Veremos en este post, como poder borrar las tablas de un usuario mediante una función de php.
Si pasamos el script tras comprobar que el query que borra el usuario se cumple, no tendrémos problemas en caso de que este no se haya borrado en la tabla de usuarios.
Vemos también como se pasan unos parámetros a los log y los datos se ecriben en cascada, según las tablas que ha detectado.
Espero que os seá muy útil.
/************* BORRAMOS TODAS LAS TABLAS DE USUARIO ***************/
/* Se busca las tablas en la base de datos */
/* REFERENCIA DEL USUARIO O $_SESSION['iniref'] = $_POST['ref'] */
/* $nom PARA LA CLAVE USUARIO ACOMPAÑANDA DE _ O NO */
global $db;
global $db_name;
global $nom;
$nom = strtolower($_POST['ref']);
$nom = "clb_".$_POST['ref']."%"; // SOLO COINCIDEN AL PRINCIPIO
$nom = "LIKE '$nom'";
//$consulta = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME $nom ";
$consulta = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '$db_name' AND TABLE_NAME $nom ";
$respuesta = mysqli_query($db, $consulta);
//$count = mysqli_num_rows($respuesta);
//print("* NUMERO TABLAS: ".$count."<br>");
//print("* CLAVE TABLA USUARIO: ".$nom."<br>");
lunes, 20 de abril de 2020
Php Mysql borrar tablas en cascada
Etiquetas:
PHP8.1,
PHPMYADMIN,
Programas Php,
XHTML / HTML
Php conocer navegador web del usuario
Hoy os dejo una forma sencilla de poder detectar el navegador web del usuario y poder presentar distintos parametros en base a ese dato.
Espero que os ayude.
// DETERMINO EL NAVEGADOR WEB Y PASO EL MENU ADECUADO
global $user_agent;
$user_agent = $_SERVER['HTTP_USER_AGENT'];
//getBrowser($user_agent);
$_SESSION['menu'] = getBrowser($user_agent);
function getBrowser($user_agent){
if(strpos($user_agent, 'MSIE') !== FALSE){
//return 'Internet explorer';
return "Inclu_MInd_b";
}elseif(strpos($user_agent, 'Edge') !== FALSE){ //Microsoft Edge
//return 'Microsoft Edge';
return "Inclu_MInd_b";
Espero que os ayude.
// DETERMINO EL NAVEGADOR WEB Y PASO EL MENU ADECUADO
global $user_agent;
$user_agent = $_SERVER['HTTP_USER_AGENT'];
//getBrowser($user_agent);
$_SESSION['menu'] = getBrowser($user_agent);
function getBrowser($user_agent){
if(strpos($user_agent, 'MSIE') !== FALSE){
//return 'Internet explorer';
return "Inclu_MInd_b";
}elseif(strpos($user_agent, 'Edge') !== FALSE){ //Microsoft Edge
//return 'Microsoft Edge';
return "Inclu_MInd_b";
Etiquetas:
PHP8.1,
Programas Php,
XHTML / HTML
martes, 10 de marzo de 2020
Descarga Plantillas Excel y Word Gratis
Aquí os dejo algunas plantillas de Excel que os serán muy útiles, van desde el seguimiento del ejercicio diario que realizáis, pasando por contabilidad doméstica, hasta facturación de actividad y cálculo financiero o balances de la actividad.
Recordad que en Google Drive las plantillas de Excel en ocasiones no se visualizan correctamente, pero están ok.
Espero que os sean muy útiles.
Dudas y sugerencias: JuanBarrosPazos@hotmail.es
PLANTILLAS PROPIAS:
- Plantillas Alquileres Inmobiliarios.
- Ejemplo de lista condicional y filtros avanzados en varias columnas
- Plantilla_Ejercicio_Anual.xls
- Plantilla_Ejercicio_Inter_Anual.xlsx
- Plantilla_Gastos_Domesticos_Anual.xls
Recordad que en Google Drive las plantillas de Excel en ocasiones no se visualizan correctamente, pero están ok.
Espero que os sean muy útiles.
Dudas y sugerencias: JuanBarrosPazos@hotmail.es
PLANTILLAS PROPIAS:
- Plantillas Alquileres Inmobiliarios.
- Ejemplo de lista condicional y filtros avanzados en varias columnas
- Plantilla_Ejercicio_Anual.xls
- Plantilla_Ejercicio_Inter_Anual.xlsx
- Plantilla_Gastos_Domesticos_Anual.xls
Etiquetas:
DESCARGAS,
EXCEL,
PLANTILLA CONTABLE,
PLANTILLA FISCAL,
PLANTILLAS EXCEL,
PLANTILLAS WORD
viernes, 31 de enero de 2020
Php sumar tiempos totales
La locura del registro del horario.
Unas lineas de código para poder sumar todos los tiempos totales:
/* TOTALES HORAS MINUTOS Y SEGUNDOS DE LA CONSULTA*/
$sh = "SELECT * FROM $vname WHERE `din` LIKE '$fil' AND `ttot` <> 'xxx' ORDER BY $orden ";
/* CALCULAMOS LAS HORAS TOTALES Y LAS PASAMOS A SEGUNDOS. */
if(!$sh){print(mysqli_error($db).".</br>");
}
else{
$qh = mysqli_query($db, $sh);
$qhr = mysqli_num_rows($qh);
$sumah = 0;
for($i=0; $i<$qhr; $i++){
$verh = mysqli_fetch_array($qh);
$verh = substr($verh['ttot'],0,2).",";
$verh = str_replace(":","",$verh);
global $sumah;
$sumah = $sumah + $verh;
}
}
$hortosec = $sumah * 3600;
//print ("</br>".$sumah);
//print ("</br>".$hortosec);
Unas lineas de código para poder sumar todos los tiempos totales:
/* TOTALES HORAS MINUTOS Y SEGUNDOS DE LA CONSULTA*/
$sh = "SELECT * FROM $vname WHERE `din` LIKE '$fil' AND `ttot` <> 'xxx' ORDER BY $orden ";
/* CALCULAMOS LAS HORAS TOTALES Y LAS PASAMOS A SEGUNDOS. */
if(!$sh){print(mysqli_error($db).".</br>");
}
else{
$qh = mysqli_query($db, $sh);
$qhr = mysqli_num_rows($qh);
$sumah = 0;
for($i=0; $i<$qhr; $i++){
$verh = mysqli_fetch_array($qh);
$verh = substr($verh['ttot'],0,2).",";
$verh = str_replace(":","",$verh);
global $sumah;
$sumah = $sumah + $verh;
}
}
$hortosec = $sumah * 3600;
//print ("</br>".$sumah);
//print ("</br>".$hortosec);
Php Calcular la diferencia entre la entrada y la salida
Con este sencillo script podremos calculas la diferencia entre dos fechas distintas.
$fecha1 = new DateTime($in);//fecha inicial
$fecha2 = new DateTime($out);//fecha de cierre
global $difer;
$difer = $fecha1->diff($fecha2);
//print ($difer);
global $ttot;
$ttot = $difer->format('%H:%i:%s');
$fecha1 = new DateTime($in);//fecha inicial
$fecha2 = new DateTime($out);//fecha de cierre
global $difer;
$difer = $fecha1->diff($fecha2);
//print ($difer);
global $ttot;
$ttot = $difer->format('%H:%i:%s');
Php foreach array tridimensional asociativo
En este ejemplo podemos ver como anidando varios foreach podremos recorrer un array asociativo tridimensional, de forma sencilla.
<?php$niveles = array( 'Primaria' => array('1º','2º','3º','4º','5º','6º'), 'Secundaria'=> array('Primer Ciclo' => array('1º Eso','2º Eso'), 'Segundo Ciclo' => array('3º Eso','4º Eso')), 'Fp' => array ( 'Grado Medio' => array ( 'Artes gráficas' => array ('Impresión','Post impresión y acabados gráficos'), 'Comercio y Marqueting' => array ('Actividades comerciales'), 'Imagen y sonido' => array ('Vídeo Disc-Jockey y Sonido'), 'Informática y Comunicaciones' => array ('Sistemas Microinformáticos y Redes')), 'Grado Superior' => array ( 'Edificación Obra Civil' => array ('Diseño y Amueblamiento'), 'Electricidad Electrónica' => array ('Eficiencia Energética y Energ. Solar Térmica'), 'Hostelería Turismo' => array ('Dirección de Servicios de Restauración'), 'Informatica y Comunicaciones' => array ('Desarrollo de Aplicaciones Multiplataforma','Desarrollo de Aplicaciones Web'))) );foreach($niveles as $nivel => $nombre){
Suscribirse a:
Entradas (Atom)
