• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP generate_random_string函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: download_files_as_zip

 public function download_files_as_zip($idlist = array())
 {
     $zip = new ZipArchive();
     $randomid = generate_random_string(16);
     $filename = DIR_BASE . "tmp/" . $randomid;
     if ($zip->open($filename, ZIPARCHIVE::CREATE) != true) {
         exit("cannot open <{$filename}>\n");
     }
     $this->model_search_message->connect_to_pilergetd();
     foreach ($idlist as $id) {
         $piler_id = $this->model_search_message->get_piler_id_by_id($id);
         $rawemail = $this->model_search_message->get_raw_message($piler_id);
         $zip->addFromString($piler_id . ".eml", $rawemail);
         AUDIT(ACTION_DOWNLOAD_MESSAGE, '', '', $id, '');
     }
     $this->model_search_message->disconnect_from_pilergetd();
     $zip->close();
     header("Cache-Control: public, must-revalidate");
     header("Pragma: no-cache");
     header("Content-Type: application/zip");
     header("Expires: 0");
     header("Content-Length: " . filesize($filename));
     header("Content-Disposition: attachment; filename=archive-{$randomid}.zip");
     header("Content-Transfer-Encoding: binary\n");
     readfile($filename);
     unlink($filename);
 }
开发者ID:buxiaoyang,项目名称:EmailArchive,代码行数:27,代码来源:restore.php


示例2: check_for_account

 public function check_for_account($google_account = array())
 {
     $session = Registry::get('session');
     $query = $this->db->query("SELECT " . TABLE_USER . ".username, " . TABLE_USER . ".uid, " . TABLE_USER . ".realname, " . TABLE_USER . ".dn, " . TABLE_USER . ".password, " . TABLE_USER . ".isadmin, " . TABLE_USER . ".domain FROM " . TABLE_USER . ", " . TABLE_EMAIL . " WHERE " . TABLE_EMAIL . ".email=? AND " . TABLE_EMAIL . ".uid=" . TABLE_USER . ".uid", array($google_account['email']));
     if ($query->num_rows == 1) {
         $user = $query->row;
     } else {
         $d = explode('@', $google_account['email']);
         $user['uid'] = $this->model_user_user->get_next_uid();
         $user['username'] = $google_account['email'];
         $user['realname'] = $google_account['name'];
         $user['email'] = $google_account['email'];
         $user['domain'] = $d[1];
         $user['dn'] = '*';
         $user['isadmin'] = 0;
         $user['password'] = generate_random_string(12);
         $user['group'] = '';
         $user['folder'] = '';
         $this->model_user_user->add_user($user);
         $this->model_domain_domain->addDomain($user['domain'], $user['domain']);
     }
     $session->set("username", $user['username']);
     $session->set("uid", $user['uid']);
     $session->set("admin_user", 0);
     $session->set("email", $user['username']);
     $session->set("domain", $query->row['domain']);
     $session->set("realname", $query->row['realname']);
     $session->set("emails", $this->model_user_user->get_users_all_email_addresses($user['uid']));
     $session->set("folders", $this->model_folder_folder->get_all_folder_ids($user['uid']));
     $session->set("extra_folders", $this->model_folder_folder->get_all_extra_folder_ids($user['uid']));
     AUDIT(ACTION_LOGIN, $user['username'], '', '', 'successful auth against Google');
 }
开发者ID:buxiaoyang,项目名称:EmailArchive,代码行数:32,代码来源:google.php


示例3: store_file

function store_file($challenge_id, $file)
{
    if ($file['error']) {
        message_error('Could not upload file: ' . file_upload_error_description($file['error']));
    }
    if ($file['size'] > max_file_upload_size()) {
        message_error('File too large.');
    }
    $file_id = db_insert('files', array('added' => time(), 'added_by' => $_SESSION['id'], 'title' => $file['name'], 'size' => $file['size'], 'md5' => md5_file($file['tmp_name']), 'download_key' => hash('sha256', generate_random_string(128)), 'challenge' => $challenge_id));
    if (file_exists(CONST_PATH_FILE_UPLOAD . $file_id)) {
        message_error('File already existed! This should never happen!');
    }
    // do we put the file on AWS S3?
    if (CONFIG_AWS_S3_KEY_ID && CONFIG_AWS_S3_SECRET && CONFIG_AWS_S3_BUCKET) {
        try {
            // Instantiate the S3 client with your AWS credentials
            $client = S3Client::factory(array('key' => CONFIG_AWS_S3_KEY_ID, 'secret' => CONFIG_AWS_S3_SECRET));
            $file_key = '/challenges/' . $file_id;
            // Upload an object by streaming the contents of a file
            $result = $client->putObject(array('Bucket' => CONFIG_AWS_S3_BUCKET, 'Key' => $file_key, 'SourceFile' => $file['tmp_name']));
            // We can poll the object until it is accessible
            $client->waitUntil('ObjectExists', array('Bucket' => CONFIG_AWS_S3_BUCKET, 'Key' => $file_key));
        } catch (Exception $e) {
            delete_file($file_id);
            message_error('Caught exception uploading file to S3: ' . $e->getMessage());
        }
    } else {
        move_uploaded_file($file['tmp_name'], CONST_PATH_FILE_UPLOAD . $file_id);
        if (!file_exists(CONST_PATH_FILE_UPLOAD . $file_id)) {
            delete_file($file_id);
            message_error('File upload failed!');
        }
    }
}
开发者ID:dirvuk,项目名称:mellivora,代码行数:34,代码来源:files.inc.php


示例4: download_attachments_as_zip

 public function download_attachments_as_zip($piler_id = '')
 {
     $zip = new ZipArchive();
     $pid = array();
     $randomid = generate_random_string(16);
     $filename = DIR_BASE . "tmp/" . $randomid;
     if ($zip->open($filename, ZIPARCHIVE::CREATE) != true) {
         exit("cannot open <{$filename}>\n");
     }
     $attachments = $this->model_search_message->get_attachment_list($piler_id);
     foreach ($attachments as $a) {
         $attachment = $this->model_search_message->get_attachment_by_id($a['id']);
         $fp = fopen(DIR_BASE . 'tmp/' . $a['id'], "w+");
         if ($fp) {
             fwrite($fp, $attachment['attachment']);
             fclose($fp);
             $zip->addFile(DIR_BASE . 'tmp/' . $a['id'], $attachment['filename']);
         }
     }
     $zip->close();
     foreach ($attachments as $a) {
         unlink(DIR_BASE . 'tmp/' . $a['id']);
     }
     header("Cache-Control: public, must-revalidate");
     header("Pragma: no-cache");
     header("Content-Type: application/zip");
     header("Expires: 0");
     header("Content-Length: " . filesize($filename));
     header("Content-Disposition: attachment; filename=" . $piler_id . ".zip");
     header("Content-Transfer-Encoding: binary\n");
     readfile($filename);
     unlink($filename);
 }
开发者ID:buxiaoyang,项目名称:EmailArchive,代码行数:33,代码来源:zip.php


示例5: userGetCoupon

 public function userGetCoupon(Request $request, $id, $coupon_id)
 {
     try {
         DB::transaction(function () use($id, $coupon_id) {
             $coupon = Coupon::where('id', $coupon_id)->get()->first();
             // 检查是否可领取(开始领取时间?是否已经激活?)
             if ($coupon->begin_gain_time < date('Y')) {
                 throw new Exception('未到优惠券领取时间');
             }
             $count = UserCoupon::where(['user_id' => $id, 'coupon_id' => $coupon_id])->count();
             // 检查是否超出可领取数量限制
             if ($count >= $coupon->limit_gain_number) {
                 throw new Exception('超出可领取数量限制');
             }
             // 生成11位随机码(检查数据库是否有重复?有重复则提示用户重新输入)
             $coupon_code = generate_random_string('0123456789');
             if (!$coupon_code) {
                 throw new Exception('优惠码重复,请重新申请');
             }
             // 设置用户优惠券状态为未使用
             $user_coupon['user_id'] = $id;
             $user_coupon['coupon_id'] = $coupon_id;
             $user_coupon['coupon_code'] = $coupon_code;
             $user_coupon['coupon_status'] = 0;
             $user_coupon['created'] = time();
             $user_cou = UserCoupon::create($user_coupon);
             if (!$user_cou->id) {
                 throw new Exception('模拟用户优惠券失败');
             }
         });
         return redirect()->route('admin.test.user.index_coupon', $id)->with('message', '成功获取模拟优惠!');
     } catch (Exception $e) {
         return redirect()->back()->withInput($request->input())->with('fail', '获取模拟优惠券失败,数据库操作返回异常!' . $e->getMessage());
     }
 }
开发者ID:xinz0526,项目名称:bbc-admin,代码行数:35,代码来源:AdminTestController.php


示例6: generate_token

function generate_token()
{
    $token = "";
    do {
        $token = generate_random_string(128);
    } while (count_rows("Sessions", "`Token` = '{$token}'", 1));
    return $token;
}
开发者ID:mcenderdragon,项目名称:Icon-Craft,代码行数:8,代码来源:session.php


示例7: login

 public function login($type = 'public', $redirect = true)
 {
     // Initialize
     global $config;
     // Get user row
     if (!($user_row = DB::queryFirstRow("SELECT * FROM users WHERE username = %s", strtolower($_POST['username'])))) {
         $this->invalid_login($type);
     }
     // Check password
     $client = new encrypt();
     if ($client->get_password_hash($_POST['password'], $user_row['id']) != $user_row['password']) {
         $this->invalid_login($type);
     }
     // Get session ID
     do {
         $session_id = generate_random_string(60);
         $exists = DB::queryFirstRow("SELECT * FROM auth_sessions WHERE auth_hash = %s", hash('sha512', $session_id)) ? 1 : 0;
     } while ($exists > 0);
     // Check for 2FA
     $require_2fa = false;
     if ($config['enable_2fa'] == 'all') {
         $require_2fa = true;
     } elseif ($config['enable_2fa'] == 'admin' && $user_row['group_id'] == 1) {
         $require_2fa = true;
     }
     // Generate 2FA hash, if needed
     if ($require_2fa === true) {
         $status_2fa = 0;
         $hash_2fa = generate_random_string(60);
         // Send e-mail
         $url = "http://" . $_SERVER['HTTP_HOST'] . '/2fa/' . $hash_2fa;
         mail($user_row['email'], "2FA Authentication - {$config['site_name']}", "You are receiving this e-mail because you just tried to login to {$config['site_name']}, which required 2FA.  To proceed with your login, please click on the below URL:\r\n\r\n\t{$url}\r\n\r\nThank you,\r\n{$config['site_name']}\r\n");
     } else {
         $status_2fa = 1;
         $hash_2fa = '';
     }
     // Create session
     DB::insert('auth_sessions', array('userid' => $user_row['id'], 'last_active' => time(), 'auth_hash' => hash('sha512', $session_id), '2fa_status' => $status_2fa, '2fa_hash' => $hash_2fa));
     // Set cookie
     $cookie_name = COOKIE_NAME . 'auth_hash';
     setcookie($cookie_name, $session_id);
     // Update alerts
     DB::query("UPDATE alerts SET is_new = 0 WHERE is_new = 2 AND userid = %d", $user_row['id']);
     DB::query("UPDATE alerts SET is_new = 2 WHERE is_new = 1 AND userid = %d", $user_row['id']);
     // Redirect user
     if ($status_2fa == 0) {
         $route = $type == 'admin' ? 'admin/2fa' : '2fa';
         $template = new template($route);
         echo $template->parse();
         exit(0);
     } elseif ($type == 'admin' && $redirect === true) {
         header("Location: " . SITE_URI . "/admin/index");
         exit(0);
     }
     // Return
     return $user_row['id'];
 }
开发者ID:nachatate,项目名称:synala,代码行数:57,代码来源:auth.php


示例8: generate_complex_array

function generate_complex_array(array $nodesPerLayer = array(5, 5, 5, 5))
{
    $layer = [];
    $n = array_shift($nodesPerLayer);
    for ($i = 0; $i < $n; ++$i) {
        $layer[generate_random_string()] = empty($nodesPerLayer) ? generate_random_string() : generate_complex_array($nodesPerLayer);
    }
    return $layer;
}
开发者ID:djfm,项目名称:json_vs_yaml_perf,代码行数:9,代码来源:index.php


示例9: change_password

function change_password($users, $passwords, $user, $old, $new)
{
    if (verify_password($users, $passwords, $user, $old)) {
        $new_salt = generate_random_string(20);
        $passwords[array_keys($users, $user)][0] = hash_password($new, $new_salt);
        $passwords[array_keys($users, $user)][1] = $new_salt;
        logout();
    }
}
开发者ID:pinoaffe,项目名称:content-management-thingy,代码行数:9,代码来源:forum-functions.php


示例10: download_files_as_zip

 public function download_files_as_zip($idlist = array())
 {
     $zip = new ZipArchive();
     $pid = array();
     $randomid = generate_random_string(16);
     $filename = DIR_BASE . "tmp/" . $randomid;
     if ($zip->open($filename, ZIPARCHIVE::CREATE) != true) {
         exit("cannot open <{$filename}>\n");
     }
     $imgs = array();
     foreach ($idlist as $id) {
         $piler_id = $this->model_search_message->get_piler_id_by_id($id);
         array_push($pid, $piler_id);
         $attachments = $this->model_search_message->get_attachment_list($piler_id);
         $images = array();
         foreach ($attachments as $a) {
             if (preg_match("/image/", $a['type'])) {
                 $attachment = $this->model_search_message->get_attachment_by_id($a['id']);
                 $fp = fopen(DIR_BASE . 'tmp/' . $a['id'], "w+");
                 if ($fp) {
                     fwrite($fp, $attachment['attachment']);
                     fclose($fp);
                     $images[] = array('id' => $a['id'], 'name' => $attachment['filename']);
                     $imgs[] = array('name' => $a['id']);
                 }
             }
         }
         $message = $this->model_search_message->extract_message($piler_id);
         $page = $message['from'] . "<br />\n";
         $page .= $message['to'] . "<br />\n";
         $page .= $message['subject'] . "<br />\n";
         $page .= $message['date'] . "<br />\n";
         $page .= "<hr />\n" . $message['message'];
         $this->create_pdf_from_eml($piler_id, $page, $images);
         foreach ($imgs as $img) {
             unlink(DIR_BASE . 'tmp/' . $img['name']);
         }
         $zip->addFile(DIR_BASE . 'tmp/' . $piler_id . '.pdf', $piler_id . '.pdf');
         AUDIT(ACTION_DOWNLOAD_MESSAGE, '', '', $id, '');
     }
     $zip->close();
     foreach ($pid as $piler_id) {
         unlink(DIR_BASE . 'tmp/' . $piler_id . '.pdf');
     }
     header("Cache-Control: public, must-revalidate");
     header("Pragma: no-cache");
     header("Content-Type: application/zip");
     header("Expires: 0");
     header("Content-Length: " . filesize($filename));
     header("Content-Disposition: attachment; filename=archive-{$randomid}.zip");
     header("Content-Transfer-Encoding: binary\n");
     readfile($filename);
     unlink($filename);
 }
开发者ID:buxiaoyang,项目名称:EmailArchive,代码行数:54,代码来源:pdf.php


示例11: create_pending_session

 public function create_pending_session($wallet_id, $product_id = 0, $amount = 0, $currency = 'btc')
 {
     // Initialize
     global $config, $template;
     $userid = LOGIN === true ? $GLOBALS['userid'] : 0;
     $expire_time = time() + $config['payment_expire_seconds'];
     // Get hash
     do {
         $hash = generate_random_string(120);
         if ($row = DB::queryFirstRow("SELECT * FROM coin_pending_payment WHERE pay_hash = %s", hash('sha512', 120))) {
             $exists = 1;
         } else {
             $exists = 0;
         }
     } while ($exists > 0);
     // Get product, if needed
     if ($product_id > 0) {
         if (!($prow = DB::queryFirstRow("SELECT * FROM products WHERE id = %d", $product_id))) {
             trigger_error("Product does not exist, ID# {$product_id}", E_USER_ERROR);
         }
         $amount = $prow['amount'];
         $currency = $prow['currency'];
         $item_name = $prow['display_name'];
     } else {
         $item_name = '';
     }
     // Get amount
     if ($currency == 'fiat') {
         $amount_btc = $amount / $config['exchange_rate'];
     } else {
         $amount_btc = $amount;
         $amount = $amount_btc * $config['exchange_rate'];
     }
     // Get payment address
     if ($userid > 0) {
         $client = new bip32();
         $payment_address = $client->get_user_address($wallet_id, $userid);
         // Delete any existing pending payments
         DB::query("DELETE FROM coin_pending_payment WHERE payment_address = %s AND status = 'pending'", $payment_address);
     } else {
         $payment_address = '';
     }
     // Add to db
     DB::insert('coin_pending_payment', array('wallet_id' => $wallet_id, 'pay_hash' => $hash, 'userid' => $userid, 'item_id' => $product_id, 'amount' => $amount, 'amount_btc' => $amount_btc, 'expire_time' => $expire_time, 'payment_address' => $payment_address));
     // Template variables
     $template->assign('payment_address', $payment_address);
     $template->assign('currency', $currency);
     $template->assign('amount', fmoney_coin($amount_btc));
     $template->assign('amount_fiat', fmoney($amount));
     $template->assign('product_id', $product_id);
     $template->assign('product_name', $item_name);
     // Return hash
     return $hash;
 }
开发者ID:nachatate,项目名称:synala,代码行数:54,代码来源:transaction.php


示例12: login_cookie_create

function login_cookie_create($user, $token_series = false)
{
    $time = time();
    $ip = get_ip(true);
    if (!$token_series) {
        $token_series = generate_random_string(16);
    }
    $token = generate_random_string(64);
    db_insert('cookie_tokens', array('added' => $time, 'ip_created' => $ip, 'ip_last' => $ip, 'user_id' => $user['id'], 'token_series' => $token_series, 'token' => $token));
    $cookie_content = array('t' => $token, 'ts' => $token_series);
    setcookie('login_tokens', json_encode($cookie_content), $time + CONFIG_COOKIE_TIMEOUT, '/', null, CONFIG_SSL_COMPAT, true);
}
开发者ID:jpnelson,项目名称:mellivora,代码行数:12,代码来源:session.inc.php


示例13: page

function page()
{
    global $logger, $session, $db, $user;
    //handle the check
    $postData = $_POST;
    if (time() < $session->csrf_expire) {
        if ($session->csrf_token === $postData['csrf_token']) {
            $email = $postData['email'];
            $password = $postData['password'];
            if ($postData['remember']) {
                $remember = true;
            } else {
                $remember = false;
            }
            //ok, we're going to search for the user based on the email
            $result = $db->select("id, email, password, token, active")->from('users')->where('email', $email)->fetch_first();
            //if we have a record...
            if ($db->affected_rows > 0) {
                //found a matching user, now lets check the password
                if (password_verify($password, $result['password']) && $result['active']) {
                    //valid user!
                    //do we have a token? if not, create one and then initialize the user object
                    if ($result['token'] == '' || $result['token'] == Null) {
                        $token = generate_random_string(32);
                        $db->where('id', $result['id'])->update('users', array('token' => $token))->execute();
                    } else {
                        $token = $result['token'];
                    }
                    $session->setCookie('user', $token, $remember);
                    $session->user_token = $token;
                    $session->logged_in = true;
                    $redirect = '/pages/dashboard.php';
                    page_cleanup($redirect);
                } else {
                    // passwords don't match, let's set a formError and return to the index page
                    $session->setFormError('email', 'That email/password combination was not found!');
                    page_cleanup("/index.php");
                }
            } else {
                // user not found, let's set a formError and return to the index page
                $session->setFormError('email', 'That email/password combination was not found.');
                page_cleanup("/index.php");
            }
        } else {
            $session->setFormError('email', 'There was a token mismatch. Hack attempt foiled.');
            page_cleanup("/index.php");
        }
    } else {
        $session->setFormError('email', 'Timed out. Please don\'t let the form sit so long.');
        page_cleanup("/index.php");
    }
    //print "Session: ".$session->csrf_token."<br>Form: ".$_POST['csrf_token']."";
}
开发者ID:Pioneer-Web-Development,项目名称:MangoV2,代码行数:53,代码来源:authorizeUser.php


示例14: autologin

 function autologin()
 {
     $this->load->helper('jazz_string');
     $this->load->model('mdl_login');
     $result = false;
     $cookie = $this->getcookie();
     if ($cookie) {
         $username = $cookie[0];
         $old_hash = $cookie[1];
         $result = $this->mdl_login->validate_cookie($username, $old_hash);
     }
     if (!$result) {
         $this->show();
     } else {
         $hash = generate_random_string(26);
         $result = $this->mdl_login->get_where_custom('jazz_users', 'user_email', $username)->row();
         modules::run('user/save_session_data', $result);
         modules::run('user/save_user_activity', $result);
         $this->deletecookie($username, $old_hash);
         $this->setcookie($username, $hash);
         redirect('dashboard');
     }
 }
开发者ID:jabouzi,项目名称:jazz,代码行数:23,代码来源:login.php


示例15: message_as_rfc822_attachment

 public function message_as_rfc822_attachment($piler_id = '', $msg = '', $rcpt = '')
 {
     if ($piler_id == '' || $msg == '' || $rcpt == '') {
         return '';
     }
     $boundary = generate_random_string(24);
     $hdr = substr($msg, 0, 8192);
     $subject = "";
     $s = strstr($hdr, "Subject:");
     if ($s) {
         $l1 = strlen($s);
         $l2 = strlen(strstr($s, "\n"));
         if ($l1 > $l2 + 10) {
             $subject = substr($s, 0, $l1 - $l2) . EOL;
         }
     }
     $s = "";
     $s .= "Received: by piler" . EOL . PILER_HEADER_FIELD . $piler_id . EOL;
     $s .= "Date: " . date("r") . EOL;
     $s .= "Message-ID: <" . generate_random_string(25) . '@' . SITE_NAME . ">" . EOL;
     $s .= "From: " . SMTP_FROMADDR . EOL;
     $s .= "To: " . $rcpt . EOL;
     if ($subject) {
         $s .= $subject;
     } else {
         $s .= "Subject: Retrieved message from the email archive" . EOL;
     }
     $s .= "MIME-Version: 1.0" . EOL;
     $s .= "Content-Type: multipart/mixed; boundary=\"{$boundary}\"" . EOL . EOL . EOL;
     $s .= "--{$boundary}" . EOL;
     $s .= "Content-Type: message/rfc822; name=\"" . $piler_id . "\"" . EOL;
     $s .= "Content-Disposition: attachment; filename=\"" . $piler_id . "\"" . EOL . EOL;
     $s .= $msg . EOL;
     $s .= "--{$boundary}" . EOL;
     return $s;
 }
开发者ID:buxiaoyang,项目名称:EmailArchive,代码行数:36,代码来源:mail.php


示例16: regenerate_password

 /**
  * If the given arguments correspond to an existing user record, generate a new
  * password and send it with an email.
  *
  * @param string $username
  * @param string $email
  * @return string|bool Returns the new password on success or FALSE on failure.
  */
 public function regenerate_password($username, $email)
 {
     $this->load->helper('general');
     $result = $this->db->select('ea_users.id')->from('ea_users')->join('ea_user_settings', 'ea_user_settings.id_users = ea_users.id', 'inner')->where('ea_users.email', $email)->where('ea_user_settings.username', $username)->get();
     if ($result->num_rows() == 0) {
         return FALSE;
     }
     $user_id = $result->row()->id;
     // Create a new password and send it with an email to the given email address.
     $new_password = generate_random_string();
     $salt = $this->db->get_where('ea_user_settings', array('id_users' => $user_id))->row()->salt;
     $hash_password = hash_password($salt, $new_password);
     $this->db->update('ea_user_settings', array('password' => $hash_password), array('id_users' => $user_id));
     return $new_password;
 }
开发者ID:bukowskiadam,项目名称:easyappointments,代码行数:23,代码来源:user_model.php


示例17: printLogin

 public function printLogin()
 {
     $_SESSION['login_key'] = $login_key = generate_random_string(32);
     require TEMPLATE_DIR . '/login_form.template.php';
 }
开发者ID:howardgrigg,项目名称:jethro-pmm,代码行数:5,代码来源:user_system.class.php


示例18: set_csrf

 public static function set_csrf()
 {
     self::set('mariana-csrf', generate_random_string(rand(15, 30)));
 }
开发者ID:pihh,项目名称:mariana-framework,代码行数:4,代码来源:session.php


示例19: testGenerateRandomString

 /**
  * @dataProvider providerGenerateRandomString
  */
 public function testGenerateRandomString($len, $chars, $regex)
 {
     $rv = generate_random_string($len, $chars);
     $this->assertRegExp($regex, $rv);
     $this->assertTrue($len == strlen($rv));
 }
开发者ID:skive,项目名称:observium,代码行数:9,代码来源:IncludesCommonTest.php


示例20: providerEncryptRandom

 public function providerEncryptRandom()
 {
     $charlist = ' 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()_+-=[]{}\\|/?,.<>;:"' . "'";
     $result = array();
     for ($i = 0; $i < 20; $i++) {
         $string = generate_random_string(mt_rand(20, 40), $charlist);
         $key = generate_random_string(mt_rand(4, 8));
         $result[] = array($string, $key);
     }
     return $result;
 }
开发者ID:skive,项目名称:observium,代码行数:11,代码来源:HtmlIncludesFunctionsTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP generate_salt函数代码示例发布时间:2022-05-15
下一篇:
PHP generate_random_password函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap