Cyber Anakins Lightsaber - A Minishell-based backdoor

Current Path : /home/bjb2293782/xn--80abaeoqbbrbgf8aea5a2a2z.xn--p1ai/docs/
Upload File :
Current File : /home/bjb2293782/xn--80abaeoqbbrbgf8aea5a2a2z.xn--p1ai/docs/filial.php

<?php
require("design.php");
require("contacts.php");

session_start();


$filial = _GET_('filial');

if ($filial == -1 ||! isset($GLOBALS['filials'])) die("Неверный номер филиала!");

TOP(2);


LEFTCOLUMN();
CHANNELS();
MAINCOLUMN();


if ($filial==14 && !(isset($_COOKIE['vi']) && $_COOKIE['vi']=="1" && isset($_COOKIE['viGamma']) && $_COOKIE['viGamma']!="0"))
{
	print "<style>.mainColumn { background-image:url('npr.jpg'); background-repeat:no-repeat; background-position:100% 0%; }</style>\n";
}
	

?>


<div class=path>
	<nobr><img src='c.png'><a href='filials.php'>Библиотеки</a></nobr>
	<nobr><img src='g.png'><b><?php print $GLOBALS['filials'][$filial]; ?></b></nobr>
</div>


<h1><?php print $GLOBALS['filials'][$filial]; ?></h1>

<center>
<span class=quick><a href='about.php?filial=<?php print $filial; ?>'><img src='info.png'><?php if ($filial!=100) print "О библиотеке"; else print "О ЦПТИ"; ?></a></span>

<?php
if ($filial==1)
{
?>
<span class=quick><a href='kuvaev.php'><img src='kuvaev-icon.png'>Об Олеге Куваеве</a></span>
<?php
}
else
if ($filial==4)
{
?>
<span class=quick><a href='zahoder.php'><img src='zahoder-icon.png'>О Борисе Заходере</a></span>
<?php
}
else
if ($filial==2)
{
?>
<span class=quick><a href='durilin.php'><img src='durilin-icon.png'>О Сергее Дурылине</a></span>
<?php
}
else
if ($filial==5)
{
?>
<span class=quick><a href='marshak.php'><img src='marshak-icon.png'>О Самуиле Маршаке</a></span>
<?php
}
?>



<span class=quick><a href='#' onclick='ahrefSmoothScroll("address"); return false'><img src='address.png'>Адрес и контакты</a></span>
</center>
<br>


<?php
if ($filial == 100)
{
?>

<center><img src='cpti.jpg' width=100% style='max-width:1280'></center>
<br>
<p>В соответствии с договором с Федеральным институтом промышленной собственности (ФИПС) с сентября 2022 года на базе Модельной библиотеки №14 открылся <b>Центр поддержки технологий и инноваций (ЦПТИ)</b>.</p>
<p>Основная цель работы ЦПТИ &#151; популяризация знаний в области интеллектуальной собственности.</p>
<p>В рамках заключенного договора ЦПТИ предоставляет доступ к патентным и непатентным базам данных ФИПС для проведения первичного патентного поиска, оказывает помощь в оформлении заявочных документов, а также проводит тематические мероприятия и консультации в соответствии с потребностями пользователей.</p>
<Br>
<br>
<hr>
<?php

//<span class=quick><a href='schoolpatent.php'><img src='info.png'>Международный детский конкурс «Школьный патент – шаг в будущее!»</a></span><br>
//<hr>
?>

<bR>

<?php
}
?>


<b>График работы:</b>
<?php
if (AdminAuth(RIGHT_EDIT_PROGRAMS, $filial))
{
	print "<script src='worktimeeditor.js'></script>\n";
	print "<img class=editBtn title='Редактировать расписание работы' src='edit.png' onclick='editWorktime($filial)'>";
}
?>

<br>
<?php
	function IsWorkDay($t, $holidays, $summerHolidays)
	{
		$tm = localtime($t,true);
		$weekDay = $tm['tm_wday'];
		$day = $tm['tm_mday'];
		$month = $tm['tm_mon']+1;
		$year=$tm['tm_year']+1900;

		if ($month>=6 && $month<=8) $holidays = $summerHolidays;

        if ($holidays!='')
        {
			$holidays = explode(',',$holidays);
			foreach($holidays as $w)
			{
				$w = intval($w);
				if ($weekDay==$w)
				{
					return false;
				}
			}
		}
		return true;
	}

	function IsSanitarDay($t, $holidays, $summerHolidays, $sanitarDay, $summerSanitarDay)
	{
		$tm = localtime($t,true);
		$day = $tm['tm_mday'];
		$month = $tm['tm_mon']+1;
		$year=$tm['tm_year']+1900;

		//print "[$day . $month . $year]";
		//$day = 28;
		//$month = 6;
		//$year = 2023;

		$leap = ($year % 4)==0;
		$daysPerMonths=array(0, 31,$leap ? 29:28, 31,30,31,30,31,31,30,31,30,31);

		if ($month>=6 && $month<=8)
		{
			$sanitarDay = $summerSanitarDay;
		}	


		if ($sanitarDay <= -8)
		{
			// последний рабочий день месяца
			for($d = $daysPerMonths[$month];$d>=1;$d--)
			{
				if (IsWorkDay(mktime(12,0,0,$month,$d,$year), $holidays, $summerHolidays))
				{
					if ($day == $d) return true;
					break;
				}
			}
		}
		else
		if ($sanitarDay >= 8)
		{
			// первый рабочий день месяца
			for($d = 1; $d <= $daysPerMonths[$month];$d++)
			{
				if (IsWorkDay(mktime(12,0,0,$month,$d,$year), $holidays, $summerHolidays))
				{
					if ($day == $d) return true;
					break;
				}
			}
		}
		else
		if ($sanitarDay<0)
		{
			// последний конкретный день недели каждого месяца
			if ($sanitarDay==-7) $sanitarDay=0;
			for($d = $daysPerMonths[$month];$d>=1;$d--)
			{
				$t = mktime(12,0,0,$month,$d,$year);
				$tm = localtime($t, true);
				if ($tm['tm_wday'] == -$sanitarDay)
				{
					//print("tm_wday=".$tm['tm_wday']." sd=$sanitarDay\n");

					if ($day == $d) return true;
					break;
				}
			}
		}
		else
		{
			// первый конкретный день недели каждого месяца
			if ($sanitarDay==7) $sanitarDay=0;
			for($d = 1; $d <= $daysPerMonths[$month];$d++)
			{
				$t = mktime(12,0,0,$month,$d,$year);
				$tm = localtime($t, true);
				if ($tm['tm_wday'] == $sanitarDay)
				{
					if ($day == $d) return true;
					break;
				}
			}
		}

		return false;
	}

	function IsSpecialDay($t, $specials)
	{
		reset($specials);
		foreach($specials as $special)
		{
				$dateStr = $special['date'];
				$timeStr = $special['time'];

				$sinceDate=0;
				$toDate=0;
				if (preg_match("/(\d+)\.(\d+)\.(\d+)\-(\d+)\.(\d+)\.(\d+)/", $dateStr, $g))
				{
					$sinceDate=mktime(0,0,0,$g[2],$g[1],$g[3]);
					$toDate=mktime(23,59,59,$g[5],$g[4],$g[6]);
				}
				else
				if (preg_match("/(\d+)\.(\d+)\.(\d+)/", $dateStr, $g))
				{
					$sinceDate=mktime(0,0,0,$g[2],$g[1],$g[3]);
					$toDate=$sinceDate+86400 - 1;
				}


				$sinceTime=0;
				$toTime=0;
				$reason='';

				if (preg_match("/(\d+)\:(\d+)\-(\d+):(\d+)/",$timeStr, $g))
				{
					$sinceTime=($g[1]*60+$g[2])*60;
					$toTime=($g[3]*60+$g[4])*60;
				}
				else
				if (preg_match("/N\:(.*)/",$timeStr, $g))
				{
					$reason = $g[1];
				}

				if ($t>=$sinceDate && $t<=$toDate)
				{
					return Array('reason'=>$reason, 'since'=>$sinceTime, 'to'=>$toTime);
				}
		}

		return false;
	}


	function printDayInfo($t, $regular, $summer, $specials)
	{
		$spec = IsSpecialDay($t, $specials);
		if ($spec!==false)
		{
			if ($spec['reason']!='')
			{
				print "<font class=redday><b>Закрыта.</b> ".$spec['reason']."</font>";
				return false;
			}
			else
			{
				$tm = localtime($t,true);
				$sec = $tm['tm_hour']*3600+$tm['tm_min']*60;


				if ($sec < $spec['since'] || $t > time())
				{
					$h = intval($spec['since'] / 3600);
					$m = ($spec['since']/60)%60;
					if (strlen($m)<2) $m="0$m";
                    
					print "<font class=greenday><b>Будет работать с $h:$m";

					$h = intval($spec['to'] / 3600);
					$m = ($spec['to']/60)%60;
					if (strlen($m)<2) $m="0$m";

					print " до $h:$m</b></font>";
					return true;
				}
				else
				if ($sec < $spec['to'])
				{
					$h = intval($spec['to'] / 3600);
					$m = ($spec['to']/60)%60;
					if (strlen($m)<2) $m="0$m";
					print "<font class=greenday><b>Открыта до $h:$m</b></font>";
					return true;
				}
				else
				{
					print "<font class=redday><b>Уже закрыта</b></font>";
					return false;
				}
			}
			return;
		}

		if (IsWorkDay($t,$regular['holidays'], $summer['holidays']))
		{
        	if (IsSanitarDay($t,$regular['holidays'], $summer['holidays'], $regular['sanitar'], $summer['sanitar']))
			{
				print "<font class=redday><b>Закрыта</b>. Санитарный день</font>";
				return false;
			}
			else
			{
				$tm = localtime($t,true);
				$month = $tm['tm_mon']+1;
				$sec = $tm['tm_hour']*3600+$tm['tm_min']*60;

				$since=0;
				$to=0;
				if ($month>=6 && $month<=8)
				{
					$since=$summer['since'];
					$to=$summer['to'];
				}
				else
				{
					$since=$regular['since'];
					$to=$regular['to'];
				}

				if (preg_match("/^(\d+)\:(\d+)/", $since,$g)) $since = $g[1]*3600+$g[2]*60; else $since=0;
				if (preg_match("/^(\d+)\:(\d+)/", $to,$g)) $to = $g[1]*3600+$g[2]*60; else $to=0;


				if ($sec < $since || $t > time())
				{
					$h = intval($since / 3600);
					$m = ($since/60)%60;
					if (strlen($m)<2) $m="0$m";

					print "<font class=greenday><b>Будет работать с $h:$m";
					
					$h = intval($to / 3600);
					$m = ($to/60)%60;
					if (strlen($m)<2) $m="0$m";
					print " до $h:$m</b></font>";
					return true;
				}
				else
				if ($sec < $to)
				{
					$h = intval($to / 3600);
					$m = ($to/60)%60;
					if (strlen($m)<2) $m="0$m";
					print "<font class=greenday><b>Открыта до $h:$m</b></font>";
					return true;
				}
				else
				{
					print "<font class=redday><b>Уже закрыта</b></font>";
					return false;
				}
			}
		}
		else
		{
			print "<font class=redday><b>Закрыта. Выходной день</b></font>";	
			return false;
		}
	}



	$info = array();
	$f = fopen("worktime/$filial.txt", "r");
	if ($f)
	{
		$section = '';
		while(!feof($f))
		{
			$line = fgets($f);
			if (preg_match("/\[(regular|summer|special)\]/",$line, $g))
			{
				$section=$g[1];
				$info[$section] = array();
			}
			else
			if ($line!='' && ($section=='regular' || $section=='summer'))
			{
				if (preg_match("/(.*)=(.*)/",$line,$g))
				{
					$info[$section][trim($g[1])]=trim($g[2]);
				}
			}
			else
			if ($line!='' && $section=='special')
			{
				if (preg_match("/(.*)=(.*)/",$line,$g))
				{
					array_push($info[$section], array('date'=>trim($g[1]),'time'=>trim($g[2])));
				}
			}
		}
		fclose($f);
	}


  if ($info['regular']['notworks']!=1)
  {
	$lastWeekDays = array("последнее воскресенье","последний понедельник","последний вторник","последняя среда","последний четверг","последняя пятница","последняя суббота","последнее воскресенье");
	$firstWeekDays = array("первое воскресенье","первый понедельник","первый вторник","первая среда","первый четверг","первая пятница","первая суббота","первое воскресенье");
	$weekDaysR = array("воскресенья","понедельника","вторника","среды","четверга","пятницы","субботы","воскресенья");
	
	
	print "С <b>".$info['regular']['since']."</b> до <b>".$info['regular']['to']."</b> каждый день";

	$holidays = $info['regular']['holidays'];
	if ($holidays!='')
	{
		print ", кроме ";
		$holidays = explode(",", $holidays);

		for($i=0; $i<count($holidays);$i++)
		{
			if ($i>0)
			{
				if ($i<=count($holidays)-1) print " и "; else print ", ";
			}
			print $weekDaysR[$holidays[$i]];
		}
	}	
	print "<br>\n";

	print "Санитарный день: ";
	if ($info['regular']['sanitar'] <=-8)
		print "Последний рабочий день месяца";
	else
	if ($info['regular']['sanitar'] >=8)
		print "Первый рабочий день месяца";
	else
	if ($info['regular']['sanitar'] < 0)
	{
		print $lastWeekDays[-$info['regular']['sanitar']]." месяца";
	}
	else
	{
		print $firstWeekDays[$info['regular']['sanitar']]." месяца";	
	}
	print "<br><br>";





	print "<b>В летний период с 1 июня по 31 августа:</b><br>";


	print "С <b>".$info['summer']['since']."</b> до <b>".$info['summer']['to']."</b> каждый день";

	$holidays = $info['summer']['holidays'];
	if ($holidays!='')
	{
		print ", кроме ";
		$holidays = explode(",", $holidays);

		for($i=0; $i<count($holidays);$i++)
		{
			if ($i>0)
			{
				if ($i<=count($holidays)-1) print " и "; else print ", ";
			}
			print $weekDaysR[$holidays[$i]];
		}
	}	
	print "<br>\n";

	print "Санитарный день: ";
	if ($info['summer']['sanitar'] <=-8)
		print "Последний рабочий день каждого месяца";
	else
	if ($info['summer']['sanitar'] >=8)
		print "Первый рабочий день каждого месяца";
	else
	if ($info['summer']['sanitar'] < 0)
	{
		print $lastWeekDays[-$info['summer']['sanitar']]." каждого месяца";
	}
	else
	{
		print $firstWeekDays[$info['summer']['sanitar']]." каждого месяца";	
	}
	print "<br><br>";


	$t = time();

	reset($info['special']);
	foreach($info['special'] as $special)
	{
			$dateStr = $special['date'];
			$timeStr = $special['time'];

			$sinceDate=0;
			$toDate=0;
			if (preg_match("/(\d+)\.(\d+)\.(\d+)\-(\d+)\.(\d+)\.(\d+)/", $dateStr, $g))
			{
				$sinceDate=mktime(0,0,0,$g[2],$g[1],$g[3]);
				$toDate=mktime(23,59,59,$g[5],$g[4],$g[6]);

				if ($t > $toDate) continue;

				print "В период с <b>".$g[1].".".$g[2].".".$g[3]."</b> по <b>".$g[4].".".$g[5].".".$g[6]."</b> ";

			}	
			else
			if (preg_match("/(\d+)\.(\d+)\.(\d+)/", $dateStr, $g))
			{
				$sinceDate=mktime(0,0,0,$g[2],$g[1],$g[3]);
				$toDate=$sinceDate+86400;
				if ($t > $toDate) continue;

				print "<b>$dateStr</b> ";
			}
			else
				continue;

			if (preg_match("/(\d+\:\d+)\-(\d+:\d+)/",$timeStr, $g))
			{
				print "библиотека работает с ".$g[1]." по ".$g[2].".<br>\n";
			}
			else
			if (preg_match("/N\:(.*)/",$timeStr, $g))
			{
				print "библиотека не работает. ".$g[1].".<br>\n";
			}
	}




	$t = time();

	print "<br><div style='border:2px solid #99ccFF; border-radius:10px; padding:8 8 8 8'>";
	print "Сегодня библиотека: ";
	printDayInfo($t, $info['regular'], $info['summer'], $info['special']);
	print "<br>";

	$tm = localtime($t, true);
	$t = mktime(12,0,0,$tm['tm_mon']+1,$tm['tm_mday'],$tm['tm_year']+1900) + 86400;
	//$t+=86400;

	print "Завтра библиотека: ";
	$works = false;
	if (printDayInfo($t, $info['regular'], $info['summer'], $info['special'])) $works = true;
	print "<br>";

	if (!$works)
	{
		print "Послезавтра библиотека: ";
		$t+=86400;
		if (printDayInfo($t, $info['regular'], $info['summer'], $info['special'])) $works = true;
		print "<br>";


		$bug = 0;
		while(!$works)
		{
			$t+=86400;

			print date('d.m.Y',$t). " библиотека: ";
			if (printDayInfo($t, $info['regular'], $info['summer'], $info['special'])) $works = true;
			print "<br>";
			$bug++;
			if ($bug > 7) break;
		}
		print "<br>";
	}
	print "</div>\n";
  }
  else
  {
  	print "<b>Деятельность библиотеки приостановлена</b>\n";
  }



  if ($filial==5)
  {
  ?>
  	<h2>Робот Настя</h2>

  	<table width=100% cellspacing=20 class=robot><tr>
  	<td width=1%><a href='5-2.jpg' target=IMAGE><img src='5-2.jpg' height=250></a></td>
  	<td width=99% valign=top>
  	
  		Здравствуйте! Будем знакомы, я робот-библиотекарь Настя. Я работаю в Библиотеке семейного чтения и досуга им. С.Я. Маршака. Если вам надоело скучать – у вас есть выход! Приходите к нам! У нас вы сможете найти занятие по душе: почитать книгу, поиграть в настольные игры, поучаствовать в разнообразных мастер-классах, пообщаться со мной и узнать много нового. В стенах нашей библиотеки проходят различные конкурсы и интересные викторины, захватывающие литературные путешествия и яркие книжные выставки. С нами интересно!
  		<br><br>
  		Рада видеть моих друзей на моей страничке в VK <nobr>(<a href='https://vk.com/bibliorobotnastya' target=_blank>https://vk.com/bibliorobotnastya</a>)</nobr>.
	</td>
	</tr></table>
  <?php
  }
  else
  if ($filial==14)
  {
  ?>

    <h2>Робот Нина</h2>

  	<table width=100% cellspacing=20 class=robot>
  	<tr>
  		<td width=1%>
  			<a href='nina.jpg' target=IMAGE><img src='nina.jpg' height=250></a>
  		</td>
  		<td width=99% valign=top style='padding-left:20'>
  		
  		Здравствуйте, меня зовут Нина. Я робот и работаю в библиотеке №14. Наших читателей я узнаю по лицу, принимаю и выдаю книги, анализирую ваши личные читательские предпочтения и могу порекомендовать соответствующие новинки из нашего фонда. Я могу дать вам нужную консультацию, помочь найти заинтересовавшую вас книгу, просто пообщаться и пошутить. Приходите к нам в библиотеку, поговорим, поболтаем! Я жду вас!
  		
		</td>
    </tr>
    </table>
  <?php
  }
 ?>




<?php

$filialType = $filial < 100 ? "библиотеки" : "ЦПТИ";

$mysql = mysqlopen();
$canEdit = false;
if (AdminAuth(RIGHT_EDIT_NEWS, $filial)) $canEdit = true;

$first = true;
$sql = "A.`title`<>'' AND ";
if ($canEdit)
{
	$sql ='';

	if ($first)
	{
		$first = false;
		print "<h2>Новости $filialType</h2>";
	}

	FILIALLISTINFO();
	print "<script src='newseditor.js'></script>\n";
	print "<center>[ <a href='#' onclick='newNews($filial)'>Новая новость</a> ]</center><br><br>\n";
}


$news = array();

$result = mysqli_query($mysql,
	"SELECT
		A.`id` 				as `id`,
		A.`title` 			as `title`,
		A.`impotant`		as `impotant`,
		A.`date`			as `date`,
		A.`poster`			as `poster`,
		A.`video`			as `video`,
		A.`text`			as `text`,
		A.`filial`			as `filial`,
		libVideos.`id`		as `videoId`,
		libVideos.`visits`	as `visits`
	FROM
		libNews as A
		LEFT JOIN libVideos ON NOT(A.`video` IS NULL) AND A.`video`<>'' AND libVideos.`video`=A.`video`
	WHERE
		$sql
		A.`filial`=$filial AND
		DATEDIFF(NOW(),A.`date`) < 30
	ORDER BY `impotant` DESC, `date` DESC
	LIMIT 6");
if (mysqli_errno($mysql)) die("ERROR: ".mysqli_error($mysql)." at line ".__LINE__." of file ".__FILE__."\n");

$videoCount = 0;

while($row = mysqli_fetch_assoc($result))
{
	$id = $row['id'];

	if ($first)
	{
		$first = false;
		print "<h2 style='margin-bottom:0'>Новости $filialType</h2>";
	}


	print "<table cellspacing=0 cellpadding=0 class=news><tr><td>\n";

	print "<div class=ellipseBlock data-maxheight=330>\n";

	

	$cls = '';
	if ($row['impotant']) $cls = ' class=impotantNews';

	print "<h2$cls>";


	if (preg_match("/(\d+)\-(\d+)-(\d+)/", $row['date'],$g))
	{
		print "<span class=newsDate>". $g[3].  "."  . $g[2] . "." . $g[1] . "</span>\n";
	}

	print _html_($row['title']);


	if ($canEdit)
	{
		print "<nobr>";
		print "<img class=editBtn title='Редактировать новость' src='edit.png' onclick='editNews($id)'>";
		print "<img class=editBtn title='Удалить новость' src='del32x32.png' onclick='delNews($id)'>";
		print "</nobr>";
	}
	
	
	print "</h2>";


	if ($row['poster']!=null && $row['poster']!='')
	{
		$img = "news/$id/".$row['poster'];
		print "<a href='$img' target=_blank><img border=0 align=left class=eventImg src='$img'></a>";
	}
	


	print "<p>"._para_($row['text'])."</p>\n";

	if ($row['video'] != null && $row['video']!='')
	{
		$w = 320;
		$h = intval($w * 9 / 16);

		$videoId = intval($row['videoId']);

		if (preg_match("/rutube/",$row['video']))
		{
			if (preg_match("/video\/([^\/]*)/",$row['video'], $g))
			{
				$url = $g[1];
				print "<center><iframe class=video data-id=$videoId data-n=$videoCount width=$w height=$h src=\"https://rutube.ru/pl/?pl_id&pl_type&pl_video=$url\" frameborder=\"0\" allow=\"clipboard-write\" webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe></center>";
			}
		}
		else
		if (preg_match("/youtube/", $row['video']))
		{
			if (preg_match("/\?v=([^\/\&]*)/", $row['video'], $g) ||
				preg_match("/\/([^\/]*)$/",$row['video'], $g))
			{
				
				
				$video = $g[1];

				print "<center><iframe class=video data-id=$videoId data-n=$videoCount width=$w height=$h src=\"https://www.youtube.com/embed/$video\" frameborder=0 allowfullscreen></iframe></center>";
			}
		}	
		if ($videoId!=0)
			print "<center>Количество просмотров: <span id=visits$videoCount>".$row['visits']."</span></center>";
		$videoCount++;
	}


	$dir = @opendir("news/$id");
	if ($dir)
	{
		$first = true;
		while($file = readdir($dir))
		{
			if ($file!=$row['poster'])
			{
				if (preg_match("/\.jpg$|\.jpeg$|\.gif$|\.png$/i", $file))
				{
					if ($first)
					{
						$first = false;
						print "<center>\n";
					}
					$img = "news/$id/$file";
					print "<a href='$img' target=_blank><img border=0 class=newsImg src='$img'></a>\n";
				}
			}
		}
		closedir($dir);

		if (!$first) print "</center>\n";
	}


	$url = GetSiteURL() . "/news.php?id=$id#news$id";

	print "<div style='font-size:12px;margin-top:15px'>Постоянный URL новости: <a href='$url'>$url</a></div>\n";
	
	
	print "</div>\n";
	print "<div class=ellipseControl style='display:none' onclick='ellipseClick(this)'>Читать полностью</div>\n";
	print "</td></tr></table>\n\n\n";

}
mysqli_free_result($result);

if (!$first) print "<div class=more>[ <a href='news.php?filial=$filial'>Другие новости</a> ]</div>";

?>



<?php
    

	$firstEvent = true;

	$canEdit = false;
	if (AdminAuth(RIGHT_EDIT_EVENTS | RIGHT_SUPER_ADMIN)) $canEdit = true;

	$sql = "`title`<>'' AND ";
	if ($canEdit)
	{
		FILIALLISTINFO();
		print "<script src='eventeditor.js'></script>\n";
		$sql='';

		$firstEvent = false;
		print "<h2>События $filialType</h2>";
		print "<center>[ <a href='#' onclick='newEvent($filial)'>Новое событие</a> ]</center>\n";
	}


	$result = mysqli_query($mysql,
	"SELECT
		`id`,
		`title`,
		`date`,
		`poster`,
		`desc`,
		`filial`,
		`category`,
		`place`,
		`scripts`,
		`duration`,
		`showDate`,
		`price`,
		MONTH(`date`) as `month`,
		YEAR(`date`) as `year`
	FROM
		libEvents
	WHERE
		$sql
		`filial`=$filial AND
		DATEDIFF(NOW(),`date`)<=0
	ORDER BY `date` ASC");
	if (mysqli_errno($mysql)) die("ERROR: ".mysqli_error($mysql)." at line ".__LINE__." of file ".__FILE__."\n");
	while($row = mysqli_fetch_assoc($result))
	{
		if ($firstEvent)
		{
			$firstEvent = false;
			print "<h2>События $filialType</h2>";
			if ($canEdit) print "<center>[ <a href='#' onclick='newEvent()'>Новое событие</a> ]</center>\n";
		}


		$id = $row['id'];
		print "<table class=event cellspacing=0 cellpadding=><tr><td>\n";

		print "<div class=ellipseBlock data-maxheight=290>\n";

		if ($row['poster']!=null && $row['poster']!='')
		{
			$img = "events/".$row['poster'];
			print "<a href='$img' target=_blank><img border=0 align=left class=eventImg src='$img'></a>";
		}
		$title = $row['title'];
		if ($title==null || trim($title)=='') $title="Новое событие";

		print "<h2>$title";
	

		if ($canEdit)
		{
			print "<nobr>";
			print "<img class=editBtn title='Редактировать событие' src='edit.png' onclick='editEvent($id)'>";
			print "<img class=editBtn title='Удалить событие' src='del32x32.png' onclick='delEvent($id)'>";
			print "</nobr>";
		}
	
	
		print "</h2>";

		if (preg_match("/(\d+)\-(\d+)-(\d+).*?(\d+):(\d+):\d+/", $row['date'],$g))
		{
			print "<div class=eventDate>". $g[3].  "."  . $g[2] . "." . $g[1] . " <span>начало в</span> " . $g[4] . ":" . $g[5]. "</div>\n";
		}

		if ($row['place']!=null && $row['place']!='')
			print "<div class=eventPlace>Место проведения: ".$row['place']."</div>\n";

		print "<p>"._para_($row['desc'])."</p>\n";

		if ($row['category']>=0)
			print "<div class=eventCategory>Категория: ".$row['category']."+</div>\n";


		if ($row['showDate']!=0)
		{
			$duration = intval($row['duration']);
			$h = intval($duration/60);
			$m = $duration%60;

			if ($h>0)
			{
				$duration = "$h ч.";
				if ($m > 0) $duration.=" $m мин.";
			}
			else
				$duration = "$m мин.";

			print "<center>Продолжительность: $duration</center>\n";
		}


		if (isset($row['scripts']) && $row['scripts']!='')
		{
			print "<center>";
			print $row['scripts'];
			print "</center>";
		}

		if ($row['price'] > 0.0)
		{
			print "<br>Цена входа: ".$row['price']." руб.<br><br>";

			if ($actual) print "<center><input type=button class=dlgBtn value='Купить билет' onclick='doBuy(this, $id, 1)'></center><br>";

			if ($canView)
			{
				print "<center><input type=button class=dlgBtn value='Список гостей' onclick='location=\"eventguest.php?event=$id\"'></center><br>";
			}
		}


		$month = $row['month'];
		$year = $row['year'];
		$mInx = $year * 12 + ($month - 1);

		$url = GetSiteURL() . "/events.php?monthinx=$mInx#evt$id";
		print "<div style='font-size:12px;margin-top:15px'>Постоянный URL события: <a href='$url'>$url</a></div>\n";


		print "</div>\n";
		print "<div class=ellipseControl style='display:none' onclick='ellipseClick(this)'>Читать полностью</div>\n";
		print "</td></tr></table>\n\n\n";

		
	}
	mysqli_free_result($result);


	if (!$firstEvent)
	{
		print "<br><div class=more>[ <a href='events.php?filial=$filial'>Архив событий</a> ]</div>";
	}

?>

<br><br>


<h1 id=address>Адрес и контакты</h1>

<?php
if (isset($GLOBALS['filialContacts'][$filial]['director']))
{
	$value = $GLOBALS['filialContacts'][$filial]['director'];
	if ($filial == 11) print "Главный библиотекарь: <b>$value</b>";
	else
	{
		//if (strpos($value,"вна")!==false) print "Заведующая"; else print "Заведующий";
		print "Заведующий библиотекой: <b>$value</b>";
	}
	print "<br>";
}
?>

<table>
<?php


foreach($GLOBALS['filialContacts'][$filial] as $key=>$value)
{
	if ($key == "address" || $key == "director") continue;
	if ($key == "email")
	{
		print "<tr><td align=right>e-mail:</td><td><img class=img16x16 src='email16x16.png'><a href='mailto:$value'>$value</a></td></tr>\n";
	}
	else
	if ($key == "phone")
	{
		print "<tr><td align=right>Телефон: </td><td><img class=img16x16 src='tel16x16.png'><b>$value</b></td></tr>\n";
	}
	/*
	else
	if ($key == "instagram")
	{
		print "<tr><td align=right></td><td><a href='$value' target=_blank><img class=img16x16 src='instagram16x16.png'>Instagram</a></td></tr>\n";
	}
	else
	if ($key == "nastya")
	{
		print "<tr><td align=right></td><td><a href='$value' target=_blank><img class=img16x16 src='instagram16x16.png'>Instagram-страничка робота Настя</a></td></tr>\n";
	}
	*/
	else
	if ($key == "vk")
	{
		print "<tr><td align=right></td><td><a href='$value' target=_blank><img class=img16x16 src='vk16x16.png'>ВКонтакте</a></td></tr>\n";
	}

	else
	if ($key == "telegram")
	{
		print "<tr><td align=right></td><td><a href='$value' target=_blank><img class=img16x16 src='telegram16x16.png'>Telegram</a></td></tr>\n";
	}
}
?>
</table>



Адрес: <b><?php print $GLOBALS['filialContacts'][$filial]['address']; ?></b><br><br>
<center>


<?php
if ($filial==11) { ?>
<iframe src="https://yandex.ru/map-widget/v1/?um=constructor%3Add9ae16f685fb338f3eaa9264f81a24468cc0156c22e2fda960d053f69c2b060&amp;source=constructor" width="100%" height="562" frameborder="0"></iframe>
<?php
}
else
if ($filial==1) { ?>
<iframe src="https://yandex.ru/map-widget/v1/?um=constructor%3A546fd41681429e6a83f19732971fa865335441d427622acd9d3068b509c31a1c&amp;source=constructor" width="100%" height="473" frameborder="0"></iframe>
<?php
}
else
if ($filial==2) { ?>
<iframe src="https://yandex.ru/map-widget/v1/?um=constructor%3A58a8f643afb21ad710fa58bb8dfc2b2ac04f6cb884f7528c8897665c4c091f8f&amp;source=constructor" width="100%" height="400" frameborder="0"></iframe>
<?php
}
else
if ($filial==3) { ?>
<iframe src="https://yandex.ru/map-widget/v1/?ll=37.888274%2C55.933935&mode=poi&poi%5Bpoint%5D=37.887430%2C55.934092&poi%5Buri%5D=ymapsbm1%3A%2F%2Forg%3Foid%3D94826067290&z=16.74" width="100%" height="400" frameborder="0" allowfullscreen="true"></iframe>
<?php
}

else
if ($filial==4) { ?>
<iframe src="https://yandex.ru/map-widget/v1/?um=constructor%3A6671e508e899976f0f985bd2f6ab35b5f73545946abc2b5fb7ab2f35cf57bf03&amp;source=constructor" width="100%" height="400" frameborder="0"></iframe>
<?php
}
else
if ($filial==5) { ?>
<iframe src="https://yandex.ru/map-widget/v1/?um=constructor%3Ac52499e22e37d16938671df1545afcfe90c77822b908eb2edddcff476aaafb0a&amp;source=constructor" width="100%" height="497" frameborder="0"></iframe>
<?php
}
else
if ($filial==6) { ?>
<iframe src="https://yandex.ru/map-widget/v1/?um=constructor%3A2e85938f78281a3d12923239ef6afe51c3b190a809c1b27fb25a90a097de92f5&amp;source=constructor" width="100%" height="470" frameborder="0"></iframe>
<?php
}
else
if ($filial==7) { ?>
<iframe src="https://yandex.ru/map-widget/v1/?um=constructor%3A30c90b30ca1615b5f832e7bdf8c228682ec0830da68e68da59bda6c9120fecac&amp;source=constructor" width="100%" height="400" frameborder="0"></iframe>
<?php
}
else
if ($filial==8) { ?>
<script type="text/javascript" charset="utf-8" async src="https://api-maps.yandex.ru/services/constructor/1.0/js/?um=constructor%3Abe83d352aae21c6b94cd822a0f787743fd1cbd77964110f6c2053182147ea9dc&amp;width=100%25&amp;height=400&amp;lang=ru_RU&amp;scroll=true"></script>
<?php
}
else
if ($filial==12) { ?>
<iframe src="https://yandex.ru/map-widget/v1/?um=constructor%3A1896e84b02e20a2fe197d84ce1e7b665e48843ee6e707c0c8b4461ea89e8dbf9&amp;source=constructor" width="100%" height="400" frameborder="0"></iframe>
<?php
}
else
if ($filial==13) { ?>
<iframe src="https://yandex.ru/map-widget/v1/?um=constructor%3Afa85d8f5d6b5a1d58d1f845ca9a5e3837c3a59ff2f6c95895f59973cc1aa6032&amp;source=constructor" width="100%" height="400" frameborder="0"></iframe>
<?php
}
else
if ($filial==14 || $filial == 100) { ?>
<iframe src="https://yandex.ru/map-widget/v1/?um=constructor%3A538ef451d38e1a9227bc1b9b70c2202e63f68541189df785c5bce584b9b1be38&amp;source=constructor" width="100%" height="461" frameborder="0"></iframe>
<?php
}
?>


</center>

<?php
if ($filial == 14)
{
	print "<br><center><a href='https://xn--80aacacvtbthqmh0dxl.xn--p1ai/feedback' target=_blank><img src=webest14.jpg width=400 height=167></a></center><br>\n";
}
?>




<hr>
<center style='margin-top:10'><input type=button onclick='history.back()' value='« Назад'></center>




<script>
focus();
visitsVideos=[];
lastIframe = null;

setInterval(function()
{
	var elm = document.activeElement;
    if (elm && elm.tagName == 'IFRAME' && elm.dataset.id && elm!=lastIframe)
    {
    	lastIframe = elm;

   		var n = elm.dataset.n;
   		var id = elm.dataset.id;
   		if (id!=0)
   		{
	   		if (visitsVideos.indexOf(n) >=0) return;
   			visitsVideos.push(n);
        
   			sendXHR('api.php','action=videos:visit&id='+id,
    			function(response)
    			{
		    		var span = document.getElementById('visits'+n);
		    		span.innerHTML = response;
				});
		}
    }
},100);

</script>




<?php

MIDDLECOLUMN2();
print "<center><table><tr><td>";
ACTUALLINKS('actualLinksH');
print "</tr></td></table></center>";
FAQ();

MIDDLECOLUMN();
CHANNELS("channelBlockH");
RIGHTCOLUMN();

ACTUALLINKS();
FAQ();

?>




<?php BOTTOM(); ?>

May the force be with you, always.