function to_pg_array($set) { settype($set, 'array'); // can be called with a scalar or array $result = array(); foreach ($set as $t) { if (is_array($t)) { $result[] = to_pg_array($t); } else { $t = str_replace('"', '\\"', $t); // escape double quote /*if (! is_numeric($t)) // quote only non-numeric values $t = '"' . $t . '"';*/ $result[] = $t; } } return '{' . implode(",", $result) . '}'; // format }
//make sure user is allowed if ($_SESSION != null) { if (!auth_check($_SESSION['email'], $_SESSION['password'])) { session_destroy(); header('Location: index.php'); } } else { session_destroy(); header('Location: index.php'); } //User is allowed! //Check to see if user posted data if (isset($_POST['title'])) { if (strlen($_POST['title']) > 0) { $title = filter_var($_POST["title"], FILTER_SANITIZE_STRING); $tags = to_pg_array(explode(" ", filter_var($_POST['tags'], FILTER_SANITIZE_STRING))); $visible = isset($_POST['visible']) ? 't' : 'f'; $is_on_odua = isset($_POST['is_on_odua']) ? 't' : 'f'; $content = $_POST['content']; $name = isset($_GET['p']) ? $_GET['p'] : $title; //Data grabed and sanatized, add to database $dbconn = post_connect(); $query = "UPDATE blog SET title='{$title}',entry='{$content}',tags='{$tags}',visible='{$visible}',is_on_odua='{$is_on_odua}' WHERE title='{$name}';\n INSERT INTO blog (title, entry, tags, visible, is_on_odua) SELECT '{$title}', '{$content}', '{$tags}', '{$visible}', '{$is_on_odua}'\n WHERE NOT EXISTS (SELECT 1 FROM blog WHERE title='{$title}');"; $results = pg_query($dbconn, $query) or die('Query failed: ' . pg_last_error()); pg_close($dbconn); if ($results) { pg_free_result($results); header('Location: thoughts.php'); } pg_free_result($results); }
$dbconn = post_connect(); $query = "SELECT id, array_to_json(slideshow) FROM odua ORDER BY id DESC LIMIT 1;"; $raw_entery = pg_query($query) or die('Query failed: ' . pg_last_error()); $line = pg_fetch_array($raw_entery, null, PGSQL_ASSOC); $photo_array = json_decode($line['array_to_json'], true); $slideshow_images = array(); $count = 0; foreach ($photo_array as $key => $value) { if (strcmp($value, $_POST['image']) == 0) { continue; } $slideshow_images[$count] = $value; $count = $count + 1; } $id = $line['id']; $slideshow = to_pg_array($slideshow_images); $update_query = "UPDATE odua SET slideshow='{$slideshow}' WHERE id={$id};"; $results = pg_query($dbconn, $update_query) or die('Query failed: ' . pg_last_error()); if ($results) { pg_free_result($results); echo $_POST['image'] . " removed."; } pg_close($dbconn); pg_free_result($raw_entery); } //END if($_POST['type']=="delete_image") } } //END if(isset($_POST['type'])) /* UTILIY FUNCTIONS FOR THIS FORM
//////////////////////////////////////////// $obj_sms = new Mensaje_sms(); $modem_vector = array(); $cantidad_modem = 1; /////Aqui si se seleccionó, varios modem en el combo ... if ($_POST["enviar_texto_modem"] == '-999') { for ($u = 0; $u < count($_POST["modem"]); $u++) { $modem_vector[$u] = $_POST["modem"][$u]; } $cantidad_modem = count($modem_vector); } else { $cantidad_modem = 1; $modem = $_POST["enviar_texto_modem"]; } /////////////////////////////////////////// $m_vector = to_pg_array($modem_vector); if ($opcion_grupo == '2') { $tlf = $grupo; $grupo = '0'; } else { $tlf = ''; } $rs = $obj_sms->enviar_sms($texto, $modem, $m_vector, $cantidad_modem, $grupo, $opcion_grupo, $tlf); //die(json_encode($rs)); if ($rs == "error") { $mensaje[0] = "error_bd"; die(json_encode($mensaje)); } else { /////////////////////////////////////////////////--AUDITORIA--/////////////////////////////////////// $auditoria_eva = new auditoria("Envio sms", "Envio de sms (GRUPO-ID:" . $grupo . ",TLF:" . $tlf . ",MENSAJE:" . $texto . ")"); $auditoria = $auditoria_eva->registrar_auditoria();
$mensaje[0] = "campos_blancos"; die(json_encode($mensaje)); } for ($i = 0; $i <= $cuantas_pr; $i++) { $k = $i + 1; /////////////// if (isset($_POST["opcion" . $k])) { $resp = $_POST["opcion" . $k]; $vector_r = $resp[0]; $vector_r = explode("*", $vector_r); $vector_respuestas[$i] = $vector_r[1]; $vector_pregunta[$i] = $vector_r[0]; } ///////////// } $vector_respuestas = to_pg_array($vector_respuestas); $vector_pregunta = to_pg_array($vector_pregunta); $obj_evaluacion = new evaluacion(); $rs = $obj_evaluacion->registrar_evaluacion_us($formacion, $unidades, $prueba, $cuantas_pr, $vector_respuestas, $vector_pregunta); //die(json_encode($rs)); if ($rs == "error") { $mensaje[0] = "error_bd"; } else { $rs2 = $obj_evaluacion->cargar_notas($prueba); if ($rs2 == "error") { $mensaje[0] = "error_cargar_notas"; die(json_encode($mensaje)); } $mensaje[0] = $rs[0][0]; die(json_encode($mensaje)); }
require_once "../libs/fbasic.php"; require "../modelos/modelo.bandeja_entrada.php"; require "../modelos/modelo.registrar_auditoria.php"; $vector_grupo = array(); //validando por metodo post... if (isset($_POST["eliminar_sms"])) { $vector_grupo = $_POST["eliminar_sms"]; $cuantos_eliminar = count($vector_grupo); } else { $mensaje = "campos_blancos"; die(json_encode($vector_grupo)); } //DECLARO EL OBJETO $obj_bandejae = new Bandeja_entrada(); for ($i = 0; $i <= $cuantos_eliminar - 1; $i++) { $rs = $obj_bandejae->borrar_sms_inbox($vector_grupo[$i]); if ($rs == "error") { $mensaje[0] = "error"; die(json_encode($mensaje)); } } /////////////////////////////////////////////////--AUDITORIA--/////////////////////////////////////// $auditoria_eva = new auditoria("Bandeja de entrada", "Eliminación de mensajes(ID:" . to_pg_array($vector_grupo) . ")"); $auditoria = $auditoria_eva->registrar_auditoria(); if ($auditoria == false) { $mensaje[0] = 'error_auditoria'; die(json_encode($mensaje)); } //////////////////////////////////////////////////////////////////////////////////////////////////// $mensaje[0] = "eliminacion_exitosa"; die(json_encode($mensaje));
if ($grupo == '-999') { $vector_grupo = $_POST["grupos"]; $cuantos_vg = count($vector_grupo); } else { $vector_grupo[0] = $grupo; $cuantos_vg = 1; } // if ($cuantos_nombres != $cuantos_tlf) { $mensaje[0] = "error1"; die(json_encode($mensaje)); } $obj_destinatarios = new Destinatarios(); $v_nombre = to_pg_array($_POST["carga_ind_nombre"]); $v_tlf = to_pg_array($_POST["carga_ind_tlf"]); $v_grupo = to_pg_array($vector_grupo); $rs = $obj_destinatarios->registrar_destinatarios($v_nombre, $v_tlf, $cuantos_tlf, $cuantos_vg, $v_grupo); //die(json_encode($rs)); if ($rs == 'error') { $mensaje[0] = "error"; die(json_encode($mensaje)); } else { if ($rs[0][0] == "registro_exitoso") { /////////////////////////////////////////////////--AUDITORIA--/////////////////////////////////////// $auditoria_eva = new auditoria("Cargar destinatario", "Registro de destinatarios (TLF:" . $v_tlf . ",GRUPO:" . $v_grupo . ")"); $auditoria = $auditoria_eva->registrar_auditoria(); //die(json_encode($auditoria)); if ($auditoria == false) { $mensaje[0] = 'error_auditoria'; die(json_encode($mensaje)); }