include "{$relative_script_path}/admin/robot_functions.php";
include $relative_script_path . '/libs/htmlheader.php';
?>
<head>
<title>PhpDig : Cleanup dashes</title>
<?php 
include $relative_script_path . '/libs/htmlmetas.php';
?>
</head>
<body bgcolor="white">
<h2><?php 
phpdigPrnMsg('Cleanup dashes');
?>
</h2>
<?php 
$locks = phpdigMySelect($id_connect, 'SELECT locked FROM ' . PHPDIG_DB_PREFIX . 'sites WHERE locked = 1');
if (is_array($locks)) {
    phpdigPrnMsg('onelock');
} else {
    mysql_query('UPDATE ' . PHPDIG_DB_PREFIX . 'sites SET locked=1', $id_connect);
    $query = mysql_query("SELECT spider_id FROM " . PHPDIG_DB_PREFIX . "spider WHERE file = '';");
    while ($row = mysql_fetch_array($query)) {
        mysql_query("DELETE FROM " . PHPDIG_DB_PREFIX . "engine WHERE spider_id=" . $row['spider_id'] . ";");
        mysql_query("DELETE FROM " . PHPDIG_DB_PREFIX . "spider WHERE spider_id=" . $row['spider_id'] . ";");
        phpdigDelText($relative_script_path, $row['spider_id']);
        $count++;
        echo $count . " ";
    }
    echo phpdigMsg('done');
    mysql_query('UPDATE ' . PHPDIG_DB_PREFIX . 'sites SET locked=0', $id_connect);
}
Example #2
0
     // either all or force_all from shell
     $query_tempspider = "INSERT INTO " . PHPDIG_DB_PREFIX . "tempspider (site_id,file,path) SELECT site_id,file,path FROM " . PHPDIG_DB_PREFIX . "spider WHERE site_id={$site_id} {$andmore_tempspider}";
     mysql_query($query_tempspider, $id_connect);
 } elseif ($mode == 'small') {
     $limit = 0;
     // bypass config limit to index just one page
     $force_first_reindex = 1;
     // set to one to index just one page
 }
 //first level
 $level = 0;
 //store robots.txt datas
 $exclude = phpdigReadRobotsTxt($full_url);
 // parse exclude paths
 $query = "SELECT ex_id, ex_path FROM " . PHPDIG_DB_PREFIX . "excludes WHERE ex_site_id='{$site_id}'";
 if (is_array($list_exclude = phpdigMySelect($id_connect, $query))) {
     foreach ($list_exclude as $add_exclude) {
         $exclude[$add_exclude['ex_path']] = 1;
     }
 }
 print $hr . 'SITE : ' . $url . $br;
 if (is_array($exclude)) {
     print phpdigMsg('excludes') . ' :' . $br;
     foreach ($exclude as $ex_path => $tmp) {
         $ex_path = str_replace("\\", "", $ex_path);
         print '- ' . $ex_path . $br;
     }
 }
 $n_links = 0;
 // Spidering ...
 while ($level <= $limit) {
Example #3
0
if ($num < 1) {
    mysql_free_result($result_id);
    phpdigPrnMsg('no_site');
    $num_tot = 0;
} else {
    $a_result = mysql_fetch_array($result_id, MYSQL_ASSOC);
    extract($a_result);
    mysql_free_result($result_id);
    $query = "SELECT count(spider_id) as num_tot FROM " . PHPDIG_DB_PREFIX . "spider WHERE site_id='{$site_id}'";
    $result_id = mysql_query($query, $id_connect);
    $num_result = mysql_fetch_array($result_id, MYSQL_ASSOC);
    extract($num_result);
    mysql_free_result($result_id);
    // retrieve list of all exclude paths
    $query = "SELECT ex_id, ex_path FROM " . PHPDIG_DB_PREFIX . "excludes WHERE ex_site_id='{$site_id}'";
    $list_exclude = phpdigMySelect($id_connect, $query);
}
$query = "SELECT path,spider_id FROM " . PHPDIG_DB_PREFIX . "spider WHERE site_id={$site_id} GROUP BY path ORDER by path";
$result_id = mysql_query($query, $id_connect);
$num = mysql_num_rows($result_id);
if ($num < 1) {
    mysql_free_result($result_id);
}
?>
</head>
<body bgcolor="white">
<a name="AAA"></a>
<img src="../phpdig_logo_2.png" width="200" height="114" alt="PhpDig <?php 
print PHPDIG_VERSION;
?>
" /><br />
function phpdigGetLogs($id_connect, $type = 'lastqueries')
{
    $result = '';
    switch ($type) {
        case 'mostkeys':
            $query = 'SELECT k.keyword ,sum(e.weight) as num
          FROM ' . PHPDIG_DB_PREFIX . 'keywords k, ' . PHPDIG_DB_PREFIX . 'engine e
          WHERE k.key_id = e.key_id
          GROUP BY k.keyword
          ORDER BY num DESC LIMIT 30';
            $result = phpdigMySelect($id_connect, $query);
            break;
        case 'mostpages':
            $query = 'SELECT CONCAT(st.site_url,s.path,s.file) as page,s.num_words
          FROM ' . PHPDIG_DB_PREFIX . 'spider s, ' . PHPDIG_DB_PREFIX . 'sites st
          WHERE s.site_id = st.site_id
          ORDER BY num_words DESC LIMIT 30';
            $result = phpdigMySelect($id_connect, $query);
            break;
        case 'mostterms':
            $query = 'SELECT l_includes as search_terms,
          count(l_id) as num_time,
          sum(l_num) as total_results,
          round(avg(l_time),2) as avg_time
          FROM ' . PHPDIG_DB_PREFIX . 'logs
          WHERE l_includes <> \'\'
          GROUP BY search_terms
          ORDER BY num_time DESC LIMIT 30';
            $result = phpdigMySelect($id_connect, $query);
            break;
        case 'largestresults':
            $query = 'SELECT count(l_id) as queries,
          l_includes as with_terms,
          l_excludes as and_without,
          round(avg(l_num)) as average_results,
          round(avg(l_time),2) as avg_time
          FROM ' . PHPDIG_DB_PREFIX . 'logs
          GROUP BY with_terms, and_without
          HAVING average_results > 0
          ORDER BY average_results DESC LIMIT 30';
            $result = phpdigMySelect($id_connect, $query);
            break;
        case 'mostempty':
            $query = 'SELECT count(l_id) as queries,
          l_includes as with_terms,
          l_excludes as and_without
          FROM ' . PHPDIG_DB_PREFIX . 'logs
          WHERE l_num = 0
          AND l_includes <> \'\'
          GROUP BY with_terms, and_without
          ORDER BY queries DESC LIMIT 30';
            $result = phpdigMySelect($id_connect, $query);
            break;
        case 'lastqueries':
            $query = 'SELECT DATE_FORMAT(l_ts,\'%Y-%m-%d %H:%i%:%S\') as date,
          l_includes as with_terms,
          l_excludes as and_without,
          l_num as results,
          l_mode as "start/any/exact",
          l_time as search_time
          FROM ' . PHPDIG_DB_PREFIX . 'logs
          ORDER BY l_ts DESC LIMIT 30';
            $result = phpdigMySelect($id_connect, $query);
            break;
        case 'responsebyhour':
            $query = 'SELECT DATE_FORMAT(l_ts,\'%H:00\') as hour,
          round(avg(l_time),2) as avg_time,
          count(l_id) as num_queries
          FROM ' . PHPDIG_DB_PREFIX . 'logs
          WHERE l_time > 0
          GROUP BY hour';
            $result = phpdigMySelect($id_connect, $query);
            // fill empty hours
            for ($i = 0; $i < 24; $i++) {
                $hour[$i] = sprintf('%02d:00', $i);
            }
            $tempresult = array();
            if ($result) {
                foreach ($result as $row) {
                    while ($row['hour'] != ($this_hour = array_shift($hour))) {
                        array_push($tempresult, array('hour' => $this_hour, 'avg_time' => 0, 'num_queries' => 0));
                    }
                    array_push($tempresult, $row);
                }
                if (count($hour) > 0) {
                    foreach ($hour as $this_hour) {
                        array_push($tempresult, array('hour' => $this_hour, 'avg_time' => 0, 'num_queries' => 0));
                    }
                }
            }
            $result = $tempresult;
            break;
        case 'lastclicks':
            $query = 'SELECT DATE_FORMAT(c_time,\'%Y-%m-%d %H:%i%:%S\') as date,
          c_num as link_num,
          c_url as link_url,
          c_val as link_query
          FROM ' . PHPDIG_DB_PREFIX . 'clicks
          ORDER BY c_time DESC LIMIT 30';
            $result = phpdigMySelect($id_connect, $query);
            break;
    }
    return $result;
}
Example #5
0
Copyright (C) 2001 - 2003, Antoine Bajolet, http://www.toiletoine.net/
Copyright (C) 2003 - current, Charter, http://www.phpdig.net/
Contributors hold Copyright (C) to their code submissions.
Do NOT edit or remove this copyright or licence information upon redistribution.
If you modify code and redistribute, you may ADD your copyright to this notice.
----------------------------------------------------------------------------------
*/
require_once "../prepend.php";
$no_connect = 0;
include "{$relative_script_path}/includes/config.php";
include "{$relative_script_path}/libs/auth.php";
include "{$relative_script_path}/admin/robot_functions.php";
$site_id = value("site_id", "NUMERIC");
// extract http vars
extract(phpdigHttpVars(array('spider_id' => 'integer', 'spider' => 'integer', 'sup' => 'integer', 'site_id' => 'integer')), EXTR_SKIP);
$verify = phpdigMySelect($id_connect, 'SELECT locked FROM ' . PHPDIG_DB_PREFIX . 'sites WHERE site_id=' . (int) $site_id);
if (is_array($verify) && !$verify[0]['locked'] && $spider_id) {
    mysql_query('UPDATE ' . PHPDIG_DB_PREFIX . 'sites SET locked=1 WHERE site_id=' . $site_id, $id_connect);
    $query = "SELECT site_id,path,file FROM " . PHPDIG_DB_PREFIX . "spider where spider_id={$spider_id}";
    $result_id = mysql_query($query, $id_connect);
    if (mysql_num_rows($result_id)) {
        list($site_id, $path, $file) = mysql_fetch_row($result_id);
    }
    if ($spider) {
        $query = "DELETE FROM " . PHPDIG_DB_PREFIX . "tempspider WHERE site_id={$site_id}";
        $result_id = mysql_query($query, $id_connect);
        if ($path && strlen($path) > 0 && LIMIT_TO_DIRECTORY) {
            $query_includes = "INSERT INTO " . PHPDIG_DB_PREFIX . "includes SET in_site_id = " . $site_id . ", in_path = '" . $path . "';";
            mysql_query($query_includes, $id_connect);
        }
        $query = "INSERT INTO " . PHPDIG_DB_PREFIX . "tempspider SET site_id={$site_id},path='{$path}',file='{$file}'";