function getBlogContent($path) { $action = array_shift($path); if ($action == null) { $action = '1'; } switch ($action) { case "post": global $title; $postId = array_shift($path); if (isValidId($postId, "posts")) { $title = fetchPostTitle($postId) . " (Post)" . $title; return getPost($postId); } else { return get404(); } break; case "tags": global $currentTag; global $title; $currentTag = array_shift($path); if (isValidId($currentTag, "tags")) { $title = fetchTagName($currentTag) . " (Tag)" . $title; return getTag($currentTag); } else { return get404(); } break; default: global $title; $validNumber = preg_match("/^[0-9]+\$/", $action, $matches); if (!$validNumber) { return get404(); } if (getPageCount("posts") < $action) { return get404(); } $title = "Blog" . $title; if ($action == 1) { $content = '<h1>Blog</h1><p>A small collection of thoughts and progress notes I thought the would would possibly what to know about. I try to keep my updates sparse but informative but I can\'t hold that promise.</p>'; } else { $content = getPageLinks("You are viewing blog posts from a past time.<br>", $action, "/blog/", "posts"); } return $content . getRecentPosts($action - 1) . getPageLinks("Page Selection<br>", $action, "/blog/", "posts"); break; } }
if ($type == 1) { $titleType = "支出"; } else { if ($type == 2) { $titleType = "收入"; } else { $titleType = "收支"; } } // get account items and statistic summaries according to the statistic period $items; $pageCount; $itemCount = $ITEMS_EVERY_PAGE; if ($year == 0) { // whole period $pageCount = getPageCount(); $statisticByCat = getAllYearStatistic($type); $accountItems = getAccountItemByPage($pageNum, $itemCount); } else { if ($month == 0) { // whole year $timeStart = mktime(0, 0, 0, 1, 1, $year); $timeEnd = mktime(23, 59, 59, 12, 31, $year); } else { // whole month $timeStart = mktime(0, 0, 0, $month, 1, $year); $timeEnd = mktime(0, 0, 0, $month + 1, 1, $year); } $statisticByCat = getStatisticByTimePeriod($type, $timeStart, $timeEnd); $pageCount = getPageCountByTimePeriod($timeStart, $timeEnd); $accountItems = getAccountItemByTimePeriod($pageNum, $itemCount, $type, $categoryId, $timeStart, $timeEnd);
function getStatisticsSidebar($db) { $value = ""; $value .= "<h2>Statistics</h2>"; $value .= "<p>The Stacks project now consists of</p>"; $value .= "<ul>"; $value .= "<li>" . getLineCount($db, "total") . " lines of code"; $value .= "<li>" . getTagCount($db) . " tags (" . getInactiveTagCount($db) . " inactive tags)"; $value .= "<li>" . getSectionCount($db) . " sections"; $value .= "<li>" . getChapterCount($db) . " chapters"; $value .= "<li>" . getPageCount($db, "book") . " pages"; $value .= "<li>" . getActiveSloganCount($db) . " slogans"; // . " slogans (" . getSubmittedSloganCount($db) . " submitted)"; $value .= "</ul>"; return $value; }
public function getSidebar() { $value = ""; $value .= "<h2>Navigating chapters</h2>"; $value .= $this->printNavigation(false); $value .= "<h2>Downloads</h2>"; $value .= "<ul>"; $value .= "<li><a href='" . href("download/" . $this->chapter["filename"] . ".pdf") . "'><code>pdf</code> of this chapter</a>"; $value .= "<li><a href='https://github.com/stacks/stacks-project/blob/master/" . $this->chapter["filename"] . ".tex'><code>tex</code> file for this chapter</a>"; $value .= "</ul>"; $value .= "<h2>Permalink</h2>"; $value .= "<p>The number of chapters in the Stacks project is likely to change. So this URL is <em>not stable</em>.</p>"; $value .= "<p>To provide a truly stable link, use the <a href='" . href("tag/" . $this->chapter["tag"]) . "'>corresponding tag lookup page for tag " . $this->chapter["tag"] . "</a>. This identifier will never change.</p>"; $value .= "<p>When referring to this chapter of the Stacks project, it is better to say<blockquote>Tag " . $this->chapter["tag"] . "<br>Chapter " . $this->chapter["tag"] . "</blockquote> or refer to the full name of the chapter.</p>"; $value .= "<h2>Statistics</h2>"; $value .= "<ul>"; $value .= "<li>" . getLineCount($this->db, $this->chapter["filename"] . ".tex") . " lines of code</li>"; $value .= "<li>" . getTagsInFileCount($this->db, $this->chapter["filename"]) . " tags</li>"; $value .= "<li>" . (getSectionsInFileCount($this->db, $this->chapter["filename"]) - 1) . " sections</li>"; // -1 to take care of the phantom section $value .= "<li>" . getPageCount($this->db, $this->chapter["filename"]) . " pages</li>"; $value .= "</ul>"; return $value; }
$start = time(); $today = wfTimestamp(TS_MW); $monthAgo = wfTimestamp(TS_MW, $start - 60 * 60 * 24 * 30); // 30 days //drop last 6 digits off the end $today = substr($today, 0, 8); $monthAgo = substr($monthAgo, 0, 8); $res = $dbr->query('page', array('page_id'), array('page_namespace' => 0, 'page_is_redirect' => 0), __FILE__); $articles = array(); while ($row = $dbr->fetchRow($res)) { $articles[$row->page_id] = $row->page_id; } $dbr->freeResult($res); $dynamodb = new AmazonDynamoDB(); foreach ($articles as $articleId) { $articles[$articleId] = getPageCount($dynamodb, $articleId, $monthAgo, $today); $dbw->update('page', array('page_monthly' => $articles[$articleId]), array('page_id' => $articleId), __FILE__); } } elseif ($argv[0] == "insert") { $today = wfTimestamp(TS_MW); //is it actually today, or is it yesterday? //drop last 6 digits off the end $today = substr($today, 0, 8); $articles = array(); $queues = array(); //get the time $count = 0; $queueCount = 0; foreach ($articles as $articleId => $articleCount) { //is the difference in the time less than a second? //insertPageCount($dynamodb, $articleId, $today, $count);