View file informer/index.php

File size: 4.27Kb
<?php // Wr-Informer v. 1.5 UTF-8 //  20.11.2018 г. // Miha-ingener@yandex.ru



error_reporting(0);
include "config-inf.php";
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';

echo "<title>Ближайшие праздники</title>";
$set['title']='Ближайшие праздники';
include_once '../sys/inc/thead.php';


aut();




function replacer($text)
{
    $text = str_replace("&#032;", ' ', $text);
    $text = str_replace(">", '&gt;', $text);
    $text = str_replace("<", '&lt;', $text);
    $text = str_replace("\"", '&quot;', $text);
    $text = preg_replace("/\n\n/", '<p>', $text);
    $text = preg_replace("/\n/", '<br>', $text);
    $text = preg_replace("/\\\$/", '&#036;', $text);
    $text = preg_replace("/\r/", '', $text);
    $text = preg_replace("/\\\/", '&#092;', $text);
    if (get_magic_quotes_gpc()) {
        $text = str_replace("&#092;&quot;", '&quot;', $text);
        $text = str_replace("&#092;'", '\'', $text);
        $text = str_replace("&#092;&#092;", '&#092;', $text);
    }
    $text = str_replace("\r\n", "<br> ", $text);
    $text = str_replace("\n\n", '<p> ', $text);
    $text = str_replace("\n", '<br> ', $text);
    $text = str_replace("\t", '', $text);
    $text = str_replace("\r", '', $text);
    $text = str_replace('   ', ' ', $text);
    return $text;
}
$msg = "";
$day = $date = date("d"); // день
$month = $date = date("m"); // месяц
$year = $date = date("Y"); // год
$vchera =  - 1;
$klvchasov = $klvdays * 24;
$lines = file($datafile);
$itogo = count($lines);
$i = 0;
$j = 0;
$records=null;
do {
    $dt = explode("|", $lines[$i]);
	$lines[$i] = replacer($lines[$i]);
    $todaydate = date("d.m.Y");
    $tekdt = time();
    $addmes = round($klvdays / 30);
    if ($dt[1] < $month and ($dt[1] - $addmes) < 0) $newyear = $year + 1; else $newyear = $year;
	$newdate = mktime(0, 0, 0, $dt[1], $dt[0], $newyear);
    $dayx = date("d.m.Y", $newdate); // конверируем дни до праздника в человеческий формат
    $hdate = ceil(($newdate - $tekdt) / 3600); // через сколько часов наступит событие
    $ddate = ceil($hdate / 24); // считаем сколько дней до события
    $dney = "дней";
    if ($ddate == "1") $dney = "день";
    if ($ddate == "2" or $ddate == "3" or $ddate == "4") $dney = "дня";
    $dt[2] = preg_replace("/([\s>\]]+)(http|https|ftp|goper):\/\/([a-zA-Z0-9\.\?&=\;\-\/_]+)([\W\s<\[]+)/", "\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>\\4", $dt[2]);
    if (($dt[0] == $vchera) and ($dt[1] == $month)) $msg .= "Вчера было: <strong>$dt[2]</strong><br>";
    if (($dt[0] == $day) and ($dt[1] == $month)) $msg .= "Сегодня: <strong>$dt[2]</strong><br>";
    if ($ddate == 1) $msg .= "Завтра: <strong>$dt[2]</strong><br>";
    if ($ddate > 1) { 
        if ($ddate < 10) $ddate = "0$ddate";
        if ($ddate < 100) $ddate = "0$ddate";
        $records[$j]="$ddate|$dney|$dayx|$dt[2]||";
        $j++;
    }
    $i++;
} while ($i < $itogo);

if (strlen($records[0]) > 1) {
    sort($records);
    reset($records);
	
    $msg .= "В ближайщее время ожидаются праздники:<br>";

    $i = 0;
    $itogo = count($records);
    if ($itogo > $klvmsg) $itogo = $klvmsg;
    do {
        $dt = explode("|", $records[$i]); // 5
        if ($klvdays > $dt[0]) $msg .= "через <b>" . number_format($dt[0]) . "</b> $dt[1] <b>$dt[3]</b> ($dt[2])<br>";
        $i++;
    } while ($i < $itogo);
echo '<table border=1 bordercolor=#EEEEEE cellpadding=5 cellspacing=1><tr><td>';
echo "$msg";
echo '</td></tr></table>';
} // if strlen($records[0])>1



	
	if (user_access('adm_panel_show'))
{
	?>
	<div class="err">
	<center><img src="/style/icons/adm.gif" alt="DS" /> <a href="admin.php">Админкa </center>
	<?
	include_once H.'plugins/admin/count.php';
	?>
	</div>
	<?
}



include_once '../sys/inc/tfoot.php';
?>