private function cacheConnect() { $_memcacheConnected = false; // connected bool if (class_exists('Memcache')) { $this->__cache = new Memcache(); $_server = $this->get('memcacheserver'); $_port = $this->get('memcacheserverport'); if (@$this->__cache->connect($_server, $_port)) { $_memcacheConnected = true; $this->set('memcacheversion', $_memcacheVersion = memcache_get_version($this->__cache)); } } $this->set('memcacheconnected', $_memcacheConnected); }
/** * Get a list of versions that are currently installed on the server. * * @package Admin * @param string[] $checkFor */ function getServerVersions($checkFor) { global $txt, $memcached, $modSettings; $db = database(); loadLanguage('Admin'); $versions = array(); // Is GD available? If it is, we should show version information for it too. if (in_array('gd', $checkFor) && function_exists('gd_info')) { $temp = gd_info(); $versions['gd'] = array('title' => $txt['support_versions_gd'], 'version' => $temp['GD Version']); } // Why not have a look at ImageMagick? If it is, we should show version information for it too. if (in_array('imagick', $checkFor) && class_exists('Imagick')) { $temp = new Imagick(); $temp2 = $temp->getVersion(); $versions['imagick'] = array('title' => $txt['support_versions_imagick'], 'version' => $temp2['versionString']); } // Now lets check for the Database. if (in_array('db_server', $checkFor)) { $conn = $db->connection(); if (empty($conn)) { trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); } else { $versions['db_server'] = array('title' => sprintf($txt['support_versions_db'], $db->db_title()), 'version' => ''); $versions['db_server']['version'] = $db->db_server_version(); } } // If we're using memcache we need the server info. if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') { require_once SUBSDIR . '/Cache.subs.php'; get_memcached_server(); } else { if (($key = array_search('memcache', $checkFor)) !== false) { unset($checkFor[$key]); } } // Check to see if we have any accelerators installed... if (in_array('mmcache', $checkFor) && defined('MMCACHE_VERSION')) { $versions['mmcache'] = array('title' => 'Turck MMCache', 'version' => MMCACHE_VERSION); } if (in_array('eaccelerator', $checkFor) && defined('EACCELERATOR_VERSION')) { $versions['eaccelerator'] = array('title' => 'eAccelerator', 'version' => EACCELERATOR_VERSION); } if (in_array('zend', $checkFor) && function_exists('zend_shm_cache_store')) { $versions['zend'] = array('title' => 'Zend SHM Accelerator', 'version' => zend_version()); } if (in_array('apc', $checkFor) && extension_loaded('apc')) { $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); } if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); } if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); } if (in_array('opcache', $checkFor) && extension_loaded('Zend OPcache')) { $opcache_config = @opcache_get_configuration(); if (!empty($opcache_config['directives']['opcache.enable'])) { $versions['opcache'] = array('title' => $opcache_config['version']['opcache_product_name'], 'version' => $opcache_config['version']['version']); } } // PHP Version if (in_array('php', $checkFor)) { $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION . ' (' . php_sapi_name() . ')', 'more' => '?action=admin;area=serversettings;sa=phpinfo'); } // Server info if (in_array('server', $checkFor)) { $req = request(); $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $req->server_software()); // Compute some system info, if we can $versions['server_name'] = array('title' => $txt['support_versions'], 'version' => php_uname()); $loading = detectServerLoad(); if ($loading !== false) { $versions['server_load'] = array('title' => $txt['load_balancing_settings'], 'version' => $loading); } } return $versions; }
function get_server_versions($checkFor) { global $txt, $db_connection, $_PHPA, $smcFunc, $memcached, $modSettings; loadLanguage('Admin'); $versions = array(); // Is GD available? If it is, we should show version information for it too. if (in_array('gd', $checkFor) && function_exists('gd_info')) { $temp = gd_info(); $versions['gd'] = array('title' => $txt['support_versions_gd'], 'version' => $temp['GD Version']); } // If we're using memcache we need the server info. if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') { get_memcached_server(); } // Check to see if we have any accelerators installed... if (in_array('mmcache', $checkFor) && defined('MMCACHE_VERSION')) { $versions['mmcache'] = array('title' => 'Turck MMCache', 'version' => MMCACHE_VERSION); } if (in_array('eaccelerator', $checkFor) && defined('EACCELERATOR_VERSION')) { $versions['eaccelerator'] = array('title' => 'eAccelerator', 'version' => EACCELERATOR_VERSION); } if (in_array('phpa', $checkFor) && isset($_PHPA)) { $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); } if (in_array('apc', $checkFor) && extension_loaded('apc')) { $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); } if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); } return $versions; }
public static function ping(&$conn) { if (!is_array($conn)) { return false; } if ($conn[1] == 'memcache') { return @memcache_get_version($conn[0]); } if ($conn[1] == "mysql") { if (function_exists('mysql_ping') && mysql_ping($conn[0])) { return true; } // if (!@mysql_query("SELECT 1", $conn[0])) { //try to reconnect for pdo $conn2 = self::init($conn[2]); var_dump($conn2); if (is_string($conn2)) { $conn[0] = $conn2; return false; } $conn = $conn2; return true; } return true; } if (current(explode("_", $conn[1])) == 'pdo') { try { if (is_object($conn[0]) && $conn[0]->query('select 1') !== false) { return true; } } catch (PDOException $e) { } //try to reconnect for pdo $conn2 = self::init($conn[2]); if (is_string($conn2)) { // has error $conn[0] = $conn2; // error stored on 0 index return false; } else { $conn = $conn2; return true; } } else { if ($conn[1] == 'mongo') { try { return $conn[0]->listDBs(); } catch (Exception $e) { $conn[4] = array($e->getCode(), $e->getMessage()); return false; } } } // for mysqli ... if (isset($conn[0]->sqlstate) && $conn[0]->sqlstate === '00000') { return true; } // In Any case closed the connection, make fresh conection is_object($conn[0]) ? self::close($conn) : ($conn[0] = null); // $conn2 = self::init($conn[2]); if (is_string($conn2)) { // has error $conn[0] = $conn2; return false; } else { $conn = $conn2; if (isset($conn2[0]) && is_object($conn2[0]) && isset($conn[0]->sqlstate) && $conn[0]->sqlstate === '00000') { return true; } } return false; }
function getServerVersions($checkFor) { global $txt, $db_connection, $_PHPA, $smcFunc, $memcached, $modSettings; loadLanguage('Admin'); $versions = array(); // Is GD available? If it is, we should show version information for it too. if (in_array('gd', $checkFor) && function_exists('gd_info')) { $temp = gd_info(); $versions['gd'] = array('title' => $txt['support_versions_gd'], 'version' => $temp['GD Version']); } // Now lets check for the Database. if (in_array('db_server', $checkFor)) { db_extend(); if (!isset($db_connection) || $db_connection === false) { trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); } else { $versions['db_server'] = array('title' => sprintf($txt['support_versions_db'], $smcFunc['db_title']), 'version' => ''); $versions['db_server']['version'] = $smcFunc['db_get_version'](); } } // If we're using memcache we need the server info. if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') { get_memcached_server(); } // Check to see if we have any accelerators installed... if (in_array('mmcache', $checkFor) && defined('MMCACHE_VERSION')) { $versions['mmcache'] = array('title' => 'Turck MMCache', 'version' => MMCACHE_VERSION); } if (in_array('eaccelerator', $checkFor) && defined('EACCELERATOR_VERSION')) { $versions['eaccelerator'] = array('title' => 'eAccelerator', 'version' => EACCELERATOR_VERSION); } if (in_array('phpa', $checkFor) && isset($_PHPA)) { $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); } if (in_array('apc', $checkFor) && extension_loaded('apc')) { $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); } if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); } if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); } if (in_array('php', $checkFor)) { $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION); } if (in_array('server', $checkFor)) { $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); } return $versions; }
function Admin() { global $sourcedir, $db_prefix, $forum_version, $txt, $scripturl, $context, $modSettings; global $user_info, $_PHPA, $boardurl, $memcached; if (isset($_GET['area']) && $_GET['area'] == 'copyright') { return ManageCopyright(); } // 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')); // Load the common admin stuff... select 'index'. adminIndex(isset($_GET['credits']) ? 'credits' : 'index'); // Find all of this forum's administrators. $request = db_query("\n\t\tSELECT ID_MEMBER, realName\n\t\tFROM {$db_prefix}members\n\t\tWHERE ID_GROUP = 1 OR FIND_IN_SET(1, additionalGroups)\n\t\tLIMIT 33", __FILE__, __LINE__); $context['administrators'] = array(); while ($row = mysql_fetch_assoc($request)) { $context['administrators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>'; } mysql_free_result($request); // If there are more than 32 admins show a more link and direct the admin to the memberlist with admin filter. if (count($context['administrators']) > 32) { // Quicker to get one too many than to count first... unset($context['administrators'][32]); $context['more_admins_link'] = '<a href="' . $scripturl . '?action=mlist;sa=search;fields=group;search=administrator">' . $txt['more'] . '</a>'; } // Some stuff.... :P. $context['credits'] = ' <i>Simple Machines wants to thank everyone who helped make SMF 1.1 what it is today; shaping and directing our project, all through the thick and the thin. It wouldn\'t have been possible without you.</i><br /> <div style="margin-top: 1ex;"><i>This includes our users and especially Charter Members - thanks for installing and using our software as well as providing valuable feedback, bug reports, and opinions.</i></div> <div style="margin-top: 2ex;"><b>Project Managers:</b> Amacythe, David Recordon, Joseph Fung, and Jeff Lewis.</div> <div style="margin-top: 1ex;"><b>Developers:</b> Hendrik Jan "Compuart" Visser, Matt "Grudge" Wolf, Michael "Thantos" Miller, Theodore "Orstio" Hildebrandt, and Unknown W. "[Unknown]" Brackets</div> <div style="margin-top: 1ex;"><b>Support Specialists:</b> Ben Scott, Michael "Oldiesmann" Eshom, Jan-Olof "Owdy" Eriksson, Aäron van Geffen, Alexandre "Ap2" Patenaude, Andrea Hubacher, Chris Cromer, [darksteel], dtm.exe, Nick "Fizzy" Dyer, Horseman, Huw Ayling-Miller, jerm, Justyne, kegobeer, Kindred, Matthew "Mattitude" Hall, Mediman, Metho, Omar Bazavilvazo, Pitti, redone, Tomer "Lamper" Dean, Tony, and xenovanis.</div> <div style="margin-top: 1ex;"><b>Mod Developers:</b> snork13, Cristián "Anguz" Lávaque, Goosemoose, Jack.R.Abbit, James "Cheschire" Yarbro, Jesse "Gobalopper" Reid, Juan "JayBachatero" Hernandez, Kirby, vbgamer45, and winrules.</div> <div style="margin-top: 1ex;"><b>Documentation Writers:</b> akabugeyes, eldacar, Gary M. "AwwLilMaggie" Gadsdon, Jerry, and Nave.</div> <div style="margin-top: 1ex;"><b>Language Coordinators:</b> Daniel Diehl and Adam "Bostasp" Southall.</div> <div style="margin-top: 1ex;"><b>Graphic Designers:</b> Bjoern "Bloc" Kristiansen, Alienine (Adrian), A.M.A, babylonking, BlackouT, Burpee, diplomat, Eren "forsakenlad" Yasarkurt, Hyper Piranha, Killer Possum, Mystica, Nico "aliencowfarm" Boer, Philip "Meriadoc" Renich and Tippmaster.</div> <div style="margin-top: 1ex;"><b>Site team:</b> dschwab9 and Tim.</div> <div style="margin-top: 1ex;"><b>Marketing:</b> Douglas "The Bear" Hazard, RickC and Trekkie101.</div> <div style="margin-top: 1ex;">And for anyone we may have missed, thank you!</div>'; // 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($url = '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'))); if ($return_data != 'void') { list($_SESSION['copy_expire'], $copyright_key) = explode('|', $return_data); $_SESSION['copy_key'] = $key; $copy_settings = $key . ',' . (int) $_SESSION['copy_expire']; updateSettings(array('copy_settings' => $copy_settings, 'copyright_key' => $copyright_key)); } else { $_SESSION['copy_expire'] = ''; db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}settings\n\t\t\t\t\tWHERE variable = 'copy_settings'\n\t\t\t\t\t\tOR variable = 'copyright_key'", __FILE__, __LINE__); } } 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), 'mysql' => array('title' => $txt['support_versions_mysql'], 'version' => ''), 'server' => array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE'])); $context['forum_version'] = $forum_version; // Is GD available? If it is, we should show version information for it too. if (function_exists('gd_info')) { $temp = gd_info(); $context['current_versions']['gd'] = array('title' => $txt['support_versions_gd'], 'version' => $temp['GD Version']); } $request = db_query("\n\t\tSELECT VERSION()", __FILE__, __LINE__); list($context['current_versions']['mysql']['version']) = mysql_fetch_row($request); mysql_free_result($request); // If we're using memcache we need the server info. if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') { get_memcached_server(); } // Check to see if we have any accelerators installed... if (defined('MMCACHE_VERSION')) { $context['current_versions']['mmcache'] = array('title' => 'Turck MMCache', 'version' => MMCACHE_VERSION); } if (defined('EACCELERATOR_VERSION')) { $context['current_versions']['eaccelerator'] = array('title' => 'eAccelerator', 'version' => EACCELERATOR_VERSION); } if (isset($_PHPA)) { $context['current_versions']['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); } if (extension_loaded('apc')) { $context['current_versions']['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); } if (function_exists('memcache_set')) { $context['current_versions']['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); } $context['can_admin'] = allowedTo('admin_forum'); $context['sub_template'] = isset($_GET['credits']) ? 'credits' : 'admin'; $context['page_title'] = isset($_GET['credits']) ? $txt['support_credits_title'] : $txt[208]; // The format of this array is: permission, action, title, description. $quick_admin_tasks = array(array('', 'admin;credits', 'support_credits_title', 'support_credits_info'), array('admin_forum', 'featuresettings', 'modSettings_title', 'modSettings_info'), array('admin_forum', 'maintain', 'maintain_title', 'maintain_info'), array('manage_permissions', 'permissions', 'edit_permissions', 'edit_permissions_info'), array('admin_forum', 'theme;sa=admin;sesc=' . $context['session_id'], 'theme_admin', 'theme_admin_info'), array('admin_forum', 'packages', 'package1', 'package_info'), array('manage_smileys', 'smileys', 'smileys_manage', 'smileys_manage_info'), array('moderate_forum', 'viewmembers', '5', 'member_center_info')); $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=' . $task[1], 'link' => '<a href="' . $scripturl . '?action=' . $task[1] . '">' . $txt[$task[2]] . '</a>', 'title' => $txt[$task[2]], 'description' => $txt[$task[3]], '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; } }