示例#1
0
 public static function init(Dog_WorkerThread $worker)
 {
     Dog::setWorker($worker);
     Dog_Lang::init();
     self::initModules();
     foreach (Dog_Server::getAllServers() as $server) {
         $server instanceof Dog_Server;
         if ($server->isActive()) {
             Dog::addServer($server);
         }
     }
     Dog_Timer::init(self::getSleepMillis());
     Dog_Timer::addTimer(array(__CLASS__, 'initTimers'), NULL, count(Dog::getServers()) * Dog::CONNECT_WAIT + 1, false);
     Dog_Timer::addTimer(array('Dog', 'botReady'), NULL, count(Dog::getServers()) * Dog::CONNECT_WAIT + 2, false);
     self::$STARTUP_TIME = microtime(true);
     return true;
 }
示例#2
0
 public static function cleanup($message = 'Clean shutdown!')
 {
     GWF_CachedCounter::persist();
     if (NULL !== Dog_Init::getStartupTime()) {
         GWF_Counter::increaseCount('dog_uptime', Dog_Init::getUptime());
     }
     if (self::$CLEANED === false) {
         self::$CLEANED = true;
         foreach (Dog::getServers() as $server) {
             $server instanceof Dog_Server;
             if ($server->isConnected()) {
                 $server->disconnect($message);
             }
         }
     }
     die(0);
 }
示例#3
0
$argv = $plugin->argv();
$argc = count($argv);
if ($argc === 0) {
    if ($chan !== false) {
        if (NULL !== ($t = $chan->getTriggers())) {
            $plugin->rply('chan', array($t));
        } elseif (NULL !== ($t = $serv->getTriggers())) {
            $plugin->rply('chan_by_serv', array($t));
        } else {
            $plugin->rply('chan_by_bot', array(Dog_Init::getTriggers()));
        }
    } else {
        if (NULL !== ($t = $serv->getTriggers())) {
            $plugin->rply('serv', array($t));
        } else {
            $plugin->rply('serv_by_bot', array(Dog_Init::getTriggers()));
        }
    }
} elseif ($argc === 1) {
    if ($chan !== false) {
        if ($argv[0] === 'default') {
            $chan->saveVar('chan_triggers', NULL);
            $plugin->rply('chan_to_default');
        } else {
            $chan->saveVar('chan_triggers', $argv[0]);
            $plugin->rply('chan_to', array($argv[0]));
        }
    } else {
        if (!Dog::hasPermission($serv, false, $user, 'i')) {
            Dog::noPermission('i');
        } elseif ($argv[0] === 'default') {
示例#4
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD%. Restart all timers.', 'ok' => 'Timers have been successfully flushed. %BOT% is sleeping for %d milliseconds each loop.'));
$millis = Dog_Init::getSleepMillis();
Dog_Timer::flush();
Dog_Timer::init(Dog_Init::getSleepMillis());
Dog_Init::initTimers();
Dog::rply('ok', array($millis));
示例#5
0
文件: PRIVMSG.php 项目: sinfocol/gwf3
$serv->addUser($user);
$user = Dog::setupUser();
$chan = Dog::setupChannel();
if ($user === false) {
    return Dog::suppressModules();
}
# Log PRIVMSGs
$msg = Dog::getIRCMsg()->getArg(1);
if (Dog::getIRCMsg()->shouldLog()) {
    Dog_Log::user($user, $msg);
    Dog_Log::channel($chan, $msg);
}
# Exec Stuff
if (!$user->isBot()) {
    if ('' !== ($trigger = Common::substrUntil($msg, ' '))) {
        if (Dog_Init::isTrigger($serv, $chan, $trigger[0])) {
            if ($user->isFlooding()) {
                return;
            }
            Dog::setTriggered();
            $trigger = substr($trigger, 1);
            if (false !== ($plug = Dog_Plugin::getPlug($trigger))) {
                if (!$plug->isInScope($serv, $chan)) {
                    Dog::scopeError($plug->getScope());
                } elseif (!$plug->hasPermission($serv, $chan, $user)) {
                    Dog::permissionError($plug->getPriv());
                } elseif (!$plug->isEnabled($serv, $chan)) {
                    Dog::rply('err_disabled');
                } else {
                    $plug->execute();
                }
示例#6
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD%. Print statistics about the bots uptime.', 'out' => 'This bot is running since %s. Total runtime: %s.'));
$plugin = Dog::getPlugin();
if ($plugin->argc() > 0) {
    $plugin->showHelp();
} else {
    $uptime = round(Dog_Init::getUptime());
    $total = GWF_Counter::getCount('dog_uptime') + $uptime;
    $plugin->rply('out', array(GWF_Time::humanDuration($uptime), GWF_Time::humanDuration($total)));
}
示例#7
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% <module> [<flush>]. Will (re)install and init a module.', 'install' => 'Triggering install for %s.', 'install_flush' => 'Dropping all tables and triggering install for %s.'), 'de' => array('help' => 'Nutze: %CMD% <Modul> [<flush>]. (Re)-Installiert und Initialisiert ein Modul.', 'install' => 'Führe die Installationsroutinen für %s aus.', 'install_flush' => 'Lösche und initialisiere Modul %s.'));
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
$flush = false;
if ($argc === 2) {
    $flush = $argv[1] === 'flush';
    $argc = 1;
}
if ($flush) {
    return Dog::reply('NO FLUSH!');
}
if ($argc !== 1) {
    return $plugin->showHelp();
}
if (false === ($module = Dog_Module::getModule($argv[0]))) {
    return Dog::rply('err_module');
}
$plugin->rply($flush ? 'install_flush' : 'install', array($module->displayName()));
Dog_Init::installModule($module, $flush);
示例#8
0
    require_once 'lamb_import.php';
}
# Want a flush?
$drop_tables = isset($argv[3]) && $argv[3] === 'flush';
#############################
### Needed GWF/inc tables ###
#############################
require_once GWF_CORE_PATH . 'inc/install/GWF_InstallFunctions.php';
GDO::table('GWF_Language')->createTable($drop_tables);
GDO::table('GWF_Country')->createTable($drop_tables);
GDO::table('GWF_LangMap')->createTable($drop_tables);
GWF_InstallFunctions::createLanguage(true, true, false);
# More util
GDO::table('GWF_CachedCounter')->createTable($drop_tables);
GDO::table('GWF_Counter')->createTable($drop_tables);
GDO::table('GWF_Settings')->createTable($drop_tables);
##################
# DOG GDO Tables #
##################
$tables = array('Channel', 'Conf_Bot', 'Conf_Chan', 'Conf_Mod', 'Conf_Mod_Chan', 'Conf_Mod_Serv', 'Conf_Mod_User', 'Conf_Plug', 'Conf_Plug_Chan', 'Conf_Plug_Serv', 'Conf_Plug_User', 'Conf_User', 'Nick', 'PrivChannel', 'PrivServer', 'Server', 'User');
# Install Tables
foreach ($tables as $table) {
    GDO::table("Dog_{$table}")->createTable($drop_tables);
}
# Install modules
Dog_Init::installModules($drop_tables);
# Want defaults?
if (isset($argv[4]) && $argv[4] === 'giz') {
    GDO::table('Dog_Server')->insertAssoc(array('serv_id' => '1', 'serv_host' => 'irc.giz.org', 'serv_port' => '6668', 'serv_triggers' => '.', 'serv_options' => Dog_Server::DEFAULT_OPTIONS));
    GDO::table('Dog_Nick')->insertAssoc(array('nick_id' => '1', 'nick_sid' => '1', 'nick_name' => 'Dog', 'nick_pass' => NULL));
}
示例#9
0
文件: lang_Pb.php 项目: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% [<iso>]. Set or show your language.', 'set' => 'Your language on %s has been set from %s to %s.', 'show' => 'Your language on %s is set to %s.'));
# Special language codes
$special = array('bot' => 'Bot', 'ibd' => 'IBDES');
$user = Dog::getUser();
$server = Dog::getServer();
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
if ($argc === 0) {
    $plugin->rply('show', array($server->displayName(), $user->displayLang()));
} elseif ($argc === 1) {
    if (!Dog_Init::isValidISO($argv[0])) {
        return Dog::rply('err_lang_iso');
    } else {
        $old = isset($special[$user->getLangISO()]) ? $special[$user->getLangISO()] : $user->displayLang();
        Dog::getUser()->saveVar('user_lang', $argv[0]);
        $dlang = isset($special[$argv[0]]) ? $special[$argv[0]] : $user->displayLang();
        $plugin->rply('set', array($server->displayName(), $old, $dlang));
    }
} else {
    $plugin->showHelp();
}
示例#10
0
文件: dog.php 项目: sinfocol/gwf3
# Require config
$config_file = $argv[1];
require_once '../../../www/protected/' . $config_file;
# and gwf
require_once '../../../gwf3.class.php';
$gwf = new GWF3(NULL, array('init' => true, 'bootstrap' => false, 'website_init' => false, 'autoload_modules' => false, 'load_module' => false, 'load_config' => false, 'start_debug' => true, 'get_user' => false, 'do_logging' => false, 'log_request' => false, 'blocking' => true, 'no_session' => true, 'store_last_url' => false, 'ignore_user_abort' => false, 'kick_banned_ip' => false, 'env' => isset($argv[5]) ? $argv[5] : 'prod', 'unix_user' => isset($argv[6]) ? $argv[6] : 'root'));
# That´s all of GWF3 we will share with the worker.
GWF_HTML::init();
GWF_Debug::setDieOnError(false);
GWF_Debug::setMailOnError(false);
$_GET['ajax'] = 1;
# And this is the worker process
require 'dog_include/Dog_WorkerThread.php';
$worker = new Dog_WorkerThread();
$worker->start();
# Parent resources
GWF_Log::init(false, GWF_Log::_DEFAULT - GWF_Log::BUFFERED, GWF_PATH . 'www/protected/logs/dog');
gdo_db();
# Dog please
require_once 'Dog.php';
Dog::setUnixUsername(GWF3::getConfig('unix_user'));
# Dog installer
if (isset($argv[2]) && $argv[2] === 'install') {
    require_once 'mini_install.php';
}
# Dog init
Dog_Init::init($worker);
# Dog l(a)unch
if (!defined('DOG_NO_LAUNCH') && Dog_Init::validate()) {
    Dog::mainloop();
}
示例#11
0
文件: db_Pb.php 项目: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Usage: %CMD%. Print database connection statistics.', 'stats' => 'Database stats since last startup: Total DB time is %.02fs with %d queries within %s (%.02f qps). Queries opened/closed: %s/%s.'), 'de' => array('help' => 'Nutze: %CMD%. Zeige DATENBANKZUGRIFFSSTATISTIKEN!!!!!', 'stats' => 'Datenbank Statistiken seit dem letzten Startvorgang: Verbrachte Zeit in der DB ist %.02fs mit %d Abfragen in %s (%.02f QpS). Abfragen Offen/Beendet: %s/%s.'));
$db = gdo_db();
$c = $db->getQueryCount();
$ct = $db->getQueryTime();
$t = microtime(true) - Dog_Init::getStartupTime();
$dt = GWF_Time::humanDuration($t);
$tps = $c / $t;
$qo = $db->getQueriesOpened();
$qc = $db->getQueriesClosed();
Dog::getPlugin()->rply('stats', array($ct, $c, $dt, $tps, $qo, $qc));
示例#12
0
文件: Dog.php 项目: sinfocol/gwf3
 /**
  * Get the first valid trigger which would currently work.
  * @return string .
  */
 public static function getTrigger()
 {
     $chan = self::getChannel();
     $trigger = $chan === false ? self::getServer()->getTriggers() : $chan->getTriggers();
     $trigger = $trigger === NULL ? Dog_Init::getTriggers() : $trigger;
     return $trigger[0];
 }
示例#13
0
 public function isFlooding($update = true)
 {
     if (Dog::$FAKING_MESSAGE) {
         return false;
     }
     $time = microtime(true);
     $flood = Dog_Init::getFloodTime();
     if ($this->last_msg + $flood > $time) {
         return true;
     }
     if ($update) {
         $this->last_msg = $time;
     }
     return false;
 }