Exemple #1
0
if (!$error) {
    $plan_db = $db->ls("SELECT planes.*, precios.* FROM api_planes planes INNER JOIN api_precio_planes precios ON planes.id_plan = precios.id_plan WHERE precios.currency = '%s' AND precios.id_plan = '%d'" . (User::isAdmin() ? '' : ' AND planes.activo = 1'), array(secInjection($_GET['currency']), (int) $_GET['id_plan']), true);
}
if (!$error && !$plan_db) {
    $error = 'El plan seleccionado no existe o no se encuentra activo para la venta en este momento.';
}
if (!$error && User::isAdmin()) {
    $id_service = false;
    if ($service) {
        $id_service = (int) $service['id_service'];
        $db->qs("UPDATE api_services SET activo = 1, id_plan = %d, proximo_corte = '%s' WHERE id_service = %d", array((int) $_GET['id_plan'], date('Y-m-d H:i:s', strtotime('+' . $plan_db['periocidad'] . ' month', $service ? strtotime($service['proximo_corte']) : time())), $id_service));
    } else {
        $db->qs("INSERT INTO api_services (id_usuario,id_plan,token,fecha_inicio,proximo_corte, activo) VALUES\n                            ('%d','%d','%s',NOW(),'%s', 1)", array((int) $user->id, (int) $id_plan, md5(time() . $user->id . User::$keySecurity), date('Y-m-d H:i:s', strtotime('+' . $plan_db['periocidad'] . ' month', $service ? strtotime($service['proximo_corte']) : time()))));
        $id_service = (int) $db->id();
    }
    $db->qs("INSERT INTO api_invoices (id_service,currency,amount,payment_name,payment_status,payment_reference,date_created,date_expire,log_payment) VALUES\n                        ('%d','%s','%s','superuser','completed','%s',NOW(),'%s','%s')", array($id_service, secInjection($plan_db['currency']), secInjection('0.0'), secInjection('SuperUser-' . time()), date('Y-m-d H:i:s', strtotime('+' . $plan_db['periocidad'] . ' month')), secInjection(print_r($_POST, true))));
    header('location: login.php');
}
$html_title = 'Plataforma de Pago';
$html_description = 'Plataforma de pago';
$menu_select = 'login';
include 'header.php';
?>

<?php 
if ($error) {
    echo '<div class="alert alert-danger" role="alert">' . $error . '</div>';
}
if ($msj) {
    echo '<div class="alert alert-success" role="alert">' . $msj . '</div>';
}
        sendNotify($n);
    }
}
$notify = $db->ls("SELECT * FROM api_services\n        WHERE activo = 1\n        AND proximo_corte < DATE_ADD(NOW(),INTERVAL 2 DAY)\n        AND last_remember < DATE_SUB(NOW(),INTERVAL 2 DAY)\n        LIMIT 30\n        ", array(), false);
if ($notify) {
    foreach ($notify as $n) {
        sendNotify($n);
    }
}
$mp_pending = $db->ls("SELECT * FROM api_invoices\n        WHERE\n            payment_status = 'pending'\n        AND\n            payment_name = 'mercadopago-ve'\n        LIMIT 30\n        ", array(), false);
if ($mp_pending) {
    foreach ($mp_pending as $invoice) {
        $result = validateMercadoPago($invoice['payment_reference']);
        if (isset($result['order_id']) && isset($result['status']) && $result['status'] != 'Pending') {
            $custom = preg_split('/-/', $result['order_id']);
            $id_plan = (int) $custom[0];
            $id_service = (int) $invoice['id_service'];
            $service = $db->ls("SELECT * FROM api_services WHERE id_service = %d", array($id_service), true);
            $user = User::getUserByID($service['id_usuario']);
            $plan_db = $user ? $db->ls("SELECT planes.*, precios.* FROM api_planes planes INNER JOIN api_precio_planes precios ON planes.id_plan = precios.id_plan WHERE precios.currency = '%s' AND precios.id_plan = '%d'" . ($user->rol == 1 ? '' : ' AND planes.activo = 1'), array(secInjection($result['currency']), (int) $id_plan), true) : false;
            if ($result['status'] == 'Completed') {
                email($user->mail, 'Pago Aceptado', 'Su pago fue aceptado y ya fue creado su APP para poder disfrutar de nuestro servicios, ingrese a "Registro / Login" en http://cedula.com.ve/ para mayor información.');
                $db->qs("UPDATE api_services SET activo = 1, proximo_corte = '%s' WHERE id_service = %d", array($id_plan, date('Y-m-d H:i:s', strtotime('+' . $plan_db['periocidad'] . ' month', strtotime($service['proximo_corte']))), $id_service));
                $db->qs("UPDATE api_invoices SET payment_status = 'completed', log_payment = '%s' WHERE id_invoice = %d", array(secInjection($result['message']), $invoice['id_invoice']));
            } else {
                email($user->mail, 'Error en el Pago', 'Su pago fue rechazado por Mercadopago, ingrese a "Registro / Login" en http://cedula.com.ve/ y vuelva a realizar su pedido para reintentar la compra.');
                $db->qs("UPDATE api_invoices SET payment_status = 'rejected', log_payment = '%s' WHERE id_invoice = %d", array(secInjection($result['message']), $invoice['id_invoice']));
            }
        }
    }
}
Exemple #3
0
    }
}
$isLogin = User::authSession();
if ($isLogin) {
    $user = $_SESSION['user'];
}
if ($isLogin && $_GET['op'] == 'renew' && (int) $_GET['id_service'] > 0) {
    $service = $db->ls("SELECT * FROM api_invoices INNER JOIN api_services ON api_invoices.id_service = api_services.id_service WHERE api_services.id_usuario = %d AND api_services.id_service = %d ORDER BY date_created DESC LIMIT 1", array($user->id, (int) $_GET['id_service']));
    if ($service) {
        header('location: payment.php?id_service=' . $service['id_service'] . '&id_plan=' . $service['id_plan'] . '&currency=' . $service['currency']);
    }
}
if ($isLogin && $_GET['op'] == 'renew_token' && (int) $_GET['id_service'] > 0) {
    $service = $db->ls("SELECT * FROM api_invoices INNER JOIN api_services ON api_invoices.id_service = api_services.id_service WHERE api_services.id_usuario = %d AND api_services.id_service = %d ORDER BY date_created DESC LIMIT 1", array($user->id, (int) $_GET['id_service']));
    if ($service) {
        if ($db->qs("UPDATE api_services SET token = '%s' WHERE id_service = %d", array(secInjection(md5(time() . $user->id . User::$keySecurity)), (int) $_GET['id_service']))) {
            $msj = 'Se ha generado un nuevo token para su APP';
        } else {
            $error = 'Ocurrió un error actualizando su APP';
        }
    } else {
        $error = 'El APP no existe o usted no es el dueño';
    }
}
if (isset($_POST)) {
    foreach ($_POST as $k => $v) {
        if ($k != 'pass' && $k != 'pass2') {
            $_POST[$k] = trim($v);
        }
    }
    if (!$isLogin) {
Exemple #4
0
    if ($_GET['cedula']) {
        if ($_REQUEST['nacionalidad'] == "M" && intval($_REQUEST['cedula'] == 0)) {
            echo json_encode(false);
            exit;
        }
        $personas = $db->l("SELECT * \r\n\t\tFROM  `personas` \r\n\t\tWHERE nacionalidad = '" . secInjection($_REQUEST['nacionalidad']) . "' AND cedula = " . intval($_REQUEST['cedula']) . "", true);
        echo json_encode($personas);
    } else {
        if ($_POST['cedula'] && $_POST['nacionalidad']) {
            $persona = $db->l("SELECT *\r\n                        FROM  `personas`\r\n                        WHERE nacionalidad = '" . secInjection($_POST['nacionalidad']) . "' AND cedula = " . intval($_POST['cedula']) . "", true);
            if ($persona && !isset($_POST['edit'])) {
                echo json_encode(-1);
            } else {
                if (!$persona) {
                    if ($_POST['nacionalidad'] == "M" && intval($_POST['cedula'] == 0)) {
                        $_POST['cedula'] = $db->pid("personas");
                    }
                    $result = $db->q("INSERT INTO personas (nacionalidad, cedula, nombres, apellidos, sexo, fecha_nacimiento, estado_civil, instruccion, profesion) VALUES " . "('" . secInjection($_POST['nacionalidad']) . "', " . intval($_POST['cedula']) . ", '" . secInjection($_POST['nombres']) . "',\r\n\t\t\t\t\t\t'" . secInjection($_POST['apellidos']) . "',  '" . secInjection($_POST['sexo']) . "', '" . secInjection($_POST['fecha_nacimiento']) . "', \r\n\t\t\t\t\t\t" . intval($_POST['estado_civil']) . ", '" . secInjection($_POST['instruccion']) . "', '" . secInjection($_POST['profesion']) . "' \r\n\t\t\t\t\t )");
                    echo json_encode($result ? $_POST['cedula'] : false);
                } else {
                    if (isset($_POST['edit'])) {
                        $result = $db->q("UPDATE personas SET nombres='" . secInjection($_POST['nombres']) . "', apellidos='" . secInjection($_POST['apellidos']) . "',  \r\n\t\t\t\t\tsexo = '" . secInjection($_POST['sexo']) . "', fecha_nacimiento = '" . secInjection($_POST['fecha_nacimiento']) . "', estado_civil = " . intval($_POST['estado_civil']) . ",\r\n\t\t\t\t\tinstruccion = '" . secInjection($_POST['instruccion']) . "', profesion = '" . secInjection($_POST['profesion']) . "' WHERE nacionalidad = '" . secInjection($_POST['nacionalidad']) . "' AND cedula = " . intval($_POST['cedula']));
                        echo json_encode($result ? $_POST['cedula'] : false);
                    } else {
                        json_encode(false);
                    }
                }
            }
        }
    }
}
 static function updateUser($id, $name, $rol, $mail, $pass = null)
 {
     global $db;
     if ($r = User::getUserByID(intval($id))) {
         if ($r2 = $db->ls("SELECT * FROM user WHERE mail='%s' and id<>%d", array(strtolower(secInjection($mail)), intval($id)))) {
             return E_MAIL_EXIST;
         } else {
             if ($pass == null) {
                 return $db->qs("UPDATE user SET name = '%s', rol = '%d', mail = '%s' WHERE id=%d;", array(secInjection($name), intval($rol), strtolower(secInjection($mail)), intval($id)));
             } else {
                 return $db->qs("UPDATE user SET name = '%s', rol = '%d', mail = '%s', pass = '******' WHERE id=%d;", array(secInjection($name), intval($rol), strtolower(secInjection($mail)), md5($pass . $r->user . User::$keySecurity), intval($id)));
             }
         }
     }
     return E_USER_NOT_EXIST;
 }
    exit;
}
if ($_POST) {
    $pid = $_GET['t'] == 'add' ? $db->pid("items_encuesta") : $_POST['id'];
    if (!isset($error)) {
        if ($_GET['t'] == 'add') {
            if ($db->l("SELECT id FROM items_encuesta WHERE LOWER(texto)=LOWER('" . secInjection($_POST['itemTexto']) . "') AND active='1' AND id_item_categoria=" . $_POST["seccionId"], true)) {
                echo "El item '" . $_POST["itemTexto"] . "'ya existe";
            } else {
                if (!$db->qs("INSERT INTO items_encuesta (texto, is_check, require_number, is_text, orden, id_item_categoria) VALUES ('%s','%s','%s','%s',%d,%d)", array(secInjection($_POST['itemTexto']), $_POST["itemType"] == "0" ? "1" : "0", $_POST["itemType"] == "0" ? isset($_POST["requireNumber"]) ? $_POST["requireNumber"] : "0" : "0", $_POST["itemType"] == "1" ? "1" : "0", $_POST["orden"], $_POST['seccionId']))) {
                    echo "Error en la Base de Datos";
                }
            }
        }
        if ($_GET['t'] == 'update') {
            if (!$db->qs("UPDATE items_encuesta SET texto='%s', is_check='%s', require_number='%s', is_text='%s', orden=%d, id_item_categoria=%d WHERE id=%d;", array(secInjection($_POST['itemTexto']), $_POST["itemType"] == "0" ? "1" : "0", $_POST["itemType"] == "0" ? isset($_POST["requireNumber"]) ? $_POST["requireNumber"] : "0" : "0", $_POST["itemType"] == "1" ? "1" : "0", $_POST["orden"], $_POST['seccionId'], intval($_POST['id'])))) {
                echo "Error en la Base de Datos";
            }
        }
    } else {
        echo $error;
    }
    exit;
}
$dCat = array();
if (intval($_GET['id']) > 0) {
    $query = "SELECT ie.id AS itemId, ie.texto AS itemTexto, ie.is_check, ie.require_number, ie.is_text, ie.orden, cie.id AS seccionId, cie.texto AS seccion " . "FROM categoria_item_encuesta cie, items_encuesta ie " . "WHERE ie.active='1' " . "AND ie.id_item_categoria = cie.id " . "AND ie.id=" . $_GET['id'];
    $data = $db->l($query, true);
}
?>
            
}
if ($_POST) {
    $pid = $_GET['t'] == 'add' ? $db->pid("parroquias") : $_POST['id'];
    if (!isset($error)) {
        $estado = $db->l("SELECT id_estado FROM `municipios` WHERE `id`=" . intval($_POST['id_municipio']) . "", true);
        if ($_GET['t'] == 'add') {
            if ($db->l("SELECT id FROM `parroquias` WHERE `id_estado`=" . intval($estado['id_estado']) . " AND `id_municipio`=" . intval($_POST['id_municipio']) . " AND parroquia='" . secInjection($_POST['parroquia']) . "'", true)) {
                echo "El municipio ya existe";
            } else {
                if (!$db->qs("INSERT INTO `parroquias` (`parroquia`,`id_estado`,`id_municipio`) VALUES ('%s', %d, %d)", array(secInjection($_POST['parroquia']), intval($estado['id_estado']), intval($_POST['id_municipio'])))) {
                    echo "Error en la Base de Datos";
                }
            }
        }
        if ($_GET['t'] == 'update') {
            if (!$db->qs("UPDATE `parroquias` SET `parroquia`='%s', `id_estado`=%d, `id_municipio`=%d  WHERE id=%d;", array(secInjection($_POST['parroquia']), intval($estado['id_estado']), intval($_POST['id_municipio']), intval($_POST['id'])))) {
                echo "Error en la Base de Datos";
            }
        }
    } else {
        echo $error;
    }
    exit;
}
if (intval($_GET['id']) > 0) {
    $data = $db->l("SELECT * FROM `parroquias` WHERE id='" . intval($_GET['id']) . "'", true);
}
$estados = $db->l("SELECT e.id id_estado, m.id id_municipio, e.estado, m.municipio FROM `estados` e, municipios m WHERE m.id_estado = e.id ORDER BY e.estado, m.municipio", false);
?>
            
<form action = "<?php 
 static function updateUserData($id, $name, $vat, $address, $country, $phone)
 {
     global $db;
     if ($r = User::getUserByID(intval($id))) {
         return $db->qs("UPDATE api_usuarios SET name = '%s', vat = '%s', address = '%s', country = '%s', phone = '%s' WHERE id_usuario=%d;", array(secInjection($name), secInjection($vat), secInjection($address), secInjection($country), secInjection($phone), intval($id)));
     }
     return E_USER_NOT_EXIST;
 }
					});
				//}

				return valid;
			}
		});
	}
	function onLoadForm(){
		<?php 
echo '/*  ';
print_r($encuesta);
echo '  */';
if ($encuesta) {
    foreach ($encuesta as $key => $val) {
        if ($val != "0") {
            echo 'if($("#' . $key . '").attr("type")=="checkbox") $("#' . $key . '").attr("checked", true); else $("#' . $key . '").val(\'' . secInjection($val) . '\');' . "\n\t\t";
        }
    }
}
?>
		styleViewFamilia();
		reloadParroquia($("#id_municipio_jefe").val(), 'load_parroquia', 'id_parroquia_jefe');
		load_persona("nacionalidad_jefe", "cedula_jefe", "cedula_jefe", reloadJefe);
		$( ".date" ).datepicker({
            changeMonth: true,
            changeYear: true,
			dateFormat: "yy-mm-dd",
			yearRange: "-120:+0"
        });
		
		validateValueCheckbox();
Exemple #10
0
								<tr>
									<td>Tiempo en la Vivienda:</td>
									<td>
										<input value="<?php 
echo $direccion["tiempo_vivienda"];
?>
" name="tiempo_vivienda_jefe" class="digits required" id="tiempo_vivienda_jefe" maxlength="3" /> (años)
									</td>
								</tr> 
							</table>
						</div>
						<div id="tabs-2">
							<div id="list_familia">
								<?php 
for ($i = 0; $i < count($familia); ++$i) {
    echo '<input type="hidden" name="persona[' . $familia[$i]['nacionalidad'] . $familia[$i]['cedula'] . ']" id="persona' . $familia[$i]['nacionalidad'] . $familia[$i]['cedula'] . '" value=\'' . secInjection(json_encode($familia[$i])) . '\' />' . "\n";
}
?>
							</div>
							<table width="100%" id="view_familia">
								<tr><th>Cedula</th><th>Nombres</th><th>Sexo</th><th>Fecha Nacimiento</th><th>Estado Civil</th><th>Instruccion</th><th>Profesion</th><th>Salud</th><th>Parentesco</th><th>Opciones</th></tr>
							
								<?php 
for ($i = 0; $i < count($familia); ++$i) {
    echo '<tr id="r' . $familia[$i]['nacionalidad'] . $familia[$i]['cedula'] . '">';
    echo '<td>';
    if ($familia[$i]['nacionalidad'] == "M") {
        echo "Niño/a";
    } else {
        echo $familia[$i]['nacionalidad'] . $familia[$i]['cedula'];
    }
    exit;
}
if ($_POST) {
    $pid = $_GET['t'] == 'add' ? $db->pid("municipios") : $_POST['id'];
    if (!isset($error)) {
        if ($_GET['t'] == 'add') {
            if ($db->l("SELECT id FROM `municipios` WHERE `id_estado`=" . intval($_POST['id_estado']) . " AND municipio='" . secInjection($_POST['municipio']) . "'", true)) {
                echo "El municipio ya existe";
            } else {
                if (!$db->qs("INSERT INTO `municipios` (`municipio`,`id_estado`) VALUES ('%s', %d)", array(secInjection($_POST['municipio']), intval($_POST['id_estado'])))) {
                    echo "Error en la Base de Datos";
                }
            }
        }
        if ($_GET['t'] == 'update') {
            if (!$db->qs("UPDATE `municipios` SET `municipio`='%s', `id_estado`=%d  WHERE id=%d;", array(secInjection($_POST['municipio']), intval($_POST['id_estado']), intval($_POST['id'])))) {
                echo "Error en la Base de Datos";
            }
        }
    } else {
        echo $error;
    }
    exit;
}
$dCat = array();
if (intval($_GET['id']) > 0) {
    $data = $db->l("SELECT * FROM `municipios` WHERE id='" . intval($_GET['id']) . "'", true);
}
$estados = $db->l("SELECT * FROM `estados` order by estado", false);
?>
            
    exit;
}
if ($_POST) {
    $pid = $_GET['t'] == 'add' ? $db->pid("estados") : $_POST['id'];
    if (!isset($error)) {
        if ($_GET['t'] == 'add') {
            if ($db->l("SELECT id FROM `estados` WHERE estado='" . secInjection($_POST['estado']) . "'", true)) {
                echo "El Estado ya existe";
            } else {
                if (!$db->qs("INSERT INTO `estados` (`estado`) VALUES ('%s')", array(secInjection($_POST['estado'])))) {
                    echo "Error en la Base de Datos";
                }
            }
        }
        if ($_GET['t'] == 'update') {
            if (!$db->qs("UPDATE `estados` SET `estado`='%s' WHERE id=%d;", array(secInjection($_POST['estado']), intval($_POST['id'])))) {
                echo "Error en la Base de Datos";
            }
        }
    } else {
        echo $error;
    }
    exit;
}
$dCat = array();
if (intval($_GET['id']) > 0) {
    $data = $db->l("SELECT * FROM `estados` WHERE id='" . intval($_GET['id']) . "'", true);
}
?>
            
<form action = "<?php 
Exemple #13
0
                } else {
                    $db->qs("INSERT INTO api_services (id_usuario,id_plan,token,fecha_inicio,proximo_corte, activo) VALUES\n                                    ('%d','%d','%s',NOW(),'%s', 1)", array((int) $user->id, (int) $id_plan, md5(time() . $user->id . User::$keySecurity), date('Y-m-d H:i:s', strtotime('+' . $plan_db['periocidad'] . ' month', $service ? strtotime($service['proximo_corte']) : time()))));
                    $id_service = (int) $db->id();
                }
                if (!$invoice) {
                    $db->qs("INSERT INTO api_invoices (id_service,currency,amount,payment_name,payment_status,payment_reference,date_created,date_expire,log_payment) VALUES\n                                    ('%d','%s','%s','paypal','completed','%s',NOW(),'%s','%s')", array($id_service, secInjection($_POST['mc_currency']), secInjection($_POST['mc_gross']), secInjection($ref_id), date('Y-m-d H:i:s', strtotime('+' . $plan_db['periocidad'] . ' month')), secInjection(print_r($_POST, true))));
                } else {
                    $db->qs("UPDATE api_invoices SET payment_status = 'completed', log_payment = '%s' WHERE id_invoice = %d", array(secInjection(print_r($_POST, true)), $invoice['id_invoice']));
                }
            } else {
                if ($_POST['payment_status'] == 'Pending' || $_POST['payment_status'] == 'Processed' || $_POST['payment_status'] == 'In-Progress') {
                    if (!$id_service) {
                        email($user->mail, 'Su Pago quedo Pendiente', 'Su pago tiene un estado de "Pendiente", cuando se procese el pago su APP pasara de "Suspendido" a "Activo" y podra disfrutar del servicio.');
                        $db->qs("INSERT INTO api_services (id_usuario,id_plan,token,fecha_inicio,proximo_corte, activo) VALUES\n                                    ('%d', '%d', '%s', NOW(), NOW(), 0)", array((int) $user->id, (int) $id_plan, md5(time() . $user->id . User::$keySecurity)));
                        $id_service = (int) $db->id();
                    }
                    if (!$invoice) {
                        $db->qs("INSERT INTO api_invoices (id_service,currency,amount,payment_name,payment_status,payment_reference,date_created,date_expire,log_payment) VALUES\n                                    ('%d','%s','%s','paypal','pending','%s',NOW(),'%s','%s')", array($id_service, secInjection($_POST['mc_currency']), secInjection($_POST['mc_gross']), secInjection($ref_id), date('Y-m-d H:i:s', strtotime('+' . $plan_db['periocidad'] . ' month')), secInjection(print_r($_POST, true))));
                    } else {
                        $db->qs("UPDATE api_invoices SET payment_status = 'pending', log_payment = '%s' WHERE id_invoice = %d", array(secInjection(print_r($_POST, true)), $invoice['id_invoice']));
                    }
                } else {
                    email($user->mail, 'Error en el Pago', 'Su pago fue rechazado por paypal (Error: ' . $_POST['payment_status'] . '), ingrese a "Mi Cuenta" en http://cedula.com.ve/ y vuelva a realizar su pedido para reintentar la compra.');
                    if ($invoice) {
                        $db->qs("UPDATE api_invoices SET payment_status = 'rejected', log_payment = '%s' WHERE id_invoice = %d", array(secInjection(print_r($_POST, true)), $invoice['id_invoice']));
                    }
                }
            }
        }
    }
}
* @copyright 2015 Desarrollos Cuado C.A.
* @license   GPLv3
*/
include_once "./lib/classDBAndUser.php";
if (isset($_POST['cedula']) && isset($_POST['nacionalidad'])) {
    if (!checkRecaptchar(RECAPTCHAR_SECRET, $_POST['g-recaptcha-response'])) {
        $error = 'reCAPTCHA inválido';
    } else {
        $rif = valid_rif($_POST['nacionalidad'], trim($_POST['cedula']));
        if (!$rif) {
            $error = 'Su cédula tiene un formato inválido';
        } else {
            if ($data = $db->ls("SELECT * FROM not_show WHERE rif = '%s'", array(secInjection($rif)))) {
                $error = 'Esta cédula ya fue dado de baja el día ' . $data['created_date'];
            } else {
                if ($db->qs("INSERT INTO not_show (rif, created_date, ip_submit) VALUES ('%s', NOW(), '%s')", array(secInjection($rif), getRealIP()))) {
                    $msj = "Su cédula fue dado de baja de nuestro sistema correctamente";
                } else {
                    $error = "Ocurrió un error temporal en nuestro sistema, intente más tarde";
                }
            }
        }
    }
}
$html_title = 'Baja de Cédula en el Sistema';
$html_description = 'No mostrar una Cédula en el Sistema';
$menu_select = 'baja';
include 'header.php';
?>
<br />
<?php 
    exit;
}
if ($_POST) {
    $pid = $_GET['t'] == 'add' ? $db->pid("categoria_item_encuesta") : $_POST['id'];
    if (!isset($error)) {
        if ($_GET['t'] == 'add') {
            if ($db->l("SELECT id FROM categoria_item_encuesta WHERE LOWER(texto)=LOWER('" . secInjection($_POST['texto']) . "') AND active='1'", true)) {
                echo "La seccion '" . $_POST["texto"] . "' ya existe";
            } else {
                if (!$db->qs("INSERT INTO categoria_item_encuesta (texto, orden) VALUES ('%s',%d)", array(secInjection($_POST['texto']), intval($_POST["orden"])))) {
                    echo "Error en la Base de Datos";
                }
            }
        }
        if ($_GET['t'] == 'update') {
            if (!$db->qs("UPDATE categoria_item_encuesta SET texto='%s', orden=%d WHERE id=%d;", array(secInjection($_POST['texto']), intval($_POST["orden"]), intval($_POST['id'])))) {
                echo "Error en la Base de Datos";
            }
        }
    } else {
        echo $error;
    }
    exit;
}
$dCat = array();
if (intval($_GET['id']) > 0) {
    $data = $db->l("SELECT * FROM categoria_item_encuesta WHERE id='" . intval($_GET['id']) . "'", true);
}
?>
            
<form action = "<?php