Location: PHPKode > projects > Rumba XML > index.php
<?php
session_start();
header('Content-Type: text/html; charset=utf-8'); 

	 $temp = array('localhost', 'test.ru', 'test1.ru');
	if	(in_array($_SERVER['SERVER_NAME'], $temp)==true )
		{Error_reporting  (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_ALL);}
include 'data/config.php';
include 'data/unikanons.php';
include 'data/def.php';
include 'data/functions.php';
include 'data/stopword.php';

# ---------- BAN
//foreach ($_bazadied['browser'] as $item)
//	{if ($item == $_SERVER['HTTP_USER_AGENT'])  {exit("Only for peoples!");}}
foreach ($_bazadied['ip'] as $item)
	{if (strpos($_SERVER['REMOTE_ADDR'], $item)!==false	)  {exit("IP ban!");}}
foreach ($_bazadied['slova'] as $item)
	{if (strpos($_SERVER['REQUEST_URI'], $item)!==false	)  {exit("XSS !");}}
#foreach ($_bazadied['host'] as $item)
#	{if (strpos($_SERVER['HTTP_REFERER'], $item)!==false || $_SERVER['HTTP_REFERER']==false)  {exit("HOST ban!");}}
if (array_key_exists('REMOTE_ADDR', $_SERVER)==false) {exit("no IP !!!");}

# echo '<pre>';print_r($_SERVER);echo '</pre>';
#====  +++++++++
$FULL_NUM_PAGES=true; # Responsible for the generation of full page numbers (a little weight as host)
$menucattape=$menucatdir=$pattern_list=$pattern_lenta=$adminpanel=$rsspage=$rsstime = $temp_title=$last_news_list=$rezult_ping=$menucatselect=$menucommentselect=$menutagselect=$keywords=$telo_query='';
$sesia=false;
if(@$_SESSION[md5(getcwd())][session_id()]==md5 ($adminpass))
{
$sesia=true; 
$temp_narod=$temp_query=''; 
if(file_exists('narod.php')){$temp_narod=' <a href=narod.php?pass='.md5($adminpass.date("dym")).' target=blank>[FTP]</a> ';}
$adminpanel.='
 <a href=index.php?event=logout>[Log out]</a> 
 '.$temp_narod.'
 '.$temp_query.'
 <a href=index.php?event=imagemenu>[Images]</a> 
 <a href=index.php?event=categorymenu>[Category]</a> 
 <a href=index.php?event=tagmenu>[Tags]</a> 
 <a href=index.php?event=addpagemenu>[Add page]</a> ';

}
$_SESSION['real']=session_id(); 
$time1 = microtime();
$time_en_to_ru=$lang;
$translit_popular=false;
# --- checking caching---
if ($cashe > 0 && $sesia != true && strpos($_SERVER['REQUEST_URI'],'index.php?event=logmenu')!=true)
	{
	$temp = del_simb ($_SERVER['REQUEST_URI']);
	if (@filemtime ($cashepatch.$temp.'.html')+$cashe >= time())
		{
		$fpp=fopen($cashepatch.$temp.'.html', 'r');
		$fulldata=fread($fpp,filesize($cashepatch.$temp.'.html')); 
		fclose($fpp);
		# -- result output
		print trim($fulldata);
		if($_GET['event'] !="rss")
		{print "<div align=\"center\">".abs(microtime()-$time1)."</div>";}
		exit;
		}
	}
# --- setting start page ---
if (array_key_exists('event', $_GET)==false && array_key_exists('event', $_POST)==false)
	{$_GET['str']=0; $_POST['event']='zero';
	if ($startpage=='none') {$_GET['event']='all';	$_GET['zapros']=0; }
	else					{$_GET['event']='page';	$_GET['zapros']=$startpage;}
	}
if (array_key_exists('str', $_GET)==false) {$_GET['str']=0;}
# --- misc stuff ---
include 'data/lang.php';
$simb_http	=	"http:".chr("47").chr("47");
$simb_left	=	"&nbsp; &lt; &lt; &lt; &lt; &nbsp;";
$simb_right	=	"&nbsp; &gt; &gt; &gt; &gt; &nbsp;";

#$server=$simb_http.str_replace("index.php", "", $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']);
$server=$simb_http.str_replace("index.php", "", $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
$serverlocal=getcwd();

$zapros='0';
$telo='<!-- telo -->';
$fulldata=$title=$desc='';
# ---------- get last komment
$tempik = file("comment/lastfodif.txt"); $lastcomm = '';
for ($i=count($tempik)-1,$ss=$q88q;  $i>0, $ss>0;  $i--,$ss--)
										{if ($i<0 || $ss<0) {break;}
										$lastcomm.=$tempik[$i];}
# ---------- get pattern
$MyGMTtime=gmdate("D, d M Y H:i:s");
if (array_key_exists('event', $_GET)==false) {$_GET['event'] = 'zero';}

		if( $_GET['event'] !="rss")
			{
			if(!isset($_GET['zapros'])){$_GET['zapros']='';}
			# $temp=explode('/', $_SERVER['REQUEST_URI']);
			if (isset($_SERVER['REDIRECT_URL']))
				{
				$temp=explode('/', $_SERVER['REDIRECT_URL']);
				$tempik=$temp[count($temp)-1];
				}
			else{$tempik='index.html';}
			
			if (file_exists('data/template/'.$tempik) && trim($tempik)!='')
				{ # individual pattern
				$fpp=fopen('data/template/'.$tempik, "r");
				$fulldata=fread($fpp,filesize('data/template/'.$tempik)); 
				fclose($fpp);
				}
			else
				{
				$tempik='pattern.html'; # standart pattern
				$temp = ''; $temp_pat_adr=array();
				# get list name for pattern
				foreach (explode ('-', $_GET['zapros']) as $item)
					{
					$temp = ($temp=='')? $item:$temp.'-'.$item;
					$temp_pat_adr[]=$temp;
					}
				$temp_pat_adr[]='';
				rsort ($temp_pat_adr);
				# search category pattern
				foreach ($temp_pat_adr as $item)
					{
					if (file_exists('data/template/'.$_GET['event'].'_'.$item.'.html'))
						{$tempik='data/template/'.$_GET['event'].'_'.$item.'.html'; break;}
					}
				# load pattern
				$fpp=fopen($tempik, "r");
				$fulldata=fread($fpp,filesize($tempik)); 
				fclose($fpp);
				}
			}
		if($_GET['event'] =="rss")
			{
				$fpp=fopen("data/pattern.xml", "r");
				$fulldata=fread($fpp,filesize("data/pattern.xml")); 
				fclose($fpp);
			}
# ---------- get category
	#$menucatselect='<select size=\'1\' name=\'sendtags\'>'."\r\n";
foreach(file('./data/category.txt') as $item)
{$temp=explode('|',trim($item));
	if (time() >= $temp[2] || $sesia==true)
		{
		$simbol_simz='';
		for ($i=substr_count ($temp[0], '-'); $i>0;$i--) {$simbol_simz.=$simz;}
		$catmassiv[$temp[0]]=$temp[1];
		$catmassivdesc[$temp[0]]=$temp[1];
		if(isset($temp[3])){$catmassivdesc[$temp[0]]=$temp[3];}
			$menucatselect.='<option value=\''.$temp[0].'\'>'.$temp[1].'</option>'."\r\n";
			$menucattape.='<a href=\''.$server.'tape_'.$temp[0].'_0.html\'>'.$temp[1].'</a>'."\r\n";
			$menucatdir.='<a href=\''.$server.'dir_'.$temp[0].'.html\'>'.$temp[1].'</a>'."\r\n";
			$pattern_list.='<li>'.$simbol_simz.$simz_dir.'<a href=\''.$server.'dir_'.$temp[0].'.html\'>'.$temp[1].'</a></li>'."\r\n";
			$pattern_lenta.='<li>'.$simbol_simz.$simz_dir.'<a href=\''.$server.'tape_'.$temp[0].'_0.html\'>'.$temp[1].'</a></li>'."\r\n";
		}
	
}
	#$menucatselect.='</select>'."\r\n";
# ---------- get datafile	
if (file_exists($basepatch.'data.xml')) 
{
	$xml = simplexml_load_file($basepatch.'data.xml');
} else {exit('Failed to open data.xml.');}
# ------------ get cloud
if (file_exists('data/cloud.txt'))
	{
		$fpp=fopen('data/cloud.txt', 'r');
		$cloud='<i>'.fread($fpp,filesize('data/cloud.txt')).'</i>'; 
		fclose($fpp);
	}
# ------------ get cloud links
if (file_exists('data/cloud_link.txt'))
	{
		$fpp=fopen('data/cloud_link.txt', 'r');
		$cloud_link = explode("\n",trim(fread($fpp,filesize('data/cloud_link.txt')))); 
		foreach ($cloud_link as $item)
			{
			$temp = explode('|', trim($item));
			$cloud_link_mass["$temp[0]"]=$temp[1];
			}
		fclose($fpp);
	}
# ------------ get checkbox
if (file_exists('data/checked.txt'))
	{
		$checkbox_form=''; $checkbox_mass=array();
		$fpp=fopen('data/checked.txt', 'r');
		$checkbox=explode("\n", fread($fpp,filesize('data/checked.txt'))); 
		foreach ($checkbox as $item)
			{
			$item=trim($item);
			if ($item!='')
				{
				$temp = explode ('|', $item);
				$checkbox_form.=' '.$temp[1].$temp[2];
				$checkbox_mass["$temp[0]"]=$temp[1];
				$menutagselect.='<option value=\''.$temp[0].'\'>'.$temp[1].'</option>'."\r\n";
				}
			}
		fclose($fpp);
	}
# ------------ get randzapis
if (file_exists('./data/randzapis.txt'))
	{
		$fpp=fopen('./data/randzapis.txt', 'r');
		$randzapis=fread($fpp,filesize('./data/randzapis.txt')); 
		fclose($fpp);
	}
# ------------ get archive
if (file_exists('data/archive.txt'))
	{
	$archive = '';
		$tempik = file ('data/archive.txt');
		foreach (file ('data/archive.txt') as $item)
			{
			$temp_pub = (time()>=strtotime(strip_tags ($item)))? true:false;
			if ($temp_pub==true || $sesia==true)
				{if ($time_en_to_ru) 
					{
					$temp_ar = strip_tags (trim($item));
					$item=str_replace($temp_ar, time_en_to_ru($temp_ar, $ling, 'en', $lang), $item); 
					}
				$archive.=$item;}
			}
	} 
# ----------------
# ---------------- SITEMAP
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='sitemap')
	{
		$temp = $xml->xpath('
		/articles/page/@id|
		/articles/page/@key|
		/articles/page/titl|
		/articles/page/desc|
		/articles/page/data');
		$i=count($temp);
		$y=$_GET['str']*$mapsize; 
		$telo.='<h2>'.$ling[$lang][41].'</h2>';
	for ($x=0, $z=0; $x<$i; $x++, $z++)
	{	
		$temp_pub = (time()>=strtotime($temp[$x+4]))? true:false;
		if($z>=$y && $z<$y+$mapsize && isset($temp[$x]) && ($temp_pub==true || $sesia==true))
		{

			if ($temp_pub==false) {$temp[$x+2].=' <font color=red>('.$ling[$lang][59].')</font> ';}
			else{$temp_map[]='<li><a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$temp[$x+2].'</a></li>'."\r\n";}# random
			
			$telo.='<h3><a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$temp[$x+2].'</a></h3><p>'.$temp[$x+3]."</p>\r\n"; $desc.=$temp[$x+2].'. ';
				# -- keywords
				$temptags = explode (';',$temp[$x+1]);
				foreach ($temptags as $item2)
					{
					if ($item2 != '')
						{
						$tempkey = explode ('-',$item2);
						$temp_tags [$tempkey[0]] = $tempkey [1];
						}
					}
		}
			$x=$x+4; 
					if($temp_pub==false && $sesia!=true){$z--;}
					if ($z==$y+$mapsize && $FULL_NUM_PAGES==false){break;}

	}
			$title.=$pref_sitemap;
				# -- may prefer keys handle
			if ($keygen=='yes'){
				foreach ($temp_tags as $item3)
					{	$keywords.=$item3.', ';}}
	$telo.='<center>';
	if ($_GET['str']>=1){$telo.='<a class=bord href=\'sitemap_'.($_GET['str']-1).'.html\'>'.$simb_left.'</a> ';}
		# -- Do page numbers
		if ($gen_num_str == 'yes')
			{
			$z = ceil($z/$mapsize)-1;
			for ($v=0; $v<=$z; $v++)
				{
				if ($_GET['str'] == $v)
					{$telo.='<a class=bord2 href=\'sitemap_'.$v.'.html\'>'.($v+1).'</a> ';}
				if ($_GET['str'] != $v)
					{$telo.='<a class=bord href=\'sitemap_'.$v.'.html\'>'.($v+1).'</a> ';}
				}
			}
	if ($z>$_GET['str']){$telo.='<a class=bord href=\'sitemap_'.($_GET['str']+1).'.html\'>'.$simb_right.'</a>';}
	$telo.='</center>';
	# -- likelink
	if ($likelink =='yes')
		{include 'data/likelink.php';}
	# -- querylink
	if ($querylink =='yes')
		{$telo.=get_query_link($ling[$lang], $sesia, $translit_popular, $keywords);}
	# -- random zapis --
	$time_randzapis = (file_exists('./data/randzapis.txt'))? filemtime('./data/randzapis.txt'):0;
	# echo "<pre>"; print_r ($temp_map); echo "</pre>";	
	if ($time_randzapis+$limit_randzapis <= time())
		{
			$temp_count  = count($temp_map)-1; #$i/4;
		$fff = fopen ('./data/randzapis.txt', 'w'); $temp_nom=array();
		for ($i=$q99q; $i>0; $i--)
			{
			$temp_rand = rand(0, $temp_count); 
			while (isset($temp_nom["$temp_rand"]))
				{
				$temp_rand = rand(0, $temp_count); 
				}
			$temp_nom["$temp_rand"]=true;
			fwrite ($fff, $temp_map["$temp_rand"]);
			}
		fclose ($fff);
		}
	}
}
# ----------------
# ---------------- DIR
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='dir' && $_GET['zapros']==true)
	{
	$temp_tags=array(); $temp_zapros=$_GET['zapros'];
	/*
	foreach(file('./data/category.txt') as $item)
	{
		if (strstr($item, $_GET['zapros'])!=false) {$tempik=explode('|', $item); $telo.='<h2>'.$tempik[1].'</h2>';}
	}
	*/
	$telo.='<h2>'.$catmassiv["$temp_zapros"]."</h2>\r\n<p>".$catmassivdesc["$temp_zapros"]."</p>\r\n";
	$desc.=strip_tags($catmassivdesc["$temp_zapros"]);
	//$catmassivdesc
		$temp = $xml->xpath('
		/articles/*[contains(@tags,\''.$_GET['zapros'].'\')]/@id|   
		/articles/*[contains(@tags,\''.$_GET['zapros'].'\')]/@key|
		/articles/*[contains(@tags,\''.$_GET['zapros'].'\')]/titl|
		/articles/*[contains(@tags,\''.$_GET['zapros'].'\')]/data');
/*
		/articles/page[@tags=\''.$_GET['zapros'].'\']/@id|
		/articles/page[@tags=\''.$_GET['zapros'].'\']/@key|
		/articles/page[@tags=\''.$_GET['zapros'].'\']/titl|
		/articles/page[@tags=\''.$_GET['zapros'].'\']/data');
*/
		$i=count($temp);
	for ($x=0, $z=0; $x<$i; $x++, $z++)
	{
		$temp_pub = (time()>=strtotime($temp[$x+3]))? true:false;
		if(isset($temp[$x]) && ($temp_pub==true || $sesia==true))
			{
			if($temp_pub==false)
				{$telo.='<font color=red>'.$ling[$lang][59].'</font> ';}
			$telo.='<a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$temp[$x+2].'</a><br>'."\r\n"; //$desc.=$temp[$x+2].' ';
			}
		$title.=$temp[$x+2].' '; 
			# -- keywords
			$temptags = explode (';',$temp[$x+1]);
			foreach ($temptags as $item2)
				{
				if ($item2 != '')
					{
					$tempkey = explode ('-',$item2);
					$temp_tags [$tempkey[0]] = $tempkey [1];
					}
				}
		$x=$x+3;
	}
	$title = $pref_list.$catmassiv[$_GET['zapros']];
	$desc = $catmassiv[$_GET['zapros']].': '.$desc;
	//$desc = $pref_list.$catmassiv[$_GET['zapros']].': '.$desc;
				# -- may prefer keys handle
			if ($keygen=='yes'){
				foreach ($temp_tags as $item3)
					{	$keywords.=$item3.', ';}}
			# -- likelink
	if ($likelink =='yes')
		{include 'data/likelink.php';}
	# -- querylink
	if ($querylink =='yes')
		{$telo.=get_query_link($ling[$lang], $sesia, $translit_popular, $keywords);}
	}
}
# ----------------
# ---------------- TAPE
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='tape' && $_GET['zapros']==true && $_GET['str']!==false)
	{
		$temp = $xml->xpath('
		/articles/*[contains(@tags,\''.$_GET['zapros'].'\')]/@id|   
		/articles/*[contains(@tags,\''.$_GET['zapros'].'\')]/@key|
		/articles/*[contains(@tags,\''.$_GET['zapros'].'\')]/titl|
		/articles/*[contains(@tags,\''.$_GET['zapros'].'\')]/desc|
		/articles/*[contains(@tags,\''.$_GET['zapros'].'\')]/author|
		/articles/*[contains(@tags,\''.$_GET['zapros'].'\')]/data|
		/articles/*[contains(@tags,\''.$_GET['zapros'].'\')]/anons');
/*
		/articles/page[@tags=\''.$_GET['zapros'].'\']/@id|
		/articles/page[@tags=\''.$_GET['zapros'].'\']/@key|
		/articles/page[@tags=\''.$_GET['zapros'].'\']/titl|
		/articles/page[@tags=\''.$_GET['zapros'].'\']/desc|
		/articles/page[@tags=\''.$_GET['zapros'].'\']/author|
		/articles/page[@tags=\''.$_GET['zapros'].'\']/data|
		/articles/page[@tags=\''.$_GET['zapros'].'\']/anons');
*/
	#	echo "<pre>"; print_r ($temp); echo "</pre>";
		$i=count($temp);
		$y=$_GET['str']*$tapesize;  $temp_tags=array();
		if(isset($temp[0]))
		{
	for ($x=0, $z=0; $x<$i; $x++, $z++)
	{
		$temp_pub = (time()>=strtotime($temp[$x+5]))? true:false;
		if($z>=$y && $z<$y+$tapesize && isset($temp[$x]) && ($temp_pub==true || $sesia==true))
		{
		if($temp_pub==false){$telo.='<h4><font color=red>'.$ling[$lang][59].'</font></h4>';}
			if ($unik_tape!='no') {$temp[$x+6]= unikanons ($temp[$x+6], $unik_tape); }
			$telo.='<h2><a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$temp[$x+2].'</a></h2>';
			if ($infopage=='yes')
			{
			$telo.=$ling[$lang][33].': <i class=dark><a href=author_'.str_replace(' ', '-', $temp[$x+4]).'_0.html>'.$temp[$x+4].'</a></i> '.$ling[$lang][57].': <i class=dark>'.time_en_to_ru($temp[$x+5], $ling, 'en', $lang).'</i>';
			}
			$telo.='<p>'.linkator (	$server, 
									$prefiks, 
									$ling, 
									$listsize, 
									$cloud_link_mass, 
									$temp[$x+6]).'&nbsp;<a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$ling[$lang][48].'</a></p>';
			$title.=$temp[$x+2].' '; $desc.=$temp[$x+3].' ';
			# -- keywords
			$temptags = explode (';',$temp[$x+1]);
			foreach ($temptags as $item2)
				{
				if ($item2 != '')
					{
					$tempkey = explode ('-',$item2);
					$temp_tags [$tempkey[0]] = $tempkey [1];
					}
				}
		}
			$x=$x+6;
		if($temp_pub==false && $sesia!=true){$z--;}
		if ($z==$y+$tapesize && $FULL_NUM_PAGES==false){break;}
	}
	$title = $pref_dirs.$catmassiv[$_GET['zapros']].': '.$title;
	$desc = $pref_dirs.$catmassiv[$_GET['zapros']].': '.$desc;
				# -- may prefer keys handle
			if ($keygen=='yes'){
				foreach ($temp_tags as $item3)
					{	$keywords.=$item3.', ';}}
	$telo.='<center>';
	if ($_GET['str']>=1){$telo.='<a class=bord href=\'tape_'.$_GET['zapros'].'_'.($_GET['str']-1).'.html\'>'.$simb_left.'</a> ';}
		# -- Do page numbers
		if ($gen_num_str == 'yes')
			{
			$z = ceil($z/$tapesize)-1;
			for ($v=0; $v<=$z; $v++)
				{
				if ($_GET['str'] == $v)
					{$telo.='<a class=bord2 href=\'tape_'.$_GET['zapros'].'_'.$v.'.html\'>'.($v+1).'</a> ';}
				if ($_GET['str'] != $v)
					{$telo.='<a class=bord href=\'tape_'.$_GET['zapros'].'_'.$v.'.html\'>'.($v+1).'</a> ';}
				}
			}
	if ($z>$_GET['str']){$telo.='<a class=bord href=\'tape_'.$_GET['zapros'].'_'.($_GET['str']+1).'.html\'>'.$simb_right.'</a>';}
	$telo.='</center>';
	# -- crosslink
	//if ($crosslink=='yes')
	//	{include 'data/getlist.php';}
		# -- likelink
	if ($likelink =='yes' && $startpage != $_GET['zapros'])
		{include 'data/likelink.php';}
	# -- querylink
	if ($querylink =='yes')
		{$telo.=get_query_link($ling[$lang], $sesia, $translit_popular, $keywords);}
		}
	}
}
# ----------------
# ---------------- TAGs 
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='key' && $_GET['zapros']==true && $_GET['str']!==false)
	{
		$temp = $xml->xpath('
		/articles/*[contains(@key,\''.$_GET['zapros'].'\')]/@id|
		/articles/*[contains(@key,\''.$_GET['zapros'].'\')]/@key|
		/articles/*[contains(@key,\''.$_GET['zapros'].'\')]/titl|
		/articles/*[contains(@key,\''.$_GET['zapros'].'\')]/desc|
		/articles/*[contains(@key,\''.$_GET['zapros'].'\')]/author|
		/articles/*[contains(@key,\''.$_GET['zapros'].'\')]/data|
		/articles/*[contains(@key,\''.$_GET['zapros'].'\')]/anons');
		$i=count($temp);
		$y=$_GET['str']*$serhsize; 
		if(isset($temp[0]))
		{
	for ($x=0, $z=0; $x<$i; $x++, $z++)
	{
		$temp_pub = (time()>=strtotime($temp[$x+5]))? true:false;
		if($z>=$y && $z<$y+$serhsize  && isset($temp[$x]) && ($temp_pub==true || $sesia==true))
		{
		if($temp_pub==false){$telo.='<h4><font color=red>'.$ling[$lang][59].'</font></h4>';}
			if ($unik_tags!='no') {$temp[$x+6]= unikanons ($temp[$x+6], $unik_tags); }
			$telo.='<h2><a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$temp[$x+2].'</a></h2>';
	if ($infopage=='yes')
			{
			$telo.=$ling[$lang][33].': <i class=dark><a href=author_'.str_replace(' ', '-', $temp[$x+4]).'_0.html>'.$temp[$x+4].'</a></i> '.$ling[$lang][57].': <i class=dark>'.time_en_to_ru($temp[$x+5], $ling, 'en', $lang).'</i>';
			}
			$telo.='<p>'.linkator (	$server, 
									$prefiks, 
									$ling, 
									$listsize, 
									$cloud_link_mass, 
									$temp[$x+6]).'&nbsp;<a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$ling[$lang][48].'</a></p>'."\r\n";
			$title.=$temp[$x+2].' '; $desc.=$temp[$x+3].' ';
			# -- keywords
			$temptags = explode (';',$temp[$x+1]);
			foreach ($temptags as $item2)
				{
				if ($item2 != '')
					{
					$tempkey = explode ('-',$item2);
					$temp_tags [$tempkey[0]] = $tempkey [1];
					}
				}
			# create title for tag
			$temp3 = explode (';', $temp[$x+1]);
			foreach ($temp3 as $item3)
				{
				if (strpos ($item3, $_GET['zapros']) !== false)
					{
					$temp_title=explode ('-', $item3);
					}
				}
			# --
		}
			$x=$x+6;
		if($temp_pub==false && $sesia!=true){$z--;}
		if ($z==$y+$serhsize && $FULL_NUM_PAGES==false){break;}
	}
	if (isset($temp_title[1])==true)
		{
		$title = $pref_tags.$temp_title[1].': '.$title;
		$desc = $pref_tags.$temp_title[1].': '.$desc;
		}
				# -- may prefer keys handle
			if ($keygen=='yes'){
				foreach ($temp_tags as $item3)
					{	$keywords.=$item3.', ';}}
	$telo.='<center>';
	if ($_GET['str']>0){$telo.='<a class=bord href=\'tags_'.$_GET['zapros'].'_'.($_GET['str']-1).'.html\'>'.$simb_left.'</a> ';}
		# -- Do page numbers
		if ($gen_num_str == 'yes')
			{
			$z = ceil($z/$serhsize)-1;
			for ($v=0; $v<=$z; $v++)
				{
				if ($_GET['str'] == $v)
					{$telo.='<a class=bord2 href=\'tags_'.$_GET['zapros'].'_'.$v.'.html\'>'.($v+1).'</a> ';}
				if ($_GET['str'] != $v)
					{$telo.='<a class=bord href=\'tags_'.$_GET['zapros'].'_'.$v.'.html\'>'.($v+1).'</a> ';}
				}
			}
	if ($z>$_GET['str']){$telo.='<a class=bord href=\'tags_'.$_GET['zapros'].'_'.($_GET['str']+1).'.html\'>'.$simb_right.'</a>';}
	$telo.='</center>';
		}
	# -- crosslink
	//if ($crosslink=='yes')
	//	{include 'data/getlist.php';}	
	if ($likelink =='yes' && $startpage != $_GET['zapros'])
		{include 'data/likelink.php';}
	# -- querylink
	if ($querylink =='yes')
		{$telo.=get_query_link($ling[$lang], $sesia, $translit_popular, $keywords);}
	}

}
# ----------------
# ---------------- RSS
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='rss')
	{
		$temp = $xml->xpath('
		/articles/page/@id|
		/articles/page/titl|
		/articles/page/desc|
		/articles/page/author|
		/articles/page/data|
		/articles/page/anons');
		$i=count($temp);
		$y=0; 
		if(isset($temp[0]))
		{
			for ($x=0, $z=0; $x<=$i; $x++, $z++)
			{
					$temp_pub = (time()>=strtotime($temp[$x+4]))? true:false;
				if($z>=$y && $z<$y+$all_size && isset($temp[$x]) && $temp_pub==true)
				{
					$telo.="
<item>
<title>".$temp[$x+1][0]."</title>
<link>".$server.$prefiks.''.$temp[$x].".html</link>
<description>".html_xml($temp[$x+5])."</description>
<author>".$temp[$x+3]."</author>
<pubDate>".$temp[$x+4]."</pubDate>
</item>";
					$title.=$temp[$x+1].' '; $desc.=$temp[$x+2].' ';
				}
					$x=$x+5;
				if($temp_pub==false){$z--;}
				if ($z==$y+$all_size){break;}
			}
		}
	}
}
# ----------------
# ---------------- SEARCH
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='search' && array_key_exists('str', $_GET)!==false)
	{$_GET['zapros']= str_replace('_', 	' ', $_GET['zapros']);
		$temp = $xml->xpath('
		/articles/*[contains(text,\''.$_GET['zapros'].'\')]/@id|
		/articles/*[contains(text,\''.$_GET['zapros'].'\')]/@key|
		/articles/*[contains(text,\''.$_GET['zapros'].'\')]/titl|
		/articles/*[contains(text,\''.$_GET['zapros'].'\')]/desc|
		/articles/*[contains(text,\''.$_GET['zapros'].'\')]/author|
		/articles/*[contains(text,\''.$_GET['zapros'].'\')]/data|
		/articles/*[contains(text,\''.$_GET['zapros'].'\')]/anons');
		$i=count($temp); 
		$y=$_GET['str']*$serhsize; 
	$title = $pref_search.$_GET['zapros'].': '.$title;
	$desc = $pref_search.$_GET['zapros'].': '.$desc;
		if(isset($temp[0]))
		{
	for ($x=0, $z=0; $x<$i; $x++, $z++)
	{
			$temp_pub = (time()>=strtotime($temp[$x+4]))? true:false;
		if($z>=$y && $z<$y+$serhsize  && isset($temp[$x]) && ($temp_pub==true || $sesia==true))
		{
		if($temp_pub==false){$telo.='<h4><font color=red>'.$ling[$lang][59].'</font></h4>';}
			if ($unik_search!='no') {$temp[$x+6]= unikanons ($temp[$x+6], $unik_search); }
			$telo.='<h2><a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$temp[$x+2].'</a></h2>';
			if ($infopage=='yes')
			{
			$telo.=$ling[$lang][33].': <i class=dark><a href=author_'.str_replace(' ', '-', $temp[$x+4]).'_0.html>'.$temp[$x+4].'</a></i> '.$ling[$lang][57].': <i class=dark>'.time_en_to_ru($temp[$x+5], $ling, 'en', $lang).'</i>';
			}
			$telo.='<p>'.linkator (	$server, 
									$prefiks, 
									$ling, 
									$listsize, 
									$cloud_link_mass, 
									$temp[$x+6]).'&nbsp;<a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$ling[$lang][48].'</a></p>'."\r\n";
			$title.=$temp[$x+2].' '; $desc.=$temp[$x+3].' ';
			# -- keywords
			$temptags = explode (';',$temp[$x+1]);
			foreach ($temptags as $item2)
				{
				if ($item2 != '')
					{
					$tempkey = explode ('-',$item2);
					$temp_tags [$tempkey[0]] = $tempkey [1];
					}
				}
		}
			$x=$x+6;
		if($temp_pub==false && $sesia!=true){$z--;}
		if ($z==$y+$serhsize && $FULL_NUM_PAGES==false){break;}
	}

				# -- may prefer keys handle
			if ($keygen=='yes'){
				foreach ($temp_tags as $item3)
					{	$keywords.=$item3.', ';}}
	$telo.='<center>';
	if ($_GET['str']>0){$telo.='<a class=bord href=\'index.php?event=search&zapros='.$_GET['zapros'].'&str='.($_GET['str']-1).'\'>'.$simb_left.'</a> ';}
		# -- Do page numbers
		if ($gen_num_str == 'yes')
			{
			$z = ceil($z/$serhsize)-1;
			for ($v=0; $v<=$z; $v++)
				{
				if ($_GET['str'] == $v)
					{$telo.='<a class=bord2 href=\'index.php?event=search&zapros='.$_GET['zapros'].'&str='.$v.'.html\'>'.($v+1).'</a> ';}
				if ($_GET['str'] != $v)
					{$telo.='<a class=bord href=\'index.php?event=search&zapros='.$_GET['zapros'].'&str='.$v.'.html\'>'.($v+1).'</a> ';}
				}
			}
	if ($z>$_GET['str']){$telo.='<a class=bord href=\'index.php?event=search&zapros='.$_GET['zapros'].'&str='.($_GET['str']+1).'\'>'.$simb_right.'</a>';}
	$telo.='</center>';
	# -- likelink
	if ($likelink =='yes')
		{include 'data/likelink.php';}
		}
		# nothing found
		else
		{
		$telo.=' <h2>'.$ling[$lang][61].'</h2> ';
		$telo.=' <a href='.$server.'>'.$ling[$lang][19].'</a> ';
		}
	}
}
# ----------------
# ---------------- POPULAR
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='popular' && array_key_exists('str', $_GET)!==false)
	{

	$zapros= str_replace('_', 	' ', $_GET['zapros']);
	if($translit_popular==true){$zapros= lat_ru($_GET['zapros'], 'lr', 'f');}
	else {$zapros=ucfirst($zapros);}
	$zapros= str_replace('-', 	' ', $zapros);
	$zapros= str_replace('+', 	' ', $zapros);	
	$title = $pref_pop.$zapros.': '.$title;
	$desc = $pref_pop.$zapros.': '.$desc;
	$temp_zapros = explode(' ', trim($zapros));
	//$temp_zapros = del_stop_slova($temp_zapros, $stopword);
	$page_mass = array();
	# --- generate list pages ---
	foreach ($temp_zapros as $item)
		{
		$temp = $xml->xpath('
		/articles/*[contains(text,\''.$item.'\')]/@id|
		/articles/*[contains(text,\''.$item.'\')]/data');
		if($temp)
			{
			//$tempik = array_chunk($temp, 2);
			foreach (array_chunk($temp, 2) as $item2)
				{
				$temp_pub = (time()>=strtotime($item2[1]))? true:false;
				if ($temp_pub)
					{
					if(!isset($page_mass["$item2[0]"])){$page_mass["$item2[0]"]=0;}
					$page_mass["$item2[0]"]++;
					}
				}
			}
		}
		arsort($page_mass); $page_mass=array_keys ($page_mass);

	# --- load pages ---
	$page_mass2 = array_chunk($page_mass, $popsize);
	if(isset($page_mass2[$_GET['str']]))
	{
	foreach ($page_mass2[$_GET['str']] as $item)
		{
		
$temp = $xml->xpath('
		/articles/page[@id=\''.$item.'\']/titl|
		/articles/page[@id=\''.$item.'\']/desc|
		/articles/page[@id=\''.$item.'\']/author|
		/articles/page[@id=\''.$item.'\']/data|
		/articles/page[@id=\''.$item.'\']/text');		
//echo '<pre>';print_r($temp);echo '</pre>';
$desc.=$temp[1].' '; $title.=$temp[0].' ';
$telo.='<h2><a href=\''.$prefiks.''.$item.'.html\'>'.$temp[0].'</a></h2>';
			if ($infopage=='yes')
			{
			
			$telo.=$ling[$lang][33].': <i class=dark><a href=author_'.str_replace(' ', '-', $temp[2]).'_0.html>'.$temp[2].'</a></i> '.$ling[$lang][57].': <i class=dark>'.time_en_to_ru($temp[3], $ling, 'en', $lang).'</i>';
			}
		$telo.='<p>'.get_page_core($temp_zapros, $temp[4], $sentence_in_query).'</p>';
		}
	}
	# navigation
	$telo.='<br><center>';
	if ($_GET['str']>0)
	{$telo.='<a class=bord href=\''.$_GET['zapros'].'_'.($_GET['str']-1).'.htm\'>'.$simb_left.'</a> ';}
	if (isset($page_mass2[$_GET['str']+1]))
	{$telo.='<a class=bord href=\''.$_GET['zapros'].'_'.($_GET['str']+1).'.htm\'>'.$simb_right.'</a> ';}
	$telo.='</center>';
		
		
		# search OK
		if(!isset($page_mass[0]))
		{
		$telo.=' <h2>'.$ling[$lang][61].'</h2> ';
		$telo.=' <a href='.$server.'>'.$ling[$lang][19].'</a> ';
		$title.=' '.$ling[$lang][19]; $desc.=' '.$ling[$lang][19];
		}		
	# -- likelink
	if ($likelink =='yes' && $startpage != $_GET['zapros'])
		{include 'data/likelink.php';}
	# -- querylink
	//if ($querylink =='yes')
	//	{$telo.=get_query_link($ling[$lang], $sesia, $translit_popular, $keywords);}
	}

}
# ----------------
# ---------------- Archive
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='archive' && $_GET['zapros']==true && $_GET['str']!==false)
	{
	$_GET['zapros']= str_replace('-', 	' ', $_GET['zapros']);
		$temp = $xml->xpath('
		/articles/*[contains(data,\''.$_GET['zapros'].'\')]/@id|
		/articles/*[contains(data,\''.$_GET['zapros'].'\')]/@key|
		/articles/*[contains(data,\''.$_GET['zapros'].'\')]/titl|
		/articles/*[contains(data,\''.$_GET['zapros'].'\')]/desc|
		/articles/*[contains(data,\''.$_GET['zapros'].'\')]/author|
		/articles/*[contains(data,\''.$_GET['zapros'].'\')]/data|
		/articles/*[contains(data,\''.$_GET['zapros'].'\')]/anons');
	$_GET['zapros']= str_replace(' ', 	'-', $_GET['zapros']);
		$i=count($temp); 
		$y=$_GET['str']*$archsize; 
		if(isset($temp[0]))
		{
	for ($x=0, $z=0; $x<$i; $x++, $z++)
	{
		$temp_pub = (time()>=strtotime($temp[$x+5]))? true:false;
		if($z>=$y && $z<$y+$archsize  && isset($temp[$x]) && ($temp_pub==true || $sesia==true))
		{
		if($temp_pub==false){$telo.='<h4><font color=red>'.$ling[$lang][59].'</font></h4>';}
			if ($unik_archive!='no') {$temp[$x+5]= unikanons ($temp[$x+6], $unik_archive); }
			$telo.='<h2><a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$temp[$x+2].'</a></h2>';
			if ($infopage=='yes')
			{
			$telo.=$ling[$lang][33].': <i class=dark><a href=author_'.str_replace(' ', '-', $temp[$x+4]).'_0.html>'.$temp[$x+4].'</a></i> '.$ling[$lang][57].': <i class=dark>'.time_en_to_ru($temp[$x+5], $ling, 'en', $lang).'</i>';
			}
			$telo.='<p>'.linkator (	$server, 
									$prefiks, 
									$ling, 
									$listsize, 
									$cloud_link_mass, 
									$temp[$x+6]).'&nbsp;<a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$ling[$lang][48].'</a></p>'."\r\n";
			$title.=$temp[$x+2].' '; $desc.=$temp[$x+3].' ';
			# -- keywords
			$temptags = explode (';',$temp[$x+1]);
			foreach ($temptags as $item2)
				{
				if ($item2 != '')
					{
					$tempkey = explode ('-',$item2);
					$temp_tags [$tempkey[0]] = $tempkey [1];
					}
				}
		}
			$x=$x+6;
		if($temp_pub==false && $sesia!=true){$z--;}
		if ($z==$y+$archsize && $FULL_NUM_PAGES==false){break;}
	}
	$title = $pref_archive.str_replace('-', ' ', $_GET['zapros']).': '.$title;
	$desc = $pref_archive.str_replace('_', 	' ', $_GET['zapros']).': '.$desc;
				# -- may prefer keys handle
			if ($keygen=='yes'){
				foreach ($temp_tags as $item3)
					{	$keywords.=$item3.', ';}}
	$telo.='<center>';
	if ($_GET['str']>0){$telo.='<a class=bord href=\'archive_'.$_GET['zapros'].'_'.($_GET['str']-1).'.html\'>'.$simb_left.'</a> ';}
		# -- Do page numbers
		if ($gen_num_str == 'yes')
			{
			$z = ceil($z/$archsize)-1;
			for ($v=0; $v<=$z; $v++)
				{
				if ($_GET['str'] == $v)
					{$telo.='<a class=bord2 href=\'archive_'.$_GET['zapros'].'_'.$v.'.html\'>'.($v+1).'</a> ';}
				if ($_GET['str'] != $v)
					{$telo.='<a class=bord href=\'archive_'.$_GET['zapros'].'_'.$v.'.html\'>'.($v+1).'</a> ';}
				}
			}
	if ($z>$_GET['str']){$telo.='<a class=bord href=\'archive_'.$_GET['zapros'].'_'.($_GET['str']+1).'.html\'>'.$simb_right.'</a>';}
	$telo.='</center>';
		}
		# -- likelink
	if ($likelink =='yes' && $startpage != $_GET['zapros'])
		{include 'data/likelink.php';}
	# -- querylink
	if ($querylink =='yes')
		{$telo.=get_query_link($ling[$lang], $sesia, $translit_popular, $keywords);}
	}
}
# ----------------
# ---------------- Author
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='author' && $_GET['zapros']==true && $_GET['str']!==false)
	{
	$_GET['zapros']= str_replace('-', 	' ', $_GET['zapros']);
	$_GET['zapros']= str_replace('_', 	' ', $_GET['zapros']);
		$temp = $xml->xpath('
		/articles/*[contains(author,\''.$_GET['zapros'].'\')]/@id|
		/articles/*[contains(author,\''.$_GET['zapros'].'\')]/@key|
		/articles/*[contains(author,\''.$_GET['zapros'].'\')]/titl|
		/articles/*[contains(author,\''.$_GET['zapros'].'\')]/desc|
		/articles/*[contains(author,\''.$_GET['zapros'].'\')]/author|
		/articles/*[contains(author,\''.$_GET['zapros'].'\')]/data|
		/articles/*[contains(author,\''.$_GET['zapros'].'\')]/anons');
	$_GET['zapros']= str_replace(' ', 	'_', $_GET['zapros']);
		$i=count($temp); 
		$y=$_GET['str']*$archsize; 
		if(isset($temp[0]))
		{
	for ($x=0, $z=0; $x<$i; $x++, $z++)
	{
		$temp_pub = (time()>=strtotime($temp[$x+5]))? true:false;
		if($z>=$y && $z<$y+$archsize  && isset($temp[$x]) && ($temp_pub==true || $sesia==true))
		{
		if($temp_pub==false){$telo.='<h4><font color=red>'.$ling[$lang][59].'</font></h4>';}
			if ($unik_archive!='no') {$temp[$x+5]= unikanons ($temp[$x+6], $unik_archive); }
			$telo.='<h2><a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$temp[$x+2].'</a></h2>';
			if ($infopage=='yes')
			{
			$telo.=$ling[$lang][33].': <i class=dark>'.$temp[$x+4].'</i> '.$ling[$lang][57].': <i class=dark>'.time_en_to_ru($temp[$x+5], $ling, 'en', $lang).'</i>';
			}
			$telo.='<p>'.linkator (	$server, 
									$prefiks, 
									$ling, 
									$listsize, 
									$cloud_link_mass, 
									$temp[$x+6]).'&nbsp;<a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$ling[$lang][48].'</a></p>'."\r\n";
			$title.=$temp[$x+2].' '; $desc.=$temp[$x+3].' ';
			# -- keywords
			$temptags = explode (';',$temp[$x+1]);
			foreach ($temptags as $item2)
				{
				if ($item2 != '')
					{
					$tempkey = explode ('-',$item2);
					$temp_tags [$tempkey[0]] = $tempkey [1];
					}
				}
		}
			$x=$x+6;
		if($temp_pub==false && $sesia!=true){$z--;}
		if ($z==$y+$archsize && $FULL_NUM_PAGES==false){break;}
	}
	$title = $pref_archive.str_replace('_', ' ', $_GET['zapros']).': '.$title;
	$desc = $pref_archive.str_replace('_', 	' ', $_GET['zapros']).': '.$desc;
				# -- may prefer keys handle
			if ($keygen=='yes'){
				foreach ($temp_tags as $item3)
					{	$keywords.=$item3.', ';}}
	$telo.='<center>';
	if ($_GET['str']>0){$telo.='<a class=bord href=\'author_'.$_GET['zapros'].'_'.($_GET['str']-1).'.html\'>'.$simb_left.'</a> ';}
		# -- Do page numbers
		if ($gen_num_str == 'yes')
			{
			$z = ceil($z/$archsize)-1;
			for ($v=0; $v<=$z; $v++)
				{
				if ($_GET['str'] == $v)
					{$telo.='<a class=bord2 href=\'author_'.$_GET['zapros'].'_'.$v.'.html\'>'.($v+1).'</a> ';}
				if ($_GET['str'] != $v)
					{$telo.='<a class=bord href=\'author_'.$_GET['zapros'].'_'.$v.'.html\'>'.($v+1).'</a> ';}
				}
			}
	if ($z>$_GET['str']){$telo.='<a class=bord href=\'author_'.$_GET['zapros'].'_'.($_GET['str']+1).'.html\'>'.$simb_right.'</a>';}
	$telo.='</center>';
		}
		# -- likelink
	if ($likelink =='yes' && $startpage != $_GET['zapros'])
		{include 'data/likelink.php';}
	# -- querylink
	if ($querylink =='yes')
		{$telo.=get_query_link($ling[$lang], $sesia, $translit_popular, $keywords);}
	}
}
# ----------------
# ---------------- ALL
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='all' && $_GET['str']!==false)
	{
		$temp = $xml->xpath('
		/articles/page/@id|
		/articles/page/@key|
		/articles/page/titl|
		/articles/page/desc|
		/articles/page/author|
		/articles/page/data|
		/articles/page/anons');
		$i=count($temp); $cc = 
		$y=$_GET['str']*$all_size;  
		if(isset($temp[0]))
		{
	for ($x=0, $z=0; $x<$i; $x++, $z++)
	{
			$temp_pub = (time()>=strtotime($temp[$x+5]))? true:false;
		if($z>=$y && $z<$y+$all_size && isset($temp[$x]) && ($temp_pub==true || $sesia==true))
		{
		if($temp_pub==false){$telo.='<h4><font color=red>'.$ling[$lang][59].'</font></h4>';}
			$telo.='<h2><a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$temp[$x+2].'</a></h2>';
			if ($infopage=='yes')
			{
			$telo.=$ling[$lang][33].': <i class=dark><a href=author_'.str_replace(' ', '-', $temp[$x+4]).'_0.html>'.$temp[$x+4].'</a></i> '.$ling[$lang][57].': <i class=dark>'.time_en_to_ru($temp[$x+5], $ling, 'en', $lang).'</i>';
			}
			$telo.='<p>'.linkator (	$server, 
									$prefiks, 
									$ling, 
									$listsize, 
									$cloud_link_mass, 
									$temp[$x+6]).'&nbsp;<a href=\''.$prefiks.''.$temp[$x].'.html\'>'.$ling[$lang][48].'</a></p>';
			$title.=$temp[$x+2].' '; $desc.=$temp[$x+3].' ';
			# -- keywords
			$temptags = explode (';',$temp[$x+1]);
			foreach ($temptags as $item2)
				{
				if ($item2 != '')
					{
					$tempkey = explode ('-',$item2);
					$temp_tags [$tempkey[0]] = $tempkey [1];
					}
				}
		}
			$x=$x+6;
		if($temp_pub==false && $sesia!=true){$z--;}
		if ($z==$y+$all_size && $FULL_NUM_PAGES==false){break;}
	}
				# -- may prefer keys handle
			if ($keygen=='yes'){
				foreach ($temp_tags as $item3)
					{	$keywords.=$item3.', ';}}
							
	$telo.='<center>';
	if ($_GET['str']>1){$telo.='<a class=bord href=\'all_'.($_GET['str']-1).'.html\'>'.$simb_left.'</a> ';$title = $title;}
	if ($_GET['str']==0){$title = $pref_home.$title;}
	if ($_GET['str']==1){$telo.="<a class=bord href=\"".$server."\">".$simb_left."</a> ";
	}
		# -- Do page numbers
		if ($gen_num_str == 'yes')
			{
			$z = ceil($z/$all_size)-1;
			for ($v=0; $v<=$z; $v++)
				{
				if ($_GET['str'] == $v)
					{
					if ($v==0)	{$telo.='<a class=bord2 href=\''.$server.'\'>'.($v+1).'</a> ';}
					else		{$telo.='<a class=bord2 href=\'all_'.$v.'.html\'>'.($v+1).'</a> ';}
					}
				if ($_GET['str'] != $v)
					{
					if ($v==0)	{$telo.='<a class=bord href=\''.$server.'\'>'.($v+1).'</a> ';}
					else		{$telo.='<a class=bord href=\'all_'.$v.'.html\'>'.($v+1).'</a> ';}
					}
				}
			}
	if ($z>$_GET['str']){$telo.='<a class=bord href=\'all_'.($_GET['str']+1).'.html\'>'.$simb_right.'</a>';}
	$telo.='</center>';
		}
	# -- crosslink
	//if ($crosslink=='yes')
	//	{include 'data/getlist.php';}
	# -- likelink
	if ($likelink =='yes')
		{include 'data/likelink.php';} 
	# -- querylink
	if ($querylink =='yes')
		{$telo.=get_query_link($ling[$lang], $sesia, $translit_popular, $keywords);}
	}
}
# ----------------
# ---------------- PAGE
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='page' && $_GET['zapros']==true)
	{
		$temp = $xml->xpath('
		/articles/page[@id=\''.$_GET['zapros'].'\']/@tags|
		/articles/page[@id=\''.$_GET['zapros'].'\']/@key|
		/articles/page[@id=\''.$_GET['zapros'].'\']/@comm|
		/articles/page[@id=\''.$_GET['zapros'].'\']/titl|
		/articles/page[@id=\''.$_GET['zapros'].'\']/desc|
		/articles/page[@id=\''.$_GET['zapros'].'\']/author|
		/articles/page[@id=\''.$_GET['zapros'].'\']/data|
		/articles/page[@id=\''.$_GET['zapros'].'\']/anons|
		/articles/page[@id=\''.$_GET['zapros'].'\']/text');
			$x=0;
	if(isset($temp[$x])) 
	{
		if(time()<strtotime($temp[$x+5])){$telo.='<h4><font color=red>'.$ling[$lang][59].'</font></h4>';}
		$telo.='<h2>'.$temp[$x+3].'</h2>';
		if ($time_en_to_ru) {$temp[$x+6]=time_en_to_ru($temp[$x+6], $ling, 'en', $lang);}
		if ($infopage=='yes' && ($temp[$x]!='slujebnaya' || $sesia==true))
		{
		//if ($temp[$x]=='slujebnaya'){$temp[$x+6]=date("d M Y");}
		$telo.=$ling[$lang][33].': <i class=dark><a href=author_'.str_replace(' ', '-', $temp[$x+5]).'_0.html>'.$temp[$x+5].'</a></i>	'.$ling[$lang][57].': <i class=dark>'.$temp[$x+6].'</i>';
		}
			
			if (file_exists('pic/'.$_GET['zapros'].'.jpg')==true) 
			{$telo.='<img align=right src=pic/'.$_GET['zapros'].'.jpg hspace=15 vspace=15>';}
			if (file_exists('pic/'.$_GET['zapros'].'.gif')==true) 
			{$telo.='<img align=right src=pic/'.$_GET['zapros'].'.gif hspace=15 vspace=15>';}
		# Editing by size on one page
		if($sentence_in_page>0)
			{
			$temp_sent1= explode ('. ', trim($temp[$x+8])); $temp_sent2='';
			$t_0=$_GET['str']*$sentence_in_page; # Offer Starter
			$t_1=$_GET['str']*$sentence_in_page+$sentence_in_page;
			$t_2=count($temp_sent1);
			for ($r=$t_0; $r<$t_1; $r++)
				{
				if ($r>=$t_2){break;}
				$temp_sent2.=$temp_sent1[$r].'. ';
				}
			$telo.='<p>'.linkator (	$server, 
									$prefiks, 
									$ling, 
									$listsize, 
									$cloud_link_mass, 
									$temp_sent2).'</p><center><br>';
				# page numbers for PAGES
				if ($_GET['str']>0 && $_GET['str']<=1)
					{$telo.='<a class=bord href=\''.$prefiks.$_GET['zapros'].'.html\'>'.$simb_left.'</a> '; 
					$title .= ' '.$_GET['str'].' ';}
				if ($_GET['str']>1)
					{$telo.='<a class=bord href=\'pages_'.$_GET['zapros'].'_'.($_GET['str']-1).'.html\'>'.$simb_left.'</a> '; 
					$title .= ' '.$_GET['str'].' ';}
				if ($_GET['str']<$t_2/$sentence_in_page-1)
					{$telo.='<a class=bord href=\'pages_'.$_GET['zapros'].'_'.($_GET['str']+1).'.html\'>'.$simb_right.'</a> '; 
					$title .= ' '.$_GET['str'].' ';}
			$telo.='<br></center>';
			}
		else {$telo.='<p>'.linkator (	$server, 
									$prefiks, 
									$ling, 
									$listsize, 
									$cloud_link_mass, 
									$temp[$x+8]).'</p>';} # usual format pages (without pagination)
		
		if ($sesia==true)
			{
				$adminpanel.=' <a href=index.php?event=delpage&zapros='.$_GET['zapros'].'>[Del page]</a> ';
				$adminpanel.=' <a href=index.php?event=edit&zapros='.$_GET['zapros'].'>[Edit page]</a> ';
			}
		$title.=$temp[$x+3]; $desc.=$temp[$x+4];
	}
	$pagetempcomm=$temp[$x+2];
	# -- add big text
	if(file_exists('data/bigtext/'.$_GET['zapros'].'.html')) {$telo.="<p>\r\n".file_get_contents('data/bigtext/'.$_GET['zapros'].'.html').'</p>';}
	# -- key
	$temp_tags = array ();
	if ($temp[$x+1]!=false)#  && $startpage != $_GET['zapros']
		{
		$telo.='<br>'.$ling[$lang][58].': ';
		$temptags = explode (';',$temp[$x+1]);
			foreach ($temptags as $item2)
			{
			if ($item2 != '')
				{
				$tempkey = explode ('-',$item2);
				$temp_tags [$tempkey[0]] = $tempkey [1];
				$telo.='<i class=white><a href=tags_'.$tempkey[0].'_0.html>'.$tempkey[1].'</a></i> ';
				if ($keygen=='yes'){
				$keywords.=$tempkey[1].', ';}
				}
			}
		}
	# -- crosslink
	//if ($crosslink =='yes')
	//	{include 'data/getlist.php';} 
	# -- likelink
	if ($likelink =='yes') #&& $startpage != $_GET['zapros']&& $contaktpage != $_GET['zapros'] 
		{include 'data/likelink.php';}
	# -- querylink
	if ($querylink =='yes')
		{$telo.=get_query_link($ling[$lang], $sesia, $translit_popular, $keywords);}
	# -- comment

	$fpp=@fopen('comment/'.$_GET['zapros'].'.txt', 'r');
	if($fpp!=false)
		{
		$telo.='<h3>'.$ling[$lang][11].'</h2>';
		$telo.=fread($fpp,filesize('comment/'.$_GET['zapros'].'.txt')); 
		fclose($fpp);
		}
	if ($pagetempcomm=='yes')# && $startpage != $_GET['zapros']
		{
			include 'data/formmail.php';
			$telo.=$komm;
		}	
	}
}
# ----------------
# ---------------- EDIT
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='edit' && $_GET['zapros']==true && $sesia==true)
	{
		$temp = $xml->xpath('
		/articles/page[@id=\''.$_GET['zapros'].'\']/@key|
		/articles/page[@id=\''.$_GET['zapros'].'\']/@tags|
		/articles/page[@id=\''.$_GET['zapros'].'\']/@comm|
		/articles/page[@id=\''.$_GET['zapros'].'\']/titl|
		/articles/page[@id=\''.$_GET['zapros'].'\']/desc|
		/articles/page[@id=\''.$_GET['zapros'].'\']/author|
		/articles/page[@id=\''.$_GET['zapros'].'\']/data|
		/articles/page[@id=\''.$_GET['zapros'].'\']/anons|
		/articles/page[@id=\''.$_GET['zapros'].'\']/text');
			$x=0;
	if(isset($temp[$x]))
	{
	$telo.='<h2>'.$temp[$x+3].'</h2>';
			$adminpanel.=' <a href=index.php?event=delpage&zapros='.$_GET['zapros'].'>[Del page]</a> ';
			# -- restores the old section --
			 $temp_address=trim($temp[$x]);
			 $menucatselect="<option value='".$temp_address."'>".$catmassiv[$temp_address].'</option>'."\r\n".$menucatselect;
			# -- restore to comments --
			 if ($temp[$x+2]=='yes')
				{$menucommentselect="<option value=\"yes\">".$ling[$lang][46]."</option>\r\n
				<option value=\"no\">".$ling[$lang][47]."</option>\r\n";}
			 else
			 	{$menucommentselect="<option value=\"no\">".$ling[$lang][47]."</option>\r\n
				<option value=\"yes\">".$ling[$lang][46]."</option>\r\n";}
			 $temp_for_checked = $temp[$x+1]; # checkbox
			include "data/formaddpage.php";
			$formadd=str_replace("rumba_id", 		$_GET['zapros'], $formadd);
			$formadd=str_replace("rumba_old_id", 	$_GET['zapros'], $formadd);
			$formadd=str_replace("rumba_key", 		$temp[$x+1], $formadd);
			$formadd=str_replace("rumba_titl", 		$temp[$x+3], $formadd);
			$formadd=str_replace("rumba_author", 	$temp[$x+5], $formadd);
			$formadd=str_replace("rumba_data",		$temp[$x+6], $formadd);
			$formadd=str_replace("rumba_desc", 		$temp[$x+4], $formadd);
			$formadd=str_replace("rumba_anons", 	$temp[$x+7], $formadd);
			$formadd=str_replace("rumba_text", 		$temp[$x+8], $formadd);
			$formadd=str_replace("add_page", 		'edit_page', $formadd);
			$telo.=$formadd;	

	$title.=$temp[$x+3]; $desc.=$temp[$x+4];}
	# for del comment
	$fpp=@fopen('comment/'.$_GET['zapros'].'.txt', 'r');
	if($fpp!=false)
		{fclose($fpp);
		$telo.='<h3>'.$ling[$lang][10].'</h2>';
		$telo.="\r\n<form class=form action=\"index.php\" method=\"post\">";
		$telo.="\r\n<select size=\"1\" name=\"senddelcomm\">";
		$temp=file('comment/'.$_GET['zapros'].'.txt'); 
		foreach ($temp as $item)
			{
			$tempik=explode ('<p>', $item);
			$telo.="<option value=\"$tempik[0]\">".$tempik[0]."</option>\r\n";
			}
		$telo.="</select>";
		$telo.="&nbsp;<input type=\"submit\" name=\"event\" value=\"del_comment\">
		<input type =\"hidden\" name=\"send_id\" value =\"".$_GET['zapros']."\"></form>";
		}
	}
}
# ----------------
# ---------------- LOG MENU
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='logmenu')
	{
	$telo='<h2>Log In</h2>';
	include 'data/formlogin.php';
	$telo.='';
		$title='Login';
		# -- likelink
	if ($likelink =='yes') #&& $startpage != $_GET['zapros']&& $contaktpage != $_GET['zapros'] 
		{include 'data/likelink.php';}
	}
}
# ----------------
# ---------------- LOG IN
# ----------------
	
if (array_key_exists('event', $_POST)!=false)
{
	if ($_POST['event']=='login' 
	&& $_POST['ses_id']==$_SESSION['real']
	&& ($colsnums.$_POST['sendkod']<=$_SESSION['post']+10 && $colsnums.$_POST['sendkod']>=$_SESSION['post']-10)
	&& $_POST['sendpass']==$adminpass
	&& $_POST['sendname']==$adminlogin)
	{
	$_SESSION[md5(getcwd())][session_id()]=md5 ($adminpass);
		$title='Login';
				$telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				$telo.=' <a href='.$server.'>'.$ling[$lang][61].'</a> ';
	}

	if ($_POST['event']=='login' 
	&& ($_POST['ses_id']!=$_SESSION['real']
	|| ($colsnums.$_POST['sendkod']>$_SESSION['post']+10 && $colsnums.$_POST['sendkod']<$_SESSION['post']-10)
	|| $_POST['sendpass']!=$adminpass
	|| $_POST['sendname']!=$adminlogin))
	{
		$title='Login';
				$telo.=' <h2>'.$ling[$lang][18].'</h2> ';
				$telo.=' <a href='.$server.'index.php?event=logmenu>'.$ling[$lang][18].'</a> ';
				sleep(3);
	}
}
# ----------------
# ---------------- LOG OUT
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='logout' && $sesia==true)
	{
	session_destroy();
	$adminpanel='';
		$title=$ling[$lang][23];
				$telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				$telo.=' <a href='.$server.'>'.$ling[$lang][61].'</a> ';
	}
}
# ----------------
# ---------------- ADD PAGE MENU
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='addpagemenu' && $sesia==true)
	{
	$telo='<h2>'.$ling[$lang][36].'</h2>'; $title=$ling[$lang][36];
			# -- comments --
			$menucommentselect="<option value=\"yes\">".$ling[$lang][46]."</option>\r\n
				<option value=\"no\">".$ling[$lang][47]."</option>\r\n";
	$temp_for_checked = 'rumba-Rumba'; # checkbox
	include "data/formaddpage.php";
	$formadd= str_replace ("rumba_key","rumba-Rumba;",$formadd);
	$formadd= str_replace ("rumba_data",$MyGMTtime, $formadd);
	$telo.=$formadd;	
	}
}
# ----------------
# ---------------- TAG MENU
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='tagmenu' && $sesia==true)
	{
	$telo='<h2>'.$ling[$lang][44].'</h2>'; $title=$ling[$lang][44];

	$telo.="<form class=form action=\"index.php\" method=\"post\">
	<h4>".$ling[$lang][52]."</h4>\r\n";
	$telo.='<select size=\'1\' name=\'sendtags\'>'."\r\n".$menutagselect."</select>";
	$telo.="<br>\r\n<input type=\"submit\" name=\"event\" value=\"del_tag\"><br>\r\n
	<h4>".$ling[$lang][66]."</h4>
	".$ling[$lang][30]." (Only letters!)<br>\r\n
	<input name=\"sendid\" type=\"text\"  size=\"20\" maxlength=\"1000\" value=\"newtag\"><br>\r\n
	".$ling[$lang][9]." (Only letters!)<br>\r\n
	<input name=\"sendname\" type=\"text\"  size=\"20\" maxlength=\"1000\" value=\"".$ling[$lang][66]."\"><br>\r\n
	<input type=\"submit\" name=\"event\" value=\"add_tag\">
	</form>";	
	}
}
# ----------------
# ---------------- ADD TAG
# ----------------
if (array_key_exists('event', $_POST)!==false)
{
	if ($_POST['event']=='add_tag' && $sesia==true)
	{
		$_POST['sendid'] = strtolower ($_POST['sendid']);
		$_POST['sendid'] = str_replace (' ', '', $_POST['sendid']);
		$_POST['sendid'] = str_replace ('-', '', $_POST['sendid']);
		$_POST['sendid'] = str_replace ('_', '', $_POST['sendid']);
	$title=$ling[$lang][40]; $temp='';
	$fpp = fopen('./data/checked.txt', 'a+');
	fwrite($fpp, $_POST['sendid'].'|'.$_POST['sendname'].'|<input name="sendtag_'.$_POST['sendid'].'" type="checkbox"  value="'.$_POST['sendid']."\">\r\n");
	fclose ($fpp);
				$telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				$telo.=' <a href='.$server.'index.php?event=tagmenu>'.$ling[$lang][61].'</a> ';
	}
}
# ----------------
# ---------------- DEL TAG
# ----------------
if (array_key_exists('event', $_POST)!==false)
{
	if ($_POST['event']=='del_tag' && $sesia==true)
	{
	$temp='';
	$fpp = fopen('./data/checked2.txt', 'w+');
	foreach(file('./data/checked.txt') as $item)
	{
		if (stristr($item, '"sendtag_'.$_POST['sendtags'].'"')!=true) {fwrite($fpp, $item);}
	}
	fclose ($fpp);
	unlink ('./data/checked.txt');
	@rename ('./data/checked2.txt', './data/checked.txt');
				$telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				$telo.=' <a href='.$server.'index.php?event=tagmenu>'.$ling[$lang][61].'</a> ';
	}
}
# ----------------
# ---------------- CATEGORY MENU
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='categorymenu' && $sesia==true)
	{
	$telo='<h2>'.$ling[$lang][29].'</h2>'; $title=$ling[$lang][29];
	$telo.="<form class=form action=\"index.php\" method=\"post\">
	<h4>".$ling[$lang][52]."</h4>\r\n";
	$telo.="<select size='1' name='sendtags'>\r\n".$menucatselect."</select>";
	$telo.="<br>\r\n<input type=\"submit\" name=\"event\" value=\"del_category\"><br><br><br>\r\n
	
	<h4>".$ling[$lang][60]."</h4>\r\n
	".$ling[$lang][70]."<br>\r\n
	<select size='1' name='sendtags2'>\r\n".$menucatselect."</select><br>\r\n
	".$ling[$lang][71]."? 
	<input name='sendsub' type='checkbox'  value='sub'><br>\r\n
	".$ling[$lang][30]."<br>\r\n
	<input name=\"sendid\" type=\"text\"  size=\"20\" maxlength=\"1000\" value=\"newcat\"><br>\r\n
	".$ling[$lang][9]."<br>\r\n
	<input name=\"sendname\" type=\"text\"  size=\"20\" maxlength=\"1000\" value=\"".$ling[$lang][60]."\"><br>\r\n
	".$ling[$lang][34]."<br>\r\n
	<textarea  name=\"senddesc\" rows=7 cols=50 wrap=\"on\">".$ling[$lang][35]."</textarea><br>\r\n
	<input type=\"submit\" name=\"event\" value=\"add_category\">
	</form>";	
	}
}
# ----------------
# ---------------- ADD CATEGORY
# ----------------
if (array_key_exists('event', $_POST)!==false)
{
	if ($_POST['event']=='add_category' && $sesia==true)
	{
	$title=$ling[$lang][40]; $temp='';
	$fpp = fopen('data/category2.txt', 'w');
	$_POST['senddesc'] = str_replace ("\r", ' ', $_POST['senddesc']);
	$_POST['senddesc'] = str_replace ("\n", '<br>', $_POST['senddesc']);
	//fwrite($fpp, $_POST['sendid'].'|'.$_POST['sendname'].'|'.time()."\r\n");
	foreach (file('data/category.txt') as $item)
		{
		fwrite($fpp, $item);
		if	(strpos($item, $_POST['sendtags2'].'|')!==false) 
			{
			if (isset($_POST['sendsub']))
				{
				$tempik = explode ("|", $item);
				$_POST['sendid']=$tempik[0].'-'.$_POST['sendid'];
				}
			fwrite($fpp, $_POST['sendid'].'|'.$_POST['sendname'].'|'.time().'|'.$_POST['senddesc']."\r\n");
			}
		}
	fclose ($fpp);
	unlink ('data/category.txt');
	rename ('data/category2.txt', 'data/category.txt');
				$telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				$telo.=' <a href='.$server.'index.php?event=categorymenu>'.$ling[$lang][61].'</a> ';
	}
}
# ----------------
# ---------------- DEL CATEGORY
# ----------------
if (array_key_exists('event', $_POST)!==false)
{
	if ($_POST['event']=='del_category' && $sesia==true)
	{//print $_POST['sendtags'];
	$temp='';
	$fpp = fopen('data/category2.txt', 'w+');
	foreach(file('./data/category.txt') as $item)
	{
		if (strpos($item, $_POST['sendtags'].'|')===false) {fwrite($fpp, $item);}
	}
	fclose ($fpp);
	unlink ('./data/category.txt');
	@rename ('./data/category2.txt', './data/category.txt');
				$telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				$telo.=' <a href='.$server.'index.php?event=categorymenu>'.$ling[$lang][61].'</a> ';
	}
}
# ----------------
# ---------------- DEL PAGE
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='delpage' && $sesia==true)
	{
	$f_new = fopen($basepatch.'data2.xml', 'w+'); $flag=true;
	foreach(file($basepatch.'data.xml') as $item2)
	{

		if (stristr($item2,'<page')!=false && strstr($item2, "id=\"".$_GET['zapros']."\"")!=false)
			{$flag=false;}

	if($flag==true){fwrite($f_new, $item2);}
		if (stristr($item2,'</page')!=false && $flag==false)
			{$flag=true;}
	}
	fclose($f_new);
	 unlink ($basepatch.'data.xml');
	 rename($basepatch.'data2.xml', $basepatch.'data.xml');
	 # -- set list links
	if ($crosslink=='yes')
		{include 'data/setlist.php';}

	set_cloud ($xml, $cloud_size);
	set_archive ($xml);
				$telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				$telo.=' <a href='.$server.'>'.$ling[$lang][61].'</a> ';
	}
}
# ----------------
# ---------------- EDIT PAGE
# ----------------
if (array_key_exists('event', $_POST)!==false)
{
	if ($_POST['event']=='edit_page' && $sesia==true)
	{
	# -- send PING --
	if(isset($_POST['sendping']))
		{
		$rezult_ping=send_ping ($ping_urls, 
					$server.$prefiks.trim($_POST['sendid']).'.html', 
					$_POST['sendtitl']);
		}
	$f_new = fopen($basepatch.'data2.xml', 'w+'); $flag=true; 
	$temp_post_checkbox_str='';
	foreach(file($basepatch.'data.xml') as $item2)
	{
		if (stristr($item2,'<page')!=false && strstr($item2, "id=\"".$_POST['send_old_id']."\"")!=false)
			{$flag=false; 
			
				foreach ($_POST as $key=>$itt)
					{
					$itt = htmlspecialchars ($itt);
					$_POST[$key] = str_replace("\\\\", 	"\\", $itt);
					$_POST[$key] = str_replace("\\'", 	"'", $_POST[$key]);
					$_POST[$key] = str_replace('\\', 	'', $_POST[$key]);
					if(strpos($key, 'sendtag_')!==false) # checkbox
						{
							$temp_post_checkbox_str.=$_POST[$key].'-'.$checkbox_mass["$_POST[$key]"].';';
						}
					}
			# after date
			$temp_senddata = date('D, d M Y H:i:s', strtotime($_POST['senddata'])+$_POST['sendlost']*24*3600);
				foreach(file('data/blank.txt') as $item)
				{
					$item= str_replace('rumbaid', 		$_POST['sendid'], $item);
					$item= str_replace('rumbatags', 	$_POST['sendtags'], $item);
					$item= str_replace('rumbakey',		$temp_post_checkbox_str, $item);#$_POST['sendkey']
					$item= str_replace('rumbacomm', 	$_POST['sendcomm'], $item);
					$item= str_replace('rumbatitl', 	$_POST['sendtitl'], $item);
					$item= str_replace('rumbadesc', 	$_POST['senddesc'], $item);
					$item= str_replace('rumbaauthor', 	$_POST['sendauthor'], $item);
					$item= str_replace('rumbaanons', 	$_POST['sendanons'], $item);
					$item= str_replace('rumbatext', 	$_POST['sendtext'], $item);
					$item= str_replace('rumbadata', 	$temp_senddata, $item);#date("Y-M-d") $MyGMTtime
					
					if (stristr($item,'<articles')!=true) {fwrite($f_new, $item);}
				}
			}

	if($flag==true){fwrite($f_new, $item2);}
		if (stristr($item2,'</page')!=false && $flag==false)
			{$flag=true;}
	}
	fclose($f_new);
	 unlink ($basepatch.'data.xml');
	 rename($basepatch.'data2.xml', $basepatch.'data.xml');
	 # -- set list links
	if ($crosslink=='yes')
		{include 'data/setlist.php';}
	set_cloud ($xml, $cloud_size);
	set_archive ($xml);
				$telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				$telo.=' <a href='.$server.$prefiks.''.$_POST['sendid'].'.html>'.$ling[$lang][61].'</a> <br><br>'.$rezult_ping;
	}
}
# ----------------
# ---------------- ADD PAGE !!!
# ----------------
if (array_key_exists('event', $_POST)!==false)
{
	if ($_POST['event']=='add_page' && $sesia==true)
	{
	$temp='';
	# -- send PING --
	if(isset($_POST['sendping']))
		{
		$rezult_ping=send_ping ($ping_urls, 
					$server.$prefiks.trim($_POST['sendid']).'.html', 
					$_POST['sendtitl']);
		}


	$f_new = fopen($basepatch.'data2.xml', 'w+');
	$temp_post_checkbox_str=''; 
	// add page in START or END base
	if ($_POST['add-end']=='end'){$who_in_blank='/articles>'; $name_add_blank = 'data/blank2.txt';}
	else{$who_in_blank='<articles'; $name_add_blank = 'data/blank.txt';}
	foreach(file($basepatch.'data.xml') as $item2)
	{
		if (stristr($item2, $who_in_blank)!=false)
			{
			
				foreach ($_POST as $key=>$itt)
					{
					$itt = htmlspecialchars ($itt);
					$_POST[$key] = str_replace("\\\\", 	"\\", $itt);
					$_POST[$key] = str_replace("\\'", 	"'", $_POST[$key]);
					$_POST[$key] = str_replace('\\', 	'', $_POST[$key]);
					if(strpos($key, 'sendtag_')!==false) # checkbox
						{
							$temp_post_checkbox_str.=$_POST[$key].'-'.$checkbox_mass["$_POST[$key]"].';';
						}
					}
			# after date
			$temp_senddata = date('D, d M Y H:i:s', strtotime($_POST['senddata'])+$_POST['sendlost']*24*3600);
				foreach(file($name_add_blank) as $item)
				{
					$item= str_replace('rumbaid', 		$_POST['sendid'], $item);
					$item= str_replace('rumbatags', 	$_POST['sendtags'], $item);
					$item= str_replace('rumbakey',		$temp_post_checkbox_str, $item);#$_POST['sendkey']
					$item= str_replace('rumbacomm', 	$_POST['sendcomm'], $item);
					$item= str_replace('rumbatitl', 	$_POST['sendtitl'], $item);
					$item= str_replace('rumbadesc', 	$_POST['senddesc'], $item);
					$item= str_replace('rumbaauthor', 	$_POST['sendauthor'], $item);
					$item= str_replace('rumbaanons', 	$_POST['sendanons'], $item);
					$item= str_replace('rumbatext', 	$_POST['sendtext'], $item);
					$item= str_replace('rumbadata', 	$temp_senddata, $item);#date("Y-M-d")$MyGMTtime
					fwrite($f_new, $item);
				}
			}
		else{fwrite($f_new, $item2);}
	}
	fclose($f_new);
	 rename($basepatch.'data.xml', $basepatch.'data3.xml');
	 rename($basepatch.'data2.xml', $basepatch.'data.xml');
	 unlink ($basepatch.'data3.xml');
	# -- set list links
	if ($crosslink=='yes')
		{include 'data/setlist.php';}
		
	set_cloud ($xml, $cloud_size);
	set_archive ($xml);

				$telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				$telo.=' <a href='.$server.$prefiks.''.$_POST['sendid'].'.html>'.$ling[$lang][61].'</a> <br><br>'.$rezult_ping;
	}
}
# ----------------
# ---------------- COMMENT
# ----------------
if (array_key_exists('event', $_POST)!==false)
{
	if ($_POST['event']=='comment' 
	&& (($colsnums.$_POST['kodreal']<=$_SESSION['post']+10 && $colsnums.$_POST['kodreal']>=$_SESSION['post']-10)
		|| $_POST['kodreal']==$adminpass)
	&& $_POST['ses_id']==$_SESSION['real'])
	{
	$telo='<h2>'.$ling[$lang][11].'</h2>'; 
	$telo.='<h4><a href='.$server.''.$prefiks.''.$_POST['whoho'].'.html>'.$ling[$lang][43].'</a></h4>';
	include 'data/comment.php';

	$telo.='';
	$title=$ling[$lang][11];
	}
	else if ($_POST['event']=='comment')
	{
			$title=$ling[$lang][11];
				$telo.=' <h2>'.$ling[$lang][11].'</h2> ';
				$telo.=' <a href='.$server.'>'.$ling[$lang][18].'</a> '; 
	}
}
# ----------------
# ---------------- DEL COMMENT
# ----------------
if (array_key_exists('event', $_POST)!==false)
{
	if ($_POST['event']=='del_comment' && $sesia==true)
	{
	$fpp=@fopen('comment/'.$_POST['send_id'].'.txt2', 'w');
	$temp=file('comment/'.$_POST['send_id'].'.txt'); 
		foreach ($temp as $item)
			{
			if (strstr ($item, $_POST['senddelcomm'])==false)
				{fwrite ($fpp, $item);}
			}
	fclose($fpp);
	copy ('comment/'.$_POST['send_id'].'.txt2', 'comment/'.$_POST['send_id'].'.txt');
	unlink ('comment/'.$_POST['send_id'].'.txt2');
	if (count ($temp)==1)
		{unlink ('comment/'.$_POST['send_id'].'.txt');}

	$telo.='<h2>'.$ling[$lang][11].'</h2>'; 
	$telo.='<h4><a href='.$server.''.$prefiks.''.$_POST['send_id'].'.html>'.$ling[$lang][49].'</a></h4>';
	$title=$ling[$lang][49];
	}
}
# ----------------
# ---------------- IMAGE LOAD
# ----------------
if (array_key_exists('event', $_POST)!==false)
{
	if ($_POST['event']=='load_img' && $sesia==true)
	{
	 #--- load --------
	 $pic_ex = array('.jpg', '.jpeg', '.gif', '.png');
	if
	($_FILES['addfile']['tmp_name']==true &&
		(
		   in_array(strrchr($_FILES['addfile']['tmp_name'], '.'), $pic_ex)==true 
		|| in_array(strrchr($_FILES['addfile']['name'], '.'), $pic_ex)==true
		)
	)
	{
				   copy($_FILES['addfile']['tmp_name'], "images/".$_FILES['addfile']['name']) or die("Could not copy $addfile");
				   $_GET['event']='imagemenu'; 
				   $telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				   $telo.=' <a href=index.php?event=imagemenu>'.$ling[$lang][61].'</a> ';
	}
	else{               
		$_GET['event']='imagemenu'; 
		$telo.=' <h2>'.$ling[$lang][18].'</h2> ';
		$telo.=' <a href=index.php?event=imagemenu>'.$ling[$lang][18].'</a> ';
		}
	}
}
# ----------------
# ---------------- IMAGE DEL
# ----------------
if (array_key_exists('event', $_POST)!==false)
{
	if ($_POST['event']=='delete_img' && $sesia==true)
	{
	 #--- del --------
	unlink($_POST['imgs']);
				   $_GET['event']='imagemenu';
				   $telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				   $telo.=' <a href=index.php?event=imagemenu>'.$ling[$lang][61].'</a> ';
	}
}
# ----------------
# ---------------- IMAGE MENU
# ----------------
if (array_key_exists('event', $_GET)!=false)
{
	if ($_GET['event']=='imagemenu' && $sesia==true)
	{
	$telo='<h2>'.$ling[$lang][51].'</h2>'; $title=$ling[$lang][51]; $temp='';
	include "data/images.php";
	$telo.=$core;
	}
}
# ----------------
# ---------------- OK
# ----------------
if (array_key_exists('event', $_POST)!==false)
{
	if ($_POST['event']=='ok')
	{
				   $telo.=' <h2>'.$ling[$lang][17].'</h2> ';
				   $telo.=' <a href='.$_POST['zapros'].'>'.$ling[$lang][61].'</a> ';
	}
}
# ----------------
# ----------------
# ----------------



# -- launch party scripts expansion
$dir = opendir ('./data/add/');
     while ($file = readdir ($dir))
     {
     if($file!="." && $file!=".." && $file!="")
        {
                      if(strpos($file,".html")==true)
						{
							$fpp=fopen('./data/add/'.$file, 'r');
							$temp=fread($fpp,filesize('./data/add/'.$file)); 
							fclose($fpp);
							$file= str_replace('.html', '', $file);
							$fulldata= str_replace('['.$file.']', $temp, $fulldata);
						}
                      if(strpos($file,".php")==true)
						{
							include_once './data/add/'.$file;
						}
         }
     }
closedir ($dir); //$dir = opendir ('./'); closedir ($dir);
# --- work with the template ----
$fulldata= str_replace("[adminmail]", $adminmail, $fulldata);
$fulldata= str_replace("[serverphp]", $server, $fulldata);
$fulldata= str_replace("[titlephp]", $title, $fulldata);
$fulldata= str_replace("[lastcomm]", $lastcomm, $fulldata);
$fulldata= str_replace("[list]", $pattern_list, $fulldata);
$fulldata= str_replace("[lenta]", $pattern_lenta, $fulldata);
$fulldata= str_replace("[cloud]", $cloud, $fulldata);
$fulldata= str_replace("[randzapis]", $randzapis, $fulldata);
$fulldata= str_replace("[archive]", $archive, $fulldata);
$fulldata= str_replace("[last_news_list]", $last_news_list, $fulldata);

if (array_key_exists('event', $_GET)==false) {$_GET['event'] = 'zero';}
	if ($_GET['event']!='rss')
		{
			$fulldata= str_replace("</TITLE>", "</title>\r\n<meta name=\"Generator\" content=\"Rumba XML http://rumbacms.com\" />", $fulldata);
			$fulldata= str_replace("</title>", "</title>\r\n<meta name=\"Generator\" content=\"Rumba XML http://rumbacms.com\" />", $fulldata);
			if($desc!='')
			{
				if (trim($keywords)!='' && $keygen=='yes')
				{$fulldata= str_replace("</title>", "</title>\r\n<meta name=\"keywords\" content=\"".trim($keywords)."\" />\r\n<meta name=\"description\" content=\"".trim($desc)."\" />", $fulldata);}
				else
				{$fulldata= str_replace("</title>", "</title>\r\n<meta name=\"description\" content=\"".trim($desc)."\" />", $fulldata);}
			}		
			$fulldata= str_replace("[telophp]", $adminpanel.xml_html("<br>\r\n".$telo_query."<br>\r\n".$telo), $fulldata);
		} else {
				$fulldata= str_replace("[descphp]", trim($desc), $fulldata);
				$fulldata= str_replace("[rsspage]", $rsspage, $fulldata);
				$fulldata= str_replace("[rsstime]", $rsstime, $fulldata);
					$telo= str_replace("", '', $telo);
					$fulldata= str_replace("[telophp]", $telo, $fulldata);
				}
# --- checking caching ---
if ($cashe > 0)
	{
	$temp = del_simb ($_SERVER['REQUEST_URI']);
	if (@filemtime ($cashepatch.$temp+$cashe) < time())
		{
		$fpp=fopen($cashepatch.$temp.'.html', 'w+');
		fwrite($fpp, $fulldata);
		fclose($fpp);
		}
	}
# -- OUT
print trim($fulldata);
if($_GET['event'] !="rss" && $sesia==true)
{print "<div align=\"center\">".abs(microtime()-$time1)."</div>";}
?> 
Return current item: Rumba XML