本文整理汇总了PHP中Typecho_Common::randString方法的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Common::randString方法的具体用法?PHP Typecho_Common::randString怎么用?PHP Typecho_Common::randString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Typecho_Common
的用法示例。
在下文中一共展示了Typecho_Common::randString方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: config
/**
* 获取插件配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form 配置面板
* @return void
*/
public static function config(Typecho_Widget_Helper_Form $form)
{
$mode = new Typecho_Widget_Helper_Form_Element_Radio('mode', array('smtp' => 'smtp', 'mail' => 'mail()', 'sendmail' => 'sendmail()'), 'smtp', '发信方式');
$form->addInput($mode);
$host = new Typecho_Widget_Helper_Form_Element_Text('host', NULL, 'smtp.', _t('SMTP地址'), _t('请填写 SMTP 服务器地址'));
$form->addInput($host->addRule('required', _t('必须填写一个SMTP服务器地址')));
$port = new Typecho_Widget_Helper_Form_Element_Text('port', NULL, '25', _t('SMTP端口'), _t('SMTP服务端口,一般为25。'));
$port->input->setAttribute('class', 'mini');
$form->addInput($port->addRule('required', _t('必须填写SMTP服务端口'))->addRule('isInteger', _t('端口号必须是纯数字')));
$user = new Typecho_Widget_Helper_Form_Element_Text('user', NULL, NULL, _t('SMTP用户'), _t('SMTP服务验证用户名,一般为邮箱名如:youname@domain.com'));
$form->addInput($user->addRule('required', _t('SMTP服务验证用户名')));
$pass = new Typecho_Widget_Helper_Form_Element_Password('pass', NULL, NULL, _t('SMTP密码'));
$form->addInput($pass->addRule('required', _t('SMTP服务验证密码')));
$validate = new Typecho_Widget_Helper_Form_Element_Checkbox('validate', array('validate' => '服务器需要验证', 'ssl' => 'ssl加密'), array('validate'), 'SMTP验证');
$form->addInput($validate);
$token = new Typecho_Widget_Helper_Form_Element_Password('token', NULL, Typecho_Common::randString(7), _t('Token'), _t('请勿泄露'));
$form->addInput($token);
$fromName = new Typecho_Widget_Helper_Form_Element_Text('fromName', NULL, NULL, _t('发件人名称'), _t('发件人名称,留空则使用博客标题'));
$form->addInput($fromName);
$mail = new Typecho_Widget_Helper_Form_Element_Text('mail', NULL, NULL, _t('接收邮件的地址'), _t('接收邮件的地址,如为空则使用文章作者个人设置中的邮件地址!'));
$form->addInput($mail->addRule('email', _t('请填写正确的邮件地址!')));
$contactme = new Typecho_Widget_Helper_Form_Element_Text('contactme', NULL, NULL, _t('模板中“联系我”的邮件地址'), _t('联系我用的邮件地址,如为空则使用文章作者个人设置中的邮件地址!'));
$form->addInput($contactme->addRule('email', _t('请填写正确的邮件地址!')));
$status = new Typecho_Widget_Helper_Form_Element_Checkbox('status', array('approved' => '提醒已通过评论', 'waiting' => '提醒待审核评论', 'spam' => '提醒垃圾评论'), array('approved', 'waiting'), '提醒设置', _t('该选项仅针对博主,访客只发送已通过的评论。'));
$form->addInput($status);
$other = new Typecho_Widget_Helper_Form_Element_Checkbox('other', array('to_owner' => '有评论及回复时,发邮件通知博主。', 'to_guest' => '评论被回复时,发邮件通知评论者。', 'to_me' => '自己回复自己的评论时,发邮件通知。(同时针对博主和访客)', 'to_log' => '记录邮件发送日志。'), array('to_owner', 'to_guest'), '其他设置', _t('选中该选项插件会在log/mailer_log.txt 文件中记录发送日志,需要本地可以写入文件。'));
$form->addInput($other->multiMode());
$titleForOwner = new Typecho_Widget_Helper_Form_Element_Text('titleForOwner', null, "[{title}] 一文有新的评论", _t('博主接收邮件标题'));
$form->addInput($titleForOwner->addRule('required', _t('博主接收邮件标题 不能为空')));
$titleForGuest = new Typecho_Widget_Helper_Form_Element_Text('titleForGuest', null, "您在 [{title}] 的评论有了回复", _t('访客接收邮件标题'));
$form->addInput($titleForGuest->addRule('required', _t('访客接收邮件标题 不能为空')));
}
示例2: setBody
private function setBody()
{
if (empty($this->parameter->confirm)) {
throw new Typecho_Widget_Exception(_t('收件人不存在'), 404);
}
$this->parameter->siteTitle = $this->options->title;
$this->parameter->token = strtolower(Typecho_Common::randString(8));
$this->parameter->subject = $this->_type[$this->parameter->type];
switch ($this->parameter->type) {
case 'reset':
$url = '/forgot';
break;
case 'register':
$url = '/activate';
break;
default:
$url = '';
break;
}
if (!empty($url)) {
$this->parameter->url = Typecho_Common::url($url . '?token=' . $this->parameter->token, $this->options->index);
} else {
$this->parameter->url = $this->parameter->token;
}
$this->parameter->body = $this->parseBody();
return $this;
}
示例3: add
/**
* 添加新的链接转换
*
*/
public function add()
{
$key = $this->request->key;
$key = $key ? $key : Typecho_Common::randString(8);
$target = $this->request->target;
if ($target === "" || $target === "http://") {
$this->widget('Widget_Notice')->set(_t('请输入目标链接。'), NULL, 'error');
} elseif ($this->getTarget($key)) {
$this->widget('Widget_Notice')->set(_t('该key已被使用,请更换key值。'), NULL, 'error');
} else {
$links = array('key' => $key, 'target' => $this->request->target, 'count' => 0);
$insertId = $this->db->query($this->db->insert('table.golinks')->rows($links));
}
}
示例4: action
/**
* 初始化函数
*
* @access public
* @return void
*/
public function action()
{
// protect
$this->security->protect();
/** 如果已经登录 */
if ($this->user->hasLogin() || !$this->options->allowRegister) {
/** 直接返回 */
$this->response->redirect($this->options->index);
}
/** 初始化验证类 */
$validator = new Typecho_Validate();
$validator->addRule('name', 'required', _t('必须填写用户名称'));
$validator->addRule('name', 'minLength', _t('用户名至少包含2个字符'), 2);
$validator->addRule('name', 'maxLength', _t('用户名最多包含32个字符'), 32);
$validator->addRule('name', 'xssCheck', _t('请不要在用户名中使用特殊字符'));
$validator->addRule('name', array($this, 'nameExists'), _t('用户名已经存在'));
$validator->addRule('mail', 'required', _t('必须填写电子邮箱'));
$validator->addRule('mail', array($this, 'mailExists'), _t('电子邮箱地址已经存在'));
$validator->addRule('mail', 'email', _t('电子邮箱格式错误'));
$validator->addRule('mail', 'maxLength', _t('电子邮箱最多包含200个字符'), 200);
/** 如果请求中有password */
if (array_key_exists('password', $_REQUEST)) {
$validator->addRule('password', 'required', _t('必须填写密码'));
$validator->addRule('password', 'minLength', _t('为了保证账户安全, 请输入至少六位的密码'), 6);
$validator->addRule('password', 'maxLength', _t('为了便于记忆, 密码长度请不要超过十八位'), 18);
$validator->addRule('confirm', 'confirm', _t('两次输入的密码不一致'), 'password');
}
/** 截获验证异常 */
if ($error = $validator->run($this->request->from('name', 'password', 'mail', 'confirm'))) {
Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
Typecho_Cookie::set('__typecho_remember_mail', $this->request->mail);
/** 设置提示信息 */
$this->widget('Widget_Notice')->set($error);
$this->response->goBack();
}
$hasher = new PasswordHash(8, true);
$generatedPassword = Typecho_Common::randString(7);
$dataStruct = array('name' => $this->request->name, 'mail' => $this->request->mail, 'screenName' => $this->request->name, 'password' => $hasher->HashPassword($generatedPassword), 'created' => $this->options->gmtTime, 'group' => 'subscriber');
$dataStruct = $this->pluginHandle()->register($dataStruct);
$insertId = $this->insert($dataStruct);
$this->db->fetchRow($this->select()->where('uid = ?', $insertId)->limit(1), array($this, 'push'));
$this->pluginHandle()->finishRegister($this);
$this->user->login($this->request->name, $generatedPassword);
Typecho_Cookie::delete('__typecho_first_run');
Typecho_Cookie::delete('__typecho_remember_name');
Typecho_Cookie::delete('__typecho_remember_mail');
$this->widget('Widget_Notice')->set(_t('用户 <strong>%s</strong> 已经成功注册, 密码为 <strong>%s</strong>', $this->screenName, $generatedPassword), 'success');
$this->response->redirect($this->options->adminUrl);
}
示例5: login
/**
* 以用户名和密码登录
*
* @access public
* @param string $name 用户名
* @param string $password 密码
* @param boolean $temporarily 是否为临时登录
* @param integer $expire 过期时间
* @return boolean
*/
public function login($name, $password, $temporarily = false, $expire = 0)
{
//插件接口
$result = $this->pluginHandle()->trigger($loginPluggable)->login($name, $password, $temporarily, $expire);
if ($loginPluggable) {
return $result;
}
/** 开始验证用户 **/
$user = $this->db->fetchRow($this->db->select()->from('table.users')->where((strpos($name, '@') ? 'mail' : 'name') . ' = ?', $name)->limit(1));
if (empty($user)) {
return false;
}
$hashValidate = $this->pluginHandle()->trigger($hashPluggable)->hashValidate($password, $user['password']);
if (!$hashPluggable) {
if ('$P$' == substr($user['password'], 0, 3)) {
$hasher = new PasswordHash(8, true);
$hashValidate = $hasher->CheckPassword($password, $user['password']);
} else {
$hashValidate = Typecho_Common::hashValidate($password, $user['password']);
}
}
if ($user && $hashValidate) {
if (!$temporarily) {
$authCode = function_exists('openssl_random_pseudo_bytes') ? bin2hex(openssl_random_pseudo_bytes(16)) : sha1(Typecho_Common::randString(20));
$user['authCode'] = $authCode;
Typecho_Cookie::set('__typecho_uid', $user['uid'], $expire);
Typecho_Cookie::set('__typecho_authCode', Typecho_Common::hash($authCode), $expire);
//更新最后登录时间以及验证码
$this->db->query($this->db->update('table.users')->expression('logged', 'activated')->rows(array('authCode' => $authCode))->where('uid = ?', $user['uid']));
}
/** 压入数据 */
$this->push($user);
$this->_hasLogin = true;
$this->pluginHandle()->loginSucceed($this, $name, $password, $temporarily, $expire);
return true;
}
$this->pluginHandle()->loginFail($this, $name, $password, $temporarily, $expire);
return false;
}
示例6: parseComment
/**
* 获取邮件内容
*
* @access public
* @param $comment 调用参数
* @return void
*/
public static function parseComment($comment)
{
$options = Typecho_Widget::widget('Widget_Options');
$cfg = array('siteTitle' => $options->title, 'timezone' => $options->timezone, 'cid' => $comment->cid, 'coid' => $comment->coid, 'created' => $comment->created, 'author' => $comment->author, 'authorId' => $comment->authorId, 'ownerId' => $comment->ownerId, 'mail' => $comment->mail, 'ip' => $comment->ip, 'title' => $comment->title, 'text' => $comment->text, 'permalink' => $comment->permalink, 'status' => $comment->status, 'parent' => $comment->parent, 'manage' => $options->siteUrl . "admin/manage-comments.php");
self::$_isMailLog = in_array('to_log', Helper::options()->plugin('CommentToMail')->other) ? true : false;
//是否接收邮件
if (isset($_POST['banmail']) && 'stop' == $_POST['banmail']) {
$cfg['banMail'] = 1;
} else {
$cfg['banMail'] = 0;
}
$fileName = Typecho_Common::randString(7);
$cfg = (object) $cfg;
file_put_contents(dirname(__FILE__) . '/cache/' . $fileName, serialize($cfg));
$url = $options->rewrite ? $options->siteUrl : $options->siteUrl . 'index.php';
$url = rtrim($url, '/') . '/action/' . self::$action . '?send=' . $fileName;
$date = new Typecho_Date(Typecho_Date::gmtTime());
$time = $date->format('Y-m-d H:i:s');
self::saveLog("{$time} 开始发送请求:{$url}\n");
self::asyncRequest($url);
}
示例7: setUserLogin
/**
* 设置用户登陆状态
*/
protected function setUserLogin($uid, $expire = 30243600)
{
Typecho_Widget::widget('Widget_User')->simpleLogin($uid);
$authCode = function_exists('openssl_random_pseudo_bytes') ? bin2hex(openssl_random_pseudo_bytes(16)) : sha1(Typecho_Common::randString(20));
Typecho_Cookie::set('__typecho_uid', $uid, time() + $expire);
Typecho_Cookie::set('__typecho_authCode', Typecho_Common::hash($authCode), time() + $expire);
//更新最后登录时间以及验证码
$this->db->query($this->db->update('table.users')->expression('logged', 'activated')->rows(array('authCode' => $authCode))->where('uid = ?', $uid));
}
示例8: upload
/**
* 上传处理功能
*/
public function upload($filead)
{
if (!empty($_FILES['file']['name']) || $filead) {
if (!$filead and !isset($_FILES['file']) || !is_uploaded_file($_FILES['file']['tmp_name']) || $_FILES['file']['error'] != 0) {
echo '<script>alert("上传失败!")</script>';
exit(0);
} elseif ($filead) {
$this->_file = basename($filead);
$part = pathinfo($this->_file);
if ($part['extension'] !== "zip") {
$this->_file = "tmp" . Typecho_Common::randString(6) . ".zip";
}
$ff = file_get_contents($filead);
if ($ff) {
file_put_contents($this->_file, $ff);
$up = False;
if (!$this->isZip($this->_file)) {
$this->showMsg('取得的文件不是zip类型', FALSE, TRUE);
}
} else {
$this->showMsg('获取远程文件失败。', FALSE, TRUE);
}
} else {
$this->_file = $_FILES['file']['tmp_name'];
$up = True;
}
$path = '';
$upType = '插件';
if (class_exists('ZipArchive')) {
$zip = new ZipArchive();
} else {
$this->showMsg("服务器不支持 php ZipArchive 类", $up);
}
if ($zip->open($this->_file) === TRUE) {
//单文件插件
if ($zip->numFiles === 1) {
$contents = $zip->getFromIndex(0);
if ($this->isPlugin($contents)) {
$path = '.' . __TYPECHO_PLUGIN_DIR__ . '/';
}
} else {
//多文件插件,搜索Plugin.php文件路径,获取插件信息
$index = $zip->locateName('Plugin.php', ZIPARCHIVE::FL_NOCASE | ZIPARCHIVE::FL_NODIR);
if ($index || 0 === $index) {
$dirs = count(explode('/', $zip->getNameIndex($index)));
if ($dirs > 2) {
$this->showMsg('压缩路径太深,无法正常安装', $up, TRUE);
}
$contents = $zip->getFromIndex($index);
$name = $this->isPlugin($contents);
if ($name) {
if (2 == $dirs) {
$path = '.' . __TYPECHO_PLUGIN_DIR__ . '/';
} else {
$path = '.' . __TYPECHO_PLUGIN_DIR__ . '/' . $name . '/';
}
}
} else {
//如果不是插件,则按模板搜索判断
$index = $zip->locateName('index.php', ZIPARCHIVE::FL_NOCASE | ZIPARCHIVE::FL_NODIR);
if ($index || 0 === $index) {
$upType = '外观';
$dirs = count(explode('/', $zip->getNameIndex($index)));
if ($dirs > 2) {
$this->showMsg('压缩路径太深,无法正常安装', $up, TRUE);
}
$contents = $zip->getFromIndex($index);
if ($this->isTheme($contents)) {
if (2 == $dirs) {
$path = '.' . __TYPECHO_THEME_DIR__ . '/';
} else {
$name = basename($_FILES['file']['name'], '.zip');
$path = '.' . __TYPECHO_THEME_DIR__ . '/' . $name . '/';
}
}
}
}
}
if ($path !== '') {
if ($zip->extractTo($path)) {
$zip->close();
$this->showMsg("安装成功,请到 控制台-->" . $upType . " 中激活使用。", $up, TRUE);
} else {
$this->showMsg("解压失败,请确认" . $upType . "目录是否有写权限。", $up);
}
} else {
$this->showMsg('上传的文件不是Typecho插件和模板', $up);
}
} else {
$this->showMsg('无法打开压缩包,请检查压缩包是否损坏。', $up);
}
@unlink($this->_file);
} else {
$this->widget('Widget_Archive@404', 'type=404')->render();
exit;
}
}
示例9: toMail
/**
* 组合邮件内容
*
* @access public
* @param $post 调用参数
* @return void
*/
public static function toMail($post)
{
$smtp = array();
$options = Typecho_Widget::widget('Widget_Options');
$smtp['site'] = $options->title;
$smtp['timezone'] = $options->timezone;
$smtp['cid'] = $post->cid;
$smtp['coid'] = $post->coid;
$smtp['created'] = $post->created;
$smtp['author'] = $post->author;
$smtp['authorId'] = $post->authorId;
$smtp['ownerId'] = $post->ownerId;
$smtp['mail'] = $post->mail;
$smtp['ip'] = $post->ip;
$smtp['title'] = $post->title;
$smtp['text'] = $post->text;
$smtp['permalink'] = $post->permalink;
$smtp['status'] = $post->status;
$smtp['parent'] = $post->parent;
$smtp['manage'] = $options->siteUrl . "admin/manage-comments.php";
//获取是否接收邮件的选项
if (isset($_POST['banmail']) && 'stop' == $_POST['banmail']) {
$smtp['banMail'] = 1;
} else {
$smtp['banMail'] = 0;
}
$filename = Typecho_Common::randString(7);
$smtp = (object) $smtp;
file_put_contents('.' . __TYPECHO_PLUGIN_DIR__ . '/CommentToMail/cache/' . $filename, serialize($smtp));
$url = $options->rewrite ? $options->siteUrl : $options->siteUrl . 'index.php';
self::asyncRequest($filename, $url);
}
示例10: authLogin
protected function authLogin($uid, $expire = 0)
{
$authCode = function_exists('openssl_random_pseudo_bytes') ? bin2hex(openssl_random_pseudo_bytes(16)) : sha1(Typecho_Common::randString(20));
Typecho_Cookie::set('__some_uid', $uid, $expire);
Typecho_Cookie::set('__some_authCode', Typecho_Common::hash($authCode), $expire);
//更新最后登录时间以及验证码
$this->db->query($this->db->update('table.users')->expression('logged', 'activated')->rows(array('authCode' => $authCode))->where('uid = ?', $uid));
}
示例11: v0_9r14_3_14
/**
* v0_9r14_3_14
*
* @param mixed $db
* @param mixed $options
* @access public
* @return void
*/
public function v0_9r14_3_14($db, $options)
{
$db->query($db->insert('table.options')->rows(array('name' => 'secret', 'user' => 0, 'value' => Typecho_Common::randString(32, true))));
}
示例12: empty
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsPageSize', 'user' => 0, 'value' => 20)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsPageDisplay', 'user' => 0, 'value' => 'last')));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsOrder', 'user' => 0, 'value' => 'ASC')));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsCheckReferer', 'user' => 0, 'value' => 1)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsAutoClose', 'user' => 0, 'value' => 0)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsPostIntervalEnable', 'user' => 0, 'value' => 1)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsPostInterval', 'user' => 0, 'value' => 60)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsShowCommentOnly', 'user' => 0, 'value' => 0)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsAvatar', 'user' => 0, 'value' => 1)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsAvatarRating', 'user' => 0, 'value' => 'G')));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsAntiSpam', 'user' => 0, 'value' => 1)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'routingTable', 'user' => 0, 'value' => 'a:25:{s:5:"index";a:3:{s:3:"url";s:1:"/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:7:"archive";a:3:{s:3:"url";s:6:"/blog/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:2:"do";a:3:{s:3:"url";s:22:"/action/[action:alpha]";s:6:"widget";s:9:"Widget_Do";s:6:"action";s:6:"action";}s:4:"post";a:3:{s:3:"url";s:24:"/archives/[cid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:10:"attachment";a:3:{s:3:"url";s:26:"/attachment/[cid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:8:"category";a:3:{s:3:"url";s:17:"/category/[slug]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:3:"tag";a:3:{s:3:"url";s:12:"/tag/[slug]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:6:"author";a:3:{s:3:"url";s:22:"/author/[uid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:6:"search";a:3:{s:3:"url";s:19:"/search/[keywords]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:10:"index_page";a:3:{s:3:"url";s:21:"/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"archive_page";a:3:{s:3:"url";s:26:"/blog/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:13:"category_page";a:3:{s:3:"url";s:32:"/category/[slug]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:8:"tag_page";a:3:{s:3:"url";s:27:"/tag/[slug]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"author_page";a:3:{s:3:"url";s:37:"/author/[uid:digital]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"search_page";a:3:{s:3:"url";s:34:"/search/[keywords]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"archive_year";a:3:{s:3:"url";s:18:"/[year:digital:4]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:13:"archive_month";a:3:{s:3:"url";s:36:"/[year:digital:4]/[month:digital:2]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"archive_day";a:3:{s:3:"url";s:52:"/[year:digital:4]/[month:digital:2]/[day:digital:2]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:17:"archive_year_page";a:3:{s:3:"url";s:38:"/[year:digital:4]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:18:"archive_month_page";a:3:{s:3:"url";s:56:"/[year:digital:4]/[month:digital:2]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:16:"archive_day_page";a:3:{s:3:"url";s:72:"/[year:digital:4]/[month:digital:2]/[day:digital:2]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"comment_page";a:3:{s:3:"url";s:53:"[permalink:string]/comment-page-[commentPage:digital]";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:4:"feed";a:3:{s:3:"url";s:20:"/feed[feed:string:0]";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:4:"feed";}s:8:"feedback";a:3:{s:3:"url";s:31:"[permalink:string]/[type:alpha]";s:6:"widget";s:15:"Widget_Feedback";s:6:"action";s:6:"action";}s:4:"page";a:3:{s:3:"url";s:12:"/[slug].html";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}}')));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'actionTable', 'user' => 0, 'value' => 'a:0:{}')));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'panelTable', 'user' => 0, 'value' => 'a:0:{}')));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'attachmentTypes', 'user' => 0, 'value' => '@image@')));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'secret', 'user' => 0, 'value' => Typecho_Common::randString(32, true))));
/** 初始分类 */
$installDb->query($installDb->insert('table.metas')->rows(array('name' => _t('默认分类'), 'slug' => 'default', 'type' => 'category', 'description' => _t('只是一个默认分类'), 'count' => 1, 'order' => 1)));
/** 初始关系 */
$installDb->query($installDb->insert('table.relationships')->rows(array('cid' => 1, 'mid' => 1)));
/** 初始内容 */
$installDb->query($installDb->insert('table.contents')->rows(array('title' => _t('欢迎使用 Typecho'), 'slug' => 'start', 'created' => Typecho_Date::gmtTime(), 'modified' => Typecho_Date::gmtTime(), 'text' => '<!--markdown-->' . _t('如果您看到这篇文章,表示您的 blog 已经安装成功.'), 'authorId' => 1, 'type' => 'post', 'status' => 'publish', 'commentsNum' => 1, 'allowComment' => 1, 'allowPing' => 1, 'allowFeed' => 1, 'parent' => 0)));
$installDb->query($installDb->insert('table.contents')->rows(array('title' => _t('关于'), 'slug' => 'start-page', 'created' => Typecho_Date::gmtTime(), 'modified' => Typecho_Date::gmtTime(), 'text' => '<!--markdown-->' . _t('本页面由 Typecho 创建, 这只是个测试页面.'), 'authorId' => 1, 'order' => 0, 'type' => 'page', 'status' => 'publish', 'commentsNum' => 0, 'allowComment' => 1, 'allowPing' => 1, 'allowFeed' => 1, 'parent' => 0)));
/** 初始评论 */
$installDb->query($installDb->insert('table.comments')->rows(array('cid' => 1, 'created' => Typecho_Date::gmtTime(), 'author' => 'Typecho', 'ownerId' => 1, 'url' => 'http://typecho.org', 'ip' => '127.0.0.1', 'agent' => $options->generator, 'text' => '欢迎加入 Typecho 大家族', 'type' => 'comment', 'status' => 'approved', 'parent' => 0)));
/** 初始用户 */
$password = empty($config['userPassword']) ? substr(uniqid(), 7) : $config['userPassword'];
$hasher = new PasswordHash(8, true);
$installDb->query($installDb->insert('table.users')->rows(array('name' => $config['userName'], 'password' => $hasher->HashPassword($password), 'mail' => $config['userMail'], 'url' => 'http://www.typecho.org', 'screenName' => $config['userName'], 'group' => 'administrator', 'created' => Typecho_Date::gmtTime())));
unset($_SESSION['typecho']);
header('Location: ./install.php?finish&user=' . urlencode($config['userName']) . '&password=' . urlencode($password));
示例13: login
/**
* 以用户名和密码登录
*
* @access public
* @param string $name 用户名
* @param string $password 密码
* @param boolean $temporarily 是否为临时登录
* @param integer $expire 过期时间
* @return boolean
*/
public function login($name, $password, $temporarily = false, $expire = 0)
{
//插件接口
$result = $this->pluginHandle()->trigger($loginPluggable)->login($name, $password, $temporarily, $expire);
if ($loginPluggable) {
return $result;
}
/** 开始验证用户 **/
$user = $this->db->fetchRow($this->db->select()->from('table.users')->where('name = ?', $name)->limit(1));
$hashValidate = $this->pluginHandle()->trigger($hashPluggable)->hashValidate($password, $user['password']);
if (!$hashPluggable) {
$hashValidate = Typecho_Common::hashValidate($password, $user['password']);
}
if ($user && $hashValidate) {
if (!$temporarily) {
$authCode = sha1(Typecho_Common::randString(20));
$user['authCode'] = $authCode;
Typecho_Cookie::set('__typecho_uid', $user['uid'], $expire, $this->options->siteUrl);
Typecho_Cookie::set('__typecho_authCode', Typecho_Common::hash($authCode), $expire, $this->options->siteUrl);
//更新最后登录时间以及验证码
$this->db->query($this->db->update('table.users')->expression('logged', 'activated')->rows(array('authCode' => $authCode))->where('uid = ?', $user['uid']));
}
/** 压入数据 */
$this->push($user);
$this->_hasLogin = true;
$this->pluginHandle()->loginSucceed($this, $name, $password, $temporarily, $expire);
return true;
}
$this->pluginHandle()->loginFail($this, $name, $password, $temporarily, $expire);
return false;
}
示例14: asyncSendMail
/**
* 异步发送邮件
*
* @access public
* @return void
*/
public static function asyncSendMail($data)
{
$filename = Typecho_Common::randString(8);
file_put_contents(self::getDIr() . $filename, serialize($data));
self::putAsyncMail($filename);
}