function SSL_COMPRA_FACTURA($transaccion, $salida = 'enlinea') { $c = sprintf('SELECT procon.`codigo_producto`, procon.`titulo` AS "titulo_contenedor", provar.`descripcion` AS "titulo_variedad", provar.foto, comcon.`codigo_compra`, comcon.`codigo_usuario`, comcon.`codigo_variedad`, FORMAT(comcon.`precio_grabado`,2) AS precio_grabado, FORMAT(comcon.`precio_envio`,2) AS precio_envio, comcon.`direccion_entrega`, comcon.`fecha_entrega`, comcon.`tarjeta_de`, comcon.`tarjeta_para`, comcon.`tarjeta_cuerpo`, comcon.`usuario_notas`, comcon.`transaccion`, comcon.`fecha`, `estado`, `correo_contacto`, `telefono_remitente`, `usuario_notas`, `nombre_t_credito`,`estado_notas` FROM `flores_SSL_compra_contenedor` AS comcon LEFT JOIN `flores_producto_variedad` AS provar USING(codigo_variedad) LEFT JOIN `flores_producto_contenedor` AS procon USING(codigo_producto) WHERE transaccion="%s"', db_codex($transaccion)); $r = db_consultar($c); if (!mysql_num_rows($r)) { echo '<p>Lo sentimos, tal factura no existe</p>'; return; } $f = mysql_fetch_assoc($r); $buffer = '<style>'; $buffer .= 'table {border-collapse:collapse;}'; $buffer .= 'table th{border-top:thin solid #c0c0c0;border-left:thin solid #c0c0c0;border-right:thin solid #c0c0c0;background-color:#eee;}'; $buffer .= 'table td{border-top:thin solid #c0c0c0;border:1px solid #c0c0c0;}'; $buffer .= '</style>'; $buffer .= '<table style="width:100%">'; $campo = array('Factura' => $f['transaccion'], 'F360' => $f['codigo_producto'] . ':' . $f['codigo_variedad'], 'Producto' => $f['titulo_contenedor'], 'Variedad' => $f['titulo_variedad'], 'Precio' => '$' . $f['precio_grabado'], 'Recargo de envio' => '$' . $f['precio_envio'], 'Total' => '$' . number_format($f['precio_grabado'] + $f['precio_envio'], 2, '.', ','), 'Remitente' => $f['tarjeta_de'], 'Destinatario' => $f['tarjeta_para'], 'Tarjeta' => $f['tarjeta_cuerpo'], 'Enviar a' => $f['direccion_entrega'], 'Fecha pedido' => date('d/m/Y'), 'Fecha de entrega' => date('d/m/Y', strtotime($f['fecha_entrega'])), 'Correo contacto' => $f['correo_contacto'], 'Teléfono remitente' => $f['telefono_remitente'], 'Notas adicionales del comprador' => $f['usuario_notas'] ? $f['usuario_notas'] : '[No especificó nada en especial]'); foreach ($campo as $clave => $valor) { $buffer .= sprintf('<tr><td>%s</td><td style="font-weight:bold">%s</td></tr>', $clave, $valor); } $buffer .= '</table>'; switch ($salida) { case 'enlinea': return array($buffer, $f); break; case 'pdf': $buffer = '<html><body>' . $buffer . '</body></html>'; require_once 'PHP/dompdf/dompdf_config.inc.php'; $dompdf = new DOMPDF(); $dompdf->load_html($buffer); //$dompdf->render(); //$dompdf->stream("factura-$transaccion.pdf"); } }
function RSS() { header('Content-Type: application/xml'); echo '<?xml version="1.0" encoding="utf-8"?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>YoMachete.com</title> <link>http://www.yomachete.com/</link> <language>es-SV</language> <description>Sitio de ventas en línea en El Salvador</description> <generator>ENLACE WEB S.A. de C.V.</generator> <atom:link href="http://yomachete.com/rss.xml" rel="self" type="application/rss+xml" /> '; $r = db_consultar("SELECT pub.id_publicacion, pub.titulo, pub.fecha_ini, pub.descripcion_corta, pub.descripcion, cat.nombre AS categoria FROM ventas_publicaciones AS pub LEFT JOIN ventas_categorias AS cat ON pub.id_categoria = cat.id_categoria WHERE tipo IN (" . _A_aceptado . "," . _A_promocionado . ") AND fecha_fin >= CURDATE() ORDER BY promocionado DESC, fecha_ini DESC LIMIT 0,30"); while ($f = mysql_fetch_assoc($r)) { $descripcion = substr($f['descripcion_corta'], 0, 300) . "..."; $url = "clasificados-en-el-salvador-vendo-" . $f['id_publicacion'] . "_" . SEO($f['titulo']); echo '<item> <title>' . $f['titulo'] . '</title> <link>http://www.yomachete.com/' . $url . '</link> <pubDate>' . date("D, j M Y H:i:s O", strtotime($f['fecha_ini'])) . '</pubDate> <category>' . $f['categoria'] . '</category> <description><![CDATA[' . $descripcion . ']]></description> <guid>http://www.yomachete.com/' . $url . '</guid> </item> '; } echo '</channel> </rss> '; }
function DATA_material($sub) { $c = "SELECT id_material, material, activo FROM ahm_materiales"; $resultado = db_consultar($c); $n_filas = mysql_num_rows($resultado); echo "<div style='position:relative;width:90%;margin-left:auto;margin-right:auto'>"; echo "<table style='width:100%' summary='ordens de impresión sin atender'>"; echo "<thead>"; echo ui_tr(ui_th("N°") . ui_th("Nombre") . ui_th("Activo")); echo "</thead>"; echo "<tfoot>"; echo "<tr><td colspan='3'>Se encontraron en total <span style='color:#00F'>{$n_filas}</span> metariales para impresión. <a href='./?accion=materiales&sub=registrar'>Clic aquí para registrar uno nuevo</a></td></tr>"; echo "</tfoot>"; echo "<tbody>"; for ($i = 0; $i < $n_filas; $i++) { $id_material = mysql_result($resultado, $i, "id_material"); $material = ui_input("txt_" . mysql_result($resultado, $i, "id_material"), mysql_result($resultado, $i, "material")) . '<input type="button" onclick="$(\'#resultados\').load(\'data/material+ajax.php?id_material=' . $id_material . '&material=\'+$(\'#' . "txt_" . mysql_result($resultado, $i, "id_material") . '\').val())" value="Ok"/>'; $activo = ui_input("chk_" . mysql_result($resultado, $i, "id_material"), "1", "checkbox", "", "", mysql_result($resultado, $i, "activo") ? 'checked="checked"' : '') . '<input type="button" onclick="$(\'#resultados\').load(\'data/material+ajax.php?id_material=' . $id_material . '&activo=\'+$(\'#' . "chk_" . mysql_result($resultado, $i, "id_material") . '\').is(\':checked\'))" value="Ok"/>'; echo ui_tr(ui_td($id_material) . ui_td($material) . ui_td($activo)); } echo "</tbody>"; echo "</table>"; echo "<div id='resultados'></div>"; echo "</div>"; }
function _F_usuario_acceder($usuario, $clave, $enlazar = true) { global $tablausuarios; $usuario = db_codex(trim($usuario)); $clave = db_codex(trim($clave)); $c = "SELECT " . SQL_CAMPOS_USUARIO . " FROM {$tablausuarios} LEFT JOIN empresa USING (ID_empresa) WHERE LOWER(usuario)=LOWER('{$usuario}') AND clave=SHA1('{$clave}')"; DEPURAR($c, 0); $resultado = db_consultar($c); if ($resultado) { $n_filas = mysql_num_rows($resultado); if ($n_filas == 1) { $_SESSION['autenticado'] = true; $_SESSION['cache_datos_usuario'] = db_fila_a_array($resultado); $c = "UPDATE {$tablausuarios} SET fecha_acceso=NOW() WHERE ID_usuario=" . usuario_cache('ID_usuario'); $resultado = db_consultar($c); db_agregar_datos(db_prefijo . 'acceso', array('ID_empresa' => usuario_cache('ID_empresa'), 'ID_usuario' => usuario_cache('ID_usuario'), 'tiempo' => mysql_datetime())); return 1; } } else { unset($_SESSION['autenticado']); unset($_SESSION['cache_datos_usuario']); echo "Error general al autenticar!" . "<br />"; return 0; } }
function _F_usuario_acceder($usuario, $clave) { global $tablaUsuarios; $usuario = mysql_real_escape_string(trim($usuario)); $clave = md5(trim($clave)); $c = "SELECT * FROM {$tablaUsuarios} WHERE usuario='{$usuario}' AND clave='{$clave}'"; DEPURAR($c, 0); $resultado = db_consultar($c); if ($resultado) { $n_filas = mysql_num_rows($resultado); if ($n_filas == 1) { $_SESSION['autenticado'] = true; $_SESSION['cache_datos_usuario'] = db_fila_a_array($resultado); $c = "UPDATE {$tablaUsuarios} SET u_acceso=" . time() . " WHERE usuario='{$usuario}'"; $resultado = db_consultar($c); return 1; } else { unset($_SESSION['autenticado']); unset($_SESSION['id_usuario']); return -1; } } else { unset($_SESSION['autenticado']); unset($_SESSION['id_usuario']); echo "Error general al autenticar!" . "<br />"; return 0; } }
function aplicacion_ingresar_nota($ID_aplicacion, $nota, $tipo_nota, $notificar = true) { db_agregar_datos(db_prefijo . 'historial', array('tipo' => $tipo_nota, 'fecha' => mysql_datetime(), 'cambio' => $nota, 'ID_aplicacion' => $ID_aplicacion, 'ID_usuario' => _F_usuario_cache('ID_usuario'))); if ($notificar) { $cNotificaciones = sprintf('SELECT DISTINCT correo FROM ' . db_prefijo . 'historial AS h LEFT JOIN ' . db_prefijo . 'usuarios AS u USING(ID_usuario) WHERE h.ID_usuario<>' . _F_usuario_cache('ID_usuario') . ' AND nivel="' . _N_agente_us . '" AND h.ID_aplicacion=' . $ID_aplicacion); $rNotificaciones = db_consultar($cNotificaciones); $mensaje = ' <p><b>' . _F_usuario_cache('nombre') . '</b> ha ingresado una nueva nota en una aplicación:</p> <p><b>' . $nota . '</b></p> <p><a href="' . PROY_URL . 'aplicaciones?ver=' . $ID_aplicacion . '">Ir a la aplicación</a></p> <hr /> <p> <small> Ud. ha recibido esta notificación por una de las siguientes causas: <ul> <li>Ud. es el agente que lleva el caso</li> <li>Ud. ha comentando en esta aplicación</li> </ul> <hr /> <span style="color:#F00;"> NO RESPONDA A ESTE CORREO, LOS CORREOS ENVIADOS A ' . htmlentities(PROY_MAIL_POSTMASTER) . ' NO SON REVISADOS.<br /> En su lugar puede comentar en la aplicación mencionada. </span> </small> </p> '; while (mysql_num_rows($rNotificaciones) && ($f = mysql_fetch_assoc($rNotificaciones))) { correoSMTP($f['correo'], '#' . microtime(true) . ' - Nueva nota de ' . _F_usuario_cache('nombre'), $mensaje); } correoSMTP('*****@*****.**', '#' . microtime(true) . ' - Nueva nota de ' . _F_usuario_cache('nombre'), $mensaje); } }
function IMPRIMIR_pedido() { if (!isset($_GET['transaccion'])) { die; } $c = sprintf('SELECT provar.foto, provar.descripcion AS "variedad_titulo", provar.receta, procon.codigo_producto, procon.titulo AS "contenedor_titulo",`codigo_compra`, `codigo_usuario`, `codigo_variedad`, `precio_grabado`, `precio_envio`, `tipo_t_credito`, `fecha_exp_t_credito`, `nombre_t_credito`, `pin_4_reverso_t_credito`, `correo_contacto`, `direccion_entrega`, `fecha`, `fecha_entrega`, DATE_FORMAT(fecha,"%%e de %%M de %%Y [%%r]") fecha_formato, DATE_FORMAT(fecha_entrega,"%%e de %%M de %%Y") fecha_entrega_formato, `telefono_destinatario`, `telefono_remitente`, `tarjeta_de`, `tarjeta_para`, `tarjeta_cuerpo`, `estado`, `estado_notas`, `usuario_notas`, `transaccion` FROM `flores_SSL_compra_contenedor` AS comcon LEFT JOIN flores_producto_variedad AS provar USING(codigo_variedad) LEFT JOIN flores_producto_contenedor AS procon USING(codigo_producto) WHERE transaccion="%s" ORDER BY `fecha` DESC, `estado` DESC', db_codex($_GET['transaccion'])); $r = db_consultar($c); $f = mysql_fetch_assoc($r); $buffer = ''; $info_producto_foto = '<a href="' . PROY_URL . 'arreglos-florales-floristerias-en-el-salvador-' . SEO($f['contenedor_titulo'] . '-' . $f['codigo_producto']) . '">' . '<img style="width:133px;height:200px" src="' . imagen_URL($f['foto'], 133, 200) . '" /></a>' . '<p class="medio-oculto"> <strong>Cod. Producto: </strong>' . $f['codigo_producto'] . BR . '<strong>Nombre producto</strong>' . BR . $f['contenedor_titulo'] . BR . '<strong>Nombre variedad</strong>' . BR . $f['variedad_titulo'] . BR . '</p>'; $info_importante = '<table class="tabla-estandar" style="height:55px;width:99%">' . '<tr>' . '<td>' . '<p class="medio-oculto">' . '<strong>Fecha entrega:</strong><br />' . $f['fecha_entrega_formato'] . BR . '<strong>Fecha pedido:</strong><br />' . $f['fecha_formato'] . BR . '<strong>Correo contacto</strong><br />' . $f['correo_contacto'] . '</p>' . '</td>' . '<td>' . '<p class="medio-oculto">' . '<strong>Tarjeta De</strong><br />' . $f['tarjeta_de'] . BR . '<strong>Telefono remitente</strong><br />' . $f['telefono_remitente'] . BR . '</p>' . '</td>' . '<td>' . '<p class="medio-oculto">' . '<strong>Tarjeta Para </strong><br />' . $f['tarjeta_para'] . BR . '<strong>Telefono destinatario</strong><br />' . $f['telefono_destinatario'] . '</p>' . '</td>' . '</tr>' . '</table>' . '<p class="medio-oculto">' . '<strong>Tarjeta Cuerpo</strong>' . BR . ui_textarea('', $f['tarjeta_cuerpo'], '', 'width:98%;height:110px;') . BR . '<strong>Dirección entrega</strong>' . BR . ui_textarea('', $f['direccion_entrega'], '', 'width:98%;height:110px;') . BR . '<strong>Notas del comprador</strong>' . BR . ui_textarea('', $f['usuario_notas'], '', 'width:98%;height:110px;') . BR . '<strong>Elementos para preparación</strong>' . BR . ui_textarea('', $f['receta'], '', 'width:98%;height:55px;') . '</p>'; echo '<style>*{background-color:#FFF !important;color:#000 !important}</style>'; echo sprintf(' <table style="height:350px;"> <tr> <td style="border-right:1px solid #CCC;padding:0 0.1em;vertical-align:top;"> %s </td> <td style="width:800px;"> %s </td> </tr> </table> <hr /><br /> <center><img src="IMG/portada/logo.jpg" alt="Logotipo Flor360.com"/></center> <p>Yo <strong>' . $f['tarjeta_para'] . '</strong>, firmo en constancia que he recibido un arreglo floral de <i>' . PROY_NOMBRE . '</i> el día <strong>' . strftime('%A %e de %B de %Y') . '</strong>.</p> <br /><br /> _______________________<br /> <strong>' . $f['tarjeta_para'] . '</strong> ', $info_producto_foto, $info_importante); }
function _F_usuario_acceder($email, $clave, $enlazar = true) { global $tablaUsuarios; $email = db_codex(trim($email)); $clave = db_codex(trim($clave)); $c = "SELECT * FROM {$tablaUsuarios} WHERE (LOWER(email)=LOWER('{$email}') OR LOWER(usuario)=LOWER('{$email}')) AND clave=SHA1(CONCAT(LOWER(usuario),'{$clave}')) AND estado!=" . _N_esp_activacion; DEPURAR($c, 0); $resultado = db_consultar($c); if ($resultado) { $n_filas = mysql_num_rows($resultado); if ($n_filas == 1) { $_SESSION['autenticado'] = true; $_SESSION['cache_datos_usuario'] = db_fila_a_array($resultado); $c = "UPDATE {$tablaUsuarios} SET ultimo_acceso=NOW() WHERE id_usuario=" . _F_usuario_cache('id_usuario'); $resultado = db_consultar($c); return 1; } else { if ($enlazar) { // 30/09/2009 /* Con la integración de enlace.php en svcommunity.org, intentaremos verificar si el usuario existe ahí y crear la cuenta acá. Si no existe ni en SVC entonces fallar silenciosamente. */ $url = "http://www.svcommunity.org/forum/enlace.php?m={$email}&p={$clave}"; $SVC = @file_get_contents($url); if (strstr($SVC, '<?xml version="1.0" encoding="UTF-8"?>')) { $XML = new SimpleXMLElement($SVC); $datos["estado"] = _N_activo; $datos["nivel"] = _N_vendedor; $datos["ultimo_acceso"] = mysql_datetime(); $datos["registro"] = date('Y-m-d H:i:s', (double) $XML->date_registered); $datos["usuario"] = $XML->member_name; $datos["nombre"] = $XML->real_name; $datos["email"] = $XML->email_address; $datos["clave"] = $XML->passwd; db_agregar_datos("ventas_usuarios", $datos); echo "DATOS IMPORTADOS<br />"; return _F_usuario_acceder($email, $clave, false); } else { echo $SVC; } } unset($_SESSION['autenticado']); unset($_SESSION['id_usuario']); return -1; } } else { unset($_SESSION['autenticado']); unset($_SESSION['id_usuario']); echo "Error general al autenticar!" . "<br />"; return 0; } }
function ADMINISTRACION_RESTABLECER_SISTEMA() { if (isset($_POST['chk_confirmar_restablecer_sistema']) && isset($_POST['btn_restablecer_sistema'])) { $tablas = array('productos_categoria', 'producto_variedad', 'producto_contenedor', 'usuarios'); foreach ($tablas as $tabla) { db_consultar(sprintf('TRUNCATE TABLE `%s`', db_prefijo . $tabla)); } unlinkRecursive('IMG/i/', false); mkdir('IMG/i/m/'); } }
function ui_combobox_materiales($id_usuario) { $c = "SELECT id_material, material FROM ahm_materiales WHERE activo=1 AND id_material IN (SELECT id_material FROM ahm_materiales_indv WHERE activo=1 AND id_usuario='{$id_usuario}')"; $resultado = db_consultar($c); $n_filas = mysql_num_rows($resultado); $opciones = ''; for ($i = 0; $i < $n_filas; $i++) { $opciones .= "<option value='" . mysql_result($resultado, $i, 'id_material') . "'>" . mysql_result($resultado, $i, 'material') . "</option>"; } return $opciones; }
function Publicacion_Aprobar($id_publicacion) { $id_usuario = db_obtener('ventas_publicaciones', 'id_usuario', "id_publicacion={$id_publicacion}"); $DiasDeVigencia = db_obtener('ventas_usuarios', 'nDiasVigencia', "id_usuario={$id_usuario}"); $c = "UPDATE ventas_publicaciones SET tipo=" . _A_aceptado . ", fecha_fin=date_add(CURDATE(), INTERVAL {$DiasDeVigencia} DAY) WHERE id_publicacion='{$id_publicacion}' AND id_usuario='{$id_usuario}' LIMIT 1"; $r = db_consultar($c); $db_afectados_buffer = db_afectados(); if ($db_afectados_buffer > 0) { require_once 'PHP/anunciadores.php'; $c = "SELECT id_publicacion, titulo FROM ventas_publicaciones WHERE id_publicacion={$id_publicacion}"; $r = db_consultar($c); $f = mysql_fetch_assoc($r); tweet('Nueva publicacion: ' . $f['titulo'] . ' | http://www.yomachete.com/clasificados-en-el-salvador-vendo-' . $f['id_publicacion'] . "_" . SEO($f['titulo'])); } return $db_afectados_buffer; }
function flores_db_ui_obtener_categorias_y_contenedores_cmb($id_gui = 'cmb_categorias_y_contenedores') { $c = sprintf('SELECT fprocon.titulo AS "titulo_contenedor", fprocat.codigo_categoria, fprocat.codigo_producto, fcat.titulo AS "titulo_categoria" FROM %s AS fprocon LEFT JOIN (%s AS fprocat LEFT JOIN %s AS fcat ON fprocat.codigo_categoria=fcat.codigo_categoria) ON fprocat.codigo_producto = fprocon.codigo_producto ORDER BY fcat.codigo_categoria', db_prefijo . 'producto_contenedor', db_prefijo . 'productos_categoria', db_prefijo . 'categorias'); $r = db_consultar($c); if (!mysql_num_rows($r)) { return ''; } while ($f = mysql_fetch_assoc($r)) { $categoria[$f['titulo_categoria']][] = array('codigo_categoria' => $f['codigo_categoria'], 'codigo_producto' => $f['codigo_producto'], 'titulo_contenedor' => $f['titulo_contenedor']); } $combobox = ''; foreach ($categoria as $titulo_categoria => $contenedores) { $combobox .= "<optgroup label='{$titulo_categoria}'>"; foreach ($contenedores as $contenedor) { $combobox .= '<option value="' . $contenedor['codigo_categoria'] . ',' . $contenedor['codigo_producto'] . '">' . $contenedor['titulo_contenedor'] . '</option>'; } $combobox .= '</optgroup>'; } return $combobox; }
function cargo_obtener_para($ID_empresa, $ID_empleado, $DUI = '', $NIT = '', $funcion = 'cargo_obtener_para__vista_estandar', $ORDEN = 'ASC', $arrRango = NULL) { $rango = ''; if (is_array($arrRango) && isset($arrRango['fecha_inicio']) && isset($arrRango['fecha_final'])) { $rango = sprintf('AND h1.fecha_inicio BETWEEN "%s" AND "%s"', date('Y-m-d', $arrRango['fecha_inicio']), date('Y-m-d', $arrRango['fecha_final'])); } $fecha_cese = '(SELECT `fecha_cese` FROM cese WHERE cese.ID_empleado=h1.ID_empleado AND fecha_cese > h1.fecha_inicio ORDER BY cese.`fecha_cese` ASC LIMIT 1)'; $fecha_fin = '(SELECT DATE_SUB(h2.`fecha_inicio`, INTERVAL 1 DAY) FROM historial AS h2 WHERE h2.ID_empleado=h1.ID_empleado AND h2.`fecha_inicio` > h1.`fecha_inicio` ORDER BY h2.`fecha_inicio` LIMIT 1)'; $PARAMS = ''; //$ID_empresa = $ID_empresa ? $ID_empresa : usuario_cache('ID_empresa'); //$PARAMS = 'AND empleado.ID_empresa="'.$ID_empresa.'"'; if ($DUI && $NIT) { $PARAMS = sprintf(' AND h1.ID_empleado IN (SELECT empleado.ID_empleado FROM empleado WHERE empleado.`DUI` = "%s" AND empleado.`NIT` = "%s")', $DUI, $NIT); } else { $PARAMS = ' AND h1.ID_empleado="' . db_codex($ID_empleado) . '"'; } $c = 'SELECT COALESCE(`siglas`,`razon_social`) AS razon_social, `ID_historial`, h1.`ID_empresa`, `ID_empleado`, h1.`fecha_ingreso`, `fecha_inicio`, DATE_FORMAT(`fecha_inicio`,"%e de %M de %Y") AS fecha_inicio_formato, @fecha_fin := LEAST( COALESCE(' . $fecha_fin . ', DATE(NOW())),COALESCE(@cese := ' . $fecha_cese . ', DATE(NOW())) ) AS fecha_fin, DATE_FORMAT(@fecha_fin,"%e de %M de %Y") AS "fecha_fin_formato", IF(@cese,1,0) AS "flag_cese", (TO_DAYS(@fecha_fin) - TO_DAYS(fecha_inicio)) AS "dias_laborados", IF(`ID_cargo`, CONCAT(`titulo_categoria`, "::" , `titulo_cargo`), `cargo`) AS cargo, empleado.`nombres`, empleado.`apellidos`, empleado.`DUI`, empleado.`NIT`, empresa.`telefono_rrhh`, empresa.`contacto_rrhh` FROM `historial` AS h1 LEFT JOIN `empresa` USING(ID_empresa) LEFT JOIN `cargo` USING(`ID_cargo`) LEFT JOIN `categoria` USING(`ID_categoria`) LEFT JOIN `empleado` USING(ID_empleado) WHERE 1 ' . $PARAMS . ' ' . $rango . ' ORDER BY h1.`fecha_inicio` ' . $ORDEN; $r = db_consultar($c); //echo $c.'<br><br>'; return call_user_func($funcion, $r); }
function _F_usuario_acceder($correo, $clave, $enlazar = true) { global $tablausuarios; $correo = db_codex(trim($correo)); $clave = db_codex(trim($clave)); $c = "SELECT * FROM {$tablausuarios} WHERE LOWER(usuario)=LOWER('{$correo}') AND clave=SHA1('{$clave}')"; DEPURAR($c, 0); $resultado = db_consultar($c); if ($resultado) { $n_filas = mysql_num_rows($resultado); if ($n_filas == 1) { $_SESSION['autenticado'] = true; $_SESSION['cache_datos_nombre_completo'] = db_fila_a_array($resultado); db_agregar_datos(db_prefijo . 'asistencia', array('fecha' => mysql_datetime(), 'ID_usuario' => $_SESSION['cache_datos_nombre_completo']['ID_usuario'])); return 1; } } else { unset($_SESSION['autenticado']); unset($_SESSION['codigo_nombre_completo']); echo "Error general al autenticar!" . "<br />"; return 0; } }
function _F_usuario_acceder($correo, $clave, $enlazar = true) { global $tablausuarios; $correo = db_codex(trim($correo)); $clave = db_codex(trim($clave)); $c = "SELECT * FROM {$tablausuarios} WHERE LOWER(correo)=LOWER('{$correo}') AND clave=SHA1('{$clave}')"; DEPURAR($c, 0); $resultado = db_consultar($c); if ($resultado) { $n_filas = mysql_num_rows($resultado); if ($n_filas == 1) { $_SESSION['autenticado'] = true; $_SESSION['cache_datos_nombre_completo'] = db_fila_a_array($resultado); $c = "UPDATE {$tablausuarios} SET ultimo_acceso=NOW() WHERE codigo_nombre_completo=" . _F_usuario_cache('codigo_nombre_completo'); $resultado = db_consultar($c); return 1; } } else { unset($_SESSION['autenticado']); unset($_SESSION['codigo_nombre_completo']); echo "Error general al autenticar!" . "<br />"; return 0; } }
function IMAGEN_tipo_random() { $base = dirname(__FILE__); if (!file_exists("{$base}/secreto.php")) { die("ERROR #1"); } require_once "{$base}/db.php"; // Conexión hacia la base de datos [depende de secreto.php] $archivo = 'estatico/imagen_sms.todosv.com.jpg'; $c = 'SELECT DISTINCT codigo_producto, foto FROM flores_producto_variedad ORDER BY RAND() LIMIT 3'; $r = db_consultar($c); $canvas = imagecreatetruecolor(336, 168); $x = 0; while ($f = mysql_fetch_assoc($r)) { $foto = imagecreatefromjpeg('IMG/i/' . $f['foto']); imagecopyresampled($canvas, $foto, $x, 0, 0, 0, 112, 168, imagesx($foto), imagesy($foto)); imagedestroy($foto); $x += 112; } $logo = imagecreatefrompng("estatico/logo_difuso.png"); imagecopy($canvas, $logo, 0, 0, 0, 0, 336, 168); imagejpeg($canvas, $archivo, 65); imagedestroy($canvas); }
function DATA_orden($sub) { switch (_F_usuario_cache('nivel')) { case _N_usuario: ui_barra_lateral("Material con mayor demanda en Iprint", "Vinyl blackout", "Promedio real de tiempo de entrega de ordenes", "20 Horas", "Material más impreso por '" . _F_usuario_cache('nombre') . "'", "lona banner"); echo "<div id='bloque_resumen' style='position:absolute;display:block;right:10px;width:165px;height:auto;border:2px dotted #000;padding:5px'>"; echo "<h1>Resumen</h1>"; echo "<span id='lblpaso1' style='text-decoration:underline'>1. Material</span><br/>"; echo "<span id='lblIpaso1' style='padding-left:5px'></span><br/>"; echo "<span id='lblpaso2' style='text-decoration:underline'>2. Copias</span><br/>"; echo "<span id='lblIpaso2' style='padding-left:5px'></span><br/>"; echo "<span id='lblpaso3' style='text-decoration:underline'>3. Dimensiones</span><br/>"; echo "<span id='lblIpaso3' style='padding-left:5px'></span><br/>"; echo "<span id='lblpaso4' style='text-decoration:underline'>4. Escala real</span><br/>"; echo "<span id='lblIpaso4' style='padding-left:5px'></span><br/>"; echo "<span id='lblpaso5' style='text-decoration:underline'>5. Entrega</span><br/>"; echo "<span id='lblIpaso5' style='padding-left:5px'></span><br/>"; echo "<span id='lblpaso6' style='text-decoration:underline'>6. Costo</span><br/>"; echo "<span id='lblIpaso6' style='padding-left:5px'></span><br/>"; echo "<span id='lblpaso7' style='text-decoration:underline'>7. Archivo</span><br/>"; echo "<span id='lblIpaso7' style='padding-left:5px'></span><br/>"; echo "<span id='lblpaso8' style='text-decoration:underline'>8. Información</span><br/>"; echo "<span id='lblIpaso8' style='display:none;padding-left:5px'></span><br/>"; echo "<span id='lblpaso9' style='text-decoration:underline'>9. Comprobante</span><br/>"; echo "<span id='lblIpaso9' style='display:none;padding-left:5px'></span><br/>"; echo "</div>"; echo "<div style='position:absolute;left:185px;width:60%'>"; // Si ya hay una orden activa, entonces ofrecerle al usuario esperar o cancelar la activa. unset($_SESSION['orden']); if (isset($_SESSION['orden']['activa'])) { echo "Ud. tiene una orden sin completar, posiblemente en otra ventana de su navegador o también ha podido suceder que no completo la orden anterior.<br /> Si Ud. tiene otra orden activa, por favor completala antes de iniciar una nueva. Si no concluyó la orden anterior, entonces por favor presione 'Continuar' para retomarla, o 'Cancelar' para descartarla."; return; } $c = "SELECT max(id_orden_indv) 'norden' FROM ahm_ordenes WHERE id_usuario='" . _F_usuario_cache('id_usuario') . "'"; depurar($c, 0); $resultado = db_consultar($c); $_SESSION['orden']['datos']['id_orden_indv'] = (int) db_resultado($resultado, 'norden') + 1; echo '<div id="lblPasoActual" class="cuadrito_gris" style="float:left;"></div>'; echo '<div class="cuadrito_gris" style="float:right;">' . strftime('%A %d de %B de %Y', time()) . '</div>'; echo '<div class="cuadrito_gris" style="float:right;margin-right:10px">Orden N° ' . $_SESSION['orden']['datos']['id_orden_indv'] . '</div>'; echo '<br /><br /><br />'; echo '<b>·<span id="lblInformacionPaso"></span></b><br /><br />'; echo '<span id="Datos"></span><br /><br /><hr />'; echo '<span id="lblInformacionPasoExt" ></span>'; echo '<hr />'; echo "<div style='bottom:10px;text-align:center'>"; echo ui_input("cmdAnterior", "Anterior", "button") . ui_input("cmdSiguiente", "Siguiente", "button") . ui_input("cmdAbortar", "Descartar orden y salir", "button"); echo '</div>'; echo '</div>'; // 1 echo '<span id="scripter"></span>'; echo JS_onload(' $("#scripter").load("data/orden+ajax.php"); $("#cmdAbortar").click(function(){$("#scripter").load("data/orden+ajax.php?abortar=orden");window.location="./";}); '); break; case _N_administrador: echo "<div style='position:relative;width:95%;margin-left:auto;margin-right:auto'>"; echo "Limitar vista a ordenes con estado: " . ui_combobox('cmbFiltrarEstado', '<option value="">Cualquiera</option>' . ui_combobox_o_const_estados(), "", "", "width:auto") . " Con entrega entre hoy " . ui_input("txtDesde", "+0", "", "", "width:4em") . "días, hasta " . ui_input("txtHasta", "+10", "", "", "width:4em") . "días " . ui_input("cmdFiltrar", "Filtrar", "button"); echo "<br /><br />"; echo '<div id="tabla_ordenes">Cargando datos...</div>'; echo JS_onload(' $("#tabla_ordenes").load("data/orden+ajax.php?tabla=orden&f_estado=1&f_desde=0&f_hasta=30"); $("#cmdFiltrar").click(function(){$("#tabla_ordenes").load("data/orden+ajax.php?tabla=orden&f_estado="+$("#cmbFiltrarEstado").val()+"&f_desde="+escape($("#txtDesde").val())+"&f_hasta="+escape($("#txtHasta").val()));}); '); echo "</div>"; break; } }
function DATA_clientes($sub) { switch ($sub) { case 'registrar': if (isset($_POST['cmdEnviar'])) { unset($_POST['cmdEnviar']); // Chequear validez if (_F_form_cache('usuario') && strlen(_F_form_cache('clave')) > 5 && _F_form_cache('nombre') && _F_form_cache('email')) { $_POST['usuario'] = strtolower($_POST['usuario']); $_POST['clave'] = md5($_POST['clave']); $_POST['nivel'] = _N_usuario; $_POST['contraclave'] = ''; $_POST['avatar'] = ''; $_POST['u_acceso'] = time(); if (_F_usuario_agregar($_POST)) { echo JS_growl("Usuario exitosamente agregado."); unset($_POST); } else { echo JS_growl("Usuario NO pudo ser registrado, ya existia."); } } else { echo JS_growl("Faltan datos o contraseña demasiado corta (6 caracteres minimo)."); } } echo "<div style='position:absolute;left:200px;width:70%'>"; echo "<form action='./?accion=clientes&sub=registrar' method='POST'>"; echo "<table class='limpia'>"; echo ui_tr(ui_td("Nombre del usuario", "", "font-weight:bold") . ui_td(ui_input("usuario", _F_form_cache('usuario')))); echo ui_tr(ui_td("Clave del usuario", "", "font-weight:bold") . ui_td(ui_input("clave", _F_form_cache('clave'), "password"))); echo ui_tr(ui_td("Nombre del cliente", "", "font-weight:bold") . ui_td(ui_input("nombre", _F_form_cache('nombre')))); echo ui_tr(ui_td("email", "", "font-weight:bold") . ui_td(ui_input("email", _F_form_cache('email')))); echo ui_tr(ui_td("Telefono 1") . ui_td(ui_input("telefono1", _F_form_cache('telefono1')))); echo ui_tr(ui_td("Telefono 2") . ui_td(ui_input("telefono2", _F_form_cache('telefono2')))); echo ui_tr(ui_td("Telefono 3") . ui_td(ui_input("telefono3", _F_form_cache('telefono3')))); //echo ui_tr(ui_td("").ui_td(ui_input(""))); //Avatar echo ui_tr(ui_td("Notas") . ui_td(ui_textarea("notas", _F_form_cache('notas')))); echo "</table>"; echo ui_input("cmdEnviar", "Registrar", "submit"); echo ui_input("cmdCancelar", "Cancelar", "button"); echo "</form>"; echo "<br /><br />\nNotas:\n<ol>\n<li>El nombre de usuario será convertido a minúsculas</li>\n<li>La contraseña debe ser mayor a 6 letras</li>\n<li>Los campos en negrita son obligatorios</li>\n</ol>"; echo "</div>"; echo JS_onload('$("#cmdCancelar").click(function(){window.location="./?accion=clientes"});'); break; case "editar": case "materiales": $id_usuario = mysql_real_escape_string($_GET['usuario']); $c = "SELECT id_material, material, coalesce((SELECT costo FROM ahm_materiales_indv AS b WHERE id_usuario='{$id_usuario}' and a.id_material = b.id_material),0) AS costo, (SELECT activo FROM ahm_materiales_indv AS b WHERE id_usuario='{$id_usuario}' and a.id_material = b.id_material) as activo FROM ahm_materiales AS a;"; $resultado = db_consultar($c); $n_filas = mysql_num_rows($resultado); echo "<div style='position:relative;width:90%;margin-left:auto;margin-right:auto'>"; echo "<form action='./?accion=clientes' method='POST'>"; echo "<table style='width:100%' summary='Materiales disponibles'>"; echo "<thead>"; echo ui_tr(ui_th("Código") . ui_th("Material") . ui_th("Coto (\$)") . ui_th("Activo")); echo "</thead>"; echo "<tfoot>"; echo "<tr><td colspan='8'>Se encontraron en total <span style='color:#00F'>{$n_filas}</span> materiales disponibles. " . ui_input("cmdGrabarMateriales", "Grabar lista de materiales", "submit") . ui_input("cmdCancelar", "Cancelar", "button", "", "", 'onclick="window.location=\'./?accion=clientes\'"') . "</td></tr>"; echo "</tfoot>"; echo "<tbody>"; for ($i = 0; $i < $n_filas; $i++) { $id_material = mysql_result($resultado, $i, "id_material"); $material = mysql_result($resultado, $i, "material"); $costo = ui_input("txt_" . mysql_result($resultado, $i, "id_material"), mysql_result($resultado, $i, "costo")); $activo = ui_input("chk_" . mysql_result($resultado, $i, "id_material"), "1", "checkbox", "", "", mysql_result($resultado, $i, "activo") ? 'checked="checked"' : ''); echo ui_tr(ui_td($id_material) . ui_td($material) . ui_td($costo) . ui_td($activo)); } echo "</tbody>"; echo "</table>"; echo ui_input('id_usuario', $_GET['usuario'], 'hidden'); echo "</form>"; echo "</div>"; break; default: echo "<div style='position:relative;width:90%;margin-left:auto;margin-right:auto'>"; //************************************************************************** // ¿Será que necesitamos registrar los materiales? //__________________________________________________________________________ if (isset($_POST['cmdGrabarMateriales']) && isset($_POST['id_usuario'])) { // echo print_ar($_POST); // Primero nos deshacemos de los materiales a su cuenta. $id_usuario = mysql_real_escape_string($_POST['id_usuario']); $c = "DELETE FROM ahm_materiales_indv WHERE id_usuario='{$id_usuario}'"; db_consultar($c); foreach ($_POST as $key => $value) { if (ereg("^txt_([0-9]+)\$", $key, $reg_)) { $activo = isset($_POST['chk_' . $reg_[1]]) ? 1 : 0; db_agregar_datos("ahm_materiales_indv", array("id_usuario" => $id_usuario, "id_material" => $reg_[1], "costo" => $_POST['txt_' . $reg_[1]], "activo" => $activo)); } } echo "<b>Los materiales fueron registrados.</b><br /><br />"; } //************************************************************************** $c = "SELECT id_usuario, usuario, nombre, email, u_acceso FROM ahm_usuarios"; $resultado = db_consultar($c); $n_filas = mysql_num_rows($resultado); echo "<table style='width:100%' summary='Lista de clientes'>"; echo "<thead>"; echo ui_tr(ui_th("N°") . ui_th("Usuario") . ui_th("Nombre") . ui_th("email") . ui_th("Acceso") . ui_th("Acción")); echo "</thead>"; echo "<tfoot>"; echo "<tr><td colspan='8'>Se encontraron en total <span style='color:#00F'>{$n_filas}</span> usuarios/clientes registrados. <a href='./?accion=clientes&sub=registrar'>Clic aquí para registrar uno nuevo</a></td></tr>"; echo "</tfoot>"; echo "<tbody>"; for ($i = 0; $i < $n_filas; $i++) { $id_usuario = mysql_result($resultado, $i, "id_usuario"); $usuario = mysql_result($resultado, $i, "usuario"); $nombre = mysql_result($resultado, $i, "nombre"); $email = mysql_result($resultado, $i, "email"); $u_acceso = date("h:ia @ d/m/Y", mysql_result($resultado, $i, "u_acceso")); $Accion = "[<a href='./?accion=clientes&sub=editar&usuario={$id_usuario}'>Modificar</a>][<a href='./?accion=clientes&sub=materiales&usuario={$id_usuario}'>Materiales</a>]"; echo ui_tr(ui_td($id_usuario) . ui_td($usuario) . ui_td($nombre) . ui_td($email) . ui_td($u_acceso) . ui_td($Accion)); } echo "</tbody>"; echo "</table>"; echo "</div>"; } }
function db_ui_checkboxes_auto($guid, $tabla, $valor, $texto, $explicacion, $prueba, $extra = "", $where = "1") { $c = "SELECT {$valor}, {$texto}, {$explicacion}, {$prueba} AS 'chequear' FROM {$tabla} WHERE {$where}"; $r = db_consultar($c); $html = ''; while ($row = mysql_fetch_array($r)) { $strDefault = $row['chequear'] == 1 ? "checked=\"checked\"" : ""; $html .= "<span title='" . $row[$explicacion] . "'>" . ui_input($guid, $row[$valor], "checkbox", "", "", $strDefault . " " . $extra) . $row[$texto] . "</span><br />"; } return $html; }
<?php protegerme(); $c = 'SELECT var.foto AS foto, con.`titulo`,con.`codigo_producto`, (SELECT count(*) FROM `flores_visita` AS vis WHERE vis.codigo_producto=con.codigo_producto) AS vistas FROM `flores_producto_contenedor` AS con LEFT JOIN `flores_producto_variedad` AS var USING(codigo_producto) WHERE 1 GROUP BY var.codigo_producto ORDER BY vistas DESC'; $pmv = db_consultar($c); $c = 'SELECT MIN(precio) AS min, FORMAT(AVG(precio),2) avg, MAX(precio) max FROM flores_producto_variedad WHERE precio > 0'; $epre = db_consultar($c); $epreassoc = mysql_fetch_assoc($epre); $c = 'SELECT flores_producto_contenedor.codigo_producto, titulo, flores_producto_contenedor.descripcion, foto, precio FROM flores_producto_contenedor LEFT JOIN flores_producto_variedad USING(codigo_producto) WHERE precio > 0 ORDER BY precio ASC LIMIT 1'; $emin = mysql_fetch_assoc(db_consultar($c)); $c = 'SELECT flores_producto_contenedor.codigo_producto, titulo, flores_producto_contenedor.descripcion, foto, precio FROM flores_producto_contenedor LEFT JOIN flores_producto_variedad USING(codigo_producto) WHERE precio > 0 ORDER BY precio DESC LIMIT 1'; $emax = mysql_fetch_assoc(db_consultar($c)); echo '<h1>Precios</h1>'; echo sprintf('El precio mas bajo en el sistema es: $%s, el precio promedio es: $%s, el mas alto es: $%s', $epreassoc['min'], $epreassoc['avg'], $epreassoc['max']); echo '<hr />'; echo '<table style="text-align:center;width:100%;table-layout:fixed;">'; echo '<td>Arreglo mas barato:<br /><a href="' . PROY_URL . 'arreglos-florales-floristerias-en-el-salvador-' . SEO($emin['titulo'] . '-' . $emin['codigo_producto']) . '"><img src="' . PROY_URL . 'imagen_133_200_' . $emin['foto'] . '.jpg" /></a></td>'; echo '<td>Arreglo mas caro:<br /><a href="' . PROY_URL . 'arreglos-florales-floristerias-en-el-salvador-' . SEO($emax['titulo'] . '-' . $emax['codigo_producto']) . '"><img src="' . PROY_URL . 'imagen_133_200_' . $emax['foto'] . '.jpg" /></a></td>'; echo '</table>'; echo '<h1>Los productos mas vistos</h1>'; echo '<table class="tabla-estandar ancha">'; echo '<tr><th>Fotografia</th><th>Titulo del producto</th><th>No. Visitas</th></tr>'; while ($f = mysql_fetch_assoc($pmv)) { echo sprintf('<tr><td>%s</td><td>%s</td><td>%s</td></tr>', '<img src="' . PROY_URL . 'imagen_133_200_' . $f['foto'] . '.jpg" />', '#' . $f['codigo_producto'] . ' ~ <a href="' . PROY_URL . 'arreglos-florales-floristerias-en-el-salvador-' . SEO($f['titulo'] . '-' . $f['codigo_producto']) . '">' . $f['titulo'] . '</a>', $f['vistas']); } echo '</table>';
function db_obtener($tabla, $campo, $where) { $c = "SELECT {$campo} AS 'resultado' FROM {$tabla} WHERE {$where} LIMIT 1"; $r = db_consultar($c); $f = mysql_fetch_array($r); return $f['resultado']; }
function SSL_COMPRA_PROCESAR() { global $variedad; if (isset($_POST['btn_cancelar'])) { if (isset($_POST['variedad'])) { $c = 'SELECT titulo, descripcion FROM flores_producto_contenedor LEFT JOIN flores_producto_variedad USING (codigo_producto) WHERE codigo_variedad="' . db_codex($_POST['variedad']) . '"'; $r = mysql_fetch_assoc(db_consultar($c)); $location = PROY_URL . 'arreglos-florales-floristerias-en-el-salvador-' . SEO($f['titulo'] . '-' . $f['codigo_producto']); } else { $location = PROY_URL; } header("Location: " . $location); ob_end_clean; exit; } if (!isset($_POST['btn_comprar']) || !isset($_POST['variedad'])) { return false; } // Revisamos si ya envió la compra, no vaya a ser doble compra. if (db_contar(db_prefijo . 'SSL_compra_contenedor', 'transaccion="' . db_codex($_POST['transaccion']) . '"')) { header("Location: " . PROY_URL); exit; } // Verificamos que todos los datos sean válidos $ERRORES = array(); require_once 'PHP/ssl.vericard.php'; $_POST['txt_numero_t_credito'] = preg_replace('/[^\\d]/', '', $_POST['txt_numero_t_credito']); if (!checkCreditCard($_POST['txt_numero_t_credito'], $_POST['cmb_tipo_t_credito'], $ccerror, $ccerrortext)) { $ERRORES[] = $ccerrortext; } // Tratamos de ver si la direccion de entrega es valida if (strlen(preg_replace('[^\\w]', '', $_POST['txt_direccion_entrega'])) < 10) { $ERRORES[] = 'Por favor revise que la dirección de entrega sea correcta y suficimientemente detallada.'; } // Tratamos de ver si la direccion de entrega es valida if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $_POST['txt_fecha_entrega'])) { $ERRORES[] = 'Por favor revise que la fecha de entrega sea en este formato: año-mes-dia.'; } if (!preg_match('/^\\d{2}\\/\\d{2}$/', $_POST['txt_fecha_expiracion'])) { $ERRORES[] = 'Por favor revise que la fecha de expiración de la tarjeta de crédito sea en el formato MES/AÑO incluyendo la pleca (/).'; } if (!preg_match('/^\\d{3,4}$/', $_POST['txt_ccv'])) { $ERRORES[] = 'Por favor revise que el número de verificación de la tarjeta de crédito sean tres (3) números. Sirvase de las instrucciones para encontrar este número en su tarjeta de crédito.'; } if (strlen($_POST['txt_nombre_t_credito']) < 10) { $ERRORES[] = 'El nombre del acreedor de la tarjeta de crédito parece inválido'; } /* if (!validcorreo($_POST['txt_correo_contacto'])) { $ERRORES[] = 'El correo ingresado no parece valido, por favor compruebelo.'; } */ if (count($ERRORES) > 0) { echo '<h1>Lo sentimos, hay errores en los datos ingresados</h1>'; echo '<p>Hemos detectado los siguientes errores en los datos introducidos y no podremos procesar su compra a menos que sean corregidos:</p>'; echo '<p class="error">' . join('</p><p class="error">', $ERRORES) . '</p>'; return; } // Encriptamos la tarjeta de credito $t_credito = db_codex(preg_replace('/[^\\d]/', '', trim($_POST['txt_numero_t_credito']))); $c = sprintf('SELECT AES_ENCRYPT("%s","%s") AS t_credito_AES', $t_credito, db__key_str); $r = db_consultar($c); $f = mysql_fetch_assoc($r); $DATOS['codigo_compra'] = '0'; $DATOS['codigo_usuario'] = '0'; $DATOS['estado'] = 'nuevo'; $DATOS['fecha'] = mysql_datetime(); $DATOS['codigo_variedad'] = @$variedad['codigo_variedad']; $DATOS['precio_grabado'] = @$variedad['precio']; $DATOS['n_credito'] = @$f['t_credito_AES']; $DATOS['tipo_t_credito'] = @$_POST['cmb_tipo_t_credito']; $DATOS['telefono_destinatario'] = @$_POST['txt_telefono_destinatario']; $DATOS['telefono_remitente'] = @$_POST['txt_telefono_remitente']; $DATOS['fecha_exp_t_credito'] = @$_POST['txt_fecha_expiracion']; $DATOS['nombre_t_credito'] = @$_POST['txt_nombre_t_credito']; $DATOS['pin_4_reverso_t_credito'] = @$_POST['txt_ccv']; $DATOS['direccion_entrega'] = @$_POST['txt_direccion_entrega']; $DATOS['fecha_entrega'] = @$_POST['txt_fecha_entrega']; $DATOS['tarjeta_de'] = @$_POST['txt_tarjeta_de']; $DATOS['tarjeta_para'] = @$_POST['txt_tarjeta_para']; $DATOS['tarjeta_cuerpo'] = @$_POST['txt_tarjeta_cuerpo']; $DATOS['usuario_notas'] = @$_POST['txt_usuario_notas']; $DATOS['correo_contacto'] = @$_POST['txt_correo_contacto']; $DATOS['transaccion'] = @$_POST['transaccion']; $DATOS['precio_envio'] = @(double) $_POST['destino']; if ($_POST['txt_numero_t_credito'] == str_repeat('1', 16)) { return '<p>ERROR</p>'; } return db_agregar_datos(db_prefijo . 'SSL_compra_contenedor', $DATOS); }
case 'mes': if (!isset($_POST['anio']) || !isset($_POST['mes'])) { return; } $andAnio = $_POST['anio'] ? "AND YEAR(txtFechaEntrega)='" . db_codex($_POST['anio']) . "'" : ""; $andMes = $_POST['mes'] ? "AND MONTH(txtFechaEntrega)='" . db_codex($_POST['mes']) . "'" : ""; $onClick = "onclick=\\'\$(\"#resultado_historial\").load(\"data/historial+ajax.php\",{opcion:\"dia\",anio:\"', YEAR(txtFechaEntrega), '\",mes:\"', MONTH(txtFechaEntrega), '\",dia:\"', DAY(txtFechaEntrega), '\"})\\'"; $c = "SELECT DISTINCT YEAR(txtFechaEntrega) AS 'Año', MONTHNAME(txtFechaEntrega) AS 'Mes', CONCAT('<a {$onClick}>',DAY(txtFechaEntrega),'</a>') AS 'Día', CONCAT('\$', SUM(lblCosto)) AS 'Precio costo del día', CONCAT('\$', SUM(lblCosto) * 0.10) AS 'Ahorro del día' FROM ahm_ordenes AS a WHERE 1 {$andAnio} {$andMes} {$andUsuario} GROUP BY DAY(txtFechaEntrega)"; break; case 'dia': if (!isset($_POST['anio']) || !isset($_POST['mes']) || !isset($_POST['dia'])) { return; } $andAnio = $_POST['anio'] ? "AND YEAR(txtFechaEntrega)='" . db_codex($_POST['anio']) . "'" : ""; $andMes = $_POST['mes'] ? "AND MONTH(txtFechaEntrega)='" . db_codex($_POST['mes']) . "'" : ""; $andDia = $_POST['dia'] ? "AND DAY(txtFechaEntrega)='" . db_codex($_POST['dia']) . "'" : ""; $onClick = "onclick=\\'\$(\"#resultado_historial\").load(\"data/historial+ajax.php\",{opcion:\"orden\",id_orden:\"', id_orden, '\"})\\'"; $c = "SELECT CONCAT('<a {$onClick}>',id_orden,'</a>') AS 'N° orden', validacion AS 'N° Validación', CONCAT('\$', lblCosto) AS 'Precio costo de orden', CONCAT('\$', lblCosto * 0.10) AS 'Ahorro de la orden' FROM ahm_ordenes AS a WHERE 1 {$andAnio} {$andMes} {$andDia} {$andUsuario}"; break; case 'orden': if (!isset($_POST['id_orden'])) { return; } $c = "SELECT id_orden AS 'N° orden Global', id_orden_indv AS 'N° orden', validacion AS 'N° Validación', lblCosto AS 'Costo', CONCAT('\$', lblCosto * 0.10) AS 'Ahorro', cmbListaMateriales AS 'Material', txtOtroMaterial AS 'Detalle Material', txtCantidad AS 'Número de copias', CONCAT(txtMedidaImpresionAncho,cmbSisMetricoAncho,'x',txtMedidaImpresionLargo,cmbSisMetricoLargo) as 'Medidas', optNoSi AS 'Escala', txtFechaOrden AS 'Fecha Orden', txtFechaEntrega AS 'Fecha Entrega', txtFechaEntregado AS 'Fecha Entregado', txtNotas AS 'Notas', CONCAT('<a target=\"_blank\" href=\"+',flArchivo, '\">', flArchivo, '</a>') AS 'Archivo', estado AS 'Estado' FROM ahm_ordenes AS a WHERE 1 {$andUsuario}"; } $resultado = db_consultar($c); if ($resultado && $_POST['opcion'] != 'orden') { echo db_ui_tabla($resultado, 'style="width:100%" class="historial"'); } else { echo db_ui_tabla_vertical($resultado); }
function db_ui_opciones($clave, $valor, $tabla, $cuales = "", $orden = "", $grupo_ui = "", $seleccionada = "") { $html = NULL; //La función es crear un combobox con name=id=$clave y value=$valor y HTML a partir de un SELECT $clave, $valor FROM $tabla $c = "SELECT {$clave}, {$valor} FROM {$tabla} {$cuales} {$orden}"; DEPURAR($c, 0); $resultado = db_consultar($c); $n_campos = mysql_num_rows($resultado); if ($grupo_ui) { $html .= "<optgroup label='{$grupo_ui}'>"; } for ($i = 0; $i < $n_campos; $i++) { $t_clave = mysql_result($resultado, $i, $clave); $t_valor = mysql_result($resultado, $i, $valor); if ($t_clave == $seleccionada) { $selected = ' selected="selected"'; } else { $selected = ""; } $html .= '<option value="' . $t_clave . '"' . $selected . '>' . $t_valor . '</option>'; } return $html; }
function mensaje($arrID_empresa = array(), $mensajes = array()) { foreach ($mensajes as $mensaje) { foreach ($arrID_empresa as $ID_empresa) { $c = sprintf('INSERT INTO %s (ID_empresa, tipo, mensaje, leido, fecha) VALUES("%s", "%s", "%s", 0, NOW())', db_prefijo . 'mensaje', $ID_empresa, $mensaje['tipo'], db_codex($mensaje['mensaje'])); $r = db_consultar($c); } } }
$error[] = 'El nombre ingresado no parece válido o es muy corto.'; } if (!validcorreo($_POST['email'])) { $error[] = 'Su correo electrónico no parece válido.'; } if (isset($error) && count($error)) { echo '<h1>Su consulta no pudo ser enviada porque se encontraron los siguientes errores</h1>'; echo '<p style="color:#F00">' . implode('</p><p style="color:#F00">', $error) . '</p>'; } else { $to = PROY_MAIL_BROADCAST_NOMBRE . PROY_MAIL_BROADCAST; $subject = 'Nueva consulta a ' . PROY_NOMBRE . ' - ' . dechex(crc32(microtime())); $message = '<style>li{font-weight:bold;}</style>' . "<p>La siguiente consulta ha sido recibida a travez de " . PROY_URL_ACTUAL . "</p>" . '<ul>' . "<li>Teléfono:</li><p>" . $_POST['tel'] . '</p>' . "<li>Correo electrónico:</li><p>" . $_POST['email'] . '</p>' . "<li>Nombre:</li><p>" . $_POST['nombre'] . '</p>' . "<li>Consulta:</li><p>" . $_POST['mensaje'] . '</p>' . '</ul>'; $headers = 'Reply-To: ' . $_POST['nombre'] . ' <' . $_POST['email'] . '>' . "\r\n"; @correo($to, $subject, $message, $headers); $c = sprintf('INSERT INTO %s (id_consulta, nombre, telefono, correo, interes, fecha) VALUES (NULL, "%s", "%s", "%s", "%s", NOW())', db_prefijo . 'consultas', db_codex($_POST['nombre']), db_codex($_POST['tel']), db_codex($_POST['email']), db_codex($_POST['mensaje'])); @db_consultar($c); echo '<p>'; echo '¡Muchas gracias por su consulta!<br />'; echo 'Lo invitamos a seguir navegando en nuestro sitio web. <a href="' . PROY_URL . '">Ir a la página principal</a>.<br />'; echo 'Recuerde que nuestro número telefonico es: ' . PROY_TELEFONO . '<br />'; echo '</p>'; return; } } ?> <h1>Contacto</h1> <div> <?php cargar_editable('contacto'); ?> </div>
require_once "PHP/admin.php"; CONTENIDO_ADMIN(); break; case 'mtime': $mtime = filemtime("../RCS/IMG/M/60m"); header('Last-Modified: lun, 26 oct 2009 18:26:27 GMT'); header('mtime: lun, 26 oct 2009 18:26:27 GMT'); echo $mtime . '<br />'; echo gmstrftime("%a, %d %b %Y %T %Z", $mtime); break; case 'imagen': if (isset($_GET['op'])) { $flag_Abortar = false; $op = db_codex($_GET['op']); $c = "SELECT id_img, id_publicacion, mime FROM ventas_imagenes WHERE id_img='{$op}' LIMIT 1"; $r = db_consultar($c); $f = mysql_fetch_array($r); // Se encontró la imagen en la base de datos? $flag_Abortar = mysql_num_rows($r) != 1; if (!$flag_Abortar) { // Se encontró en la base de datos, pero estará en el disco? $archivo = "../RCS/IMG/" . $f['id_img']; $flag_Abortar = !file_exists($archivo); } if (!$flag_Abortar && isset($_GET['miniatura'])) { // Se encontró el archivo principal, y se solicitó una minuatura de el. // Forzamos Content-Type: image/jpeg $TipoContenido = 'image/jpeg'; $archivo_m = "../RCS/IMG/M/" . $f['id_img'] . "m"; // Comprobamos si existe la miniatura o si debemos crearla if (!file_exists($archivo_m)) {
unlinkRecursive('catalogo360/pages/', false); $c = 'SELECT codigo_categoria, titulo FROM flores_categorias WHERE codigo_menu IN (1,2) ORDER BY titulo'; $r = db_consultar($c); $XML = simplexml_load_file('catalogo360/marcadores-base.xml'); $XMLP = simplexml_load_file('catalogo360/config-base.xml'); $general = $XML->addChild('seccion'); $general->addAttribute("titulo", "Catalogo"); $general->addAttribute("pagina", ""); $pagina_actual = 1; while ($f = mysql_fetch_assoc($r)) { $ref = $general->addChild('ref'); //$ref->addAttribute("titulo",iconv('ISO-8859-1','UTF-8//TRANSLIT',$f['titulo'])); $ref->addAttribute("titulo", $f['titulo']); $ref->addAttribute("pagina", $pagina_actual); $cp = 'SELECT foto, pc.titulo FROM flores_productos_categoria LEFT JOIN flores_producto_contenedor AS pc USING(codigo_producto) LEFT JOIN flores_producto_variedad USING(codigo_producto) WHERE codigo_categoria=' . $f['codigo_categoria'] . ' GROUP BY codigo_producto'; $rp = db_consultar($cp); $pagina_actual += 1 + mysql_numrows($rp); while ($fp = mysql_fetch_assoc($rp)) { if (!file_exists('catalogo360/pages/' . $fp['foto'])) { $im = new Imagick('IMG/i/' . $fp['foto']); $im->setCompression(Imagick::COMPRESSION_JPEG); $im->setCompressionQuality(90); $im->setImageFormat('jpeg'); $im->stripImage(); $draw = new ImagickDraw(); $pixel = new ImagickPixel('gray'); $pixel->setColor('black'); $draw->setFont('flower.ttf'); $draw->setFontSize(30); $im->thumbnailImage(350, 525, false); $im->annotateImage($draw, 10, 45, 0, $fp['titulo']);
function CONTENIDO_CERRAR($publicacion) { if (isset($_POST['cerrar']) && _autenticado() && _F_usuario_cache('id_usuario') == $publicacion['id_usuario']) { db_consultar(sprintf('UPDATE ventas_publicaciones SET tipo=%s WHERE id_publicacion=%s', _A_vendido, $publicacion['id_publicacion'])); if (db_afectados() > 0) { echo '<h1>Publicación concluida</h1>'; echo sprintf('Su publicación ha sido cerrada y marcada como "vendida". Gracias por usar %s!<br />', PROY_NOMBRE); echo '<h1>Opciones</h1>'; echo ui_href('', PROY_URL, 'Retornar a la página principal'); echo ui_href("", "vender", "Retornar a su lista de publicaciones"); } return; } echo '<h1>Cerrar publicación</h1>'; echo '<p>Presione "Cerrar" para marcar su publicación como vendida y cerrarla.<br />Tenga en cuenta que no podrá re-abrirla luego de esto, asi que procure no cerrarla antes de concluir la venta.</p>'; echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="POST">'; echo '<input name="cerrar" type="submit" value="Cerrar" />'; echo '</form>'; echo '<h1>Opciones</h1>'; echo ui_href("", "vender", "Cancelar y retornar a su lista de publicaciones"); }
function enviar_prospecto($ID_aplicacion, $ID_prospecto, $lote = false) { db_actualizar_datos(db_prefijo . 'prospectos_aplicados', array('enviado' => mysql_datetime()), 'ID_aplicacion="' . $ID_aplicacion . '"'); $c = sprintf('SELECT `ID_prospecto`, `situacion`, `ultima_presentacion`, `intentos`, `apellido`, `nombre`, `direccion1`, `direccion2`, `especial1`, `ciudad`, `estado`, `zip`, `telefono`, `especial2`, `especial3`, `especial4`, `especial5`, `especial6`, `especial7`, `especial8`, `especial9`, `especial10`, `especial11`, `especial13`, `especial14`, `especial15`, `especial16`, `especial17`, `especial18`, `especial19`, `especial20`, `especial21`, `ID_aplicacion`, `ID_agente_sv`, `ID_agente_us`, (SELECT nombre FROM ' . db_prefijo . 'usuarios WHERE ID_usuario = `ID_agente_sv`) AS nombre_agente_sv, (SELECT nombre FROM ' . db_prefijo . 'usuarios WHERE ID_usuario = `ID_agente_us`) AS nombre_agente_us, `fecha_ingresada`, `fecha_cerrada`, `comision_agente_sv`, `comision_agente_us`, `comsion_ufs_sv`, `comision_ufs_us`, `enviado`, `notas` FROM %s LEFT JOIN %s USING (ID_prospecto) WHERE ID_prospecto="%s" ORDER BY fecha_ingresada ASC', db_prefijo . 'prospectos_aplicados', db_prefijo . 'prospectos', db_codex($ID_prospecto)); $r = db_consultar($c); $f = mysql_fetch_assoc($r); if ($lote) { $buffer = ' <table> <tr><th style="text-align:right;border-right:1px solid #000;">Agent SV</th><td>' . $f['nombre_agente_sv'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Agent US</th><td>' . $f['nombre_agente_us'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Prospect ID</th><td>' . $f['ID_prospecto'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Application date</th><td>' . $f['fecha_ingresada'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Name</th><td>' . $f['apellido'] . ', ' . $f['nombre'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Phone</th><td>' . $f['telefono'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Address</th><td>' . $f['direccion2'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">City</th><td>' . $f['ciudad'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Zip Code</th><td>' . $f['zip'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Mortage Date</th><td>' . $f['especial2'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Mortage Amount</th><td>$' . @number_format(preg_replace('/[^\\d]/', '', $f['especial5']), 2, '.', ',') . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Mortage rate</th><td>' . $f['especial7'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Sales Price</th><td>' . $f['especial3'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Lender</th><td>' . $f['especial6'] . '</td></tr> <tr><th style="text-align:right;border-right:1px solid #000;">Notas</th><td>' . $f['notas'] . '</td></tr> </table> <a href="' . PROY_URL . 'aplicaciones?ver=' . $f['ID_aplicacion'] . '&correo">Ir a la aplicación</a> '; } else { $buffer = ' <p>El agente <b>' . $f['nombre_agente_sv'] . '</b> ha ingresado una nueva aplicación.</p> <a href="' . PROY_URL . 'aplicaciones?ver=' . $f['ID_aplicacion'] . '&correo">Ir a la aplicación</a> <hr /> <p> <small> Ud. ha recibido esta notificación por una de las siguientes causas: <ul> <li>Ud. es un agente US registrado en el sistema UFS Online Network</li> <li>Ud. esta en la lista de administradores/supervisores</li> </ul> <hr /> <span style="color:#F00;"> NO RESPONDA A ESTE CORREO, LOS CORREOS ENVIADOS A ' . htmlentities(PROY_MAIL_POSTMASTER) . ' NO SON REVISADOS.<br /> En su lugar puede comentar en la aplicación mencionada. </span> </small> </p> '; } if ($lote) { return $buffer; } else { require_once 'php/mensajitos.us.php'; $c = 'SELECT usuario, nombre, correo, telefono, carrier FROM ' . db_prefijo . 'usuarios WHERE nivel="agente_us"'; $r = db_consultar($c); while (mysql_num_rows($r) && ($f = mysql_fetch_assoc($r))) { EnviarMensajitosUS($f['telefono'], $f['carrier'], 'Nueva aplicacion disponible en el sistema'); } correoSMTP('*****@*****.**', 'Nueva aplicación - ' . $ID_aplicacion . '+' . $ID_prospecto, $buffer); } }