예제 #1
0
파일: warserver.php 프로젝트: sinfocol/gwf3
function warscore_function($socket, $pid)
{
    # Init GWF
    $gwf = new GWF3(getcwd(), array('website_init' => false, 'autoload_modules' => false, 'load_module' => false, 'start_debug' => true, 'get_user' => false, 'log_request' => false, 'no_session' => true, 'store_last_url' => false, 'ignore_user_abort' => false));
    gdo_db();
    GWF_Debug::setDieOnError(false);
    GWF_HTML::init();
    if (false === ($wechall = GWF_Module::loadModuleDB('WeChall', true, true, true))) {
        warscore_error($socket, 'Cannot load WeChall!');
    }
    $wechall->includeClass('WC_Warbox');
    $wechall->includeClass('WC_WarToken');
    $wechall->includeClass('WC_Warflag');
    $wechall->includeClass('WC_Warflags');
    $wechall->includeClass('sites/warbox/WCSite_WARBOX');
    if (false === ($input = socket_read($socket, 2048))) {
        warscore_error($socket, 'Read Error 1!');
    }
    warscore_debug("GOT INPUT: {$input}");
    if (false === ($username = Common::substrUntil($input, "\n", false))) {
        warscore_error($socket, 'No username sent!');
    }
    if (false === ($user = GWF_User::getByName($username))) {
        warscore_error($socket, 'Unknown user!');
    }
    warscore_debug("GOT USER: {$username}");
    if ('' === ($token = Common::substrFrom($input, "\n", ''))) {
        warscore_error($socket, 'No token sent!');
    }
    $token = trim(Common::substrUntil($token, "\n", $token));
    if (!WC_WarToken::isValidWarToken($user, $token)) {
        warscore_error($socket, 'Invalid Token!');
    }
    if (!socket_getpeername($socket, $client_ip, $client_port)) {
        warscore_error($socket, 'Socket Error 2!');
    }
    echo "{$client_ip}\n";
    $boxes = WC_Warbox::getByIP($client_ip);
    if (count($boxes) === 0) {
        warscore_error($socket, 'Unknown Warbox!');
    }
    warscore_debug("GOT N BOXES: " . count($boxes));
    $curr_port = 0;
    foreach ($boxes as $box) {
        $box instanceof WC_Warbox;
        if ($curr_port !== $box->getVar('wb_port')) {
            $curr_port = $box->getVar('wb_port');
            warscore_identd($socket, $box, $user, $client_ip, $client_port);
        }
    }
    socket_write($socket, 'Bailing out! You should not see me.');
    socket_close($socket);
    die(0);
}
예제 #2
0
 public static function init($init_language = true)
 {
     if (isset($_GET['plain'])) {
         self::plaintext();
     } else {
         header('Content-Type: text/html; charset=UTF-8');
     }
     if ($init_language) {
         GWF_Language::init();
     }
     GWF_HTML::init();
     self::$xhtml = (self::isHTML() ? '>' : ' />') . "\n\t";
     self::addLink(GWF_WEB_ROOT . 'favicon.ico', 'img/x-icon', 'shortcut icon');
     self::addMeta(array('Content-Type', 'text/html; charset=utf-8', 1));
 }
예제 #3
0
파일: bootstrap.php 프로젝트: sinfocol/gwf3
<?php

require_once 'ruth/config.php';
$_GET['ajax'] = 1;
require_once '/opt/php/gwf3/gwf3.class.php';
# Init
$gwf = new GWF3(getcwd(), array('bootstrap' => false, 'website_init' => false, 'autoload_modules' => false, 'load_module' => false, 'load_config' => false, 'start_debug' => true, 'get_user' => false, 'do_logging' => true, 'log_request' => false, 'blocking' => false, 'no_session' => true, 'store_last_url' => false, 'ignore_user_abort' => false));
GWF_Language::initEnglish();
GWF_HTML::init();
$db = gdo_db();
// if (false === ($db = gdo_db_instance('localhost', 'warchall', 'ThreeLittlePonies', 'warchall')))
// {
// 	die('EEK DB GONE!');
// }
$db->lock('CRON');