View Single Post
  #26  
Old 04-14-2009, 05:45 PM
Crimm's Avatar
Crimm Crimm is offline
 
Join Date: Feb 2007
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay this update utilizes the config.php to pull database information, so you don't have to enter it.

The only thing you have to enter is the little bit of stuff at the top.

Code:
<?php
require_once('./includes/config.php');

///////////////////////Configure this/////////////////////////////////////////////////////

$sitename="SITENAME WITHOUT THE HTTP!!"; // sitename including www
$maxkey = "8"; // max key words as you specified in tfseo control panel
$home_freq = "daily"; //always, hourly, daily, weekly, monthly, yearly, never
$home_priority = "1"; // google priority for home (www.yoursite.com)
$forum_freq = "daily"; //always, hourly, daily, weekly, monthly, yearly, never
$forum_priority = "0.8"; // google priority for forums (www.yoursite.com/f4)
$thread_freq = "daily"; //always, hourly, daily, weekly, monthly, yearly, never
$thread_priority = "0.4"; // google priority for threads (www.yoursite.com/f4/your-thread)

function remove_accents($string){ ////this strings must be the same you are using as character replacements, these are the "wide range"

    return strtr($string,
                "???????????????????????????????????????????????????????????????@?",
                "YuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyyEan");
}

////////////////////////////DONT NEED TO TOUCH ANYTHING BELOW//////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////

$username=$config['MasterServer']['username']; //your db user name
$password=$config['MasterServer']['password']; // the pass for the db
$database=$config['Database']['dbname']; // name of db
$server=$config['MasterServer']['servername']; // server 
$prefix = $config['Database']['tableprefix'];


function unhtmlspecialchars($text)
{

		$text = preg_replace('/&#([0-9]+);/esiU', "convert_int_to_utf8('\\1')", $text);


	return str_replace(array('&lt;', '&gt;', '&quot;', '&amp;'), array('<', '>', '"', '&'), $text);
}



//connect to the database  
$link = mysql_connect($server,$username,$password);
mysql_select_db($database,$link) or die( "Unable to select database"); 

$result = mysql_query("select * from " . $prefix . "thread WHERE visible = 1",$link);
$num_rows = mysql_num_rows($result);     
$query = "select * from " . $prefix . "thread WHERE visible = 1  ORDER BY dateline desc" ;  
$result = mysql_query($query) or die("Query failed");  

$num_rows2 = mysql_num_rows(mysql_query("select * from " . $prefix . "forum"));     
$query2 = "select * from " . $prefix . "forum ORDER BY forumid desc" ;  
$result2 = mysql_query($query2) or die("Query failed");  

//this is the normal header applied to any Google sitemap.xml file  
echo '<?xml version="1.0" encoding="ISO-8859-1"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">';  

//HOME RESULTS
 
$url_product ="http://" . $sitename;
          
$realdate = date("Y-m-d");
$year = substr($realdate,0,4); //work out the month    
$mon  = substr($realdate,5,2); //work out the month  
$day  = substr($realdate,8,2); //work out the day       
$displaydate = ''.$year.'-'.$mon.'-'.$day.''; 
                     
echo  
'  
<url>  
<loc>'.$url_product.'</loc>  
<lastmod>'.$displaydate.'</lastmod>  
<changefreq>'.$home_freq.'</changefreq>  
<priority>'.$home_priority.'</priority>  
</url>  
';  


//FORUM RESULTS  
$i=0;
for($i=0;$i<$num_rows2; $i++)  
{  
$url_product ="http://" . $sitename . "/f" .mysql_result($result2,$i,"forumid");
     
/*you need to assign a date to the entity.  if you don't  
 store a timestamp in the Database then you need slapping*/  
      
$realdate = date("Y-m-d");
$year = substr($realdate,0,4); //work out the month    
$mon  = substr($realdate,5,2); //work out the month  
$day  = substr($realdate,8,2); //work out the day       
$displaydate = ''.$year.'-'.$mon.'-'.$day.''; 
                     
echo  
'  
<url>  
<loc>'.$url_product.'</loc>  
<lastmod>'.$displaydate.'</lastmod>  
<changefreq>'.$forum_freq.'</changefreq>  
<priority>'.$forum_priority.'</priority>  
</url>  
';  
}

//THREAD RESULTS  
for($i=0;$i<$num_rows; $i++)  
{  
//cleanurl
$title = mysql_result($result,$i,"title");
$a = strtolower($title);
$a = remove_accents($a);
$a = unhtmlspecialchars($a);
$a = str_replace("'", '', $a);
$a = preg_split("#[^a-z0-9]#", $a, -1, PREG_SPLIT_NO_EMPTY);
$a = array_slice($a, 0, $maxkey);
$a = implode("-",$a);
if (empty($a))
{
$a = 'thread';
}

//your url-product as we worked out in #4   
$url_product ="http://" . $sitename . "/f" .mysql_result($result,$i,"forumid") . "/" . $a . '-t' .mysql_result($result,$i,"threadid");
     
/*you need to assign a date to the entity.  if you don't  
 store a timestamp in the Database then you need slapping*/  
      

$date = mysql_result($result,$i,"dateline"); //the date stored  
$realdate = date('Y-m-d H:i:s', $date);

$year = substr($realdate,0,4); //work out the month    
$mon  = substr($realdate,5,2); //work out the month  
$day  = substr($realdate,8,2); //work out the day  
   
/*display the date in the format Google expects: 
2006-01-29 for example*/  
     
$displaydate = ''.$year.'-'.$mon.'-'.$day.''; 
                     
//you can assign whatever changefreq and priority you like 
echo  
'  
<url>  
<loc>'.$url_product.'</loc>  
<lastmod>'.$displaydate.'</lastmod>  
<changefreq>'.$thread_freq.'</changefreq>  
<priority>'.$thread_priority.'</priority>  
</url>  
';  
   }  
   
mysql_close(); //close connection  
 
//close the XML attribute that we opened in #3  
echo  
'</urlset>';  



?>
It translates to XML using IE7 - Just tried and I'm awaiting another re-submission with Google Webmaster Tools.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01079 seconds
  • Memory Usage 1,800KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete