public function GetAvatarURL()
 {
     // 请求参数列表
     $RequestParameter = array("access_token" => $this->AccessToken, "oauth_consumer_key" => $this->AppKey, "openid" => $this->OpenID, "format" => "json");
     $GraphURL = self::GET_USER_INFO_URL . '?' . http_build_query($RequestParameter);
     $Response = URL::Get($GraphURL);
     // http://wiki.connect.qq.com/get_info
     $UserInfo = json_decode($Response, true);
     if ($UserInfo['ret'] != 0) {
         //记录错误,这里没写Error Log模块
         return null;
     } else {
         // 返回头像
         return $UserInfo['figureurl_qq_2'];
     }
 }
예제 #2
0
 public function GetUserInfo()
 {
     // 请求参数列表
     $RequestParameter = array("access_token" => $this->AccessToken);
     $Response = URL::Get(self::GET_USER_INFO_URL . '?' . http_build_query($RequestParameter));
     $UserInfo = json_decode($Response, true);
     if ($UserInfo === false || empty($UserInfo['id'])) {
         //记录错误,这里没写Error Log模块
         return false;
     } else {
         // 储存昵称
         $this->NickName = $UserInfo['login'];
         // 储存头像
         $this->AvatarURL = $UserInfo['avatar_url'];
         return true;
     }
 }
예제 #3
0
 public function GetUserInfo()
 {
     // 请求参数列表
     $RequestParameter = array("access_token" => $this->AccessToken, "openid" => $this->OpenID, "lang" => "zh-CN");
     $GraphURL = self::GET_USER_INFO_URL . '?' . http_build_query($RequestParameter);
     $Response = URL::Get($GraphURL);
     // http://wiki.connect.qq.com/get_user_info
     $UserInfo = json_decode($Response, true);
     if ($UserInfo === false || empty($UserInfo['openid'])) {
         //记录错误,这里没写Error Log模块
         return false;
     } else {
         // 储存昵称
         $this->NickName = $UserInfo['nickname'];
         // 储存头像
         $this->AvatarURL = $UserInfo['headimgurl'];
         return true;
     }
 }
 /**
  * Outputs the section to the client.
  *
  * Outputs the HTML opening tags, then the content, then the HTML closing tags.
  */
 function Show()
 {
     echo "<div class='div_navi'>\n";
     $start = max(0, $this->page - $this->range);
     $end = min($this->pages - 1, $this->page + $this->range);
     if ($this->pages <= $this->range_all) {
         $start = 0;
         $end = $this->pages - 1;
     }
     if ($this->page > 0) {
         $this->url->parameters[$this->key] = 0;
         echo "<a href='" . $this->url->Get() . "'>{$this->first}</a>";
         $this->url->parameters[$this->key] = $this->page - 1;
         echo "&nbsp;<a href='" . $this->url->Get() . "'>{$this->previous}</a>";
     } else {
         echo "{$this->first}&nbsp;{$this->previous}";
     }
     if ($start > 0) {
         echo "&nbsp;...";
     }
     for ($i = $start; $i <= $end; $i++) {
         $this->url->parameters[$this->key] = $i;
         if ($i != $this->page) {
             echo "&nbsp;<a href='" . $this->url->Get() . "'>" . ($i + 1) . "</a>";
         } else {
             echo "&nbsp;" . ($i + 1);
         }
     }
     if ($end < $this->pages - 1) {
         echo "&nbsp;...";
     }
     if ($this->page < $this->pages - 1) {
         $this->url->parameters[$this->key] = $this->page + 1;
         echo "&nbsp;<a href='" . $this->url->Get() . "'>{$this->next}</a>";
         $this->url->parameters[$this->key] = $this->pages - 1;
         echo "&nbsp;<a href='" . $this->url->Get() . "'>{$this->last}</a><br>\n";
     } else {
         echo "&nbsp;{$this->next}&nbsp;{$this->last}<br>\n";
     }
     parent::Show();
     echo "</div>\n";
 }
예제 #5
0
            //Insert App user
            $DB->query('INSERT INTO `' . $Prefix . 'app_users`
				 (`ID`, `AppID`, `OpenID`, `AppUserName`, `UserID`, `Time`) 
				VALUES (:ID, :AppID, :OpenID, :AppUserName, :UserID, :Time)', array('ID' => null, 'AppID' => $AppID, 'OpenID' => $OauthObject->OpenID, 'AppUserName' => htmlspecialchars($OauthObject->NickName), 'UserID' => $CurUserID, 'Time' => $TimeStamp));
            //var_dump(htmlspecialchars($OauthObject->NickName));
            //更新全站统计数据
            $NewConfig = array("NumUsers" => $Config["NumUsers"] + 1, "DaysUsers" => $Config["DaysUsers"] + 1);
            UpdateConfig($NewConfig);
            // 设置登录状态
            $TemporaryUserExpirationTime = 30 * 86400 + $TimeStamp;
            //默认保持30天登陆状态
            SetCookies(array('UserID' => $CurUserID, 'UserExpirationTime' => $TemporaryUserExpirationTime, 'UserCode' => md5($NewUserPassword . $NewUserSalt . $TemporaryUserExpirationTime . $SALT)), 30);
            if ($OauthUserInfo) {
                //获取并缩放头像
                require __DIR__ . "/includes/ImageResize.class.php";
                $UploadAvatar = new ImageResize('String', URL::Get($OauthObject->AvatarURL));
                $LUploadResult = $UploadAvatar->Resize(256, 'upload/avatar/large/' . $CurUserID . '.png', 80);
                $MUploadResult = $UploadAvatar->Resize(48, 'upload/avatar/middle/' . $CurUserID . '.png', 90);
                $SUploadResult = $UploadAvatar->Resize(24, 'upload/avatar/small/' . $CurUserID . '.png', 90);
            } else {
                if (extension_loaded('gd')) {
                    require __DIR__ . "/includes/MaterialDesign.Avatars.class.php";
                    $Avatar = new MDAvtars(mb_substr($UserName, 0, 1, "UTF-8"), 256);
                    $Avatar->Save('upload/avatar/large/' . $CurUserID . '.png', 256);
                    $Avatar->Save('upload/avatar/middle/' . $CurUserID . '.png', 48);
                    $Avatar->Save('upload/avatar/small/' . $CurUserID . '.png', 24);
                    $Avatar->Free();
                }
            }
            header('location: ' . $Config['WebsitePath'] . '/');
            exit;
예제 #6
0
 /**
  * Outputs the section to the client.
  */
 function Show()
 {
     $this->table->ShowForm("form_{$this->table->name}", $this->url->Get(), $this->submit, $this->data);
     parent::Show();
 }
예제 #7
0
 /**
  * Outputs a list for viewing/editing records.
  *
  * @param URL $url URL to link the records to. Leave blank for no links.
  * @param int $page Current page to show the records. Leave -1 to show all records.
  * @param array $data Array containing the data to seek as 'field' => 'value'.
  * @return bool Returns TRUE on success, FALSE on error.
  */
 function ShowList($url = NULL, $page = -1, $data = NULL)
 {
     $sel = array('from' => array($this->name_db));
     foreach ($this->fields_list as $field) {
         $sel['fields'][] = $field->name_db;
     }
     foreach ($this->fields as $field) {
         if ($field->pkey) {
             $sel['fields'][] = $field->name_db;
         }
     }
     if (!empty($data)) {
         $where = '';
         foreach ($this->fields as $field) {
             if (isset($data[$field->name_form])) {
                 $where .= (strlen($where) ? ' AND ' : '') . $field->Where($data[$field->name_form]);
             }
         }
         if (strlen($where)) {
             $sel['where'] = $where;
         }
     }
     if (!empty($this->list_order)) {
         $sel['order'] = $this->list_order;
     }
     if (!($rs = $this->db->Select($sel))) {
         $this->error = TB_ERR_DB;
         return FALSE;
     }
     if ($page >= 0) {
         if ($page > 0) {
             $rs->SetRow($this->list_recspage * $page);
         }
         $rows = array();
         for ($i = 0; $i < $this->list_recspage; $i++) {
             if (!($rows[] = $rs->Row())) {
                 break;
             }
         }
     } else {
         if (!($rows = $rs->All())) {
             $this->error = TB_ERR_EMPTY;
             return FALSE;
         }
     }
     echo "<div class='div_list'><table id='tb_{$this->name}'>\n<thead><tr>\n";
     foreach ($this->fields_list as $field) {
         echo "<th class='fd_{$field->name}'>{$field->label}</th>\n";
     }
     echo "</tr></thead>\n<tbody>\n";
     foreach ($rows as $row) {
         if (!empty($row)) {
             echo "<tr>\n";
             if (!empty($url)) {
                 foreach ($this->fields as $field) {
                     if ($field->pkey) {
                         $url->parameters[$field->name] = $row[$field->name];
                     }
                 }
             }
             foreach ($this->fields_list as $field) {
                 echo "<td class='fd_{$field->name}'>";
                 if (!empty($url)) {
                     echo "<a href='" . $url->Get() . "'>";
                 }
                 $field->ShowPlain($row[$field->name]);
                 if (!empty($url)) {
                     echo '</a>';
                 }
                 echo "</td>\n";
             }
             echo "</tr>\n";
         }
     }
     echo "</tbody>\n</table></div>\n";
     return TRUE;
 }
예제 #8
0
 /**
  * Build the buttons and return them.
  *
  * @return string Returns the HTML code for the form's buttons.
  */
 function BuildButtons()
 {
     global $vortex_msgs;
     $code = '';
     $buttons = preg_split('//', $this->buttons, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($buttons as $button) {
         if (!strcmp($button, 'S')) {
             if (empty($this->img_submit)) {
                 $code .= "<input type='submit' value='" . (empty($this->txt_submit) ? $vortex_msgs['form_submit'] : $this->txt_submit) . "' />\n";
             } else {
                 $code .= "<input type='image' src='{$this->img_submit}' alt='" . (empty($this->txt_submit) ? $vortex_msgs['form_submit'] : $this->txt_submit) . "' />\n";
             }
         } elseif (!strcmp($button, 'R')) {
             $url = new URL();
             foreach ($this->table->fields as $field) {
                 if ($field->pkey) {
                     unset($url->parameters[$field->name]);
                 }
             }
             unset($url->parameters["page_{$this->table->name}"]);
             $url->parameters["{$this->table->name}_action"] = 'R';
             $code .= "<script language='JavaScript'>\n\tfunction {$this->table->name}_Reset() {\n\t\tdocument.form_{$this->table->name}.action = '" . $url->Get() . "';\n\t\tdocument.form_{$this->table->name}.submit();\n\t}\n</script>\n";
             if (empty($this->img_reset)) {
                 $code .= "<input type='button' value='" . (empty($this->txt_reset) ? $vortex_msgs['form_reset'] : $this->txt_reset) . "' onclick='{$this->table->name}_Reset();' />\n";
             } else {
                 $code .= "<input type='image' src='{$this->img_reset}' alt='" . (empty($this->txt_reset) ? $vortex_msgs['form_reset'] : $this->txt_reset) . "' onclick='{$this->table->name}_Reset();' />\n";
             }
         } elseif (!strcmp($button, 'N')) {
             $url = new URL();
             $url->parameters["{$this->table->name}_action"] = 'N';
             $code .= "<script language='JavaScript'>\n\tfunction {$this->table->name}_New() {\n\t\tdocument.form_{$this->table->name}.action = '" . $url->Get() . "';\n\t\tdocument.form_{$this->table->name}.submit();\n\t}\n</script>\n";
             if (empty($this->img_new)) {
                 $code .= "<input type='button' value='" . (empty($this->txt_new) ? $vortex_msgs['form_new'] : $this->txt_new) . "' onclick='{$this->table->name}_New();' />\n";
             } else {
                 $code .= "<input type='image' src='{$this->img_new}' alt='" . (empty($this->txt_new) ? $vortex_msgs['form_new'] : $this->txt_new) . "' onclick='{$this->table->name}_New();' />\n";
             }
         } elseif (!strcmp($button, 'D')) {
             $url = new URL();
             $url->parameters["{$this->table->name}_action"] = 'D';
             $code .= "<script language='JavaScript'>\n\tfunction {$this->table->name}_Delete() {\n\t\tdocument.form_{$this->table->name}.action = '" . $url->Get() . "';\n\t\tdocument.form_{$this->table->name}.submit();\n\t}\n</script>\n";
             if (empty($this->img_delete)) {
                 $code .= "<input type='button' value='" . (empty($this->txt_delete) ? $vortex_msgs['form_delete'] : $this->txt_delete) . "' onclick='{$this->table->name}_Delete();' />\n";
             } else {
                 $code .= "<input type='image' src='{$this->img_delete}' alt='" . (empty($this->txt_delete) ? $vortex_msgs['form_delete'] : $this->txt_delete) . "' onclick='{$this->table->name}_Delete();' />\n";
             }
         } elseif (!strcmp($button, 'F')) {
             $url = new URL();
             unset($url->parameters["page_{$this->table->name}"]);
             $url->parameters["{$this->table->name}_action"] = 'F';
             $code .= "<script language='JavaScript'>\n\tfunction {$this->table->name}_Find() {\n\t\tdocument.form_{$this->table->name}.action = '" . $url->Get() . "';\n\t\tdocument.form_{$this->table->name}.submit();\n\t}\n</script>\n";
             if (empty($this->img_find)) {
                 $code .= "<input type='button' value='" . (empty($this->txt_find) ? $vortex_msgs['form_find'] : $this->txt_find) . "' onclick='{$this->table->name}_Find();' />\n";
             } else {
                 $code .= "<input type='image' src='{$this->img_find}' alt='" . (empty($this->txt_find) ? $vortex_msgs['form_find'] : $this->txt_find) . "' onclick='{$this->table->name}_Find();' />\n";
             }
         }
     }
     return $code;
 }