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


PHP Utils::generateRandomAlphanumericStr方法代码示例

本文整理汇总了PHP中Utils::generateRandomAlphanumericStr方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::generateRandomAlphanumericStr方法的具体用法?PHP Utils::generateRandomAlphanumericStr怎么用?PHP Utils::generateRandomAlphanumericStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils的用法示例。


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

示例1: createSettingsFile

    public static function createSettingsFile($dbHostname, $dbName, $dbUsername, $dbPassword, $tablePrefix)
    {
        $encryptionSalt = Utils::generateRandomAlphanumericStr("DDD");
        $dbUsername = Utils::sanitize($dbUsername);
        $dbPassword = Utils::sanitize($dbPassword);
        $tablePrefix = Utils::sanitize($tablePrefix);
        $content = <<<END
<?php

\$dbHostname     = '{$dbHostname}';
\$dbName         = '{$dbName}';
\$dbUsername     = '{$dbUsername}';
\$dbPassword     = '{$dbPassword}';
\$dbTablePrefix  = '{$tablePrefix}';
\$encryptionSalt = '{$encryptionSalt}';
END;
        $file = __DIR__ . "/../../settings.php";
        $handle = @fopen($file, "w");
        if ($handle) {
            fwrite($handle, $content);
            fclose($handle);
            return array(true, "");
        }
        // no such luck! we couldn't create the file on the server. The user will need to do it manually
        return array(false, $content);
    }
开发者ID:balmychan,项目名称:generatedata,代码行数:26,代码来源:Installation.class.php

示例2: fillTemplate

 private static function fillTemplate($template, $countryCode)
 {
     $bic = self::generateBic($countryCode);
     $bicPos = 0;
     $unsigned = '';
     $len = strlen($template);
     $uppercaseTemplate = strtoupper($template);
     for ($i = 0; $i < $len; $i++) {
         $c = $template[$i];
         if ($uppercaseTemplate[$i] === $c) {
             $unsigned .= $c;
             continue;
         }
         if ($c === 'i') {
             $unsigned .= $bic[$bicPos++];
             continue;
         }
         if ($c === 'k') {
             $unsigned .= '_';
             continue;
         }
         $unsigned .= Utils::generateRandomAlphanumericStr('x');
     }
     return self::recalculateChecksum($unsigned);
 }
开发者ID:keepliving,项目名称:generatedata,代码行数:25,代码来源:IBAN.class.php

示例3: createSettingsFile

    public static function createSettingsFile($dbHostname, $dbName, $dbUsername, $dbPassword, $tablePrefix)
    {
        $encryptionSalt = Utils::generateRandomAlphanumericStr("DDD");
        $dbUsername = Utils::sanitize($dbUsername);
        $dbPassword = Utils::sanitize($dbPassword);
        $tablePrefix = Utils::sanitize($tablePrefix);
        $content = <<<END
<?php

\$dbHostname     = '{$dbHostname}';
\$dbName         = '{$dbName}';
\$dbUsername     = '{$dbUsername}';
\$dbPassword     = '{$dbPassword}';
\$dbTablePrefix  = '{$tablePrefix}';
\$encryptionSalt = '{$encryptionSalt}';
END;
        $file = __DIR__ . "/../../settings.php";
        $handle = @fopen($file, "w+");
        if ($handle) {
            fwrite($handle, $content);
            fclose($handle);
        }
        // now check the file exists, and if it DOES, contains the right stuff
        if (is_readable($file)) {
            $result = self::validateSettingsFile($file);
            if ($result["success"]) {
                return array(true, "");
            } else {
                return array(false, $result["error"]);
            }
        }
        // no such luck! we couldn't create the file on the server. The user will need to do it manually. Return
        // the
        return array(false, $content);
    }
开发者ID:JaeHoYun,项目名称:generatedata,代码行数:35,代码来源:Installation.class.php

示例4: generate

 public function generate($generator, $generationContextData)
 {
     $formats = explode("|", $generationContextData["generationOptions"]);
     $chosenFormat = $formats[0];
     if (count($formats) > 1) {
         $chosenFormat = $formats[mt_rand(0, count($formats) - 1)];
     }
     $val = Utils::generateRandomAlphanumericStr($chosenFormat);
     return array("display" => $val);
 }
开发者ID:balmychan,项目名称:generatedata,代码行数:10,代码来源:AlphaNumeric.class.php

示例5: generate

 public function generate($generator, $generationContextData)
 {
     $phoneStr = Utils::generateRandomAlphanumericStr($generationContextData["generationOptions"]);
     $formats = explode("|", $phoneStr);
     $chosenFormat = $formats[0];
     $numFormats = count($formats);
     if ($numFormats > 1) {
         $chosenFormat = $formats[mt_rand(0, $numFormats - 1)];
     }
     return array("display" => $chosenFormat);
 }
开发者ID:JaeHoYun,项目名称:generatedata,代码行数:11,代码来源:Phone.class.php

示例6: generate

 public function generate($generator, $generationContextData)
 {
     $placeholderStr = "HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH";
     $guid = Utils::generateRandomAlphanumericStr($placeholderStr);
     // pretty sodding unlikely, but just in case!
     while (in_array($guid, $this->generatedGUIDs)) {
         $guid = Utils::generateRandomAlphanumericStr($placeholderStr);
     }
     $this->generatedGUIDs[] = $guid;
     return array("display" => $guid);
 }
开发者ID:JaeHoYun,项目名称:generatedata,代码行数:11,代码来源:GUID.class.php

示例7: resetPassword

 public static function resetPassword($email)
 {
     $prefix = Core::getDbTablePrefix();
     $email = Utils::sanitize($email);
     $response = Core::$db->query("\n\t\t\tSELECT * \n\t\t\tFROM {$prefix}user_accounts\n\t\t\tWHERE email = '{$email}'\n\t\t\tLIMIT 1\n\t\t");
     if (!$response["success"]) {
         return;
     }
     $L = Core::$language->getCurrentLanguageStrings();
     $data = mysqli_fetch_assoc($response["results"]);
     if (empty($data)) {
         return array("success" => false, "message" => $L["user_not_found"]);
     }
     $randPassword = Utils::generateRandomAlphanumericStr("CXCXCX");
     // now attempt to send the email
     try {
         $emailContent = preg_replace("/%1/", $randPassword, $L["password_reset_email_content1"]);
         $emailContent .= "\n\n" . $L["password_reset_email_content2"];
         $emailSent = Emails::sendEmail(array("recipient" => $email, "subject" => $L["reset_password"], "content" => $emailContent));
         $encryptionSalt = Core::getEncryptionSalt();
         $encryptedPassword = crypt($randPassword, $encryptionSalt);
         $response = Core::$db->query("\n\t\t\t\tUPDATE {$prefix}user_accounts\n\t\t\t\tSET password = '{$encryptedPassword}'\n\t\t\t\tWHERE email = '{$email}'\n\t\t\t\tLIMIT 1\n\t\t\t");
         if ($response && $emailSent) {
             if ($response["success"]) {
                 return array("success" => true, "message" => $L["password_reset_complete"]);
             }
         } else {
             return array("success" => false, "message" => $L["email_not_sent"]);
         }
     } catch (Exception $e) {
         return array("success" => false, "message" => $L["email_not_sent"]);
     }
 }
开发者ID:JaeHoYun,项目名称:generatedata,代码行数:33,代码来源:Account.class.php

示例8: convert

 private function convert($countrySlug, $regionShort = "")
 {
     $zipInfo = $this->zipFormats[$countrySlug];
     $result = "";
     if ($zipInfo["isAdvanced"]) {
         // if the country plugin defined a custom zip format for this region, use it
         if (!empty($regionShort) && !empty($zipInfo["regionSpecificFormat"]) && array_key_exists($regionShort, $zipInfo["regionSpecificFormat"])) {
             $customFormat = isset($zipInfo["regionSpecificFormat"][$regionShort]["format"]) ? $zipInfo["regionSpecificFormat"][$regionShort]["format"] : "";
             $replacements = isset($zipInfo["regionSpecificFormat"][$regionShort]["replacements"]) ? $zipInfo["regionSpecificFormat"][$regionShort]["replacements"] : "";
         }
         $customFormat = !empty($customFormat) ? $customFormat : $zipInfo["format"];
         $replacements = !empty($replacements) ? $replacements : $zipInfo["replacements"];
         // now iterate over $customFormat and do whatever replacements have been specified
         $customFormatLen = strlen($customFormat);
         for ($i = 0; $i < $customFormatLen; $i++) {
             if (array_key_exists($customFormat[$i], $replacements)) {
                 $replacementKey = $replacements[$customFormat[$i]];
                 $randChar = $replacementKey[mt_rand(0, strlen($replacementKey) - 1)];
                 $result .= $randChar;
             } else {
                 $result .= $customFormat[$i];
             }
         }
     } else {
         $formats = explode("|", $zipInfo["format"]);
         $numFormats = count($formats);
         if ($numFormats == 1) {
             $format = $formats[0];
         } else {
             $format = $formats[mt_rand(0, $numFormats - 1)];
         }
         $result = Utils::generateRandomAlphanumericStr($format);
     }
     return $result;
 }
开发者ID:balmychan,项目名称:generatedata,代码行数:35,代码来源:PostalZip.class.php

示例9: replaceRandomAreaCode

 /**
  * Assumption: the area code is in a single block of A's.
  * @param $desiredFormat
  * @param $areaCodes
  * @return mixed|string
  */
 private function replaceRandomAreaCode($desiredFormat, $areaCodes)
 {
     // if the desired format doesn't contain an area code, shut down the party
     if (!strstr($desiredFormat, "A")) {
         return $desiredFormat;
     }
     $str = "";
     if (!empty($areaCodes)) {
         $areaCode = $areaCodes[mt_rand(0, count($areaCodes) - 1)];
         $str = preg_replace("/A+/", $areaCode, $desiredFormat);
     } else {
         preg_match("/A+/", $desiredFormat, $matches);
         $areaCodeLength = strlen($matches[0]);
         $replacement = substr("Xxxxxxxxxxxxxxxx", 0, $areaCodeLength);
         $str = preg_replace("/A+/", Utils::generateRandomAlphanumericStr($replacement), $desiredFormat);
     }
     return $str;
 }
开发者ID:nishant8BITS,项目名称:generatedata,代码行数:24,代码来源:PhoneRegional.class.php

示例10: header

<?php

require_once "library.php";
Core::init("installation");
// if the script is already installed, redirect them to the index page.
if (Core::checkIsInstalled()) {
    header("location: index.php");
    exit;
}
$currentPage = 1;
if (Core::checkSettingsFileExists()) {
    $currentPage = 3;
    if (Settings::getSetting("installationStepComplete_Core") == "yes") {
        $currentPage = 4;
    }
}
$params = array();
$params["theme"] = Core::getDefaultTheme();
$params["randomPassword"] = Utils::generateRandomAlphanumericStr("CVxxCxV");
$params["tablePrefix"] = Core::getDbTablePrefix();
$params["currentPage"] = $currentPage;
Templates::displayPage("resources/templates/install.tpl", $params);
开发者ID:mdb-webdev,项目名称:generatedata,代码行数:22,代码来源:install.php

示例11: convert

 private function convert($str)
 {
     $formats = explode("|", $str);
     if (count($formats) == 1) {
         $format = $formats[0];
     } else {
         $format = $formats[rand(0, count($formats) - 1)];
     }
     return Utils::generateRandomAlphanumericStr($format);
 }
开发者ID:GrimDerp,项目名称:vagrant-synthetic-data-machine,代码行数:10,代码来源:PostalZip.class.php


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