1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

vbsitemap version 0.1 for google sitemaps

Discussion in 'Google Sitemaps' started by kalius, Jun 4, 2005.

  1. Infiniterb

    Infiniterb Well-Known Member

    Messages:
    1,312
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    168
    #21
    I know, just something to keep in mind. Great work on what has been done thus far. If I knew a lick of php I'd lend a hand, but instead I just sit back and give ideas while development is in progress by those of you who have a clue.

    Thanks again, btw.
    SEMrush
     
    Infiniterb, Jun 4, 2005 IP
    SEMrush
  2. sarahk

    sarahk iTamer Staff

    Messages:
    24,965
    Likes Received:
    3,392
    Best Answers:
    99
    Trophy Points:
    615
    #22
    Google have provided us with the ping address so at the end we need to add a ping (untested)
    $google_url = 'http://www.google.com/webmasters/sitemaps/ping?sitemap=';
     $ping_url = rawurlencode($google_url . $base. $file);
    
     $churl = @fopen($ping_url,'r');
     
     if (!$churl) mail($technicalemail, 'Google ping failed', date('Y-m-d H:i'));
    Code (markup):
    $technicalemail is defined in config.php

    Sarah
     
    sarahk, Jun 5, 2005 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    24,965
    Likes Received:
    3,392
    Best Answers:
    99
    Trophy Points:
    615
    #23
    Ok, got it set up and ready to test but because the file name has changed I'll wait for Google to take it manually first.

    I like that you've added the gzip!

    Sarah
     
    sarahk, Jun 5, 2005 IP
  4. kalius

    kalius Peon

    Messages:
    599
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #24
    Thanks for the ping part sarahk, I'll add it. Im thinking about doing a major rewrite to make it scale better.
     
    kalius, Jun 5, 2005 IP
  5. ZuraX

    ZuraX Active Member

    Messages:
    156
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #25
    nm fixed.. I had the file chmod 777 and changed it to 666 and it worked :)
     
    ZuraX, Jun 6, 2005 IP
  6. kalius

    kalius Peon

    Messages:
    599
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #26
    Some minor code cleaning.
     

    Attached Files:

    kalius, Jun 8, 2005 IP
  7. City2

    City2 Peon

    Messages:
    542
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #27
    The idea is awesome and works well but the problem is some of us have Mod Rewrite installed and the sitemaps shows our old URLS. The concept is pretty much the same as the threads instead of showthread.php?t=# are as thread#.html and same format for the posts but with showpost of course. Would it be possible to show us how to use mod rewrite URLS as well.

    Thanks :)
     
    City2, Jun 9, 2005 IP
  8. berberber

    berberber Peon

    Messages:
    4
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #28
    Hello, i added some things and i share the additions, upload did not work...


    added, links to archive, links to member profiles, and ping to google like above
    Bernhard


    <?php
    // base url of the forum with trailing slash, table prefix if any,
    $base = 'http://help.berberber.com/';
    $prefix = '';
    // home page if different than the base url for the forum
    $home = 'http://help.berberber.com/';
    
    // the var string for forum display
    // if your url is forumdisplay.php?f=73  then this would be f=
    $forumq = 'f=';
    // the var string for your thread display
    // if your url is  showthread.php?t=872 then is t=
    $threadq = 't=';
    
    
    // the var string for your member display
    // if your url is  member.php?u=872 then is t=
    $memberq = 'u=';
    
    
    // url text file name make it writable!!!
    $file = 'sitemap.xml.gz';
    // new line character \r\n for widnows \n for unix
    $nl = "\n";
    // forum priority , tread priority, member priority, change frequency tread and forum see the sitemaps dcumentation
    $fpriority = "0.8";
    $tpriority = '1.0';	
     $mpriority = '0.1';	
    
    
    $fchange ='daily' ;
    $tchange ='weekly';	 
    $mchange ='monthly';	 
    // base and forum base change and priority
    $bchange ='hourly';
    $bpriority = '1.0';
    
    // change to the path to config.php
    require 'includes/config.php';
    // end variabless
    
    
    function mysql2date($dateformatstring, $mysqlstring, $use_b2configmonthsdays = 1) {
    	global $month, $weekday, $month_abbrev, $weekday_abbrev;
    	$m = $mysqlstring;
    	if (empty($m)) {
    		return false;
    	}
    	$i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4));
    	if (!empty($month) && !empty($weekday) && $use_b2configmonthsdays) {
    		$datemonth = $month[date('m', $i)];
    		$datemonth_abbrev = $month_abbrev[$datemonth];
    		$dateweekday = $weekday[date('w', $i)];
    		$dateweekday_abbrev = $weekday_abbrev[$dateweekday];
    		$dateformatstring = ' '.$dateformatstring;
    		$dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
    		$dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
    		$dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
    		$dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
    
    		$dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
    	}
    	$j = @date($dateformatstring, $i);
    	if (!$j) {
    	// for debug purposes
    	//	echo $i." ".$mysqlstring;
    	}
    	return $j;
    }
    
    
    
    $basestr = " $bchange $bpriority";
    $fstr = " $fchange $fpriority";
    $tstr = " $tchange $tpriority";
    
    	$connection = mysql_connect($servername, $dbusername, $dbpassword ) or die("Database is down please try again");
        $db = mysql_select_db($dbname, $connection) or die ("NO DATABASE" );
    
    //$handle = fopen("$file", "w");
    $a = date('Y-m-d\TH:i:s\Z');
    $handle = gzopen($file, 'w9');
    gzwrite( $handle, '<?xml version="1.0" encoding="UTF-8"?>'."\n");
    gzwrite( $handle, "<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\">
    <url>
    <loc>{$home}</loc>
    <lastmod>".$a."</lastmod>
    <changefreq>{$bchange}</changefreq>
    <priority>{$bpriority}</priority>
    </url>\n
    <url>
    <loc>{$base}</loc>
    <lastmod>".$a."</lastmod>
    <changefreq>{$bchange}</changefreq>
    <priority>{$bpriority}</priority>
    </url>\n");
    
    $forums = $prefix."forum";
    $treads = $prefix."thread";
    $members = $prefix."user";							
    
    
    
    
    
    
    $fquery = "SELECT forumid, lastpost FROM $forums";
    $results = mysql_query($fquery) or DIE("$fquery" );
    $num_rows = mysql_num_rows($results);
    for ( $i = 0; $i < $num_rows; $i++)
     {
    
       $row = mysql_fetch_row($results);
    
       $url = $base."forumdisplay.php?".$forumq.$row[0];	
       $url2 = $base."archive/index.php/f-".$row[0].".html";
        $txt = "<url>
    <loc>{$url}</loc>
    
    <changefreq>{$fchange}</changefreq>
    <priority>{$fpriority}</priority>
    </url>\n
    <url>
    <loc>{$url2}</loc>
    
    <changefreq>{$fchange}</changefreq>
    <priority>{$fpriority}</priority>
    </url>\n";
       gzwrite($handle, $txt);
     }
    // <lastmod>".mysql2date('Y-m-d\TH:i:s\Z', $row[1], false)."</lastmod>
    								
    
    
    
    
    $tquery = "SELECT threadid, lastpost FROM $treads";
    
    $results = mysql_query($tquery) or DIE("$tquery" );
    $num_rows = mysql_num_rows($results);
    
    for ( $i = 0; $i < $num_rows; $i++)
     {
       $row = mysql_fetch_row($results);
       // print_r($row);
       $url = $base."showthread.php?".$threadq.$row[0];	 
       $url2 = $base."archive/index.php/t-".$row[0].".html";
       $txt = "<url>
    <loc>{$url}</loc>
    
    <changefreq>{$tchange}</changefreq>
    <priority>{$tpriority}</priority>
    </url>\n
    <url>
    <loc>{$url2}</loc>
    
    <changefreq>{$tchange}</changefreq>
    <priority>{$tpriority}</priority>
    </url>\n";
       gzwrite($handle, $txt);
    
     }
    //<lastmod>".mysql2date('Y-m-d\TH:i:s\Z', $row[1], false)."</lastmod>		  
    
    
    
    
    
    
     $tquery = "SELECT userid FROM $members";
    
    $results = mysql_query($tquery) or DIE("$tquery" );
    $num_rows = mysql_num_rows($results);
    
    for ( $i = 0; $i < $num_rows; $i++)
     {
       $row = mysql_fetch_row($results);
       // print_r($row);
       $url = $base."member.php?".$memberq.$row[0];	 
       $txt = "<url>
    <loc>{$url}</loc>
    
    <changefreq>{$mchange}</changefreq>
    <priority>{$mpriority}</priority>
    </url>\n";
       gzwrite($handle, $txt);
    
     }
    
    
    
    
    
    
    
    
    
    gzwrite($handle, "</urlset>\n");
    gzclose($handle);
    
    $google_url = 'http://www.google.com/webmasters/sitemaps/ping?sitemap=';
     $ping_url = rawurlencode($google_url . $base. $file);
    
     $churl = @fopen($ping_url,'r');
     
     if (!$churl) mail($technicalemail, 'Google ping failed', date('Y-m-d H:i'));
     
     
     
    header("Location: {$file}");
    exit;
    ?>
    
    PHP:
     
    berberber, Jun 14, 2005 IP
    Infiniterb likes this.
  9. Infiniterb

    Infiniterb Well-Known Member

    Messages:
    1,312
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    168
    #29
    Well done, berberber.

    Anyway to do any checks to see if you have more than 50,000 urls to make a second site map (and possibly more). This would greatly benefit those of us with large forums.
     
    Infiniterb, Jun 15, 2005 IP
  10. ZuraX

    ZuraX Active Member

    Messages:
    156
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #30
    Why does it have to ping google?
     
    ZuraX, Jun 15, 2005 IP
  11. Infiniterb

    Infiniterb Well-Known Member

    Messages:
    1,312
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    168
    #31
    It pings google to let them know a new map is up. It does this so you don't have to manually submit the site map when changes are made to it.
     
    Infiniterb, Jun 15, 2005 IP
  12. berberber

    berberber Peon

    Messages:
    4
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #32
    to say its updated..... you can do the same action, on -https://www.google.com/webmasters/sitemaps/
     
    berberber, Jun 15, 2005 IP
  13. ZuraX

    ZuraX Active Member

    Messages:
    156
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #33
    Any idea why everytime I change the file to the new code you all keep posting I get the text of the file and not an XML showing when I goto the page? If I try a refresh it still shows a text of the links. If I close the window and reopen it and view the page again it works fine.

    Also the sitemap.xml.gz file, if I dont chmod it 666 it wont work. Can google still grab it?
     
    ZuraX, Jun 15, 2005 IP
  14. ZuraX

    ZuraX Active Member

    Messages:
    156
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #34
    I just got an email saying the ping failed...

    Subject: Google ping failed
    From: Nobody

    2005-06-15 03:43
     
    ZuraX, Jun 15, 2005 IP
  15. berberber

    berberber Peon

    Messages:
    4
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #35
    you are redirected to the created file, to not be you can remove that

    header("Location: {$file}");
    PHP:
    concerning ping, i am not sure it actualyworks, i heard servers are pretty busy

    yes, 666 shouldnt be a problem, to see if it worked well, submit uour sitemap on googles sites, it will say you how it worked
     
    berberber, Jun 15, 2005 IP
  16. kalius

    kalius Peon

    Messages:
    599
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #36
    Can you show me the links exactly? I might be able to help.

    Sorry I haven't replied in a while this tread wasn't comming up for me
     
    kalius, Jun 15, 2005 IP
  17. kalius

    kalius Peon

    Messages:
    599
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #37

    I'm planning on it but I wont have time until next month to work on this, Does anyone know fi the tables stay the same with vb 3.5 or they change?
     
    kalius, Jun 15, 2005 IP
  18. berberber

    berberber Peon

    Messages:
    4
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #38
    I saw the feature was suggested to be on VB3.5 on vb.com, so perhaps it will be native then ?
     
    berberber, Jun 15, 2005 IP
  19. bonjurkes

    bonjurkes Well-Known Member

    Messages:
    106
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #39
    hey i uploaded this script and change my forum address and etc... but when i enter link i get this error

    Warning: main(/public_html/forum/includes/config.php): failed to open stream: No such file or directory in /home/xturkx/public_html/deneme/vbsitemap-035.php on line 28

    Warning: main(/public_html/forum/includes/config.php): failed to open stream: No such file or directory in /home/xturkx/public_html/deneme/vbsitemap-035.php on line 28

    Fatal error: main(): Failed opening required '/public_html/forum/includes/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xturkx/public_html/deneme/vbsitemap-035.php on line 28


    what is the reason of this?

    also this script's address is :

    http://www.xturkx.com/deneme/vbsitemap-035.php
     
    bonjurkes, Jun 15, 2005 IP
  20. ZuraX

    ZuraX Active Member

    Messages:
    156
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #40
    Make sure you edit this line:

    
    // change to the path to config.php 
    require 'forums/includes/config.php'; 
    
    Code (markup):
    No begining /
     
    ZuraX, Jun 15, 2005 IP