本文整理汇总了PHP中helper::createRandomStr方法的典型用法代码示例。如果您正苦于以下问题:PHP helper::createRandomStr方法的具体用法?PHP helper::createRandomStr怎么用?PHP helper::createRandomStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper
的用法示例。
在下文中一共展示了helper::createRandomStr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
/**
* Post a thread.
*
* @param int $boardID
* @access public
* @return void
*/
public function post($boardID = 0)
{
$this->loadModel('forum');
if ($this->app->user->account == 'guest') {
die(js::locate($this->createLink('user', 'login', "referer=" . helper::safe64Encode($this->app->getURI()))));
}
/* Get the board. */
$board = $this->loadModel('tree')->getById($boardID);
/* Checking the board exist or not. */
if (!$board) {
die(js::error($this->lang->forum->notExist) . js::locate('back'));
}
/* Checking current user can post to the board or not. */
if (!$this->forum->canPost($board)) {
die(js::error($this->lang->forum->readonly) . js::locate('back'));
}
/* Set editor for current user. */
$this->thread->setEditor($board->id, 'post');
/* User posted a thread, try to save it to database. */
if ($_POST) {
$captchaConfig = isset($this->config->site->captcha) ? $this->config->site->captcha : 'auto';
$needCaptcha = false;
if ($captchaConfig == 'auto' and $this->loadModel('guarder')->isEvil($this->post->{$this->session->contentInput})) {
$needCaptcha = true;
}
if ($captchaConfig == 'open') {
$needCaptcha = true;
}
if ($captchaConfig == 'close') {
$needCaptcha = false;
}
/* If no captcha but is garbage, return the error info. */
$captchaInput = $this->session->captchaInput;
if ($this->post->{$captchaInput} === false and $needCaptcha) {
$this->send(array('result' => 'fail', 'reason' => 'needChecking', 'captcha' => $this->loadModel('guarder')->create4Thread()));
}
$result = $this->thread->post($boardID);
$this->send($result);
}
$titleInput = helper::createRandomStr(6, $skip = 'A-Z');
$contentInput = helper::createRandomStr(7, $skip = 'A-Z');
$this->session->set('titleInput', $titleInput);
$this->session->set('contentInput', $contentInput);
$this->config->thread->require->post = "{$this->session->titleInput}, {$this->session->contentInput}";
$this->config->thread->editor->post = array('id' => $this->session->contentInput, 'tools' => 'simple');
$this->view->title = $board->name . $this->lang->minus . $this->lang->thread->post;
$this->view->board = $board;
$this->view->canManage = $this->thread->canManage($boardID);
$this->view->titleInput = $titleInput;
$this->view->contentInput = $contentInput;
$this->view->board = $board;
$this->view->mobileURL = helper::createLink('thread', 'post', "boardID={$boardID}", '', 'mhtml');
$this->view->desktopURL = helper::createLink('thread', 'post', "boardID={$boardID}", '', 'html');
$this->display();
}
示例2: create4MessageReply
/**
* Create guarder for message reply.
*
* @access public
* @return string
*/
public function create4MessageReply()
{
$guarder = $this->createCaptcha();
$input = helper::createRandomStr(8, $skip = 'A-Z');
$this->session->set('captchaInput', $input);
shuffle($this->config->guarder->captchaTags);
$htmlTag = current($this->config->guarder->captchaTags);
list($leftTag, $rightTag) = explode('|', $htmlTag);
$equal = empty($this->config->guarder->captchas) ? "</td><td class='text-lg text-center w-40px'> {$this->lang->guarder->equal} </td><td>" : '';
return <<<EOT
<th>{$this->lang->guarder->captcha}</th>
<td>
<table class='captcha'>
<tr class='text-middle'>
<td class='text-lg w-110px'>{$leftTag}{$guarder}{$rightTag}
{$equal}
<input type='text' name='{$input}' id='{$input}' class='w-100px inline-block form-control text-center' placeholder='{$this->lang->guarder->placeholder}'/> </td>
</tr>
</table>
</td>
EOT;
}
示例3: verifyAdmin
/**
* Verify administrator through ok file.
*
* @access public
* @return array
*/
public function verifyAdmin()
{
if ($this->session->okFileName == false or $this->session->okFileName == '') {
$this->session->set('okFileName', helper::createRandomStr(4, $skip = '0-9A-Z') . '.txt');
$this->session->set('okFileContent', helper::createRandomStr(4, $skip = '0-9A-Z'));
}
$okFile = $this->app->getTmpRoot() . $this->session->okFileName;
if (file_exists($okFile) and trim(file_get_contents($okFile)) != $this->session->okFileContent or !$this->session->okFileContent) {
@unlink($okFile);
$this->session->set('okFileName', helper::createRandomStr(4, $skip = '0-9A-Z') . '.txt');
$this->session->set('okFileContent', helper::createRandomStr(4, $skip = '0-9A-Z'));
$okFile = $this->app->getTmpRoot() . $this->session->okFileName;
}
if (!file_exists($okFile) or trim(file_get_contents($okFile)) != $this->session->okFileContent) {
return array('result' => 'fail', 'name' => $okFile, 'content' => $this->session->okFileContent);
}
$this->session->set('verify', 'pass');
$this->session->set('okFileName', '');
return array('result' => 'success');
}
示例4: createHookFile
/**
* Create hook file.
*
* @param string $template
* @param string $theme
* @param string $code
* @access public
* @return bool
*/
public function createHookFile($template, $theme, $code)
{
$hookFile = $this->directories->encryptLessPath . helper::createRandomStr(6, $skip = '0-9A-Z') . ".php";
$params = $this->getCustomParams($template, $theme);
$params = var_export($params, true);
$params = str_replace("{$template}/{$theme}/", "{$template}/_THEME_CODEFIX_/", $params);
foreach ($this->config->css as $item => $value) {
$value = str_replace("{$template}/{$theme}/", "{$template}/_THEME_CODEFIX_/", $value);
}
foreach ($this->config->js as $item => $value) {
$value = str_replace("{$template}/{$theme}/", "{$template}/_THEME_CODEFIX_/", $value);
}
$cssCodes = serialize($this->config->css);
$jsCodes = serialize($this->config->js);
$cssCode = var_export($cssCodes, true);
$jsCodes = var_export($jsCodes, true);
$code = "<?php\nif(!function_exists('get_THEME_CODEFIX_CSS'))\n{\n function get_THEME_CODEFIX_CSS()\n {\n \$css = unserialize({$cssCode});\n return \$css;\n }\n}\nif(!function_exists('get_THEME_CODEFIX_JS'))\n{\n function get_THEME_CODEFIX_JS()\n {\n \$js = unserialize({$jsCodes});\n return \$js;\n }\n}\nif(!function_exists('get_THEME_CODEFIX_params'))\n{\n function get_THEME_CODEFIX_params()\n {\n return {$params};\n }\n}\n";
return file_put_contents($hookFile, $code);
}
示例5: createHookFile
/**
* Create hook file.
*
* @param string $template
* @param string $theme
* @param string $code
* @access public
* @return bool
*/
public function createHookFile($template, $theme, $code)
{
if (!is_dir($hookPath)) {
mkdir($hookPath, 0777, true);
}
$hookFile = $this->directories->encryptLessPath . helper::createRandomStr(6, $skip = '0-9A-Z') . ".php";
$params = $this->getCustomParams($template, $theme);
$css = var_export($params['css'], true);
$js = var_export($params['js'], true);
unset($params['css']);
unset($params['js']);
$params = var_export($params, true);
$css = str_replace("{$template}/{$theme}/", "{$template}/_THEME_CODEFIX_/", $css);
$js = str_replace("{$template}/{$theme}/", "{$template}/_THEME_CODEFIX_/", $js);
$params = str_replace("{$template}/{$theme}/", "{$template}/_THEME_CODEFIX_/", $params);
$code = "<?php\nif(!function_exists('get_THEME_CODEFIX_CSS'))\n{\n function get_THEME_CODEFIX_CSS()\n {\n return {$css};\n }\n}\nif(!function_exists('get_THEME_CODEFIX_JS'))\n{\n function get_THEME_CODEFIX_JS()\n {\n return {$js};\n }\n}\nif(!function_exists('get_THEME_CODEFIX_params'))\n{\n function get_THEME_CODEFIX_params()\n {\n return {$params};\n }\n}\n";
return file_put_contents($hookFile, $code);
}
示例6: verfyAdmin
/**
* Verfy administrator through ok file.
*
* @access public
* @return array
*/
public function verfyAdmin()
{
if ($this->session->okFileName == false or $this->session->okFileName == '') {
$this->session->set('okFileName', helper::createRandomStr(4, $skip = '0-9A-Z') . '.txt');
}
$okFile = $this->app->getTmpRoot() . $this->session->okFileName;
if (file_exists($okFile) and time() - filemtime($okFile) > 3600) {
@unlink($okFile);
$this->session->set('okFileName', helper::createRandomStr(4, $skip = '0-9A-Z') . '.txt');
$okFile = $this->app->getTmpRoot() . $this->session->okFileName;
}
if (!file_exists($okFile) or time() - filemtime($okFile) > 3600) {
return array('result' => 'fail', 'okFile' => $okFile);
}
return array('result' => 'success');
}