Skip to content

n0wheremany/Request-Tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

Request-Tag

Мега хак: Работаем с глобальным массивом $_REQUEST

Установка

Открываем engine/classes/templates.class.php

ищем:

$this->copy_template = $this->template;
	
$this->template_parse_time += $this->get_real_time() - $time_before;

вставляем выше

	if( strpos( $this->template, "{request=" ) !== false or strpos( $this->template, "[request=" ) !== false ) {		
		preg_match_all("#[\\{\\[]request=['\"](.+?)['\"]#is",$this->template,$matchs,PREG_PATTERN_ORDER);
		$matchs = ((isset($matchs[1]) and is_array($matchs[1]))?$matchs[1]:array());
		$matchs = array_unique($matchs);
		foreach($matchs as $match){
			$xx = explode('=',$match);
			$vmatch = array(array_shift($xx),implode('=',$xx));
			$amatch = explode('->',$vmatch[0]);
			$value = $_REQUEST;
			foreach($amatch as $imatch)
				$value = (($value and isset($value[$imatch]))?$value[$imatch]:false);
			
			if((isset($vmatch[1]) and (is_array($value) and in_array($vmatch[1],$value) or $vmatch[1]==$value)) or (!isset($vmatch[1]) and $value)){
				$this->template = preg_replace ( "#\\{request=['\"]{$vmatch[0]}['\"]\\}#is", (is_array($value)?'array':$value), $this->template );
				$this->template = preg_replace ( "#\\[request=['\"]{$vmatch[0]}['\"]\\](.+?)\\[/request\\]#is", '\\1', $this->template );
				$this->template = preg_replace ( "#\\[request=['\"]{$vmatch[0]}={$vmatch[1]}['\"]\\](.+?)\\[/request\\]#is", '\\1', $this->template );
			} else {
				$this->template = preg_replace ( "#\\{request=['\"]{$vmatch[0]}['\"]\\}#is", '', $this->template );
				$this->template = preg_replace ( "#\\[request=['\"]{$vmatch[0]}['\"]\\](.+?)\\[/request\\]#is", '', $this->template );
				$this->template = preg_replace ( "#\\[request=['\"]{$vmatch[0]}={$vmatch[1]}['\"]\\](.+?)\\[/request\\]#is", '', $this->template );
			}
		}
	}
	if( strpos( $this->template, "{request}" ) !== false) {
		$this->template = str_replace('{request}', var_export($_REQUEST,true), $this->template );
	}

Уставнока завершена.

Использование

В любом шаблоне можно использовать: Для вывода глобального массива $_REQUEST: - debug тэг

{request}

Для получения данных из $_REQUEST Для вывода начения

{request="do"}

или для вывода из массива

{request="do->some"}

для проверки существования значения $_REQUEST[do][some]

[request="do->some"][/request]

для проверки значения $_REQUEST[do][some] == myvalue

[request="do->some=myvalue"][/request]

About

Мега хак: Работаем с запросом

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages