Пример #1
0
 protected function generateContent()
 {
     /****************/
     /* Main Content */
     /****************/
     if (in_array(array_search($this->page, $this->validPages), [0, 1, 2, 3, 11, 12])) {
         $this->h1Links = '<small><a href="?' . $this->page . ($this->category ? '=' . $this->category[0] : null) . '&rss" class="icon-rss">' . Lang::main('subscribe') . '</a></small>';
     }
     switch ($this->page) {
         case 'random':
             $type = array_rand(array_filter(Util::$typeStrings));
             $typeId = (new Util::$typeClasses[$type](null))->getRandomId();
             header('Location: ?' . Util::$typeStrings[$type] . '=' . $typeId, true, 302);
             die;
         case 'latest-comments':
             $this->lvTabs[] = array('file' => 'commentpreview', 'data' => CommunityContent::getCommentPreviews(), 'params' => []);
             break;
         case 'latest-screenshots':
             $this->lvTabs[] = array('file' => 'screenshot', 'data' => [], 'params' => []);
             break;
         case 'latest-videos':
             $this->lvTabs[] = array('file' => 'video', 'data' => [], 'params' => []);
             break;
         case 'latest-articles':
             $this->lvTabs = [];
             break;
         case 'latest-additions':
             $extraText = '';
             break;
         case 'unrated-comments':
             $this->lvTabs[] = array('file' => 'commentpreview', 'data' => [], 'params' => []);
             break;
         case 'missing-screenshots':
             // limit to 200 entries each (it generates faster, consumes less memory and should be enough options)
             $cnd = [[['cuFlags', CUSTOM_HAS_SCREENSHOT, '&'], 0], 200];
             if (!User::isInGroup(U_GROUP_EMPLOYEE)) {
                 $cnd[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
             }
             foreach (Util::$typeClasses as $classStr) {
                 if (!$classStr) {
                     continue;
                 }
                 $typeObj = new $classStr($cnd);
                 if (!$typeObj->error) {
                     $this->extendGlobalData($typeObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED | GLOBALINFO_REWARDS));
                     $this->lvTabs[] = array('file' => $typeObj::$brickFile, 'data' => $typeObj->getListviewData(), 'params' => []);
                 }
             }
             break;
         case 'most-comments':
             if ($this->category && !in_array($this->category[0], [1, 7, 30])) {
                 header('Location: ?most-comments=1' . ($this->rss ? '&rss' : null), true, 302);
             }
             $this->lvTabs[] = array('file' => 'commentpreview', 'data' => [], 'params' => []);
             break;
     }
 }
Пример #2
0
 private function prepareContent()
 {
     if (!$this->loadCache()) {
         $this->addArticle();
         $this->generatePath();
         $this->generateTitle();
         $this->generateContent();
         $this->applyGlobals();
         $this->saveCache();
     }
     if (isset($this->type) && isset($this->typeId)) {
         $this->gPageInfo = array('type' => $this->type, 'typeId' => $this->typeId, 'name' => $this->name);
     }
     if (!empty($this->path)) {
         $this->pageTemplate['breadcrumb'] = $this->path;
     }
     if (!empty($this->filter)) {
         $this->pageTemplate['filter'] = empty($this->filter['query']) ? 0 : 1;
     }
     if (method_exists($this, 'postCache')) {
         // e.g. update dates for events and such
         $this->postCache();
     }
     if (!empty($this->hasComContent)) {
         $this->community = CommunityContent::getAll($this->type, $this->typeId, $jsGlobals);
         $this->extendGlobalData($jsGlobals);
         // as comments are not cached, those globals cant be either
         $this->applyGlobals();
     }
     $this->time = microtime(true) - $this->time;
     Util::arraySumByKey($this->mysql, DB::Aowow()->getStatistics(), DB::World()->getStatistics());
 }
Пример #3
0
 protected function generateContent()
 {
     /****************/
     /* Main Content */
     /****************/
     if (in_array(array_search($this->page, $this->validPages), [0, 1, 2, 3, 11, 12])) {
         $this->h1Links = '<small><a href="?' . $this->page . ($this->category ? '=' . $this->category[0] : null) . '&rss" class="icon-rss">' . Lang::main('subscribe') . '</a></small>';
     }
     switch ($this->page) {
         case 'random':
             $type = array_rand(array_filter(Util::$typeClasses));
             $typeId = (new Util::$typeClasses[$type](null))->getRandomId();
             header('Location: ?' . Util::$typeStrings[$type] . '=' . $typeId, true, 302);
             die;
         case 'latest-comments':
             // rss
             $data = CommunityContent::getCommentPreviews();
             if ($this->rss) {
                 foreach ($data as $d) {
                     // todo (low): preview should be html-formated
                     $this->feedData[] = array('title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])) . Lang::main('colon') . htmlentities($d['subject'])], 'link' => [false, [], HOST_URL . '/?go-to-comment&amp;id=' . $d['id']], 'description' => [true, [], htmlentities($d['preview']) . "<br /><br />" . sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true))], 'pubDate' => [false, [], date(DATE_RSS, time() - $d['elapsed'])], 'guid' => [false, [], HOST_URL . '/?go-to-comment&amp;id=' . $d['id']]);
                 }
             } else {
                 $this->lvTabs[] = ['commentpreview', ['data' => $data]];
             }
             break;
         case 'latest-screenshots':
             // rss
             $data = CommunityContent::getScreenshots();
             if ($this->rss) {
                 foreach ($data as $d) {
                     $desc = '<a href="' . HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#screenshots:id=' . $d['id'] . '"><img src="' . STATIC_URL . '/uploads/screenshots/thumb/' . $d['id'] . '.jpg" alt="" /></a>';
                     if ($d['caption']) {
                         $desc .= '<br />' . $d['caption'];
                     }
                     $desc .= "<br /><br />" . sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true));
                     // enclosure/length => filesize('static/uploads/screenshots/thumb/'.$d['id'].'.jpg') .. always set to this placeholder value though
                     $this->feedData[] = array('title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])) . Lang::main('colon') . htmlentities($d['subject'])], 'link' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#screenshots:id=' . $d['id']], 'description' => [true, [], $desc], 'pubDate' => [false, [], date(DATE_RSS, time() - $d['elapsed'])], 'enclosure' => [false, ['url' => STATIC_URL . '/uploads/screenshots/thumb/' . $d['id'] . '.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null], 'guid' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#screenshots:id=' . $d['id']]);
                 }
             } else {
                 $this->lvTabs[] = ['screenshot', ['data' => $data]];
             }
             break;
         case 'latest-videos':
             // rss
             $data = CommunityContent::getVideos();
             if ($this->rss) {
                 foreach ($data as $d) {
                     $desc = '<a href="' . HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#videos:id=' . $d['id'] . '"><img src="//i3.ytimg.com/vi/' . $d['videoId'] . '/default.jpg" alt="" /></a>';
                     if ($d['caption']) {
                         $desc .= '<br />' . $d['caption'];
                     }
                     $desc .= "<br /><br />" . sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true));
                     // is enclosure/length .. is this even relevant..?
                     $this->feedData[] = array('title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])) . Lang::main('colon') . htmlentities($row['subject'])], 'link' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#videos:id=' . $d['id']], 'description' => [true, [], $desc], 'pubDate' => [false, [], date(DATE_RSS, time() - $row['elapsed'])], 'enclosure' => [false, ['url' => '//i3.ytimg.com/vi/' . $d['videoId'] . '/default.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null], 'guid' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#videos:id=' . $d['id']]);
                 }
             } else {
                 $this->lvTabs[] = ['video', ['data' => $data]];
             }
             break;
         case 'latest-articles':
             // rss
             $this->lvTabs = [];
             break;
         case 'latest-additions':
             // rss
             $extraText = '';
             break;
         case 'unrated-comments':
             $this->lvTabs[] = ['commentpreview', ['data' => []]];
             break;
         case 'missing-screenshots':
             // limit to 200 entries each (it generates faster, consumes less memory and should be enough options)
             $cnd = [[['cuFlags', CUSTOM_HAS_SCREENSHOT, '&'], 0], 200];
             if (!User::isInGroup(U_GROUP_EMPLOYEE)) {
                 $cnd[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
             }
             foreach (Util::$typeClasses as $classStr) {
                 if (!$classStr) {
                     continue;
                 }
                 $typeObj = new $classStr($cnd);
                 if (!$typeObj->error) {
                     $this->extendGlobalData($typeObj->getJSGlobals(GLOBALINFO_ANY));
                     $this->lvTabs[] = [$typeObj::$brickFile, ['data' => array_values($typeObj->getListviewData())]];
                 }
             }
             break;
         case 'most-comments':
             // rss
             if ($this->category && !in_array($this->category[0], [1, 7, 30])) {
                 header('Location: ?most-comments=1' . ($this->rss ? '&rss' : null), true, 302);
             }
             $tabBase = array('extraCols' => ["\$Listview.funcBox.createSimpleCol('ncomments', 'tab_comments', '10%', 'ncomments')"], 'sort' => ['-ncomments']);
             foreach (Util::$typeClasses as $type => $classStr) {
                 if (!$classStr) {
                     continue;
                 }
                 $comments = DB::Aowow()->selectCol('
                     SELECT   `typeId` AS ARRAY_KEY, count(1) FROM ?_comments
                     WHERE    `replyTo` = 0 AND (`flags` & ?d) = 0 AND `type`= ?d AND `date` > (UNIX_TIMESTAMP() - ?d)
                     GROUP BY `type`, `typeId`
                     LIMIT    100', CC_FLAG_DELETED, $type, (isset($this->category[0]) ? $this->category[0] : 1) * DAY);
                 if (!$comments) {
                     continue;
                 }
                 $typeClass = new $classStr(array(['id', array_keys($comments)]));
                 if (!$typeClass->error) {
                     $data = $typeClass->getListviewData();
                     if ($this->rss) {
                         foreach ($data as $typeId => &$d) {
                             $this->feedData[] = array('title' => [true, [], htmlentities(Util::$typeStrings[$type] == 'item' ? mb_substr($d['name'], 1) : $d['name'])], 'type' => [false, [], Util::$typeStrings[$type]], 'link' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$type] . '=' . $d['id']], 'ncomments' => [false, [], $comments[$typeId]]);
                         }
                     } else {
                         foreach ($data as $typeId => &$d) {
                             $d['ncomments'] = $comments[$typeId];
                         }
                         $this->extendGlobalData($typeClass->getJSGlobals(GLOBALINFO_ANY));
                         $this->lvTabs[] = [$typeClass::$brickFile, array_merge($tabBase, ['data' => array_values($data)])];
                     }
                 }
             }
             break;
     }
     // found nothing => set empty content
     // tpl: commentpreview - anything, doesn't matter what
     if (!$this->lvTabs && !$this->rss) {
         $this->lvTabs[] = ['commentpreview', ['data' => []]];
     }
 }
Пример #4
0
 protected function handleReplyEdit()
 {
     if (!User::canComment()) {
         return 'You are not allowed to reply.';
     } else {
         if (!$this->_post['replyId'] || !$this->_post['commentId']) {
             return Lang::main('genericError');
         } else {
             if (!$this->_post['body'] || mb_strlen($this->_post['body']) < self::REPLY_LENGTH_MIN || mb_strlen($this->_post['body']) > self::REPLY_LENGTH_MAX) {
                 return 'Your reply has ' . mb_strlen($this->_post['body']) . ' characters and must have at least ' . self::REPLY_LENGTH_MIN . ' and at most ' . self::REPLY_LENGTH_MAX . '.';
             }
         }
     }
     if (DB::Aowow()->query('UPDATE ?_comments SET body = ?, editUserId = ?d, editDate = UNIX_TIMESTAMP(), editCount = editCount + 1 WHERE id = ?d AND replyTo = ?d{ AND userId = ?d}', $this->_post['body'], User::$id, $this->_post['replyId'], $this->_post['commentId'], User::isInGroup(U_GROUP_MODERATOR) ? DBSIMPLE_SKIP : User::$id)) {
         return Util::toJSON(CommunityContent::getCommentReplies($this->_post['commentId']));
     } else {
         return Lang::main('genericError');
     }
 }
Пример #5
0
 private function handleScreenshots()
 {
     $this->addJS('screenshot.js');
     $this->addCSS(array(['string' => '.layout {margin: 0px 25px; max-width: inherit; min-width: 1200px; }'], ['string' => '#highlightedRow { background-color: #322C1C; }']));
     $ssGetAll = isset($_GET['all']) && empty($_GET['all']);
     $ssPages = [];
     $ssData = [];
     $nMatches = 0;
     if (!empty($_GET['type']) && !empty($_GET['typeid'])) {
         $ssData = CommunityContent::getScreenshotsForManager(intVal($_GET['type']), intVal($_GET['typeid']));
         $nMatches = count($ssData);
     } else {
         if (!empty($_GET['user'])) {
             $name = urldecode($_GET['user']);
             if (mb_strlen($name) >= 3) {
                 if ($uId = DB::Aowow()->selectCell('SELECT id FROM ?_account WHERE displayName = ?', ucFirst($name))) {
                     $ssData = CommunityContent::getScreenshotsForManager(0, 0, $uId);
                     $nMatches = count($ssData);
                 }
             }
         } else {
             $ssPages = CommunityContent::getScreenshotPagesForManager($ssGetAll, $nMatches);
         }
     }
     $this->getAll = $ssGetAll;
     $this->ssPages = $ssPages;
     $this->ssData = $ssData;
     $this->ssNFound = $nMatches;
     // ssm_numPagesFound
 }
Пример #6
0
 protected function generateContent()
 {
     /***********/
     /* Infobox */
     /***********/
     $infobox = $contrib = $groups = [];
     foreach (Lang::account('groups') as $idx => $key) {
         if ($idx >= 0 && $this->user['userGroups'] & 1 << $idx) {
             $groups[] = (!fMod(count($groups) + 1, 3) ? '[br]' : null) . Lang::account('groups', $idx);
         }
     }
     $infobox[] = Lang::user('joinDate') . Lang::main('colon') . '[tooltip name=joinDate]' . date('l, G:i:s', $this->user['joinDate']) . '[/tooltip][span class=tip tooltip=joinDate]' . date(Lang::main('dateFmtShort'), $this->user['joinDate']) . '[/span]';
     $infobox[] = Lang::user('lastLogin') . Lang::main('colon') . '[tooltip name=lastLogin]' . date('l, G:i:s', $this->user['prevLogin']) . '[/tooltip][span class=tip tooltip=lastLogin]' . date(Lang::main('dateFmtShort'), $this->user['prevLogin']) . '[/span]';
     $infobox[] = Lang::user('userGroups') . Lang::main('colon') . ($groups ? implode(', ', $groups) : Lang::account('groups', -1));
     $infobox[] = Lang::user('consecVisits') . Lang::main('colon') . $this->user['consecutiveVisits'];
     $infobox[] = Util::ucFirst(Lang::main('siteRep')) . Lang::main('colon') . Lang::nf($this->user['sumRep']);
     // contrib -> [url=http://www.wowhead.com/client]Data uploads: n [small]([tooltip=tooltip_totaldatauploads]xx.y MB[/tooltip])[/small][/url]
     $co = DB::Aowow()->selectRow('SELECT COUNT(DISTINCT c.id) AS sum, SUM(IFNULL(cr.value, 0)) AS nRates FROM ?_comments c LEFT JOIN ?_comments_rates cr ON cr.commentId = c.id AND cr.userId <> 0 WHERE c.replyTo = 0 AND c.userId = ?d', $this->user['id']);
     if ($co['sum']) {
         $contrib[] = Lang::user('comments') . Lang::main('colon') . $co['sum'] . ($co['nRates'] ? ' [small]([tooltip=tooltip_totalratings]' . $co['nRates'] . '[/tooltip])[/small]' : null);
     }
     $ss = DB::Aowow()->selectRow('SELECT COUNT(*) AS sum, SUM(IF(status & ?d, 1, 0)) AS nSticky, SUM(IF(status & ?d, 0, 1)) AS nPending FROM ?_screenshots WHERE userIdOwner = ?d AND (status & ?d) = 0', CC_FLAG_STICKY, CC_FLAG_APPROVED, $this->user['id'], CC_FLAG_DELETED);
     if ($ss['sum']) {
         $buff = [];
         if ($ss['nSticky'] || $ss['nPending']) {
             if ($normal = $ss['sum'] - $ss['nSticky'] - $ss['nPending']) {
                 $buff[] = '[tooltip=tooltip_normal]' . $normal . '[/tooltip]';
             }
             if ($ss['nSticky']) {
                 $buff[] = '[tooltip=tooltip_sticky]' . $ss['nSticky'] . '[/tooltip]';
             }
             if ($ss['nPending']) {
                 $buff[] = '[tooltip=tooltip_pending]' . $ss['nPending'] . '[/tooltip]';
             }
         }
         $contrib[] = Lang::user('screenshots') . Lang::main('colon') . $ss['sum'] . ($buff ? ' [small](' . implode($buff, ' + ') . ')[/small]' : null);
     }
     $vi = DB::Aowow()->selectRow('SELECT COUNT(id) AS sum, SUM(IF(status & ?d, 1, 0)) AS nSticky, SUM(IF(status & ?d, 0, 1)) AS nPending FROM ?_videos WHERE userIdOwner = ?d AND (status & ?d) = 0', CC_FLAG_STICKY, CC_FLAG_APPROVED, $this->user['id'], CC_FLAG_DELETED);
     if ($vi['sum']) {
         $buff = [];
         if ($vi['nSticky'] || $vi['nPending']) {
             if ($normal = $vi['sum'] - $vi['nSticky'] - $vi['nPending']) {
                 $buff[] = '[tooltip=tooltip_normal]' . $normal . '[/tooltip]';
             }
             if ($vi['nSticky']) {
                 $buff[] = '[tooltip=tooltip_sticky]' . $vi['nSticky'] . '[/tooltip]';
             }
             if ($vi['nPending']) {
                 $buff[] = '[tooltip=tooltip_pending]' . $vi['nPending'] . '[/tooltip]';
             }
         }
         $contrib[] = Lang::user('videos') . Lang::main('colon') . $vi['sum'] . ($buff ? ' [small](' . implode($buff, ' + ') . ')[/small]' : null);
     }
     // contrib -> Forum posts: 5769 [small]([tooltip=topics]579[/tooltip] + [tooltip=replies]5190[/tooltip])[/small]
     $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]';
     if ($contrib) {
         $this->contributions = '[ul][li]' . implode('[/li][li]', $contrib) . '[/li][/ul]';
     }
     /****************/
     /* Main Content */
     /****************/
     $this->name = $this->user['title'] ? $this->user['displayName'] . '&nbsp;&lt;' . $this->user['title'] . '&gt;' : sprintf(Lang::user('profileTitle'), $this->user['displayName']);
     /**************/
     /* Extra Tabs */
     /**************/
     $this->lvTabs = [];
     $this->forceTabs = true;
     // [unused] Site Achievements
     // Reputation changelog (params only for comment-events)
     if ($repData = DB::Aowow()->select('SELECT action, amount, date AS \'when\', IF(action IN (3, 4, 5), sourceA, 0) AS param FROM ?_account_reputation WHERE userId = ?d', $this->user['id'])) {
         foreach ($repData as &$r) {
             $r['when'] = date(Util::$dateFormatInternal, $r['when']);
         }
         $this->lvTabs[] = ['reputationhistory', ['data' => $repData]];
     }
     // Comments
     if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => false], $nFound)) {
         $tabData = array('data' => $_, 'hiddenCols' => ['author'], 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', '_totalCount' => $nFound);
         if ($nFound > CFG_SQL_LIMIT_DEFAULT) {
             $tabData['name'] = '$LANG.tab_latestcomments';
             $tabData['note'] = '$$WH.sprintf(LANG.lvnote_usercomments, ' . $nFound . ')';
         }
         $this->lvTabs[] = ['commentpreview', $tabData];
     }
     // Comment Replies
     if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => true], $nFound)) {
         $tabData = array('data' => $_, 'hiddenCols' => ['author'], 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', '_totalCount' => $nFound);
         if ($nFound > CFG_SQL_LIMIT_DEFAULT) {
             $tabData['name'] = '$LANG.tab_latestreplies';
             $tabData['note'] = '$$WH.sprintf(LANG.lvnote_userreplies, ' . $nFound . ')';
         }
         $this->lvTabs[] = ['replypreview', $tabData];
     }
     // Screenshots
     if ($_ = CommunityContent::getScreenshots(-$this->user['id'], 0, $nFound)) {
         $tabData = array('data' => $_, '_totalCount' => $nFound);
         if ($nFound > CFG_SQL_LIMIT_DEFAULT) {
             $tabData['name'] = '$LANG.tab_latestscreenshots';
             $tabData['note'] = '$$WH.sprintf(LANG.lvnote_userscreenshots, ' . $nFound . ')';
         }
         $this->lvTabs[] = ['screenshot', $tabData];
     }
     // Videos
     if ($_ = CommunityContent::getVideos(-$this->user['id'], 0, $nFound)) {
         $tabData = array('data' => $_, '_totalCount' => $nFound);
         if ($nFound > CFG_SQL_LIMIT_DEFAULT) {
             $tabData['name'] = '$LANG.tab_latestvideos';
             $tabData['note'] = '$$WH.sprintf(LANG.lvnote_uservideos, ' . $nFound . ')';
         }
         $this->lvTabs[] = ['video', $tabData];
     }
     // forum -> latest topics  [unused]
     // forum -> latest replies [unused]
     // Characters [todo]
     $this->user['characterData'] = [];
     /*
         us_addCharactersTab([
             {
                 id:763,
                 "name":"Lilywhite",
                 "achievementpoints":"0",
                 "guild":"whatever",
                 "guildrank":"0",
                 "realm":"draenor",
                 "realmname":"Draenor",
                 "battlegroup":"cyclone",
                 "battlegroupname":"Cyclone",
                 "region":"us",
                 "level":"10",
                 "race":"7",
                 "gender":"0",
                 "classs":"1",
                 "faction":"0",
                 "gearscore":"0",
                 "talenttree1":"0",
                 "talenttree2":"0",
                 "talenttree3":"0",
                 "talentspec":0,
                 "published":1,
                 "pinned":0
             }
         ]);
     */
     // Profiles [todo]
     $this->user['profileData'] = [];
 }
Пример #7
0
 protected function ssManage()
 {
     $res = [];
     if ($this->_get['type'] && $this->_get['type'] && $this->_get['typeid'] && $this->_get['typeid']) {
         $res = CommunityContent::getScreenshotsForManager($this->_get['type'], $this->_get['typeid']);
     } else {
         if ($this->_get['user']) {
             if ($uId = DB::Aowow()->selectCell('SELECT id FROM ?_account WHERE displayName = ?', $this->_get['user'])) {
                 $res = CommunityContent::getScreenshotsForManager(0, 0, $uId);
             }
         }
     }
     return 'ssm_screenshotData = ' . Util::toJSON($res);
 }
Пример #8
0
 private function createDashboard()
 {
     if (!User::$id) {
         $this->forwardToSignIn('account');
     }
     $user = DB::Aowow()->selectRow('SELECT * FROM ?_account WHERE id = ?d', User::$id);
     $bans = DB::Aowow()->select('SELECT ab.*, a.displayName, ab.id AS ARRAY_KEY FROM ?_account_banned ab LEFT JOIN ?_account a ON a.id = ab.staffId WHERE ab.userId = ?d', User::$id);
     /***********/
     /* Infobox */
     /***********/
     $infobox = [];
     $infobox[] = Lang::user('joinDate') . Lang::main('colon') . '[tooltip name=joinDate]' . date('l, G:i:s', $user['joinDate']) . '[/tooltip][span class=tip tooltip=joinDate]' . date(Lang::main('dateFmtShort'), $user['joinDate']) . '[/span]';
     $infobox[] = Lang::user('lastLogin') . Lang::main('colon') . '[tooltip name=lastLogin]' . date('l, G:i:s', $user['prevLogin']) . '[/tooltip][span class=tip tooltip=lastLogin]' . date(Lang::main('dateFmtShort'), $user['prevLogin']) . '[/span]';
     $infobox[] = Lang::account('lastIP') . Lang::main('colon') . $user['prevIP'];
     $infobox[] = Lang::account('email') . Lang::main('colon') . $user['email'];
     $groups = [];
     foreach (Lang::account('groups') as $idx => $key) {
         if ($idx >= 0 && $user['userGroups'] & 1 << $idx) {
             $groups[] = (!fMod(count($groups) + 1, 3) ? '[br]' : null) . Lang::account('groups', $idx);
         }
     }
     $infobox[] = Lang::user('userGroups') . Lang::main('colon') . ($groups ? implode(', ', $groups) : Lang::account('groups', -1));
     $infobox[] = Util::ucFirst(Lang::main('siteRep')) . Lang::main('colon') . User::getReputation();
     $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]';
     /*************/
     /* Ban Popup */
     /*************/
     foreach ($bans as $b) {
         if (!($b['typeMask'] & (ACC_BAN_TEMP | ACC_BAN_PERM)) || $b['end'] && $b['end'] <= time()) {
             continue;
         }
         $this->banned = array('by' => [$b['staffId'], $b['displayName']], 'end' => $b['end'], 'reason' => $b['reason']);
         break;
         // one is enough
     }
     /************/
     /* Listview */
     /************/
     $this->forceTabs = true;
     // Reputation changelog (params only for comment-events)
     if ($repData = DB::Aowow()->select('SELECT action, amount, date AS \'when\', IF(action IN (3, 4, 5), sourceA, 0) AS param FROM ?_account_reputation WHERE userId = ?d', User::$id)) {
         foreach ($repData as &$r) {
             $r['when'] = date(Util::$dateFormatInternal, $r['when']);
         }
         $this->lvTabs[] = ['reputationhistory', ['data' => $repData]];
     }
     // comments
     if ($_ = CommunityContent::getCommentPreviews(['user' => User::$id, 'replies' => false])) {
         // needs foundCount for params
         // _totalCount: 377,
         // note: $WH.sprintf(LANG.lvnote_usercomments, 377),
         $this->lvTabs[] = ['commentpreview', array('data' => $_, 'hiddenCols' => ['author'], 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments')];
     }
     // replies
     if ($_ = CommunityContent::getCommentPreviews(['user' => User::$id, 'replies' => true])) {
         // needs commentid (parentComment) for data
         // needs foundCount for params
         // _totalCount: 377,
         // note: $WH.sprintf(LANG.lvnote_usercomments, 377),
         $this->lvTabs[] = ['replypreview', array('data' => $_, 'hiddenCols' => ['author'])];
     }
     /*
     <div id="description" class="left"><div id="description-generic"></div>
     <script type="text/javascript">//<![CDATA[
     Markup.printHtml("description text here", "description-generic", { allow: Markup.CLASS_PREMIUM, roles: "256" });
     //]]></script>
     </div>
     <script type="text/javascript">us_addDescription()</script>
     */
     // claimed characters
     // profiles
     // own screenshots
     // own videos
     // own comments (preview)
     // articles guides..?
     // cpmsg    change pass messaeg class:failure|success, msg:blabla
 }
Пример #9
0
 private function admin_handleSSManage()
 {
     $res = [];
     if ($this->get('type') && intVal($this->get('type')) && $this->get('typeid') && intVal($this->get('typeid'))) {
         $res = CommunityContent::getScreenshotsForManager($this->get('type'), $this->get('typeid'));
     } else {
         if ($this->get('user') && strlen(urldecode($this->get('user'))) > 2) {
             if ($uId = DB::Aowow()->selectCell('SELECT id FROM ?_account WHERE displayName = ?', strtolower(urldecode($this->get('user'))))) {
                 $res = CommunityContent::getScreenshotsForManager(0, 0, $uId);
             }
         }
     }
     return 'ssm_screenshotData = ' . json_encode($res, JSON_NUMERIC_CHECK);
 }
Пример #10
0
 protected function generateContent()
 {
     /***********/
     /* Infobox */
     /***********/
     $infobox = $contrib = $groups = [];
     foreach (Lang::account('groups') as $idx => $key) {
         if ($idx >= 0 && $this->user['userGroups'] & 1 << $idx) {
             $groups[] = (!fMod(count($groups) + 1, 3) ? '[br]' : null) . Lang::account('groups', $idx);
         }
     }
     $infobox[] = Lang::user('joinDate') . Lang::main('colon') . '[tooltip name=joinDate]' . date('l, G:i:s', $this->user['joinDate']) . '[/tooltip][span class=tip tooltip=joinDate]' . date(Lang::main('dateFmtShort'), $this->user['joinDate']) . '[/span]';
     $infobox[] = Lang::user('lastLogin') . Lang::main('colon') . '[tooltip name=lastLogin]' . date('l, G:i:s', $this->user['prevLogin']) . '[/tooltip][span class=tip tooltip=lastLogin]' . date(Lang::main('dateFmtShort'), $this->user['prevLogin']) . '[/span]';
     $infobox[] = Lang::user('userGroups') . Lang::main('colon') . ($groups ? implode(', ', $groups) : Lang::account('groups', -1));
     $infobox[] = Lang::user('consecVisits') . Lang::main('colon') . $this->user['consecutiveVisits'];
     $infobox[] = Util::ucFirst(Lang::main('siteRep')) . Lang::main('colon') . number_format($this->user['sumRep']);
     // contrib -> [url=http://www.wowhead.com/client]Data uploads: n [small]([tooltip=tooltip_totaldatauploads]xx.y MB[/tooltip])[/small][/url]
     $co = DB::Aowow()->selectRow('SELECT COUNT(DISTINCT c.id) AS sum, COUNT(cr.commentId) AS nRates FROM ?_comments c LEFT JOIN ?_comments_rates cr ON cr.commentId = c.id WHERE c.replyTo = 0 AND c.userId = ?d', $this->user['id']);
     if ($co['sum']) {
         $contrib[] = Lang::user('comments') . Lang::main('colon') . $co['sum'] . ' [small]([tooltip=tooltip_totalratings]' . $co['nRates'] . '[/tooltip])[/small]';
     }
     $ss = DB::Aowow()->selectRow('SELECT COUNT(id) AS sum, SUM(IF(status & ?d, 1, 0)) as nSticky FROM ?_screenshots WHERE userIdOwner = ?d AND status & ?d AND (status & ?d) = 0', CC_FLAG_STICKY, $this->user['id'], CC_FLAG_APPROVED, CC_FLAG_DELETED);
     if ($ss['sum']) {
         $contrib[] = Lang::user('screenshots') . Lang::main('colon') . $ss['sum'] . ' [small]([tooltip=tooltip_normal]' . ($ss['sum'] - $ss['nSticky']) . '[/tooltip] + [tooltip=tooltip_sticky]' . $ss['nSticky'] . '[/tooltip])[/small]';
     }
     $vi = DB::Aowow()->selectRow('SELECT COUNT(id) AS sum, SUM(IF(status & ?d, 1, 0)) as nSticky FROM ?_videos WHERE userIdOwner = ?d AND status & ?d AND (status & ?d) = 0', CC_FLAG_STICKY, $this->user['id'], CC_FLAG_APPROVED, CC_FLAG_DELETED);
     if ($vi['sum']) {
         $contrib[] = Lang::user('videos') . Lang::main('colon') . $vi['sum'] . ' [small]([tooltip=tooltip_normal]' . ($vi['sum'] - $vi['nSticky']) . '[/tooltip] + [tooltip=tooltip_sticky]' . $vi['nSticky'] . '[/tooltip])[/small]';
     }
     // contrib -> Forum posts: 5769 [small]([tooltip=topics]579[/tooltip] + [tooltip=replies]5190[/tooltip])[/small]
     $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]';
     if ($contrib) {
         $this->contributions = '[ul][li]' . implode('[/li][li]', $contrib) . '[/li][/ul]';
     }
     /****************/
     /* Main Content */
     /****************/
     $this->name = $this->user['title'] ? $this->user['displayName'] . '&nbsp;&lt;' . $this->user['title'] . '&gt;' : sprintf(Lang::user('profileTitle'), $this->user['displayName']);
     /**************/
     /* Extra Tabs */
     /**************/
     $this->lvTabs = [];
     $this->forceTabs = true;
     // [unused] Site Achievements
     // Reputation changelog (params only for comment-events)
     if ($repData = DB::Aowow()->select('SELECT action, amount, date AS \'when\', IF(action IN (3, 4, 5), sourceA, 0) AS param FROM ?_account_reputation WHERE userId = ?d', $this->user['id'])) {
         foreach ($repData as &$r) {
             $r['when'] = date(Util::$dateFormatInternal, $r['when']);
         }
         $this->lvTabs[] = array('file' => 'reputationhistory', 'data' => $repData, 'params' => []);
     }
     // Comments
     if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => false], $nFound)) {
         $lvData = array('file' => 'commentpreview', 'data' => $_, 'params' => array('hiddenCols' => "\$['author']", 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', '_totalCount' => $nFound));
         if ($nFound > CFG_SQL_LIMIT_DEFAULT) {
             $lvData['params']['name'] = '$LANG.tab_latestcomments';
             $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_usercomments, ' . $nFound . ')';
         }
         $this->lvTabs[] = $lvData;
     }
     // Comment Replies
     if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => true], $nFound)) {
         $lvData = array('file' => 'replypreview', 'data' => $_, 'params' => array('hiddenCols' => "\$['author']", 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', '_totalCount' => $nFound));
         if ($nFound > CFG_SQL_LIMIT_DEFAULT) {
             $lvData['params']['name'] = '$LANG.tab_latestreplies';
             $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_userreplies, ' . $nFound . ')';
         }
         $this->lvTabs[] = $lvData;
     }
     // Screenshots
     if ($_ = CommunityContent::getScreenshots(-$this->user['id'], 0, $nFound)) {
         $lvData = array('file' => 'screenshot', 'data' => $_, 'params' => array('_totalCount' => $nFound));
         if ($nFound > CFG_SQL_LIMIT_DEFAULT) {
             $lvData['params']['name'] = '$LANG.tab_latestscreenshots';
             $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_userscreenshots, ' . $nFound . ')';
         }
         $this->lvTabs[] = $lvData;
     }
     // Videos
     if ($_ = CommunityContent::getVideos(-$this->user['id'], 0, $nFound)) {
         $lvData = array('file' => 'video', 'data' => $_, 'params' => array('_totalCount' => $nFound));
         if ($nFound > CFG_SQL_LIMIT_DEFAULT) {
             $lvData['params']['name'] = '$LANG.tab_latestvideos';
             $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_uservideos, ' . $nFound . ')';
         }
         $this->lvTabs[] = $lvData;
     }
     // forum -> latest topics  [unused]
     // forum -> latest replies [unused]
     // Characters [todo]
     $this->user['characterData'] = [];
     // Profiles [todo]
     $this->user['profileData'] = [];
 }