function create_faculty_file()
{
    $fac_file = get_file();
    // Get the html file
    if (empty($fac_file)) {
        return false;
    }
    preg_match('/<tbody(.+)tbody>/sm', $fac_file, $table);
    // Get the table
    $rows = preg_split('/<tr/', $table[0]);
    // Get each row
    array_shift($rows);
    // Get rid of the first element
    $fp = fopen(FACULTY_FILE, 'w');
    // Open the file for writing
    if (empty($fp)) {
        return false;
    }
    if (@flock($fp, LOCK_EX)) {
        // Prevent multiple creations
        foreach ($rows as $row) {
            // Iterate through the rows
            $cols = preg_split('/<td/', $row);
            // Split up the columns
            $name = filter_name($cols[1]);
            // Get the name
            $area = filter_area($cols[2]);
            // Get the area of research
            $mail = filter_email($cols[3]);
            // Get the email
            fwrite($fp, "{$mail},{$name},{$area}\n");
            // Write the output to the file
        }
        flock($fp, LOCK_UN);
    } else {
        fclose($fp);
        // Couldn't get lock
        return false;
    }
    fclose($fp);
    // Close the file
    return true;
}
Beispiel #2
0
     if (preg_match_all($no_character, $contrasena, $matches)) {
         for ($i = 0; $i < count($matches); $i++) {
             for ($e = 0; $e < count($matches[$i]); $e++) {
                 $contrasena_matches = $contrasena_matches . $matches[$i][$e] . ',';
             }
         }
         $contrasena_matches = trim($contrasena_matches, ",");
         $error["pass"] = "******";
     } else {
     }
 }
 if (empty($correo)) {
     $error["correo"] = "<div class='errorsote'>El campo correo es requerido</div>";
 }
 if (!empty($correo)) {
     if (filter_email($correo)) {
     } else {
         $error["correo"] = "<div class='errorsote'>El campo correo tiene que tener el sig formato '*****@*****.**'</div>";
     }
 }
 if (!count($error)) {
     $contrasena = md5($contrasena);
     $fecha = date("Y-m-d H:i:s");
     $codigo_confirmacion = md5($fecha);
     $query = "INSERT INTO usuarios values(NULL,'{$usuario}','{$contrasena}','{$nombre}','{$correo}',1)";
     $db->query($query);
     if (!$db->insert_id) {
         echo "Hubo un error al procesar su petición " . $db->error;
     } else {
         echo "<div class='exito'>Datos almacenados</div>";
     }
Beispiel #3
0
function one_mail($subject, $body, $to)
{
    //returns true=ok, false=notok
    $config = $GLOBALS['config'];
    $from = filter_email($config['mail_username']);
    $subject = filter_name($subject);
    $to = filter_email($to);
    if (isset($config['mail_smtp']) && $config['mail_smtp']) {
        require_once "Mail.php";
        $host = $config['mail_smtp_host'];
        $port = $config['mail_smtp_port'];
        $username = $config['mail_username'];
        $password = $config['mail_password'];
        $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject, 'Content-Type' => 'text/html');
        $smtp = Mail::factory('smtp', array('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password));
        $mail = $smtp->send($to, $headers, $body);
        if (PEAR::isError($mail)) {
            return false;
        } else {
            return true;
        }
    } else {
        $headers = "From: {$from}\r\n";
        $headers .= "To: {$to}\r\n";
        $headers .= "Content-type: text/html\r\n";
        return mail($to, $subject, $body, $headers);
    }
}
 }
 //nombre
 if ($post['tipo'] == 3) {
     @mysqli_query($con, "SET NAMES 'utf8'");
     $id = $_SESSION['clave'];
     $sql = "UPDATE usuarios SET nombre='{$valor}' WHERE id = {$id}";
     if ($con->query($sql) == TRUE) {
         echo json_encode(1);
     } else {
         echo json_encode(0);
         print_r("Error al actualizar: " . $con->error);
     }
 }
 //correo
 if ($post['tipo'] == 4) {
     if (filter_email($correo) == true) {
         @mysqli_query($con, "SET NAMES 'utf8'");
         $id = $_SESSION['clave'];
         $sql = "UPDATE usuarios SET correo='{$valor}' WHERE id = {$id}";
         if ($con->query($sql) == TRUE) {
             echo json_encode(1);
         } else {
             echo json_encode(0);
             print_r("Error al actualizar: " . $con->error);
         }
     } else {
         echo json_encode(0);
     }
 }
 // alta y baja de uausrios
 if ($post['tipo'] == 5) {