function authenticate($users = null) { if (!isset($_SERVER['PHP_AUTH_DIGEST']) || empty($_SERVER['PHP_AUTH_DIGEST'])) { return false; } # users if ($users === null) { $users = $this->users ? $this->users : array(); } # analyze if (!($data = self::parse($_SERVER['PHP_AUTH_DIGEST']))) { gb::log('GBHTTPDigestAuth: failed to parse ' . var_export($_SERVER['PHP_AUTH_DIGEST'], 1)); return false; } elseif (!isset($users[$data['username']])) { gb::log('GBHTTPDigestAuth: unknown username ' . var_export($data['username'], 1)); return false; } # check input if ($this->ttl > 0 && $data['nonce'] !== $this->nonce()) { return false; } # generate the valid response $A1 = $users[$data['username']]; # MD5(username:realm:password) $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']); # MD5(method:digestURI) $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2); if ($data['response'] != $valid_response) { gb::log('GBHTTPDigestAuth: unexpected response ' . var_export($data['response'], 1)); return false; } return $data['username']; }
static function init($context) { self::$conf = gb::data('plugins/google-analytics', array('property_id' => '')); if (!self::$conf['property_id']) { gb::log(LOG_WARNING, 'missing property_id in google-analytics configuration'); } else { gb::observe('on-html-footer', array(__CLASS__, 'echo_tracking_code')); return true; } return false; }
static function init($context) { if ($context === 'rebuild') { gb::observe('did-parse-object-meta', array(__CLASS__, 'check_content')); gb_cfilter::add('body.html', array(__CLASS__, 'escape_php'), 0); gb_cfilter::add('body.html', array(__CLASS__, 'unescape_php'), 9000); return true; } elseif ($context === 'request') { gb::add_filter('post-body', array(__CLASS__, 'eval_body')); return true; } }
static function will_handle_req() { if (!gb::$is_feed) { return; } $allowed_ips = self::$conf['allowed_ips']; if (!$allowed_ips) { $allowed_ips = array(); } elseif (!is_array($allowed_ips)) { $allowed_ips = array($allowed_ips); } $isfb = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'FeedBurner/') !== false; if ($isfb === false and in_array($_SERVER['REMOTE_ADDR'], $allowed_ips) === false and !isset($_GET['original-feed'])) { # we send an atom feed as response for clients which do not follow redirects $site_title = h(gb::$site_title); $curr_url = h(gb::url()->__toString()); $site_url = h(gb::$site_url); $url = h(self::$conf['url']); $mdate = @filemtime(self::$conf->storage()->file); $mdate = date('c', $mdate ? $mdate : time()); $s = <<<XML <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en" xml:base="{$site_url}"> \t<id>{$curr_url}</id> \t<title>{$site_title}</title> \t<link rel="alternate" type="application/atom+xml" href="{$url}" /> \t<link rel="alternate" type="text/html" href="{$site_url}" /> \t<updated>{$mdate}</updated> \t<entry> \t\t<title type="html">This feed has moved</title> \t\t<link rel="alternate" type="application/atom+xml" href="{$url}" /> \t\t<id>{$url}</id> \t\t<published>{$mdate}</published> \t\t<updated>{$mdate}</updated> \t\t<content type="html"><![CDATA[ \t\t\t<p>This feed has moved to <a href="{$url}">{$url}</a>.</p> \t\t\t<p>You see this because your feed client does not support automatic redirection.</p> \t\t]]></content> \t</entry> </feed> XML; header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . self::$conf['url']); header('Content-Length: ' . strlen($s)); header('Content-Type: application/atom+xml; charset=utf-8'); exit($s); } }
<?php require_once '../_base.php'; gb::authenticate(); gb::$title[] = 'Settings'; include '../_header.php'; ?> <script type="text/javascript" charset="utf-8">//<![CDATA[ var settings = gb.data('admin', <?php echo gb::data('admin')->toJSON(); ?> ); var activeRequestCount = 0; var throbber = null; settings.onRequestStart = function(xhr) { throbber.push(); } settings.onRequestComplete = function(xhr, textStatus) { throbber.pop(); console.log(xhr.responseText); } settings.onData = function(delta) { console.log('settings updated =>', this.data); } settings.onSet = function(pairs) { // don't set stuff we believe is already set var p = pairs; for (var k in p) if (this.get(k) == p[k]) delete pairs[k]; // check custom "composing/default_mime_type" var default_mime_type = pairs["composing/default_mime_type"]; if (typeof default_mime_type != 'undefined' && !default_mime_type.match(/[a-zA-Z0-9\.-]+/)) { $('#custom_default_mime_type').select();
} header('HTTP/1.1 303 See Other'); header('Location: ' . $referrer); exit(0); } else { exit2("new comment: {$comment->id}\n", '200 OK'); } } catch (Exception $e) { if ($e instanceof GitError && strpos($e->getMessage(), 'nothing to commit') !== false) { gb::log('skipped duplicate comment from ' . var_export($comment->email, 1) . ' (nothing to commit)'); gb::event('was-duplicate-comment', $comment); header('HTTP/1.1 304 Not Modified'); header('Location: ' . $input['gb-referrer'] . '#skipped-duplicate-reply'); exit(0); } gb::log(LOG_ERR, 'failed to add comment ' . var_export($comment->body, 1) . ' from ' . var_export($comment->name, 1) . ' <' . var_export($comment->email, 1) . '>' . ' to ' . $post->cachename()); header('HTTP/1.1 500 Internal Server Error'); echo '$input => '; var_export($input); echo "\n"; gb_flush(); throw $e; } } else { # rejected by filter(s) if ($referrer) { $referrer->fragment = 'comments'; $referrer['comment-status'] = 'rejected'; header('HTTP/1.1 303 See Other'); header('Location: ' . $referrer); } else {
<?php require_once '../_base.php'; gb::authenticate(); gb::$title[] = 'Repository status'; include '../_header.php'; $st = git::status(); ?> <div id="content" class="<?php echo gb_admin::$current_domid; ?> margins git-status"> <h2>Status</h2> <p class="repo-state"> On branch <span class="git-branch"><?php echo h($st['branch']); ?> </span> <?php if (isset($st['upstream'])) { ?> ← ahead of <span class="git-branch"><?php echo h($st['upstream']['name']); ?> </span> by <?php echo $st['upstream']['distance']; ?> commits. <?php }
foreach ($state_fields as $k => $discard) { if ($k === 'body') { $modified_state[$k] = $post->rawBody(); } else { $v = $post->{$k}; if ($v instanceof GBDateTime) { $v = strval($v); } $modified_state[$k] = $v; } } } # commit? if ($input['commit']) { git::add($post->name); git::commit(($created ? 'Created' : 'Updated') . ' post ' . r($post->title), gb::$authorized, $post->name); } # build response entity $rsp = array('name' => $post->name, 'version' => $post->id, 'exists' => $post->exists(), 'isTracked' => $post->isTracked(), 'isDirty' => $post->isDirty(), 'state' => $modified_state); # status $status = '200 OK'; if ($created) { $status = '201 Created'; } # send JSON response gb_admin::json_rsp($rsp, $status); gb::log('saved post %s', $post->name); } catch (Exception $e) { gb::log('failed to save post: %s', GBException::format($e, true, false, null, 0)); gb_admin::json_rsp($e->getMessage(), '400 Bad Request'); }
$referrer = gb::referrer_url(); # comment not found if (!$removed_comment) { if ($referrer) { $referrer['gb-error'] = 'Comment ' . $input['comment'] . ' not found'; header('HTTP/1.1 303 See Other'); header('Location: ' . $referrer); } else { header('HTTP/1.1 404 Not Found'); } exit('no such comment ' . $input['comment']); } gb::log(LOG_NOTICE, 'removed comment %s by %s from post %s', $input['comment'], $removed_comment->name, $post->cachename()); gb::event('did-remove-comment', $removed_comment); # done OK if ($referrer) { $referrer->fragment = 'comments'; header('HTTP/1.1 303 See Other'); header('Location: ' . $referrer); } else { exit2("removed comment: {$removed_comment->id}\n", '200 OK'); } } catch (Exception $e) { gb::log(LOG_ERR, 'failed to remove comment %s from %s', $input['comment'], $post->cachename()); header('HTTP/1.1 500 Internal Server Error'); echo '$input => '; var_export($input); echo "\n"; gb_flush(); throw $e; }
$post = GBPost::findByName($name, $status === 'deleted' ? null : 'work', false); if ($post) { if (!isset($muxed_posts[$post->name])) { $muxed_posts[$post->name] = array(); } $muxed_posts[$post->name][] = array($post, $stageflag . _mkflags($post, $status)); } } } } # Add dirty staged, unstaged and untracked files _add_posts_from_status($st, 'content/posts/', 'staged', st::STAGED); _add_posts_from_status($st, 'content/posts/', 'unstaged', st::UNSTAGED); _add_posts_from_status($st, 'content/posts/', 'untracked', st::UNTRACKED); # Add clean drafts foreach (gb::index('draft-posts') as $post) { if (!isset($muxed_posts[$post->name])) { $muxed_posts[$post->name] = array(); } $muxed_posts[$post->name][] = array($post, st::DRAFT); } function _post_tuple_sortfunc($a, $b) { return $b[0]->modified->time - $a[0]->modified->time; } function _muxed_posts_sortfunc($a, $b) { return $b[0][0]->modified->time - $a[0][0]->modified->time; } # Add published and scheduled posts $pageno = 0;
title="How and where to download Smisk">downloads</a></li> <li><a href="http://github.com/rsms/smisk/issues" title="List of all the horrible bugs... or wait a minute... no bugs?!">issues</a></li> <li><a href="http://github.com/rsms/smisk/tree/master" title="The master repository at GitHub, including all source code and information about the current development process">code</a></li> </ul> </div> <?php if (gb::$is_page && !gb::$is_404) { require '_page.php'; } else { ?> <div id="error404"> <div class="wrapper"> <h1>404 Not Found</h1> The page <b><?php echo h(gb::url()->toString(false)); ?> </b> does not exist. </div> </div> <?php } ?> <?php gb_footer(); ?> </body> </html>
</a> <span class="age"><?php echo $post->published->age(); ?> </span> </li> <?php } ?> </ol> </div> <div class="col"> <h2>Popular tags</h2> <ol class="tags"> <?php foreach (gb::tags() as $tag => $popularity) { if ($popularity < 0.2) { break; } ?> <li class="p<?php echo intval(round($popularity * 10.0)); ?> "><?php echo gb_tag_link($tag); ?> </li> <?php } ?> </ol>
function sync($force = false) { if ($this->index === null) { return false; } $data = $this->serialize(); if ($this->checksum !== null && $this->checksum === sha1($data) && $force === false) { return false; } # no changes $bw = file_put_contents($this->path(), $data, LOCK_EX); chmod($this->path(), 0664); gb::log(LOG_NOTICE, 'wrote %s', $this->cachename()); return $bw; }
<?php # Site title and description gb::$site_title = 'smisk'; # Private secret gb::$secret = trim(file_get_contents(dirname(__FILE__) . '/secret')); # Index prefix -- rewrite rules only engaged live if ($_SERVER['SERVER_NAME'] === 'python-smisk.org') { gb::$index_prefix = ''; }
static function filter($text = '') { $text = preg_replace_callback('/<codeblock([^>]*)>(.*)<\\/codeblock>/Usm', array(__CLASS__, '_escapeBlockContentCB'), $text); $tokens = gb_tokenize_html($text); $out = ''; $depth = 0; $block = ''; $tag = ''; foreach ($tokens as $token) { if (substr($token, 0, 10) === '<codeblock') { $depth++; if ($depth === 1) { # code block just started $tag = $token; continue; } } elseif (substr($token, 0, 12) === '</codeblock>') { $depth--; if ($depth < 0) { gb::log(LOG_WARNING, 'stray </codeblock> messing up a code block'); $depth = 0; } if ($depth === 0) { # code block ended if ($block) { $block = base64_decode($block); $lang = ''; # find lang, if any if (preg_match('/[\\s\\t ]+lang=("[^"]*"|\'[^\']*\')[\\s\\t ]*/', $tag, $m, PREG_OFFSET_CAPTURE)) { $lang = trim($m[1][0], '"\''); $end = substr($tag, $m[0][1] + strlen($m[0][0])); $tag = substr($tag, 0, $m[0][1]) . ($end === '>' ? '>' : ' ' . $end); } # add CSS class name $extra_cssclass = ''; if (preg_match('/class="([^"]+)"/', $tag, $m)) { $extra_cssclass = $m[1]; } # remove first and last line break if present if ($block[0] === "\n") { $block = substr($block, 1); } if ($block[strlen($block) - 1] === "\n") { $block = substr($block, 0, -1); } # expand tabs if (self::$conf['tabsize']) { $block = strtr($block, array("\t" => str_repeat(' ', self::$conf['tabsize']))); } # append block to output $out .= self::highlight($block, $lang, $extra_cssclass); # clear block $block = ''; } continue; } } # in codeblock or not? if ($depth) { $block .= $token; } else { $out .= $token; } } return $out; }
If git is not installed, please install it. Otherwise you need to update <tt>PATH</tt>. Putting something like this in <tt>gb-config.php</tt> would do it:<br/><br/> <code>$_ENV[\'PATH\'] .= \':/opt/local/bin\';</code><br/><br/> <tt>/opt/local/bin</tt> being the directory in which git is installed. Alternatively edit PATH in your php.ini file.<br/><br/> <small>(Original error from shell: ' . h($e->getMessage()) . ')</small>'; } # ------------------------------------------------------------------------- # create repository if (!gb::$errors) { $add_sample_content = isset($_POST['add-sample-content']) && $_POST['add-sample-content'] === 'true'; if (!gb::init($add_sample_content)) { gb::$errors[] = 'Failed to create and initialize repository at ' . var_export(gb::$site_dir, 1); } } # ------------------------------------------------------------------------- # commit changes (done by gb::init()) if (!gb::$errors) { try { if (!git::commit('gitblog created', trim($_POST['name']) . ' <' . trim($_POST['email']) . '>')) { gb::$errors[] = 'failed to commit creation'; } } catch (Exception $e) { gb::$errors[] = 'failed to commit creation: ' . nl2br(h(strval($e))); } } # -------------------------------------------------------------------------
function _bounceURL($relpath, $post = null, $include_referrer = true) { $post = $this->_post($post); if ($this->id === null) { throw new UnexpectedValueException('$this->id is null'); } $object = strpos(gb::$content_cache_fnext, '.') !== false ? gb_filenoext($post->cachename()) : $post->cachename(); return gb::$site_url . $relpath . 'object=' . urlencode($object) . '&comment=' . $this->id . ($include_referrer ? '&referrer=' . urlencode(gb::url()) : ''); }
/** * Rebuild caches, indexes, etc. */ static function rebuild($forceFullRebuild = false) { gb::log(LOG_NOTICE, 'rebuilding cache' . ($forceFullRebuild ? ' (forcing full rebuild)' : '')); $time_started = microtime(1); $failures = array(); # Load rebuild plugins gb::load_plugins('rebuild'); # Load rebuilders if needed if (empty(self::$rebuilders)) { self::loadRebuilders(); } # Create rebuilder instances $rebuilders = array(); foreach (self::$rebuilders as $cls) { $rebuilders[] = new $cls($forceFullRebuild); } # Load rebuild plugins (2nd offer) gb::load_plugins('rebuild'); # Query ls-tree $ls = rtrim(git::exec('ls-files --stage')); if ($ls) { # Iterate objects $ls = explode("\n", $ls); foreach ($ls as $line) { try { # <mode> SP <object> SP <stage no> TAB <name> if (!$line) { continue; } $line = explode(' ', $line, 3); $id = $line[1]; $name = gb_normalize_git_name(substr($line[2], strpos($line[2], "\t") + 1)); foreach ($rebuilders as $rebuilder) { $rebuilder->onObject($name, $id); } } catch (RuntimeException $e) { gb::log(LOG_ERR, 'failed to rebuild object %s %s: %s', var_export($name, 1), $e->getMessage(), $e->getTraceAsString()); $failures[] = array($rebuilder, $name); } } } # Let rebuilders finalize foreach ($rebuilders as $rebuilder) { try { $rebuilder->finalize(); } catch (RuntimeException $e) { gb::log(LOG_ERR, 'rebuilder %s (0x%x) failed to finalize: %s', get_class($rebuilder), spl_object_hash($rebuilder), GBException::format($e, true, false, null, 0)); $failures[] = array($rebuilder, null); } } gb::log(LOG_NOTICE, 'cache updated -- time spent: %s', gb_format_duration(microtime(1) - $time_started)); return $failures; }
?> <body> <div id="head"> <?php if (gb::$authorized) { ?> <div class="user"> Logged in as <?php echo h(gb::$authorized); ?> — <a href="<?php echo gb_admin::$url; ?> helpers/deauthorize.php?referrer=<?php echo urlencode(gb::url()); ?> ">Log out</a> </div> <?php } ?> <h1> <a href="<?php echo gb::$site_url; ?> "><?php echo h(gb::$site_title); ?> <span class="note">‹ visit site</span></a> </h1>
static function init($context) { if ($context !== 'rebuild') { return false; } foreach (array('md', 'markdown', 'mdown') as $ext) { gb_cfilter::add('post-reload-GBExposedContent.' . $ext, array(__CLASS__, 'reloadExposedObject'), 10); } # setup the MD parser self::$parser = new GBMarkdownParser(); self::$parser->use_codeblocks = gb::plugin_check_enabled($context, 'code_blocks'); gb_cfilter::add('body.md', array(self::$parser, 'transform'), 10); return true; }
function deduceChannelTimezoneOffset($channel) { # find timezone $diffs = array(); foreach ($channel->getElementsByTagName('item') as $item) { if ($item->nodeType !== XML_ELEMENT_NODE) { continue; } $localdate = ''; $utcdate = ''; foreach ($item->childNodes as $n) { if ($n->nodeType !== XML_ELEMENT_NODE) { continue; } $nname = '' . $n->nodeName; if ($nname === 'wp:post_date') { $localdate = $n->nodeValue; } elseif ($nname === 'wp:post_date_gmt') { $utcdate = $n->nodeValue; } } if ($utcdate !== '0000-00-00 00:00:00') { # lets guess the timezone. yay $diff = strtotime($localdate) - strtotime($utcdate); if (isset($diffs[$diff])) { $diffs[$diff]++; } else { $diffs[$diff] = 1; } } } #var_export($diffs); if (count($diffs) === 1) { return key($diffs); } $k = array_keys($diffs); $mindiff = min($k[0], $k[1]); $difference = max($k[0], $k[1]) - $mindiff; if (count($diffs) === 2) { #$v = array_values($diffs); #echo "distribution ";var_dump(max($v[0],$v[1]) - min($v[0],$v[1])); #echo "difference ";var_dump($difference); #echo "variation ";var_dump(count($diffs));#floatval(max($k[0],$k[1])) / floatval($mindiff)); #echo "occurance min/max ", min($v[0],$v[1]), '/', max($v[0],$v[1]), PHP_EOL; #echo "offsets min/max ", $mindiff, '/', max($k[0],$k[1]), PHP_EOL; if ($difference === $mindiff) { return $mindiff; } # most likely DST causing the variation, so } gb::log(LOG_WARNING, 'unable to exactly deduce timezone -- guessing %s%d', $mindiff < 0 ? '-' : '+', $mindiff); return $mindiff; }
<?php require_once '../_base.php'; gb::authenticate(); gb::$title[] = 'Posts'; include '../_header.php'; $unapproved_comments = gb::index('unapproved-comments', array()); ?> <div id="content" class="<?php echo gb_admin::$current_domid; ?> manage items"> <h2>Pending comments</h2> <table class="items comments"> <?php foreach ($unapproved_comments as $t) { list($comment, $post) = $t; ?> <?php $post_editurl = gb_admin::$url . 'edit/post.php?name=' . urlencode($post->name); ?> <tr class="<?php echo $comment->spam === true ? 'spam' : ''; ?> "> <td class="avatar"> <img src="<?php echo h($comment->avatarURL(48, gb_admin::$url . 'res/default-avatar.png')); ?> " alt="Avatar" width="48" height="48" /> </td>
static function commit($message, $author = null, $pathspec = null, $deferred = false) { # clear status cache self::$status_cache = null; if ($deferred && gb::defer(array('gb', 'commit'), $message, $author, $pathspec, false)) { $pathspec = $pathspec ? r($pathspec) : ''; gb::log('deferred commit -m %s --author %s %s', escapeshellarg($message), escapeshellarg($author), $pathspec); if (!$pathspec) { gb::log(LOG_WARNING, 'deferred commits without pathspec might cause unexpected changesets'); } return true; } if ($pathspec) { $pathspec = ' ' . self::escargs($pathspec); } else { $pathspec = ''; } $author = $author ? '--author=' . escapeshellarg($author) : ''; git::exec('commit -m ' . escapeshellarg($message) . ' --quiet ' . $author . ' -- ' . $pathspec); @chmod(gb::$site_dir . '/.git/COMMIT_EDITMSG', 0664); return true; }
function render_menu($menu_disabled = false, $items = null, $baseurl = null, $currurlpath = null, $liststart = '<ul>', $listend = '</ul>') { if ($items === null) { $items = self::$menu; } if ($baseurl === null) { $baseurl = gb_admin::$url; } if ($currurlpath === null) { $currurlpath = gb::url()->path; } $accesskey_prefix = ''; $is_osx = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac OS X') !== false; if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false) { if ($is_osx) { $accesskey_prefix = '⌃⌥'; } } $s = $liststart; foreach ($items as $k => $item) { $uri = $url = ''; $is_curr = $is_todo = false; $accesskey = is_string($k) ? strtoupper($k) : ''; if (isset($item[1]) && is_string($item[1])) { $uri = $item[1]; $url = $uri && ($uri[0] === '/' || strpos($uri, '://') !== false) ? $uri : $baseurl . $uri; $url_st = GBURL::parse($url); $actual_currpath = $url_st->path; $is_todo = strpos($url_st->fragment, 'todo:') === 0; $is_curr = !$is_todo && $actual_currpath === substr($currurlpath, 0, strlen($actual_currpath)); if ($uri === '') { $is_curr = gb::url()->path === GBURL::parse(gb_admin::$url)->path; } } $dom_id = $uri ? gb_strtodomid(gb_filenoext($item[1])) : $k; $s .= '<li id="menu-item-' . $dom_id . '"'; $css_class = ''; if ($is_curr) { $css_class .= 'selected'; self::$current_domid = $dom_id; } if ($is_todo) { $css_class .= ' todo'; } if ($css_class) { $s .= ' class="' . $css_class . '"'; } $s .= '><a'; if ($url && !$is_todo && !$menu_disabled) { $s .= ' href="' . h($url) . '"'; } if ($accesskey && !$menu_disabled) { $s .= ' accesskey="' . $accesskey . '"'; } $s .= '><span class="title">' . h($item[0]) . '</span>'; if ($accesskey && !$menu_disabled) { $s .= '<span class="accesskey-hint">' . $accesskey_prefix . $accesskey . '</span>'; } $s .= '</a>'; if (isset($item[2]) && $item[2]) { $s .= self::render_menu($menu_disabled, $item[2], $baseurl, $currurlpath, $liststart, $listend); } $s .= '</li>'; } $s .= $listend; return $s; }
<?php require '../gitblog.php'; ini_set('html_errors', '0'); gb::verify(); if (!isset($_SERVER['HTTP_X_GB_SHARED_SECRET']) || $_SERVER['HTTP_X_GB_SHARED_SECRET'] !== gb::$secret) { header('HTTP/1.1 401 Unauthorized'); exit('error: 401 Unauthorized'); } try { GBRebuilder::rebuild(isset($_REQUEST['force-full-rebuild'])); } catch (Exception $e) { echo 'error:'; throw $e; }
<?php require '../_base.php'; gb::verify(); gb::deauthorize();
<?php require dirname(__FILE__) . '/../gitblog.php'; $integrity = gb::verify_integrity(); if (strpos($_SERVER['SCRIPT_NAME'], '/admin/setup.php') === false) { if ($integrity === 2) { header('Location: ' . gb_admin::$url . 'setup.php'); exit(0); } else { gb::verify_config(); } } $admin_conf = gb::data('admin');
<div id="sidebar"> <?php if ($recent_comments = gb::index('recent-comments')) { ?> <h2>Recent comments</h2> <ol class="recent-comments"> <?php foreach ($recent_comments as $tuple) { list($comment, $_post) = $tuple; ?> <li> <a href="<?php echo h($_post->url()); ?> #comment-<?php echo $comment->id; ?> "><?php echo h($comment->name); ?> on <em><?php echo h($_post->title); ?> </em></a> <small><?php echo $comment->date->age(); ?> </small> </li> <?php }
static function upgrade($fromVersion) { self::sync_site_state(); # this can potentially take a very long time set_time_limit(120); $stages = gb_upgrade::perform($fromVersion, gb::$version); gb::log('triggering rebuild as an effect of the upgrade to %s', gb::$version); $failures = GBRebuilder::rebuild($stages ? true : false); gb::log('gitblog is now version %s', gb::$version); if ($failures) { gb::log(LOG_WARNING, 'rebuilding failed with %d failures', count($failures)); return false; } return true; }
static function did_add_comment($comment) { if ($comment->spam) { return; } # really do this? if ($comment->approved && !self::$data['notify_new_comment']) { return; } elseif (!$comment->approved && !self::$data['notify_pending_comment']) { return; } $subject = '[' . gb::$site_title . '] ' . ($comment->approved ? 'New' : 'Pending') . ' comment on "' . $comment->post->title . '"'; $body = self::comment_mkbody($comment); $to = self::recipient($comment); if (!$to[0]) { gb::log(LOG_WARNING, 'failed to deduce recipient -- ' . 'please add your address to "admin" in data/email.json'); } else { GBMail::compose($subject, $body, $to)->send(true); } }