/* v.3.8 */
if (!defined('IN_ADMIN'))
{
mail("admin@steindev.de", "Script without IN_ADMIN defined", $_SERVER["SCRIPT_NAME"]);
die("Error. Admin-Status not defined. System-Administrator notified. Sorry for inconveniences!");
}
$mtime = explode(' ',microtime());
$starttime = $mtime[1] + $mtime[0];
ob_start();
//$assigned_index = 0;
$err_msg = '';
$info_msg = '';
unset($loc);
unset($loc_conf);
$S = array();
$U = array();
$BC = array('num_perview'=>1, 'num_perclick'=>2, 'explicit'=>'');
$SS_ARR = array(''=>'Normal', 'adm/'=>'Admin');
$PG = array();
$CONTENT_TYPES = array();
if(!isset($p_group))
{
$p_group = '';
}
if(!isset($p_color))
{
$p_color = '';
}
$p_title = '';
//error_reporting (E_ALL);
include($root_path.'../inc/bon_config.php');
include($root_path.'../inc/'.$DB['dbms'].'.php');
open_db();
// Get configuration data into $C
$db->sql_query("SELECT * FROM sites WHERE id = ".CURR_SITE);
if($db->sql_numrows() != 1)
{
die("Error: SITE not defined correctly");
}
$SITE = $db->sql_fetchrow();
$C = unserialize($SITE['config']);
unset($SITE['config']);
$php_x = $C['php_x'];
$db->sql_query("SELECT SUM(id) as all_sites FROM sites");
$result = $db->sql_fetchrow();
define('ALL_SITES', $result['all_sites']);
// Prepare language data
$C = array_merge($C, $C_LANGS);
$CORR_LANGS = $C['CORR_LANGS'];
$PUBLIC_LANGS = $C['PUBLIC_LANGS'];
$ADMIN_LANGS = $C['ADMIN_LANGS'];
$MOD_LANGS = $C['MOD_LANGS'];
$all_mod_langs = 0;
foreach($MOD_LANGS as $key=>$elem) $all_mod_langs += $key;
if (IN_ADMIN == 'adm/')
{
// INSTALLED LANGUAGES (Binary system: 1, 2, 4, 8, etc.
unset($lang);
unset($lang_id);
$LANG_ARR = $ADMIN_LANGS;
$lang_pref_id = 1; // 'German' as preferred language
$all_langs = 0;
foreach($LANG_ARR as $key=>$elem)
{
$all_langs += $key;
}
}
else
{
// INSTALLED LANGUAGES (Binary system: 1, 2, 4, 8, etc.
unset($lang);
unset($lang_id);
$LANG_ARR = $PUBLIC_LANGS;
$lang_pref_id = 1; // 'deutsch' as preferred language
$all_langs = 0;
foreach($LANG_ARR as $key=>$elem)
{
$all_langs += $key;
}
}
include($root_path.'../inc/func_global.php');
if(IN_ADMIN == 'adm/')
{
include($root_path.'../inc/func_adm.php');
}
else
{
include($root_path.'../inc/func_spec.php');
}
$cl = new client_info();
include($root_path.'../inc/bon_template.php');
include($root_path.'../inc/'.IN_ADMIN.'session.php');
include($root_path.'../inc/tfcode.php');
// get script information
if(!$script_index)
{
log_hacking("No script_index. Die.");
die();
}
$db->sql_query("SELECT * FROM thr_script_index WHERE id = '".(int)$script_index."'");
if(!$SCRIPT = $db->sql_fetchrow())
{
err_die("No such script_index in database: ".(int)$script_index);
}
$p_group = $SCRIPT['p_group'];
$p_color = $SCRIPT['color'];
// Check, if user came through valid affiliate subdomain
$check_host = preg_replace("/\.[\w-]+\.[a-z]{2,4}$/i", '', $_SERVER['HTTP_HOST']);
if($check_host && $check_host != 'www')
{
$check_host = addslashes($check_host);
$q = "SELECT id, activated FROM users WHERE username = '$check_host' AND rank >= 11";
$db->sql_query($q);
if($db->sql_numrows() > 0)
{
$result = @$db->sql_fetchrow();
if($result['activated']=='1')
{
header("Location: ".$C['site_root']."start.html?host=".urlencode($check_host));
}
else
{
header("Location: ".$C['site_root']."start.html");
}
die();
}
}
$settings_changed = false;
if(isset($C['common_spec_1']))
{
include($root_path.'../inc/spec/'.preg_replace("/\/|(\.\.)/", '', $C['common_spec_1']));
}
user_session();
// user-settings overwrite $C
// receive messages from previous page, if any
if(isset($_SESSION['info_msg']))
{
$info_msg = $_SESSION['info_msg'];
unset($_SESSION['info_msg']);
}
if(isset($_SESSION['err_msg']))
{
$err_msg = $_SESSION['err_msg'];
unset($_SESSION['err_msg']);
}
check_auth();
/*
* Retrieve User Settings and other information from long lastin cookie, if set
*/
if(isset($_COOKIE[IN_ADMIN.'settings']) && !isset($SETTINGS))
{
$SETTINGS = unserialize(stripslashes($_COOKIE[IN_ADMIN.'settings']));
$SETTINGS = is_array($SETTINGS) ? $SETTINGS : array();
}
if(!isset($_SESSION['size']))
{
$_SESSION['size'] = isset($SETTINGS['size']) ? ($SETTINGS['size'] == 'b' ? 'b' : 's') : 's';
}
if(!isset($_SESSION['host']))
{
if(isset($_GET['host']))
{
if(is_numeric($_GET['host']))
{
$q = "SELECT id FROM users WHERE id = '".$_GET['host']."' AND rank >= 11";
}
else
{
$q = "SELECT id FROM users WHERE username = '".strtolower(addslashes($_GET['host']))."' AND rank >= 11";
}
$db->sql_query($q);
$result = $db->sql_fetchrow();
if(isset($result['id']))
{
$U['host'] = $result['id'];
$SETTINGS['host'] = $result['id'];
$_SESSION['host'] = $result['id'];
$settings_changed = true;
}
else
{
log_hacking("User tried to use not existing host.");
$U['host'] = 1;
$_SESSION['host'] = 1;
}
}
else
{
if(isset($SETTINGS['host'])) // Okay, we trust this cookie so far to avoid db-access on each page
{
$U['host'] = $SETTINGS['host'];
$_SESSION['host'] = $SETTINGS['host'];
}
else
{
$U['host'] = 1;
$_SESSION['host'] = 1;
}
}
}
else
{
$U['host'] = $_SESSION['host'];
}
/***************** ADMIN CHEATS ***********************/
/*if(isset($_GET['admin_open']))
{
$_SESSION['admin_open'] = true;
}
if(!$_SESSION['admin_open'])
{
echo "
Wegen Datenbank-Umstellungen vorübergehend geschlossen.";
die();
}*/
if(isset($_GET['dp_host']))
{
$q = "SELECT id, p_username, firstname, lastname FROM users WHERE id = '{$U['host']}'";
$db->sql_query($q);
if($db->sql_numrows()>0)
{
$result = $db->sql_fetchrow();
echo "*** Assigned to Associate No. {$result['id']} ({$result['firstname']} {$result['lastname']} / Username: {$result['p_username']}) ***
\n\n";
}
}
if(isset($_GET['dp_sessid']))
{
echo "*** SESSID: $sessid";
}
// Set this GET-parameter to 'yes', if you want to see user front end
// with a language that is actually not in $PUBLIC_LANGS
if(isset($_GET['check_langs']))
{
if($_GET['check_langs'] == 'yes')
{
$_SESSION['check_langs'] = true;
}
else
{
unset($_SESSION['check_langs']);
}
}
if(isset($_SESSION['check_langs']))
{
$LANG_ARR = $MOD_LANGS;
$all_langs = 0;
foreach($LANG_ARR as $key=>$elem)
{
$all_langs += $key;
}
}
if(isset($_GET['debug_mode']))
{
if($_GET['debug_mode'] != 'off')
{
$_SESSION['debug_mode'] = true;
}
else
{
unset($_SESSION['debug_mode']);
}
}
if($_SESSION['debug_mode'])
{
echo "SESS_ID: $sessid User: ".(int)$U['id'];
}
if(isset($_GET['dp_settings']))
{
var_dump($SETTINGS);
}
/****************** END ADMIN CHEATS **********************/
// catch switch lang order
if(isset($_GET['switch_lang']))
{
$_SESSION[IN_ADMIN.'lang_id'] = $SETTINGS[IN_ADMIN.'lang_id'] = $_SESSION[IN_ADMIN.'lang_id'] == 2 ? 1 : 2;
$settings_changed = true;
}
if(isset($_GET['lang_id']) && isset($LANG_ARR[(int)$_GET['lang_id']]))
{
$_SESSION[IN_ADMIN.'lang_id'] = (int)$_GET['lang_id'];
$SETTINGS[IN_ADMIN.'lang_id'] = (int)$_GET['lang_id'];
$settings_changed = true;
}
elseif( isset($_GET['lang_id']) && isset($lang_id_transform[$_GET['lang_id']]) )
{
$_SESSION['lang_id'] = $lang_id_transform[$_GET['lang_id']];
$SETTINGS['lang_id'] = $lang_id_transform[$_GET['lang_id']];
$settings_changed = true;
}
if(isset($_GET['unset_loc']))
{
unset($_SESSION['loc']);
unset($SETTINGS[IN_ADMIN.'loc']);
$settings_changed = true;
}
if(isset($_GET['loc']))
{
$db->sql_query("SELECT id, pref_lang FROM locations");
while($row = $db->sql_fetchrow())
{
$LOC_ARR[$row['id']] = $row['pref_lang'];
}
if(isset($LOC_ARR[$_GET['loc']]))
{
$_SESSION['loc'] = $_GET['loc'];
$SETTINGS[IN_ADMIN.'loc'] = $_GET['loc'];
$settings_changed = true;
}
}
if(isset($_GET['switch_size']))
{
$_SESSION['size'] = $_SESSION['size'] == 's' ? 'b' : 's';
}
if(isset($C['common_spec_2']))
{
include($root_path.'../inc/spec/'.preg_replace("/\/|(\.\.)/", '', $C['common_spec_2']));
}
// choose current language language
get_lang();
if(isset($_GET['unset_loc']))
{
unset($_SESSION['loc']);
unset($SETTINGS[IN_ADMIN.'loc']);
$settings_changed = true;
}
if(!isset($_GET['noforward']) && $lang_id > 1 && !IN_ADMIN)
{
header( "HTTP/1.1 301 Moved Permanently" );
header("Location: http://www.shadow-electronics.com/index.php");
die();
}
if(isset($_GET['loc']))
{
$db->sql_query("SELECT id, pref_lang FROM locations");
while($row = $db->sql_fetchrow())
{
$LOC_ARR[$row['id']] = $row['pref_lang'];
}
if(isset($LOC_ARR[$_GET['loc']]))
{
$_SESSION['loc'] = $_GET['loc'];
$SETTINGS[IN_ADMIN.'loc'] = $_GET['loc'];
$settings_changed = true;
}
}
$loc = isset($_SESSION['loc']) ? $_SESSION['loc'] : '';
if(!$LOC && $loc)
{
$q = "SELECT l.id as loc, l.pref_lang, l.conf, l.currency AS loc_currency,
c.name AS conf_name, c.pref_lang AS conf_pref_lang, c.currency
FROM locations l
LEFT JOIN location_conf c ON c.id = l.conf
WHERE l.id ='$curr_loc'";
if ($db->sql_query($q) )
{
$result = $db->sql_fetchrow();
$LOC = $result;
}
}
// get serialized language data from DB into global array $L
$q = "SELECT serialized_data FROM thr_serialized WHERE id = '$script_index' AND lang_id = '$lang_id' AND site='".CURR_SITE."'";
$db->sql_query($q);
$row = $db->sql_fetchrow();
$L = unserialize($row['serialized_data']);
$SM = unserialize($L['SM']);
// Load function depending on current language
if(file_exists($root_path.'lang/'.$lang.'/func.php'))
{
include($root_path.'lang/'.$lang.'/func.php');
}
// initiate template class
$tpl = new bontpl($root_path);
// if not set, set to false
if(!isset($_SESSION['js_enabled']))
{
$_SESSION['js_enabled'] = false;
}
// get global $SYSTEM_STATUS
$db->sql_query("SELECT * FROM z_system_status WHERE status_time = 1");
$SYSTEM_STATUS = $db->sql_fetchrow();
if(isset($C['common_spec_3']))
{
include($root_path.'../inc/spec/'.preg_replace("/\/|(\.\.)/", '', $C['common_spec_3']));
}
?>