Hide by Day [DLE 9.x — 10.x]

Hide by Day [DLE 9.x — 10.x]

Название: Hide by Day
Автор: Gameer
CMS: DLE 9.x — 10.x
Описание:
С помощью этого хака вы сможете скрывать текст внутри тегов если пользователь зарегистрирован меньше указанного времени.
Установка :
 Для DLE 10.0 и Выше
Открыть /engine/classes/templates.class.php найти :

if (strpos ( $this->template, "[aviable=" ) !== false) {

Выше вставить:

if (strpos ( $this->template, "[show_user=" ) !== false) {
$this->template = preg_replace_callback ( "#\\[(show_user)=(.+?)\\](.*?)\\[/show_user\\]#is", array( &$this, 'show_user'), $this->template );
}

Далее найти :

if (strpos ( $template, "[aviable=" ) !== false) {

Выше вставить :

if (strpos ( $template, "[show_user=" ) !== false) {
$template = preg_replace_callback ( "#\\[(show_user)=(.+?)\\](.*?)\\[/show_user\\]#is", array( &$this, 'show_user'), $template );
}

Далее найти :

function check_module( $matches=array() ) {

Выше вставить :

function show_user( $matches=array() ) {
		global $member_id;
		$show_user = $matches[2]; $block = $matches[3];
		if(count(explode('|', $show_user)) > 1)
		{
			$show_user = explode('|', $show_user);
			$show_user[0] = (int)$show_user[0];
			$show_user[1] = trim(strip_tags(stripslashes($show_user[1])));
		}
		else
			$show_user = (int)$show_user;
		if ($matches[1] == "show_user") $action = true; else $action = false;
		$date = langdate("Y-m-d", $member_id['reg_date']);
		if( $action AND (int)$member_id['user_group'] != 5) {
			if((floor((strtotime(date('Y-m-d'))-strtotime($date))/(3600*24))) <= (!empty($show_user[0]) ? $show_user[0] : $show_user)) return !empty($show_user[1]) ? $show_user[1] : '';
			else return $block;
		} 
		else
			return !empty($show_user[1]) ? $show_user[1] : '';
	}


 Для DLE 9.8 и Ниже
Открыть /engine/classes/templates.class.php найти :

if (strpos ( $this->template, "[aviable=" ) !== false) {

Выше вставить:

if (strpos ( $this->template, "[show_user=" ) !== false) {
$this->template = preg_replace ( "#\\[show_user=(.+?)\\](.*?)\\[/show_user\\]#ies", "\$this->show_user('\\1', '\\2')", $this->template );
}

Далее найти :

if (strpos ( $template, "[aviable=" ) !== false) {

Выше вставить :

if (strpos ( $template, "[show_user=" ) !== false) {
$template = preg_replace ( "#\\[show_user=(.+?)\\](.*?)\\[/show_user\\]#ies", "\$this->show_user('\\1', '\\2')", $template );
}

Далее найти :

function check_module($aviable, $block, $action = true) {

Выше вставить :

function show_user( $show_user, $block, $action = true ) {
		global $member_id;
		if(count(explode('|', $show_user)) > 1)
		{
			$show_user = explode('|', $show_user);
			$show_user[0] = (int)$show_user[0];
			$show_user[1] = trim(strip_tags(stripslashes($show_user[1])));
		}
		else
			$show_user = (int)$show_user;
		$date = langdate("Y-m-d", $member_id['reg_date']);
		if( $action AND (int)$member_id['user_group'] != 5) {
			if((floor((strtotime(date('Y-m-d'))-strtotime($date))/(3600*24))) <= (!empty($show_user[0]) ? $show_user[0] : $show_user)) return !empty($show_user[1]) ? $show_user[1] : '';
			else return $block;
		} 
		else
			return !empty($show_user[1]) ? $show_user[1] : '';
	}


В любом tpl файле использовать тег [show_user=1] — где 1 сколько нужно быть зарегистрированным на сайте в днях. Так же можно сделать вывод почему нельзя видеть, просто прописав [show_user=25|Вы еще мало дней на сайте]текст[/show_user]
Выразите свою благодарность на WebMoney за бесплатную работу, кто сколько может

  1. R118095764291 — рубли
  2. U218134219019 — гривны
  3. Z228640084773 — доллары