# Create Google Sitemap for 4images
# Created by Mai Minh (minh@maingo.com http://www.vna2z.com)
# Modified by Oliver van der Werf (info@flash-webdesign.de http://www.flash-webdesign.de)
# Adapted for [MOD] Google Friendly Urls by Fábio Dantas (fabio@amopiaui.com http://www.famosasx.info)
# Date: 28/11/2006 | 02.01.2007 | 16/06/2008
# You can send ping to Google with this request: http://www.google.com/webmasters/sitemaps/ping?sitemap=URL_TO_YOUR_SITEMAP
#---------------------------------
require("config.php");
# 4images top page (with trailing slash)
$gallery_url = 'http://www.zharii.kiev.ua/4/';
# Choose the URL format
# 0 is http://www.site.com/cat123.htm
# 1 is http://www.site.com/details.php?image_id=123
# 2 is http://www.site.com/r-category-1-subcategory-2-image-123.htm
$shortURL = 2; // 0 or 1 or 2
# If $shortURL is different of 2, you can delete these three lines below:
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$link=mysql_connect("$db_host","$db_user","$db_password");
mysql_select_db("$db_name") or die ("Cannot connect database!");
# Priotity
//select between 0.0 and 1.0
//0.0 identifies the lowest priority page(s) on your website
//1.0 identifies the highest priority page(s) on your website
$prio_img		= 0.5;
$prio_cat		= 0.8;
$prio_profile	= 0.3;
# Frequency
//"always", "hourly", "daily", "weekly", "monthly", "yearly" or "never"
$freq_img		= 'weekly';
$freq_cat		= 'daily';
$freq_profile	= 'daily';
# Print XML header
xml_head();
# Print URLs
$categories = mysql_query('SELECT cat_id FROM ' . $table_prefix . 'categories');
while ($category = mysql_fetch_array($categories))
{
	$catid = $category['cat_id'];
	
	switch ($shortURL){
	case 0:
		$cat_url = $gallery_url.'cat'.$catid.'.htm';
		break;
	case 1:
		$cat_url = $gallery_url.'categories.php?cat_id='.$catid;
		break;	
	case 2:
		$cat_url = $site_sess->url($script_url."/categories.php?".URL_CAT_ID."=".$catid);
		break;
	}
	print_xml($cat_url,$prio_cat,'',$freq_cat);
}
$images = mysql_query('SELECT image_id,image_active,image_date FROM ' . $table_prefix . 'images ');
while ($image = mysql_fetch_array($images))
{
	if ($image['image_active'] == 1) {
		$imgid = $image['image_id'];
		$date = $image['image_date'];
		$date = date("Y-m-d",$date)."T".date("H:i:s",$date)."+00:00";
		switch ($shortURL){
		case 0:
			$img_url = $gallery_url.'img'.$imgid.'.htm';
			break;
		case 1:
			$img_url = $gallery_url.'details.php?image_id='.$imgid;
			break;	
		case 2:
			$img_url = $site_sess->url($script_url."/details.php?".URL_IMAGE_ID."=".$imgid);
			break;
		}
		
		print_xml($img_url,$prio_img,$date,$freq_img);
	}
}
$profiles = mysql_query('SELECT user_id, user_lastaction FROM ' . $table_prefix . 'users WHERE user_id >= "1"');
while ($profile = mysql_fetch_array($profiles))
{
	$profileid = $profile['user_id'];
	$date = $profile['user_lastaction'];
	$date = date("Y-m-d",$date)."T".date("H:i:s",$date)."+00:00";
	$profile_url = $gallery_url.'member.php?action=showprofile&user_id='.$profileid;
	print_xml($profile_url,$prio_profile,$date,$freq_profile);
}
# Print XML footer
xml_foot();
function xml_head() {
	$freq = 'daily';
	$priority = '1.0';
	$mod = date("Y-m-d")."T".date("H:i:s")."+00:00";
	echo "
";
}
#-----------------------------------------------
# xml_foot
#-----------------------------------------------
function xml_foot() {
	echo "
";
}
#-----------------------------------------------
# print_xml
#-----------------------------------------------
function print_xml($url,$priority,$lastmod,$changefreq) {
	$temp = "
	$url";
	$temp .= "  $priority";
	if ($lastmod != '') {
		$temp .="  $lastmod";
	}
	$temp .= "  $changefreq
	";
	echo $temp;
}
?>