| [ Index ] |
PHP Cross Reference of MyBB 1.8.40 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.8 4 * Copyright 2014 MyBB Group, All Rights Reserved 5 * 6 * Website: http://www.mybb.com 7 * License: http://www.mybb.com/about/license 8 * 9 */ 10 11 /** 12 * @param int $is_install 13 * @param string $prev_version 14 * @param string $current_version 15 * @param string $charset 16 * 17 * @return array 18 */ 19 function build_server_stats($is_install=1, $prev_version='', $current_version='', $charset='') 20 { 21 $info = array(); 22 23 // Is this an upgrade or an install? 24 if($is_install == 1) 25 { 26 $info['is_install'] = 1; 27 } 28 else 29 { 30 $info['is_install'] = 0; 31 } 32 33 // If we are upgrading.... 34 if($info['is_install'] == 0) 35 { 36 // What was the previous version? 37 $info['prev_version'] = $prev_version; 38 } 39 40 // What's our current version? 41 $info['current_version'] = $current_version; 42 43 // What is our current charset? 44 $info['charset'] = $charset; 45 46 // Parse phpinfo into array 47 $phpinfo = parse_php_info(); 48 49 // PHP Version 50 $info['phpversion'] = phpversion(); 51 52 // MySQL Version 53 $info['mysql'] = 0; 54 if(isset($phpinfo['mysql']['Client API version'])) 55 { 56 $info['mysql'] = $phpinfo['mysql']['Client API version']; 57 } 58 59 // PostgreSQL Version 60 $info['pgsql'] = 0; 61 if(isset($phpinfo['pgsql']['PostgreSQL(libpq) Version'])) 62 { 63 $info['pgsql'] = $phpinfo['pgsql']['PostgreSQL(libpq) Version']; 64 } 65 66 // SQLite Version 67 $info['sqlite'] = 0; 68 if(isset($phpinfo['sqlite']['SQLite Library'])) 69 { 70 $info['sqlite'] = $phpinfo['sqlite']['SQLite Library']; 71 } 72 73 // Iconv Library Extension Version 74 $info['iconvlib'] = 0; 75 if(isset($phpinfo['iconv']['iconv implementation'], $phpinfo['iconv']['iconv library version'])) 76 { 77 $info['iconvlib'] = html_entity_decode($phpinfo['iconv']['iconv implementation'])."|".$phpinfo['iconv']['iconv library version']; 78 } 79 80 // Check GD & Version 81 $info['gd'] = 0; 82 if(isset($phpinfo['gd']['GD Version'])) 83 { 84 $info['gd'] = $phpinfo['gd']['GD Version']; 85 } 86 87 // CGI Mode 88 $sapi_type = php_sapi_name(); 89 90 $info['cgimode'] = 0; 91 if(strpos($sapi_type, 'cgi') !== false) 92 { 93 $info['cgimode'] = 1; 94 } 95 96 // Server Software 97 $info['server_software'] = $_SERVER['SERVER_SOFTWARE']; 98 99 // Allow url fopen php.ini setting 100 $info['allow_url_fopen'] = 0; 101 if(ini_get('safe_mode') == 0 && ini_get('allow_url_fopen')) 102 { 103 $info['allow_url_fopen'] = 1; 104 } 105 106 // Check classes, extensions, php info, functions, and php ini settings 107 $check = array( 108 'classes' => array( 109 'dom' => array('bitwise' => 1, 'title' => 'DOMElement'), 110 'soap' => array('bitwise' => 2, 'title' => 'SoapClient'), 111 'xmlwriter' => array('bitwise' => 4, 'title' => 'XMLWriter'), 112 'imagemagick' => array('bitwise' => 8, 'title' => 'Imagick'), 113 ), 114 115 'extensions' => array( 116 'zendopt' => array('bitwise' => 1, 'title' => 'Zend Optimizer'), 117 'xcache' => array('bitwise' => 2, 'title' => 'XCache'), 118 'eaccelerator' => array('bitwise' => 4, 'title' => 'eAccelerator'), 119 'ioncube' => array('bitwise' => 8, 'title' => 'ionCube Loader'), 120 'PDO' => array('bitwise' => 16, 'title' => 'PDO'), 121 'pdo_mysql' => array('bitwise' => 32, 'title' => 'pdo_mysql'), 122 'pdo_pgsql' => array('bitwise' => 64, 'title' => 'pdo_pgsql'), 123 'pdo_sqlite' => array('bitwise' => 128, 'title' => 'pdo_sqlite'), 124 'pdo_oci' => array('bitwise' => 256, 'title' => 'pdo_oci'), 125 'pdo_odbc' => array('bitwise' => 512, 'title' => 'pdo_odbc'), 126 ), 127 128 'phpinfo' => array( 129 'zlib' => array('bitwise' => 1, 'title' => 'zlib'), 130 'mbstring' => array('bitwise' => 2, 'title' => 'mbstring'), 131 'exif' => array('bitwise' => 4, 'title' => 'exif'), 132 ), 133 134 'functions' => array( 135 'sockets' => array('bitwise' => 1, 'title' => 'fsockopen'), 136 'mcrypt' => array('bitwise' => 2, 'title' => 'mcrypt_encrypt'), 137 'simplexml' => array('bitwise' => 4, 'title' => 'simplexml_load_string'), 138 'ldap' => array('bitwise' => 8, 'title' => 'ldap_connect'), 139 'mysqli' => array('bitwise' => 16, 'title' => 'mysqli_connect'), 140 'imap' => array('bitwise' => 32, 'title' => 'imap_open'), 141 'ftp' => array('bitwise' => 64, 'title' => 'ftp_login'), 142 'pspell' => array('bitwise' => 128, 'title' => 'pspell_new'), 143 'apc' => array('bitwise' => 256, 'title' => 'apc_cache_info'), 144 'curl' => array('bitwise' => 512, 'title' => 'curl_init'), 145 'iconv' => array('bitwise' => 1024, 'title' => 'iconv'), 146 ), 147 148 'php_ini' => array( 149 'post_max_size' => 'post_max_size', 150 'upload_max_filesize' => 'upload_max_filesize', 151 'safe_mode' => 'safe_mode', 152 ), 153 ); 154 155 foreach($check as $cat_name => $category) 156 { 157 foreach($category as $name => $what) 158 { 159 if(!isset($info[$cat_name])) 160 { 161 $info[$cat_name] = 0; 162 } 163 switch($cat_name) 164 { 165 case "classes": 166 if(class_exists($what['title'])) 167 { 168 $info[$cat_name] |= $what['bitwise']; 169 } 170 break; 171 case "extensions": 172 if(extension_loaded($what['title'])) 173 { 174 $info[$cat_name] |= $what['bitwise']; 175 } 176 break; 177 case "phpinfo": 178 if(array_key_exists($what['title'], $phpinfo)) 179 { 180 $info[$cat_name] |= $what['bitwise']; 181 } 182 break; 183 case "functions": 184 if(function_exists($what['title'])) 185 { 186 $info[$cat_name] |= $what['bitwise']; 187 } 188 break; 189 case "php_ini": 190 if(ini_get($what) != 0) 191 { 192 $info[$name] = ini_get($what); 193 } 194 else 195 { 196 $info[$name] = 0; 197 } 198 break; 199 } 200 } 201 } 202 203 // Host URL & hostname 204 // Dropped fetching host details since v.1.8.16 as http://www.whoishostingthis.com API seems to be down and this info is not required by MyBB. 205 $info['hosturl'] = $info['hostname'] = "unknown/local"; 206 if($_SERVER['HTTP_HOST'] == 'localhost') 207 { 208 $info['hosturl'] = $info['hostname'] = "localhost"; 209 } 210 211 if(isset($_SERVER['HTTP_USER_AGENT'])) 212 { 213 $info['useragent'] = $_SERVER['HTTP_USER_AGENT']; 214 } 215 216 // We need a unique ID for the host so hash it to keep it private and send it over 217 $id = $_SERVER['HTTP_HOST'].time(); 218 219 if(function_exists('sha1')) 220 { 221 $info['clientid'] = sha1($id); 222 } 223 else 224 { 225 $info['clientid'] = md5($id); 226 } 227 228 $string = ""; 229 $amp = ""; 230 foreach($info as $key => $value) 231 { 232 $string .= $amp.$key."=".urlencode($value); 233 $amp = "&"; 234 } 235 236 $server_stats_url = 'https://community.mybb.com/server_stats.php?'.$string; 237 238 $return = array(); 239 $return['info_sent_success'] = false; 240 if(fetch_remote_file($server_stats_url) !== false) 241 { 242 $return['info_sent_success'] = true; 243 } 244 $return['info_image'] = "<img src='".$server_stats_url."&img=1' />"; 245 $return['info_get_string'] = $string; 246 247 return $return; 248 } 249 250 /** 251 * parser_php_info 252 * Function to get and parse the list of PHP info into a usuable array 253 * 254 * @return Array An array of all the extensions installed in PHP 255 */ 256 function parse_php_info() 257 { 258 ob_start(); 259 phpinfo(INFO_MODULES); 260 $phpinfo_html = ob_get_contents(); 261 ob_end_clean(); 262 263 $phpinfo_html = strip_tags($phpinfo_html, "<h2><th><td>"); 264 $phpinfo_html = preg_replace("#<th[^>]*>([^<]+)<\/th>#", "<info>$1</info>", $phpinfo_html); 265 $phpinfo_html = preg_replace("#<td[^>]*>([^<]+)<\/td>#", "<info>$1</info>", $phpinfo_html); 266 $phpinfo_html = preg_split("#(<h2[^>]*>[^<]+<\/h2>)#", $phpinfo_html, -1, PREG_SPLIT_DELIM_CAPTURE); 267 $modules = array(); 268 269 for($i=1; $i < count($phpinfo_html); $i++) 270 { 271 if(preg_match("#<h2[^>]*>([^<]+)<\/h2>#", $phpinfo_html[$i], $match)) 272 { 273 $name = trim($match[1]); 274 $tmp2 = explode("\n", $phpinfo_html[$i+1]); 275 foreach($tmp2 as $one) 276 { 277 $pat = '<info>([^<]+)<\/info>'; 278 $pat3 = "/$pat\s*$pat\s*$pat/"; 279 $pat2 = "/$pat\s*$pat/"; 280 281 // 3 columns 282 if(preg_match($pat3, $one, $match)) 283 { 284 $modules[$name][trim($match[1])] = array(trim($match[2]), trim($match[3])); 285 } 286 // 2 columns 287 else if(preg_match($pat2, $one, $match)) 288 { 289 $modules[$name][trim($match[1])] = trim($match[2]); 290 } 291 } 292 } 293 } 294 return $modules; 295 } 296
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| 2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |