Пример #1
0
 *
 * Each of these can be imported at the start of a function with eg "global $page, $user;"
 */
if (!file_exists("data/config/shimmie.conf.php")) {
    header("Location: install.php");
    exit;
}
try {
    require_once "core/_bootstrap.inc.php";
    ctx_log_start(@$_SERVER["REQUEST_URI"], true, true);
    // start the page generation waterfall
    $user = _get_user();
    if (PHP_SAPI === 'cli') {
        send_event(new CommandEvent($argv));
    } else {
        send_event(new PageRequestEvent(_get_query()));
        $page->display();
    }
    // saving cache data and profiling data to disk can happen later
    if (function_exists("fastcgi_finish_request")) {
        fastcgi_finish_request();
    }
    $database->commit();
    ctx_log_endok();
} catch (Exception $e) {
    if ($database) {
        $database->rollback();
    }
    _fatal_error($e);
    ctx_log_ender();
}
Пример #2
0
 private function navlinks($link, $desc, $pages_matched)
 {
     /**
      * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.)
      */
     $html = null;
     $url = ltrim(_get_query(), "/");
     $re1 = '.*?';
     $re2 = '((?:[a-z][a-z_]+))';
     if (preg_match_all("/" . $re1 . $re2 . "/is", $url, $matches)) {
         $url = $matches[1][0];
     }
     $count_pages_matched = count($pages_matched);
     for ($i = 0; $i < $count_pages_matched; $i++) {
         if ($url == $pages_matched[$i]) {
             $html = "<li class='current-page'><a href='{$link}'>{$desc}</a></li>";
         }
     }
     if (is_null($html)) {
         $html = "<li><a class='tab' href='{$link}'>{$desc}</a></li>";
     }
     return $html;
 }
Пример #3
0
function modify_url($url, $changes)
{
    // SHIT: PHP is officially the worst web API ever because it does not
    // have a built-in function to do this.
    // SHIT: parse_str is magically retarded; not only is it a useless name, it also
    // didn't return the parsed array, preferring to overwrite global variables with
    // whatever data the user supplied. Thankfully, 4.0.3 added an extra option to
    // give it an array to use...
    $params = array();
    parse_str($url, $params);
    if (isset($changes['q'])) {
        $base = $changes['q'];
        unset($changes['q']);
    } else {
        $base = _get_query();
    }
    if (isset($params['q'])) {
        unset($params['q']);
    }
    foreach ($changes as $k => $v) {
        if (is_null($v) and isset($params[$k])) {
            unset($params[$k]);
        }
        $params[$k] = $v;
    }
    return make_link($base, http_build_query($params));
}