Template processing error: template file "'.$f.'" doesn\'t exist!'); $c=join('',file($f)); $c=str_replace('$','$',$c); $c=tpl_strip_subs($c); if($p) $c=tpl_process($c); if($e) echo(str_replace('$','$',$c)); return str_replace('$','$',$c); } function tpl_block($s,$p=true,$e=false){ global $tpl_SUBS; $c=$tpl_SUBS[$s]; if($p) $c=tpl_process($c); if($e) echo($c); return $c; } function tpl_strip_subs($c){ global $tpl_SUBS,$tpl_SUBS_li,$tpl_SUBS_nli; if(!isset($tpl_SUBS)) $tpl_SUBS=Array(); while(preg_match('/% *SUB *([^% ]+) *%(.*)% *ENDSUB *\\1 *%/Ums',$c,$m)){ $m[2]=tpl_strip_subs($m[2]); $tpl_SUBS[$m[1]]=$m[2]; $c=str_replace($m[0],'%{'.$m[1].'()}%',$c); } if(!isset($tpl_SUBS_li)) $tpl_SUBS_li=Array(); while(preg_match('/% *IFL *%(.*)% *ENDIFL *%/Ums',$c,$m)){ $m[1]=tpl_strip_subs($m[1]); $tpl_SUBS_li[sizeof($tpl_SUBS_li)]=$m[1]; $c=str_replace($m[0],'%{tpl_ifli(0,'.(sizeof($tpl_SUBS_li)-1).')}%',$c); } if(!isset($tpl_SUBS_nli)) $tpl_SUBS_nli=Array(); while(preg_match('/% *IFNL *%(.*)% *ENDIFNL *%/Ums',$c,$m)){ $m[1]=tpl_strip_subs($m[1]); $tpl_SUBS_nli[sizeof($tpl_SUBS_nli)]=$m[1]; $c=str_replace($m[0],'%{tpl_ifli(1,'.(sizeof($tpl_SUBS_nli)-1).')}%',$c); } return $c; } function tpl_ifli($t,$n){ $t=$t?'n':''; global ${'tpl_SUBS_'.$t.'li'}; if(($t==''&&$_SESSION['uid'])||($t=='n'&&!$_SESSION['uid'])) return tpl_process(${'tpl_SUBS_'.$t.'li'}[$n]); else return ""; } function tpl_process($c){ global $_LANG; //VARIABLES before FUNCTIONS while(preg_match('/% *! *= *([^%]+) *%/',$c,$__m)){ $arn=preg_replace('/\[[^\]]*\]/Usmi','',$__m[1]); eval('global $'.$arn.'; $rv=$'.$__m[1].';'); $rv = str_replace('$','$',$rv); $c=preg_replace('/'.str_replace('/','\/',preg_quote($__m[0])).'/',tpl_process($rv),$c,1); } //FUNCTIONS ob_start(); while(preg_match('/% *\{ *([^\}]+) *\} *%/',$c,$m)){ $old=ob_get_contents(); ob_end_clean(); ob_start(); ${$m[1]} = str_replace('$','$',${$m[1]}); preg_match('/^([a-zA-Z0-9_]+)/',$m[1],$m1); if(function_exists($m1[1])) $c2=eval('return '.$m[1].';'); else $c2=''; $c1=ob_get_contents(); ob_end_clean(); $c=preg_replace( '/'.str_replace('/','\/',preg_quote($m[0])).'/', str_replace('$','$',tpl_process($c1)).str_replace('$','$',tpl_process($c2)), $c,1); ob_start(); echo($old); } ob_end_clean(); //IF ob_start(); while(preg_match('/% *IF *([^ ]+) *(\([^\) ]+\)) *%(.*)% *ENDIF *\\1%/Ums',$c,$m)){ $old=ob_get_contents(); ob_end_clean(); ob_start(); eval('$if_result = '.str_replace('$','$',$m[2]).';'); if($if_result) echo $m[3]; $c1=ob_get_contents(); ob_end_clean(); $c=preg_replace('/'.str_replace('/','\/',preg_quote($m[0])).'/',str_replace('$','$',tpl_process($c1)).str_replace('$','$',tpl_process($c2)),$c,1); ob_start(); echo($old); } ob_end_clean(); //VARIABLES after FUNCTIONS while(preg_match('/% *= *([^%]+) *%/',$c,$__m)){ $arn=preg_replace('/\[[^\]]*\]/Usmi','',$__m[1]); eval('global $'.$arn.'; $rv=$'.$__m[1].';'); $rv = str_replace('$','$',$rv); $c=preg_replace('/'.str_replace('/','\/',preg_quote($__m[0])).'/',tpl_process($rv),$c,1); } return $c; } function link_replace($matches){ global $i, $ar_link, $ar_rep; $ar_link[$i]=$matches[0]; $ar_rep[$i]='/%%link'.$i.'%%/'; return ' %%link'.$i++.'%% '; } function tag_replace($matches){ global $y, $ar_tag, $ar_tagrep; $ar_tag[$y]=$matches[0]; $ar_tagrep[$y]='/%%tag'.$y.'%%/'; return '%%tag'.$y++.'%%'; } function sendValidText($txt, $max_length, $length_criteria, $max_links=2){ $txt = strip_tags($txt, ""); if (!$txt) {print "not_txt";return;} unset($GLOBALS['ar_rep']);unset($GLOBALS['ar_link']);unset($GLOBALS['ar_tag']);unset($GLOBALS['ar_tagrep']); global $i,$y,$ar_rep, $ar_link,$ar_tag, $ar_tagrep; $i=$y=0; srand((double)microtime()*1000000); $end_frase=array ('.','?','!',';',':',')'); $ellipsis='...'; if ($length_criteria=='word') { $t=preg_replace_callback("/(]+>\s*)+([^()<>])*(?(1)\s*<\/a>)|((http|ftp|https|ftps|irc):\/\/[^()<>\s]+)/ims", "link_replace", $txt); $t=preg_replace_callback("/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/ims", "tag_replace", $t); //replace all tags with %%tag#%% $t=strip_tags($t); $t = str_replace("<", "<", str_replace(".", "&", $t)); $k=0; /////////////////trim by words $t=count($words = preg_split("/[\s\.,!\?:;\n\r]+/ims", ltrim($t), $max_length + 1)) > $max_length ? rtrim(substr($t, 0, strlen($t) - strlen(end($words)))) : $t; if (preg_match("/[\.?!;]/ims",$t)) { $k=strlen($t); while (!in_array($t[$k--],$end_frase)) ; $t=substr($t,0,$k+2); } elseif (!in_array($t[strlen($t)],$end_frase)) $t.=$ellipsis; ////////////////////////////// if (count($ar_tagrep)) $t=preg_replace($ar_tagrep,$ar_tag,$t); // input back all tags if (count($ar_rep)) $t=preg_replace($ar_rep, $ar_link, $t); // input back all lincks unset($GLOBALS['ar_rep']);unset($GLOBALS['ar_link']); $i=0; // reset variables // \/ \/ insert random link \/ \/ global $ar_rep, $ar_link; // reinitialize $t=preg_replace_callback("/(]+>\s*)+([^()<>])*(?(1)\s*<\/a>)|((http|ftp|https|ftps|irc):\/\/[^()<>\s]+)/ims", "link_replace", $t); for ($i=0;$i<(count($ar_rep)-$max_links);$i++){ $k=1; $k=1;$step=0; while ($k && $step([^<>\"])+]*>)(.*)(<\/\\2>)/ims", "tag_replace", $t); //ubiraem vse zakritie tagi $k=0; $t=strip_tags($t); $t = str_replace("<", "<", str_replace(".", "&", $t)); //esli tag naiden, stiraem vseo 4to posle nego if (count($ar_tagrep)>0) $t=preg_replace($ar_tagrep,$ar_tag,$t); //vozvrashaem zakrti tagi nazad $sgn= array (' ','.',',','?','!',';',')','/','\\','\n','>'); unset($GLOBALS['ar_tagrep']);unset($GLOBALS['ar_tag']); $i=0; // reset variables global $ar_tagrep, $ar_tag; $t=preg_replace_callback("/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/ims", "tag_replace", $t); if (preg_match("/[\.?!;:]/",$t)) { $k=strlen($t); while (!in_array($t[$k--],$end_frase) && $k>=0); $t=substr($t,0,$k+2); } if (($max_length-strlen($t))>=3) { if (substr($t,strlen($t),1) == '.') $t.=$ellipsis; else $t.="..."; } if (count($ar_tagrep)>0) $t=preg_replace($ar_tagrep, $ar_tag, $t); $t=preg_replace_callback("/(]+>\s*)+([^()<>])*(?(1)\s*<\/a>)|((http|ftp|https|ftps|irc):\/\/[^()<>\s]+)/ims", "link_replace", $t); for ($i=0;$i<(count($ar_rep)-$max_links);$i++){ $k=1;$step=0; while ($k && $step([^<>\"])+0) $t=preg_replace($ar_rep, $ar_link, $t); } $t = str_replace("&", ".", $t); return nl2br($t); } function news(){ $url = "http://www.simteevee.com/rss.php?f=1"; $file = file_get_contents($url); preg_match_all("!.*!imsU", $file, $m); foreach($m[0] as $item){ preg_match("!.*

(.*)

.*
!imsU", $item, $d); preg_match("!(.*)!imsU", $item, $l); preg_match("!!imsU", $item, $i); preg_match("!(.*)!imsU", $item, $t); $GLOBALS['description'] = $d[1]; // $GLOBALS['description'] = $d[1]; $GLOBALS['title'] = $t[1]; $GLOBALS['link'] = $l[1]; $GLOBALS['image'] = $i[1]; // if($_GET['short']) $GLOBALS['description'] = sendValidText($GLOBALS['description'], 50, 'char', 1); $GLOBALS['description'] = "
" . sendValidText($GLOBALS['description'], 78, 'char', 1) . "
"; tpl_block("news",1,1); } } tpl_load("rss_template.html",1,1); ?>