Пример #1
0
 function SetToken($id)
 {
     $mysql = new MySQL();
     $token = generateCode();
     $mysql->UpdateString($this->NameBase, 'User', "token='" . $token . "'", "id='" . $id . "'");
     return $token;
 }
Пример #2
0
function generateStyles(array $styles)
{
    debug(count($styles) . " styles found");
    foreach ($styles as $style) {
        if (property_exists($style, 'styles') && count($style->styles) == 1 && property_exists($style, 'substyles') && count($style->substyles) > 0) {
            $sourceCode = generateCode($style->styles[0], $style->substyles, true);
            writeClass(filterKeyword($style->styles[0]), $sourceCode);
        } elseif (property_exists($style, 'styles') && count($style->styles) > 0 && !property_exists($style, 'substyles') && count($style->elements) == 1) {
            switch ($style->elements[0]) {
                case 'label':
                    $_style = 'LabelStyles';
                    break;
                case 'frame3d':
                    $_style = 'Frame3dStyles';
                    break;
                default:
                    throw new UnexpectedValueException('Woot');
            }
            $sourceCode = generateCode($_style, $style->styles, false);
            writeClass($_style, $sourceCode);
        } else {
            debug("Cannot process element");
        }
    }
}
Пример #3
0
function generateCookie($user, $extended)
{
    $code = generateCode(32, $user);
    $code2 = grHash($code, $user);
    $monthLater = time() + 30 * 24 * 60 * 60;
    $dbh = ConnectToDB();
    $stmt = $dbh->prepare("UPDATE active_users SET last_session_code=?,session_expiration=? WHERE email=?");
    $stmt->execute(array($code2, date("Y-m-d H:i:s", $monthLater), $user));
    return $code;
}
Пример #4
0
 public function submit_details()
 {
     $alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
     function generateCode($length = 2)
     {
         $az = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
         $azr = rand(0, 25);
         $azs = substr($az, $azr, 10);
         $stamp = hash('sha256', time());
         $mt = hash('sha256', mt_rand(5, 20));
         $alpha = hash('sha256', $azs);
         $hash = str_shuffle($stamp . $mt . $alpha);
         $code = ucfirst(substr($hash, $azr, $length));
         return $code;
     }
     function generateCode1($length = 3)
     {
         $az = '1234567890';
         $azr = rand(0, 9);
         $azs = substr($az, $azr, 5);
         $stamp = hash('sha256', time());
         $mt = hash('sha256', mt_rand(1, 5));
         $alpha = hash('sha256', $azs);
         $hash = str_shuffle($stamp . $mt . $alpha);
         $code1 = ucfirst(substr($hash, $azr, $length));
         return $code1;
     }
     $name = $this->input->post('txt_name');
     $mail = $this->input->post('txt_email');
     $phn = $this->input->post('txt_phn');
     $alt_phn = $this->input->post('txt_alt_phn');
     if ($alt_phn == '') {
         $alt_phn1 = 'N/A';
     } else {
         $alt_phn1 = $alt_phn;
     }
     $add = $this->input->post('txt_address');
     $country = $this->input->post('txt_country');
     $state = $this->input->post('txt_state');
     $city = $this->input->post('txt_city');
     $zip = $this->input->post('txt_pin');
     $id = generateCode() . '/' . generateCode1();
     $pass = generateCode() . '@' . generateCode1();
     $fields = array('name' => $name, 'email' => $mail, 'phone' => $phn, 'alt_phone' => $alt_phn1, 'address' => $add, 'country' => $country, 'state' => $state, 'city' => $city, 'zip' => $zip, 'emp_id' => $id, 'emp_pass' => $pass);
     $service = $this->base_model->form_post('td_employee_details', $fields);
     if ($service) {
         $category['data'] = $this->base_model->show_data('td_employee_details', '*', '')->result_array();
         $this->load->view('employee/emp_details', $category);
     } else {
         $category['msg'] = 'Sorry ! Category was not successfully Inserted';
         $this->load->view('employee/emp_details', $category);
     }
 }
Пример #5
0
function generateActivation($pdo, $userId)
{
    // Create an activation code 20 characters long
    $code = generateCode(20);
    // Create the activation code listing using $userId
    $stmt = $pdo->prepare('INSERT INTO AccountActivation (UserId, ActivationCode) VALUES (:userId, :activationCode);');
    $stmt->bindParam(':userId', $userId, PDO::PARAM_INT);
    // <-- Automatically sanitized for SQL by PDO
    $stmt->bindParam(':activationCode', $code, PDO::PARAM_STR);
    // <-- Automatically sanitized for SQL by PDO
    $stmt->execute();
    // Give the $code to the rest of the program
    return $code;
}
 public function create($input)
 {
     // Set transaction instance
     $transaction = new Transaction(['code' => generateCode(), 'draw' => getDrawTime()]);
     // Create transaction
     Auth::user()->transactions()->save($transaction);
     // Set transaction for the bet
     if ($input['type'] == 'fourdigit') {
         Auth::user()->bets()->whereIn('type', ['last2', 'last3', 'fourdigit'])->where('transaction_id', '=', null)->update(['transaction_id' => $transaction->id]);
     } elseif ($input['type'] == 'swertres') {
         Auth::user()->bets()->whereIn('type', ['swertwo', 'swertres'])->where('transaction_id', '=', null)->update(['transaction_id' => $transaction->id]);
     } else {
         Auth::user()->bets()->where('type', '=', $input['type'])->where('transaction_id', '=', null)->update(['transaction_id' => $transaction->id]);
     }
     return $transaction;
 }
function insertSmallJob()
{
    if (isset($_POST['agree'])) {
        include 'connection.php';
        $date = date("d/m/Y");
        $secretCode = generateCode();
        $name = $_POST['name'];
        $email = $_POST['email'];
        $phone = $_POST['phone'];
        $location = $_POST['location'];
        $region = $_POST['region'];
        $description = $_POST['description'];
        $type = $_POST['type'];
        if (!empty($name) && !empty($email) && !empty($phone) && !empty($location) && !empty($region) && !empty($description)) {
            $insert = "INSERT INTO smallJobs (name, phone, email, activation, secretCode, location, description, region, types, date) VALUES ('{$name}', '{$phone}', '{$email}', 0, '{$secretCode}' , '{$location}', '{$description}', '{$region}', '{$type}', '{$date}')";
            $insertSmallJob = mysqli_query($connect, $insert) or die(mysqli_error());
            echo "<div class='container'><h1>Skelbimas pridėtas</h1><br>Jūsų skelbimo slaptas kodas yra <h2>{$secretCode}</h2>. Prašome jį saugiai užsirašyti. Jūsų slaptas kodas taip pat išsiųstas Jūsų nurodytu el. paštu. Prašome pasitikrinti el.pašto dėžutę. Jeigu nematote, rekomenduojame patikrinti ir šiukšlių dėžutę (angl. spam). Su šiuo kodu Jūs bet kada galėsite koreguoti skelbimo turinį ar jį ištrinti.<br>Skelbimą galėsite matyti tinklapyje tuomet kai jį aktyvuos administratorius. Prašome palaukti. <br>Dėkojame, kad naudojatės mūsų paslaugomis.<br></div>";
            //================
            //   Mailing system
            //=================
            $to = $_POST['email'];
            $subject = "Jūsų smulkaus darbo registracija katalogas.no";
            $name = $_POST['name'];
            $headers = "From: Katalogas.no registracija <*****@*****.**>" . "\r\n";
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Type: text/html; charset=UTF-8" . "\r\n";
            $message = '<html><body>';
            $message .= "Sveiki,";
            $message .= "<br><br>Jūs sėkmingai pridėjote reklamą/skelbimą " . $name . ". Norėdami jį redaguoti ar ištrinti naudokite šitą kodą: <b>" . $secretCode . "</b>.";
            $message .= "<br>Rekomenduojame šio kodo niekam neskleisti ir nesidalinti, taip siekiant užtikrinti Jūsų skelbimo saugumą.";
            $message .= "<br>Jeigu turite kokių nors klausimų ar pasiūlymų, prašome kreiptis el. paštu administracija@katalogas.no.";
            $message .= "<br><br>Taip pat prašome neatsakyti (nenaudoti reply) į šį el. laišką, nes tai yra automatinis pranešimas.";
            $message .= "<br><br>Dėkojame, kad naudojatės katalogas.no. <br><br> Pagarbiai <br> katalogas.no kolektyvas.";
            $message .= '</body></html>';
            mail($to, $subject, $message, $headers);
        } else {
            echo "<div class='container'><h1>Pažymėti laukai * yra privalomi. Prašome užpildyti pažymėtus * laukus.</h1></div>";
        }
    } else {
        echo "<div class='container'><h1>Jūs privalote susipažinti su taisyklėmis!</h1></div>";
    }
}
function insertAd()
{
    if (isset($_POST['agree'])) {
        include 'connection.php';
        $adsCode = generateCode();
        $name = $_POST['name'];
        $email = $_POST['email'];
        $phone = $_POST['phone'];
        $website = $_POST['website'];
        $facebook = $_POST['facebook'];
        $town = $_POST['town'];
        $region = $_POST['region'];
        $category = $_POST['category'];
        $description = $_POST['description'];
        $worksHours = $_POST['workHours'];
        $workHoursWeekend = $_POST['workHoursWeekend'];
        //==============
        // Photo upload
        //==============
        $logoRandom = imageNameGenerator();
        $logoName = $_FILES['logo']['name'];
        $logoSize = $_FILES['logo']['size'];
        $logoType = $_FILES['logo']['type'];
        $logoTemp = $_FILES['logo']['tmp_name'];
        $logoExtension = strtolower(substr(strrchr($logoName, '.'), 1));
        $newLogoName = $logoRandom . '.' . $logoExtension;
        if (!empty($name) && !empty($email) && !empty($phone) && !empty($description) && !empty($town)) {
            if (!empty($logoName)) {
                if ($logoType == "image/jpeg" || $logoType == "image/png" || $logoType == "image/bmp" || $logoType == "image/gif" || $logoType == "image/jpg" || $logoType == "image/psd" || $logoType == "image/tiff" || $logoType == "image/tga" || $logoType == "") {
                    if ($logoSize < 500000) {
                        move_uploaded_file($logoTemp, "images/catalogLogos/" . $newLogoName);
                        echo "Logotipas ikeltas!";
                    } else {
                        die("Paveikslelis per didelis.");
                    }
                } else {
                    die("Neleistinas failo formatas.");
                }
            } else {
                $newLogoName = "noLogo.png";
            }
            $insert = "INSERT INTO katalogas (name, phone, email, activation, adsCode, website, facebook, town, description, worksHours, workHoursWeekend, logoName, region, category) VALUES ('{$name}', '{$phone}', '{$email}', 0, '{$adsCode}', '{$website}', '{$facebook}', '{$town}', '{$description}', '{$worksHours}' , '{$workHoursWeekend}', '{$newLogoName}', '{$region}', '{$category}')";
            $insertAd = mysqli_query($connect, $insert) or die(mysqli_error());
            echo "<div class='container'><h1>Įmonė/paslauga pridėta</h1><br>Jūsų skelbimo slaptas kodas yra <h2> {$adsCode} </h2>. Prašome jį saugiai užsirašyti.Jūsų slaptas kodas taip pat išsiųstas Jūsų nurodytu el. paštu. Prašome pasitikrinti el.pašto dėžutę. Jeigu nematote, rekomenduojame patikrinti ir šiukšlių dėžutę (angl. spam). Su šiuo kodu Jūs bet kada galėsite koreguoti įmonės/paslaugos reklamos turinį ar ją ištrinti.<br>Skelbimą galėsite matyti tinklapyje tuomet kai jį aktyvuos administratorius. Prašome palaukti. <br>Dėkojame, kad naudojatės mūsų paslaugomis.<br></div>";
            //================
            //   Mailing system
            //=================
            $to = $_POST['email'];
            $subject = "Jūsų kompanijos registracija katalogas.no";
            $headers = "From: Katalogas.no registracija <*****@*****.**>" . "\r\n";
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Type: text/html; charset=UTF-8" . "\r\n";
            $message = '<html><body>';
            $message .= "Sveiki,";
            $message .= "<br><br>Jūs sėkmingai pridėjote įmonę/paslaugą " . $name . ". Norėdami ją redaguoti ar ištrinti naudokite šitą kodą: <b>" . $adsCode . "</b>.";
            $message .= "<br>Rekomenduojame šio kodo niekam neskleisti ir nesidalinti, taip siekiant užtikrinti Jūsų skelbimo saugumą.";
            $message .= "<br>Jeigu turite kokių nors klausimų ar pasiūlymų, prašome kreiptis el. paštu administracija@katalogas.no.";
            $message .= "<br><br>Taip pat prašome neatsakyti (nenaudoti reply) į šį el. laišką, nes tai yra automatinis pranešimas.";
            $message .= "<br><br>Dėkojame, kad naudojatės katalogas.no. <br><br> Pagarbiai <br> katalogas.no kolektyvas.";
            $message .= '</body></html>';
            mail($to, $subject, $message, $headers);
        } else {
            echo "<div class='container'><h1>Pažymėti laukai * yra privalomi. Prašome užpildyti pažymėtus * laukus.</h1></div>";
        }
    } else {
        echo "<div class='container'>Jūs privalote susipažinti su taisyklėmis!</div>";
    }
}
Пример #9
0
//$targetPath="".WEB_PATH."";
//var $font = '/home/www/htdocs/capcha/monofont.ttf'; //╡├╟и╩═║ path р═з┴╥у╩ш╣╨д├╤║
$_SERVER['DOCUMENT_ROOT'] = dirname(dirname(__FILE__));
$targetPath = $_SERVER['DOCUMENT_ROOT'];
function generateCode($characters)
{
    $possible = '╝╗═╖┴┐╦б┤╩╟з╛├╣┬║┼└╢д╡ивк';
    //		$possible = _CAPTCHA_RAN;
    $code = '';
    $i = 0;
    while ($i < $characters) {
        $code .= substr($possible, mt_rand(0, strlen($possible) - 1), 1);
        $i++;
    }
    return $code;
}
$font = $targetPath . "/capcha/font/angsab.ttf";
$code = generateCode($_GET['characters']);
$im = imagecreate($_GET['width'], $_GET['height']);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
$new_string = tis620_to_utf8($code);
imagefill($im, 0, 0, $black);
imageTTFText($im, 20, 0, 6, 18, $white, $font, $new_string);
if (ISO == 'utf-8') {
    $_SESSION["security_code"] = $new_string;
} else {
    $_SESSION["security_code"] = utf8_to_tis620($new_string);
}
imagepng($im);
imagedestroy($im);
Пример #10
0
 $SUSERID = $result->fields['USERID'];
 $SEMAIL = $result->fields['email'];
 $SUSERNAME = $result->fields['username'];
 $SVERIFIED = $result->fields['verified'];
 $SPP = $result->fields['profilepicture'];
 $SFNAME = $result->fields['fname'];
 $SLNAME = $result->fields['lname'];
 $_SESSION['USERID'] = $SUSERID;
 $_SESSION['EMAIL'] = $SEMAIL;
 $_SESSION['USERNAME'] = $SUSERNAME;
 $_SESSION['VERIFIED'] = $SVERIFIED;
 $_SESSION['PP'] = $SPP;
 $_SESSION['FNAME'] = $SFNAME;
 $_SESSION['LNAME'] = $SLNAME;
 // Generate Verify Code Begin
 $verifycode = generateCode(5) . time();
 $query = "INSERT INTO members_verifycode SET USERID='" . mysql_real_escape_string($SUSERID) . "', code='{$verifycode}'";
 $conn->execute($query);
 if (mysql_affected_rows() >= 1) {
     $proceedtoemail = true;
 } else {
     $proceedtoemail = false;
 }
 // Generate Verify Code End
 // Send Welcome E-Mail Begin
 if ($proceedtoemail) {
     $sendto = $SEMAIL;
     $sendername = $config['site_name'];
     $from = $config['site_email'];
     $subject = $lang['67'] . " " . $sendername;
     $sendmailbody = stripslashes($_SESSION['USERNAME']) . ",<br><br>";
Пример #11
0
    while ($i < $characters) {
        $code .= substr($possible, mt_rand(0, strlen($possible) - 1), 1);
        $i++;
    }
    return $code;
}
function print_image($code, $width = 120, $height = 40, $characters = 6)
{
    $font_path = __DIR__ . '/monofont.ttf';
    $font_size = $height * 0.75;
    $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
    $background_color = imagecolorallocate($image, 255, 255, 255);
    $text_color = imagecolorallocate($image, 20, 40, 100);
    $noise_color = imagecolorallocate($image, 225, 160, 11);
    for ($i = 0; $i < $width * $height / 3; $i++) {
        imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
    }
    $textbox = imagettfbbox($font_size, 0, $font_path, $code) or die('Error in imagettfbbox function');
    $x = ($width - $textbox[4]) / 2;
    $y = ($height - $textbox[5]) / 2;
    imagettftext($image, $font_size, 0, $x, $y, $text_color, $font_path, $code) or die('Error in imagettftext function');
    header('Content-Type: image/jpeg');
    imagejpeg($image);
    imagedestroy($image);
    exit;
}
$width = isset($_GET['width']) ? (int) $_GET['width'] : 253;
$height = isset($_GET['height']) ? (int) $_GET['height'] : 60;
$characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? (int) $_GET['characters'] : 6;
$_SESSION['security_code'] = generateCode($characters);
print_image($_SESSION['security_code'], $width, $height, $characters);
Пример #12
0
 public function __construct($app)
 {
     $this->app = $app;
     $app->group('/user', function () use($app) {
         $app->get('/autocomplete', function () {
             $userService = new \Core\Service\UserService();
             echo json_encode($userService->getAutocomplete($_GET['s']));
         });
         $app->get('/check', function () {
             $userAvailible = ECP\UserQuery::create()->filterByName($_GET['name'])->count() == 0;
             echo json_encode((object) array('isAvailible' => $userAvailible));
         });
         $app->get('/status', function () {
             $userService = new \Core\Service\UserService();
             $isLoggedIn = $userService->isLoggedIn();
             if (!$isLoggedIn) {
                 die(json_encode((object) array('isLoggedIn' => false)));
             }
             $user = $userService->getLoggedInUser();
             echo json_encode((object) array('isLoggedIn' => true, 'id' => $user->id, 'username' => $user->username));
         });
         $app->post('/login', function () {
             $p = getPost();
             $user = ECP\UserQuery::create()->filterByName($p->username)->filterByPassword(sha1($p->password))->filterByConfirmationCode('')->findOne();
             if (!$user) {
                 die(json_encode((object) array('status' => 'incorrect credentials')));
             }
             $_SESSION['ecp'] = (object) array('id' => $user->getId(), 'username' => $user->getName());
             echo $this->getBoolStatus(true);
         });
         $app->post('/register', function () {
             $userService = new \Core\Service\UserService();
             $p = getPost();
             if (strpos($p->username, '/') !== false) {
                 die_err('Slashes are not allowed in names!');
             }
             $code = generateCode();
             $user = new ECP\User();
             $user->setName($p->username);
             $user->setPassword(sha1($p->password));
             $user->setEmail($p->email);
             $user->setCreated(time());
             $user->setConfirmationCode($code);
             $user->save();
             $userService->sendRegistrationMail($user);
             echo $this->getBoolStatus(true);
         });
         $app->post('/logout', function () {
             unset($_SESSION['ecp']);
             echo '{}';
         });
         $app->post('/recover-password', function () {
             $userService = new \Core\Service\UserService();
             $p = getPost();
             $users = ECP\UserQuery::create()->filterByEmail($p->email)->filterByConfirmationCode('')->find();
             foreach ($users as $user) {
                 $code = generateCode();
                 $user->setRecoverPasswordCode($code);
                 $user->save();
                 $userService->sendRecoverPassword($user);
             }
             echo $this->getBoolStatus(true);
         });
         $app->get('/reset-password-check', function () {
             $userCount = ECP\UserQuery::create()->filterByRecoverPasswordCode($_GET['code'])->count();
             echo $this->getBoolStatus($userCount != 0);
         });
         $app->post('/reset-password', function () {
             $p = getPost();
             $users = ECP\UserQuery::create()->filterByRecoverPasswordCode($p->code)->find();
             $found = false;
             foreach ($users as $user) {
                 $user->setRecoverPasswordCode('');
                 $user->setPassword(sha1($p->password));
                 $user->save();
                 $found = true;
             }
             echo $this->getBoolStatus($found);
         });
         $app->post('/confirm-registration', function () {
             $p = getPost();
             $users = ECP\UserQuery::create()->filterByConfirmationCode($p->code)->find();
             $found = false;
             foreach ($users as $user) {
                 $user->setConfirmationCode('');
                 $user->save();
                 $found = true;
             }
             echo $this->getBoolStatus($found);
         });
     });
 }
Пример #13
0
function sendRandomPass($email)
{
    $query = "select name from user where email='{$email}'";
    $status = mysql_query($query);
    $row = mysql_fetch_array($status);
    $user = $row['name'];
    $pass = generateCode();
    $salt = substr("{$user}", 0, 2);
    $epass = crypt($pass, $salt);
    $email = mysql_real_escape_string($email);
    $to = "{$email}";
    $from = "From: nobody@change.this.now";
    $subject = "password";
    $body = "hi, your password is {$pass}. please login using your email address and the password.  feel free to change your password at anytime.";
    if (mail($to, $subject, $body, $from)) {
        $params = array('email' => $email, 'pass' => $epass);
        $result = query("user.sendRandomPass", $params);
        echo "<p>Your new password has been sent!  <a href='login.php'>login</a> after you receive your password.</p>";
    } else {
        echo "<p>Message delivery failed...</p>";
    }
}
$HOST_NAME = '127.0.0.1';
$USER_NAME = 'root';
$PASSWORD = '';
// Parse command line
if ($argc > 1) {
    $ACTION = $argv[1];
}
if ($ACTION == 'help') {
    die("Usage:\n\tphp query_cache_triggers [<action> [<hostname> [<username> [<password>]]]]\n");
}
$ALLOWED_ACTIONS = array('create', 'remove', 'gencode');
if (!in_array($ACTION, $ALLOWED_ACTIONS)) {
    die("Error: Invalid action {$ACTION} possible actions: " . implode(', ', $ALLOWED_ACTIONS) . "\n");
}
if ($ACTION == 'gencode') {
    generateCode();
    die;
}
if ($argc > 2) {
    $HOST_NAME = $argv[2];
}
if ($argc > 3) {
    $USER_NAME = $argv[3];
}
if ($argc > 4) {
    $PASSWORD = $argv[4];
}
// Connect to database
$link = mysql_connect($HOST_NAME, $USER_NAME, $PASSWORD) or die('Error: Could not connect: ' . mysql_error() . "\n");
// Make sure 'Memcached Functions for MySQL' is installed
mysql_select_db('mysql') or die("Error: Could not select 'mysql' database\n");
}
function generateCode($characters)
{
    // list all possible characters, similar looking characters and vowels have been removed
    $possible = '23456789bcdfghjkmnpqrstvwxyz';
    $code = '';
    $i = 0;
    while ($i < $characters) {
        $code .= substr($possible, mt_rand(0, strlen($possible) - 1), 1);
        $i++;
    }
    $session =& JFactory::getSession();
    $session->set('code', $code);
    return $code;
}
generateCode(5);
?>
	<script>
function clear_ses()
{
var form=document.contactform;
my_name.value="";
email.value="";
testimonial.value="";
return false;
}
</script>

<h2><?php 
echo $menuname;
?>
Пример #16
0
 public function sendCheckcode()
 {
     $phone = I('get.phone');
     if (!preg_match('/^[1][3458]{1}[0-9]{9}$/', $phone)) {
         $this->error('手机号码格式有误');
     }
     //手机号码格式检测
     $res = M('Member')->where(array('user_phone' => $phone))->field('user_phone')->find();
     if ($res['user_phone']) {
         $this->error("手机号码已经被注册了");
     }
     $code = generateCode();
     if (sendSMS($phone, $code)) {
         $this->success('发送成功,请注意查收短信');
     } else {
         $this->error('未知错误,短信发送失败,请联系hmv客服');
     }
 }
function addAccount($username, $password, $email, $phone)
{
    $code = generateCode($username, $email);
    $password = ENCRYPT . $password;
    $password = SHA1($password);
    $added_by = "admin";
    //Add an account
    $sql = "INSERT INTO users(username, password, code, email, added_by, added_on) VALUES(:username, :password, :code, :email, :added_by, NOW())";
    $params = array(':username' => $username, ':password' => $password, ':email' => $email, ':code' => $code, ':added_by' => $added_by);
    $result = DatabaseHandler::Execute($sql, $params);
    //Add empty profile for that account
    $user_id = getAccountid($username);
    $sql = "INSERT INTO user_details(user_id, contact, added_on) VALUES(:user_id, :phone, NOW())";
    $params = array(':user_id' => $user_id, ':phone' => $phone);
    $result = DatabaseHandler::Execute($sql, $params);
    //login time
    $ip = $_SERVER['REMOTE_ADDR'];
    $sql = "INSERT INTO log_login_sessions(username, ip) VALUES(:username, :ip)";
    $params = array(':username' => $username, ':ip' => $ip);
    $result = DatabaseHandler::Execute($sql, $params);
    return;
}
Пример #18
0
 private function _generateBarCodes($nos)
 {
     $barcodes = array();
     for ($i = 1; $i <= $nos; $i++) {
         $text = generateCode(10, 2);
         $dest = "assets/barcodes/" . $text . ".jpg";
         Barcode39($text, $text, $dest, 220, 120);
         $barcodes[$i] = $text;
     }
     return $barcodes;
 }
Пример #19
0
<?php

include_once "base.php";
session_start();
$p = $_POST;
$cIdE = explode(",", $p['cId']);
$countE = explode(",", $p['count']);
$cId = $p['cId'];
$count = $p['count'];
$email = $p['email'];
$hash = generateCode(32);
$_SESSION['hash'] = $hash;
$first_name = $p['first_name'];
$last_name = $p['last_name'];
$address = $p['address'];
$query = "SELECT * FROM `js_catalog` WHERE 1!=1";
for ($i = 0; $i < sizeof($cIdE); $i++) {
    $query .= " OR `cId`=" . $cIdE[$i];
}
$d = SQL($query);
SQL("INSERT INTO `js_card`(`cId`, `count`, `hash`, `email`, `first_name`, `last_name`, `address`) VALUES ('" . $cId . "', '" . $count . "', '" . $hash . "', '" . $email . "', '" . $first_name . "', '" . $last_name . "', '" . $address . "')");
$m = '<a href="http://js.apicat.ru/' . $hash . '">Перейти к заказу</a>';
$m .= '<br/>Имя: ' . $first_name;
$m .= '<br/>Фамилия: ' . $last_name;
$m .= '<br/>Адрес: ' . $address;
$to = $email;
$text = $m;
$subject = "Заказ оформлен!";
$from_name = "*****@*****.**";
$dc = "UTF-8";
$sc = "windows-1251";
Пример #20
0
         $_SESSION['FNAME'] = $result->fields['fname'];
         $_SESSION['LNAME'] = $result->fields['lname'];
         $_SESSION['FB'] = "1";
         if (isset($_SESSION['PINREDIRECT'])) {
             $pindir = $_SESSION['PINREDIRECT'];
             $pindir = base64_decode($pindir);
             $_SESSION['PINREDIRECT'] = "";
             header("Location:{$config['baseurl']}" . $pindir);
             exit;
         } else {
             header("Location:{$config['baseurl']}/");
             exit;
         }
     }
 } else {
     $mdpass = generateCode(5) . time();
     $md5pass = md5($mdpass);
     if ($fname != "" && $femail != "") {
         $thename = explode(" ", $fname);
         $fname = $thename[0];
         $mname = $thename[1];
         $lname = $thename[2];
         if ($lname == "") {
             $lname = $mname;
         }
         $query = "INSERT INTO members SET email='" . mysql_real_escape_string($femail) . "', fname='" . mysql_real_escape_string($fname) . "', lname='" . mysql_real_escape_string($lname) . "', username='', password='******', pwd='" . mysql_real_escape_string($mdpass) . "', addtime='" . time() . "', lastlogin='******', ip='" . $_SERVER['REMOTE_ADDR'] . "', lip='" . $_SERVER['REMOTE_ADDR'] . "', verified='1'";
         $result = $conn->execute($query);
         $userid = mysql_insert_id();
         if ($userid != "" && is_numeric($userid) && $userid > 0) {
             $query = "SELECT USERID,email,verified,profilepicture,fname,lname from members WHERE USERID='" . mysql_real_escape_string($userid) . "'";
             $result = $conn->execute($query);
Пример #21
0
$options = ['cost' => $config['PsaltCost'], 'salt' => $salt . $config['Ppepper']];
// Create hash of their 'old password' entry
$oldHash = password_hash($_POST['old_password'], $config['PhashPattern'], $options);
if ($oldHash == $hash) {
    // Old Password Correct
    if ($_POST['new_password'] == $_POST['new_password_confirm']) {
        // New Password == Password confirmation
        if (strlen($_POST['new_password']) >= 7) {
            // Password >= 7 chars
            if (strlen($_POST['new_password']) <= 20) {
                // Password <= 20 chars
                if (preg_match("/(?:.*[^abcdefghijklmnopqrstuvwxyz0123456789\\[\\]\\(\\)\\{\\}\\@\\#\\!\\£\$\\%\\^\\&\\*\\?\\<\\>].*)+/i", $_POST['new_password']) == 0) {
                    // Password contains valid characters
                    if ($_POST['old_password'] != $_POST['new_password']) {
                        // New password is different from old password
                        $newSalt = generateCode($config['PsaltLength']);
                        $options = ['cost' => $config['PsaltCost'], 'salt' => $newSalt . $config['Ppepper']];
                        // Generate new hash + salt for new password
                        $newHash = password_hash($_POST['new_password'], $config['PhashPattern'], $options);
                        $stmt = $pdo->prepare("UPDATE Users SET Hash = :newHash WHERE Id = :id;");
                        $stmt->bindParam(':newHash', $newHash, PDO::PARAM_STR);
                        // <-- Automatically sanitized for SQL by PDO
                        $stmt->bindParam(':id', $userId, PDO::PARAM_INT);
                        // <-- Automatically sanitized for SQL by PDO
                        $stmt->execute();
                        $stmt = $pdo->prepare("UPDATE Users SET Salt = :newSalt WHERE Id = :id;");
                        $stmt->bindParam(':newSalt', $newSalt, PDO::PARAM_STR);
                        // <-- Automatically sanitized for SQL by PDO
                        $stmt->bindParam(':id', $userId, PDO::PARAM_INT);
                        // <-- Automatically sanitized for SQL by PDO
                        $stmt->execute();
Пример #22
0
} else {
    $mapView = $conArr[0]->mapView;
}
function generateCode($characters)
{
    $possible = '987654321AbcdEFghJkMnpqrsTvwxYz';
    $code = '';
    $i = 0;
    while ($i < $characters) {
        $code .= substr($possible, mt_rand(0, strlen($possible) - 1), 1);
        $i++;
    }
    return $code;
}
$spamStatus = $conArr[0]->companySpamcheck;
$randSpamCode = generateCode(4);
?>
<script src="DWConfiguration/ActiveContent/IncludeFiles/AC_ActiveX.js" type="text/javascript"></script>
<script src="DWConfiguration/ActiveContent/IncludeFiles/AC_RunActiveContent.js" type="text/javascript"></script>

<div>

<script language="javascript" >

	function comGoogleFrmValidate(comfrm)
		{
			
			var errorStr='';	
			my_name = document.comGoogleForm.myName;
			my_email = document.comGoogleForm.myEmail;
			mess_heading = document.comGoogleForm.messHeading;	
Пример #23
0
 function CaptchaSecurityImages($width = '120', $height = '40', $characters = '6')
 {
     $CI =& get_instance();
     $font = './assets/font/monofont.ttf';
     $code = generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.75;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 255, 255, 255);
     $text_color = imagecolorallocate($image, 20, 40, 100);
     $noise_color = imagecolorallocate($image, 100, 120, 180);
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 3; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
     }
     /* generate random lines in background */
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
     }
     /* create textbox and add text */
     $textbox = imagettfbbox($font_size, 0, $font, $code) or die('Error in imagettfbbox function');
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     imagettftext($image, $font_size, 0, $x, $y, $text_color, $font, $code) or die('Error in imagettftext function');
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
     $CI->session->set_userdata("security_code", $code);
 }
Пример #24
0
<?php

header("Content-Type: application/json");
include "../dbconnection.php";
$email = mysql_real_escape_string($_POST['email']);
$password = mysql_real_escape_string(md5($_POST['pass']));
$verificationcode = mysql_real_escape_string($_POST['code']);
$verificationcode = generateCode(1);
updateAppUserPassword($email, $password, $verificationcode);
$status = array('status' => 0, 'success' => 'Password Change Successfully');
echo json_encode($status);
Пример #25
0
 public function password_find_send_sms()
 {
     if ($_SESSION['find_password_user']) {
         $phone = $_SESSION['find_password_user']['user_phone'];
     } else {
         $this->error("错误");
     }
     $code = generateCode();
     if (sendSMS($phone, $code)) {
         $this->success('发送成功,请注意查收短信');
     } else {
         $this->error('未知错误,短信发送失败,请联系hmv客服');
     }
 }
Пример #26
0
function new_room($title, $add_guest, $email_guest, $date, $time)
{
    $rooms_isset_of_user = mysql_fetch_assoc(mysql_query("SELECT COUNT(`id`) as count FROM `rooms` WHERE (`first_p` = " . mysql_real_escape_string($_COOKIE['id']) . " OR `second_p` = " . mysql_real_escape_string($_COOKIE['id']) . ") AND `active` = 1"));
    $err = array();
    if ($rooms_isset_of_user['count'] > 0) {
        $err[] = 'Вы уже участвуете в какой-либо комнате. Завершите участие в комнате, чтобы начать новый раунд';
    }
    if (mb_strlen($title, 'utf-8') < 3) {
        $err[] = 'Название не подходит по условию';
    }
    if (!preg_match("/^([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})\$/", $date)) {
        $err[] = 'Дата указана неверно';
    }
    if (!preg_match("/^([0-9]{2}):([0-9]{2})\$/", $time)) {
        $err[] = 'Время указано неверно';
    }
    $second_id = 0;
    if ($add_guest == 1) {
        $second_user = mysql_fetch_assoc(mysql_query("SELECT `id` FROM `users` WHERE `email` = '" . $email_guest . "'"));
        if ($second_user == true) {
            if (!preg_match("/^([A-z0-9_\\.-]{2,64}+)@([A-z0-9_\\.-]+){1,8}\\.([A-z\\.]{1,15})\$/", $email_guest)) {
                $err[] = 'Email пользователя не подходит по условию';
            }
            $second_id = $second_user['id'];
        }
    }
    if (count($err) == 0) {
        $date = explode(".", $date);
        if ($date[0] < 10) {
            $date[0] = '0' . $date[0];
        }
        if ($date[1] < 10) {
            $date[1] = '0' . $date[1];
        }
        $date = $date[2] . '-' . $date[1] . '-' . $date[0];
        $time = $time . ":00";
        $datetime = $date . ' ' . $time;
        $hash = md5(generateCode(10));
        mysql_query("INSERT INTO `rooms` SET `title` = '" . mysql_real_escape_string($title) . "', `first_p` = '" . mysql_real_escape_string($_COOKIE['id']) . "', `second_p` =  '" . $second_id . "', `time_start` = '" . $datetime . "', `active` = 1") or die(mysql_error());
        header('Location: /');
    } else {
        echo '<strong>Ошибки: </strong><br>';
        foreach ($err as $errors) {
            echo $errors . '<br>';
        }
    }
}
Пример #27
0
        $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_SPECIAL_CHARS);
        $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
        if ($_POST['password'] == $username) {
            $errormessage = $localize->Translate('error_invalid_passwor');
        } elseif (!validemail($email)) {
            $errormessage = $localize->Translate('error_invalid_email');
        } elseif (!validusername($username)) {
            $errormessage = $localize->Translate('error_invalid_login');
        } else {
            $result = $db->query("SELECT email FROM users WHERE (email='{$email}')");
            if ($db->num_rows($result) > 0) {
                $errormessage = $localize->Translate('error_registered_email') . $email . $localize->Translate('error_registered');
            } else {
                $result = $db->query("SELECT username FROM users WHERE (username='******')");
                if ($db->num_rows($result) > 0) {
                    $errormessage = $username . $localize->Translate('error_registered');
                } else {
                    $secret = generateCode();
                    $passhash = md5($secret . $_POST['password'] . $secret);
                    $last_login = time();
                    $query = "INSERT INTO users (username, passhash, secret, email, last_login) VALUES ('{$username}', '{$passhash}', '{$secret}', '{$email}', {$last_login})";
                    $db->query($query);
                    $_SESSION['username'] = $username;
                    $_SESSION['userid'] = $db->result($db->query("SELECT id FROM users WHERE (username='******')"), 0);
                    header("Location: ?page=private");
                    exit;
                }
            }
        }
    }
}
Пример #28
0
function codeDispatch($op)
{
    checkPerm('view');
    if (Get::req('undo_group', DOTY_MIXED, '') || Get::req('cancelselector', DOTY_MIXED, '')) {
        $op = 'list';
    }
    if (Get::req('undo_code', DOTY_MIXED, '')) {
        $op = 'code_list';
    }
    switch ($op) {
        case 'add_group_code':
            addGroupCode();
            break;
        case 'mod_group_code':
            modGroupCode();
            break;
        case 'del_group_code':
            delGroupCode();
            break;
        case 'code_list':
            codeList();
            break;
        case 'add_code':
            addCode();
            break;
        case 'mod_code':
            modCode();
            break;
        case 'del_code':
            delCode();
            break;
        case 'assign_course':
            assignCourse();
            break;
        case 'assign_tree':
            assignTree();
            break;
        case 'generate_code':
            generateCode();
            break;
        case 'import_code':
            importCode_step1();
            break;
        case 'import_code_2':
            importCode_step2();
            break;
        case 'export':
            export();
            break;
        default:
        case 'list':
            groupCodeList();
            break;
    }
}
Пример #29
0
{
    $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHI JKLMNOPRQSTUVWXYZ0123456789";
    $code = "";
    $clen = strlen($chars) - 1;
    while (strlen($code) < $length) {
        $code .= $chars[mt_rand(0, $clen)];
    }
    return $code;
}
mysql_connect("localhost", "root", "root");
mysql_select_db("test_quest");
if (isset($_POST['submit'])) {
    $query = mysql_query("SELECT user_id, user_password FROM users WHERE user_login='******'login']) . "' LIMIT 1");
    $data = mysql_fetch_assoc($query);
    if ($data['user_password'] === md5(md5($_POST['password']))) {
        $hash = md5(generateCode(10));
        mysql_query("UPDATE users SET user_hash='" . $hash . "' " . $insip . " WHERE user_id='" . $data['user_id'] . "'");
        setcookie("id", $data['user_id'], time() + 60 * 60 * 24 * 30);
        setcookie("hash", $hash, time() + 60 * 60 * 24 * 30);
        header("Location: check.php");
        exit;
    } else {
        print "INVALID PASS/LOGIN";
    }
}
?>

<form method="POST">

Логин <input name="login" type="text"><br>
Пример #30
0
function getUserHash()
{
    return md5(generateCode(10));
}