Просмотр файла game/fallout/lugaro_game.class.php

Размер файла: 2.67Kb
<?php
/*
=>Автор: Демидов Анатолий aka lugaro
=>ICQ: 2000882
=>E-mail: [email protected]
=>Сайт: http://wapNEW.ru
---------------------------------
Внимание! Распространять скрип без согласия автора ЗАПРЕЩЕННО!!!
*/

		class lugaro_game{
	function __construct($lugaro){
	$this->lugaro = $lugaro;	}

	function start(){
	$this->lugaro = str_replace("\0",' ', $this->lugaro);
	$this->lugaro = str_replace('../','',$this->lugaro);
	$this->lugaro = str_replace('./','',$this->lugaro);
	$this->lugaro = preg_replace("/[^0-9a-z\/]/i", "", $this->lugaro);
	$this->lugaro = preg_replace ("|^[\/]|si",'', $this->lugaro);
	$this->lugaro = preg_replace ("|[\/]$|si",'', $this->lugaro);
	$this->lugaro = file_exists("db_game/".$this->lugaro.".txt") ? $this->lugaro : false;
	return $this->lugaro;	}

	function no_br($str,$replace){ 
$str=preg_replace ("|[\r\n]+|si",$replace,$str);
return $str; 	}

	function text(){
$file = file("db_game/".$this->lugaro.".txt");
$count = count($file);
$t = 0;
$l = 0;
$off = 0;
$echo['txt']='';
	for($i=0; $i<$count; $i++){
$txt = $this->no_br($file[$i],'');
	if($txt == '[TEXT]'){
$i++;
$t = 1;	}
	if($txt == '[ACTIONS]'){
$i++;
$t=0;
$l = 1; 	}
	if($txt == '[IMAGE]'){
$t=0;
$l = 0; 	}
	if(($t == 1) && ($txt != '[TEXT]') && ($txt != '')){
$echo['txt'] .= $txt.'<br/>';	}


	if(($l == 1) && ($txt != '[ACTIONS]') && ($txt != '')){
	if($off==0){
$link_name[] = $txt;
$off = 1;
	}else{
$off = 0;
$link[] = $txt;	}	}
	if(($t == 0) && ($txt != '[IMAGE]') &&($l == 0) && ($txt != '')){
$echo['img'] = $txt;	}	}
$this->link = $link;
$this->link_name = $link_name;
$echo['txt'] = iconv("windows-1251", "UTF-8", $echo['txt']);
return $echo;	}

	function link(){
$count = count($this->link);
	for($i=0; $i<$count; $i++){
$txt = iconv("windows-1251", "UTF-8", $this->link_name[$i]);
$tx = str_replace('.txt','',$this->link[$i]);
$ext = strtolower(substr($this->link[$i], 1 + strrpos($this->link[$i], ".")));
	if($ext=='png'){
$txx = $this->lugaro;
	echo '<img src="img/atc.gif" alt=""/> <a href="game.php?mod='.$txx.'&amp;img='.$tx.'&amp;r='.rand(0,999).'&amp;">'.$txt.'</a><br/>';
	}else{
	echo '<img src="img/atc.gif" alt=""/> <a href="game.php?mod='.$tx.'&amp;r='.rand(0,999).'&amp;">'.$txt.'</a><br/>';
	}	}	}

	function xss($str){
	$str = str_replace("\0",' ', $str);
	$str = str_replace('../','',$str);
	$str = str_replace('./','',$str);
	$str = preg_replace("/[^0-9a-z\/\.]/i", "", $str);
	$str = preg_replace ("|^[\/]|si",'', $str);
	$str = preg_replace ("|[\/]$|si",'', $str);
	$str = file_exists("db_game/".$str) ? $str : false;
	return $str;	}	}
?>