registerErrorHandler(); } } else { ini_set('display_errors', FALSE); error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE & ~E_WARNING ); ini_set("error_log", "bwadmin/errors.txt"); } // BENCHMARK include "include/class_benchmark.php"; $_benchmark = SEBenchmark::getInstance('default'); SE_DEBUG ? $_benchmark->start('total') : NULL; SE_DEBUG ? $_benchmark->start('include') : NULL; // INITIATE SMARTY include "include/class_smarty.php"; $smarty =& SESmarty::getInstance(); //$smarty->debugging = TRUE; // INCLUDE DATABASE INFORMATION include "include/database_config.php"; // INCLUDE CLASS/FUNCTION FILES include "include/functions_file.php"; include "include/cache/cache.php"; include "include/cache/storage.php"; include "include/session/session.php"; include "include/session/storage.php"; // INCLUDE CACHE/SESSION //include "include/cake/config.php"; include "include/class_core.php"; include "include/class_admin.php"; include_once("include/class_database-new.php"); include "include/class_datetime.php"; include "include/class_comment.php"; include "include/class_field.php"; include "include/class_hook.php"; include "include/class_language.php"; include "include/class_notify.php"; include "include/class_upload.php"; include "include/class_user.php"; include "include/class_url.php"; include "include/class_misc.php"; //include "include/class_ads.php"; include "include/class_actions.php"; include "include/functions_general.php"; include "include/functions_email.php"; include "include/functions_stats.php"; // JS API MOD JSON FUNCTIONS include "include/class_javascript.php"; if(!function_exists('json_encode')) { include_once "include/xmlrpc/xmlrpc.inc"; include_once "include/xmlrpc/xmlrpcs.inc"; include_once "include/xmlrpc/xmlrpc_wrappers.inc"; include_once "include/jsonrpc/jsonrpc.inc"; include_once "include/jsonrpc/jsonrpcs.inc"; include_once "include/jsonrpc/json_extension_api.inc"; } SE_DEBUG ? $_benchmark->end('include') : NULL; SE_DEBUG ? $_benchmark->start('initialization') : NULL; // INITIATE DATABASE CONNECTION $database =& SEDatabase::getInstance(); // Use this line if you changed the way database connection is loaded //$database = new SEDatabase($database_host, $database_username, $database_password, $database_name); // SET DATABASE CONSTANTS $database->database_query("SET @SE_PRIVACY_SELF = 1, @SE_PRIVACY_FRIEND = 2, @SE_PRIVACY_FRIEND2 = 4, @SE_PRIVACY_SUBNET = 8, @SE_PRIVACY_REGISTERED = 16, @SE_PRIVACY_ANONYMOUS = 32"); // SET LANGUAGE CHARSET $database->database_set_charset(SE_Language::info('charset')); // GET SETTINGS $setting =& SECore::getSettings(); // CREATE URL CLASS $url = new SEUrl(); // CREATE DATETIME CLASS $datetime = new se_datetime(); // CREATE MISC CLASS $misc = new se_misc(); // ENSURE NO SQL INJECTIONS THROUGH POST OR GET ARRAYS $_POST = security($_POST); $_GET = security($_GET); $_COOKIE = security($_COOKIE); // CREATE SESSION $session_options = ( defined('SE_SESSION_RESUME') && !empty($session_id) ? array('id' => $session_id, 'security' => array()) : array() ); $session =& SESession::getInstance($session_options); if( $session->getState() == 'expired' || $session->getState() == 'error' ) { $session->restart(); } /* $session_options = @unserialize($setting['setting_session_options']); if( !empty($session_options) ) { if( !empty($session_options['storage']) ) Configure::write('Session.save', $session_options['storage']); if( !empty($session_options['name']) ) Configure::write('Session.cookie', $session_options['name']); if( !empty($session_options['expire']) ) Configure::write('Session.timeout', $session_options['expire']); } $session =& SESession::getInstance(null, true); $session->engine(@$session_options['storage'], $session_options); if( defined('SE_SESSION_RESUME') && SE_SESSION_RESUME && isset($session_id) ) { $session->_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt')); $session->id($session_id); } $session->start(); // CREATE CACHE OBJECT $cache =& SECache::getInstance(); if( !empty($setting['setting_cache_enabled']) && !empty($setting['setting_cache_default']) ) { $config = array(); $config['engine'] = ucfirst($setting['setting_cache_default']); $config['duration'] = ( !empty($setting['setting_cache_lifetime']) ? $setting['setting_cache_lifetime'] : 3600 ); $config['prefix'] = 'se_'; $cache_options = @unserialize($setting['setting_cache_'.$setting['setting_cache_default'].'_options']); if( !$cache_options ) $cache_options = array(); if( $setting['setting_cache_default'] == 'file' ) { $config['path'] = ( !empty($cache_options['root']) ? $cache_options['root'] : SE_ROOT.DS.'cache' ); $config['lock'] = ( isset($cache_options['locking']) ? $cache_options['locking'] : false ); $config['serialize'] = true; if( !defined('CACHE') ) define('CACHE', $config['path']); } else if( $setting['setting_cache_default'] == 'memcache' ) { $config['servers'] = array(); foreach( $cache_options['servers'] as $server ) { $config['servers'][] = $server['host'].':'.$server['port']; } $config['compress'] = false; } SECache::config('default', $config); } */ // Check for expired captcha codes if( !empty($_SESSION['codes']) && is_array($_SESSION['codes']) ) foreach( $_SESSION['codes'] as $index => $info ) if( @$info['expires'] < time() ) unset($_SESSION['codes'][$index]); //session rate limiting if (isset($_SESSION['LAST_CALL'])) { $last = strtotime($_SESSION['LAST_CALL']); $curr = strtotime(date("Y-m-d h:i:s")); $sec = abs($curr-$last); if ($sec <= 1&&$_SESSION["ratecnt"]>10) { if($_SESSION["ratecnt"]>=10){echo "Sorry you are doing that too fast, please slow down.";exit;} if ($sec <= 1&&$_SESSION["ratecnt"]>50) { if($_SESSION["mailed"]!=1){ /*mail("leprakhauns2@lepslair.com", "WOAH RATE LIMIT 50", $_SESSION['LAST_CALL']." ".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]." ".$_SERVER["REMOTE_ADDR"]." ".$_SERVER['HTTP_USER_AGENT']); */ } $_SESSION["mailed"]=1; /*mail("leprakhauns2@lepslair.com", "WOAH RATE LIMIT MYSQL", "INSERT INTO ratelimiting SET date='".$_SESSION['LAST_CALL']."', addr='".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."', ip='".$_SERVER["REMOTE_ADDR"]."' browser='".$_SERVER['HTTP_USER_AGENT']."', time='".time()."'");*/ } $database->database_query("INSERT INTO ratelimiting SET `date`='".$_SESSION['LAST_CALL']."', addr='".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."', ip='".$_SERVER["REMOTE_ADDR"]."', browser='".$_SERVER['HTTP_USER_AGENT']."', `time`='".time()."', num='".$_SESSION["ratecnt"]."', referrer='".$_SERVER['HTTP_REFERER']."', `post`='".var_export($_POST, true)."'"); //$data = 'Rate Limit Exceeded'; // rate limit //header('Content-Type: application/json'); //die (json_encode($data)); } if($last!=$curr) { $_SESSION["ratecnt"]=0; $_SESSION["mailed"]=0; } } if(!isset($_SESSION["ratecnt"])){$_SESSION["ratecnt"]=0;} $_SESSION['LAST_CALL'] = date("Y-m-d h:i:s"); $_SESSION["ratecnt"]++; // CHECK FOR PAGE OWNER if(isset($_POST['user'])) { $user_username = $_POST['user']; } elseif(isset($_GET['user'])) { $user_username = $_GET['user']; } else { $user_username = ""; } if(isset($_POST['user_id'])) { $user_id = $_POST['user_id']; } elseif(isset($_GET['user_id'])) { $user_id = $_GET['user_id']; } else { $user_id = ""; } $owner = new SEUser(Array($user_id, $user_username)); // CREATE USER OBJECT AND ATTEMPT TO LOG USER IN $user = new SEUser(); $user->user_checkCookies(); // INSTANTIATE JAVASCRIPT OBJECT $se_javascript = new SE_Javascript(); // CREATE ADMIN OBJECT AND ATTEMPT TO LOG ADMIN IN $admin = new se_admin(); $admin->admin_checkCookies(); //SE_DEBUG ? $admin->admin_exists = true : null; // CANNOT ACCESS USER-ONLY AREA IF NOT LOGGED IN if( !$user->user_exists && substr($page, 0, 5) == "user_" ) { header("Location: login.php?return_url=".$url->url_current()); exit(); } // SET GLOBAL TIMEZONE $global_timezone = ( $user->user_exists ? $user->user_info['user_timezone'] : $setting['setting_timezone'] ); // SET UP LANGUAGE VARIABLES if( !empty($_GET['lang_id']) ) { $lang_id = NULL; if( $user->user_exists && $setting['setting_lang_allow'] ) { $lang_id = $user->user_info['user_language_id'] = (int)$_GET['lang_id']; $database->database_query("UPDATE se_users SET user_language_id='{$user->user_info['user_language_id']}' WHERE user_id='{$user->user_info['user_id']}' LIMIT 1"); } if( !$user->user_exists && $setting['setting_lang_anonymous'] ) { $lang_id = (int)$_GET['lang_id']; } if( $lang_id ) { setcookie('se_language_anonymous', $lang_id, time()+99999999, "/"); $_COOKIE['se_language_anonymous'] = $lang_id; } } SE_Language::select($user); if( SE_Language::info('language_setlocale') ) { $multi_language = 1; setlocale(LC_TIME, SE_Language::info('language_setlocale')); } header("Content-Language: ".SE_Language::info('language_code')); // CREATE ACTIONS CLASS $actions = new se_actions(); // CREATE NOTIFICATION CLASS $notify = new se_notify(); // CREATE ADS CLASS //$ads = new se_ads(); // Define SE_PAGE_AJAX in your page before the header include to not load ads or update page views if( !defined('SE_PAGE_AJAX') && ($page=="chat_frame" || $page=="chat_ajax" || $page=="misc_js" || $page=="ad") ) define('SE_PAGE_AJAX', TRUE); if( !defined('SE_PAGE_AJAX') ) { // UPDATE STATS TABLE update_stats("views"); // LOAD ADS //$ads->load(); } // CREATE GLOBAL CSS STYLES VAR (USED FOR CUSTOM USER-DEFINED PROFILE/PLUGIN STYLES) $global_css = ""; SE_DEBUG ? $_benchmark->end('initialization') : NULL; SE_DEBUG ? $_benchmark->start('plugins') : NULL; // INCLUDE RELEVANT PLUGIN FILES // AND SET PLUGIN HEADER TEMPLATES $show_menu_user = FALSE; $global_plugins =& SECore::getPlugins(); foreach( $global_plugins as $plugin_type=>$plugin_info ) { $plugin_vars = array(); if( file_exists("header_{$plugin_info['plugin_type']}.php") ) { include "header_{$plugin_info['plugin_type']}.php"; } // Set the hooks for each of the plugin templates if not using the new hooked template includes (backwards compatibility) if( empty($plugin_vars['uses_tpl_hooks']) ) { if( file_exists(SE_ROOT."/templates/header_{$plugin_info['plugin_type']}.tpl") ) $smarty->assign_hook('header', "header_{$plugin_info['plugin_type']}.tpl"); if( file_exists(SE_ROOT."/templates/footer_{$plugin_info['plugin_type']}.tpl") ) $smarty->assign_hook('footer', "footer_{$plugin_info['plugin_type']}.tpl"); if( !empty($plugin_vars['menu_main']) ) $smarty->assign_hook('menu_main', $plugin_vars['menu_main']); if( !empty($plugin_vars['menu_user']) ) $smarty->assign_hook('menu_user_apps', $plugin_vars['menu_user']); if( $page=="profile" && !empty($plugin_vars['menu_profile_side']) ) { $plugin_vars['menu_profile_side']['name'] = $plugin_info['plugin_type']; $smarty->assign_hook('profile_side', $plugin_vars['menu_profile_side']); } if( $page=="profile" && !empty($plugin_vars['menu_profile_tab']) ) { $plugin_vars['menu_profile_tab']['name'] = $plugin_info['plugin_type']; $smarty->assign_hook('profile_tab', $plugin_vars['menu_profile_tab']); } if( $page=="user_home" && !empty($plugin_vars['menu_userhome']) ) { $plugin_vars['menu_userhome']['name'] = $plugin_info['plugin_type']; $smarty->assign_hook('user_home', $plugin_vars['menu_userhome']); } } // If using the new template hooks, the header should also hook the styles sheets $global_plugins[$plugin_info['plugin_type']] =& $plugin_vars; if( !empty($plugin_vars['menu_user']) ) $show_menu_user = TRUE; unset($plugin_vars); } $global_plugins['plugin_controls'] = array('show_menu_user' => $show_menu_user); SE_DEBUG ? $_benchmark->end('plugins') : NULL; SE_DEBUG ? $_benchmark->start('page') : NULL; // CHECK TO SEE IF SITE IS ONLINE OR NOT, ADMIN NOT LOGGED IN, DISPLAY OFFLINE PAGE if( !$setting['setting_online'] && !$admin->admin_exists ) { $page = "offline"; include "footer.php"; } // CALL HEADER HOOK ($hook = SE_Hook::exists('se_header')) ? SE_Hook::call($hook, array()) : NULL; // CHECK IF LOGGED-IN USER IS ON OWNER'S BLOCKLIST if( $user->user_exists && $owner->user_exists && $owner->user_blocked($user->user_info['user_id']) ) { // ASSIGN VARIABLES AND DISPLAY ERROR PAGE $page = "error"; $smarty->assign('error_header', 639); $smarty->assign('error_message', 640); $smarty->assign('error_submit', 641); include "footer.php"; } // CHECK TO SEE IF USER HAS BEEN BLOCKED BY IP if( check_ip_in_banned_list($_SERVER['REMOTE_ADDR'], $setting['setting_banned_ips']) ) { // LOGOUT IF LOGGED IN if( $user->user_exists ) { $user->user_logout(); } // ASSIGN VARIABLES AND DISPLAY ERROR PAGE $page = "error"; $smarty->assign('error_header', 639); $smarty->assign('error_message', 807); $smarty->assign('error_submit', 641); include "footer.php"; } if(($user->user_exists&&$_SERVER['PHP_SELF']=="/home.php")||$_SERVER['PHP_SELF']=="/search.php") { $smarty->assign('bg', "/images/newimages/bg/background_main_v2.png"); $smarty->assign('himg',"http://b8world.com/bateimages/header_home.jpg"); $smarty->assign('htext',"/images/newimages/text/home_text.png"); } elseif($_SERVER['PHP_SELF']=="/login.php"||$_SERVER['PHP_SELF']=="/signup.php"||$_SERVER['PHP_SELF']=="/home.php") { if(!$user->user_exists) { function is_mobile() { // Get the user agent $user_agent = $_SERVER['HTTP_USER_AGENT']; // Create an array of known mobile user agents // This list is from the 21 October 2010 WURFL File. // Most mobile devices send a pretty standard string that can be covered by // one of these. I believe I have found all the agents (as of the date above) // that do not and have included them below. If you use this function, you // should periodically check your list against the WURFL file, available at: // http://wurfl.sourceforge.net/ $mobile_agents = Array( "240x320", "acer", "acoon", "acs-", "abacho", "ahong", "airness", "alcatel", "amoi", "android", "anywhereyougo.com", "applewebkit/525", "applewebkit/532", "asus", "audio", "au-mic", "avantogo", "becker", "benq", "bilbo", "bird", "blackberry", "blazer", "bleu", "cdm-", "compal", "coolpad", "danger", "dbtel", "dopod", "elaine", "eric", "etouch", "fly " , "fly_", "fly-", "go.web", "goodaccess", "gradiente", "grundig", "haier", "hedy", "hitachi", "htc", "huawei", "hutchison", "inno", "ipad", "ipaq", "ipod", "jbrowser", "kddi", "kgt", "kwc", "lenovo", "lg ", "lg2", "lg3", "lg4", "lg5", "lg7", "lg8", "lg9", "lg-", "lge-", "lge9", "longcos", "maemo", "mercator", "meridian", "micromax", "midp", "mini", "mitsu", "mmm", "mmp", "mobi", "mot-", "moto", "nec-", "netfront", "newgen", "nexian", "nf-browser", "nintendo", "nitro", "nokia", "nook", "novarra", "obigo", "palm", "panasonic", "pantech", "philips", "phone", "pg-", "playstation", "pocket", "pt-", "qc-", "qtek", "rover", "sagem", "sama", "samu", "sanyo", "samsung", "sch-", "scooter", "sec-", "sendo", "sgh-", "sharp", "siemens", "sie-", "softbank", "sony", "spice", "sprint", "spv", "symbian", "tablet", "talkabout", "tcl-", "teleca", "telit", "tianyu", "tim-", "toshiba", "tsm", "up.browser", "utec", "utstar", "verykool", "virgin", "vk-", "voda", "voxtel", "vx", "wap", "wellco", "wig browser", "wii", "windows ce", "wireless", "xda", "xde", "zte" ); // Pre-set $is_mobile to false. $is_mobile = false; // Cycle through the list in $mobile_agents to see if any of them // appear in $user_agent. foreach ($mobile_agents as $device) { // Check each element in $mobile_agents to see if it appears in // $user_agent. If it does, set $is_mobile to true. if (stristr($user_agent, $device)) { $is_mobile = true; // break out of the foreach, we don't need to test // any more once we get a true value. break; } } return $is_mobile; } $smarty->assign('bg', "/images/homebgs/mainbg.jpg"); if(is_mobile()){ $smarty->assign('himg',"/images/homebgs/topbg3.png"); } else{$smarty->assign('himg',"/images/homebgs/topbg1.png");} $smarty->assign('htext',""); }else{ $smarty->assign('bg', "/images/newimages/bg/background_main_v2.png"); $smarty->assign('himg',"/images/newimages/header/header_home.jpg"); $smarty->assign('htext',"/images/newimages/text/home_text.png"); } } elseif($_SERVER['PHP_SELF']=="/user_album.php"||$_SERVER['PHP_SELF']=="/profile.php"||$_SERVER['PHP_SELF']=="/user_video.php"||$_SERVER['PHP_SELF']=="/user_music.php"||$_SERVER['PHP_SELF']=="/user_group.php"||$_SERVER['PHP_SELF']=="/user_blog.php"||$_SERVER['PHP_SELF']=="/user_notes.php"||$_SERVER['PHP_SELF']=="/user_poll.php"||$_SERVER['PHP_SELF']=="/user_event.php"||$_SERVER['PHP_SELF']=="/user_editprofile.php"||$_SERVER['PHP_SELF']=="/user_editprofile_photo.php"||$_SERVER['PHP_SELF']=="/user_account.php"||$_SERVER['PHP_SELF']=="/user_account_privacy.php"||$_SERVER['PHP_SELF']=="/user_account_pass.php") { $smarty->assign('bg', "/images/newimages/bg/background_profile.jpg"); $smarty->assign('himg',"/images/newimages/header/header_profile.jpg"); $smarty->assign('htext',"/images/newimages/text/profile_text.png"); } elseif($_SERVER['PHP_SELF']=="/user_friends_requests.php"||$_SERVER['PHP_SELF']=="/user_friends_requests_outgoing.php"||$_SERVER['PHP_SELF']=="/user_messages_outbox.php"||$_SERVER['PHP_SELF']=="/user_messages.php" || $_SERVER['PHP_SELF']== "/user_messages_view.php") { $smarty->assign('bg', "/images/newimages/bg/background_messages.jpg"); $smarty->assign('himg',"/images/newimages/header/header_messages.jpg"); $smarty->assign('htext',"/images/newimages/text/messages_text.png"); } elseif($_SERVER['PHP_SELF']=="/content.php"&&($_GET["page"]=="premium-membership"||$_GET["page"]=="helping-hand-sponsorship"||$_GET["page"]=="helping-hand")) { $smarty->assign('bg', "/images/newimages/bg/background_membership.jpg"); $smarty->assign('himg',"/images/newimages/header/header_membership.jpg"); $smarty->assign('htext',"/images/newimages/text/membership_text.png"); } elseif($_SERVER['PHP_SELF']=="/membership-popup.php") { $smarty->assign('bg', "/images/newimages/bg/background_membership.jpg"); $smarty->assign('himg',""); $smarty->assign('htext',"/images/newimages/text/membership_text.png"); } elseif($_SERVER['PHP_SELF']=="/browse_albums.php"||$_SERVER['PHP_SELF']=="/browse_videos.php"||$_SERVER['PHP_SELF']=="/browse_music.php" || $_SERVER['PHP_SELF']=="/tumblr.php" || $_SERVER['PHP_SELF']=="/browse_channels.php" || ($_SERVER['PHP_SELF']=="/content.php"&&($_GET["page"]=="video-channel-page-1"))) { $smarty->assign('bg', "/images/newimages/bg/background_media.jpg"); $smarty->assign('himg',"/images/newimages/header/header_media.jpg"); $smarty->assign('htext',"/images/newimages/text/media_text.png"); } elseif($_SERVER['PHP_SELF']=="/user_home.php"||$_SERVER['PHP_SELF']=="/search_advanced.php"||$_SERVER['PHP_SELF']=="/onlinemembers.php"||$_SERVER['PHP_SELF']=="/user_friends.php"||$_SERVER['PHP_SELF']=="/browse_avchat3.php"||$_SERVER['PHP_SELF']=="/browse_groups.php"||$_SERVER['PHP_SELF']=="/browse_blogs.php"||$_SERVER['PHP_SELF']=="/group.php" || $_SERVER['PHP_SELF']=="/browse_polls.php"||$_SERVER['PHP_SELF']=="/browse_events.php"||$_SERVER['PHP_SELF']=="/content.php"||$_SERVER['PHP_SELF']=="/invite.php"||$_SERVER['PHP_SELF']=="/forum.php") { $smarty->assign('bg', "/images/newimages/bg/background_community.jpg"); $smarty->assign('himg',"/images/newimages/header/header_community.jpg"); $smarty->assign('htext',"/images/newimages/text/community_text.png"); } ?>