$set['max_server_load_bots']){ header( 'HTTP/1.0 503 Service Unavailable' ); header( "Retry-After: 60" ); header( 'Connection: close' ); header( 'Content-Type: text/html' ); echo "

Server under undue load, please retry in a few minutes."; exit; } } require './code/constants.php'; require './code/db_mysql.php'; require './core.php'; require './code/perms.php'; require './code/modifiers.php'; require './code/mailer.php'; require './code/articlems.php'; require './code/php-captcha.inc.php'; require './lib/safehtml/safehtml.php'; if (!$set['installed']) { header('Location: ./install/index.php'); } $articlems = new articlems(); $articlems->pre = $set['db_pre']; $articlems->db_settings = $set; $articlems->server_load = $server_load; $articlems->user_is_bot = $user_is_bot; $articlems->db = new database($articlems->db_settings['db_host'], $articlems->db_settings['db_user'], $articlems->db_settings['db_pass'], $articlems->db_settings['db_name'], $articlems->db_settings['db_port'], $articlems->db_settings['db_socket']); if (!$articlems->db->connection) { exit('A connection to the database could not be established: '.mysql_error()); } @session_start(); $articlems->db->ams = &$articlems; $row_settings = $articlems->db->fetch("SELECT * from {$articlems->pre}amssettings"); $testsettings = unserialize($row_settings['settings_settings']); if (!$testsettings['site_enabled']){ $output = ' '.$testsettings['sitename'].'

'.($testsettings['disabled_message']? $testsettings['disabled_message']: '

We are upgrading to the latest version of ArticleMS, please be patient.

If you are an administrator, you can login here.'). '
'; echo $output; exit; } //---Setup $_GET and $_POST etc with mysql_real_escape_string instead of addslashes or magic_quotes_gpc function stripslashes_deep($value){ return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value)); } if (get_magic_quotes_gpc()){ $_GET = array_map('stripslashes_deep', $_GET); $_POST = array_map('stripslashes_deep', $_POST); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_ENV = array_map('stripslashes_deep', $_ENV); $_SERVER = array_map('stripslashes_deep', $_SERVER); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); $HTTP_SERVER_VARS = array_map('stripslashes_deep', $HTTP_SERVER_VARS); $HTTP_GET_VARS = array_map('stripslashes_deep', $HTTP_GET_VARS); $HTTP_POST_VARS = array_map('stripslashes_deep', $HTTP_POST_VARS); $HTTP_COOKIE_VARS = array_map('stripslashes_deep', $HTTP_COOKIE_VARS); $HTTP_POST_FILES = array_map('stripslashes_deep', $HTTP_POST_FILES); $HTTP_ENV_VARS = array_map('stripslashes_deep', $HTTP_ENV_VARS); if (isset($_SESSION)) { $_SESSION = array_map('stripslashes_deep', $_SESSION); $HTTP_SESSION_VARS = array_map('stripslashes_deep', $HTTP_SESSION_VARS); } } //An replacement for addslashes() to prevent mysql injection function real_addslashes($s){ $s = mysql_real_escape_string($s); $s = str_replace('\r\n',"\n",$s); //this makes it possible to unescape.. return $s; } function addslashes_deep($value){ if (phpversion() >= '4.3.0') { return (is_array($value) ? array_map('addslashes_deep', $value) : real_addslashes($value)); } else{ return (is_array($value) ? array_map('addslashes_deep', $value) : addslashes($value)); } } $_GET = array_map('addslashes_deep', $_GET); $_POST = array_map('addslashes_deep', $_POST); $_COOKIE = array_map('addslashes_deep', $_COOKIE); $_ENV = array_map('addslashes_deep', $_ENV); $_SERVER = array_map('addslashes_deep', $_SERVER); $_REQUEST = array_map('addslashes_deep', $_REQUEST); $HTTP_SERVER_VARS = array_map('addslashes_deep', $HTTP_SERVER_VARS); $HTTP_GET_VARS = array_map('addslashes_deep', $HTTP_GET_VARS); $HTTP_POST_VARS = array_map('addslashes_deep', $HTTP_POST_VARS); $HTTP_COOKIE_VARS = array_map('addslashes_deep', $HTTP_COOKIE_VARS); $HTTP_POST_FILES = array_map('addslashes_deep', $HTTP_POST_FILES); $HTTP_ENV_VARS = array_map('addslashes_deep', $HTTP_ENV_VARS); if (isset($_SESSION)) { $_SESSION = array_map('addslashes_deep', $_SESSION); $HTTP_SESSION_VARS = array_map('addslashes_deep', $HTTP_SESSION_VARS); } //------------------------------------------------ $articlems->safehtml =& new safehtml(); $articlems->loadSettings($row_settings); if ($articlems->settings['mod_rewrite']){ $articlems->setupGetVariables(); } $articlems->user = $articlems->login(); if ($articlems->user['user_amsskin'] == ''){ $articlems->user['user_amsskin'] = $articlems->settings['defaultskin']; } $articlems->User = new baseclass(); $articlems->_getUser($articlems->user, $articlems->User); $articlems->session['id'] = session_id(); $articlems->skin = $articlems->user['user_amsskin']; if ($articlems->skin == ''){ $articlems->skin = $articlems->settings['defaultskin']; } $query = $articlems->db->fetch("SELECT * FROM {$articlems->pre}amsskins WHERE skin_name = '{$articlems->skin}'"); if (!$query['skin_name']){ $articlems->skin = 'default'; } $articlems->loadSettings_Skin(); $articlems->perms = new permissions; $articlems->perms->db = &$articlems->db; $articlems->perms->pre = &$articlems->pre; //$articlems->perms->load_perms($articlems->user['user_amsgroup'], $articlems->user['user_id']); $articlems->perms->load_perms($articlems->user['user_amsgroup'], $articlems->User); $articlems->title = $articlems->sitename; $articlems->output = ''; $articlems->url = $_SERVER['REQUEST_URI']; $articlems->active = $articlems->updateActiveUsers(); $articlems->Active = new baseclass(); $articlems->Active->guests = $articlems->active['guests']; $articlems->Active->members = $articlems->active['members']; $articlems->Active->total = $articlems->active['total']; $Email = new mailer($articlems); if (!$articlems->settings['use_cron']){ $Email->process_queue(); } $articlems->executeInit(); $articlems->Modifiers = new modifiers($articlems); $articlems->Mailer = new mailer($articlems); if (isset($articlems->get['a'])){ $loginArray = array('login'); $registerArray = array('register'); $articlesArray = array('submit'); $searchArray = array('search'); $articlems->module = ''; if ($articlems->get['a'] == $articlems->settings['url_login']){ $articlems->module = 'login'; $articlems->executeLogin($articlems->get['a']); } elseif ($articlems->get['a'] == $articlems->settings['url_pwreset']){ $articlems->module = 'pwreset'; $articlems->executePwreset(); } elseif ($articlems->get['a'] == $articlems->settings['url_profile']){ $articlems->module = 'profile'; $articlems->executeProfile(); } elseif ($articlems->get['a'] == $articlems->settings['url_usercp']){ $articlems->module = 'usercp'; $articlems->executeUserCP(); } elseif ($articlems->get['a'] == $articlems->settings['url_register']){ $articlems->module = 'register'; $articlems->executeRegister(); } elseif ($articlems->get['a'] == $articlems->settings['url_submit']){ $articlems->module = 'submit'; $articlems->executeArticles(); } elseif ($articlems->get['a'] == $articlems->settings['url_edit_article']){ $articlems->module = 'edit'; $articlems->executeEditArticles(); } elseif ($articlems->get['a'] == $articlems->settings['url_memberlist']){ $articlems->module = 'members'; $articlems->executeMemberList(); } elseif ($articlems->get['a'] == $articlems->settings['url_search']){ $articlems->module = 'search'; $articlems->executeSearch(); } elseif ($articlems->get['a'] == $articlems->settings['url_articleview']){ $articlems->module = 'articleview'; $articlems->executeArticles(); } else{ //possibly part of article category, or standalone plugin if ($articlems->settings['mod_rewrite']){ $result = $articlems->db->query("SELECT category_urltitle FROM {$articlems->pre}categories WHERE category_urltitle = '".$articlems->get['a']."' AND category_parentid = 0"); if ($row = $articlems->db->nqfetch($result)){ $articlems->module = 'articles'; $articlems->executeArticles(); } else{ //not part of article or category, might be standalone plugin if (($articlems->plugins[$articlems->get['a']]) and ($articlems->plugins[$articlems->get['a'].'__standalone'])){ //Module $articlems->module = 'plugin'; $articlems->executePlugin($articlems->get['a']); } else{ $result = $articlems->db->query("SELECT block_name, block_displayname FROM {$articlems->pre}blocks WHERE block_url = '".$articlems->get['a']."' AND block_active = 1 AND block_parentset = 'standalone' AND block_skin = '{$articlems->user['user_amsskin']}'"); if ($row = $articlems->db->nqfetch($result)){ $articlems->navblock = $row['block_displayname']; $articlems->module = 'standalone'; $articlems->executeStandalone($row['block_name']); } else{ //not found $articlems->module = 'notfound'; $articlems->executeDefault('notfound'); } } } } else{ if ($articlems->get['a'] == 'articles'){ $articlems->module = 'articles'; $articlems->executeArticles(); } elseif ($articlems->get['a'] == 'stand'){ $articlems->module = 'standalone'; $articlems->executeStandalone($articlems->get['block']); } elseif ($articlems->get['a'] == 'plugin'){ $articlems->module = 'standalone'; $articlems->executePlugin($articlems->get['block']); } else{ //not found $articlems->module = 'notfound'; $articlems->executeDefault('notfound'); } } } } elseif ((isset($articlems->get['page']))){ $articlems->executePage(); } else{ //homepage $articlems->executeDefault(); } ?>