phplinkdirectory mod for google sitemap

Discussion in 'PHP' started by mehrun48, Jul 28, 2007.

Thread Status:
Not open for further replies.
  1. #1
    what is the best free google sitemap mod for phplinkdirectory 2.2.

    thanks
     
    mehrun48, Jul 28, 2007 IP
  2. Greg Carnegie

    Greg Carnegie Peon

    Messages:
    385
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I belive there isn't any but it shouldn't be hard to create one.

    This is what i created it is code for phpLD v2 only, i didn't wrote code for link directories with more then 5000 categories because i do not have such directory and i would be unable to test it, but it can be done also.
    
    <?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
    	http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
    <?php
    
    // phpLD sitemap
    require "init.php";
    
    function outputXML($url)
    {
        echo "<url>";
        echo "<loc>$url</loc>";
        echo "<lastmod>".date("Y-m-d")."</lastmod><changefreq>weekly</changefreq><priority>0.8</priority>";
        echo "</url>";
    }
    
    $rs = $db->Execute("SELECT count(*) as x FROM ".TABLE_PREFIX."category");
    
    if($rs->fields['x']>5000)
    {
        // create multi sitemaps
        
    }
    else
    {
        // one sitemap
        if(ENABLE_REWRITE)
        {
            $rs = $db->Execute("SELECT ID, TITLE_URL, PARENT_ID FROM ".TABLE_PREFIX."category WHERE STATUS=2 ORDER BY ID ASC");
            $p = array();
            while(!$rs->EOF)
            {
                if($rs->fields['PARENT_ID']==0)
                {
    				outputXML(SITE_URL.$rs->fields['TITLE_URL']);
                    $p[$rs->fields['ID']] = $rs->fields['TITLE_URL'];
                }
                else
                {
                    outputXML(SITE_URL.$p[$rs->fields['PARENT_ID']]."/".$rs->fields['TITLE_URL']);
                }
                $rs->MoveNext();
            }
        }
        else
        {
            $rs = $db->Execute("SELECT ID FROM ".TABLE_PREFIX."category WHERE STATUS=2 ORDER BY ID ASC");
            while(!$rs->EOF)
            {
                outputXML(SITE_URL."index.php?c=".$rs->fields['ID']);
                $rs->MoveNext();
            }
        }
    }        
    ?>	
    	
    </urlset>
    	
    
    PHP:
     
    Greg Carnegie, Jul 28, 2007 IP
Thread Status:
Not open for further replies.