public function __init() { $this->user = logged_in() ? Visitor::current()->login : "******"; $this->path = INCLUDES_DIR . "/caches/" . sanitize($this->user); $this->caches = INCLUDES_DIR . "/caches"; $this->url = self_url(); $this->file = $this->path . "/" . md5($this->url) . ".html"; # If the cache directory is not writable, disable this module and cancel execution. if (!is_writable($this->caches)) { cancel_module("cacher"); } # Prepare actions that should result in new cache files. $this->prepare_cache_updaters(); # Remove all expired files. $this->remove_expired(); $config = Config::current(); $config->cache_exclude = (array) $config->cache_exclude; if (!empty($config->cache_exclude)) { foreach ($config->cache_exclude as &$exclude) { if (substr($exclude, 7) != "http://") { $exclude = $config->url . "/" . ltrim($exclude, "/"); } } } }
/** * Function: error * Shows an error message. * * Parameters: * $title - The title for the error dialog. * $body - The message for the error dialog. * $backtrace - The trace of the error. */ function error($title, $body, $backtrace = array()) { if (defined('MAIN_DIR') and !empty($backtrace)) { foreach ($backtrace as $index => &$trace) { if (!isset($trace["file"]) or !isset($trace["line"])) { unset($backtrace[$index]); } else { $trace["file"] = str_replace(MAIN_DIR . "/", "", $trace["file"]); } } } # $trace["file"] = isset($trace["file"]) ? # : # (isset($trace["function"]) ? # (isset($trace["class"]) ? # $trace["class"].$trace["type"] : # "").$trace["function"] : # "[internal]"); # Clear all output sent before this error. if (($buffer = ob_get_contents()) !== false) { ob_end_clean(); # Since the header might already be set to gzip, start output buffering again. if (extension_loaded("zlib") and !ini_get("zlib.output_compression") and isset($_SERVER['HTTP_ACCEPT_ENCODING']) and substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) { ob_start("ob_gzhandler"); header("Content-Encoding: gzip"); } else { ob_start(); } } elseif (!UPGRADING) { # If output buffering is not started, assume this # is sent from the Session class or somewhere deep. error_log($title . ": " . $body); foreach ($backtrace as $index => $trace) { error_log(" " . ($index + 1) . ": " . _f("%s on line %d", array($trace["file"], $trace["line"]))); } exit; } if (TESTER) { exit("ERROR: " . $body); } if ($title == __("Access Denied")) { $_SESSION['redirect_to'] = self_url(); } # Display the error. if (defined('THEME_DIR') and class_exists("Theme") and Theme::current()->file_exists("pages/error")) { MainController::current()->display("pages/error", array("title" => $title, "body" => $body, "backtrace" => $backtrace)); } else { require INCLUDES_DIR . "/error.php"; } if ($buffer !== false) { ob_end_flush(); } exit; }
public function on_comment_store($comment) { global $rel_path_to_root; $baseurl = explode("/", self_url()); $baseurl = array_slice($baseurl, 0, -1); foreach (explode("/", $rel_path_to_root) as $part) { if ($part == "..") { $baseurl = array_slice($baseurl, 0, -1); } } $baseurl = implode("/", $baseurl); $article = $comment->get_article(); $msg = "Hello,\nSomeone posted a comment to this article:\n Title: " . @$article->title[$comment->get_language()]->text . "\n URL: " . $baseurl . "/" . $comment->get_language() . "/" . $article->get_section()->name . "/" . $article->urlname . "\nThe comment:\n Author Name: " . $comment->author_name . "\n Author Mail: " . $comment->author_mail . "\n Comment Text:\n" . implode("\n", array_map(function ($l) { return " " . $l; }, explode("\n", $comment->text))) . "\nIf you are logged in to the Ratatöskr backend, you can view the comment here:\n " . $baseurl . "/backend/content/comments/" . $comment->get_id(); $moreheaders = "From: " . $this->config["from"] . "\r\nX-Mailer: new_comment_notifier plugin for Ratatoeskr\r\nContent-Transfer-Encoding: 8bit\r\nContent-Type: text/plain; charset=\"UTF-8\""; foreach ($this->config["to"] as $to) { mail($to, "Comment received", $msg, $moreheaders); } }
public function __init() { # Prepare actions that should result in new cache files. $this->prepare_cache_updaters(); $config = Config::current(); $config->cache_exclude = (array) $config->cache_exclude; if (!empty($config->cache_exclude)) { foreach ($config->cache_exclude as &$exclude) { if (substr($exclude, 7) != "http://") { $exclude = $config->url . "/" . ltrim($exclude, "/"); } } } if (count((array) $config->cache_memcached_hosts) > 0) { $this->cacher = new MemCacher(self_url(), $config); } else { $this->cacher = new FileCacher(self_url(), $config); } # Prepare actions that should result in new cache files. $this->prepare_cache_updaters(); }
function renderProfileDiffForm($diff, $sections) { ?> <form method="POST" action="<? echo self_url() ?>"> <input type="hidden" name="xml" value="<? echo base64_encode($diff->asXML()) ?>"> <table class="profilediff"> <tr> <td colspan="3" class="action"> <span class="heading"> Replace these fields in your PeopleAggregator profile: </span> <br /> Please be careful: the fields you select to import in this section will overwrite the info you had in those fields in your PeopleAggregator profile. </td> </tr> <?php action('update', $diff, $sections); ?> <tr> <td colspan="3" class="action"> <span class="heading"> Create new fields in your PeopleAggregator profile: </span> <br /> The fields you select below will be added to your PeopleAggregator profile. </td> </tr> <?php action('create', $diff, $sections); ?> </table> <input type="submit" name="confirm_import" value="import" /> </form> <?php }
echo fix($config->description); ?> </subtitle> <?php } ?> <id><?php echo fix(self_url()); ?> </id> <updated><?php echo date("c", $latest_timestamp); ?> </updated> <link href="<?php echo fix(self_url(), true); ?> " rel="self" type="application/atom+xml" /> <link href="<?php echo fix($config->url, true); ?> " /> <generator uri="http://chyrp.net/" version="<?php echo CHYRP_VERSION; ?> ">Chyrp</generator> <?php foreach ($posts as $post) { $updated = $post->updated ? $post->updated_at : $post->created_at; $tagged = substr(strstr(url("id/" . $post->id), "//"), 2); $tagged = str_replace("#", "/", $tagged);
* @author [creator, or "Original Author"] * @license http://bit.ly/aVWqRV PayAsYouGo License * @copyright Copyright (c) 2010 Broadband Mechanics * @package PeopleAggregator */ require_once dirname(__FILE__) . "/../../config.inc"; ob_start(); $login_required = TRUE; include_once "web/includes/page.php"; require_once "api/User/User.php"; // PA includes require_once "api/Logger/Logger.php"; require_once "web/functions.php"; require_once dirname(__FILE__) . "/common.php"; killslashes(); $script_url = self_url(); $_POST = get_proper_post(); // request dispatch if (isset($_REQUEST['do'])) { switch ($_REQUEST['do']) { case 'discover': if (!isset($_POST['dix:/homesite']) or !strlen($_POST['dix:/homesite'])) { default_page('Please enter your homesite'); } else { require_once 'Net/SXIP/Membersite.php'; $ms = new Net_SXIP_Membersite(); $response = $ms->discover($_POST['dix:/homesite']); if ($ms->isError($response)) { default_page($response->getMessage()); } else { auto_post_page($response['endpoint']);
/** * Function: reply_to_link * Outputs a Reply to comment link, if the <User.can> add comment and allow_nested_comments is checked. * * Parameters: * $text - The text to show for the link. * $before - If the link can be shown, show this before it. * $after - If the link can be shown, show this after it. * $classes - Extra CSS classes for the link, space-delimited. */ public function replyto_link($text = null, $before = null, $after = null, $classes = "") { if (!Config::current()->allow_nested_comments) { return; } fallback($text, __("Reply")); $name = strtolower(get_class($this)); echo $before . '<a href="' . self_url() . '&replyto' . $name . '=' . $this->id . '#add_comment" title="Reply to ' . $this->author . '" class="' . ($classes ? $classes . " " : '') . $name . '_reply_link replyto" id="comment_reply">' . $text . '</a>' . $after; }
function show_navigator() { global $offset, $g_ini, $g_lang; $ipp = $g_ini->read_var('control', 'AdminCount'); $count = $this->list_count; $current_page = floor($offset / $ipp) + 1; $last = floor(($count - 1) / $ipp) + 1; $pages[0] = true; $pages[1] = true; $pages[$last] = true; for ($i = 1; $i <= $last; $i++) { if (!($i % 5)) { $pages[$i] = true; } } for ($i = $current_page - 2; $i < $current_page + 3; $i++) { $pages[$i] = true; } $link = self_url(array('page'), array('offset' => ($current_page - 2) * $ipp)) . 'page=list&'; $out = ''; if (1 == $current_page) { $out = ''; } else { $out = "<a href='{$link}'><<</a>"; } for ($i = 1; $i <= $last; $i++) { $link = self_url(array('page'), array('offset' => ($i - 1) * $ipp)) . 'page=list&'; if (isset($pages[$i]) && isset($pages[$i - 1])) { if ($i == $current_page) { $out .= " <b>{$i}</b>"; } else { $out .= " <a href='{$link}'>{$i}</a>"; } } elseif (isset($pages[$i])) { $out .= " ··· <a href='{$link}'>{$i}</a>"; } } $link = self_url(array('page'), array('offset' => $current_page * $ipp)) . 'page=list&'; if ($last == $current_page || !$count) { $out .= ''; } else { $out .= " <a href='{$link}'>>></a>"; } $out .= "<br>" . $g_lang['list.navigator.total'] . ": {$count}"; return $out; }
/** * Function: init * Attempt Controller actions until one of them doesn't return false. * * This will also call the @[controllername]_xxxxx@ and @route_xxxxx@ triggers. */ public function init() { $trigger = Trigger::current(); $trigger->call("route_init", $this); $try = $this->try; if (isset($this->action)) { array_unshift($try, $this->action); } $count = 0; foreach ($try as $key => $val) { if (is_numeric($key)) { list($method, $args) = array($val, array()); } else { list($method, $args) = array($key, $val); } $this->action = $method; $name = strtolower(str_replace("Controller", "", get_class($this->controller))); if ($trigger->exists($name . "_" . $method) or $trigger->exists("route_" . $method)) { $call = $trigger->call(array($name . "_" . $method, "route_" . $method), $this->controller); } else { $call = false; } if ($call !== true and method_exists($this->controller, $method)) { $response = call_user_func_array(array($this->controller, $method), $args); } else { $response = false; } if ($response !== false or $call !== false) { $this->success = true; break; } if (++$count == count($try) and isset($this->controller->fallback) and method_exists($this->controller, "display")) { call_user_func_array(array($this->controller, "display"), $this->controller->fallback); } } if ($this->action != "login" and $this->success) { $_SESSION['redirect_to'] = self_url(); } $trigger->call("route_done", $this); return true; }
function show_list() { global $g_lang; return "<a href='" . self_url(array('page')) . "page=edit&id=" . $this->table_id() . "'>" . $g_lang['list_edit'] . "</a>"; }
$admin = User::create($_POST["admin_name"]); $admin->pwhash = PasswordHash::create($_POST["admin_password"]); $admin->isadmin = True; $admin->save(); $settings["repo_name"] = $_POST["repo_name"]; $settings["repo_description"] = $_POST["repo_description"]; $settings["repo_baseurl"] = $_POST["repo_baseurl"]; $settings["repo_mode"] = $_POST["repo_mode"]; update_repometa(); $settings["setup_finished"] = True; $url_next = array("_prelude", "index"); return; } } } $ste->vars["baseurl_predicted"] = self_url(); echo $ste->exectemplate("setup.html"); }); /* bootstrapping... */ $urlpath = explode("/", $_GET["action"]); $rel_path_to_root = implode("/", array_merge(array("."), array_repeat("..", count($urlpath) - 1))); $GLOBALS["rel_path_to_root"] = $rel_path_to_root; $data = array("rel_path_to_root" => $rel_path_to_root); $ste->vars["rel_path_to_root"] = $rel_path_to_root; /* Enforce setup */ if (!@$settings["setup_finished"]) { $urlpath = array("setup"); } try { url_process($urlpath, $url_handlers, $data); } catch (Exception $e) {