Example #1
0
function init_global()
{
    global $gbl, $sgbl, $ghtml;
    global $g_demo;
    $sgbl = new Sgbl();
    $gbl = new Gbl();
    $gbl->get();
    //
    // Turn on demo version by putting a empty file called demo in the etc dir
    //
    if (lfile_exists("__path_program_etc/demo")) {
        $g_demo = 1;
    }
    //
    // ### LxCenter
    //
    // Check for Development/Debug version
    // If file not exists, Production mode (-1)
    // If file exists it can have the following numbers to enable
    // 1  = Debug mode 1
    // 2  = Debug mode 2
    // 3  = Debug mode 3
    // 4  = Debug mode 4
    // 5  = Debug mode 5
    // -1 = Turn Off and go to production mode
    check_for_debug("/commands.php");
    // Disabled by LxCenter, we are not at PHP version with number 1 at postition N ( x.N.x )
    //  $v = explode(".", PHP_VERSION);
    //  if ($v[1] == "1" && $sgbl->isDebug()) {
    //      date_default_timezone_set("UTC");
    //  }
    $sgbl->method = $sgbl->dbg >= 1 ? "get" : "post";
}
Example #2
0
function init_global()
{
    global $gbl, $sgbl, $ghtml;
    global $g_demo;
    $sgbl = new Sgbl();
    $gbl = new Gbl();
    $gbl->get();
    date_default_timezone_set("UTC");
    //
    // Turn on demo version by putting a empty file called demo in the etc dir.
    // More info about enable a demo server soon at our wiki
    //
    if (lfile_exists("__path_program_etc/demo")) {
        $g_demo = 1;
    }
    check_for_debug("/usr/local/lxlabs/hypervm/httpdocs/commands.php");
    $sgbl->method = $sgbl->dbg >= 1 ? "get" : "post";
    //
    // ### LxCenter
    //
    // Check for Development/Debug version
    // If file not exists, Production mode (-1)
    // If file exists it can have the following numbers to enable
    // 1  = Debug mode 1
    // 2  = Debug mode 2
    // 3  = Debug mode 3
    // 4  = Debug mode 4
    // 5  = Debug mode 5
    // -1 = Turn Off and go to production mode
}
Example #3
0
 /**
  * Retreive a variable from the Gbl.
  */
 public static function get($name, $default = false)
 {
     $self = Gbl::get_current();
     if (isset($self->stored[$name])) {
         return $self->stored[$name];
     } else {
         return $default;
     }
 }
Example #4
0
 public function get_controller()
 {
     if (SITE_AVAILABLE) {
         $controllers_array = Gbl::get('controllers_array');
         if (!empty($this->up[0]) && Cleaner::sanitized(CTYPE_ARRAY, $this->up[0], array_keys($controllers_array))) {
             $controller_name = $controllers_array[$this->up[0]];
         } else {
             # we are running from the default page of the site, so pass the default back
             $controller_name = Gbl::get('default_controller');
         }
     } else {
         $controller_name = 'MaintenanceController';
     }
     # do we have to include the code for the controller?
     if (!is_object($controller_name)) {
         require_once CONTROLLERS_PATH . '/' . $controller_name . '.lib.php';
     }
     return new $controller_name();
 }
Example #5
0
 protected function _load($template_name, $cache_timeout = 86400, $cache_id = '')
 {
     $template_engine = Gbl::get('template_engine');
     # check for cached version of the template by the cache id (which can be empty)
     if (!$template_engine->is_cached($template_name, $cache_id)) {
         $template_engine->cache_lifetime = $cache_timeout;
     }
     //$template_engine->assign('user',Gbl::get('user'));
     # set up the variables for the template engine
     if (!empty($this->state)) {
         foreach ($this->state as $vn => $vv) {
             $template_engine->assign($vn, $vv);
         }
     }
     # fetch or display the template
     if ($this->_fetch_template) {
         return $template_engine->fetch($template_name, $cache_id);
     } else {
         $template_engine->display($template_name, $cache_id);
         return true;
     }
 }
Example #6
0
 protected function dump_log()
 {
     $log = "============\n" . strftime("%X %x", time()) . "\n" . $this->url . "\n";
     $log .= print_r($this->curlinfo, 1);
     $log .= "\n\nheader ------\n";
     $log .= print_r($this->header, 1);
     $log .= "\n\njson ------\n";
     $log .= print_r($this->json_response, 1);
     $log .= "\n\nerror ------\n";
     $log .= print_r($this->json_error, 1);
     Gbl::get('system_log')->write(LOG_LEVEL_ALL, $log);
 }
Example #7
0
#!/usr/bin/php5 -q
<?php 
define('CRON_MODE', 1);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '768M');
$dir = explode('/', __FILE__);
array_pop($dir);
$dir = implode('/', $dir);
require_once $dir . '/../../config/node.conf.php';
require_once MODULES_PATH . '/Cron.lib.php';
mb_internal_encoding("UTF-8");
try {
    $cron = new Cron();
    $cron->run_script();
} catch (Exception $e) {
    Gbl::get('system_log')->write(LOG_LEVEL_ERROR, 'Fatal website error (run-cron.php):' . $e->getMessage());
    die('Exception!');
}
Example #8
0
require_once SMARTY_CLASS_PATH . '/SmartyBC.class.php';
$smarty = new SmartyBC();
$smarty->template_dir = TEMPLATE_PATH;
$smarty->compile_dir = SMARTY_TEMPLATE_C_PATH;
$smarty->config_dir = SMARTY_CONFIGS_PATH;
$smarty->cache_dir = SMARTY_CACHE_PATH;
$smarty->assign('site_url', SITE_URL);
$smarty->assign('template_url', TEMPLATE_URL);
if (MODE == 'staging') {
    $smarty->caching = 0;
    $smarty->cache_lifetime = 0;
}
Gbl::store('template_engine', $smarty);
# create the system log, used for most logging
$system_log = new Log(SYSTEM_LOG_PATH, LOG_LEVEL_ALL);
Gbl::store('system_log', $system_log);
# authentication types -- auth module
define('AUTH_SITE', 0);
# cleaner types -- used by the Cleaner module.
define('CTYPE_ARRAY', 0);
define('CTYPE_REGEX', 1);
define('CTYPE_INT', 2);
define('CTYPE_ID', 3);
define('CTYPE_POS_NUMERIC', 4);
define('CTYPE_BOOL', 5);
define('CTYPE_POS_INT', 6);
# auth params
define('AUTH_COOKIE', 'auth');
define('AUTH_COOKIE_EXPIRE', 24 * 60 * 60);
define('AUTH_COOKIE_DOMAIN', DOMAIN);
define('DEFAULT_MINER_FEE', 1000);
Example #9
0
function query_count($count_query) {
	$return = mysqli_query(Gbl::get('db'), $count_query); 
	return(mysqli_num_rows($return));
}
Example #10
0
 public function sendGroupMessage()
 {
     // send a normal group message
     $textGroupMessage = new TextGroupChatPacket();
     $textGroupMessage->setFrom($this->userId);
     $textGroupMessage->setGroupId(Gbl::getRandomUserId());
     $textGroupMessage->setSendToAll();
     $textGroupMessage->setText('everybody is ok?汉字[ID:' . rand(1000, 9999) . ']');
     $this->send($this->serializePacket($textGroupMessage));
     // send to friend
     $textGroupMessage = new TextGroupChatPacket();
     $textGroupMessage->setFrom($this->userId);
     $textGroupMessage->setGroupId($this->groupId);
     $textGroupMessage->setTo(Gbl::getRandomUserId());
     $textGroupMessage->setText('is ok, friend?表情[ID:' . rand(1000, 9999) . ']');
     $this->send($this->serializePacket($textGroupMessage));
 }