public function verify_file_contents() { $includedfiles = get_dir_contents($this->unzipdir); $okfiles = array(); $badfiles = array(); // check what arrived in the directory foreach ($includedfiles as $k => $f) { // @todo penny later we might need this if (is_dir($f)) { $badfiles[] = $f; unset($includedfiles[$k]); continue; } $sha1 = sha1_file($this->unzipdir . $f); if (array_key_exists($sha1, $this->manifest)) { $tmp = new StdClass(); $tmp->sha1 = $sha1; $tmp->wantsfilename = $this->manifest[$sha1]['filename']; $tmp->actualfilename = $f; $okfiles[] = $tmp; unset($includedfiles[$k]); continue; } $badfiles[] = $f; unset($includedfiles[$k]); } $ok_c = count($okfiles); $bad_c = count($badfiles); $man_c = count($this->manifest); if ($ok_c != $man_c) { throw new ImportException('Files receieved did not exactly match what was in the manifest'); // @todo penny later - better reporting (missing files, too many files, etc) } $this->files = $okfiles; }
public function verify_file_contents() { $uzd = $this->importertransport->get('tempdir') . 'extract/'; $includedfiles = get_dir_contents($uzd); $okfiles = array(); $badfiles = array(); // check what arrived in the directory foreach ($includedfiles as $k => $f) { // @todo penny later we might need this if (is_dir($f)) { $badfiles[] = $f; unset($includedfiles[$k]); continue; } if (get_config('viruschecking')) { $pathtoclam = escapeshellcmd(trim(get_config('pathtoclam'))); if ($pathtoclam && file_exists($pathtoclam) && is_executable($pathtoclam)) { if ($errormsg = mahara_clam_scan_file($uzd . $f)) { throw new ImportException($this, $errormsg); } } else { clam_mail_admins(get_string('clamlost', 'mahara', $pathtoclam)); } } $sha1 = sha1_file($uzd . $f); if (array_key_exists($sha1, $this->manifest)) { $tmp = new StdClass(); $tmp->sha1 = $sha1; $tmp->wantsfilename = $this->manifest[$sha1]['filename']; $tmp->actualfilename = $f; $okfiles[] = $tmp; unset($includedfiles[$k]); continue; } $badfiles[] = $f; unset($includedfiles[$k]); } $ok_c = count($okfiles); $bad_c = count($badfiles); $man_c = count($this->manifest); if ($ok_c != $man_c) { throw new ImportException($this, 'Files receieved did not exactly match what was in the manifest'); // @todo penny later - better reporting (missing files, too many files, etc) } $this->files = $okfiles; }
if ($language == "tr") { echo "selected"; } ?> >Turkish</option> </SELECT> </td> <td> 语言包 (用于前台搜索页)</td> </tr> <tr> <td class="left1"> <SELECT name="_template"> <?php $directories = get_dir_contents($template_dir); if (count($directories) > 0) { for ($i = 0; $i < count($directories); $i++) { $dir = $directories[$i]; ?> <option value="<?php print $dir; ?> " <?php if ($template == $dir) { echo "selected"; } ?> ><?php print $dir; ?>
/** * Fifth installation step: FTP upload (not used for manual installer). * * @return array A pair: progress report/ui, and number of files uploaded so far (or -1 meaning all uploaded) */ function step_5_ftp() { global $FILE_ARRAY, $DIR_ARRAY; if (count($_POST) == 0) { exit(do_lang('INST_POST_ERROR')); } if (!is_suexec_like()) { if (!function_exists('ftp_connect')) { warn_exit(do_lang_tempcode('NO_PHP_FTP')); } $ftp_domain = trim(post_param('ftp_domain')); if (strpos($ftp_domain, 'ftp://') !== false) { warn_exit(do_lang_tempcode('FTP_DOMAIN_NOT_LIKE_THIS')); } $port = 21; if (strpos($ftp_domain, ':') !== false) { list($ftp_domain, $_port) = explode(':', $ftp_domain, 2); $port = intval($_port); } $conn = false; if (function_exists('ftp_ssl_connect')) { $conn = @ftp_ssl_connect($ftp_domain, $port); } $ssl = $conn !== false; $username = trim(post_param('ftp_username')); $password = trim(post_param('ftp_password')); if ($ssl && @ftp_login($conn, $username, $password) === false) { $conn = false; $ssl = false; } if ($conn === false) { $conn = ftp_connect($ftp_domain, $port); } if ($conn === false) { warn_exit(do_lang_tempcode('NO_FTP_CONNECT')); } if (!$ssl && !@ftp_login($conn, $username, $password)) { warn_exit(do_lang_tempcode('NO_FTP_LOGIN', @strval($php_errormsg))); } $ftp_folder = post_param('ftp_folder'); if (substr($ftp_folder, -1) != '/') { $ftp_folder .= '/'; } if (!@ftp_chdir($conn, $ftp_folder)) { warn_exit(do_lang_tempcode('NO_FTP_DIR', @strval($php_errormsg), '1')); } $files = @ftp_nlist($conn, '.'); if ($files === false) { $files = array(); if (@ftp_rename($conn, 'install.php', 'install.php')) { $files = array('install.php', 'data.ocp'); } } if (!in_array('install.php', $files)) { warn_exit(do_lang_tempcode('NO_FTP_DIR', @strval($php_errormsg), '2')); } $overwrite_ok = !file_exists(get_file_base() . '/ocp_inst_tmp/tmp'); // Because if the file doesn't exist, the step completed in full - we DON'T want to overwrite if it didn't, because the step probably timed out and by refreshing we complete the step in pieces if (!file_exists('ocp_inst_tmp')) { // Make temporary directory if (!in_array('ocp_inst_tmp', $files) && !is_string(@ftp_mkdir($conn, 'ocp_inst_tmp'))) { warn_exit(do_lang_tempcode('NO_FTP_ACCESS')); } @ftp_site($conn, 'CHMOD 0777 ocp_inst_tmp'); } if (!is_writable_wrap('ocp_inst_tmp')) { warn_exit(do_lang_tempcode('MANUAL_CHMOD_TMP_FILE')); } // Test tmp file isn't currently being used by another iteration of process (race issue, causing horrible corruption) $file_size_before = @filesize(get_file_base() . '/ocp_inst_tmp/tmp'); sleep(1); $file_size_after = @filesize(get_file_base() . '/ocp_inst_tmp/tmp'); if ($file_size_before !== $file_size_after) { warn_exit(do_lang_tempcode('DATA_FILE_CONFLICT')); } // Test tmp file isn't currently being used by another iteration of process (race issue, causing horrible corruption) $lock_myfile = fopen(get_file_base() . '/ocp_inst_tmp/tmp', 'ab'); if (!defined('PHALANGER')) { if (!flock($lock_myfile, LOCK_EX)) { warn_exit(do_lang_tempcode('DATA_FILE_CONFLICT')); } } $file_size_before = @filesize(get_file_base() . '/ocp_inst_tmp/tmp'); sleep(1); $file_size_after = @filesize(get_file_base() . '/ocp_inst_tmp/tmp'); if ($file_size_before !== $file_size_after) { warn_exit(do_lang_tempcode('DATA_FILE_CONFLICT')); } fclose($lock_myfile); } else { $overwrite_ok = true; $files = array(); if (file_exists(get_file_base() . '/info.php')) { $files[] = 'info.php'; } } // Make folders $langs1 = get_dir_contents('lang'); $langs2 = get_dir_contents('lang_custom'); $langs = array_merge($langs1, $langs2); foreach ($DIR_ARRAY as $dir) { if (strpos($dir, '/' . fallback_lang()) !== false) { foreach (array_keys($langs) as $lang) { if ($lang == fallback_lang() || strpos($lang, '.') !== false) { continue; } if (is_suexec_like()) { @mkdir(get_file_base() . '/' . str_replace('/' . fallback_lang(), '/' . $lang, $dir), 0777); fix_permissions(get_file_base() . '/' . str_replace('/' . fallback_lang(), '/' . $lang, $dir), 0777); } else { @ftp_mkdir($conn, str_replace('/' . fallback_lang(), '/' . $lang, $dir)); @ftp_site($conn, 'CHMOD 755 ' . str_replace('/' . fallback_lang(), '/' . $lang, $dir)); } } } if (is_suexec_like()) { @mkdir(get_file_base() . '/' . $dir, 0777); fix_permissions(get_file_base() . '/' . $dir, 0777); } else { @ftp_mkdir($conn, $dir); if ($dir == 'exports/mods' && !is_suexec_like()) { @ftp_site($conn, 'CHMOD 777 ' . $dir); } else { @ftp_site($conn, 'CHMOD 755 ' . $dir); } } } // Upload files $count = file_array_count(); $php_perms = fileperms(get_file_base() . '/install.php'); $start_pos = get_param_integer('start_from', 0); $done_all = false; $time_start = time(); $max_time = intval(round(floatval(ini_get('max_execution_time')) / 1.5)); $max = post_param_integer('max', is_suexec_like() ? 5000 : 1000); for ($i = $start_pos; $i < $start_pos + $max; $i++) { list($filename, $contents) = file_array_get_at($i); if (is_string($contents)) { $file_size = strlen($contents); } else { list($file_size, $dump_myfile, $dump_offset) = $contents; } if ($filename != 'info.php' || !in_array('info.php', $files)) { if (($overwrite_ok || !file_exists(get_file_base() . '/' . $filename) || @filemtime(get_file_base() . '/' . $filename) < filemtime(get_file_base() . '/install.php') || filesize(get_file_base() . '/' . $filename) != $file_size) && ($filename != 'forum/index.php' || !file_exists(get_file_base() . '/' . $filename))) { if (strpos($filename, '/' . fallback_lang() . '/') !== false && is_string($contents)) { foreach (array_keys($langs) as $lang) { if ($lang == fallback_lang() || strpos($lang, '.') !== false) { continue; } if (is_suexec_like()) { $myfile = fopen(get_file_base() . '/' . str_replace('/' . fallback_lang() . '/', '/' . $lang . '/', $filename), 'wb'); fwrite($myfile, $contents); fclose($myfile); fix_permissions(get_file_base() . '/' . str_replace('/' . fallback_lang() . '/', '/' . $lang . '/', $filename), 0666); } else { @ftp_delete($conn, str_replace('/' . fallback_lang() . '/', '/' . $lang . '/', $filename)); $tmp = fopen(get_file_base() . '/ocp_inst_tmp/tmp', 'wb'); fwrite($tmp, $contents); fclose($tmp); ftp_put($conn, str_replace('/' . fallback_lang() . '/', '/' . $lang . '/', $filename), get_file_base() . '/ocp_inst_tmp/tmp', FTP_BINARY); $mask = 0; if (get_file_extension($filename) == 'php') { if (($php_perms & 0100) == 0100) { $mask = $mask | 0100; } if (($php_perms & 010) == 010) { $mask = $mask | 010; } if (($php_perms & 01) == 01) { $mask = $mask | 01; } } @ftp_site($conn, 'CHMOD 0' . decoct(0644 | $mask) . ' ' . str_replace('/' . fallback_lang() . '/', '/' . $lang . '/', $filename)); } } } if (is_suexec_like()) { $myfile = fopen(get_file_base() . '/' . $filename, 'wb'); if (is_string($contents)) { fwrite($myfile, $contents); } else { fseek($dump_myfile, $dump_offset, SEEK_SET); $amount_read = 0; while ($amount_read < $file_size) { $read_amount = min(4096, $file_size - $amount_read); $shuttle_contents = fread($dump_myfile, $read_amount); fwrite($myfile, $shuttle_contents); $amount_read += strlen($shuttle_contents); } } fclose($myfile); fix_permissions(get_file_base() . '/' . $filename, 0666); } else { @ftp_delete($conn, $filename); $tmp = fopen(get_file_base() . '/ocp_inst_tmp/tmp', 'wb'); if (is_string($contents)) { fwrite($tmp, $contents); } else { fseek($dump_myfile, $dump_offset, SEEK_SET); $amount_read = 0; while ($amount_read < $file_size) { $read_amount = min(4096, $file_size - $amount_read); $shuttle_contents = fread($dump_myfile, $read_amount); fwrite($tmp, $shuttle_contents); $amount_read += strlen($shuttle_contents); } } fclose($tmp); if (!@ftp_put($conn, $filename, get_file_base() . '/ocp_inst_tmp/tmp', FTP_BINARY)) { if (strpos(@strval($php_errormsg), 'bind() failed') !== false) { warn_exit(do_lang_tempcode('FTP_FIREWALL_ERROR')); } else { warn_exit(@strval($php_errormsg)); } } $mask = 0; if (get_file_extension($filename) == 'php') { if (($php_perms & 0100) == 0100) { $mask = $mask | 0100; } if (($php_perms & 010) == 010) { $mask = $mask | 010; } if (($php_perms & 01) == 01) { $mask = $mask | 01; } } @ftp_site($conn, 'CHMOD ' . decoct(0644 | $mask) . ' ' . $filename); } } } if ($max_time > 0 && time() - $time_start >= $max_time) { break; } if ($i + 1 == $count) { $done_all = true; break; // That's them all } } if (!is_suexec_like()) { if (!file_exists(get_file_base() . '/ocp_inst_tmp/tmp')) { warn_exit(do_lang_tempcode('DOUBLE_INSTALL_DO')); } @unlink(get_file_base() . '/ocp_inst_tmp/tmp'); } test_htaccess(is_suexec_like() ? NULL : $conn); $log = new ocp_tempcode(); if ($done_all) { // If the file user is different to the FTP user, we need to make it world writeable if (!is_suexec_like()) { // Chmod global $CHMOD_ARRAY; $no_chmod = false; foreach ($CHMOD_ARRAY as $chmod) { if (file_exists($chmod) && !@ftp_site($conn, 'CHMOD 0777 ' . $chmod)) { $no_chmod = true; } } $log->attach(do_template('INSTALLER_DONE_SOMETHING', array('_GUID' => '2e4ccdd5a0b034125ee62403d5a48319', 'SOMETHING' => do_lang_tempcode(!$no_chmod ? 'CHMOD_PASS' : 'CHMOD_FAIL')))); } } if (!is_suexec_like()) { if (function_exists('ftp_close')) { ftp_close($conn); } } $log->attach(do_template('INSTALLER_DONE_SOMETHING', array('_GUID' => '1b447cee9e9aa3ad8e24530d4dceb03f', 'SOMETHING' => do_lang_tempcode('FILES_TRANSFERRED', strval($i + 1), strval($count))))); return array($log, $done_all ? -1 : $i); }
function statisticsForm($type) { global $db_con, $mysql_table_prefix, $log_dir, $include_dir, $sites_per_page, $search_script; global $debug, $thumb_dir, $start, $image_dir, $mysql_csize, $mysql_cacheon, $dba_act; global $index_id3, $delim, $thumb_folder; error_reporting(0); echo "<div class='submenu cntr'>| Database {$dba_act} with table prefix '{$mysql_table_prefix}' |</div>\n <div class='submenu y4'>\n <ul>\n <li><a href='admin.php?f=statistics&type=keywords' title='Show list of Top 100 Keywords'>Top keywords</a></li>\n <li><a href='admin.php?f=statistics&type=thumb_files' title='Show list of all indexed thumbnails.'>Indexed Thumbnails</a></li>\n <li><a href='admin.php?f=statistics&type=pages' title='Show list of Largest Pages and their indexed file size'>Largest pages</a></li>\n <li><a href='admin.php?f=statistics&type=spidering_log' title='Show list of Spidering Logs'>Spidering logs</a></li>\n <li><a href='admin.php?f=statistics&type=autoindex' title='Show start time and index counter'>Auto Re-index log file</a></li>\n <li><a href='admin.php?f=statistics&type=ids' title='Show list of intrusion attempts'>IDS log file</a></li>\n <li><a href='admin.php?f=statistics&type=server_info' title='Show all available server info'>Server Info</a></li>\n </ul>\n <br /><br />\n <ul>\n <li><a href='admin.php?f=statistics&type=log' title='Show Search Log activity'>Search log</a></li>\n <li><a href='admin.php?f=statistics&type=top_searches' title='Show list of the most popular on-line Searches'>Most popular searches</a></li>\n <li><a href='admin.php?f=statistics&type=top_links' title='Show list of the most popular page links, clicked by the user'>Most popular page links</a></li>\n <li><a href='admin.php?f=statistics&type=top_media' title='Show list of the most popular media flinks, clicked by the user'>Most popular media links</a></li>\n </ul>\n </div>\n "; if ($type == "") { $cachedSumQuery = "SELECT sum(length(fulltxt)) from " . $mysql_table_prefix . "links"; $result = $db_con->query($cachedSumQuery); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); printf("<p>{$cachedSumQuery}</p>"); exit; } if ($row = $result->fetch_array(MYSQLI_NUM)) { $cachedSumSize = $row[0]; } $cachedSumSize = number_format($cachedSumSize / 1024, 2); $sitesSizeQuery = "SELECT sum(size) from " . $mysql_table_prefix . "links"; $result = $db_con->query("{$sitesSizeQuery}"); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); printf("<p>{$sitesSizeQuery}</p>"); exit; } if ($row = $result->fetch_array(MYSQLI_NUM)) { $sitesSize = $row[0]; } $sitesSize = number_format($sitesSize, 2); $sql_query = "SELECT ip from " . $mysql_table_prefix . "query_log"; $result = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $query_tot = '0'; $sql_query = "SELECT count(*) from " . $mysql_table_prefix . "query_log"; $result = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } if ($row = $result->fetch_array(MYSQLI_NUM)) { $query_tot = $row[0]; } $page_clicks = '0'; $sql_query = "SELECT sum(click_counter) from " . $mysql_table_prefix . "links"; $result = $db_con->query($sql_query); if (!$db_con->errno) { if ($row = $result->fetch_array(MYSQLI_NUM)) { $page_clicks = $row[0]; } $result = $db_con->query("SELECT count(*) from " . $mysql_table_prefix . "media"); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } if ($row = $result->fetch_array(MYSQLI_NUM)) { $media_tot = $row[0]; } $media_clicks = '0'; $sql_query = "SELECT * from " . $mysql_table_prefix . "media where click_counter > 0"; $result = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } if ($row = $result->num_rows) { $media_clicks = $row; } $stats = getStatistics(); echo "<div class='panel w60'>\n <dl class='tblhead'>\n <dt class='headline x2'>Overall Statistics :</dt><dd class='headline'> Counts</dd>\n <dt class='odrow bd x2'>Sites :</dt><dd class='odrow'> " . $stats['sites'] . "</dd>\n <dt class='evrow bd x2'>Links :</dt><dd class='evrow'> " . $stats['links'] . "</dd>\n <dt class='odrow bd x2'>Categories :</dt><dd class='odrow'> " . $stats['categories'] . "</dd>\n <dt class='evrow bd x2'>Keywords :</dt><dd class='evrow'> " . $stats['keywords'] . "</dd>\n <dt class='odrow bd x2'>Media files :</dt><dd class='odrow'> {$media_tot}</dd>\n <dt class='odrow bd x2'>Keyword link-relations :</dt><dd class='odrow'> " . $stats['index'] . "</dd>\n <dt class='evrow bd x2'>Cached texts total :</dt><dd class='evrow'> {$cachedSumSize} kb</dd>\n <dt class='odrow bd x2'>Sites size total :</dt><dd class='odrow'> {$sitesSize} kb</dd>\n <dt class='evrow bd x2'>Queries total :</dt><dd class='evrow'> {$query_tot}</dd>\n <dt class='odrow bd x2'>Page Link clicks total :</dt><dd class='odrow'> {$page_clicks}</dd>\n <dt class='odrow bd x2'>Media Link clicks total :</dt><dd class='odrow'> {$media_clicks}</dd>\n </dl>\n </div>\n "; } else { echo "\n <div class='submenu cntr'>\n <span class='warnadmin'>\n "; echo "<br /><br /><br />\n Invalid database table installation.\n <br />\n </span>\n </div>\n <br /><br />\n "; die; } echo "</div>\n </div>\n </body>\n </html>\n "; exit; } if ($type == 'keywords') { $class = "evrow"; $sql_query = "SELECT keyword, count(" . $mysql_table_prefix . "link_keyword.keyword_id) as x from " . $mysql_table_prefix . "keywords, " . $mysql_table_prefix . "link_keyword\n where " . $mysql_table_prefix . "keywords.keyword_id = " . $mysql_table_prefix . "link_keyword.keyword_id group by keyword order by x desc limit 30"; $result = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $num_rows = $result->num_rows; if ($num_rows) { while ($row = $result->fetch_array(MYSQLI_NUM)) { $topwords[$row[0]] = $row[1]; } } arsort($topwords); echo "<div class='panel'>\n <p class='headline cntr'>Top 100 Keywords</p>\n "; $nloops = 1; do { $nloops++; $count = 1; echo "<div class='ltfloat x3'>\n <dl>\n <dt class='headline x2'>Keyword</dt><dd class='headline'>: Instances</dd>\n "; while ((list($word, $weight) = each($topwords)) && $count < 34) { $count++; if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } echo "<dt class='{$class}'><a href='../{$search_script}?query={$word}&search=1' target='rel' title='View search results in new window'>" . trim(substr($word, 0, 35)) . "</a></dt>\n <dd class='{$class}'>: " . $weight . "</dd>\n "; } echo "</dl>\n </div>\n "; } while ($nloops <= 3); echo "<div class='clear'></div>\n <br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br />\n </div>\n </div>\n </div>\n </body>\n </html>\n "; exit; } if ($type == 'pages') { $class = "evrow"; echo "<div class='panel'>\n <dl class='tblhead'>\n <dt class='headline x8'>File Size</dt><dd class='headline cntr'>Links to Largest Pages</dd>\n "; $sql_query = "SELECT " . $mysql_table_prefix . "links.link_id, url, length(fulltxt) as x from " . $mysql_table_prefix . "links order by x desc LIMIT 20"; $result = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } while ($row = $result->fetch_array(MYSQLI_NUM)) { if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } $url = reconvert_url($row[1]); $sum = number_format($row[2] / 1024, 2); echo "<dt class='{$class} x8'>" . $sum . "kb </dt>\n <dd class='{$class}'><a href='{$url}' title='Open this page in new window' target='_blank'>" . $url . "</a></dd>\n "; } echo "</dl>\n <br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br />\n </div>\n </div>\n </div>\n </body>\n </html>\n "; exit; } if ($type == 'top_searches') { $class = "evrow"; echo "<div class='panel'>\n <p class='headline cntr sml'>Most Popular Searches (Top 50)</p>\n <table width='100%'>\n <tr>\n <td class='tblhead'>Query</td>\n <td class='tblhead'>Count</td>\n <td class='tblhead'>Media query</td>\n <td class='tblhead'>Average results</td>\n <td class='tblhead'>Last queried</td>\n <td class='tblhead'>Queried by IP</td>\n <td class='tblhead'>Country</td>\n <td class='tblhead'>Host name</td>\n </tr>\n "; $sql_query = "SELECT query, count(*) as c, date_format(max(time), '%Y-%m-%d %H:%i:%s'), avg(results), media from " . $mysql_table_prefix . "query_log group by query order by c desc LIMIT 50"; $result = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } while ($row = $result->fetch_array(MYSQLI_NUM)) { if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } $word = $row[0]; $times = $row[1]; $date = $row[2]; $media = $row[4]; $avg = number_format($row[3], 0); $word = str_replace("\"", "", $word); $sql_query = "SELECT ip from " . $mysql_table_prefix . "query_log where query='{$word}' order by time desc "; $result1 = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $ips = $result1->fetch_array(MYSQLI_NUM); $ip = $ips[0]; //$ip = "222.46.18.34"; // just for tests if (intval($ip) > 0) { $hostname = @gethostbyaddr($ip); // very slow! comment this row, if not required if ($hostname == $ip) { $hostname = "Unknown host"; } } else { $hostname = "Unknown host"; // a bad address. } // convert any IP into IPv6 $ip6 = IPv4To6($ip); // find Country Code using the IPv6 database and IPV6 IPs $gi = geoip_open("GeoIPv6.dat", GEOIP_STANDARD); $cc = geoip_country_code_by_addr_v6($gi, $ip6); $country = geoip_country_name_by_addr_v6($gi, $ip6); geoip_close($gi); if ($media) { // prepare a media search $sql_query = "query_m=" . $word . "&submit=Media&search=1&media_only=0&cat_sel0=&cat_sel1=&cat_sel2=&cat_sel3=&cat_sel4=&type=and&results=10&db=0&prefix=0"; } else { // prepare a text search $sql_query = "query_t=" . $word . "&submit=Text&search=1&media_only=0&cat_sel0=&cat_sel1=&cat_sel2=&cat_sel3=&cat_sel4=&type=and&mark=blau+markiert&results=10&db=0&prefix=0"; } echo "<tr class='{$class} sml'>\n <td><a href='../{$search_script}?{$query}' target='_blank' title='Open this Log File in new window'>" . $word . "</a></td>\n <td class='cntr'> " . $times . "</td>\n <td class='cntr sml'> " . $media . "</td>\n <td class='cntr'> " . $avg . "</td>\n <td class='cntr'> " . $date . "</td>\n <td class='cntr'> " . $ip . "</td>\n <td class='cntr sml'> " . $cc . " - " . $country . "</td>\n <td class='cntr sml'> " . $hostname . "</td>\n </tr>\n "; } echo "\n </table>\n <br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br />\n </div>\n </div>\n </div>\n </body>\n </html>\n "; exit; } if ($type == 'top_links') { $class = "evrow"; echo "<div class='panel'>\n <p class='headline cntr sml'>Most Popular Links (Top 50)</p>\n <table width='100%'>\n <tr>\n <td class='tblhead'>Link</td>\n <td class='tblhead'>Total clicks</td>\n <td class='tblhead'>Last clicked</td>\n <td class='tblhead'>Last query</td>\n <td class='tblhead'>Queried<br />by IP</td>\n <td class='tblhead'>Country</td>\n <td class='tblhead'>Host name</td>\n </tr>\n "; $sql_query = "SELECT url, click_counter, last_click, last_query from " . $mysql_table_prefix . "links order by click_counter DESC, url LIMIT 50"; $result = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } while ($row = $result->fetch_array(MYSQLI_NUM)) { if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } $url = reconvert_url($row[0]); $click_counter = $row[1]; $Timestamp = $row[2]; $last_query = $row[3]; if ($Timestamp != '0') { $last_click = date("Y-m-d H:i:s", $Timestamp); $sql_query = "SELECT ip from " . $mysql_table_prefix . "links where last_query='{$last_query}' order by last_click desc "; $result1 = $db_con->query($sql_query); $ips = $result1->fetch_array(MYSQLI_NUM); $ip = $ips[0]; //$ip = "222.46.18.34"; // just for tests if (intval($ip) > 0) { $hostname = @gethostbyaddr($ip); // very slow! comment this row, if not required if ($hostname == $ip) { $hostname = "Unknown host"; } } else { $hostname = "Unknown host"; // a bad address. } // convert any IP into IPv6 $ip6 = IPv4To6($ip); // find Country Code using the IPv6 database and IPV6 IPs $gi = geoip_open("GeoIPv6.dat", GEOIP_STANDARD); $cc = geoip_country_code_by_addr_v6($gi, $ip6); $country = geoip_country_name_by_addr_v6($gi, $ip6); geoip_close($gi); echo "<tr class='{$class} sml'>\n <td><a href='{$url}' target='rel' title='View link in new window'>" . htmlentities($url) . "</a></td>\n <td class='cntr sml'> " . $click_counter . "</td>\n <td class='cntr sml'> " . $last_click . "</td>\n <td class='cntr sml'> " . $last_query . "</td>\n <td class='cntr'> " . $ip . "</td>\n <td class='cntr sml'> " . $cc . " - " . $country . "</td>\n <td class='cntr sml'> " . $hostname . "</td>\n </tr>\n "; } } echo "\n </table>\n <br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br />\n </div>\n </div>\n </div>\n </body>\n </html>\n "; exit; } if ($type == 'top_media') { $class = "evrow"; echo "<div class='panel'>\n <p class='headline cntr sml'>Most Popular Media (Top 50)</p>\n <form action='' id='fdeltm'>\n <table width='100%'>\n <tr>\n <td colspan='5' class='odrow bd'>\n <input type='hidden' name='f' value='14' />\n <input class='sbmt' id='submit11' type='submit' value='Clear this statistics' title='Start statistics deletion'\n onclick=\"return confirm('Are you sure you want to delete the 'Most popular media' statistics?')\" />\n </td>\n </tr>\n <tr>\n <td class='tblhead'>Thumbnail</td>\n <td class='tblhead'>Details</td>\n <td class='tblhead'>Total clicks</td>\n <td class='tblhead'>Last clicked</td>\n <td class='tblhead'>Last query</td>\n <td class='tblhead'>Queried<br />by IP</td>\n <td class='tblhead'>Country</td>\n <td class='tblhead'>Host name</td>\n </tr>\n "; $sql_query = "SELECT link_addr, media_link, thumbnail, title, type, click_counter, last_click, last_query from " . $mysql_table_prefix . "media order by click_counter DESC, media_link LIMIT 50"; $result = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } while ($row = $result->fetch_array(MYSQLI_NUM)) { if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } $title = substr($row[3], 0, strpos($row[3], $delim)); // extract original title without transliterated words $name0 = basename($var[1]); // extract file name $name = substr($name0, 0, strrpos($name0, ".")); // remove original suffix $last_query = $row[7]; // add folder path, db, table-prefix and add own suffix $file = utf8_decode("." . $thumb_folder . "/db" . $dba_act . "_" . $mysql_table_prefix . "_" . $name . ".gif"); // temporary save thumbnail in folder if (!($handle = fopen($file, "ab"))) { if ($debug > 0) { print "Unable to open {$file} "; } } if (!fwrite($handle, $row[2])) { if ($debug > 0) { print "Unable to write the file {$file}. No thumbnails will be presented"; } } fclose($handle); if ($row[4] == 'audio') { // use dummy thumbnail $thumb_link = "{$image_dir}/notes60.gif"; } if ($row[4] == 'video') { // use dummy thumbnail $thumb_link = "{$image_dir}/film60.gif"; } if ($row[6] != '0') { $last_click = date("Y-m-d H:i:s", $row[6]); $sql_query = "SELECT ip from " . $mysql_table_prefix . "media where last_query='{$last_query}' order by last_click desc "; $result1 = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $ips = $result1->fetch_array(MYSQLI_NUM); $ip = $ips[0]; //$ip = "222.46.18.34"; // just for tests if (intval($ip) > 0) { $hostname = @gethostbyaddr($ip); // very slow! comment this row, if not required if ($hostname == $ip) { $hostname = "Unknown host"; } } else { $hostname = "Unknown host"; // a bad address. } // convert any IP into IPv6 $ip6 = IPv4To6($ip); // find Country Code using the IPv6 database and IPV6 IPs $gi = geoip_open("GeoIPv6.dat", GEOIP_STANDARD); $cc = geoip_country_code_by_addr_v6($gi, $ip6); $country = geoip_country_name_by_addr_v6($gi, $ip6); geoip_close($gi); echo "<tr class='{$class} sml'>\n <td class='cntr'><a href='{$row['1']}' target='rel' title='Open this object'><img src='{$file}' border='1' alt='Open this object' /></a></td>\n <td><strong>Title:</strong> {$title}\n <br /><br />\n <strong>Found at:</strong> <a href='{$row['0']}' target='rel' title='Open this page in a new window'>{$row['0']}</a></td>\n <td class='cntr sml'> " . $row[5] . "</td>\n <td class='cntr sml'> " . $last_click . "</td>\n <td class='cntr sml'> " . $row[7] . "</td>\n <td class='cntr'> " . $ip . "</td>\n <td class='cntr sml'> " . $cc . " - " . $country . "</td>\n <td class='cntr sml'> " . $hostname . "</td>\n </tr>\n "; } } echo "\n </table>\n </form>\n <br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br />\n </div>\n </div>\n </div>\n </body>\n </html>\n "; exit; } if ($type == 'autoindex') { $i = "0"; $logfolder = "./log/"; if ($handle = opendir($logfolder)) { // open log-folder echo "<div class='panel'>\n "; while (false !== ($logfile = readdir($handle))) { //get all log files if (strstr($logfile, "db" . $dba_act . "_" . $mysql_table_prefix . "")) { //separate only log files of current active db and table prefix $att = ''; if (strstr($logfile, "._all")) { // this log file was created during 'Re-index all sites' $att = "all"; } else { // this log file was created during individual site indexing // extract site_id from file name $end = strrpos($logfile, "_"); $start = strpos($logfile, "._") + 2; $site_id = substr($logfile, $start, $end - $start); // get URL according to actual site_id $sql_query = "SELECT * from " . $mysql_table_prefix . "sites where site_id={$site_id}"; $result = $db_con->query($sql_query); $row = $result->fetch_array(MYSQLI_ASSOC); $site_url = $row['url']; } // build some nice headlines for monitor output if ($att) { $headline = "Periodical Re-indexer<br /><br />Log file created during indexing all sites"; } else { $headline = "<br >Periodical Re-indexer<br /><br />Log file created during indexing<br />{$site_url}<br />Site id: {$site_id}"; } $content = @file("log/" . $logfile . ""); // get content of the current logfile // output the periodical Re-indexer for each log file $class = "evrow"; echo "<p class='headline cntr sml'>{$headline}</p>\n <br />\n <table width='50%'>\n <tr>\n <td class='tblhead'>Index counter</td>\n <td class='tblhead'>Started</td>\n </tr>\n "; foreach ($content as $thisrow) { if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } $counter = substr($thisrow, 0, strpos($thisrow, "count")); $started = date("Y-m-d H:i:s", substr($thisrow, strpos($thisrow, "count") + 5)); // if Auto-indexer already finished by count limit if (strpos($thisrow, "inish")) { $counter = "finished:"; $started = date("Y-m-d H:i:s", substr($thisrow, strpos($thisrow, "finished") + 8)); } // if Auto-indexer already finished because interval was too short if (strpos($thisrow, "borted")) { $counter = "Aborted because<br />interval too short"; $started = date("Y-m-d H:i:s", substr($thisrow, strpos($thisrow, "finished") + 7)); } echo " <tr class='{$class} sml'>\n <td class='cntr'>{$counter}</td>\n <td class='cntr'>{$started}</td>\n </tr>\n "; } echo "</table>\n <br /><br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br /><br />\n "; $i++; } } if ($i < "1") { echo "<br />\n <p class='cntr msg'>Note: <span class='warnadmin'>Currently no log file available</span></p>\n "; } } echo "<br />\n </div>\n <br />\n </body>\n </html>\n "; exit; } if ($type == 'log') { $class = "evrow"; echo "<div class='panel w100'>\n <p class='headline cntr sml'>Search Log (Latest 100)</p>\n <table width='100%'>\n <tr>\n <td class='tblhead'>Query</td>\n <td class='tblhead'>Media query</td>\n <td class='tblhead'>Results</td>\n <td class='tblhead'>Queried at:</td>\n <td class='tblhead'>Time taken</td>\n <td class='tblhead'>User IP</td>\n <td class='tblhead'>Country</td>\n <td class='tblhead'>Host name</td>\n </tr>\n "; $sql_query = "SELECT query, date_format(time, '%Y-%m-%d %H:%i:%s'), elapsed, results, ip, media from " . $mysql_table_prefix . "query_log order by time desc LIMIT 100"; $result = $db_con->query($sql_query); while ($row = $result->fetch_array(MYSQLI_NUM)) { if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } $query = ''; $word = $row[0]; $time = $row[1]; $elapsed = $row[2]; $results = $row[3]; $ip = $row[4]; $media = $row[5]; //$ip = "222.46.18.34"; // just for tests if (intval($ip) > 0) { $hostname = @gethostbyaddr($ip); // very slow! comment this row, if not required if ($hostname == $ip) { $hostname = "Unknown host"; } } else { $hostname = "Unknown host"; // a bad address. } // convert any IP into IPv6 $ip6 = IPv4To6($ip); // find Country Code using the IPv6 database and IPV6 IPs $gi = geoip_open("GeoIPv6.dat", GEOIP_STANDARD); $cc = geoip_country_code_by_addr_v6($gi, $ip6); $country = geoip_country_name_by_addr_v6($gi, $ip6); geoip_close($gi); if ($media) { // prepare a media search $query = "query_m=" . $word . "&submit=Media&search=1&media_only=0&cat_sel0=&cat_sel1=&cat_sel2=&cat_sel3=&cat_sel4=&type=and&results=10&db=0&prefix=0"; } else { // prepare a text search $query = "query_t=" . $word . "&submit=Text&search=1&media_only=0&cat_sel0=&cat_sel1=&cat_sel2=&cat_sel3=&cat_sel4=&type=and&mark=blau+markiert&results=10&db=0&prefix=0"; } echo "<tr class='{$class}'>\n <td><a href='../{$search_script}?{$query}' target='_blank' title='Open this Log File in new window'>" . $word . "</a></td>\n <td class='cntr sml'> " . $media . "</td>\n <td class='cntr sml'> " . $results . "</td>\n <td class='cntr sml'> " . $time . "</td>\n <td class='cntr sml'> " . $elapsed . "</td>\n <td class='cntr sml'> " . $ip . "</td>\n <td class='cntr sml'> " . $cc . " - " . $country . "</td>\n <td class='cntr sml'> " . $hostname . "</td>\n </tr>\n "; } echo "\n </table>\n <br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br />\n </div>\n </div>\n </div>\n </body>\n </html>\n "; exit; } if ($type == 'spidering_log') { $class = "evrow"; $files = get_dir_contents($log_dir); if (count($files) > 0) { echo "<div class='panel w75'>\n <p class='headline cntr'>Spidering Logs</p>\n <form action='' id='fdelfm'>\n <table width='100%'>\n <tr>\n <td class='tblhead'>File</td>\n <td class='tblhead'>Created</td>\n <td class='tblhead' width='25%'>Option</td>\n </tr>\n <tr>\n <td colspan='3' class='odrow cntr bd'>\n <input type='hidden' name='f' value='44'\n />\n <input class='sbmt' id='submit1' type='submit' value='Delete ALL log files' title='Start Log File deletion'\n onclick=\"return confirm('Are you sure you want to delete ALL log files? ATTENTION: A still running periodical indexing will be aborted.')\" />\n </td>\n </tr>\n "; for ($i = 0; $i < count($files); $i++) { $file = $files[$i]; $year = substr($file, 4, 2); $month = substr($file, 6, 2); $day = substr($file, 8, 2); $hour = substr($file, 11, 2); $minute = substr($file, 14, 2); $second = substr($file, 17, 2); if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } echo "<tr class='{$class}'>\n <td class='cntr sml'>\n <a href='{$log_dir}/{$file}' target='_blank' title='Open this Log File in new window'>{$file}</a></td>\n "; if (strlen($file) > '13') { if (strstr($file, "auto-indexer")) { // the log-file for the Auto Re-indexer $logfile = "log/db" . $dba_act . "_" . $mysql_table_prefix . "._all_auto-indexer.log"; $content = @file($logfile); // content of the logfile $started = date("Y-m-d H:i:s", substr($content[0], strpos($content[0], "count") + 5)); echo " <td class='cntr sml'>{$started}</td>\n <td class='cntr sml options'><a href='?f=delete_log&file={$file}' class='options' title='Click to Delete this Log File'\n onclick=\"return confirm('Are you sure you want to delete? {$file} ATTENTION: Deleting this Log File may abort periodical Re-indexing.')\">Delete</a></td>\n "; } else { echo " <td class='cntr sml'>20{$year}-{$month}-{$day} {$hour}:{$minute}.{$second}</td>\n <td class='cntr sml options'><a href='?f=delete_log&file={$file}' class='options' title='Click to Delete this Log File'\n onclick=\"return confirm('Are you sure you want to delete '{$file}' Indexing Log File will be lost.')\">Delete</a></td>\n "; } } else { echo " <td></td><td></td>\n "; } echo "\n </tr>\n "; } echo "\n </table></form>\n <br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br />\n </div>\n "; } else { echo "<br />\n <p class='cntr msg'>Note: <span class='warnadmin'>No saved spidering logs exist!</span></p>\n <br /> <br />\n "; } echo "</div>\n </div>\n </body>\n </html>\n "; exit; } if ($type == 'thumb_files') { if ($thumb_folder) { // delete all former thumbnails in temporary folder clear_folder("." . $thumb_folder); } $class = "odrow"; $files = array(); $sql_query = "SELECT media_id from " . $mysql_table_prefix . "media"; $result = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $thumb_count = $result->num_rows; if ($thumb_count) { while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $files[] = $row['media_id']; } } //Prepare thumbnails and their info for listing //$sites_per_page = '100'; // if you prefer another count than used for Sphiders result pages, uncomment this row and place your count of thumbnails per page here. $pages = ceil($thumb_count / $sites_per_page); // Calculate count of required pages if (empty($start)) { $start = '1'; } // As $start is not yet defined this is required for the first result page if ($start == '1') { $from = '0'; // Also for first page in order not to multipy with 0 } else { $from = ($start - 1) * $sites_per_page; // First $num_row of actual page } $to = $thumb_count; // Last $num_row of actual page $rest = $thumb_count - $start; if ($thumb_count > $sites_per_page) { // Display more then one page? $rest = $thumb_count - $from; $to = $from + $rest; // $to for last page if ($rest > $sites_per_page) { $to = $from + $sites_per_page; } // Calculate $num_row of actual page } if ($thumb_count > '0') { $fromm = $from + 1; echo "<div class='panel'>\n <p class='headline cntr sml'>Displaying thumbnails {$fromm} - {$to} from {$thumb_count}</p>\n <form action='' id='fdelfm'>\n <table width='100%'>\n <tr>\n <td class='tblhead' width='30%'>Thumbnail</td>\n <td class='tblhead'>Details</td>\n <td class='tblhead' width='20%'>Option</td>\n </tr>\n <tr>\n <td colspan='3' class='odrow bd'>\n <input type='hidden' name='f' value='49' />\n <input class='sbmt' id='submit1' type='submit' value='Delete ALL images' title='Start File deletion'\n onclick=\"return confirm('Are you sure you want to delete ALL indexed images \\n and ALL thumbnail files?')\" />\n </td>\n </tr>\n "; for ($i = $from; $i < $to; $i++) { $this_thumb = $files[$i]; $i_1 = $i + 1; // so table output does not start with zero $result = $db_con->query("SELECT media_id, media_link, thumbnail, title from " . $mysql_table_prefix . "media where media_id like '{$this_thumb}'"); if ($result->num_rows > '0') { $var = $result->fetch_array(MYSQLI_NUM); $media_id = $var[0]; $this_img = $var[1]; $title = substr($var[3], 0, strpos($var[3], $delim)); // extract original title without transliterated words $name0 = basename($var[1]); // extract file name $name = substr($name0, 0, strrpos($name0, ".")); // remove original suffix // add folder path, db, table-prefix and add own suffix $file = utf8_decode("." . $thumb_folder . "/db" . $dba_act . "_" . $mysql_table_prefix . "_" . $name . ".gif"); // temporary save thumbnail in folder if (!($handle = fopen($file, "ab"))) { if ($debug > 0) { print "Unable to open {$file} "; } } if (!fwrite($handle, $var[2])) { if ($debug > 0) { print "Unable to write the file {$file}. No thumbnails will be presented"; } } fclose($handle); } if ($class == "odrow") { $class = "evrow"; } else { $class = "odrow"; } echo " <tr class='{$class}'>\n <td class='cntr x4'>\n <a href='{$this_img}' target='rel' title='View the real image (not only the thumbnail) in new window'><img src=\"{$file}\" border='1' alt=\"Thumbnail\" /></a>\n </td>\n <td class='lft sml'>\n <p> Thumb no.: {$i_1}</p>\n <p> File name: {$name0}</p>\n <p> Title: {$title}</p>\n <p> Thumb_ID : {$media_id}</p>\n "; if ($index_id3 == '1') { echo "<p><a href='" . $include_dir . "/show_id3.php?media_id={$media_id}' target='rel' title='Click here to see EXIF and ID3 Infos in a new window'>Show EXIF Info</a></p>\n "; } echo "</td>\n <td class='cntr sml options'>\n <a href='?f=delete_thumb&file={$media_id}' class='options' title='Click to delete this thumbnail'\n onclick=\"return confirm('Are you sure you want to delete \\'{$name}\\'. \\nThumbnail file will be lost.')\">Delete</a>\n </td>\n </tr>\n "; } echo "</table>\n </form>\n <br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br />\n </div>\n "; // Display end of table if ($thumb_count > 0) { echo "\n <br />"; if ($pages > 1) { // If we have more than 1 result-page echo "\n <div class='submenu cntr'>\n Result page: {$start} from {$pages} \n "; if ($start > 1) { // Display 'First' echo "\n <a href='admin.php?f=statistics&type=thumb_files&start=1'>First</a> \n "; if ($start > 5) { // Display '-5' $minus = $start - 5; echo "\n <a href='admin.php?f=statistics&type=thumb_files&start={$minus}'>- 5</a> \n "; } } if ($start > 1) { // Display 'Previous' $prev = $start - 1; echo "\n <a href='admin.php?f=statistics&type=thumb_files&start={$prev}'>Previous</a> \n "; } if ($rest >= $sites_per_page) { // Display 'Next' $next = $start + 1; echo "\n <a href='admin.php?f=statistics&type=thumb_files&start={$next}' >Next</a> \n "; if ($pages - $start > 5) { // Display '+5' $plus = $start + 5; echo "\n <a href='admin.php?f=statistics&type=thumb_files&start={$plus}'>+ 5</a> \n "; } } if ($start < $pages) { // Display 'Last' echo "\n <a href='admin.php?f=statistics&type=thumb_files&start={$pages}'>Last</a>\n "; } echo "</div>\n "; } } } else { echo "<br />\n <p class='cntr msg'>Note: <span class='warnadmin'>No saved thumbnails exist!</span></p>\n <br /> <br />\n "; } echo "\n </div>\n </body>\n </html>\n "; exit; } if ($type == "ids") { $back = ''; showIDS($back); exit; } if ($type = 'server_info') { $s_infos = str_replace("&", "&", $_SERVER); $e_infos = str_replace("&", "&", $_ENV); echo "<div class='submenu'>\n <ul>\n <li><a href='#serv_info'>Server</a></li>\n <li><a href='#en_info'>Environment</a></li>\n <li><a href='#mysql_info'>MySQL</a></li>\n <li><a href='#pdf_con'>PDF-converter</a></li>\n <li><a href='#gd_info'>Image func.</a></li>\n <li><a href='#php_ini'>php.ini file</a></li>\n <li><a href='admin.php?f=35'>PHP integration</a></li>\n <li><a href='#php_sec'>PHP security info</a></li>\n </ul>\n </div>\n <div class='tblhead sml'><a name='serv_info'>Server</a> </div>\n <table width='98%'>\n <tr>\n <td width='20%' class='tblhead'>Key</td>\n <td class='tblhead'>Value</td>\n\n </tr>\n "; $bgcolor = 'odrow'; $i = 0; reset($s_infos); while (list($key, $value) = each($s_infos)) { echo "<tr class='{$bgcolor} cntr'>\n <td>{$key}</td>\n <td class='bordl'>{$value}</td>\n </tr>\n "; $i++; if ($bgcolor == 'odrow') { $bgcolor = 'evrow'; } else { $bgcolor = 'odrow'; } } echo "\n </table><br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br /><br />\n <div class='headline cntr sml'><a name='en_info'>Environment</a></div>\n <table width='98%'>\n <tr>\n <td width='20%' class='tblhead'>Key</td>\n <td class='tblhead'>Value</td>\n\n </tr>\n "; $bgcolor = 'odrow'; $i = 0; reset($e_infos); while (list($key, $value) = each($e_infos)) { echo "<tr class='{$bgcolor} cntr'>\n <td>{$key}</td>\n <td class='bordl'>{$value}</td>\n </tr>\n "; $i++; if ($bgcolor == 'odrow') { $bgcolor = 'evrow'; } else { $bgcolor = 'odrow'; } } echo "\n </table><br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n "; $server_version = $db_con->server_info; $host_info = $db_con->host_info; $client_info = $db_con->client_info; $protocol_version = $db_con->protocol_version; $sql_query = "SHOW STATUS LIKE 'Qcache_free_memory'"; $status = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $row = $status->fetch_array(MYSQLI_ASSOC); $cmem_size = $row['Value']; echo "<br /><br />\n <div class='headline cntr sml'><a name='mysql_info'>MySQL Info</a></div>\n <table width='98%'>\n <tr>\n <td width='35%' class='tblhead'>Key</td>\n <td class='tblhead'>Value</td>\n </tr>\n "; $bgcolor = 'odrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>MySQL Server version</td>\n <td class='bordl'>{$server_version}</td>\n </tr>\n "; $bgcolor = 'evrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Connection info</td>\n <td class='bordl'>{$host_info}</td>\n </tr>\n "; $bgcolor = 'odrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Client library info</td>\n <td class='bordl'>{$client_info}</td>\n </tr>\n "; $bgcolor = 'evrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>MySQL protocol version</td>\n <td class='bordl'>{$protocol_version}</td>\n </tr>\n "; $bgcolor = 'odrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Support for mysqli</td>\n <td class='bordl'>See below as part of your PHP installation</td>\n </tr>\n "; $bgcolor = 'evrow'; echo "<tr><td></td><td></td></tr>\n <tr class='{$bgcolor} cntr'>\n <td>MySQL cache</td>\n "; if ($cmem_size == '0') { echo "<td class='warnadmin'>Cache is not initialized</td>"; } else { echo "<td class='bordl'>32 MByte initialized</td>\n </tr>\n "; $bgcolor = 'odrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Currently free cache size</td>\n <td class='bordl'>{$cmem_size} Bytes</td>\n </tr>\n "; $sql_query = "SHOW STATUS LIKE 'Qcache_total_blocks'"; $status = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $row = $status->fetch_array(MYSQLI_ASSOC); $ctot_blocks = $row['Value']; $bgcolor = 'evrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Cache total blocks</td>\n <td class='bordl'>{$ctot_blocks}</td>\n </tr>\n "; $sql_query = "SHOW STATUS LIKE 'Qcache_free_blocks'"; $status = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $row = $status->fetch_array(MYSQLI_ASSOC); $cfree_blocks = $row['Value']; $bgcolor = 'odrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Cache free blocks</td>\n <td class='bordl'>{$cfree_blocks}</td>\n </tr>\n "; $sql_query = "SHOW STATUS LIKE 'Qcache_hits'"; $status = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $row = $status->fetch_array(MYSQLI_ASSOC); $cache_hits = $row['Value']; $bgcolor = 'evrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Cache hits</td>\n <td class='bordl'>{$cache_hits}</td>\n </tr>\n "; $sql_query = "SHOW STATUS LIKE 'Qcache_inserts'"; $status = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $row = $status->fetch_array(MYSQLI_ASSOC); $cache_inserts = $row['Value']; $bgcolor = 'odrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Cache inserts</td>\n <td class='bordl'>{$cache_inserts}</td>\n </tr>\n "; $sql_query = "SHOW STATUS LIKE 'Qcache_queries_in_cache'"; $status = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $row = $status->fetch_array(MYSQLI_ASSOC); $queries_in_cache = $row['Value']; $bgcolor = 'evrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Queries in cache</td>\n <td class='bordl'>{$queries_in_cache}</td>\n </tr>\n "; $sql_query = "SHOW STATUS LIKE 'Qcache_not_cached'"; $status = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $row = $status->fetch_array(MYSQLI_ASSOC); $q_not_cached = $row['Value']; $bgcolor = 'odrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Queries not cached</td>\n <td class='bordl'>{$q_not_cached}</td>\n </tr>\n "; $sql_query = "SHOW STATUS LIKE 'Qcache_lowmem_prunes'"; $status = $db_con->query($sql_query); if ($debug && $db_con->errno) { $err_row = __LINE__ - 2; printf("<p><span class='red'> MySQL failure: %s \n<br /></span></p>", $db_con->error); if (__FUNCTION__) { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} in function(): " . __FUNCTION__ . " <br /></span></p>"); } else { printf("<p><span class='red'> Found in script: " . __FILE__ . " row: {$err_row} <br /></span></p>"); } printf("<p><span class='red'> Script execution aborted. <br /></span>"); printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>"); echo "<p> {$sql_query} </p>"; exit; } $row = $status->fetch_array(MYSQLI_ASSOC); $q_low_prun = $row['Value']; $bgcolor = 'evrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Not cached because low memory</td>\n <td class='bordl'>{$q_low_prun}</td>\n </tr>\n "; } echo "\n </table><br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n "; $os = ''; $os = $_ENV['OS']; // not all shared hosting server will supply this info $admin_path = $_ENV['ORIG_PATH_TRANSLATED']; // that might work for shared hosting server $admin_file = $_SERVER['SCRIPT_FILENAME']; // should present the physical path $sdoc_root = $_SERVER['DOCUMENT_ROOT']; // this should provide every hoster (???) $edoc_root = $_ENV['DOCUMENT_ROOT']; // this should provide every hoster (???) echo "<br /><br />\n <div class='headline cntr sml'><a name='pdf_con'>PDF-converter relevant Info</a></div>\n <table width='98%'>\n <tr>\n <td width='35%' class='tblhead'>Key</td>\n <td class='tblhead'>Value</td>\n </tr>\n "; $bgcolor = 'odrow'; if ($os) { echo "\n <tr class='{$bgcolor} cntr'>\n <td>Operating System</td>\n <td class='bordl'>{$os}</td>\n </tr>\n "; $bgcolor = 'evrow'; } if (!$os) { $s_soft = $_SERVER['SERVER_SOFTWARE']; $sys_os = stripos($s_soft, "lin"); if (!$sys_os) { $sys_os = stripos($s_soft, "uni"); if (!$sys_os) { $sys_os = stripos($s_soft, "win"); } } if ($sys_os) { $os = substr($s_soft, $sys_os, '5'); echo "\n <tr class='{$bgcolor} cntr'>\n <td>Operating System</td>\n <td class='bordl'>{$os}</td>\n </tr>\n "; $bgcolor = 'evrow'; } else { $s_sig = $_SERVER['SERVER_SIGNATURE']; $sys_os = stripos($s_sig, "lin"); if (!$sys_os) { $sys_os = stripos($s_sig, "uni"); if (!$sys_os) { $sys_os = stripos($s_sig, "win"); } } } if ($sys_os) { $os = substr($s_sig, $sys_os, '5'); echo "\n <tr class='{$bgcolor} cntr'>\n <td>Operating System</td>\n <td class='bordl'>{$os}</td>\n </tr>\n "; $bgcolor = 'evrow'; } } // if ENV or SERVER_SIGNATURE or SERVER_SOFTWARE do not deliver OperatingSystem info, we will use the PHPinfo to extract it if (!$os) { $phpinfo = ''; ob_start(); // redirect output into buffer phpinfo(); $phpinfo = ob_get_contents(); // get all from phpinfo ob_end_clean(); // clean buffer and close it // extract OS information $start = stripos($phpinfo, "\"v\"") + 4; $end = stripos($phpinfo, "</td>", $start); $length = $end - $start; $os = substr($phpinfo, $start, $length); echo "\n <tr class='{$bgcolor} cntr'>\n <td>Operating System</td>\n <td class='bordl'>{$os}</td>\n </tr>\n "; $bgcolor = 'evrow'; } if ($admin_path) { $admin_path = str_replace("\\\\", "/", $admin_path); $admin_path = str_replace("\\", "/", $admin_path); $pdf_path = substr($admin_path, 0, strrpos($admin_path, "/")); $pdf_path = substr($pdf_path, 0, strrpos($pdf_path, "/")); $pdf_path = "" . $pdf_path . "/converter/pdftotext"; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Physical path to Sphider-plus Admin</td>\n <td class='bordl'>{$admin_path}</td>\n </tr>\n "; $bgcolor = 'odrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Physical path to the Linux / UNIX PDF-converter</td>\n <td class='bordl'>{$pdf_path}</td>\n </tr>\n "; $bgcolor = 'evrow'; } else { if ($admin_file) { $admin_file = str_replace("\\\\", "/", $admin_file); $admin_file = str_replace("\\", "/", $admin_file); $pdf_path = substr($admin_file, 0, strrpos($admin_file, "/")); $pdf_path = substr($pdf_path, 0, strrpos($pdf_path, "/")); $pdf_path = "" . $pdf_path . "/converter/pdftotext"; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Physical path to Sphider-plus Admin</td>\n <td class='bordl'>{$admin_file}</td>\n </tr>\n "; $bgcolor = 'odrow'; echo "\n <tr class='{$bgcolor} cntr'>\n <td>Physical path to the Linux / UNIX PDF-converter</td>\n <td class='bordl'>{$pdf_path}</td>\n </tr>\n "; $bgcolor = 'evrow'; } } if ($sdoc_root) { echo "\n <tr class='{$bgcolor} cntr'>\n <td>Physical path to document root</td>\n <td class='bordl'>{$sdoc_root}</td>\n </tr>\n "; } else { if ($edoc_root) { echo "\n <tr class='{$bgcolor} cntr'>\n <td>Physical path to document root</td>\n <td class='bordl'>{$edoc_root}</td>\n </tr>\n "; } } if (!$admin_path && !$admin_file) { if ($sdoc_root) { echo "\n <tr class='{$bgcolor} cntr'>\n <td>Physical path to document root</td>\n <td class='bordl'>{$sdoc_root}</td>\n </tr>\n "; } if ($edoc_root) { echo "\n <tr class='{$bgcolor} cntr'>\n <td>Physical path to document root</td>\n <td class='bordl'>{$edoc_root}</td>\n </tr>\n "; } else { echo "\n </table>\n <table width='98%'>\n <tr>\n <td>\n <span class='cntr warnadmin'><br />\n Attention: Your server does not deliver information about the physical path to Sphider-plus.<br />\n For LINUX and UNIX systems you will have to initialize the PDF converter manually.<br />\n For details see the file readme.pdf, chapter: PDF converter for Linux/UNIX systems.<br />\n <br /></span>\n </td>\n </tr>\n "; } } echo "\n </table><br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a><br /><br />\n "; if (function_exists(gd_info)) { $gd = gd_info(); // get details about image functions } echo "<br /><br />\n <div class='headline cntr sml'><a name='gd_info'>Info about Image Functions (GD-library)</a></div>\n <table width='98%'>\n <tr>\n <td width='50%' class='tblhead'>Key</td>\n <td class='tblhead'>Value</td>\n </tr>\n "; if ($gd) { $bgcolor = "evrow"; foreach ($gd as $key => $val) { if ($bgcolor == "evrow") { $bgcolor = "odrow"; } else { $bgcolor = "evrow"; } echo "\n <tr class='{$bgcolor} cntr'>\n <td>{$key}</td>\n <td class='bordl'>{$val}</td>\n </tr>\n "; } } else { echo "\n <tr class='warnadmin cntr'>\n <td>Image functions are not installed.</td>\n <td>You will need to compile PHP with the GD library.</td>\n </tr>\n "; } echo "\n </table><br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a><br /><br />\n "; echo "\n <div class='headline cntr sml'>PHP Info</div>\n <br />\n <div class='headline cntr sml'><a name='php_ini'>php.ini file</a></div>\n <table width='98%'>\n <tr>\n <td width='20%' class='tblhead'>Key</td>\n <td class='tblhead'>Value</td>\n\n </tr>\n "; $php_ini = str_replace("&", "&", ini_get_all()); $bgcolor = 'odrow'; $i = 0; reset($php_ini); while (list($key, $value) = each($php_ini)) { echo "\n <tr class='{$bgcolor} cntr'>\n <td>{$key}</td>\n <td class='bordl'>\n "; print_r($value); echo "\n </td>\n </tr>\n "; $i++; if ($bgcolor == 'odrow') { $bgcolor = 'evrow'; } else { $bgcolor = 'odrow'; } } echo "\n </table>\n <br /><br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br /><br />\n <div class='headline cntr sml'><a name='php_sec'>PHP security info</a></div>\n <table width='98%'>\n <tr>\n <td width='20%' class='tblhead'></td>\n <td class='tblhead'></td>\n\n </tr>\n "; //phpsecinfo(); // get PHP security information echo "\n </table>\n <br /><br />\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\n <br /><br />\n </div>\n "; exit; } }
function statisticsForm($type) { global $mysql_table_prefix, $log_dir; ?> <div id='submenu'> <ul> <li><a href="admin.php?f=statistics&type=keywords">Top keywords</a></li> <li><a href="admin.php?f=statistics&type=pages">Largest pages</a></li> <li><a href="admin.php?f=statistics&type=top_searches">Most popular searches</a></li> <li><a href="admin.php?f=statistics&type=log">Search log</a></li> <li><a href="admin.php?f=statistics&type=spidering_log">Spidering logs</a></li> </ul> </div> <?php if ($type == "") { $cachedSumQuery = "select sum(length(fulltxt)) from " . $mysql_table_prefix . "links"; $result = mysql_query("select sum(length(fulltxt)) from " . $mysql_table_prefix . "links"); echo mysql_error(); if ($row = mysql_fetch_array($result)) { $cachedSumSize = $row[0]; } $cachedSumSize = number_format($cachedSumSize / 1024, 2); $sitesSizeQuery = "select sum(size) from " . $mysql_table_prefix . "links"; $result = mysql_query("{$sitesSizeQuery}"); echo mysql_error(); if ($row = mysql_fetch_array($result)) { $sitesSize = $row[0]; } $sitesSize = number_format($sitesSize, 2); $stats = getStatistics(); print "<br/><div align=\"center\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr class=\"grey\"><td><b>Sites:</b></td><td align=\"center\">" . $stats['sites'] . "</td></tr>"; print "<tr class=\"white\"><td><b>Links:</b></td><td align=\"center\"> " . $stats['links'] . "</td></tr>"; print "<tr class=\"grey\"><td><b>Categories:</b></td><td align=\"center\"> " . $stats['categories'] . "</td></tr>"; print "<tr class=\"white\"><td><b>Keywords:</b></td><td align=\"center\"> " . $stats['keywords'] . "</td></tr>"; print "<tr class=\"grey\"><td><b>Keyword-link realations:</b></td><td align=\"center\"> " . $stats['index'] . "</td></tr>"; print "<tr class=\"white\"><td><b>Cached texts total:</b></td><td align=\"center\"> {$cachedSumSize} kb</td></tr>"; print "<tr class=\"grey\"><td><b>Sites size total:</b></td><td align=\"center\"> {$sitesSize} kb</td></tr>"; print "</table></td></tr></table></div>"; } if ($type == 'keywords') { $class = "grey"; print "<br/><div align=\"center\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr class=\"grey\"><td><b>Keyword</b></td><td><b>Occurrences</b></td></tr>"; for ($i = 0; $i <= 15; $i++) { $char = dechex($i); $result = mysql_query("select keyword, count(" . $mysql_table_prefix . "link_keyword{$char}.keyword_id) as x from " . $mysql_table_prefix . "keywords, " . $mysql_table_prefix . "link_keyword{$char} where " . $mysql_table_prefix . "keywords.keyword_id = " . $mysql_table_prefix . "link_keyword{$char}.keyword_id group by keyword order by x desc limit 30"); echo mysql_error(); while ($row = mysql_fetch_row($result)) { $topwords[$row[0]] = $row[1]; } } arsort($topwords); $count = 0; while ((list($word, $weight) = each($topwords)) && $count <= 30) { $count++; if ($class == "white") { $class = "grey"; } else { $class = "white"; } print "<tr class=\"{$class}\"><td align=\"left\">" . $word . "</td><td> " . $weight . "</td></tr>\n"; } print "</table></td></tr></table></div>"; } if ($type == 'pages') { $class = "grey"; ?> <br/><div align="center"> <table cellspacing ="0" cellpadding="0" class="darkgrey"><tr><td> <table cellpadding="2" cellspacing="1"> <tr class="grey"><td> <b>Page</b></td> <td><b>Text size</b></td></tr> <?php $result = mysql_query("select " . $mysql_table_prefix . "links.link_id, url, length(fulltxt) as x from " . $mysql_table_prefix . "links order by x desc limit 20"); echo mysql_error(); while ($row = mysql_fetch_row($result)) { if ($class == "white") { $class = "grey"; } else { $class = "white"; } $url = $row[1]; $sum = number_format($row[2] / 1024, 2); print "<tr class=\"{$class}\"><td align=\"left\"><a href=\"{$url}\">" . $url . "</td><td align= \"center\"> " . $sum . "kb</td></tr>"; } print "</table></td></tr></table></div>"; } if ($type == 'top_searches') { $class = "grey"; print "<br/><div align=\"center\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr class=\"grey\"><td><b>Query</b></td><td><b>Count</b></td><td><b> Average results</b></td><td><b>Last queried</b></td></tr>"; $result = mysql_query("select query, count(*) as c, date_format(max(time), '%Y-%m-%d %H:%i:%s'), avg(results) from " . $mysql_table_prefix . "query_log group by query order by c desc"); echo mysql_error(); while ($row = mysql_fetch_row($result)) { if ($class == "white") { $class = "grey"; } else { $class = "white"; } $word = $row[0]; $times = $row[1]; $date = $row[2]; $avg = number_format($row[3], 1); print "<tr class=\"{$class}\"><td align=\"left\">" . htmlentities($word) . "</td><td align=\"center\"> " . $times . "</td><td align=\"center\"> " . $avg . "</td><td align=\"center\"> " . $date . "</td></tr>"; } print "</table></td></tr></table></div>"; } if ($type == 'log') { $class = "grey"; print "<br/><div align=\"center\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr class=\"grey\"><td align=\"center\"><b>Query</b></td><td align=\"center\"><b>Results</b></td><td align=\"center\"><b>Queried at</b></td><td align=\"center\"><b>Time taken</b></td></tr>"; $result = mysql_query("select query, date_format(time, '%Y-%m-%d %H:%i:%s'), elapsed, results from " . $mysql_table_prefix . "query_log order by time desc"); echo mysql_error(); while ($row = mysql_fetch_row($result)) { if ($class == "white") { $class = "grey"; } else { $class = "white"; } $word = $row[0]; $time = $row[1]; $elapsed = $row[2]; $results = $row[3]; print "<tr class=\"{$class}\"><td align=\"left\">" . htmlentities($word) . "</td><td align=\"center\"> " . $results . "</td><td align=\"center\"> " . $time . "</td><td align=\"center\"> " . $elapsed . "</td></tr>"; } print "</table></td></tr></table></div>"; } if ($type == 'spidering_log') { $class = "grey"; $files = get_dir_contents($log_dir); if (count($files) > 0) { print "<br/><div align=\"center\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr class=\"grey\"><td align=\"center\"><b>File</b></td><td align=\"center\"><b>Time</b></td><td align=\"center\"><b></b></td></tr>"; for ($i = 0; $i < count($files); $i++) { $file = $files[$i]; $year = substr($file, 0, 2); $month = substr($file, 2, 2); $day = substr($file, 4, 2); $hour = substr($file, 6, 2); $minute = substr($file, 8, 2); if ($class == "white") { $class = "grey"; } else { $class = "white"; } print "<tr class=\"{$class}\"><td align=\"left\"><a href='{$log_dir}/{$file}' tareget='_blank'>{$file}</a></td><td align=\"center\"> 20{$year}-{$month}-{$day} {$hour}:{$minute}</td><td align=\"center\"> <a href='?f=delete_log&file={$file}' id='small_button'>Delete</a></td></tr>"; } print "</table></td></tr></table></div>"; } else { ?> <br/><br/> <center><b>No saved logs.</b></center> <?php } } }
function delete_post_attachments($post_ids) { global $db; if (strpos($post_ids, ',') === false) { $result = $db->query('SELECT id, poster_id, location FROM ' . $db->prefix . 'attachments WHERE post_id=' . $post_ids) or error('Unable to fetch attachments', __FILE__, __LINE__, $db->error()); } else { $result = $db->query('SELECT id, poster_id, location FROM ' . $db->prefix . 'attachments WHERE post_id IN(' . $post_ids . ')') or error('Unable to fetch attachments', __FILE__, __LINE__, $db->error()); } if ($db->num_rows($result)) { $att_ids = ''; $poster_ids = array(); $thumb_dir = PUN_ROOT . $GLOBALS['pun_config']['file_thumb_path']; $thumb_files = get_dir_contents($thumb_dir); while ($row = $db->fetch_assoc($result)) { $att_ids .= $att_ids ? ',' . $row['id'] : $row['id']; if (isset($poster_ids[$row['poster_id']])) { $poster_ids[$row['poster_id']]++; } else { $poster_ids[$row['poster_id']] = 1; } // Delete file and all it's possible thumbnails unlink(PUN_ROOT . $row['location']); foreach ($thumb_files as $thumb_file) { if (preg_match('/^' . $row['id'] . '-[0-9x]+.*/i', $thumb_file)) { unlink($thumb_dir . $thumb_file); } } } $db->free_result($result); if ($att_ids) { // Delete attachment records $db->query('DELETE FROM ' . $db->prefix . 'attachments WHERE id IN(' . $att_ids . ')') or error('Unable to delete attachments', __FILE__, __LINE__, $db->error()); foreach ($poster_ids as $poster_id => $num_files) { // Fix user file counter $db->query('UPDATE ' . $db->prefix . 'users SET num_files=IF((num_files-' . $num_files . ')>0, num_files-' . $num_files . ', 0) WHERE id=' . $poster_id) or error('Unable to update users file counter', __FILE__, __LINE__, $db->error()); } } } }
function statisticsForm($type) { echo "<div class='submenu y3'>\r\n\t\t\t\t<ul>\r\n\t\t\t\t\t<li><a href='" . WEBROOT_DIR . "/admin/?f=statistics&type=keywords' title='Show list of Top 60 Keywords'>Top keywords</a></li>\r\n\t\t\t\t\t<li><a href='" . WEBROOT_DIR . "/admin/?f=statistics&type=pages' title='Show list of Largest Pages and their indexed file size'>Largest pages</a></li>\r\n\t\t\t\t\t<li><a href='" . WEBROOT_DIR . "/admin/?f=statistics&type=spidering_log' title='Show list of Spidering Logs'>Spidering logs</a></li>\r\n\t\t\t\t\t<li><a href='" . WEBROOT_DIR . "/admin/?f=statistics&type=server_info' title='Show all available server info'>Server Info</a></li>\r\n\t\t\t\t\t<li><a href='" . WEBROOT_DIR . "/admin/?f=statistics&type=log' title='Show Search Log activity'>Search log</a></li>\r\n\t\t\t\t\t<li><a href='" . WEBROOT_DIR . "/admin/?f=statistics&type=top_searches' title='Show list of the most popular on-line Searches'>Most popular searches</a></li>\r\n\t\t\t\t\t<li><a href='" . WEBROOT_DIR . "/admin/?f=statistics&type=top_links' title='Show list of the most popular links, clicked by the user'>Most popular links</a></li>\r\n\t\t\t\t</ul>\r\n\t\t\t</div>\r\n\t\t"; if ($type == "") { $cachedSumQuery = "select sum(length(fulltxt)) from " . TABLE_PREFIX . "links"; $result = mysql_query("select sum(length(fulltxt)) from " . TABLE_PREFIX . "links"); if (DEBUG > '0') { echo mysql_error(); } if ($row = mysql_fetch_array($result)) { $cachedSumSize = $row[0]; } $cachedSumSize = number_format($cachedSumSize / 1024, 2); $sitesSizeQuery = "select sum(size) from " . TABLE_PREFIX . "links"; $result = mysql_query("{$sitesSizeQuery}"); if (DEBUG > '0') { echo mysql_error(); } if ($row = mysql_fetch_array($result)) { $sitesSize = $row[0]; } $sitesSize = number_format($sitesSize, 2); $result = mysql_query("select count(*) from " . TABLE_PREFIX . "query_log"); if (DEBUG > '0') { echo mysql_error(); } if ($row = mysql_fetch_array($result)) { $query_tot = $row[0]; } $result = mysql_query("select sum(click_counter) from " . TABLE_PREFIX . "links"); if (!mysql_error()) { if ($row = mysql_fetch_array($result)) { $click_tot = $row[0]; } $stats = getStatistics(); echo "<div class='panel w60'>\r\n\t\t\t\t\t<dl class='tblhead'>\r\n\t\t\t\t\t\t<dt class='headline x2'>Overall Statistics:</dt><dd class='headline'> Details</dd>\r\n\t\t\t\t\t\t<dt class='odrow bd x2'>Sites:</dt><dd class='odrow'> " . $stats['sites'] . "</dd>\r\n\t\t\t\t\t\t<dt class='evrow bd x2'>Links:</dt><dd class='evrow'> " . $stats['links'] . "</dd>\r\n\t\t\t\t\t\t<dt class='odrow bd x2'>Categories:</dt><dd class='odrow'> " . $stats['categories'] . "</dd>\r\n\t\t\t\t\t\t<dt class='evrow bd x2'>Keywords:</dt><dd class='evrow'> " . $stats['keywords'] . "</dd>\r\n\t\t\t\t\t\t<dt class='odrow bd x2'>Keyword link-relations:</dt><dd class='odrow'> " . $stats['index'] . "</dd>\r\n\t\t\t\t\t\t<dt class='evrow bd x2'>Cached texts total:</dt><dd class='evrow'> {$cachedSumSize} kb</dd>\r\n\t\t\t\t\t\t<dt class='odrow bd x2'>Sites size total:</dt><dd class='odrow'> {$sitesSize} kb</dd>\r\n\t\t\t\t\t\t<dt class='evrow bd x2'>Queries total:</dt><dd class='evrow'> {$query_tot}</dd>\r\n\t\t\t\t\t\t<dt class='odrow bd x2'>Link clicks total:</dt><dd class='odrow'> {$click_tot}</dd>\r\n\t\t\t\t\t</dl>\r\n\t\t\t\t</div>\r\n\t\t\t\t"; } else { echo "\r\n\t\t\t\t\t<div class='submenu cntr'>\r\n\t\t\t\t\t<span class='warnadmin'>\r\n\t\t\t\t"; if (DEBUG > '0') { echo mysql_error(); } echo "<br /><br /><br />\r\n\t\t\t\t\tPlease run the .../admin/install_bestclick.php file.\r\n\t\t\t\t\t<b r />\r\n\t\t\t\t\t</span>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<br /><br />\r\n\t\t\t\t"; die; } exit; } if ($type == 'keywords') { $class = "evrow"; for ($i = 0; $i <= 15; $i++) { $char = dechex($i); $result = mysql_query("select keyword, count(" . TABLE_PREFIX . "link_keyword{$char}.keyword_id) as x from " . TABLE_PREFIX . "keywords, " . TABLE_PREFIX . "link_keyword{$char} where " . TABLE_PREFIX . "keywords.keyword_id = " . TABLE_PREFIX . "link_keyword{$char}.keyword_id group by keyword order by x desc limit 30"); if (DEBUG > '0') { echo mysql_error(); } while ($row = mysql_fetch_row($result)) { $topwords[$row[0]] = $row[1]; } } arsort($topwords); echo "<div class='panel'>\r\n\t\t\t\t<p class='headline cntr'>Top 60 Keywords</p>\r\n\t\t\t"; $nloops = 1; do { $nloops++; $count = 1; echo "<div class='ltfloat x3'>\r\n\t\t\t\t\t<dl>\r\n\t\t\t\t\t\t<dt class='headline x2'>Keyword</dt><dd class='headline'>: Instances</dd>\r\n\t\t\t\t"; while ((list($word, $weight) = each($topwords)) && $count < 21) { $word = quote_replace($word); $count++; if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } echo "<dt class='{$class}'><a href='../" . WEBROOT_DIR . "/admin/?query={$word}&search=1' target='rel' title='View search results in new window'>" . trim(substr($word, 0, 35)) . "</a></dt>\r\n\t\t\t\t\t\t<dd class='{$class}'>: " . $weight . "</dd>\r\n\t\t\t\t\t"; } echo "</dl>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t"; } while ($nloops <= 3); echo "<div class='clear'></div>\r\n\t\t\t\t\t<br />\r\n\t\t\t\t\t<a class='navup' href='#head' title='Jump to Page Top'>Top</a>\r\n\t\t\t\t\t<br />\r\n\t\t\t\t\t</div>\r\n\t\t\t\t"; exit; } if ($type == 'pages') { $class = "evrow"; echo "<div class='panel'>\r\n <dl class='tblhead'>\r\n <dt class='headline x8'>File Size</dt><dd class='headline cntr'>Links to Largest Pages</dd>\r\n "; $result = mysql_query("select " . TABLE_PREFIX . "links.link_id, url, length(fulltxt) as x from " . TABLE_PREFIX . "links order by x desc limit 20"); if (DEBUG > '0') { echo mysql_error(); } while ($row = mysql_fetch_row($result)) { if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } $url = $row[1]; $sum = number_format($row[2] / 1024, 2); echo "<dt class='{$class} x8'>" . $sum . "kb </dt>\r\n <dd class='{$class}'><a href='{$url}' title='Open this page in new window' target='_blank'>" . $url . "</a></dd>\r\n "; } echo "</dl>\r\n <br />\r\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a> \r\n <br />\r\n \r\n </div>\r\n "; exit; } if ($type == 'top_searches') { $class = "evrow"; echo "<div class='panel'>\r\n <p class='headline cntr'>Most Popular Searches (Top 50)</p>\r\n <table width='100%'>\r\n <tr>\r\n <td class='tblhead'>Query</td>\r\n <td class='tblhead'>Count</td>\r\n <td class='tblhead'>Average results</td>\r\n <td class='tblhead'>Last queried</td>\r\n </tr>\r\n "; $allthese = '1'; $result = mysql_query("select query, count(*) as c, date_format(max(time), '%Y-%m-%d %H:%i:%s'), avg(results) from " . TABLE_PREFIX . "query_log group by query order by c desc"); if (DEBUG > '0') { echo mysql_error(); } while (($row = mysql_fetch_row($result)) && $allthese <= '50') { if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } $word = $row[0]; $times = $row[1]; $date = $row[2]; $avg = number_format($row[3], 0); $word = str_replace("\"", "", $word); echo "<tr class='{$class} '>\r\n <td><a href='../" . WEBROOT_DIR . "/admin/?query={$word}&search=1' target='rel' title='View search results in new window'>" . $word . "</a></td>\r\n <td class='cntr'> " . $times . "</td>\r\n <td class='cntr'> " . $avg . "</td><td class='cntr'> " . $date . "</td>\r\n </tr>\r\n "; $allthese++; } echo "\r\n </table>\r\n <br />\r\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a> \r\n <br /> \r\n </div>\r\n "; exit; } if ($type == 'top_links') { $class = "evrow"; echo "<div class='panel'>\r\n <p class='headline cntr'>Most Popular Links (Top 50)</p>\r\n <table width='100%'>\r\n <tr>\r\n <td class='tblhead'>Link</td>\r\n <td class='tblhead'>Total clicks</td>\r\n <td class='tblhead'>Last clicked</td>\r\n <td class='tblhead'>Last query</td>\r\n </tr>\r\n "; $allthese = '1'; $result = mysql_query("select url, click_counter, last_click, last_query from " . TABLE_PREFIX . "links order by click_counter DESC, url"); if (DEBUG > '0') { echo mysql_error(); } while (($row = mysql_fetch_row($result)) && $allthese <= '50') { if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } $url = $row[0]; $click_counter = $row[1]; $Timestamp = $row[2]; $last_query = $row[3]; if ($Timestamp != '0') { $last_click = date("Y-m-d H:i:s", $Timestamp); echo "<tr class='{$class}'>\r\n <td><a href='{$url}' target='rel' title='View link in new window'>" . htmlentities($url) . "</a></td>\r\n <td class='cntr sml'> " . $click_counter . "</td>\r\n <td class='cntr sml'> " . $last_click . "</td>\r\n <td class='cntr sml'> " . $last_query . "</td>\r\n </tr>\r\n "; $allthese++; } } echo "\r\n </table>\r\n <br />\r\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a> \r\n <br /> \r\n </div>\r\n "; exit; } if ($type == 'log') { $class = "evrow"; echo "<div class='panel w75'>\r\n <p class='headline cntr'>Search Log (Latest 100)</p>\r\n <table width='100%'>\r\n <tr>\r\n <td class='tblhead'>Query</td>\r\n <td class='tblhead x6'>Results</td>\r\n <td class='tblhead x3'>Queried at:</td>\r\n <td class='tblhead x5'>Time taken</td>\r\n </tr>\r\n "; $num = '1'; $result = mysql_query("select query, date_format(time, '%Y-%m-%d %H:%i:%s'), elapsed, results from " . TABLE_PREFIX . "query_log order by time desc"); if (DEBUG > '0') { echo mysql_error(); } while (($row = mysql_fetch_row($result)) && $num <= '100') { if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } $word = $row[0]; $time = $row[1]; $elapsed = $row[2]; $results = $row[3]; echo "<tr class='{$class}'>\r\n <td><a href='../" . WEBROOT_DIR . "/admin/?query={$word}&search=1' target='rel' title='View search results in new window'>" . $word . "</a></td>\r\n <td class='cntr'> " . $results . "</td>\r\n <td class='cntr'> " . $time . "</td>\r\n <td class='cntr'> " . $elapsed . "</td>\r\n </tr>\r\n "; $num++; } echo "\r\n </table>\r\n <br />\r\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a> \r\n <br /> \r\n </div>\r\n "; exit; } if ($type == 'spidering_log') { $class = "evrow"; $files = get_dir_contents(LOG_DIR); if (count($files) > 0) { echo "<div class='panel w75'>\r\n <p class='headline cntr'>Spidering Logs</p>\r\n <form action='' id='fdelfm'>\r\n <table width='100%'>\r\n <tr>\r\n <td class='tblhead'>File</td>\r\n <td class='tblhead'>Created</td>\r\n <td class='tblhead' width='22%'>Option</td>\r\n </tr>\r\n <tr>\r\n <td colspan='3' class='odrow cntr bd'>\r\n <input type='hidden' name='f' value='44' />\r\n <input class='sbmt' id='submit1' type='submit' value='Delete ALL log files' title='Start Log File deletion' onclick=\"return confirm('Are you sure you want to delete ALL log files?')\" />\r\n </td>\r\n </tr>\r\n "; for ($i = 0; $i < count($files); $i++) { $file = $files[$i]; $year = substr($file, 0, 2); $month = substr($file, 2, 2); $day = substr($file, 4, 2); $hour = substr($file, 6, 2); $minute = substr($file, 8, 2); if ($class == "evrow") { $class = "odrow"; } else { $class = "evrow"; } echo "<tr class='{$class}'>\r\n <td class='cntr'>\r\n <a href='" . LOG_DIR . "/{$file}' target='_blank' title='Open this Log File in new window'>{$file}</a></td>\r\n "; if (strlen($file) > '13') { echo " <td class='cntr'>20{$year}-{$month}-{$day} {$hour}:{$minute}</td>\r\n <td class='cntr options'><a href='?f=delete_log&file={$file}' class='options' title='Click to Delete this Log File' onclick=\"return confirm('Are you sure you want to delete? {$file} Indexing Log File will be lost.')\">Delete</a></td>\r\n "; } else { echo " <td></td><td></td\r\n "; } echo "\r\n </tr>\r\n "; } echo "\r\n\t\t\t\t\t</table></form>\r\n\t\t\t\t\t<br />\r\n\t\t\t\t\t<a class='navup' href='#head' title='Jump to Page Top'>Top</a>\r\n\t\t\t\t\t<br />\r\n\t\t\t\t\t</div>\r\n\t\t\t\t"; } else { echo "<br />\r\n\t\t\t\t\t<p class='cntr msg'>Note: <span class='warnadmin'>No saved spidering logs exist!</span></p>\r\n\t\t\t\t\t<br /> <br />\r\n\t\t\t\t"; } exit; } if ($type = 'server_info') { $s_infos = $_SERVER; $e_infos = $_ENV; echo "<div class='submenu'>\r\n\t\t\t\t\t<ul>\r\n\t\t\t\t\t\t<li><a href='#serv_info'>Server</a></li>\r\n\t\t\t\t\t\t<li><a href='#en_info'>Environment</a></li>\r\n\t\t\t\t\t\t<li><a href='#mysql_info'>MySQL</a></li>\r\n\t\t\t\t\t\t<li><a href='#pdf_con'>PDF-converter</a></li>\r\n\t\t\t\t\t\t<li><a href='#php_ini'>php.ini file</a></li>\r\n\t\t\t\t\t\t<li><a href='" . WEBROOT_DIR . "/admin/?f=35'>PHP integration</a></li>\r\n\t\t\t\t\t\t<li><a href='#php_sec'>PHP security info</a></li>\r\n\t\t\t\t\t</ul>\r\n\t\t\t\t</div>\r\n\t\t\t\t<table width='98%'>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td class='headline' colspan='6'>\r\n\t\t\t\t\t\t\t<div class='headline cntr'><a name='serv_info'>Server</a></span> </div>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td width='20%' class='tblhead'>Key</td>\r\n\t\t\t\t\t\t<td class='tblhead'>Value</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t"; $bgcolor = 'odrow'; $i = 0; reset($s_info); while (list($key, $value) = each($s_infos)) { echo "<tr class='{$bgcolor} cntr'>\r\n\t\t\t\t\t\t<td>{$key}</td>\r\n\t\t\t\t\t\t<td class='bordl'>{$value}</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t"; $i++; if ($bgcolor == 'odrow') { $bgcolor = 'evrow'; } else { $bgcolor = 'odrow'; } } echo "\r\n\t\t\t\t</table><br />\r\n\t\t\t\t<a class='navup' href='#head' title='Jump to Page Top'>Top</a>\r\n\t\t\t\t<br /><br />\r\n\t\t\t\t<table width='98%'>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td class='headline' colspan='6'>\r\n\t\t\t\t\t\t\t<div class='headline cntr'><a name='en_info'>Environment</a></span> </div>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td width='20%' class='tblhead'>Key</td>\r\n\t\t\t\t\t\t<td class='tblhead'>Value</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t"; $bgcolor = 'odrow'; $i = 0; reset($e_info); while (list($key, $value) = each($e_infos)) { echo "<tr class='{$bgcolor} cntr'> \r\n <td>{$key}</td>\r\n <td class='bordl'>{$value}</td>\r\n </tr>\r\n "; $i++; if ($bgcolor == 'odrow') { $bgcolor = 'evrow'; } else { $bgcolor = 'odrow'; } } echo "\r\n </table><br />\r\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\r\n "; $server_version = mysql_get_server_info(); $host_info = mysql_get_host_info(); $client_info = mysql_get_client_info(); $protocol_version = mysql_get_proto_info(); echo "<br /><br />\r\n \t<table width='98%'>\r\n \t<tr>\r\n \t\t<td class='headline' colspan='6'>\r\n \t\t<div class='headline cntr'><a name='mysql_info'>MySQL Info</a></span> </div>\r\n \t\t</td>\r\n \t</tr>\r\n \t<tr>\r\n \t<td width='35%' class='tblhead'>Key</td>\r\n \t<td class='tblhead'>Value</td>\r\n </tr>\r\n "; $bgcolor = 'odrow'; echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>MySQL Server version</td>\r\n <td class='bordl'>{$server_version}</td>\r\n </tr>\r\n "; $bgcolor = 'evrow'; echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>Connection info</td>\r\n <td class='bordl'>{$host_info}</td>\r\n </tr>\r\n "; $bgcolor = 'odrow'; echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>Client library info</td>\r\n <td class='bordl'>{$client_info}</td>\r\n </tr>\r\n "; $bgcolor = 'evrow'; echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>MySQL protocol version</td>\r\n <td class='bordl'>{$protocol_version}</td>\r\n </tr>\r\n "; $bgcolor = 'odrow'; echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>Support for mysqli</td>\r\n <td class='bordl'>See below as part of your PHP installation</td>\r\n </tr>\r\n </table><br /> \r\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\r\n "; $os = ''; $os = $_ENV['OS']; // not all shared hosting server will supply this info $admin_path = $_ENV['ORIG_PATH_TRANSLATED']; // that might work for shared hosting server $admin_file = $_SERVER['SCRIPT_FILENAME']; // should present the physical path $sdoc_root = $_SERVER['DOCUMENT_ROOT']; // this should provide every hoster (???) $edoc_root = $_ENV['DOCUMENT_ROOT']; // this should provide every hoster (???) echo "<br /><br />\r\n \t<table width='98%'>\r\n \t<tr>\r\n \t\t<td class='headline' colspan='6'>\r\n \t\t<div class='headline cntr'><a name='pdf_con'>PDF-converter relevant Info</a></span> </div>\r\n \t\t</td>\r\n \t</tr>\r\n \t<tr>\r\n \t<td width='35%' class='tblhead'>Key</td>\r\n \t<td class='tblhead'>Value</td>\r\n </tr>\r\n "; $bgcolor = 'odrow'; if ($os) { echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>Operating System</td>\r\n <td class='bordl'>{$os}</td>\r\n </tr>\r\n "; $bgcolor = 'evrow'; } if (!$os) { $s_soft = $_SERVER['SERVER_SOFTWARE']; $sys_os = stripos($s_soft, "lin"); if (!$sys_os) { $sys_os = stripos($s_soft, "uni"); if (!$sys_os) { $sys_os = stripos($s_soft, "win"); } } if ($sys_os) { $os = substr($s_soft, $sys_os, '5'); echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>Operating System</td>\r\n <td class='bordl'>{$os}</td>\r\n </tr>\r\n "; $bgcolor = 'evrow'; } else { $s_sig = $_SERVER['SERVER_SIGNATURE']; $sys_os = stripos($s_sig, "lin"); if (!$sys_os) { $sys_os = stripos($s_sig, "uni"); if (!$sys_os) { $sys_os = stripos($s_sig, "win"); } } } if ($sys_os) { $os = substr($s_sig, $sys_os, '5'); echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>Operating System</td>\r\n <td class='bordl'>{$os}</td>\r\n </tr>\r\n "; $bgcolor = 'evrow'; } } // if ENV or SERVER_SIGNATURE or SERVER_SOFTWARE do not deliver OperatingSystem info, we will use the PHPinfo to extract it if (!$os) { $phpinfo = ''; ob_start(); // redirect output into buffer phpinfo(); $phpinfo = ob_get_contents(); // get all from phpinfo ob_end_clean(); // clean buffer and close it // extract OS information $start = stripos($phpinfo, "\"v\"") + 4; $end = stripos($phpinfo, "</td>", $start); $length = $end - $start; $os = substr($phpinfo, $start, $length); echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>Operating System</td>\r\n <td class='bordl'>{$os}</td>\r\n </tr>\r\n "; $bgcolor = 'evrow'; } if ($admin_path) { $admin_path = str_replace("\\\\", "/", $admin_path); $admin_path = str_replace("\\", "/", $admin_path); $pdf_path = str_replace("admin/index.php", "converter/", $admin_path); echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>Physical path to Sphider-plus Admin</td>\r\n <td class='bordl'>{$admin_path}</td>\r\n </tr> \r\n "; $bgcolor = 'odrow'; echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>Physical path to the Linux / UNIX PDF-converter</td>\r\n <td class='bordl'>{$pdf_path}</td>\r\n </tr> \r\n "; $bgcolor = 'evrow'; } else { if ($admin_file) { $admin_file = str_replace("\\\\", "/", $admin_file); $admin_file = str_replace("\\", "/", $admin_file); $pdf_path = str_replace("admin/index.php", "converter/", $admin_file); echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>Physical path to Sphider-plus Admin</td>\r\n <td class='bordl'>{$admin_file}</td>\r\n </tr>\r\n "; $bgcolor = 'odrow'; echo "\r\n <tr class='{$bgcolor} cntr'>\r\n <td>Physical path to the Linux / UNIX PDF-converter</td>\r\n <td class='bordl'>{$pdf_path}</td>\r\n </tr> \r\n "; $bgcolor = 'evrow'; } } if ($sdoc_root) { echo " \r\n <tr class='{$bgcolor} cntr'>\r\n <td>Physical path to document root</td>\r\n <td class='bordl'>{$sdoc_root}</td>\r\n </tr> \r\n "; } else { if ($edoc_root) { echo " \r\n <tr class='{$bgcolor} cntr'>\r\n <td>Physical path to document root</td>\r\n <td class='bordl'>{$edoc_root}</td>\r\n </tr> \r\n "; } } if (!$admin_path && !$admin_file) { if ($sdoc_root) { echo " \r\n <tr class='{$bgcolor} cntr'>\r\n <td>Physical path to document root</td>\r\n <td class='bordl'>{$sdoc_root}</td>\r\n </tr> \r\n "; } if ($edoc_root) { echo " \r\n <tr class='{$bgcolor} cntr'>\r\n <td>Physical path to document root</td>\r\n <td class='bordl'>{$edoc_root}</td>\r\n </tr> \r\n "; } else { echo "\r\n </table>\r\n \t<table width='98%'>\r\n \t<tr>\r\n <td>\r\n <span class='cntr warnadmin'><br />\r\n Attention: Your server does not deliver information about the physical path to Sphider-plus.<br />\r\n For LINUX and UNIX systems you will have to initialize the PDF converter manually.<br />\r\n For details see the file readme.pdf, chapter: PDF converter for Linux/UNIX systems.<br />\r\n <br /></span>\r\n </td>\r\n </tr>\r\n "; } } echo "\r\n </table><br />\r\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a><br /><br />\r\n "; echo " \r\n \t<table width='98%'>\r\n \t<tr>\r\n \t\t<td class='headline' colspan='6'>\r\n \t\t<div class='headline cntr'>PHP Info</span> </div>\r\n \t\t</td>\r\n \t</tr>\r\n </table>\r\n "; echo "<br />\r\n \t<table width='98%'>\r\n \t<tr>\r\n \t\t<td class='headline' colspan='6'>\r\n \t\t<div class='headline cntr'><a name='php_ini'>php.ini file</a></span> </div>\r\n \t\t</td>\r\n \t</tr>\r\n \t<tr>\r\n \t\t<td width='20%' class='tblhead'>Key</td>\r\n \t\t<td class='tblhead'>Value</td>\r\n\r\n \t</tr>\r\n \t"; $php_ini = ini_get_all(); $bgcolor = 'odrow'; $i = 0; reset($php_ini); while (list($key, $value) = each($php_ini)) { echo "<tr class='{$bgcolor} cntr'> \r\n <td>{$key}</td>\r\n <td class='bordl'>\r\n "; // print_r($value); "</td>\r\n </tr>\r\n "; $i++; if ($bgcolor == 'odrow') { $bgcolor = 'evrow'; } else { $bgcolor = 'odrow'; } } echo "\r\n </table>\r\n <br /><br />\r\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\r\n <br /><br />\r\n \t<table width='98%'>\r\n \t<tr>\r\n \t\t<td class='headline' colspan='6'>\r\n \t\t<div class='headline cntr'><a name='php_sec'>PHP security info</a></span> </div>\r\n \t\t</td>\r\n \t</tr>\r\n \t<tr>\r\n \t\t<td width='20%' class='tblhead'></td>\r\n \t\t<td class='tblhead'></td>\r\n\r\n \t</tr>\r\n \t"; //phpsecinfo(); // get PHP security information echo "\r\n </table>\r\n <br /><br />\r\n <a class='navup' href='#head' title='Jump to Page Top'>Top</a>\r\n <br /><br />\r\n </div>\r\n "; exit; } }
<?php function is_in_string($haystack, $needle) { if (strpos($haystack, $needle) !== false) { return 1; } else { return 0; } } function get_dir_contents($web_directory) { $directory = get_stylesheet_directory_uri() . $web_directory; if (file_exists($directory)) { $myDirectory = opendir($directory); while ($entryName = readdir($myDirectory)) { if (is_in_string($entryName, "@2x")) { $dirArray[] = $entryName; } } return $dirArray; } } header('Content-type: application/json'); echo json_encode(get_dir_contents("/images"));
// enter here if the table for real logging was not jet installed echo "\r\n\t\t\t\t\t<div class='submenu cntr'>\r\n\t\t\t\t\t\t<span class='warnadmin'>"; if (DEBUG > '0') { echo mysql_error(); } echo "\r\n\t\t\t\t\t\t\tPlease run the .../admin/install_reallog.php file.\r\n\t\t\t\t\t\t</span>\r\n\t\t\t\t\t</div>"; die; } } } echo "\r\n\t\t<div class='submenu cntr'>\r\n\t\t\t<ul>\r\n\t\t\t\t<li><a href='#set_1'>- General Settings</a></li>\r\n\t\t\t\t<li><a href='#set_2'>- Index Log Settings</a></li>\r\n\t\t\t\t<li><a href='#set_3'>- Spider settings</a></li>\r\n\t\t\t\t<li><a href='#set_4'>- Search Settings</a></li>\r\n\t\t\t\t<li><a href='#set_5'>- Suggest Options</a></li>\r\n\t\t\t\t<li><a href='#set_6'>- Page Indexing Weights</a></li>\r\n\t\t\t</ul>\r\n\t\t</div>\r\n\t\t<div class=\"panel\">\r\n\t\t\t<div class='headline cntr'>Settings for Sphider-plus version " . Configure::read('plus_nr') . " based on original Sphider v. " . Configure::read('version_nr') . "</div>\r\n\t\t\t"; if ($settings_saved) { echo '<p class="warnadmin">Your configuration settings have been saved</p>'; } echo "\r\n\t\t\t<div id='settings'>\r\n\t\t\t\t<form class='txt' name='form1' method='post' action='" . WEBROOT_DIR . "/admin/'>\r\n\t\t\t\t\t<fieldset>\r\n\t\t\t\t\t\t<legend><a name=\"set_1\">General Settings</a></legend>\r\n\t\t\t\t\t\t<div class='input'>\r\n\t\t\t\t\t\t\t<label for='home_charset'>Enter your preferred charset:</label>\r\n\t\t\t\t\t\t\t<input name='home_charset' id='home_charset' value='" . Configure::read('home_charset') . "' type='text' size='24' title='Enter your local charset (e.g. ISO-8859-1).' />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class='input'>\r\n\t\t\t\t\t\t\t<label for='admin_email'>Administrator e-mail address:</label>\r\n\t\t\t\t\t\t\t<input name='admin_email' id='admin_email' value='" . Configure::read('admin_email') . "' type='text' size='24' title='Enter email address for info and log posting' />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class='input'>\r\n\t\t\t\t\t\t\t<label for='dispatch_email'>Dispatcher e-mail address:</label>\r\n\t\t\t\t\t\t\t<input name='dispatch_email' id='dispatch_email' value='" . Configure::read('dispatch_email') . "' type='text' size='24' title='Enter email address for log and info mail transmission' />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class='input'>\r\n\t\t\t\t\t\t\t<label for='local'>Address to localhost document root:</label>\r\n\t\t\t\t\t\t\t<input name='local' id='local' value='" . Configure::read('local') . "' type='text' size='24' title='Enter the address to your local root folder' />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class='select'>\r\n\t\t\t\t\t\t\t<label for='template'>Template design:</label>\r\n\t\t\t\t\t\t\t<select name='template' size='3'>\r\n\t\t\t\t\t\t\t\t"; $directories = get_dir_contents(APP . 'templates/'); if (count($directories) > 0) { for ($i = 0; $i < count($directories); $i++) { $tdir = $directories[$i]; if (substr($tdir, 0, 1) != '.') { echo "<option id='template' value='" . $tdir . "'"; if ($tdir == Configure::read('template')) { echo " selected='selected'"; } echo ">{$tdir}</option>"; } } } echo "\r\n\t\t\t\t\t\t\t</select>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class='checkbox'>\r\n\t\t\t\t\t\t\t<input name='sites_alpha' type='hidden' value='1' />\r\n\t\t\t\t\t\t\t<input name='_sites_alpha' type='checkbox' id='sites_alpha' value='1' title=\"Select for Admin's Site Table sorted in alphabetic order\""; if (Configure::read('sites_alpha') == 1) { echo " checked='checked'";
function statisticsForm($type) { global $mysql_table_prefix, $log_dir; ?> <div id='submenu'> <ul> <li><a href="admin.php?f=statistics&type=keywords">关键词排行</a></li> <li><a href="admin.php?f=statistics&type=pages">最大页面</a></li> <li><a href="admin.php?f=statistics&type=top_searches">热门搜索</a></li> <li><a href="admin.php?f=statistics&type=log">搜索日志</a></li> <li><a href="admin.php?f=statistics&type=spidering_log">蜘蛛日志</a></li> </ul> </div> <?php if ($type == "") { $cachedSumQuery = "select sum(length(fulltxt)) from " . $mysql_table_prefix . "links"; $result = mysql_query("select sum(length(fulltxt)) from " . $mysql_table_prefix . "links"); echo mysql_error(); if ($row = mysql_fetch_array($result)) { $cachedSumSize = $row[0]; } $cachedSumSize = number_format($cachedSumSize / 1024, 2); $sitesSizeQuery = "select sum(size) from " . $mysql_table_prefix . "links"; $result = mysql_query("{$sitesSizeQuery}"); echo mysql_error(); if ($row = mysql_fetch_array($result)) { $sitesSize = $row[0]; } $sitesSize = number_format($sitesSize, 2); $stats = getStatistics(); print "<div id=\"details\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr class=\"grey\"><td><b>站点:</b></td><td align=\"center\">" . $stats['sites'] . "</td></tr>"; print "<tr class=\"white\"><td><b>链接:</b></td><td align=\"center\"> " . $stats['links'] . "</td></tr>"; print "<tr class=\"grey\"><td><b>分类:</b></td><td align=\"center\"> " . $stats['categories'] . "</td></tr>"; print "<tr class=\"white\"><td><b>关键词:</b></td><td align=\"center\"> " . $stats['keywords'] . "</td></tr>"; print "<tr class=\"grey\"><td><b>关键词关联链接:</b></td><td align=\"center\"> " . $stats['index'] . "</td></tr>"; print "<tr class=\"white\"><td><b>文本缓存总计:</b></td><td align=\"center\"> {$cachedSumSize} kb</td></tr>"; print "<tr class=\"grey\"><td><b>站点总数:</b></td><td align=\"center\"> {$sitesSize} kb</td></tr>"; print "</table></td></tr></table></div>"; } if ($type == 'keywords') { $class = "grey"; print "<div id=\"details\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr class=\"grey\"><td><b>关键词</b></td><td><b>关联</b></td></tr>"; for ($i = 0; $i <= 15; $i++) { $char = dechex($i); $result = mysql_query("select keyword, count(" . $mysql_table_prefix . "link_keyword{$char}.keyword_id) as x from " . $mysql_table_prefix . "keywords, " . $mysql_table_prefix . "link_keyword{$char} where " . $mysql_table_prefix . "keywords.keyword_id = " . $mysql_table_prefix . "link_keyword{$char}.keyword_id group by keyword order by x desc limit 30"); echo mysql_error(); while ($row = mysql_fetch_row($result)) { $topwords[$row[0]] = $row[1]; } } arsort($topwords); $count = 0; while ((list($word, $weight) = each($topwords)) && $count <= 30) { $count++; if ($class == "white") { $class = "grey"; } else { $class = "white"; } print "<tr class=\"{$class}\"><td align=\"left\">" . $word . "</td><td> " . $weight . "</td></tr>\n"; } print "</table></td></tr></table></div>"; } if ($type == 'pages') { $class = "grey"; ?> <div id="details"> <table cellspacing ="0" cellpadding="0" class="darkgrey"><tr><td> <table cellpadding="2" cellspacing="1"> <tr class="grey"><td> <b>页面</b></td> <td><b>文本尺寸</b></td></tr> <?php $result = mysql_query("select " . $mysql_table_prefix . "links.link_id, url, length(fulltxt) as x from " . $mysql_table_prefix . "links order by x desc limit 20"); echo mysql_error(); while ($row = mysql_fetch_row($result)) { if ($class == "white") { $class = "grey"; } else { $class = "white"; } $url = $row[1]; $sum = number_format($row[2] / 1024, 2); print "<tr class=\"{$class}\"><td align=\"left\"><a href=\"{$url}\">" . $url . "</td><td align= \"center\"> " . $sum . "kb</td></tr>"; } print "</table></td></tr></table></div>"; } if ($type == 'top_searches') { $class = "grey"; print "<div id=\"details\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr class=\"grey\"><td><b>查询</b></td><td><b>计数</b></td><td><b> 平均结果</b></td><td><b>最后查询</b></td></tr>"; $result = mysql_query("select query, count(*) as c, date_format(max(time), '%Y-%m-%d %H:%i:%s'), avg(results) from " . $mysql_table_prefix . "query_log group by query order by c desc"); echo mysql_error(); while ($row = mysql_fetch_row($result)) { if ($class == "white") { $class = "grey"; } else { $class = "white"; } $word = $row[0]; $times = $row[1]; $date = $row[2]; $avg = number_format($row[3], 1); print "<tr class=\"{$class}\"><td align=\"left\">" . htmlspecialchars($word) . "</td><td align=\"center\"> " . $times . "</td><td align=\"center\"> " . $avg . "</td><td align=\"center\"> " . $date . "</td></tr>"; } print "</table></td></tr></table></div>"; } if ($type == 'log') { $class = "grey"; print "<div id=\"details\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr class=\"grey\"><td align=\"center\"><b>查询</b></td><td align=\"center\"><b>结果</b></td><td align=\"center\"><b>查询时间</b></td><td align=\"center\"><b>所需时间</b></td></tr>"; $result = mysql_query("select query, date_format(time, '%Y-%m-%d %H:%i:%s'), elapsed, results from " . $mysql_table_prefix . "query_log order by time desc"); echo mysql_error(); while ($row = mysql_fetch_row($result)) { if ($class == "white") { $class = "grey"; } else { $class = "white"; } $word = $row[0]; $time = $row[1]; $elapsed = $row[2]; $results = $row[3]; print "<tr class=\"{$class}\"><td align=\"left\">" . htmlspecialchars($word) . "</td><td align=\"center\"> " . $results . "</td><td align=\"center\"> " . $time . "</td><td align=\"center\"> " . $elapsed . "</td></tr>"; } print "</table></td></tr></table></div>"; } if ($type == 'spidering_log') { $class = "grey"; $files = get_dir_contents($log_dir); if (count($files) > 0) { print "<div id=\"details\"><table cellspacing =\"0\" cellpadding=\"0\" class=\"darkgrey\"><tr><td><table cellpadding=\"3\" cellspacing = \"1\"><tr class=\"grey\"><td align=\"center\"><b>文件</b></td><td align=\"center\"><b>时间</b></td><td align=\"center\"><b></b></td></tr>"; for ($i = 0; $i < count($files); $i++) { $file = $files[$i]; $year = substr($file, 0, 2); $month = substr($file, 2, 2); $day = substr($file, 4, 2); $hour = substr($file, 6, 2); $minute = substr($file, 8, 2); if ($class == "white") { $class = "grey"; } else { $class = "white"; } print "<tr class=\"{$class}\"><td align=\"left\"><a href='{$log_dir}/{$file}' tareget='_blank'>{$file}</a></td><td align=\"center\"> 20{$year}-{$month}-{$day} {$hour}:{$minute}</td><td align=\"center\"> <a href='?f=delete_log&file={$file}' id='small_button'>删除</a></td></tr>"; } print "</table></td></tr></table></div>"; } else { ?> <br/><br/> <center><b>没有日志。</b></center> <?php } } }
<?php // Retina screen image replacement // see also js/2x.js // via: http://css3.bradshawenterprises.com/blog/retina-image-replacement-for-new-ipad/ function is_in_string($haystack, $needle) { if (strpos($haystack, $needle) !== false) { return 1; } else { return 0; } } function get_dir_contents($web_directory) { $directory = $_SERVER['DOCUMENT_ROOT'] . $web_directory; if (file_exists($directory)) { $myDirectory = opendir($directory); while ($entryName = readdir($myDirectory)) { if (is_in_string($entryName, "_2x")) { $dirArray[] = $entryName; } } return $dirArray; } } $web_directory = "/wp-content/themes/boilerplate/images/"; header('Content-type: application/json'); echo json_encode(get_dir_contents($web_directory));