当前位置: 首页>>代码示例>>PHP>>正文


PHP random_password函数代码示例

本文整理汇总了PHP中random_password函数的典型用法代码示例。如果您正苦于以下问题:PHP random_password函数的具体用法?PHP random_password怎么用?PHP random_password使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了random_password函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createContingent

function createContingent($nameParam)
{
    $password = random_password();
    $name = clean_string($nameParam);
    $loginID = registration_id();
    $db = \Udaan\Database::connect();
    $sth = $db->prepare("INSERT INTO contingent_college(name,loginid,password) VALUES('{$name}','{$loginID}','{$password}')");
    $sth->execute();
    header('Location: college.php');
}
开发者ID:sachingadagi,项目名称:Udaan2016,代码行数:10,代码来源:allFunctions.php

示例2: post_login

 public static function post_login($parameters)
 {
     $uid = $parameters['uid'];
     $samlBackend = new OC_USER_SAML();
     if ($samlBackend->auth->isAuthenticated()) {
         $attributes = $samlBackend->auth->getAttributes();
         if (array_key_exists($samlBackend->usernameMapping, $attributes) && $attributes[$samlBackend->usernameMapping][0] == $uid) {
             $attributes = $samlBackend->auth->getAttributes();
             if (array_key_exists($samlBackend->mailMapping, $attributes)) {
                 $saml_email = $attributes[$samlBackend->mailMapping][0];
             }
             if (array_key_exists($samlBackend->groupMapping, $attributes)) {
                 $saml_groups = $attributes[$samlBackend->groupMapping];
             } else {
                 if (!empty($samlBackend->defaultGroup)) {
                     $saml_groups = array($samlBackend->defaultGroup);
                     OC_Log::write('saml', 'Using default group "' . $samlBackend->defaultGroup . '" for the user: ' . $uid, OC_Log::DEBUG);
                 }
             }
             if (!OC_User::userExists($uid)) {
                 if (preg_match('/[^a-zA-Z0-9 _\\.@\\-]/', $uid)) {
                     OC_Log::write('saml', 'Invalid username "' . $uid . '", allowed chars "a-zA-Z0-9" and "_.@-" ', OC_Log::DEBUG);
                     return false;
                 } else {
                     $random_password = random_password();
                     OC_Log::write('saml', 'Creating new user: ' . $uid, OC_Log::DEBUG);
                     OC_User::createUser($uid, $random_password);
                     if (OC_User::userExists($uid)) {
                         if (isset($saml_email)) {
                             update_mail($uid, $saml_email);
                         }
                         if (isset($saml_groups)) {
                             update_groups($uid, $saml_groups, $samlBackend->protectedGroups, true);
                         }
                     }
                 }
             } else {
                 if ($samlBackend->updateUserData) {
                     OC_Log::write('saml', 'Updating data of the user: ' . $uid, OC_Log::DEBUG);
                     if (isset($saml_email)) {
                         update_mail($uid, $saml_email);
                     }
                     if (isset($saml_groups)) {
                         update_groups($uid, $saml_groups, $samlBackend->protectedGroups, false);
                     }
                 }
             }
             return true;
         }
     }
     return false;
 }
开发者ID:nanowish,项目名称:apps,代码行数:52,代码来源:hooks.php

示例3: probability

function probability($length = 8, $type = 'alpha_numeric', $max = 1000000)
{
    $result = random_password($length, $type);
    $iterations = 0;
    while (true) {
        $next = random_password($length, $type);
        //printf("Probability progress: %f%s\r", $iterations / $max, '%');
        if ($result === $next) {
            break;
        }
        if ($iterations == $max) {
            break;
        }
        $iterations++;
    }
    $probability = $iterations == $max ? '+' . $max : '1 / ' . $iterations;
    //printf("Probability: %s\n", $probability);
    return $iterations;
}
开发者ID:BideoWego,项目名称:php-random-password-generator,代码行数:19,代码来源:test.php

示例4: reset_password

function reset_password($username, $email)
{
    global $db_link;
    $result = wrap_db_query("SELECT email FROM " . BOOKING_USER_TABLE . " WHERE username='" . wrap_db_escape_string($username) . "'");
    if (!$result) {
        return false;
        // no result
    } else {
        if (wrap_db_num_rows($result) == 0) {
            return false;
            // username not in db
        } else {
            $fields = wrap_db_fetch_array($result);
            if ($email != $fields['email']) {
                return false;
                // emails do not match
            }
        }
    }
    $new_passwd = random_password(6);
    // crypt user password entry
    $crypted_new_passwd = crypt_password($new_passwd);
    // set user's password to this in database or return false
    $result = wrap_db_query("UPDATE " . BOOKING_USER_TABLE . " SET passwd = '" . wrap_db_escape_string($crypted_new_passwd) . "' " . "WHERE username = '" . wrap_db_escape_string($username) . "' AND email = '" . wrap_db_escape_string($email) . "'");
    if (!$result) {
        return false;
        // not changed
    } else {
        return $new_passwd;
        // changed successfully
    }
}
开发者ID:dev-lav,项目名称:htdocs,代码行数:32,代码来源:user_auth_fns.php

示例5: forget_pass

 public function forget_pass()
 {
     if (!empty($this->data)) {
         $data = $this->data['ForgetPassForm'];
         if (!isset($this->Captcha)) {
             //if Component was not loaded throug $components array()
             App::import('Component', 'Captcha');
             //load it
             $this->Captcha = new CaptchaComponent();
             //make instance
             $this->Captcha->startup($this);
             //and do some manually calling
         }
         $cap = $this->Captcha->getVerCode();
         if ($cap == $data['code']) {
             $user = $this->User->find('first', array('conditions' => array('User.username' => $data['username'], 'User.user_role_id' => $data['user_role_id'])));
             if (!empty($user)) {
                 $Mail = new MailController();
                 $Mail->constructClasses();
                 $pass = random_password();
                 $this->User->id = $user['User']['id'];
                 $this->User->save(array('password' => encrypt($pass, SALT)));
                 $arr = array();
                 $arr['TO_EMAIL'] = $user['User']['email'];
                 $arr['TO_NAME'] = $user['User']['username'];
                 $arr['USERNAME'] = $user['User']['username'];
                 $arr['PASSWORD'] = $pass;
                 $Mail->sendMail($user['User']['id'], 'forgot_password', $arr);
                 echo 'success';
                 die;
             } else {
                 echo 'error';
             }
         } else {
             echo 'code';
             die;
         }
     }
     die;
 }
开发者ID:pushpendraraj,项目名称:tigzie,代码行数:40,代码来源:LoginController.php

示例6: random_password

<?php

$password = "";
function random_password($length = 8)
{
    $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#\$%^&*()_-=+;:,.?";
    $password = substr(str_shuffle($chars), 0, $length);
    return $password;
}
$email = $_POST["email"];
$servername = "sql3.freemysqlhosting.net:3306";
$user_db = "sql382663";
$password_db = "lR7%jI1%";
$dbname = "sql382663";
$password_new = random_password();
$password_encrypted = md5($password_new);
// Create connection
$conn = new mysqli($servername, $user_db, $password_db, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$sql2 = "UPDATE user SET user_password='{$password_encrypted}' WHERE user_mail = '{$email}'";
$result2 = mysqli_query($conn, $sql2);
if (mysqli_affected_rows($conn) > 0) {
    $to = $email;
    $subject = "Senha - ACE Application";
    $message = "Trocamos sua senha. Ela agora é " . $password_new . " . Enjoy! /o/";
    include "sendEmail.php";
    echo "<script> window.location.href='index.php' </script>";
    //header("Location: index.php");
开发者ID:OneCommunity,项目名称:HGN,代码行数:31,代码来源:resetPassword.php

示例7: lostPassword

function lostPassword($email)
{
    global $bdd;
    global $_TABLES;
    if (!is_null($bdd) && !is_null($_TABLES)) {
        // Requete de verification de l'existence du compte
        $objUser = new User($bdd, $_TABLES);
        $user = $objUser->getExist($email);
        if ($user && !is_null($user)) {
            // Generation du nouveau mot de passe
            $new_password = random_password();
            // Mise à jour du mot de passe de l'utilisateur
            $objUser->updatePassword($user->id, $new_password);
            // Génération de l'email
            $template = new Template(dirname(dirname(dirname(__FILE__))) . "/ressources/template/email/reset_password.html");
            $content = $template->getView(array("first_name" => $first_name, "last_name" => $last_name, "new_password" => $new_password));
            // Envoi de l'email de bienvenue
            $objMailer = new Mailer();
            $objMailer->from = "postmaster@whatsup.agency";
            $objMailer->fromName = "Whats Up Street";
            $objMailer->to = $email;
            $objMailer->toName = $first_name . ' ' . $last_name;
            $objMailer->subject = "[Important] Whats Up Street : Changement mot de passe";
            $objMailer->content = $content;
            $objMailer->isHTML();
            $objMailer->send();
            // Retour 0 si tout c'est bien passé
            return 0;
        } else {
            // Compte n'existe pas
            return 1;
        }
    } else {
        error_log("BDD ERROR : " . json_encode($bdd));
        error_log("TABLES ERROR : " . json_encode($_TABLES));
    }
}
开发者ID:xXNoceboXx,项目名称:WUS,代码行数:37,代码来源:controller.login.php

示例8: random_password

<?php

include_once "model/GenericTable.php";
include_once "header.php";
function random_password($length = 8)
{
    $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#\$%^&*()_-=+;:,.?";
    $password = substr(str_shuffle($chars), 0, $length);
    return $password;
}
if (isset($_POST)) {
    $location = $_POST['location'];
    $mailid = $_POST['mailid'];
    $otableuser = new GenericTable($dbh, 'fb_userdetails');
    $otablepassword = new GenericTable($dbh, 'fb_password');
    $pass = random_password(8);
    $password = md5($pass);
    $updatelist = array('password' => $password, 'changepassword' => 'Y');
    $clause = "where location='{$location}'";
    $otableuser->updateRow($updatelist, $clause);
    $plist = array('LOCNAME' => $location, 'EMAIL' => $mailid, 'PASSWORD' => $pass, 'TIMESTAMP' => time());
    $otablepassword->insertRow($plist);
    //Email Header
    $emailheader = "From: ikure <no-reply@iplanet.in>\r\nContent-type: text/html";
    $to = $mailid;
    $subject = "Password Reset";
    $txt = "Your account password has been reset to the following password.<BR/> Password: " . $password;
    if (mail($to, $subject, $txt, $emailheader)) {
        ?>
			<script type="text/javascript">
				alert("Your password has been send to registered mail id.");
开发者ID:selva316,项目名称:feedback,代码行数:31,代码来源:forgotpassword_db.php

示例9: mysqli_real_escape_string

        }
    }
}
//END SIGN IN APPLICATION
//CODE FOR RESET PASSWORD
if (isset($_POST['reset_passsword'])) {
    $reset_mykadNO = mysqli_real_escape_string($con, $_POST['reset_mykadNO']);
    $reset_email = mysqli_real_escape_string($con, $_POST['reset_email']);
    $dtc_reset_user = "SELECT lu.lu_loginID, lq.us_name, lq.us_icNo, lq.us_email\n\t\t\t\t\t\tFROM login_user lu, login_quest lq\n\t\t\t\t\t\tWHERE lq.us_icNo = '{$reset_mykadNO}' AND lq.us_email = '{$reset_email}' AND lq.login_user_lu_loginID = lu.lu_loginID";
    $dtc_reset_user_query = mysqli_query($con, $dtc_reset_user);
    if (mysqli_num_rows($dtc_reset_user_query) > 0) {
        $dtc_reset_user_array = mysqli_fetch_array($dtc_reset_user_query);
        $user_id_reset = $dtc_reset_user_array['lu_loginID'];
        $user_staff_name = $dtc_reset_user_array['us_name'];
        $user_staff_email = $dtc_reset_user_array['us_email'];
        $tmp_pss = random_password();
        $tmp_hash_pss = md5($tmp_pss);
        $dtc_error = "SELECT * FROM login_error lrr WHERE lrr.login_user_lu_loginID = '{$user_id_reset}'";
        $dtc_error_query = mysqli_query($con, $dtc_error);
        if (mysqli_num_rows($dtc_error_query) > 0) {
            $del_error = "DELETE FROM login_error WHERE login_user_lu_loginID = '{$user_id_reset}'";
            $del_error_query = mysqli_query($con, $del_error);
            if (!$del_error_query) {
                $error = "<div class='alert alert-danger alert-dismissable'>\n\t\t\t<button type='button' class='close' data-dismiss='alert' aria-hidden='true'><i class='fa fa-remove pr10'></i></button>\n\t\t\t<center><strong>Error delete error!</strong> " . mysqli_error($con) . "</center>\n\t\t\t</div>";
            }
        }
        //UPDATE login_user table FOR RESET PASSWORD
        $lu_updt_rst = "UPDATE login_user lu\n\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\tlu_password = '{$tmp_hash_pss}',\n\t\t\t\t\t\t\t\t\t\tlu_reset_password = '1'\n\t\t\t\t\tWHERE lu.lu_loginID = '{$user_id_reset}'";
        $lu_updt_rst_query = mysqli_query($con, $lu_updt_rst);
        if (!$lu_updt_rst_query) {
            $error = "<div class='alert alert-danger alert-dismissable'>\n\t\t\t<button type='button' class='close' data-dismiss='alert' aria-hidden='true'><i class='fa fa-remove pr10'></i></button>\n\t\t\t<center><strong>Error!</strong> " . mysqli_error($con) . "</center>\n\t\t\t</div>";
开发者ID:syafiqazwan,项目名称:pharmaco,代码行数:31,代码来源:back-login.php

示例10: check_level

check_level();
function random_user($length = 8)
{
    $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    $user = substr(str_shuffle($chars), 0, $length);
    return $user;
}
function random_password($length = 4)
{
    $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    $password = substr(str_shuffle($chars), 0, $length);
    return $password;
}
$submit = $_POST['btnsave'];
$InstID = random_user(8);
$pin = random_password(8);
$lname = $_POST['lname'];
$fname = $_POST['fname'];
$mi = $_POST['mi'];
$address = $_POST['address'];
$gender = $_POST['gender'];
$contactno = $_POST['contactno'];
$rate = $_POST['rate'];
$position = $_POST['position'];
$status = $_POST['status'];
$teaching_type = $_POST['teaching_type'];
if ($submit) {
    if ($InstID && $pin && $lname && $fname && $mi && $address && $gender && $contactno && $rate && $position && $status && $teaching_type) {
        mysql_query("insert into faculty values('','" . $InstID . "','" . $pin . "','" . $lname . "','" . $fname . "','" . $mi . "','" . $address . "','" . $gender . "','" . $contactno . "','" . $rate . "','" . $position . "','" . $status . "','" . $teaching_type . "')");
        echo "<meta http-equiv = 'refresh' content='0; url=instructormain.php' />\n\t\t\t\t\t\t\t\t\t\t\t<script type='text/javascript'>\n\n\t\t\t\t\t\t\t\t\t\t\talert('Record Added');\n\n\t\t\t\t\t\t\t\t\t\t\t</script>";
    } else {
开发者ID:pr1nce5tephen,项目名称:officeautomation,代码行数:31,代码来源:addinstructor.php

示例11: foreach

 $db->setQuery($query);
 $list = $db->loadObjectList();
 $countOn = $countOff = 0;
 $report = '<ul class="list list-condensed">';
 foreach ($list as $obj) {
     // registra o voto e envia confirmação
     $sender = array($config->get('mailfrom'), $config->get('fromname'));
     $mailer->setSender($sender);
     $reciver = array();
     $reciver[] = $obj->email;
     if (count($users) == 1 && !empty($email_opt)) {
         $reciver[] = $email_opt;
     }
     $mailer->addRecipient($reciver);
     $mailer->setSubject('Reenvio de senha de usuário');
     $setPass = random_password();
     jimport('joomla.user.helper');
     $newPass = JUserHelper::hashPassword($setPass);
     $msg = isset($message) && $message != '' ? $message . "\n\n" : 'por questões de segurança estamos reenviando seus dados de acesso ao nosso site:';
     $msg = "\n\t\t\tOlá " . $obj->name . ",\n\n" . $msg . "\n\nUsuário:  " . $obj->username . "\nSenha:  " . $setPass . "\n\nVocê pode alterar sua senha a qualquer momento. Para isso acesse nosso website:\n" . JURI::root() . "profile\n\n Atenciosamente,\n\t\t";
     $mailer->setBody($msg);
     $query = "UPDATE #__users SET password='" . $newPass . "' WHERE id=" . $obj->id;
     $update = $db->setQuery($query);
     $db->execute();
     if ($mailer->Send() && $update) {
         $report .= '<li class="text-success"><span class="base-icon-check"></span> A senha (<strong>' . $setPass . '</strong>) foi enviada com sucesso para o usuário ' . $obj->name . ' (' . implode(', ', $reciver) . ')</li>';
         $countOn++;
     } else {
         $report .= '<li class="bg-danger text-danger strong"><span class="base-icon-cancel"></span> A nova senha <strong>NÃO</strong> foi enviada para o usuário ' . $obj->name . ' (' . implode(', ', $reciver) . ')</li>';
         $countOff++;
     }
开发者ID:envolute,项目名称:templates,代码行数:31,代码来源:send_new_pass.php

示例12: not_login

require_once "../classes/Upload.php";
not_login($_SESSION['admin_id'], "login.php");
if (isset($_GET['id'])) {
    $id = escape($_GET['id']);
    // check id is valid
    $product = $db->Fetch("*", "product", "id='{$id}'");
    if (empty($product)) {
        die("Invalid Product id");
    }
} else {
    die("Invalid Page");
}
// when submit button is clicked
if (isset($_FILES['image'])) {
    $allowed = array("jpg", "png", "jpeg");
    $dir = md5(rand() . random_password());
    mkdir("../images/{$dir}/");
    $upload = new Upload($_FILES['image'], "../images/{$dir}/", 2000000, $allowed);
    $result = $upload->GetResult();
    if ($result['type'] == "success") {
        // insert into the database
        $image = $_FILES['image']['name'];
        $insert = $db->Update("product", "image='images/{$dir}/{$image}'", "id='{$id}'");
        if ($insert) {
            echo "<div class='alert alert-success'>Image Updated <a href='edit_product.php?id={$id}'>Go Back</a></div>";
        } else {
            echo "<div class='alert alert-danger'>Failed to update file</div>";
        }
    } else {
        echo "<div class='alert alert-danger'>{$result['message']}</div>";
    }
开发者ID:husainsaify,项目名称:the-cart-script-v1,代码行数:31,代码来源:edit_product_image.php

示例13: die

    if (empty($banner)) {
        die("<center>Invalid Banner Id</center>");
    }
} else {
    die("<center>Invalid Url</center>");
}
?>
<div class="container padding-10">
	<div id="search-container">
		<h1 class="text-center text-bs-primary text-upper">Edit Banner</h1>
		<div class="row">
			<div class="col-sm-6">
				<?php 
if (isset($_FILES['image'])) {
    $allowed = array("jpg", "png", "jpeg");
    $dir = md5(rand() . $_FILES['image']['name'] . random_password());
    mkdir("../images/{$dir}/");
    $upload = new Upload($_FILES['image'], "../images/{$dir}/", 2000000, $allowed);
    $return = $upload->GetResult();
    if ($return['type'] == "success") {
        $filename = $_FILES['image']['name'];
        $insert = $db->Update("offer", "image='images/{$dir}/{$filename}'", "id='{$banner_id}'");
        echo "<div class='alert alert-success'>Banner updated <a href='banner.php'>GO BACk</a></div>";
    } else {
        echo "<div class='alert alert-danger'>{$return['message']}</div>";
    }
}
?>
				<form action="edit_banner.php?id=<?php 
echo $banner_id;
?>
开发者ID:husainsaify,项目名称:the-cart-script-v1,代码行数:31,代码来源:edit_banner.php

示例14: error_reporting

<?php

error_reporting(E_ALL ^ E_STRICT);
require_once realpath(__DIR__) . '/index.php';
$length = 8;
$type = 'alpha_numeric';
if (isset($argv[1])) {
    $length = $argv[1];
}
if (isset($argv[2])) {
    $type = $argv[2];
}
echo "\n" . random_password($length, $type) . "\n\n";
开发者ID:BideoWego,项目名称:php-random-password-generator,代码行数:13,代码来源:run.php

示例15: random_password

<?php

function random_password($length = 8)
{
    $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    $password = substr(str_shuffle($chars), 0, $length);
    return $password;
}
$mdp = random_password(10);
$mdp_proprietaire = md5($mdp);
$b = md5('9rwhVumJl8');
echo $b;
开发者ID:Yourgene,项目名称:loungehotel,代码行数:12,代码来源:test.php


注:本文中的random_password函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。