コード例 #1
0
ファイル: Dog_Launcher.php プロジェクト: sinfocol/gwf3
 public static function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
 {
     GWF_Debug::error_handler($errno, $errstr, $errfile, $errline, $errcontext);
     if ($errno === E_ERROR) {
         self::cleanup('Fatal PHP Error :O');
     }
 }
コード例 #2
0
ファイル: SR_RealNPC.php プロジェクト: sinfocol/gwf3
 public function message($message)
 {
     $this->setChatPartner(Shadowcmd::$CURRENT_PLAYER);
     echo GWF_Debug::backtrace('AIGOT', false);
     echo "AI GOT: {$message}\n";
     return true;
 }
コード例 #3
0
ファイル: Dog_Log.php プロジェクト: sinfocol/gwf3
 public static function error($message)
 {
     $message = GWF_Debug::backtrace($message, false);
     echo $message;
     GWF_Log::rawLog('dog/error', trim($message));
     GWF_Log::flush();
     return false;
 }
コード例 #4
0
ファイル: SR_AIDecision.php プロジェクト: sinfocol/gwf3
 /**
  * Remove all items from array that are not a decision.
  * @param array $args
  * @return array
  */
 public static function filterDecisions(array &$args)
 {
     foreach ($args as $i => $arg) {
         if (!$arg instanceof SR_AIDecision) {
             Dog_Log::debug('filterDecisions argument is not a decision.');
             GWF_Debug::backtrace('filterDecisions argument is not a decision.', $args);
             unset($args[$i]);
         }
     }
     return $args;
 }
コード例 #5
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);
}
コード例 #6
0
ファイル: index.php プロジェクト: sinfocol/gwf3
function math_pyramid_check(WC_Challenge $chall, $formula, $maxlen, $precision = 4)
{
    error_reporting(E_ERROR);
    GWF_Debug::setDieOnError(false);
    GWF_Debug::setMailOnError(false);
    $len = strlen($formula);
    $tests = array('0' => 0, '1' => 0.2357, '3.14' => 7.2971, '10' => 235.7023, '100' => 235702.2604);
    $eval = new EvalMath();
    $fa = "f(a) = {$formula}";
    if (false === $eval->evaluate($fa)) {
        echo GWF_HTML::error('Math Pyramid', $chall->lang('err_formula', array(htmlspecialchars($fa))));
        return false;
    }
    GWF_Debug::setDieOnError(true);
    GWF_Debug::setMailOnError(true);
    $back = GWF_HTML::message('Math Pyramid', $chall->lang('msg_formula', array(htmlspecialchars($fa))), false);
    $correct = 0;
    foreach ($tests as $a => $result) {
        $result2 = $eval->evaluate("f({$a})");
        $result = sprintf('%.0' . $precision . 'f', $result);
        $result2 = sprintf('%.0' . $precision . 'f', $result2);
        if ($result === $result2) {
            $back .= GWF_HTML::message('Math Pyramid', $chall->lang('msg_correct', array($a, $result2, $result)), false);
            $correct++;
        } else {
            $back .= GWF_HTML::error('Math Pyramid', $chall->lang('err_wrong', array($a, $result2, $result)), false);
        }
    }
    require_once GWF_CORE_PATH . 'module/WeChall/WC_MathChall.php';
    if ($chall->getID() > 0 && $correct === count($tests)) {
        if (false === WC_MathChall::insertSolution($chall->getID(), GWF_Session::getUserID(), $formula)) {
            $back .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
        } else {
            $back .= GWF_HTML::message('Math Pyramid', WC_HTML::lang('msg_wmc_sol_inserted', array($len, WC_MathChall::getLimitedHREF($chall, $len))), false);
        }
    }
    # Check Len
    if ($len > $maxlen) {
        $back .= GWF_HTML::error('Math Pyramid', $chall->lang('err_too_long', array($len, $maxlen)), false);
    }
    echo $back;
    if ($correct === count($tests) && $len <= $maxlen) {
        if ($len < $maxlen) {
            echo GWF_HTML::message('Math Pyramid', $chall->lang('msg_new_record', array($len, $maxlen)), false);
            GWF_Settings::setSetting('WC_MATH_PYRAMID', $len);
        }
        $chall->onChallengeSolved(GWF_Session::getUserID());
    }
}
コード例 #7
0
ファイル: dog.php プロジェクト: sinfocol/gwf3
<?php

chdir(dirname(__FILE__));
chdir('../');
# 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);
コード例 #8
0
ファイル: install.php プロジェクト: sinfocol/gwf3
/**
 * The GWF-Installation-Wizard
 * @author spaceone
 * @author gizmore
 */
header('Content-Type: text/html; charset=UTF-8');
# Load Install-Core
require_once GWF_CORE_PATH . 'inc/install/GWF_InstallWizard.php';
require_once GWF_CORE_PATH . 'inc/install/GWF_InstallConfig.php';
require_once GWF_CORE_PATH . 'inc/install/GWF_InstallFunctions.php';
require_once GWF_CORE_PATH . 'inc/install/GWF_InstallWizardLanguage.php';
// define('GWF_INSTALLATION', true);
define('GWF_STEP', Common::getGetString('step', '0'));
define('GWF_LOGGING_PATH', getcwd() . '/protected/installog');
$gwf = new GWF3(getcwd(), array('website_init' => false, 'autoload_modules' => false, 'load_module' => false, 'load_config' => false, 'start_debug' => true, 'get_user' => false, 'do_logging' => true, 'log_request' => true, 'blocking' => false, 'no_session' => true, 'store_last_url' => false, 'ignore_user_abort' => true));
GWF_Debug::setDieOnError(false);
# Website init
GWF_InstallWizardLanguage::init();
GWF_HTML::init();
# Set install language
$il = new GWF_LangTrans(GWF_CORE_PATH . 'lang/install/install');
GWF_InstallWizard::setGWFIL($il);
# Design init
GWF3::setDesign('install');
GWF_Website::addCSS(GWF_WEB_ROOT . 'tpl/install/css/install.css');
GWF_Website::addCSS(GWF_WEB_ROOT . 'tpl/install/css/design.css');
GWF_Website::setPageTitle('GWF Install Wizard');
$tVars = array('gwfpath' => GWF_PATH, 'gwfwebpath' => GWF_WWW_PATH, 'step' => GWF_STEP, 'il' => $il, 'steps' => 11, 'timings' => GWF_DebugInfo::getTimings());
GWF_Template::addMainTvars($tVars);
if (false !== Common::getPost('create_admin')) {
    $page = GWF_InstallWizard::wizard_9_1();
コード例 #9
0
ファイル: GWF_HTML.php プロジェクト: sinfocol/gwf3
 public static function displayMessages($messages)
 {
     if (count($messages) === 0) {
         return '';
     }
     if (Common::getGet('ajax') !== false) {
         $output = '';
         foreach ($messages['messages'] as $m) {
             $m2 = GWF_Debug::shortpath(self::decode($m));
             $output .= sprintf('1:%d:%s', strlen($m2), $m2) . PHP_EOL;
         }
         return $output;
         // 			return GWF_Website::addDefaultOutput($output);
     }
     return GWF_Template::templateMain('message.tpl', array('title' => $messages['title'], 'messages' => $messages['messages']));
 }
コード例 #10
0
ファイル: GWF_Template.php プロジェクト: sinfocol/gwf3
 private static function sendErrorMail($path, $msg)
 {
     return GWF_Mail::sendDebugMail(': Smarty Error: ' . $path, GWF_Debug::backtrace($msg, false));
 }
コード例 #11
0
ファイル: index.php プロジェクト: sinfocol/gwf3
<?php

require_once 'live_lfi.config.php';
require_once '/opt/php/gwf3/GWF3.php';
$gwf = new GWF3(getcwd());
GWF_Debug::enableErrorHandler();
$iso = Common::getGetString('lang', 'en');
$lang = (require_once $iso);
$page = sprintf('%s<br/>%s', $lang['welcome'], $lang['construction']);
echo GWF_Website::displayPage($page);
コード例 #12
0
ファイル: GWF_LangTrans.php プロジェクト: sinfocol/gwf3
 /**
  * Load a language for this basefile by ISO.
  * @param string $iso
  * @return boolean
  */
 private function loadLanguage($iso)
 {
     if (true === isset($this->trans[$iso])) {
         return true;
         # ISO Cache hit
     }
     $path1 = $this->base_path . '_' . $iso . '.php';
     if (true === Common::isFile($path1)) {
         $path = $path1;
         # Load ISO
     } elseif (true === isset($this->trans[GWF_DEFAULT_LANG])) {
         $this->trans[$iso] =& $this->trans[GWF_DEFAULT_LANG];
         return false;
         # Copy default cache
     } else {
         # Load default
         $path = $this->base_path . '_' . GWF_DEFAULT_LANG . '.php';
         if (false === Common::isFile($path)) {
             die(GWF_Debug::backtrace(sprintf("A language file is completely missing: %s\n", htmlspecialchars($path)), false));
         }
     }
     # Load file
     require $path;
     $this->trans[$iso] = $lang;
     return true;
 }
コード例 #13
0
ファイル: GWF_Mail.php プロジェクト: sinfocol/gwf3
 public static function sendDebugMail($subject, $body)
 {
     return self::sendMailS(GWF_BOT_EMAIL, GWF_ADMIN_EMAIL, GWF_SITENAME . $subject, GWF_Debug::getDebugText($body), false, true);
 }
コード例 #14
0
function Upgrade_WeChall_5_06(Module_WeChall $module)
{
    GWF_Website::addDefaultOutput(GWF_HTML::message('WC5', "Database additions for speedy warboxes."));
    gdo_db()->setDieOnError(false);
    GWF_Debug::setDieOnError(false);
    $back = '';
    # Copy warchalls to warflags table
    $module->includeClass('WC_Warchall');
    $module->includeClass('WC_Warchalls');
    $module->includeClass('WC_Warflag');
    $module->includeClass('WC_Warflags');
    $flag = GDO::table('WC_Warflag');
    $flags = GDO::table('WC_Warflags');
    #
    if (!$flag->createColumn('wf_solvers')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$flag->createColumn('wf_options')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$flag->dropColumn('wf_flag')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    $flag->update("wf_options=1");
    $now = GWF_Time::getDate();
    $chall = GDO::table('WC_Warchall');
    $challs = GDO::table('WC_Warchalls');
    foreach ($chall->selectAll('*', '', '', NULL, -1, -1, GDO::ARRAY_O) as $c) {
        $c instanceof WC_Warchall;
        $boxid = $c->getVar('wc_boxid');
        $newflag = new WC_Warflag(array('wf_id' => '0', 'wf_wbid' => $boxid, 'wf_order' => '0', 'wf_cat' => 'exploit', 'wf_score' => '1', 'wf_solvers' => '0', 'wf_title' => $c->getVar('wc_level'), 'wf_url' => '', 'wf_authors' => 'Steven', 'wf_status' => 'up', 'wf_login' => '', 'wf_flag_enc' => NULL, 'wf_created_at' => $now, 'wf_last_solved_at' => NULL, 'wf_last_solved_by' => NULL, 'wf_options' => WC_Warflag::WARCHALL));
        $newflag->replace();
        $nfid = $newflag->getID();
        foreach ($challs->selectAll('*', "wc_wcid={$c->getID()}", '', NULL, -1, -1, GDO::ARRAY_O) as $entry) {
            $entry instanceof WC_Warchalls;
            $flags->insertAssoc(array('wf_wfid' => $nfid, 'wf_uid' => $entry->getVar('wc_uid'), 'wf_solved_at' => $entry->getVar('wc_solved_at'), 'wf_attempts' => '1', 'wf_last_attempt' => NULL));
        }
    }
    $flag->update("wf_solvers = (SELECT COUNT(*) FROM wc4_wc_warflags WHERE wf_wfid=wf_id)");
    $flag->update("wf_last_solved_at = (SELECT MAX(wf_solved_at) FROM wc4_wc_warflags WHERE wf_wfid=wf_id)");
    $flag->update("wf_last_solved_by = (SELECT wf_uid FROM wc4_wc_warflags WHERE wf_wfid=wf_id ORDER BY wf_solved_at DESC LIMIT 1)");
    $module->includeClass('WC_Warbox');
    $boxes = GDO::table('WC_Warbox');
    if (!$boxes->createColumn('wb_players')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$boxes->createColumn('wb_flags')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$boxes->createColumn('wb_challs')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    if (!$boxes->createColumn('wb_totalscore')) {
        $back .= GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    foreach ($boxes->selectAll('*', "", "", NULL, -1, -1, GDO::ARRAY_O) as $box) {
        $box instanceof WC_Warbox;
        $box->recalcPlayersAndScore();
    }
    $box->update("wb_challs=(SELECT COUNT(*) FROM wc4_wc_warflag WHERE wf_wbid=wb_id)");
    $box->update("wb_levels=(SELECT COUNT(*) FROM wc4_wc_warflag WHERE wf_wbid=wb_id AND wf_options&2)");
    $box->update("wb_flags=(SELECT COUNT(*) FROM wc4_wc_warflag WHERE wf_wbid=wb_id AND wf_options&1)");
    $chall->dropTable();
    $challs->dropTable();
    return $back;
}
コード例 #15
0
ファイル: GWF_Debug.php プロジェクト: sinfocol/gwf3
 public static function enableExceptionHandler()
 {
     if (self::$exception === false) {
         set_exception_handler(array('GWF_Debug', 'exception_handler'));
         self::$exception = true;
     }
 }
コード例 #16
0
ファイル: who.php プロジェクト: sinfocol/gwf3
<?php

chdir('../../../');
define('GWF_PAGE_TITLE', 'What is your Name?');
define('NO_HEADER_PLEASE', '1');
require_once 'challenge/html_head.php';
$SOLUTION_FLAG = (require_once 'challenge/Mawekl/what_is_your_name/solution.php');
GWF_Debug::disableErrorHandler();
error_reporting(E_ERROR);
#########################
# Challenge starts here #
#########################
function honeypot($buff)
{
    return str_replace('mawekl', 'Mawekl', $buff);
}
ob_start('honeypot', 4096);
session_start();
?>
<html><head><title>What is your name?</title><meta name="description" content="What is your name challenge from Mawekl on WeChall. It requires knowledge of PHP, Programming and Exploitation." /><meta name="keywords" content="Hackit,Challenge,PHP,Exploit" /><meta name="author" content="Mawekl" /><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><body><p>
<?php 
if (isset($_SESSION['whoami'])) {
    if ($_SESSION['whoami'] === 'Mawekl') {
        echo 'Welcome Mawekl! Password is ' . $SOLUTION_FLAG;
    } else {
        echo 'STRANGER! GO AWAY!';
    }
    unset($_SESSION['whoami']);
} elseif (isset($_GET['who'])) {
    $honeypot = $_GET['honeypot'] * 1337 + 1.7;
    if (!preg_match('/[^0-9.E+]/', (string) $honeypot) && is_float((int) round($honeypot) - 33)) {
コード例 #17
0
ファイル: GWF_Error.php プロジェクト: sinfocol/gwf3
 private static function displayAjax(&$subject)
 {
     $back = '';
     foreach ($subject as $messages) {
         foreach ($messages as $msg) {
             $m = GWF_Debug::shortpath(self::decode($msg));
             $back .= sprintf('0:%d:%s', strlen($m), $m) . PHP_EOL;
         }
     }
     GWF_Website::addDefaultOutput($back);
     return $back;
 }
コード例 #18
0
ファイル: index.php プロジェクト: sinfocol/gwf3
define('GWF_PAGE_TITLE', 'Training: Regex');
require_once 'challenge/html_head.php';
require_once GWF_CORE_PATH . 'module/WeChall/solutionbox.php';
if (false === ($chall = WC_Challenge::getByTitle('Training: Regex'))) {
    $chall = WC_Challenge::dummyChallenge('Training: Regex', 2, '/challenge/training/regex/index.php', false);
}
$chall->showHeader();
$level = GWF_Session::getOrDefault('WCC_T_REGEX', 1);
if (false !== ($answer = Common::getPost('answer'))) {
    $function = 'train_regex_level_' . $level;
    # Users can cause errors... don`t die :) (thx busyr
    GWF_Debug::setMailOnError(false);
    GWF_Debug::setDieOnError(false);
    $solved = call_user_func($function, $chall, $answer);
    GWF_Debug::setMailOnError(true);
    GWF_Debug::setDieOnError(true);
    if ($solved === true) {
        $level++;
        $next_func = 'train_regex_level_' . $level;
        if (!function_exists($next_func)) {
            echo GWF_HTML::message('WeChall', $chall->lang('msg_solved'), false);
            $chall->onChallengeSolved(GWF_Session::getUserID());
            $level = 1;
        } else {
            echo GWF_HTML::message('WeChall', $chall->lang('msg_next_level'), false);
        }
        GWF_Session::set('WCC_T_REGEX', $level);
    } else {
        echo GWF_HTML::error('WeChall', $chall->lang('err_wrong'), false);
    }
}
コード例 #19
0
ファイル: GDO_Database.php プロジェクト: sinfocol/gwf3
 private function emailOnError($message)
 {
     if (GWF_DEBUG_EMAIL & 1) {
         $message = GWF_HTML::br2nl($message) . PHP_EOL . PHP_EOL;
         GWF_Mail::sendDebugMail(GWF_SITENAME . ': Database Error!', GWF_Debug::backtrace($message, false));
     }
 }
コード例 #20
0
ファイル: index.php プロジェクト: sinfocol/gwf3
<?php

# WeChall things
chdir('../../../');
define('GWF_PAGE_TITLE', 'PHP 0819');
require_once 'challenge/html_head.php';
if (false === ($chall = WC_Challenge::getByTitle(GWF_PAGE_TITLE))) {
    $chall = WC_Challenge::dummyChallenge(GWF_PAGE_TITLE, 2, 'challenge/space/php0819/index.php', false);
}
$chall->showHeader();
###############
## Challenge ##
###############
GWF_Debug::setDieOnError(false);
GWF_Debug::setMailOnError(false);
require_once 'challenge/space/php0819/php0819.php';
echo GWF_Box::box($chall->lang('info', array(GWF_WEB_ROOT . 'profile/space')), $chall->lang('title'));
if (isset($_GET['eval'])) {
    if (true === $challenge()) {
        $chall->onChallengeSolved(GWF_Session::getUserID());
    }
}
GWF_Debug::setDieOnError(true);
GWF_Debug::setMailOnError(true);
$filename = 'challenge/space/php0819/php0819.php';
$message = '[PHP]' . file_get_contents($filename) . '[/PHP]';
echo GWF_Message::display($message);
# TODO: GET form input box? (gizmore)
echo $chall->copyrightFooter();
require_once 'challenge/html_foot.php';
コード例 #21
0
ファイル: Checker.php プロジェクト: sinfocol/gwf3
 /**
  * Check a file for translation errors 
  * @todo remove 2 loops, compare keys with array sort
  */
 private function onCheckFile($path2)
 {
     $this->num_files++;
     $path1 = $this->getOtherPath($path2);
     # English file exists?
     if (!file_exists($path1) || !is_file($path1) || !is_readable($path1)) {
         $this->MissingFile['en'][] = $path1;
         $this->errors['en']++;
         $lang1 = false;
     } else {
         # TODO: try{} to catch syntax errors?!
         include $path1;
         if (!isset($lang) || empty($lang)) {
             $this->EmptyFile['en'][] = $path1;
             $this->errors['en']++;
             $lang = false;
         }
         $lang1 = $lang;
         unset($lang);
     }
     # same paths?
     if ($path1 === $path2) {
         $lang2 = false;
     } elseif (!file_exists($path2) || !is_file($path2) || !is_readable($path2)) {
         # if $lang1 is false or empty, the error lies within the english file, not the translation one
         if (false !== $lang1 && !empty($lang1)) {
             $this->MissingFile['tr'][] = $path2;
             $this->missing['tr']++;
         }
         $lang2 = false;
     } else {
         include $path2;
         if (!isset($lang)) {
             $this->EmptyFile['tr'][] = $path2;
             $this->errors['tr']++;
             $lang = false;
         }
         $lang2 = $lang;
         unset($lang);
     }
     # separation between errors/warns related to english files and errors in tranaltion files
     $errs = array('en' => array(), 'tr' => array());
     $warn = array('en' => array(), 'tr' => array());
     # Check if there really is a lang to check
     if (is_array($lang1)) {
         # English lang file
         foreach ($lang1 as $key => $value) {
             # Value is empty?
             if ($value === '') {
                 $errs['en'][] = $this->module->lang('err_empty_key', array($key));
                 continue;
             }
             # other ISO lang file
             if ($lang2 === false) {
                 continue;
             }
             # Key exists?
             if (false === isset($lang2[$key])) {
                 $errs['tr'][] = $this->module->lang('err_missing_key', array($key));
             } elseif ($lang2[$key] === $lang1[$key]) {
                 $out = is_array($lang2[$key]) ? 'A(' . GWF_Array::implodeHuman($lang2[$key]) . ')' : $lang2[$key];
                 $warn['tr'][] = $this->module->lang('err_key_not_translated', array($key, htmlspecialchars($out)));
             }
         }
         if (isset($lang1[''])) {
             $errs['en'][] = $this->module->lang('err_not_finished', array($path1));
         }
     }
     # Check if there really is a lang to check
     if (is_array($lang2)) {
         if (isset($lang2[''])) {
             $errs['tr'][] = $this->module->lang('err_not_finished', array($path2));
         }
         # TODO: remove, do it faster
         # other-ISO lang file
         foreach ($lang2 as $key => $value) {
             if ($value === '') {
                 $errs['tr'][] = $this->module->lang('err_empty_key', array($key));
             }
         }
     }
     if ($lang2 !== false) {
         $this->errors['tr'] += count($errs['tr']);
         $this->warnings['tr'] += count($warn['tr']);
         $path = GWF_Debug::shortpath(realpath($path2));
         # FIXME: duplication errors if two different modulelang locations
         if (count($errs['tr']) > 0) {
             $this->errErrorMessages[$path] = $errs['tr'];
         }
         if (count($warn['tr']) > 0 && $this->show_warns === true) {
             $this->errWarnMessages[$path] = $warn['tr'];
         }
     }
     if ($lang1 !== false) {
         $this->errors['en'] += count($errs['en']);
         $this->warnings['en'] += count($warn['en']);
         $path = GWF_Debug::shortpath(realpath($path1));
         # FIXME: duplication errors if two different modulelang locations
         if (count($errs['en']) > 0) {
             $this->errErrorMessages[$path] = $errs['en'];
         }
         if (count($warn['en']) > 0 && $this->show_warns === true) {
             $this->errWarnMessages[$path] = $warn['en'];
         }
     }
 }
コード例 #22
0
ファイル: gwf3.class.php プロジェクト: sinfocol/gwf3
 /**
  * Initialize by ConfigOptions
  * @return GWF3 
  */
 public function init()
 {
     $config =& self::$CONFIG;
     if (true === $config['start_debug']) {
         GWF_Debug::enableErrorHandler();
         GWF_Debug::setMailOnError((GWF_DEBUG_EMAIL & 2) > 0);
     }
     if (true === $config['kick_banned_ip']) {
         $this->onKickBannedIP();
     }
     if (true === defined('GWF_WEBSITE_DOWN')) {
         $this->setConfig('load_module', false);
         $this->setConfig('autoload_modules', false);
         $this->setConfig('no_session', true);
     }
     // 		$db = gdo_db();
     if (false === $config['no_session']) {
         $this->onStartSession($config['blocking']);
     }
     if (true === $config['website_init']) {
         $db = gdo_db();
         GWF_Website::init();
     }
     if (true === $config['do_logging']) {
         $this->onStartLogging($config['no_session']);
     }
     if (true === $config['autoload_modules']) {
         $this->onAutoloadModules();
     }
     if (true === $config['get_user']) {
         GWF_Template::addMainTvars(array('user' => self::$user = GWF_User::getStaticOrGuest()));
     }
     if (true === $config['load_module']) {
         $this->onLoadModule();
     }
     if (true === defined('GWF_WEBSITE_DOWN')) {
         die($this->onDisplayPage(GWF_WEBSITE_DOWN));
     }
     return $this;
 }
コード例 #23
0
ファイル: GWF_Log.php プロジェクト: sinfocol/gwf3
 public static function logCritical($message)
 {
     self::log('critical', $message, self::GWF_CRITICAL);
     self::log('critical_details', GWF_Debug::backtrace(print_r($_GET, true) . PHP_EOL . self::stripPassword($_POST) . PHP_EOL . $message, false), self::GWF_CRITICAL);
     // TODO: formating
 }