View Single Post
Old 03-24-2004, 10:27 PM   #4
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. TMTOWTDI, but here's one way to make a sitemap using info in the PhpDig tables.
PHP Code:
<?php

define
('PHPDIG_DB_PREFIX','prefix');
define('PHPDIG_DB_HOST','localhost');
define('PHPDIG_DB_USER','username');
define('PHPDIG_DB_PASS','password');
define('PHPDIG_DB_NAME','database');

$id_connect mysql_connect(PHPDIG_DB_HOST,PHPDIG_DB_USER,PHPDIG_DB_PASS);
if (!
$id_connect) {
    die(
"Unable to connect to database.\n");
}

$db_select mysql_select_db(PHPDIG_DB_NAME,$id_connect);
if (!
$db_select) {
    die(
"Unable to select the database.\n");
}

$query mysql_query("SELECT ".PHPDIG_DB_PREFIX."sites.site_url,".
PHPDIG_DB_PREFIX."spider.path,".PHPDIG_DB_PREFIX."spider.file,".
PHPDIG_DB_PREFIX."spider.first_words FROM ".
PHPDIG_DB_PREFIX."sites,".PHPDIG_DB_PREFIX."spider WHERE ".
PHPDIG_DB_PREFIX."sites.site_id = ".PHPDIG_DB_PREFIX."spider.site_id ".
"ORDER BY ".PHPDIG_DB_PREFIX."sites.site_url,".
PHPDIG_DB_PREFIX."spider.path,".PHPDIG_DB_PREFIX."spider.first_words;");

$num mysql_num_rows($query);
echo 
"<html><body><b>Sitemap</b><br><br>";
list(
$url,$path,$file,$words) = mysql_fetch_row($query);
$one_url $url;
$one_path $path;
echo 
$one_url.$one_path."<ul>";

for (
$i=0$i<$num$i++) {
    if ((
$one_url != $url) || ($one_path != $path)) {
        
$one_url $url;
        
$one_path $path;
        echo 
"</ul>".$one_url.$one_path."<ul>";
    }
    
$full_url $url.$path.$file;
    
$words explode("\n",$words);
    if (
strlen($words[0]) > 20) {
        
$part_words substr($words[0],0,17)."...";
    }
    else {
        
$part_words $words[0];
    }
    echo 
"<li><a href=\"$full_url\">$part_words</a>";
    if (
$i != $num-1) {
        list(
$url,$path,$file,$words) = mysql_fetch_row($query);
    }
}

echo 
"</ul></body></html>";

?>
Remember to remove any "word" wrapping in the above code.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote