示例#1
0
function main()
{
    session_start();
    $verifyCode = getRandomCode();
    $_SESSION['verifyCode'] = $verifyCode;
    if (!isset($_REQUEST["width"])) {
        $imgWidth = 80;
    } else {
        $imgWidth = $_REQUEST["width"];
    }
    if (!isset($_REQUEST["height"])) {
        $imgHeight = 18;
    } else {
        $imgWidth = $_REQUEST["height"];
    }
    if (!isset($_REQUEST["font"])) {
        $imgFont = 6;
    } else {
        $imgWidth = $_REQUEST["font"];
    }
    doOutputImg($verifyCode, $imgWidth, $imgHeight, $imgFont);
}
 global $wpdb;
 for ($i = 0; $i < count($_SESSION['flattereremails']); $i++) {
     if ($_SESSION['flattereremails'][$i] != "") {
         $duplicatecheck = $wpdb->get_var("SELECT COUNT(PID) FROM flatterers WHERE invalid = 0 AND PID = " . $invitePID . " AND flatterer_email = '" . $_SESSION['flattereremails'][$i] . "'");
         if ($duplicatecheck == 0) {
             $wpdb->insert('flatterers', array('PID' => $invitePID, 'flatterer_email' => $_SESSION["flattereremails"][$i], 'flatterer_name' => $_SESSION["flatterernames"][$i], 'responded' => 0), array('%d', '%s', '%s', '%d'));
             $flatterer_id = $wpdb->insert_id;
             // check if flatterbox is private and assign a passcode if so.
             $flatterbox_post = get_post($invitePID);
             $PID = $flatterbox_post->ID;
             $private = get_field("private", $PID);
             // For Passcode
             $can_invite = get_field("can_invite", $PID);
             // For Flatterer able to Invite
             if ($private) {
                 $passcode = getRandomCode();
                 $wpdb->update('flatterers', array('passcode' => $passcode), array('FID' => $flatterer_id), array('%s'), array('%d'));
             }
             //send invitation e-mail
             $bloginfo = get_bloginfo('url');
             $bloginfo2 = home_url();
             //$sentimentneeded = date_create(get_field("date_sentiments_complete",$invitePID));
             $date = DateTime::createFromFormat('d/m/Y', get_field('date_sentiments_complete', $invitePID));
             if ($date) {
                 $sentimentneeded = $date->format('m/d/Y');
             }
             $post_author_id = get_post_field('post_author', $invitePID);
             if (strpos(get_field("box_theme", $invitePID), '(name)') > 0) {
                 $box_theme = str_replace('(name)', get_field("who_is_this_for", $invitePID), get_field("box_theme", $invitePID));
             } else {
                 $box_theme = get_field("box_theme", $invitePID) . ' ' . get_field("who_is_this_for", $invitePID);
示例#3
0
<?php

session_start();
$usuario = $_POST["name_reset"];
$email = $_POST["email_reset"];
$conexion = mysql_connect("mysql.hostinger.es", "u477358893_sigie", "sigie.custodes");
if (!$conexion) {
    $_SESSION['error'] = 'reset_no';
    header('Location: ../index.php');
} else {
    mysql_select_db("u477358893_sigie", $conexion);
    $sql = "SELECT * FROM usuario WHERE user='******' and email='{$email}'";
    $ro = mysql_fetch_array(mysql_query($sql));
    if ($ro) {
        $new_pass = getRandomCode();
        $sql = "UPDATE usuario SET pass='******' WHERE user='******'";
        if (mysql_query($sql)) {
            $subjet = "Sigie - Restablecer contraseña";
            $mensaje = "Su contraseña provicional es: " . $new_pass . " , por su seguridad modifiquela al ingresar.";
            if (mail($email, $subjet, $mensaje)) {
                $_SESSION['error'] = "reset_yes";
                header('Location: ../index.php');
            } else {
                $_SESSION['error'] = "reset_no";
                header('Location: ../index.php');
            }
        } else {
            $_SESSION['error'] = "reset_no";
            header('Location: ../index.php');
        }
    } else {
示例#4
0
function restaurar($strHostMYSQL, $strUserMYSQL, $strPWDMYSQL, $strDBMYSQL, $mail)
{
    $link = mysql_connect($strHostMYSQL, $strUserMYSQL, $strPWDMYSQL);
    mysql_select_db($strDBMYSQL, $link);
    if (mysql_errno() > 0) {
        $strResultOp = "No fue posible validar el usuario.";
        $strInfoTec = "No fue posible localizar el host[" . mysql_errno() . "-" . mysql_error() . "]";
        $strModulo = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/" . basename($_SERVER['PHP_SELF']);
        $strParameters = "host:" . $strHostMYSQL . "~-user:"******"~PWD:" . $strPWDMYSQL . "bd:" . $strDBMYSQL;
    } else {
        $str = "select *from user where mailUser='******'";
        $Res = mysql_query($str);
        if (mysql_errno() > 0) {
            $strResultOp = "No fue posible validar el usuario.";
            $strInfoTec = "No fue posible ejecutar la consulta[" . mysql_errno() . "-" . mysql_error() . "]";
            $strModulo = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/" . basename($_SERVER['PHP_SELF']);
            $strParameters = $str;
            $html = "0";
            // no conexion
        } else {
            if (mysql_num_rows($Res) > 0) {
                $passnew = getRandomCode();
                $strSql = "update user set passUser=password('" . $passnew . "') where mailUser='******'";
                $Result = mysql_query($strSql);
                $html = mailrestaurar($mail, $passnew);
                // enviar mail al usuario para reestablecer contraseña
                // se encontro usuario
            } else {
                $html = "2";
            }
            // no se encontro usuario
        }
    }
    return $html;
}
示例#5
0
 $db->connect();
 $app = $db->query_first("SELECT * FROM app_tokens WHERE token = '{$token}'");
 if ($app) {
     $db->query_update("apps", array("state" => $state), "id = " . $app["appid"]);
     $response = array("success" => "true", "results" => array(array("id" => $app["appid"], "token" => $token)));
     echo json_encode($response);
 } else {
     $touch_lib = $db->query_first("SELECT version FROM touch_libs ORDER BY version DESC");
     $app_id = $db->query_insert("apps", array("name" => $name, "state" => $state, "version" => $touch_lib['version']));
     if (!$app_id) {
         $error = array("success" => "false", "message" => "Internal server error.");
         echo json_encode($error);
     } else {
         $token = "";
         do {
             $token = getRandomCode(5);
             $tokened = $db->query_insert("app_tokens", array("token" => $token, "appid" => $app_id, "lastused" => "CURRENT_TIMESTAMP"));
         } while (mysql_errno() != 0);
         if ($user_token) {
             // add to the user account
             // take uid from token
             $user = $db->query_first("SELECT uid FROM user_tokens WHERE token = '{$user_token}'");
             if ($user && isset($user["uid"])) {
                 $user_id = $user["uid"];
                 $db->query_insert("user_app", array("uid" => $user_id, "appid" => $app_id, "privacy" => $app_privacy));
             }
         }
         // show json response
         $response = array("success" => "true", "results" => array(array("id" => "{$app_id}", "token" => $token)));
         echo json_encode($response);
     }
示例#6
0
/**
 * Function to generate a random number that is not already be used for another user.
 */
function getRandomCode()
{
    // Generate a random 4 digit code
    $code = rand(1000, 9999);
    // Check to make sure this code is not already being used
    global $wpdb;
    $result = $wpdb->get_row("SELECT * FROM {$wpdb->usermeta} WHERE (meta_key = 'nexmo_code') AND (meta_value = '{$code}') LIMIT 1");
    // If this code is already being used, get another random number.
    if ($result) {
        getRandomCode();
    }
    return $code;
}