Example #1
0
/**
 * Perform preflight checks for Mercator
 *
 * Checks that we can actually run Mercator, then attaches the relevant actions
 * and filters to make it useful.
 */
function run_preflight()
{
    // Are we installing? Bail if so.
    if (defined('WP_INSTALLING')) {
        return;
    }
    // Are we still in sunrise stage?
    if (did_action('muplugins_loaded')) {
        warn_with_message('Mercator must be loaded in your <code>sunrise.php</code>. Check out the <a href="https://github.com/humanmade/Mercator/wiki/Installation">installation instructions</a>.');
        return;
    }
    // Are we actually on multisite?
    if (!is_multisite()) {
        warn_with_message('Mercator requires WordPress to be in <a href="http://codex.wordpress.org/Create_A_Network">multisite mode</a>.');
        return;
    }
    // Are we running a good version of WP?
    if (!function_exists('get_site_by_path')) {
        warn_with_message('Mercator requires <a href="https://wordpress.org/download/">WordPress 3.9</a> or newer. Update now.');
        return;
    }
    // Check for COOKIE_DOMAIN definition
    //
    // Note that this can't be an admin notice, as you'd never be able to log in
    // to see it.
    if (defined('COOKIE_DOMAIN')) {
        status_header(500);
        header('X-Mercator: COOKIE_DOMAIN');
        wp_die('The constant <code>COOKIE_DOMAIN</code> is defined (probably in <code>wp-config.php</code>). Please remove or comment out that <code>define()</code> line.');
    }
    // M: We have clearance, Clarence.
    // O: Roger, Roger. What's our Vector Victor?
    startup();
}
Example #2
0
<?php

header('Content-Type: text/html; charset=utf-8');
//собираем всю информацию об защедщих на сайт
session_start();
include_once 'startup.php';
// Установка параметров, подключение к БД, запуск сессии.
startup();
//прооверяем, что мы админ
include 'variables.php';
if ($_SESSION['Guest_id']['id_user'] == $AdminID) {
    include 'rss_scripts.php';
} else {
    //echo 'Вы не Админ!!!';
}
echo "<br />";
//в дальнейшем бы надо закешировать структуры
//$_GET['avtor']='all';
//$_GET['avtor']='7';
$avtor = '';
if (isset($_POST['avtor'])) {
    $_GET['avtor'] = $_POST['avtor'];
}
//		include('MakeStructAvtArr.php');
if ($_GET['avtor'] != 'all') {
    //если мы выводим структуру какого либо определенного автора, то просчитываем ее
    include 'MakeStructAvtArr.php';
} else {
    //если всех авторов, то вытаскиваем структуру из БД, куда ее запихиваем при всех изменениях авторов
    $arrWho = array();
    //вытаскиваем из БД
Example #3
0
<?php

require_once 'modules/startup.php';
require 'modules/classes.php';
require 'modules/repository.php';
$link = startup();
$id = $_GET['id'];
$article_get = ArticleRepo::load($link, $id);
$article_title = $article_get->getTitle();
$article_content = $article_get->getContent();
$getTitle = $article_title;
$img_get = array();
if (isset($_POST['edit'])) {
    header("location: edit.php?id=" . $_GET['id']);
}
if (isset($_POST['delete'])) {
    if (ArticleRepo::delete($link, $id)) {
        header("location: editor.php");
    }
}
if (is_dir("img_p")) {
    $img_get = ImageRepo::loadAll($link, $id);
}
header('Content-type: text/html; charset=utf-8');
include 'views/header.php';
include 'views/v_article.php';
include 'views/footer.php';
Example #4
0
 /**
  * App constructor.
  */
 function __construct()
 {
     // we'll reset this after we read our config file
     date_default_timezone_set('UTC');
     $this->config = array('system' => array());
     $this->page = array();
     $this->pager = array();
     $this->query_string = '';
     startup();
     set_include_path('include' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'library/phpsec' . PATH_SEPARATOR . 'library/langdet' . PATH_SEPARATOR . '.');
     $this->scheme = 'http';
     if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
         $this->scheme = 'https';
     } elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) {
         $this->scheme = 'https';
     }
     if (x($_SERVER, 'SERVER_NAME')) {
         $this->hostname = $_SERVER['SERVER_NAME'];
         if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
             $this->hostname .= ':' . $_SERVER['SERVER_PORT'];
         }
         /**
          * Figure out if we are running at the top of a domain
          * or in a sub-directory and adjust accordingly
          */
         $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
         if (isset($path) && strlen($path) && $path != $this->path) {
             $this->path = $path;
         }
     }
     set_include_path("include/{$this->hostname}" . PATH_SEPARATOR . get_include_path());
     if (x($_SERVER, 'QUERY_STRING') && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
         $this->query_string = substr($_SERVER['QUERY_STRING'], 2);
         // removing trailing / - maybe a nginx problem
         if (substr($this->query_string, 0, 1) == "/") {
             $this->query_string = substr($this->query_string, 1);
         }
     }
     if (x($_GET, 'q')) {
         $this->cmd = trim($_GET['q'], '/\\');
     }
     // unix style "homedir"
     if (substr($this->cmd, 0, 1) === '~') {
         $this->cmd = 'channel/' . substr($this->cmd, 1);
     }
     /*
      * Break the URL path into C style argc/argv style arguments for our
      * modules. Given "http://example.com/module/arg1/arg2", $this->argc
      * will be 3 (integer) and $this->argv will contain:
      *   [0] => 'module'
      *   [1] => 'arg1'
      *   [2] => 'arg2'
      *
      * There will always be one argument. If provided a naked domain
      * URL, $this->argv[0] is set to "home".
      */
     $this->argv = explode('/', $this->cmd);
     $this->argc = count($this->argv);
     if (array_key_exists('0', $this->argv) && strlen($this->argv[0])) {
         $this->module = str_replace(".", "_", $this->argv[0]);
         $this->module = str_replace("-", "_", $this->module);
     } else {
         $this->argc = 1;
         $this->argv = array('home');
         $this->module = 'home';
     }
     /*
      * See if there is any page number information, and initialise
      * pagination
      */
     $this->pager['page'] = x($_GET, 'page') && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
     $this->pager['itemspage'] = 60;
     $this->pager['start'] = $this->pager['page'] * $this->pager['itemspage'] - $this->pager['itemspage'];
     if ($this->pager['start'] < 0) {
         $this->pager['start'] = 0;
     }
     $this->pager['total'] = 0;
     /*
      * Detect mobile devices
      */
     $mobile_detect = new Mobile_Detect();
     $this->is_mobile = $mobile_detect->isMobile();
     $this->is_tablet = $mobile_detect->isTablet();
     $this->head_set_icon('/images/rm-32.png');
     BaseObject::set_app($this);
     /*
      * register template engines
      */
     $dc = get_declared_classes();
     foreach ($dc as $k) {
         if (in_array("ITemplateEngine", class_implements($k))) {
             $this->register_template_engine($k);
         }
     }
 }
Example #5
0
 /**
  * App constructor.
  */
 public static function init()
 {
     // we'll reset this after we read our config file
     date_default_timezone_set('UTC');
     self::$config = array('system' => array());
     self::$page = array();
     self::$pager = array();
     self::$query_string = '';
     startup();
     set_include_path('include' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'library/langdet' . PATH_SEPARATOR . '.');
     self::$scheme = 'http';
     if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
         self::$scheme = 'https';
     } elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) {
         self::$scheme = 'https';
     }
     if (x($_SERVER, 'SERVER_NAME')) {
         self::$hostname = $_SERVER['SERVER_NAME'];
         if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
             self::$hostname .= ':' . $_SERVER['SERVER_PORT'];
         }
         /**
          * Figure out if we are running at the top of a domain
          * or in a sub-directory and adjust accordingly
          */
         $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
         if (isset($path) && strlen($path) && $path != self::$path) {
             self::$path = $path;
         }
     }
     set_include_path("include/self::{$hostname}" . PATH_SEPARATOR . get_include_path());
     if (x($_SERVER, 'QUERY_STRING') && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
         self::$query_string = substr($_SERVER['QUERY_STRING'], 2);
         // removing trailing / - maybe a nginx problem
         if (substr(self::$query_string, 0, 1) == "/") {
             self::$query_string = substr(self::$query_string, 1);
         }
     }
     if (x($_GET, 'q')) {
         self::$cmd = trim($_GET['q'], '/\\');
     }
     // unix style "homedir"
     if (substr(self::$cmd, 0, 1) === '~') {
         self::$cmd = 'channel/' . substr(self::$cmd, 1);
     }
     /*
      * Break the URL path into C style argc/argv style arguments for our
      * modules. Given "http://example.com/module/arg1/arg2", self::$argc
      * will be 3 (integer) and self::$argv will contain:
      *   [0] => 'module'
      *   [1] => 'arg1'
      *   [2] => 'arg2'
      *
      * There will always be one argument. If provided a naked domain
      * URL, self::$argv[0] is set to "home".
      */
     self::$argv = explode('/', self::$cmd);
     self::$argc = count(self::$argv);
     if (array_key_exists('0', self::$argv) && strlen(self::$argv[0])) {
         self::$module = str_replace(".", "_", self::$argv[0]);
         self::$module = str_replace("-", "_", self::$module);
         if (strpos(self::$module, '_') === 0) {
             self::$module = substr(self::$module, 1);
         }
     } else {
         self::$argc = 1;
         self::$argv = array('home');
         self::$module = 'home';
     }
     /*
      * See if there is any page number information, and initialise
      * pagination
      */
     self::$pager['page'] = x($_GET, 'page') && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
     self::$pager['itemspage'] = 60;
     self::$pager['start'] = self::$pager['page'] * self::$pager['itemspage'] - self::$pager['itemspage'];
     if (self::$pager['start'] < 0) {
         self::$pager['start'] = 0;
     }
     self::$pager['total'] = 0;
     /*
      * Detect mobile devices
      */
     $mobile_detect = new Mobile_Detect();
     self::$is_mobile = $mobile_detect->isMobile();
     self::$is_tablet = $mobile_detect->isTablet();
     self::head_set_icon('/images/hz-32.png');
     /*
      * register template engines
      */
     spl_autoload_register('ZotlabsAutoloader::loader');
     self::$meta = new Zotlabs\Web\HttpMeta();
     // create an instance of the smarty template engine so we can register it.
     $smarty = new Zotlabs\Render\SmartyTemplate();
     $dc = get_declared_classes();
     foreach ($dc as $k) {
         if (in_array('Zotlabs\\Render\\TemplateEngine', class_implements($k))) {
             self::register_template_engine($k);
         }
     }
 }
Example #6
0
 function __construct()
 {
     global $default_timezone, $argv, $argc;
     $this->timezone = x($default_timezone) ? $default_timezone : 'UTC';
     date_default_timezone_set($this->timezone);
     $this->performance["start"] = microtime(true);
     $this->performance["database"] = 0;
     $this->performance["network"] = 0;
     $this->performance["rendering"] = 0;
     $this->performance["parser"] = 0;
     $this->performance["marktime"] = 0;
     $this->performance["markstart"] = microtime(true);
     $this->config = array();
     $this->page = array();
     $this->pager = array();
     $this->query_string = '';
     startup();
     $this->scheme = 'http';
     if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
         $this->scheme = 'https';
     } elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) {
         $this->scheme = 'https';
     }
     if (x($_SERVER, 'SERVER_NAME')) {
         $this->hostname = $_SERVER['SERVER_NAME'];
         // See bug 437 - this didn't work so disabling it
         //if(stristr($this->hostname,'xn--')) {
         // PHP or webserver may have converted idn to punycode, so
         // convert punycode back to utf-8
         //	require_once('library/simplepie/idn/idna_convert.class.php');
         //	$x = new idna_convert();
         //	$this->hostname = $x->decode($_SERVER['SERVER_NAME']);
         //}
         if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
             $this->hostname .= ':' . $_SERVER['SERVER_PORT'];
         }
         /**
          * Figure out if we are running at the top of a domain
          * or in a sub-directory and adjust accordingly
          */
         $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
         if (isset($path) && strlen($path) && $path != $this->path) {
             $this->path = $path;
         }
     }
     if (is_array($argv) && $argc > 1 && substr(end($argv), 0, 4) == "http") {
         $this->set_baseurl(array_pop($argv));
         $argc--;
     }
     set_include_path("include/{$this->hostname}" . PATH_SEPARATOR . 'include' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'library/phpsec' . PATH_SEPARATOR . 'library/langdet' . PATH_SEPARATOR . '.');
     if (x($_SERVER, 'QUERY_STRING') && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
         $this->query_string = substr($_SERVER['QUERY_STRING'], 2);
         // removing trailing / - maybe a nginx problem
         if (substr($this->query_string, 0, 1) == "/") {
             $this->query_string = substr($this->query_string, 1);
         }
     }
     if (x($_GET, 'q')) {
         $this->cmd = trim($_GET['q'], '/\\');
     }
     // unix style "homedir"
     if (substr($this->cmd, 0, 1) === '~') {
         $this->cmd = 'profile/' . substr($this->cmd, 1);
     }
     // Diaspora style profile url
     if (substr($this->cmd, 0, 2) === 'u/') {
         $this->cmd = 'profile/' . substr($this->cmd, 2);
     }
     /**
      *
      * Break the URL path into C style argc/argv style arguments for our
      * modules. Given "http://example.com/module/arg1/arg2", $this->argc
      * will be 3 (integer) and $this->argv will contain:
      *   [0] => 'module'
      *   [1] => 'arg1'
      *   [2] => 'arg2'
      *
      *
      * There will always be one argument. If provided a naked domain
      * URL, $this->argv[0] is set to "home".
      *
      */
     $this->argv = explode('/', $this->cmd);
     $this->argc = count($this->argv);
     if (array_key_exists('0', $this->argv) && strlen($this->argv[0])) {
         $this->module = str_replace(".", "_", $this->argv[0]);
         $this->module = str_replace("-", "_", $this->module);
     } else {
         $this->argc = 1;
         $this->argv = array('home');
         $this->module = 'home';
     }
     /**
      * See if there is any page number information, and initialise
      * pagination
      */
     $this->pager['page'] = x($_GET, 'page') && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
     $this->pager['itemspage'] = 50;
     $this->pager['start'] = $this->pager['page'] * $this->pager['itemspage'] - $this->pager['itemspage'];
     if ($this->pager['start'] < 0) {
         $this->pager['start'] = 0;
     }
     $this->pager['total'] = 0;
     /**
      * Detect mobile devices
      */
     $mobile_detect = new Mobile_Detect();
     $this->is_mobile = $mobile_detect->isMobile();
     $this->is_tablet = $mobile_detect->isTablet();
 }
Example #7
0
 function __construct()
 {
     $this->config = array();
     $this->page = array();
     $this->pager = array();
     $this->query_string = '';
     startup();
     $this->scheme = 'http';
     if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
         $this->scheme = 'https';
     } elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) {
         $this->scheme = 'https';
     }
     if (x($_SERVER, 'SERVER_NAME')) {
         $this->hostname = $_SERVER['SERVER_NAME'];
         if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
             $this->hostname .= ':' . $_SERVER['SERVER_PORT'];
         }
         /**
          * Figure out if we are running at the top of a domain
          * or in a sub-directory and adjust accordingly
          */
         $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
         if (isset($path) && strlen($path) && $path != $this->path) {
             $this->path = $path;
         }
     }
     set_include_path("include/{$this->hostname}" . PATH_SEPARATOR . 'include' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'library/phpsec' . PATH_SEPARATOR . '.');
     if (x($_SERVER, 'QUERY_STRING') && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
         $this->query_string = substr($_SERVER['QUERY_STRING'], 2);
         // removing trailing / - maybe a nginx problem
         if (substr($this->query_string, 0, 1) == "/") {
             $this->query_string = substr($this->query_string, 1);
         }
     }
     if (x($_GET, 'q')) {
         $this->cmd = trim($_GET['q'], '/\\');
     }
     // unix style "homedir"
     if (substr($this->cmd, 0, 1) === '~') {
         $this->cmd = 'profile/' . substr($this->cmd, 1);
     }
     // Diaspora style profile url
     if (substr($this->cmd, 0, 2) === 'u/') {
         $this->cmd = 'profile/' . substr($this->cmd, 2);
     }
     /**
      *
      * Break the URL path into C style argc/argv style arguments for our
      * modules. Given "http://example.com/module/arg1/arg2", $this->argc
      * will be 3 (integer) and $this->argv will contain:
      *   [0] => 'module'
      *   [1] => 'arg1'
      *   [2] => 'arg2'
      *
      *
      * There will always be one argument. If provided a naked domain
      * URL, $this->argv[0] is set to "home".
      *
      */
     $this->argv = explode('/', $this->cmd);
     $this->argc = count($this->argv);
     if (array_key_exists('0', $this->argv) && strlen($this->argv[0])) {
         $this->module = str_replace(".", "_", $this->argv[0]);
         if (array_key_exists('2', $this->argv)) {
             $this->category = $this->argv[2];
         }
     } else {
         $this->argc = 1;
         $this->argv = array('home');
         $this->module = 'home';
     }
     /**
      * Special handling for the webfinger/lrdd host XRD file
      */
     if ($this->cmd === '.well-known/host-meta') {
         $this->argc = 1;
         $this->argv = array('hostxrd');
         $this->module = 'hostxrd';
     }
     /**
      * See if there is any page number information, and initialise
      * pagination
      */
     $this->pager['page'] = x($_GET, 'page') ? $_GET['page'] : 1;
     $this->pager['itemspage'] = 50;
     $this->pager['start'] = $this->pager['page'] * $this->pager['itemspage'] - $this->pager['itemspage'];
     $this->pager['total'] = 0;
 }
Example #8
0
function handle_data($data, $is_sock = False, $auth = False, $exec = False)
{
    global $buckets;
    global $alias_locks;
    global $dest_overrides;
    global $admin_accounts;
    global $admin_data;
    global $admin_is_sock;
    global $admin_aliases;
    global $exec_errors;
    global $exec_list;
    global $throttle_time;
    global $ignore_list;
    if ($auth == False) {
        echo "" . date("Y-m-d H:i:s", microtime(True)) . " > {$data}";
        handle_errors($data);
    } else {
        term_echo("*** auth = true");
    }
    $items = parse_data($data);
    if ($items !== False) {
        write_out_buffer_data($items);
        if ($items["destination"] == DEBUG_CHAN) {
            return;
        }
        if ($auth == False and $is_sock == True) {
            log_items($items);
        }
        if (in_array($items["nick"], $ignore_list) == True) {
            return;
        }
        if (isset($buckets[BUCKET_IGNORE_NEXT]) == True and $items["nick"] == get_bot_nick()) {
            unset($buckets[BUCKET_IGNORE_NEXT]);
            return;
        }
        if ($items["prefix"] == IRC_HOST and strpos(strtolower($items["trailing"]), "throttled") !== False) {
            term_echo("*** THROTTLED BY SERVER - REFUSING ALL OUTGOING MESSAGES TO SERVER FOR " . THROTTLE_LOCKOUT_TIME . " SECONDS ***");
            $throttle_time = microtime(True);
            return;
        }
        if ($items["cmd"] == 330) {
            authenticate($items);
        }
        if ($items["cmd"] == 376) {
            dojoin(INIT_CHAN_LIST);
        }
        if ($items["cmd"] == "NOTICE" and $items["nick"] == "NickServ" and $items["trailing"] == NICKSERV_IDENTIFY_PROMPT) {
            if (file_exists(PASSWORD_FILE) == True and NICKSERV_IDENTIFY === "1") {
                rawmsg("NickServ IDENTIFY " . trim(file_get_contents(PASSWORD_FILE)), True);
            }
            startup();
        }
        $args = explode(" ", $items["trailing"]);
        if (in_array($args[0], $admin_aliases) == True or has_account_list($args[0]) == True) {
            if ($auth == False and $is_sock == True) {
                term_echo("authenticating \"" . $args[0] . "\"...");
                $admin_data = $items["data"];
                $admin_is_sock = $is_sock;
                rawmsg("WHOIS " . $items["nick"]);
                return;
            }
        }
        $alias = $args[0];
        handle_events($items);
        switch ($alias) {
            case ALIAS_ADMIN_NICK:
                if (count($args) == 2) {
                    rawmsg(":" . get_bot_nick() . " NICK :" . trim($args[1]));
                    set_bot_nick(trim($args[1]));
                }
                break;
            case ALIAS_ADMIN_QUIT:
                if (count($args) == 1) {
                    write_out_buffer_command($items, "quit");
                    process_scripts($items, ALIAS_QUIT);
                }
                break;
            case ALIAS_ADMIN_PS:
                if (count($args) == 1) {
                    write_out_buffer_command($items, "ps");
                    ps($items);
                }
                break;
            case ALIAS_ADMIN_KILL:
                if (count($args) == 2) {
                    write_out_buffer_command($items, "kill");
                    kill($items, $args[1]);
                }
                break;
            case ALIAS_ADMIN_KILLALL:
                if (count($args) == 1) {
                    write_out_buffer_command($items, "killall");
                    killall($items);
                }
                break;
            case ALIAS_LIST:
                if (check_nick($items, $alias) == True) {
                    if (count($args) == 1) {
                        write_out_buffer_command($items, "list");
                        get_list($items);
                    }
                }
                break;
            case ALIAS_LIST_AUTH:
                if (check_nick($items, $alias) == True) {
                    if (count($args) == 1) {
                        write_out_buffer_command($items, "listauth");
                        get_list_auth($items);
                    }
                }
                break;
            case ALIAS_LOCK:
                if (check_nick($items, $alias) == True) {
                    if (count($args) == 2) {
                        write_out_buffer_command($items, "lock");
                        $alias_locks[$items["nick"]][$items["destination"]] = $args[1];
                        privmsg($items["destination"], $items["nick"], "alias \"" . $args[1] . "\" locked for nick \"" . $items["nick"] . "\" in \"" . $items["destination"] . "\"");
                    } else {
                        privmsg($items["destination"], $items["nick"], "syntax: " . ALIAS_LOCK . " <alias>");
                    }
                }
                break;
            case ALIAS_UNLOCK:
                if (check_nick($items, $alias) == True and isset($alias_locks[$items["nick"]][$items["destination"]]) == True) {
                    write_out_buffer_command($items, "unlock");
                    privmsg($items["destination"], $items["nick"], "alias \"" . $alias_locks[$items["nick"]][$items["destination"]] . "\" unlocked for nick \"" . $items["nick"] . "\" in \"" . $items["destination"] . "\"");
                    unset($alias_locks[$items["nick"]][$items["destination"]]);
                }
                break;
            case ALIAS_ADMIN_DEST_OVERRIDE:
                if (count($args) == 2) {
                    write_out_buffer_command($items, "dest_override");
                    privmsg($items["destination"], $items["nick"], "destination override \"" . $args[1] . "\" set for nick \"" . $items["nick"] . "\" in \"" . $items["destination"] . "\"");
                    $dest_overrides[$items["nick"]][$items["destination"]] = $args[1];
                } else {
                    privmsg($items["destination"], $items["nick"], "syntax: " . ALIAS_ADMIN_DEST_OVERRIDE . " <dest>");
                }
                break;
            case ALIAS_ADMIN_DEST_CLEAR:
                if (isset($dest_overrides[$items["nick"]][$items["destination"]]) == True) {
                    write_out_buffer_command($items, "dest_clear");
                    $override = $dest_overrides[$items["nick"]][$items["destination"]];
                    unset($dest_overrides[$items["nick"]][$items["destination"]]);
                    privmsg($items["destination"], $items["nick"], "destination override \"{$override}\" cleared for nick \"" . $items["nick"] . "\" in \"" . $items["destination"] . "\"");
                }
                break;
            case ALIAS_ADMIN_IGNORE:
                if (count($args) == 2) {
                    if (in_array($args[1], $ignore_list) == False) {
                        write_out_buffer_command($items, "ignore");
                        privmsg($items["destination"], $items["nick"], get_bot_nick() . " set to ignore " . $args[1]);
                        $ignore_list[] = $args[1];
                        if (file_put_contents(IGNORE_FILE, implode("\n", $ignore_list)) === False) {
                            privmsg($items["destination"], $items["nick"], "error saving ignore file");
                        }
                    }
                } else {
                    privmsg($items["destination"], $items["nick"], "syntax: " . ALIAS_ADMIN_IGNORE . " <nick>");
                }
                break;
            case ALIAS_ADMIN_UNIGNORE:
                if (count($args) == 2) {
                    if (in_array($args[1], $ignore_list) == True) {
                        $i = array_search($args[1], $ignore_list);
                        if ($i !== False) {
                            write_out_buffer_command($items, "unignore");
                            privmsg($items["destination"], $items["nick"], get_bot_nick() . " set to listen to " . $args[1]);
                            unset($ignore_list[$i]);
                            $ignore_list = array_values($ignore_list);
                            if (file_put_contents(IGNORE_FILE, implode("\n", $ignore_list)) === False) {
                                privmsg($items["destination"], $items["nick"], "error saving ignore file");
                            }
                        } else {
                            privmsg($items["destination"], $items["nick"], $args[1] . " not found in " . get_bot_nick() . " ignore list");
                        }
                    }
                } else {
                    privmsg($items["destination"], $items["nick"], "syntax: " . ALIAS_ADMIN_UNIGNORE . " <nick>");
                }
                break;
            case ALIAS_ADMIN_LIST_IGNORE:
                if (count($ignore_list) > 0) {
                    write_out_buffer_command($items, "ignorelist");
                    privmsg($items["destination"], $items["nick"], get_bot_nick() . " ignore list: " . implode(", ", $ignore_list));
                } else {
                    privmsg($items["destination"], $items["nick"], get_bot_nick() . " isn't ignoring anyone");
                }
                break;
            case ALIAS_ADMIN_REHASH:
                if (count($args) == 1) {
                    if (exec_load() === False) {
                        privmsg($items["destination"], $items["nick"], "error reloading exec file");
                        doquit();
                    } else {
                        write_out_buffer_command($items, "rehash");
                        process_exec_helps();
                        process_exec_inits();
                        process_exec_startups();
                        $users = get_users();
                        foreach ($users[get_bot_nick()]["channels"] as $channel => $timestamp) {
                            rawmsg("NAMES {$channel}");
                        }
                        privmsg($items["destination"], $items["nick"], "successfully reloaded exec file (" . count($exec_list) . " aliases)");
                    }
                }
                break;
            case ALIAS_ADMIN_BUCKETS_DUMP:
                if (count($args) == 1) {
                    write_out_buffer_command($items, "buckets_dump");
                    buckets_dump($items);
                }
                break;
            case ALIAS_ADMIN_BUCKETS_SAVE:
                if (count($args) == 1) {
                    write_out_buffer_command($items, "buckets_save");
                    buckets_save($items);
                }
                break;
            case ALIAS_ADMIN_BUCKETS_LOAD:
                if (count($args) == 1) {
                    write_out_buffer_command($items, "buckets_load");
                    buckets_load($items);
                }
                break;
            case ALIAS_ADMIN_BUCKETS_FLUSH:
                if (count($args) == 1) {
                    write_out_buffer_command($items, "buckets_flush");
                    buckets_flush($items);
                }
                break;
            case ALIAS_ADMIN_BUCKETS_LIST:
                if (count($args) == 1) {
                    write_out_buffer_command($items, "buckets_list");
                    buckets_list($items);
                }
                break;
            case ALIAS_INTERNAL_RESTART:
                if (count($args) == 1 and $items["cmd"] == CMD_INTERNAL) {
                    define("RESTART", True);
                    process_scripts($items, ALIAS_QUIT);
                }
                break;
            case ALIAS_ADMIN_RESTART:
                if (count($args) == 1) {
                    write_out_buffer_command($items, "restart");
                    define("RESTART", True);
                    process_scripts($items, ALIAS_QUIT);
                }
                break;
            case ALIAS_ADMIN_EXEC_CONFLICTS:
                if (count($args) == 1) {
                    # TODO
                    # $admin_aliases $reserved_aliases
                }
                break;
            case ALIAS_ADMIN_EXEC_LIST:
                if (count($args) == 1) {
                    # TODO
                }
                break;
            case ALIAS_ADMIN_EXEC_TIMERS:
                if (count($args) == 1) {
                    # TODO
                }
                break;
            case ALIAS_ADMIN_EXEC_ERRORS:
                if (count($args) == 1) {
                    $n = count($exec_errors);
                    if ($n > 0) {
                        write_out_buffer_command($items, "exec_load_errors");
                        privmsg($items["destination"], $items["nick"], "exec load errors:");
                        $i = 0;
                        foreach ($exec_errors as $filename => $messages) {
                            if ($i == $n - 1) {
                                privmsg($items["destination"], $items["nick"], "  └─" . $filename);
                                for ($j = 0; $j < count($messages); $j++) {
                                    if ($j == count($messages) - 1) {
                                        privmsg($items["destination"], $items["nick"], "     └─" . $messages[$j]);
                                    } else {
                                        privmsg($items["destination"], $items["nick"], "     ├─" . $messages[$j]);
                                    }
                                }
                            } else {
                                privmsg($items["destination"], $items["nick"], "  ├─" . $filename);
                                for ($j = 0; $j < count($messages); $j++) {
                                    if ($j == count($messages) - 1) {
                                        privmsg($items["destination"], $items["nick"], "  │  └─" . $messages[$j]);
                                    } else {
                                        privmsg($items["destination"], $items["nick"], "  │  ├─" . $messages[$j]);
                                    }
                                }
                            }
                            $i++;
                        }
                    } else {
                        privmsg($items["destination"], $items["nick"], "no errors");
                    }
                }
                break;
            default:
                process_scripts($items, "");
                # execute scripts occurring for a specific alias
                process_scripts($items, ALIAS_ALL);
                # process scripts occuring for every line (* alias)
        }
    }
}
Example #9
0
if (DEBUG) {
    error_reporting(E_ALL | E_STRICT);
    ini_set('display_errors', 'On');
}
//session_start();
require_once 'config.php';
require_once MODELS_DIR . '/JL.php';
/*
//Создаём новый объект. Также можно писать и в процедурном стиле
$MC = new Memcache;

//Соединяемся с нашим сервером
$MC->connect('127.0.0.1', 11211) or die("Could not connect");
*/
require_once 'core/Controller.php';
spl_autoload_register('JL::AutoLoad');
global $DB;
$DB = startup();
if (isset($_GET['type'])) {
    $contr = 'C_' . $_GET['type'];
    if (isset($_GET['module'])) {
        $contr = 'C_' . $_GET['module'] . '_' . $_GET['type'];
    }
    echo $contr;
    $controller = new $contr();
} else {
    $controller = new C_Index();
}
$controller->Request();
//Закрываем соединение с сервером Memcached
//$MC->close();
Example #10
0
 protected function before()
 {
     startup();
     $this->title = 'Название сайта';
     $this->content = '';
 }