(!is_callable('version_compare') or version_compare(PHP_VERSION, '4.3.0', '<')) ? gTxt('php_version_4_3_0_required') : '', 'path_to_site_missing' => (!isset($path_to_site)) ? gTxt('path_to_site_missing') : '', 'dns_lookup_fails' => (@gethostbyname($mydomain) == $mydomain) ? gTxt('dns_lookup_fails').cs. $mydomain : '', 'path_to_site_inacc' => (!@is_dir($path_to_site)) ? gTxt('path_to_site_inacc').cs.$path_to_site : '', 'site_trailing_slash' => (rtrim($siteurl, '/') != $siteurl) ? gTxt('site_trailing_slash').cs.$path_to_site : '', 'index_inaccessible' => (!@is_file($path_to_site."/index.php") or !@is_readable($path_to_site."/index.php")) ? "{$path_to_site}/index.php ".gTxt('is_inaccessible') : '', 'dir_not_writable' => trim( ((!@is_writable($path_to_site.'/'.$img_dir)) ? str_replace('{dirtype}', gTxt('img_dir'), gTxt('dir_not_writable')).": {$path_to_site}/{$img_dir}".n : ''). ((!@is_writable($file_base_path)) ? str_replace('{dirtype}', gTxt('file_base_path'), gTxt('dir_not_writable')).": {$file_base_path}".n : ''). ((!@is_writable($tempdir)) ? str_replace('{dirtype}', gTxt('tempdir'), gTxt('dir_not_writable')).": {$tempdir}".n : '')), 'cleanurl_only_apache' => ($permlink_mode != 'messy' and !$is_apache ) ? gTxt('cleanurl_only_apache') : '', 'htaccess_missing' => ($permlink_mode != 'messy' and !@is_readable($path_to_site.'/.htaccess')) ? gTxt('htaccess_missing') : '', 'mod_rewrite_missing' => ($permlink_mode != 'messy' and is_callable('apache_get_modules') and !apache_module('mod_rewrite')) ? gTxt('mod_rewrite_missing') : '', 'file_uploads_disabled' => (!ini_get('file_uploads')) ? gTxt('file_uploads_disabled') : '', 'setup_still_exists' => (@is_dir(txpath . DS. 'setup')) ? txpath.DS."setup".DS.' '.gTxt('still_exists') : '', 'no_temp_dir' => (empty($tempdir)) ? gTxt('no_temp_dir') : '', 'warn_mail_unavailable' => (is_disabled('mail')) ? gTxt('warn_mail_unavailable') : '', 'warn_register_globals_or_update' => ( $is_register_globals && ( version_compare(phpversion(),'4.4.0','<=') or ( version_compare(phpversion(),'5.0.0','>=') and version_compare(phpversion(),'5.0.5','<=') ) )) ? gTxt('warn_register_globals_or_update') : '', ); if ($permlink_mode != 'messy') { $rs = safe_column("name","txp_section", "1"); foreach ($rs as $name) { if ($name and @file_exists($path_to_site.'/'.$name)) $fail['old_placeholder_exists'] = gTxt('old_placeholder').": {$path_to_site}/{$name}"; } } $missing = array(); foreach ($files as $f) { $realpath = realpath(txpath . $f); if (is_readable($realpath)) { $found[] = $realpath; } else { $missing[] = txpath . $f; } } $files = $found; unset($found); if ($missing) $fail['missing_files'] = gTxt('missing_files').cs.n.t.join(', '.n.t, $missing); foreach ($fail as $k=>$v) if (empty($v)) unset($fail[$k]); # Find the highest revision number $file_revs = $file_md5 = array(); $rev = 0; foreach ($files as $f) { $content = @file_get_contents($f); if ($content !== FALSE) { if (preg_match('/^\$'.'LastChangedRevision: (\d+) \$/m', $content, $match)) { $file_revs[$f] = $match[1]; if ($match[1] > $rev) { $rev = $match[1]; } } $file_md5[$f] = md5(str_replace('$'.'HeadURL: http:', '$'.'HeadURL: https:', str_replace("\r\n", "\n", $content))); } } # Check revs & md5 against stable release, if possible $dev_files = $old_files = $modified_files = array(); if ($cs = @file(txpath . '/checksums.txt')) { foreach ($cs as $c) { if (preg_match('@^(\S+): r?(\S+) \((.*)\)$@', trim($c), $m)) { list(,$file,$r,$md5) = $m; $file = realpath(txpath . $file); if (!empty($file_revs[$file]) and $r and $file_revs[$file] < $r) { $old_files[] = $file; } elseif (!empty($file_revs[$file]) and $r and $file_revs[$file] > $r) { $dev_files[] = $file; } elseif (!empty($file_md5[$file]) and $file_md5[$file] != $md5) { $modified_files[] = $file; } } } } # files that haven't been updated if ($old_files) $fail['old_files'] = gTxt('old_files').cs.n.t.join(', '.n.t, $old_files); # files that don't match their checksums if ($modified_files) $fail['modified_files'] = gTxt('modified_files').cs.n.t.join(', '.n.t, $modified_files); # running development code in live mode is not recommended if ($dev_files and $production_status == 'live') $fail['dev_version_live'] = gTxt('dev_version_live').cs.n.t.join(', '.n.t, $dev_files); # anything might break if arbitrary functions are disabled if (ini_get('disable_functions')) { $disabled_funcs = array_map('trim', explode(',', ini_get('disable_functions'))); # commonly disabled functions that we don't need $disabled_funcs = array_diff($disabled_funcs, array( 'imagefilltoborder', 'exec', 'system', 'dl', 'passthru', 'chown', 'shell_exec', 'popen', 'proc_open', )); if ($disabled_funcs) $fail['some_php_functions_disabled'] = gTxt('some_php_functions_disabled').cs.join(', ',$disabled_funcs); } # not sure about this one #if (strncmp(php_sapi_name(), 'cgi', 3) == 0 and ini_get('cgi.rfc2616_headers')) # $fail['cgi_header_config'] = gTxt('cgi_header_config'); $guess_site_url = $_SERVER['HTTP_HOST'] . preg_replace('#[/\\\\]$#','',dirname(dirname($_SERVER['SCRIPT_NAME']))); if ($siteurl and strip_prefix($siteurl, 'www.') != strip_prefix($guess_site_url, 'www.')) $fail['site_url_mismatch'] = gTxt('site_url_mismatch').cs.$guess_site_url; # test clean URL server vars if (hu) { if (ini_get('allow_url_fopen') and ($permlink_mode != 'messy')) { $s = md5(uniqid(rand(), true)); ini_set('default_socket_timeout', 10); $pretext_data = @file(hu.$s.'/?txpcleantest=1'); if ($pretext_data) { $pretext_req = trim(@$pretext_data[0]); if ($pretext_req != md5('/'.$s.'/?txpcleantest=1')) $fail['clean_url_data_failed'] = gTxt('clean_url_data_failed').cs.htmlspecialchars($pretext_req); } else $fail['clean_url_test_failed'] = gTxt('clean_url_test_failed'); } } if ($tables = list_txp_tables()) { $table_errors = check_tables($tables); if ($table_errors) $fail['mysql_table_errors'] = gTxt('mysql_table_errors').cs.n.t.join(', '.n.t, $table_errors); } $active_plugins = array(); if ($rows = safe_rows('name, version, code_md5, md5(code) as md5', 'txp_plugin', 'status > 0')) { foreach ($rows as $row) { $n = $row['name'].'-'.$row['version']; if (strtolower($row['md5']) != strtolower($row['code_md5'])) $n .= 'm'; $active_plugins[] = $n; } } // check GD info if (function_exists('gd_info')) { $gd_info = gd_info(); $gd_support = array(); if ($gd_info['GIF Create Support']) { $gd_support[] = 'GIF'; } if ($gd_info['JPG Support']) { $gd_support[] = 'JPG'; } if ($gd_info['PNG Support']) { $gd_support[] = 'PNG'; } if ($gd_support) { $gd_support = join(', ', $gd_support); } else { $gd_support = gTxt('none'); } $gd = gTxt('gd_info', array( '{version}' => $gd_info['GD Version'], '{supported}' => $gd_support )); } else { $gd = gTxt('gd_unavailable'); } if ( realpath($prefs['tempdir']) == realpath($prefs['plugin_cache_dir']) ) { $fail['tmp_plugin_paths_match'] = gTxt('tmp_plugin_paths_match'); } echo pagetop(gTxt('tab_diagnostics'),''), startTable('list'), tr(td(hed(gTxt('preflight_check'),1))); if ($fail) { foreach ($fail as $help => $message) echo tr(tda(nl2br($message).sp.popHelp($help), ' class="not-ok"')); } else { echo tr(tda(gTxt('all_checks_passed'), ' class="ok"')); } echo tr(td(hed(gTxt('diagnostic_info'),1))); $fmt_date = '%Y-%m-%d %H:%M:%S'; $out = array( ''.br; $dets = array('low'=>gTxt('low'),'high'=>gTxt('high')); $out[] = form( eInput('diag').n. gTxt('detail').cs. selectInput('step', $dets, $step, 0, 1) ); echo tr(td(join('',$out))), endTable(); } ?>