Esempio n. 1
0
 public function create($group_id = 2)
 {
     // Initialize
     global $template, $config;
     // Validate profile
     $this->validate_profile();
     if ($template->has_errors == 1) {
         return 0;
     }
     // Set variables
     $reg_ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
     $full_name = isset($_POST['full_name']) ? $_POST['full_name'] : '';
     // Get custom fields
     $custom_fields = array();
     $rows = DB::query("SELECT * FROM users_custom_fields ORDER BY id");
     foreach ($rows as $row) {
         $var = 'custom' . $row['id'];
         if (!isset($_POST[$var])) {
             continue;
         }
         $custom_fields[$var] = $_POST[$var];
     }
     // Add to DB
     DB::insert('users', array('username' => $_POST['username'], 'full_name' => $full_name, 'email' => $_POST['email'], 'password' => '*', 'group_id' => $group_id, 'reg_ip' => $reg_ip, 'custom_fields' => serialize($custom_fields)));
     $this->userid = DB::insertId();
     // Update password
     $client = new encrypt();
     $password = $client->get_password_hash($_POST['password'], $this->userid);
     DB::update('users', array('password' => $password), "id = %d", $this->userid);
     // Add alerts
     add_alert('new_user', $this->userid);
     // Execute hooks
     execute_hooks('new_user', $this->userid);
     // Return
     return $this->userid;
 }
Esempio n. 2
0
<?php

if (isset($sn_page_name) || ($sn_page_name = isset($_GET['page']) ? trim(strip_tags($_GET['page'])) : '')) {
    require_once 'common.' . substr(strrchr(__FILE__, '.'), 1);
    // pdump($sn_mvc);
    if ($sn_page_name) {
        // Loading page-specific language files
        global $template;
        isset($sn_mvc['model'][$sn_page_name]) and execute_hooks($sn_mvc['model'][$sn_page_name], $template);
        isset($sn_mvc['view'][$sn_page_name]) and execute_hooks($sn_mvc['view'][$sn_page_name], $template);
        /*
            if($sn_mvc['model'][$sn_page_name]) {
              foreach($sn_mvc['model'][$sn_page_name] as $hook) {
                if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) {
                  call_user_func($hook_call);
                }
              }
            }
        
            if($sn_mvc['view'][$sn_page_name]) {
              foreach($sn_mvc['view'][$sn_page_name] as $hook) {
                if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) {
                  $template = call_user_func($hook_call, $template);
                }
              }
            }
        */
        if (!empty($template_result) && is_object($template)) {
            $template->assign_recursive($template_result);
        }
        display($template);
 /**
  * @override
  */
 function WdfRenderAsRoot()
 {
     if (!hook_already_fired(HOOK_PRE_RENDER)) {
         execute_hooks(HOOK_PRE_RENDER, array($this));
     }
     return $this->WdfRender();
 }
Esempio n. 4
0
function sn_display($page, $title = '', $topnav = true, $metatags = '', $AdminPage = false, $isDisplayMenu = true, $die = true)
{
    global $link, $debug, $user, $user_impersonator, $planetrow, $config, $lang, $template_result, $sn_mvc;
    if (!$user || !isset($user['id']) || !is_numeric($user['id'])) {
        $isDisplayMenu = false;
        $topnav = false;
    }
    //  $template->assign_recursive($template_result);
    $isDisplayMenu = is_object($page) && isset($page->_rootref['MENU']) ? $page->_rootref['MENU'] : $isDisplayMenu;
    $topnav = is_object($page) && isset($page->_rootref['NAVBAR']) ? $page->_rootref['NAVBAR'] : $topnav;
    $title = $title ? $title : (is_object($page) && isset($page->_rootref['PAGE_HEADER']) ? $page->_rootref['PAGE_HEADER'] : '');
    if (is_object($page) && !isset($page->_rootref['PAGE_HEADER']) && $title) {
        $page->assign_var('PAGE_HEADER', $title);
    }
    isset($sn_mvc['view']['']) and execute_hooks($sn_mvc['view'][''], $page);
    // Global header
    $user_time_diff = user_time_diff_get();
    $user_time_measured_unix = intval(isset($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) ? strtotime($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) : 0);
    $player_options = player_load_option($user);
    $template = gettemplate('_global_header', true);
    $template->assign_vars(array('USER_AUTHLEVEL' => intval($user['authlevel']), 'TIME_NOW' => SN_TIME_NOW, 'LOGIN_LOGOUT' => defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true, 'GAME_MODE_CSS_PREFIX' => $config->game_mode == GAME_BLITZ ? 'blitz_' : '', 'TIME_DIFF_MEASURE' => intval(empty($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) && (SN_TIME_NOW - $user_time_measured_unix > PERIOD_HOUR || $user_time_diff[PLAYER_OPTION_TIME_DIFF] == '')), 'title' => ($title ? "{$title} - " : '') . "{$lang['sys_server']} {$config->game_name} - {$lang['sys_supernova']}", '-meta-' => $metatags, 'ADV_SEO_META_DESCRIPTION' => $config->adv_seo_meta_description, 'ADV_SEO_META_KEYWORDS' => $config->adv_seo_meta_keywords, 'ADV_SEO_JAVASCRIPT' => $config->adv_seo_javascript, 'LANG_LANGUAGE' => $lang['LANG_INFO']['LANG_NAME_ISO2'], 'LANG_ENCODING' => 'utf-8', 'LANG_DIRECTION' => $lang['LANG_INFO']['LANG_DIRECTION'], 'SOUND_ENABLED' => $player_options[PLAYER_OPTION_SOUND_ENABLED], 'IMPERSONATING' => $user_impersonator ? sprintf($lang['sys_impersonated_as'], $user['username'], $user_impersonator['username']) : ''));
    $template->assign_recursive($template_result);
    displayP(parsetemplate($template));
    if ($isDisplayMenu && !isset($_COOKIE['menu_disable'])) {
        $AdminPage = $AdminPage ? $user['authlevel'] : 0;
        displayP(parsetemplate(tpl_render_menu($AdminPage)));
    }
    if ($topnav) {
        displayP(parsetemplate(tpl_render_topnav($user, $planetrow)));
    }
    displayP(parsetemplate(gettemplate('_content_header', true)));
    if (!is_array($page)) {
        $page = array($page);
    }
    $result_added = false;
    foreach ($page as $page_item) {
        if (!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) {
            $page_item = gettemplate('_result_message', $page_item);
            $temp = $page_item->files['_result_message'];
            unset($page_item->files['_result_message']);
            $page_item->files = array_reverse($page_item->files);
            $page_item->files['_result_message'] = $temp;
            $page_item->files = array_reverse($page_item->files);
            $result_added = true;
        }
        displayP($page_item);
    }
    //  echo '</center>';
    if ($isDisplayMenu) {
        //    echo '</div>';
    }
    displayP(parsetemplate(gettemplate('_content_footer', true)));
    // Global footer
    $template = gettemplate('_global_footer', true);
    $template->assign_vars(array('ADMIN_EMAIL' => $config->game_adminEmail, 'TIME_NOW' => SN_TIME_NOW, 'SN_VERSION' => SN_VERSION));
    displayP(parsetemplate($template));
    $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;
    isset($link) ? sn_db_diconnect($link) : false;
    sn_benchmark();
    $die ? die($die === true ? 0 : $die) : false;
}
Esempio n. 5
0
/**
 * Terminats the current run.
 * 
 * Will be called from exception and error handlers. You may, call this directly, but we
 * recommend to throw an exception instead. See the WdfException class and it's Raise() method
 * for more about this.
 * Note: This function will call `die()`!
 * @param string $reason The reason as human readable and hopefully understandable text
 * @param string $additional_message More details to be logged
 * @return void
 */
function system_die($reason, $additional_message = '')
{
    if ($reason instanceof Exception) {
        $stacktrace = $reason instanceof WdfException ? $reason->getTraceEx() : $reason->getTrace();
        $reason = logging_render_var($reason);
    }
    if (!isset($stacktrace)) {
        $stacktrace = debug_backtrace();
    }
    if (isset($GLOBALS['system']['hooks'][HOOK_SYSTEM_DIE]) && count($GLOBALS['system']['hooks'][HOOK_SYSTEM_DIE]) > 0) {
        execute_hooks(HOOK_SYSTEM_DIE, array($reason, $stacktrace));
    }
    if (system_is_ajax_call()) {
        $res = AjaxResponse::Error($reason . "\n" . $additional_message, true);
        die($res->Render());
        //		$code = "alert(unescape(".json_encode($reason."\n".$additional_message)."));";
        //		$res = new stdClass();
        //		$res->html = "<script>$code</script>";
        //		die(system_to_json($res));
    } else {
        $stacktrace = system_stacktrace_to_string($stacktrace);
        $res = "<html><head><title>Fatal system error</title></head>";
        $res .= "<body>";
        $res .= "<h1>Fatal system error occured</h1>";
        if (isDev()) {
            $res .= "<pre>{$reason}</pre><pre>{$additional_message}</pre><pre>" . $stacktrace . "</pre>";
        } else {
            $res .= "Fatal System Error occured.<br/>Please try again.<br/>Contact our technical support if this problem occurs again.<br/><br/>Apologies for any inconveniences this may have caused you.";
        }
        $res .= "</body></html>";
        die($res);
    }
}
Esempio n. 6
0
 /**
  * @override
  */
 function WdfRenderAsRoot()
 {
     execute_hooks(HOOK_PRE_RENDER, array($this));
     $init_data = $this->wdf_settings;
     $init_data['request_id'] = request_id();
     $init_data['site_root'] = cfg_get('system', 'url_root');
     if (cfg_getd('system', 'attach_session_to_ajax', false)) {
         $init_data['session_id'] = session_id();
         $init_data['session_name'] = session_name();
     }
     if (isDevOrBeta()) {
         $init_data['log_to_console'] = true;
     }
     if ($GLOBALS['CONFIG']['system']['ajax_debug_argument']) {
         $init_data['log_to_server'] = $GLOBALS['CONFIG']['system']['ajax_debug_argument'];
     }
     $this->set("wdf_init", "wdf.init(" . json_encode($init_data) . ");");
     $this->set("docready", $this->docready);
     $this->set("plaindocready", $this->plaindocready);
     return parent::WdfRenderAsRoot();
 }
Esempio n. 7
0
 public function check_unconfirmed()
 {
     // Initialize
     global $config;
     // Go through inputs
     $rows = DB::query("SELECT * FROM coin_inputs WHERE is_confirmed = 0 AND confirmations >= %d", $config['btc_minconf']);
     foreach ($rows as $row) {
         DB::query("UPDATE coin_inputs SET is_confirmed = 1 WHERE id = %d", $row['id']);
         execute_hooks('confirmed_deposit', $row['id']);
     }
 }
Esempio n. 8
0
    // Process transaction, if ok
    if ($template->has_errors != 1) {
        // Update db
        DB::update('coin_sends', array('status' => 'sent', 'txid' => $txid), "id = %d", $_POST['send_id']);
        // Mark inputs as spent
        $input_ids = explode(",", $_POST['input_ids']);
        foreach ($input_ids as $input_id) {
            if (!$input_id > 0) {
                continue;
            }
            DB::query("UPDATE coin_inputs SET is_spent = 1, is_locked = 0 WHERE id = %d", $input_id);
        }
        // Send notifications
        send_notifications('funds_sent', $_POST['send_id']);
        // Execute hooks
        execute_hooks('funds_sent', $_POST['send_id']);
        // User message
        $template->add_message("Successfully broadcast transaction, TxID {$txid}");
    }
}
// Initialize
$bip32 = new bip32();
// Get wallets
$first = true;
$bip32_key_fields = '';
$required_sigs = 0;
$wallet_id = 0;
$wallet_javascript = '';
$wallet_options = '';
$rows = DB::query("SELECT * FROM coin_wallets WHERE status = 'active' ORDER BY display_name");
foreach ($rows as $row) {
Esempio n. 9
0
if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
    if (defined('IN_API')) {
        return;
    }
    $bantime = date(FMT_DATE_TIME, $template_result[F_BANNED_STATUS]);
    // TODO: Add ban reason. Add vacation time. Add message window
    sn_sys_logout(false, true);
    message("{$lang['sys_banned_msg']} {$bantime}", $lang['ban_title']);
    die("{$lang['sys_banned_msg']} {$bantime}");
}
$template_result[F_USER_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
// !!! Просто $allow_anonymous используется в платежных модулях !!!
$allow_anonymous = $allow_anonymous || isset($sn_page_data['allow_anonymous']) && $sn_page_data['allow_anonymous'];
if (!$allow_anonymous && !$sys_user_logged_in) {
    sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
    sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
}
$user_time_diff = user_time_diff_get();
//defined('SN_CLIENT_TIME_DIFF_SECONDS') or define('SN_CLIENT_TIME_DIFF_SECONDS', $user_time_diff[PLAYER_OPTION_TIME_DIFF]);
//defined('SN_CLIENT_TIME_UTC_OFFSET') or define('SN_CLIENT_TIME_UTC_OFFSET', $user_time_diff[PLAYER_OPTION_TIME_DIFF_UTC_OFFSET]);
//$time_diff = SN_CLIENT_TIME_DIFF_SECONDS + SN_CLIENT_TIME_UTC_OFFSET;
//defined('SN_CLIENT_TIME_DIFF') or define('SN_CLIENT_TIME_DIFF', $time_diff);
//defined('SN_CLIENT_TIME_LOCAL') or define('SN_CLIENT_TIME_LOCAL', SN_TIME_NOW + SN_CLIENT_TIME_DIFF);
global $time_diff;
define('SN_CLIENT_TIME_DIFF', $time_diff = $user_time_diff[PLAYER_OPTION_TIME_DIFF] + $user_time_diff[PLAYER_OPTION_TIME_DIFF_UTC_OFFSET]);
define('SN_CLIENT_TIME_LOCAL', SN_TIME_NOW + SN_CLIENT_TIME_DIFF);
!empty($user) && sys_get_param_id('only_hide_news') ? die(nws_mark_read($user)) : false;
!empty($user) && sys_get_param_id('survey_vote') ? die(survey_vote($user)) : false;
lng_load_i18n($sn_mvc['i18n'][$sn_page_name]);
execute_hooks($sn_mvc['model'][''], $template);
Esempio n. 10
0
/**
 * @param template|string $page
 * @param string          $title
 * @param bool|true       $isDisplayTopNav
 * @param string          $metatags
 * @param bool|false      $AdminPage
 * @param bool|true       $isDisplayMenu
 * @param bool|int|string $exitStatus - Код или сообщение выхода
 */
function sn_display($page, $title = '', $isDisplayTopNav = true, $metatags = '', $isDisplayMenu = true, $exitStatus = true)
{
    global $debug, $user, $planetrow, $config, $lang, $template_result, $sn_mvc, $sn_page_name;
    //  $isDisplayMenu = is_object($page) && isset($page->_rootref['MENU']) ? $page->_rootref['MENU'] : $isDisplayMenu;
    //  $topnav = is_object($page) && isset($page->_rootref['NAVBAR']) ? $page->_rootref['NAVBAR'] : $topnav;
    //  $title = $title ? $title : (is_object($page) && isset($page->_rootref['PAGE_HEADER']) ? $page->_rootref['PAGE_HEADER'] : '');
    //  if(is_object($page) && !isset($page->_rootref['PAGE_HEADER']) && $title) {
    //    $page->assign_var('PAGE_HEADER', $title);
    //  }
    if (is_object($page)) {
        isset($page->_rootref['MENU']) ? $isDisplayMenu = $page->_rootref['MENU'] : false;
        isset($page->_rootref['NAVBAR']) ? $isDisplayTopNav = $page->_rootref['NAVBAR'] : false;
        !$title && !empty($page->_rootref['PAGE_HEADER']) ? $title = $page->_rootref['PAGE_HEADER'] : false;
        !isset($page->_rootref['PAGE_HEADER']) && $title ? $page->assign_var('PAGE_HEADER', $title) : false;
    }
    if (empty($user['id']) || !is_numeric($user['id'])) {
        $isDisplayMenu = false;
        $isDisplayTopNav = false;
    }
    isset($sn_mvc['view']['']) and execute_hooks($sn_mvc['view'][''], $page);
    // Global header
    $user_time_diff = playerTimeDiff::user_time_diff_get();
    $user_time_measured_unix = intval(isset($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) ? strtotime($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) : 0);
    $font_size = !empty($_COOKIE[SN_COOKIE_F]) ? $_COOKIE[SN_COOKIE_F] : classSupernova::$user_options[PLAYER_OPTION_BASE_FONT_SIZE];
    if (strpos($font_size, '%') !== false) {
        // Размер шрифта в процентах
        $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%';
    } elseif (strpos($font_size, 'px') !== false) {
        // Размер шрифта в пикселях
        $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px';
    } else {
        // Не мышонка, не лягушка...
        $font_size = FONT_SIZE_PERCENT_DEFAULT_STRING;
    }
    $template = gettemplate('_global_header', true);
    if (!empty($sn_mvc['javascript'])) {
        foreach ($sn_mvc['javascript'] as $page_name => $script_list) {
            if (empty($page_name) || $page_name == $sn_page_name) {
                foreach ($script_list as $filename => $content) {
                    $template->assign_block_vars('javascript', array('FILE' => $filename, 'CONTENT' => $content));
                }
            }
        }
    }
    $template->assign_vars(array('USER_AUTHLEVEL' => intval($user['authlevel']), 'FONT_SIZE' => $font_size, 'FONT_SIZE_PERCENT_DEFAULT_STRING' => FONT_SIZE_PERCENT_DEFAULT_STRING, 'SN_TIME_NOW' => SN_TIME_NOW, 'LOGIN_LOGOUT' => defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true, 'GAME_MODE_CSS_PREFIX' => $config->game_mode == GAME_BLITZ ? 'blitz_' : '', 'TIME_DIFF_MEASURE' => intval(empty($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) && (SN_TIME_NOW - $user_time_measured_unix > PERIOD_HOUR || $user_time_diff[PLAYER_OPTION_TIME_DIFF] == '')), 'title' => ($title ? "{$title} - " : '') . "{$lang['sys_server']} {$config->game_name} - {$lang['sys_supernova']}", '-meta-' => $metatags, 'ADV_SEO_META_DESCRIPTION' => $config->adv_seo_meta_description, 'ADV_SEO_META_KEYWORDS' => $config->adv_seo_meta_keywords, 'ADV_SEO_JAVASCRIPT' => $config->adv_seo_javascript, 'LANG_LANGUAGE' => $lang['LANG_INFO']['LANG_NAME_ISO2'], 'LANG_ENCODING' => 'utf-8', 'LANG_DIRECTION' => $lang['LANG_INFO']['LANG_DIRECTION'], 'SOUND_ENABLED' => classSupernova::$user_options[PLAYER_OPTION_SOUND_ENABLED], 'PLAYER_OPTION_ANIMATION_DISABLED' => classSupernova::$user_options[PLAYER_OPTION_ANIMATION_DISABLED], 'PLAYER_OPTION_PROGRESS_BARS_DISABLED' => classSupernova::$user_options[PLAYER_OPTION_PROGRESS_BARS_DISABLED], 'IMPERSONATING' => !empty($template_result[F_IMPERSONATE_STATUS]) ? sprintf($lang['sys_impersonated_as'], $user['username'], $template_result[F_IMPERSONATE_OPERATOR]) : '', 'PLAYER_OPTION_DESIGN_DISABLE_BORDERS' => classSupernova::$user_options[PLAYER_OPTION_DESIGN_DISABLE_BORDERS]));
    $template->assign_recursive($template_result);
    displayP(parsetemplate($template));
    if ($isDisplayMenu && !isset($_COOKIE['menu_disable'])) {
        // $AdminPage = $AdminPage ? $user['authlevel'] : 0;
        displayP(parsetemplate(tpl_render_menu()));
    }
    if ($isDisplayTopNav) {
        displayP(parsetemplate(tpl_render_topnav($user, $planetrow)));
    }
    displayP(parsetemplate(gettemplate('_content_header', true)));
    !is_array($page) ? $page = array($page) : false;
    $result_added = false;
    foreach ($page as $page_item) {
        if (!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) {
            $page_item = gettemplate('_result_message', $page_item);
            $temp = $page_item->files['_result_message'];
            unset($page_item->files['_result_message']);
            $page_item->files = array_reverse($page_item->files);
            $page_item->files['_result_message'] = $temp;
            $page_item->files = array_reverse($page_item->files);
            $result_added = true;
        }
        displayP($page_item);
    }
    displayP(parsetemplate(gettemplate('_content_footer', true)));
    // Global footer
    $template = gettemplate('_global_footer', true);
    $template->assign_vars(array('ADMIN_EMAIL' => $config->game_adminEmail, 'SN_TIME_NOW' => SN_TIME_NOW, 'SN_VERSION' => SN_VERSION));
    displayP(parsetemplate($template));
    $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;
    sn_db_disconnect();
    $exitStatus and die($exitStatus === true ? 0 : $exitStatus);
}