Просмотр файла includes/wap/builder/page_import.php

Размер файла: 19.79Kb
<?php
$filename=stripslashes($HTTP_POST_VARS['name']);
$url=stripslashes($HTTP_POST_VARS['url']);

$fname=explode('.',$filename);
$name=$fname[0];
$ext=$fname[1];

if (($url!='')&&($filename!=''))
    {
	if (($ext!='wml')||(strlen(trim(strtr(strtr(trim($name),' ','^'),'0123456789-_abcdefghjiklmnopqrstuvwxyz','                                      ')))!=0)||(strlen($filename)>20))
		{
		for ($i=1;file_exists($userpath.$currentdir.'imp_page'.$i.'.wml');$i++);
		print $head.cyr2utf('<card id="main" title="Импорт страницы"><p>'.
		'<b>'.$filename.' - недопустимое имя или расширение файла</b> <br/> <br/>'.
		'URL:<br/>'.
		'<input name="url'.$nocache.'" type="text" title="URL" value="'.$url.'" maxlength="128"/><br/>'.
		'Сохранить как...:<br/>'.
		'<input name="name'.$nocache.'" type="text" title="Сохранить как..." value="imp_page'.$i.'.wml" maxlength="20"/><br/>'.
		'<anchor>Сохранить'.
		'<go href="?'.$id.'/pm/index/import/'.$nocache.'" method="post">'.
		'<postfield name="query" value="'.$id.'/pm/index/import/'.$nocache.'"/>'.
		'<postfield name="url" value="$(url'.$nocache.')"/>'.
		'<postfield name="name" value="$(name'.$nocache.')"/>'.
		'</go>'.
		'</anchor> <br/> <br/>'.
		'<a href="?'.$id.'/pm">Отменить</a> <br/>'.
		'</p></card></wml>');
		exit;
		}

    if ($query3!='') $nocache_=$query3+0;
    $fp = @fopen ($userpath."opeation.cache", "r");$testcache = trim(@fgets($fp, 10));@fclose ($fp);
    if ($nocache_!=$testcache)
        {
		if (file_exists($userpath.$currentdir.$filename) && ($query4!='rewrite'))
			{
			for ($i=1;file_exists($userpath.$currentdir.'imp_page'.$i.'.wml');$i++);
			print $head.cyr2utf('<card id="main" title="Импорт страницы"><p>'.
			'<b>Папка _UPLOAD_ уже содержит файл '.$filename.', заменить?</b><br/>'.
			'<anchor>Заменить'.
			'<go href="?'.$id.'/pm/index/import/'.$nocache.'/rewrite" method="post">'.
			'<postfield name="query" value="'.$id.'/pm/index/import/'.$nocache.'/rewrite"/>'.
			'<postfield name="url" value="$(url'.$nocache.')"/>'.
			'<postfield name="name" value="$(name'.$nocache.')"/>'.
			'</go>'.
			'</anchor> <br/> <br/>'.
			'URL:<br/>'.
			'<input name="url'.$nocache.'" type="text" title="URL" value="'.$url.'" maxlength="128"/><br/>'.
			'Сохранить как...:<br/>'.
			'<input name="name'.$nocache.'" type="text" title="Сохранить как..." value="imp_page'.$i.'.wml" maxlength="20"/><br/>'.
			'<anchor>Сохранить'.
			'<go href="?'.$id.'/pm/index/import/'.$nocache.'" method="post">'.
			'<postfield name="query" value="'.$id.'/pm/index/import/'.$nocache.'"/>'.
			'<postfield name="url" value="$(url'.$nocache.')"/>'.
			'<postfield name="name" value="$(name'.$nocache.')"/>'.
			'</go>'.
			'</anchor> <br/> <br/>'.
			'<a href="?'.$id.'/pm">Отменить</a> <br/>'.
			'</p></card></wml>');
			exit;
			}

		if ((!file_exists($userpath.$currentdir.$filename)) || (file_exists($userpath.$currentdir.$filename) && ($query4=='rewrite')))
			{
			@unlink($userpath.$currentdir.$filename);
            if (!($textpage=grabwml($url)))
				{
				print $head.cyr2utf('<card id="main" title="Импорт страницы"><p>'.
				'<b>Не могу открыть URL <u>'.$url.'</u></b> <br/> <br/>'.
				'URL:<br/>'.
				'<input name="url'.$nocache.'" type="text" title="URL" value="'.$url.'" maxlength="128"/><br/>'.
				'Сохранить как...:<br/>'.
				'<input name="name'.$nocache.'" type="text" title="Сохранить как..." value="'.$filename.'" maxlength="20"/><br/>'.
				'<anchor>Сохранить'.
				'<go href="?'.$id.'/pm/index/import/'.$nocache.'" method="post">'.
				'<postfield name="query" value="'.$id.'/pm/index/import/'.$nocache.'"/>'.
				'<postfield name="url" value="$(url'.$nocache.')"/>'.
				'<postfield name="name" value="$(name'.$nocache.')"/>'.
				'</go>'.
				'</anchor> <br/> <br/>'.
				'<a href="?'.$id.'/import">Отменить</a> <br/>'.
				'</p></card></wml>');
				exit;
				}
			$fp = fopen ($userpath.$currentdir.$filename, "w+");fwrite ($fp, $textpage);fclose ($fp);
			@chmod($userpath.$currentdir.$filename,0777);
			$fp = fopen ($userpath."opeation.cache", "w+");fwrite ($fp, $nocache_);fclose ($fp);
			}
		}

	$editfile=$query1=$name;
	$action=$query2='';
	include($wappath.'builder/page_menu.php');
	exit;
	}
else
	{
	for ($i=1;file_exists($userpath.$currentdir.'imp_page'.$i.'.wml');$i++);
   	print $head.cyr2utf('<card id="page" title="Импорт страниц"><p>'.
	'URL:<br/>'.
	'<input name="url'.$nocache.'" type="text" title="URL" value="http://" maxlength="128"/><br/>'.
	'Сохранить как...:<br/>'.
	'<input name="name'.$nocache.'" type="text" title="Сохранить как..." value="imp_page'.$i.'.wml" maxlength="20"/><br/>'.
	'<anchor>Сохранить'.
	'<go href="?'.$id.'/pm/index/import/'.$nocache.'" method="post">'.
	'<postfield name="query" value="'.$id.'/pm/index/import/'.$nocache.'"/>'.
	'<postfield name="url" value="$(url'.$nocache.')"/>'.
	'<postfield name="name" value="$(name'.$nocache.')"/>'.
	'</go>'.
	'</anchor> <br/>'.
	'<small>При экспортировании файл будет преобразован в вид, поддерживаемый конструктором. Возможна потеря некоторых элементов. Также будут удалены все известные счетчики и реклама.</small> <br/>'.
	'<a href="?'.$id.'/pm">Отмена</a>'.
	'</p></card></wml>');
    exit;
	}


function grabwml($graburl)
{
# Читаем файл
if ($f=@fopen($graburl,'r'))
	{
	$text='';
	while ((!feof($f))&&(strlen($text)<16384)) {$text.=fread($f,256);}
	fclose($f);
	}
else
	{
	return false;
	}

# Убираем пролог и антикеш
$text=preg_replace("|<\?xml.*\?>|","",$text);
$text=preg_replace("|<!DOCTYPE[^>]+>|","",$text);
$text=preg_replace("|<!--[^>]*-->|","",$text);
#$text=preg_replace("|<head>[^<]+</head>|","",$text);
$text=preg_replace("|<head.*head>|","",$text);
$text=str_replace('&nbsp;',' ',$text);

# Убираем спецсимволы
$text=str_replace("\t"," ",$text);
$text=str_replace("\r"," ",$text);
$text=str_replace('\n\n\n\n','\n',$text);
$text=str_replace('\n\n\n','\n',$text);
$text=str_replace('\n\n','\n',$text);
$text=str_replace("\n","_break_point_",$text);
# Убираем двойные пробелы
$text=str_replace('     ',' ',$text);
$text=str_replace('    ',' ',$text);
$text=str_replace('   ',' ',$text);
$text=str_replace('  ',' ',$text);

$text=preg_replace("|>[\s]*_break_point_|",">",$text);
$text=preg_replace("|_break_point_[\s]*<|","<",$text);
$text=str_replace("_break_point_","\n",$text);

# Разделяем теги
$text=str_replace(">",">\n",$text);
$text=str_replace("<","\n<",$text);

# Убираем начало деки
$text=str_replace('<wml>','',$text);
# Преобразуем старые теги
$text=str_replace('<strong>',"<b>",$text);
$text=str_replace('</strong>',"</b>",$text);
$text=str_replace('<em>',"<i>",$text);
$text=str_replace('</em>',"</i>",$text);
# Убираем двойные \n
$text=str_replace("\n\n\n\n","\n",$text);
$text=str_replace("\n\n\n","\n",$text);
$text=str_replace("\n\n","\n",$text);
# Собираем элементы
$text=str_replace("<small>\n","<small>",$text);
$text=str_replace("<big>\n","<big>",$text);
$text=str_replace("<b>\n","<b>",$text);
$text=str_replace("<i>\n","<i>",$text);
$text=str_replace("<u>\n","<u>",$text);

$text=str_replace("\n</small>","</small>",$text);
$text=str_replace("\n</big>","</big>",$text);
$text=str_replace("\n</b>","</b>",$text);
$text=str_replace("\n</i>","</i>",$text);
$text=str_replace("\n</u>","</u>",$text);

$text=str_replace("</p>\n<p",'</p><p',$text);

$text=preg_replace("|(<a [^>]+>)\n|","\\1",$text);
$text=str_replace("\n</a>","</a>",$text);

$text=preg_replace("|(<anchor[^>]*>)\n|","\\1",$text);
$text=str_replace("\n</anchor>","</anchor>",$text);

$text=preg_replace("|(<do [^>]+>)\n|","\\1",$text);
$text=str_replace("\n</do>","</do>",$text);

$text=preg_replace("|(<go [^>]+>)\n|","\\1",$text);
$text=preg_replace("|\n(<go [^>]+>)|","\\1",$text);
$text=str_replace("\n</go>","</go>",$text);
$text=str_replace("</go>\n","</go>",$text);

$text=preg_replace("|(<option [^>]+>)\n|","\\1",$text);
$text=preg_replace("|\n(<option [^>]+>)|","\\1",$text);
$text=str_replace("\n</option>","</option>",$text);
$text=str_replace("</option>\n","</option>",$text);

$text=preg_replace("|(<select [^>]+>)\n|","\\1",$text);
$text=str_replace("\n</select>","</select>",$text);

$text=preg_replace("|(<postvar [^>]+>)\n|","\\1",$text);
$text=preg_replace("|\n(<postvar [^>]+>)|","\\1",$text);

$text=preg_replace("|(<setvar [^>]+>)\n|","\\1",$text);
$text=preg_replace("|\n(<setvar [^>]+>)|","\\1",$text);

$text=preg_replace("|(<prev[^>]*>)\n|","\\1",$text);
$text=preg_replace("|\n(<prev[^>]*>)|","\\1",$text);

$text=preg_replace("|(<refresh[^>]*>)\n|","\\1",$text);
$text=preg_replace("|\n(<refresh[^>]*>)|","\\1",$text);

# Собираем и удаляем конец деки
$text=preg_replace("[\s]*</p>[\s]*</card>[\s]*</wml>[\s]*|","",$text);

# Чистим начало и конец
$text=trim($text);

#die($text);

# Создаем массив для обработки
$tmp=explode("\n",$text);unset($text);
array($tmp_element);
array($tmp_softkey);
for ($i=0;$i<sizeof($tmp);$i++)
	{
	if (substr(trim($tmp[$i]),0,12)=='<!-- cnt -->') continue;
	if (substr(trim($tmp[$i]),0,10)=='<!-- * -->') continue;
	if (substr(trim($tmp[$i]),0,4)=='<do ') {$tmp_softkey[]=trim($tmp[$i]); continue;}
	if (trim($tmp[$i])!='') $tmp_element[]=trim($tmp[$i]);
	}
unset($tmp);
$tmp=$tmp_element;unset($tmp_element);array($tmp_element);

# Восстановление начала карты
if     ((substr(trim($tmp[0]),0,10)=='<card id="')&&(substr(trim($tmp[1]),0,2)=='<p')) {$tmp_element[]=trim($tmp[0]);$tmp_element[]=trim($tmp[1]);$tmp[0]=$tmp[1]='';}
elseif ((substr(trim($tmp[0]),0,10)=='<card id="')&&(substr(trim($tmp[1]),0,2)!='<p')) {$tmp_element[]=trim($tmp[0]);$tmp_element[]='<p align="center">';$tmp[0]='';}
elseif  (substr(trim($tmp[0]),0,2 )=='<p')                                             {$tmp_element[]='<card id="card0" title="Page"><do name="back" type="options" label="Назад"><prev/></do>';$tmp_element[]=trim($tmp[0]);$tmp[0]='';}
elseif ((substr(trim($tmp[0]),0,10)!='<card id="')&&(substr(trim($tmp[1]),0,2)=='<p')) {$tmp_element[]='<card id="card0" title="Page"><do name="back" type="options" label="Назад"><prev/></do>';$tmp_element[]=trim($tmp[1]);$tmp[0]=$tmp[1]='';}
elseif ((substr(trim($tmp[0]),0,10)!='<card id="')&&(substr(trim($tmp[1]),0,2)!='<p')) {$tmp_element[]='<card id="card0" title="Page"><do name="back" type="options" label="Назад"><prev/></do>';$tmp_element[]='<p align="center">';}
for ($i=0;$i<sizeof($tmp);$i++)
	{
	if ((trim($tmp[$i]))=='') continue;
	$tmp_element[]=trim($tmp[$i]);
	}
$tmp=$tmp_element;unset($tmp_element);array($tmp_element);

# Проверка правильности элементов
$tmp_element[]='<?xml version="1.0" encoding="Utf-8"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml12.dtd"><wml><head><meta forua="true" http-equiv="Cache-Control" content="max-age=0,proxy-revalidate,must-revalidate"/></head>';

for ($i=0;$i<sizeof($tmp);$i++)
	{
    if ($propusk) $i++;
    $propusk=false;
	$atr='';
	$stmp=$tmp[$i];
	if (strpos(' '.$stmp,'<i>'))          $atr.='.<i>';
	if (strpos(' '.$stmp,'<u>'))          $atr.='.<u>';
	if (strpos(' '.$stmp,'<b>'))          $atr.='.<b>';
	if (strpos(' '.$stmp,'<big>'))        $atr.='.<big>';
	if (strpos(' '.$stmp,'<small>'))      $atr.='.<small>';
	if (strpos(' '.$stmp,'</i>'))         $atr.='.<i>';
	if (strpos(' '.$stmp,'</u>'))         $atr.='.<u>';
	if (strpos(' '.$stmp,'</b>'))         $atr.='.<b>';
	if (strpos(' '.$stmp,'</big>'))       $atr.='.<big>';
	if (strpos(' '.$stmp,'</small>'))     $atr.='.<small>';
	if (strpos(' '.$stmp,'<br/>'))        $br='<br/>'; else $br='';
	$stmp=str_replace('<i>','',$stmp);    $stmp=str_replace('</i>','',$stmp);
	$stmp=str_replace('<u>','',$stmp);    $stmp=str_replace('</u>','',$stmp);
	$stmp=str_replace('<b>','',$stmp);    $stmp=str_replace('</b>','',$stmp);
	$stmp=str_replace('<big>','',$stmp);  $stmp=str_replace('</big>','',$stmp);
	$stmp=str_replace('<small>','',$stmp);$stmp=str_replace('</small>','',$stmp);
	$stmp=str_replace('<br/>','',$stmp);
	if ($i==0)
		{
        $stra=explode('title="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $title=$stra[0];
        $stra=explode('ontimer="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $url=$stra[0];
        $stra=explode('value="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $second=$stra[0]+0;
		if (($url!='')&&($second>0)) $redirect=' ontimer="'.$url.'"><timer value="'.$second.'"/>'; else $redirect='>';
		$tmp_element[]='<card id="card0" title="'.$title.'"'.$redirect.'<do name="back" type="options" label="Назад"><prev/></do>';
		for ($j=0;$j<sizeof($tmp_softkey);$j++)
			{
			$stra=explode('label="',$tmp_softkey[$j]);
			$stra=explode('"',$stra[1]);
			$caption=$stra[0];
			$stra=explode('href="',$tmp_softkey[$j]);
			$stra=explode('"',$stra[1]);
			$url=$stra[0];
			if (($caption!='')&&($url!=''))
				{
				$tmp_element[]='<do name="sk'.rand(1000,9999).'" type="options" label="'.$caption.'"><go href="'.$url.'"/></do>';
				}
			}
		}
	elseif ($i==1)
		{
        $stra=explode('align="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $algn=$stra[0];
        $stra=explode('mode="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $wrp=$stra[0];
        if ($algn=='center') $align='center';
        elseif ($algn=='right') $align='right';
        else $align='left';
        if ($wrp=='nowrap') $wrap=' mode="nowrap"';
        elseif ($wrp=='wrap') $wrap=' mode="wrap"';
        else $wrap='';
		$tmp_element[]='<p align="'.$align.'"'.$wrap.'>';
		$tmp_element[]='<!-- * -->';
		$tmp_element[]='<!-- Copy '.date('j.m G:i').' from '.htmlspecialchars($graburl).' -->';
		}
	elseif (substr($tmp[$i],0,6)=='</p><p')
		{
        $stra=explode('align="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $algn=$stra[0];
        $stra=explode('mode="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $wrp=$stra[0];
        if ($algn=='center') $align='center';
        elseif ($algn=='right') $align='right';
        else $align='left';
        if ($wrp=='nowrap') $wrap=' mode="nowrap"';
        elseif ($wrp=='wrap') $wrap=' mode="wrap"';
        else $wrap='';
		$tmp_element[]='</p><p align="'.$align.'"'.$wrap.'>';
		}
	elseif (substr($tmp[$i],0,3)=='<br')
		{
		$tmp_element[]='<br/>';
		}
	elseif (substr($stmp,0,3)=='<a ')
		{
        $stra=explode('">',$stmp);
        $strb=explode(' ',$stra[1]);
        if ($strb[0]=='<img')
            {
			$tmp[$i]=$stmp;
            $stra=explode('href="',$tmp[$i]);
            $stra=explode('"',$stra[1]);
            $link_=$stra[0];
            $stra=explode('<img src="',$tmp[$i]);
            $stra=explode('"',$stra[1]);
            $imgurl=$stra[0];
            $stra=explode(' alt="',$tmp[$i]);
            $stra=explode('"',$stra[1]);
            $alttext=$stra[0];
			if (($br=='')&&(trim($tmp[$i+1])=='<br/>')) {$propusk=true; $br='<br/>';}
            if (($imgurl!='')&&($link_!=''))
			if (!(strpos($imgurl,'top.wab.ru/count')||strpos($imgurl,'top.nash-kovcheg.ru')||strpos($imgurl,'oz.beeonglyuk.ru/rating')||strpos($imgurl,'wwap.ru/exban')||strpos($imgurl,'playfon')||strpos($imgurl,'cnt.kmx.ru')||strpos($link_,'bodr.net')||strpos($link_,'rating.samsungi')))
                {
                $tmp_element[]='<a href="'.$link_.'"><img src="'.$imgurl.'" alt="'.$alttext.'"/></a>'.$br;
				}
			}
		else
            {
			$tmp[$i]=$stmp;
            $stra=explode('href="',$tmp[$i]);
            $stra=explode('"',$stra[1]);
            $link_=$stra[0];
            $stra=explode('">',$tmp[$i]);
            $stra=explode('</a>',$stra[1]);
            $caption=$stra[0];
			if (($br=='')&&(trim($tmp[$i+1])=='<br/>')) {$propusk=true; $br='<br/>';}
            if (($caption!='')&&($link_!=''))
			if (!(strpos($link_,'playmobile')||strpos($link_,'mag.su/game')||strpos($link_,'mag.su/poly')||strpos($link_,'mag.su/java')||strpos($link_,'playfon')||strpos($link_,'javagames')||strpos($link_,'wapix')))
                {
				$tmp[$i]='<a href="'.$link_.'">'.$caption.'</a>';
		        if (strpos($atr,'<i>'))     $tmp[$i]='<i>'.$tmp[$i].'</i>';
				if (strpos($atr,'<u>'))     $tmp[$i]='<u>'.$tmp[$i].'</u>';
				if (strpos($atr,'<b>'))     $tmp[$i]='<b>'.$tmp[$i].'</b>';
				if (strpos($atr,'<big>'))   $tmp[$i]='<big>'.$tmp[$i].'</big>';
				if (strpos($atr,'<small>')) $tmp[$i]='<small>'.$tmp[$i].'</small>';
                $tmp_element[]=$tmp[$i].$br;
                }
			}
		}
	elseif (substr($tmp[$i],0,5)=='<img ')
		{
		$stra=explode('<img src="',$tmp[$i]);
		$stra=explode('"',$stra[1]);
		$imgurl=$stra[0];
		$stra=explode(' alt="',$tmp[$i]);
		$stra=explode('"',$stra[1]);
		$alttext=$stra[0];
		if ($imgurl!='')
			{
			if (($br=='')&&(trim($tmp[$i+1])=='<br/>')) {$propusk=true; $br='<br/>';}
			$tmp_element[]='<img src="'.$imgurl.'" alt="'.$alttext.'"/>'.$br;
			}
		}
	elseif (substr($tmp[$i],0,7)=='<input ')
		{
        $stra=explode('name="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $var_=$stra[0];
        $stra=explode('maxlength="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $size=$stra[0]+0;
		if ($size<1) $size='999';
        $stra=explode('value="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $def=$stra[0];
        $stra=explode('title="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $caption=$stra[0];
        $stra=explode('type="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        if ($stra[0]!='password') $type='text'; else $type='password';
		if ($var_!='')
			{
			if (($br=='')&&(trim($tmp[$i+1])=='<br/>')) {$propusk=true; $br='<br/>';}
			$tmp_element[]='<input name="'.$var_.'" type="'.$type.'" emptyok="true" title="'.$caption.'" maxlength="'.$size.'" value="'.$def.'"/>'.$br;
			}
		}
	elseif (substr($stmp,0,7)=='<anchor')
		{
		$tmp[$i]=$stmp;
        $stra=explode('href="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $url=$stra[0];
        $stra=explode('<anchor',$tmp[$i]);
        $stra=explode('>',$stra[1]);
        $stra=explode('<',$stra[1]);
        $caption=$stra[0];
        $stra=explode('method="',$tmp[$i]);
        $stra=explode('"',$stra[1]);
        $method=$stra[0];
		if (($url!='')&&($caption!=''))
			{
			$tmp[$i]='<anchor >'.$caption.'<go href="'.$url.'" method="'.$method.'"></go></anchor>';
			if (strpos($atr,'<i>'))     $tmp[$i]='<i>'.$tmp[$i].'</i>';
			if (strpos($atr,'<u>'))     $tmp[$i]='<u>'.$tmp[$i].'</u>';
			if (strpos($atr,'<b>'))     $tmp[$i]='<b>'.$tmp[$i].'</b>';
			if (strpos($atr,'<big>'))   $tmp[$i]='<big>'.$tmp[$i].'</big>';
			if (strpos($atr,'<small>')) $tmp[$i]='<small>'.$tmp[$i].'</small>';
			if (($br=='')&&(trim($tmp[$i+1])=='<br/>')) {$propusk=true; $br='<br/>';}
			$tmp_element[]=$tmp[$i].$br;
			}
		}
	elseif (substr($tmp[$i],0,7)=='<!--var')
		{
        $stra=explode('|',$tmp[$i]);
		if (($stra[1]!='')&&($stra[2]!=''))
			{
			$tmp_element[]='<!--var |'.$stra[1].'|'.$stra[2].'|-->';
			}
		}
	elseif (substr($tmp[$i],0,5)=='<!--r')
		{
        $str=substr($tmp[$i],9);
		if (($str!='') && !(strpos(strtolower($str),'<card') && ($currentdir.$editfile=='./index')))
			{
			$tmp_element[]='<!--r -->'.$str;
			}
		}
	elseif (strpos($stmp,'<')||strpos($stmp,'>'))
		{
		if ($tmp[$i]!='')
			{
			$tmp_element[]='<!--r -->'.$tmp[$i].$br;
			}
		}
	else
		{
		$tmp[$i]=$stmp;
		if (strpos($atr,'<i>'))     $tmp[$i]='<i>'.$tmp[$i].'</i>';
		if (strpos($atr,'<u>'))     $tmp[$i]='<u>'.$tmp[$i].'</u>';
		if (strpos($atr,'<b>'))     $tmp[$i]='<b>'.$tmp[$i].'</b>';
		if (strpos($atr,'<big>'))   $tmp[$i]='<big>'.$tmp[$i].'</big>';
		if (strpos($atr,'<small>')) $tmp[$i]='<small>'.$tmp[$i].'</small>';
		if ($tmp[$i]!='')
			{
			if (($br=='')&&(trim($tmp[$i+1])=='<br/>')) {$propusk=true; $br='<br/>';}
			$tmp_element[]=$tmp[$i].$br;
			}
		}
	}

$tmp_element[]='</p></card></wml>';

$rezult='';
for ($i=0;$i<sizeof($tmp_element);$i++) $rezult.=$tmp_element[$i]."\n";
return $rezult;
}

?>