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


PHP complex_random_string函数代码示例

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


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

示例1: install_generate_configphp

/**
 * Returns content of config.php file.
 *
 * Uses PHP_EOL for generating proper end of lines for the given platform.
 *
 * @param moodle_database $database database instance
 * @param object $cfg copy of $CFG
 * @return string
 */
function install_generate_configphp($database, $cfg)
{
    $configphp = '<?php  // Moodle configuration file' . PHP_EOL . PHP_EOL;
    $configphp .= 'unset($CFG);' . PHP_EOL;
    $configphp .= 'global $CFG;' . PHP_EOL;
    $configphp .= '$CFG = new stdClass();' . PHP_EOL . PHP_EOL;
    // prevent PHP5 strict warnings
    $dbconfig = $database->export_dbconfig();
    foreach ($dbconfig as $key => $value) {
        $key = str_pad($key, 9);
        $configphp .= '$CFG->' . $key . ' = ' . var_export($value, true) . ';' . PHP_EOL;
    }
    $configphp .= PHP_EOL;
    $configphp .= '$CFG->wwwroot   = ' . var_export($cfg->wwwroot, true) . ';' . PHP_EOL;
    $configphp .= '$CFG->dataroot  = ' . var_export($cfg->dataroot, true) . ';' . PHP_EOL;
    $configphp .= '$CFG->admin     = ' . var_export($cfg->admin, true) . ';' . PHP_EOL . PHP_EOL;
    if (empty($cfg->directorypermissions)) {
        $chmod = '02777';
    } else {
        $chmod = '0' . decoct($cfg->directorypermissions);
    }
    $configphp .= '$CFG->directorypermissions = ' . $chmod . ';' . PHP_EOL . PHP_EOL;
    $configphp .= '$CFG->passwordsaltmain = ' . var_export(complex_random_string(), true) . ';' . PHP_EOL . PHP_EOL;
    $configphp .= 'require_once(dirname(__FILE__) . \'/lib/setup.php\');' . PHP_EOL . PHP_EOL;
    $configphp .= '// There is no php closing tag in this file,' . PHP_EOL;
    $configphp .= '// it is intentional because it prevents trailing whitespace problems!' . PHP_EOL;
    return $configphp;
}
开发者ID:JP-Git,项目名称:moodle,代码行数:37,代码来源:installlib.php

示例2: test_complex_random_string

 /**
  * Test function for creation of complex random strings.
  */
 public function test_complex_random_string()
 {
     $pool = preg_quote('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#%^&*()_+-=[];,./<>?:{} ', '/');
     $result = complex_random_string(10);
     $this->assertSame(10, strlen($result));
     $this->assertRegExp('/^[' . $pool . ']+$/', $result);
     $this->assertNotSame($result, complex_random_string(10));
     $result = complex_random_string(21);
     $this->assertSame(21, strlen($result));
     $this->assertRegExp('/^[' . $pool . ']+$/', $result);
     $this->assertNotSame($result, complex_random_string(21));
     $result = complex_random_string(666);
     $this->assertSame(666, strlen($result));
     $this->assertRegExp('/^[' . $pool . ']+$/', $result);
     $result = complex_random_string();
     $this->assertEquals(28, strlen($result), '', 4);
     // Expected length is 24 - 32.
     $this->assertRegExp('/^[' . $pool . ']+$/', $result);
     $this->assertDebuggingNotCalled();
     $result = complex_random_string(0);
     $this->assertSame('', $result);
     $this->assertDebuggingCalled();
     $result = complex_random_string(-1);
     $this->assertSame('', $result);
     $this->assertDebuggingCalled();
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:29,代码来源:moodlelib_test.php

示例3: generate_password

 /**
  * Returns a random string to be used as the authorization token
  *
  * @return string
  */
 protected function generate_password()
 {
     return complex_random_string();
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:9,代码来源:pluginlib.php

示例4: addsingleslashes

        $str .= '$CFG->dbname    = \'' . $INSTALL['dbname'] . "';\r\n";
        // support single quotes in db user/passwords
        $str .= '$CFG->dbuser    = \'' . addsingleslashes($INSTALL['dbuser']) . "';\r\n";
        $str .= '$CFG->dbpass    = \'' . addsingleslashes($INSTALL['dbpass']) . "';\r\n";
    }
    $str .= '$CFG->dbpersist =  false;' . "\r\n";
    $str .= '$CFG->prefix    = \'' . $INSTALL['prefix'] . "';\r\n";
    $str .= "\r\n";
    $str .= '$CFG->wwwroot   = \'' . s($INSTALL['wwwrootform'], true) . "';\r\n";
    $str .= '$CFG->dirroot   = \'' . s($INSTALL['dirrootform'], true) . "';\r\n";
    $str .= '$CFG->dataroot  = \'' . s($INSTALL['dataroot'], true) . "';\r\n";
    $str .= '$CFG->admin     = \'' . s($INSTALL['admindirname'], true) . "';\r\n";
    $str .= "\r\n";
    $str .= '$CFG->directorypermissions = 00777;  // try 02777 on a server in Safe Mode' . "\r\n";
    $str .= "\r\n";
    $str .= '$CFG->passwordsaltmain = \'' . addsingleslashes(complex_random_string()) . '\';' . "\r\n";
    $str .= "\r\n";
    $str .= 'require_once("$CFG->dirroot/lib/setup.php");' . "\r\n";
    $str .= '// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,' . "\r\n";
    $str .= '// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.' . "\r\n";
    $str .= '?>';
    umask(0137);
    if (($configsuccess = $fh = @fopen($configfile, 'w')) !== false) {
        fwrite($fh, $str);
        fclose($fh);
    }
    $INSTALL['config'] = $str;
}
//==========================================================================//
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
开发者ID:NextEinstein,项目名称:riverhills,代码行数:31,代码来源:install.php


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