예제 #1
0
 /**
  * 获得安全的表单数据
  * @access public
  * @param $type 'login'、'register'、'open'
  * @return array
  */
 public static function getInputData($type = null)
 {
     $InputData = array();
     switch ($type) {
         case 'login':
             foreach ($_POST as $key => $value) {
                 $_POST[$key] = trim($value);
             }
             if (!empty($_POST['u'])) {
                 if (Juser_is_mail($_POST['u'])) {
                     $InputData['mail'] = strtolower($_POST['u']);
                     #数据库仅记录小写的邮箱
                 }
             }
             if (!empty($_POST['p'])) {
                 if (Juser_is_password($_POST['p'])) {
                     $InputData['password'] = $_POST['p'];
                 }
             }
             return $InputData;
         case 'register':
             foreach ($_POST as $key => $value) {
                 $_POST[$key] = trim($value);
             }
             #用户昵称设定  禁止使用管理员、作者昵称以及博客名
             if (!empty($_POST['n']) && mb_strlen($_POST['n'], 'UTF-8') < 16) {
                 $fobidName = array_merge(Juser_get_admin_name(), array('admin', 'administrator', 'writer', 'visitor', Option::get('blogname')));
                 $UserName = strip_tags($_POST['n']);
                 $InputData['name'] = str_replace($fobidName, '**', $UserName);
             } else {
                 $InputData['name'] = '路人乙';
             }
             #注册邮箱不允许使用管理员的邮箱
             if (!empty($_POST['u']) && Juser_is_mail($_POST['u']) && !in_array($_POST['u'], Juser_get_admin_mail())) {
                 $InputData['mail'] = strtolower($_POST['u']);
                 #数据库仅记录小写的邮箱
             } else {
                 $InputData['mail'] = false;
             }
             if (!empty($_POST['p']) && !empty($_POST['rp']) && $_POST['p'] == $_POST['rp'] && Juser_is_password($_POST['p'])) {
                 $InputData['password'] = $_POST['p'];
             } else {
                 $InputData['password'] = false;
             }
             if (!empty($_POST['url']) && Juser_is_url($_POST['url'])) {
                 $InputData['url'] = rtrim($_POST['url'], '/') . '/';
             }
             return $InputData;
         default:
             return false;
             break;
     }
 }
예제 #2
0
 public static function getUserInfoByMail($mail)
 {
     if (!Juser_is_mail($mail)) {
         return false;
     }
     if (empty(self::$JuserModel)) {
         self::$JuserModel = new JuserModel();
     }
     return self::$JuserModel->field(true)->where(array('mail' => $mail))->find();
 }
예제 #3
0
 public function getPageString($mail)
 {
     if (!Juser_is_mail($mail)) {
         return '';
     }
     $rowsCount = $this->query("SELECT count(*) AS J_COUNT FROM {$this->tableName} WHERE `mail`='{$mail}'");
     $rowsCount = $rowsCount[0]['J_COUNT'];
     $nowPage = isset($_GET['page']) && ctype_digit((string) $_GET['page']) ? intval($_GET['page']) : 1;
     $pageString = pagination($rowsCount, 10, $nowPage, BLOG_URL . '?plugin=juser&a=UserComment&page=');
     return $pageString ? '<div class="Juser_page">' . $pageString . '<font class="count">共' . $rowsCount . '条</font></div>' : $pageString;
 }