/** * The main administration section. * It prepares all the data necessary for the administration front page. * It uses the Admin template along with the admin sub template. * It requires the moderate_forum, manage_membergroups, manage_bans, * admin_forum, manage_permissions, manage_attachments, manage_smileys, * manage_boards, edit_news, or send_mail permission. * It uses the index administrative area. * It can be found by going to ?action=admin. */ function AdminHome() { global $sourcedir, $forum_version, $txt, $scripturl, $context, $user_info, $boardurl, $modSettings, $smcFunc; // You have to be able to do at least one of the below to see this page. isAllowedTo(array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments')); // Find all of this forum's administrators... require_once $sourcedir . '/Subs-Membergroups.php'; if (listMembergroupMembers_Href($context['administrators'], 1, 32) && allowedTo('manage_membergroups')) { // Add a 'more'-link if there are more than 32. $context['more_admins_link'] = '<a href="' . $scripturl . '?action=moderate;area=viewgroups;sa=members;group=1">' . $txt['more'] . '</a>'; } // Load the credits stuff. require_once $sourcedir . '/Who.php'; Credits(true); // This makes it easier to get the latest news with your time format. $context['time_format'] = urlencode($user_info['time_format']); $context['forum_version'] = $forum_version; // Get a list of current server versions. require_once $sourcedir . '/Subs-Admin.php'; $checkFor = array('gd', 'imagick', 'db_server', 'mmcache', 'eaccelerator', 'phpa', 'apc', 'memcache', 'xcache', 'php', 'server'); $context['current_versions'] = getServerVersions($checkFor); $context['can_admin'] = allowedTo('admin_forum'); $context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin'; $context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center']; // The format of this array is: permission, action, title, description, icon. $quick_admin_tasks = array(array('', 'credits', 'support_credits_title', 'support_credits_info', 'support_and_credits.png'), array('admin_forum', 'featuresettings', 'modSettings_title', 'modSettings_info', 'features_and_options.png'), array('admin_forum', 'maintain', 'maintain_title', 'maintain_info', 'forum_maintenance.png'), array('manage_permissions', 'permissions', 'edit_permissions', 'edit_permissions_info', 'permissions_lg.png'), array('admin_forum', 'theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id'], 'theme_admin', 'theme_admin_info', 'themes_and_layout.png'), array('admin_forum', 'packages', 'package', 'package_info', 'packages_lg.png'), array('manage_smileys', 'smileys', 'smileys_manage', 'smileys_manage_info', 'smilies_and_messageicons.png'), array('moderate_forum', 'viewmembers', 'admin_users', 'member_center_info', 'members_lg.png')); $context['quick_admin_tasks'] = array(); foreach ($quick_admin_tasks as $task) { if (!empty($task[0]) && !allowedTo($task[0])) { continue; } $context['quick_admin_tasks'][] = array('href' => $scripturl . '?action=admin;area=' . $task[1], 'link' => '<a href="' . $scripturl . '?action=admin;area=' . $task[1] . '">' . $txt[$task[2]] . '</a>', 'title' => $txt[$task[2]], 'description' => $txt[$task[3]], 'icon' => $task[4], 'is_last' => false); } if (count($context['quick_admin_tasks']) % 2 == 1) { $context['quick_admin_tasks'][] = array('href' => '', 'link' => '', 'title' => '', 'description' => '', 'is_last' => true); $context['quick_admin_tasks'][count($context['quick_admin_tasks']) - 2]['is_last'] = true; } elseif (count($context['quick_admin_tasks']) != 0) { $context['quick_admin_tasks'][count($context['quick_admin_tasks']) - 1]['is_last'] = true; $context['quick_admin_tasks'][count($context['quick_admin_tasks']) - 2]['is_last'] = true; } // Lastly, fill in the blanks in the support resources paragraphs. $txt['support_resources_p1'] = sprintf($txt['support_resources_p1'], 'http://wiki.simplemachines.org/', 'http://wiki.simplemachines.org/smf/features2', 'http://wiki.simplemachines.org/smf/options2', 'http://wiki.simplemachines.org/smf/themes2', 'http://wiki.simplemachines.org/smf/packages2'); $txt['support_resources_p2'] = sprintf($txt['support_resources_p2'], 'http://www.simplemachines.org/community/', 'http://www.simplemachines.org/redirect/english_support', 'http://www.simplemachines.org/redirect/international_support_boards', 'http://www.simplemachines.org/redirect/smf_support', 'http://www.simplemachines.org/redirect/customize_support'); }
function SMStats() { global $modSettings, $user_info, $forum_version, $sourcedir; // First, is it disabled? if (empty($modSettings['allow_sm_stats'])) { die; } // Are we saying who we are, and are we right? (OR an admin) if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['allow_sm_stats'])) { die; } // Verify the referer... if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) { die; } // Get some server versions. require_once $sourcedir . '/Subs-Admin.php'; $checkFor = array('php', 'db_server'); $serverVersions = getServerVersions($checkFor); // Get the actual stats. $stats_to_send = array('UID' => $modSettings['allow_sm_stats'], 'time_added' => time(), 'members' => $modSettings['totalMembers'], 'messages' => $modSettings['totalMessages'], 'topics' => $modSettings['totalTopics'], 'boards' => 0, 'php_version' => $serverVersions['php']['version'], 'database_type' => strtolower($serverVersions['db_server']['title']), 'database_version' => $serverVersions['db_server']['version'], 'smf_version' => $forum_version, 'smfd_version' => $modSettings['smfVersion']); // Encode all the data, for security. foreach ($stats_to_send as $k => $v) { $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v); } // Turn this into the query string! $stats_to_send = implode('&', $stats_to_send); // If we're an admin, just plonk them out. if ($user_info['is_admin']) { echo $stats_to_send; } else { // Connect to the collection script. $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); if ($fp) { $length = strlen($stats_to_send); $out = 'POST /smf/stats/collect_stats.php HTTP/1.1' . "\r\n"; $out .= 'Host: www.simplemachines.org' . "\r\n"; $out .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n"; $out .= 'Content-Length: ' . $length . "\r\n\r\n"; $out .= $stats_to_send . "\r\n"; $out .= 'Connection: Close' . "\r\n\r\n"; fwrite($fp, $out); fclose($fp); } } // Die. die('OK'); }
/** * The credits section in admin panel. * * What it does: * - Determines the current level of support functions from the server, such as * current level of caching engine or graphics librayrs installed. * - Accessed by ?action=admin;area=credits */ public function action_credits() { global $forum_version, $txt, $scripturl, $context, $user_info; // We need a little help from our friends require_once SUBSDIR . '/Membergroups.subs.php'; require_once SUBSDIR . '/Who.subs.php'; require_once SUBSDIR . '/Admin.subs.php'; // You have to be able to do at least one of the below to see this page. isAllowedTo(array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments')); // Find all of this forum's administrators... if (listMembergroupMembers_Href($context['administrators'], 1, 32) && allowedTo('manage_membergroups')) { // Add a 'more'-link if there are more than 32. $context['more_admins_link'] = '<a href="' . $scripturl . '?action=moderate;area=viewgroups;sa=members;group=1">' . $txt['more'] . '</a>'; } // Load credits. $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['support_credits_title'], 'help' => '', 'description' => ''); loadLanguage('Who'); $context += prepareCreditsData(); // This makes it easier to get the latest news with your time format. $context['time_format'] = urlencode($user_info['time_format']); $context['forum_version'] = $forum_version; // Get a list of current server versions. $checkFor = array('gd', 'imagick', 'db_server', 'mmcache', 'eaccelerator', 'zend', 'apc', 'memcache', 'xcache', 'opcache', 'php', 'server'); $context['current_versions'] = getServerVersions($checkFor); $context['can_admin'] = allowedTo('admin_forum'); $context['sub_template'] = 'credits'; $context['page_title'] = $txt['support_credits_title']; // Load in the admin quick tasks $context['quick_admin_tasks'] = getQuickAdminTasks(); }
function AdminHome() { global $sourcedir, $forum_version, $txt, $scripturl, $context, $user_info, $boardurl, $modSettings, $smcFunc; // You have to be able to do at least one of the below to see this page. isAllowedTo(array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_awards', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments')); // Find all of this forum's administrators... require_once $sourcedir . '/Subs-Membergroups.php'; if (listMembergroupMembers_Href($context['administrators'], 1, 32) && allowedTo('manage_membergroups')) { // Add a 'more'-link if there are more than 32. $context['more_admins_link'] = '<a href="' . $scripturl . '?action=moderate;area=viewgroups;sa=members;group=1">' . $txt['more'] . '</a>'; } // Load the credits stuff. require_once $sourcedir . '/Who.php'; Credits(true); // Fill in the blanks in the support resources paragraphs. $txt['support_resources_p1'] = sprintf($txt['support_resources_p1'], 'http://docs.simplemachines.org/', 'http://docs.simplemachines.org/redirect/features', 'http://docs.simplemachines.org/redirect/settings', 'http://docs.simplemachines.org/redirect/themes', 'http://docs.simplemachines.org/redirect/packages'); $txt['support_resources_p2'] = sprintf($txt['support_resources_p2'], 'http://www.simplemachines.org/community/', 'http://www.simplemachines.org/redirect/english_support', 'http://www.simplemachines.org/redirect/international_support_boards', 'http://www.simplemachines.org/redirect/smf_support', 'http://www.simplemachines.org/redirect/customize_support'); // Copyright? if (!empty($modSettings['copy_settings']) || !empty($modSettings['copyright_key'])) { if (empty($modSettings['copy_settings'])) { $modSettings['copy_settings'] = 'a,0'; } // Not done it yet... if (empty($_SESSION['copy_expire'])) { list($key, $expires) = explode(',', $modSettings['copy_settings']); // Get the expired date. require_once $sourcedir . '/Subs-Package.php'; $return_data = fetch_web_data('http://www.simplemachines.org/smf/copyright/check_copyright.php?site=' . base64_encode($boardurl) . '&key=' . $key . '&version=' . base64_encode($forum_version)); // Get the expire date. $return_data = substr($return_data, strpos($return_data, 'STARTCOPY') + 9); $return_data = trim(substr($return_data, 0, strpos($return_data, 'ENDCOPY'))); $deletekeys = true; if ($return_data != 'void') { list($_SESSION['copy_expire'], $copyright_key) = explode('|', $return_data); $_SESSION['copy_key'] = $key; if ($_SESSION['copy_expire'] > time()) { $deletekeys = false; $copy_settings = $key . ',' . (int) $_SESSION['copy_expire']; updateSettings(array('copy_settings' => $copy_settings, 'copyright_key' => $copyright_key)); } } if ($deletekeys) { $_SESSION['copy_expire'] = ''; $smcFunc['db_query']('', ' DELETE FROM {db_prefix}settings WHERE variable = {string:copy_settings} OR variable = {string:copyright_key}', array('copy_settings' => 'copy_settings', 'copyright_key' => 'copyright_key')); } } if (isset($_SESSION['copy_expire']) && $_SESSION['copy_expire'] > time()) { $context['copyright_expires'] = (int) (($_SESSION['copy_expire'] - time()) / 3600 / 24); $context['copyright_key'] = $_SESSION['copy_key']; } } // This makes it easier to get the latest news with your time format. $context['time_format'] = urlencode($user_info['time_format']); $context['current_versions'] = array('php' => array('title' => $txt['support_versions_php'], 'version' => PHP_VERSION), 'db' => array('title' => sprintf($txt['support_versions_db'], $smcFunc['db_title']), 'version' => ''), 'server' => array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE'])); $context['forum_version'] = $forum_version; // Get a list of current server versions. require_once $sourcedir . '/Subs-Admin.php'; $checkFor = array('gd', 'db_server', 'mmcache', 'eaccelerator', 'phpa', 'apc', 'memcache', 'xcache', 'php', 'server'); $context['current_versions'] = getServerVersions($checkFor); $context['can_admin'] = allowedTo('admin_forum'); $context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin'; $context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center']; // The format of this array is: permission, action, title, description, icon. $quick_admin_tasks = array(array('', 'credits', 'support_credits_title', 'support_credits_info', 'support_and_credits.png'), array('admin_forum', 'featuresettings', 'modSettings_title', 'modSettings_info', 'features_and_options.png'), array('admin_forum', 'maintain', 'maintain_title', 'maintain_info', 'forum_maintenance.png'), array('manage_permissions', 'permissions', 'edit_permissions', 'edit_permissions_info', 'permissions.png'), array('admin_forum', 'theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id'], 'theme_admin', 'theme_admin_info', 'themes_and_layout.png'), array('admin_forum', 'packages', 'package', 'package_info', 'packages.png'), array('manage_smileys', 'smileys', 'smileys_manage', 'smileys_manage_info', 'smilies_and_messageicons.png'), array('moderate_forum', 'viewmembers', 'admin_users', 'member_center_info', 'members.png')); $context['quick_admin_tasks'] = array(); foreach ($quick_admin_tasks as $task) { if (!empty($task[0]) && !allowedTo($task[0])) { continue; } $context['quick_admin_tasks'][] = array('href' => $scripturl . '?action=admin;area=' . $task[1], 'link' => '<a href="' . $scripturl . '?action=admin;area=' . $task[1] . '">' . $txt[$task[2]] . '</a>', 'title' => $txt[$task[2]], 'description' => $txt[$task[3]], 'icon' => $task[4], 'is_last' => false); } if (count($context['quick_admin_tasks']) % 2 == 1) { $context['quick_admin_tasks'][] = array('href' => '', 'link' => '', 'title' => '', 'description' => '', 'is_last' => true); $context['quick_admin_tasks'][count($context['quick_admin_tasks']) - 2]['is_last'] = true; } elseif (count($context['quick_admin_tasks']) != 0) { $context['quick_admin_tasks'][count($context['quick_admin_tasks']) - 1]['is_last'] = true; $context['quick_admin_tasks'][count($context['quick_admin_tasks']) - 2]['is_last'] = true; } }