HEX
Server: Apache/2.4.59 (Debian)
System: Linux skycube.cz 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08) x86_64
User: ilya (534)
PHP: 7.3.31-1~deb10u7
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/ilya/data/www/afish-ka.ru/modules/main/actions.inc
<?php

#————————————————————> CMS Termit <———————————————————————#
#                                                         #
#                 Author: Ilya Rudomilov                  #
#                                                         #
#                E-mail: ilya@rudomilov.ru                #
#              URL: http://www.rudomilov.ru/              #
#                      ICQ: 203015                        #
#                                                         #
#——————————————> Grafix Design — (c) 2006 <———————————————#

function get_daughter_opinions($parent_opinion_id) {
	GLOBAL $opinions_add_url;
	$html_source = "";
	
	$result_container = "result_".$parent_opinion_id; //print $parent_opinion_id."<br>";
	$data_container = "data_".$parent_opinion_id;
	$$result_container = query("SELECT * FROM `opinions` WHERE `parent_id`=".$parent_opinion_id.";");
	if(mysql_num_rows($$result_container)>0) {
		while($data=mysql_fetch_array($$result_container)) {
			$opinions_id = $data['id'];
			$opinions_rate = $data['rate'];
			$opinions_author = $data['author'];
			$opinions_date = substr($data['datetime'],8,2)." ".skin_date_humanmon(substr($data['datetime'],5,2))." ".substr($data['datetime'],0,4)." г.";
			$opinions_text = str_replace("\r","<br>",$data['text']);
				
			$daughter_opinions = get_daughter_opinions($data['id']);
			$html_source .= preg_replace("/{%(\w+)%}/ee", "$\\1",_html("opinions_row.htm",0));
			$temp_html .= $result_container." - ";

		}
	}
		return $html_source;
	
}

$result = query("SELECT `type_subtitle`, `id`, `human_id`, `human_subid` FROM `firms_types` WHERE `human_subid`='".$global_vars['request'][1]."' AND `human_id`='".$global_vars['request'][0]."' LIMIT 1;");
if(mysql_num_rows($result)==0)
	error(404);
$actions_type = mysql_fetch_array($result);
$actions_type_id = $actions_type[1];
$actions_type_subhuman = $actions_type[3];
$actions_type_human = $actions_type[2];
$actions_type = $actions_type[0];

$global_vars['title'][] = $actions_type;

$opinions_ratelist = array('Очень плохо','Плохо','Довольно плохо','Удовлетворительно','Весьма неплохо','Нормально','Весьма хорошо','Хорошо','Очень хорошо','Отлично');

if (!strpos($global_vars['request'][2],".html") && ($global_vars['request'][2]!=''))
    {
    $action = query("SELECT * FROM `actions` WHERE `id`='".$global_vars['request'][2]."' AND `type`=".$actions_type_id." LIMIT 1;");
    if(mysql_num_rows($action)!=1)
       error(404);

    $data = mysql_fetch_array($action);

    $actions_id = $data['id'];
    $actions_title = $data['title'];
    $actions_genre = $data['genre'];
    $actions_country = $data['country'];
    $actions_length = $data['length'];
    $actions_author = $data['author'];
    $actions_producer = $data['producer'];
    $actions_actors = $data['actors'];
    $actions_prime = $data['prime-date'];
    $actions_counter = $data['counter'];
    $actions_description = str_replace("\r","<br>",$data['description']);
	$actions_description_simple = text_replace($actions_description);
    if ($data['www']!='') $actions_www = "<a href=\"http://".$data['www']."\" target=\"blank\">".$data['www']."</a>";
	
	switch($data['age-limit']) {
		case "21": $actions_age_limit = "С 21 года"; break;
		case "18": $actions_age_limit = "С 18 лет"; break;
		case "16": $actions_age_limit = "С 16 лет"; break;
		case "12": $actions_age_limit = "С 12 лет"; break;
		case "6": $actions_age_limit = "С 6 лет"; break;
		case "0": $actions_age_limit = "С 0 лет"; break;
		default: $actions_age_limit = "";
	}


    $actions_opinions = mysql_fetch_array(query("SELECT COUNT(`id`) AS `count`, SUM(`rate`)/COUNT(`id`) AS `rating` FROM `opinions` WHERE `aid`=".$actions_id.";"));
    $actions_opinions_num = $actions_opinions['count'];
    $actions_opinions_rating_5 = round($actions_opinions['rating']*10)/20; // for google rich snippets at search results
    $actions_opinions_rating = round($actions_opinions['rating']);
	
    $actions_opinions_url = $global_vars['request'][0]."/".$global_vars['request'][1]."/".$global_vars['request'][2]."/opinions/";

    $actions_info_img="";

    $global_vars['title'][] = $actions_title;

    if(array_key_exists(3,$global_vars['request']) && ($global_vars['request'][3]=='opinions'))
       {
       $global_vars['title'][] = "Отзывы";

       if($global_vars['request'][4]=='add')
          {
          if (isset($_POST['author'],$_POST['rate'],$_POST['email'],$_POST['text']))
              {
              $errors = array();
			  $sql_res = mysql_fetch_array(query("SELECT COUNT(`id`) FROM `opinions` WHERE `aid`=".$actions_id." AND `author`='".text_replace($_POST['author'])."' AND `email`='".text_replace($_POST['email'])."' AND `text`='".text_replace($_POST['text'])."' AND `rate`='".$_POST['rate']."' AND `parent_id`='".$opinion_parent."';"));
			  if($sql_res[0]>0)
                  $errors[] = "Это дубликат комментария";
              if(strstr(text_replace($_POST['text']),"http://") || strstr(text_replace($_POST['text']),"www."))
                  $errors[] = "Комментарий не может содержать ссылку";
              if ($_POST['author']=='')
                  $errors[] = "Не указан автор";
              if ($_POST['email']=='')
                  $errors[] = "Не указан адрес эл. почты";
              if ($_POST['text']=='')
                  $errors[] = "Не введен текст";
              if (($_POST['rate']<0) || ($_POST['rate']>9))
                  $errors[] = "Не указана оценка";

              if(isset($_GET['parent']))
                  $opinion_parent = $_GET['parent'];
              else
				$opinion_parent = 0;
				
              if(count($errors)==0)
                {
				query("INSERT INTO `opinions` (`parent_id`, `aid`, `datetime`, `author`, `email`, `ip`, `text`, `rate`) VALUES ('".$opinion_parent."', ".$actions_id.",'".date("Y-m-d H:i:s",TIME)."', '".text_replace($_POST['author'])."', '".text_replace($_POST['email'])."', '".$_SERVER['REMOTE_ADDR']."', '".text_replace($_POST['text'])."', '".$_POST['rate']."')");
				cache_delete(array('opinions_actions'),$actions_id.'.html');
				setcookie('opinions_author'.COOKIE_ID,text_replace($_POST['author']),time()+8035200,'/');
				setcookie('opinions_email'.COOKIE_ID,text_replace($_POST['email']),time()+8035200,'/');
				header("Location: ".SITE_BASE_HTTP_URI.$global_vars['request'][0]."/".$global_vars['request'][1]."/".$global_vars['request'][2]."/opinions/#opinion_".mysqli_insert_id($global_vars['db_connection']));
				}
				else
                  {
                  $author = $_POST['author'];
                  $rate = $_POST['rate'];
				  $email = $_POST['email'];
                  $text = $_POST['text'];
                  $errors = join("<br>",$errors);
                  }
              }
		  else {
		       $author = $_COOKIE['opinions_author'.COOKIE_ID];
			   $email = $_COOKIE['opinions_email'.COOKIE_ID];
		  }
          $opinions_rate = "<select name=\"rate\" style=\"width: 100%\">\r<option value=\"-1\">Оцените...\r";
          for ($i=count($opinions_ratelist);$i>0;$i--)
               {
               if(isset($_POST['rate']) && ($_POST['rate']==$i))
                  $opinions_rate .= "<option value=\"".$i."\" selected>".$opinions_ratelist[$i]."\r";
               else
                  $opinions_rate .= "<option value=\"".$i."\">".$opinions_ratelist[$i]."\r";
               }

          $opinions_rate .= "</select>\r";
          $opinions_title = "<a href=\"".$actions_type_human."/".$actions_type_subhuman."/\">".$actions_type."</a> / <a href=\"".$actions_type_human."/".$actions_type_subhuman."/".$actions_id."/\">".$actions_title."</a> / <a href=\"".$actions_type_human."/".$actions_type_subhuman."/".$actions_id."/opinions/\">Отзывы</a>";

          $temp_html = preg_replace("/{%(\w+)%}/ee", "$\\1",_html("opinions_add.htm",0));
          if ($errors=='') $temp_html = preg_replace("'<!-- errors -->.*?<!-- /errors -->'si","",$temp_html);
          }
       else {
          $opinions_title = "<a href=\"".$actions_type_human."/".$actions_type_subhuman."/\">".$actions_type."</a> / <a href=\"".$actions_type_human."/".$actions_type_subhuman."/".$actions_id."/\">".$actions_title."</a>";
          $opinions_add_url = $actions_type_human."/".$actions_type_subhuman."/".$actions_id;

          if (cache_check(array('opinions_actions'),$actions_id.'.html','31536000'))
				$temp_html = cache_read(array('opinions_actions'),$actions_id.'.html');
          else {
		  
          $result = query("SELECT * FROM `opinions` WHERE `aid`=".$actions_id." AND `parent_id`=0 ORDER BY `datetime`;");

          $temp_html = "";

          if (mysql_num_rows($result)==0)
              {
              $opinions_author = "Нет отзывов";
              $opinions_text = "К сожалению, нет отзывов. Вы можете добавить первый отзыв, перейдя по ссылке \"Добавить отзыв\"";

              $temp_html = preg_replace("/{%(\w+)%}/ee", "$\\1",_html("opinions_row.htm",0));
              $temp_html = preg_replace("'<!-- opinions_adv -->.*?<!-- /opinions_adv -->'si","",$temp_html);
              }

          while ($data = mysql_fetch_array($result))
                 {
				 $opinions_id = $data['id'];
                 $opinions_rate = $data['rate'];
                 $opinions_author = $data['author'];
                 $opinions_date = substr($data['datetime'],8,2)." ".skin_date_humanmon(substr($data['datetime'],5,2))." ".substr($data['datetime'],0,4)." г.";
                 $opinions_text = str_replace("\r","<br>",$data['text']);
				
				 $daughter_opinions = get_daughter_opinions($data['id']);
                 $temp_html .= preg_replace("/{%(\w+)%}/ee", "$\\1",_html("opinions_row.htm",0));
				 
                 }

          $temp_html = preg_replace("/{%(\w+)%}/ee", "$\\1",_html("opinions.htm",0));
		  cache_write(array('opinions_actions'),$actions_id.'.html',$temp_html);
		}
          }
       }
    else
        {
    query("UPDATE `actions` SET `counter`=`counter`+1 WHERE `id`='".$global_vars['request'][2]."' LIMIT 1;");

    $handle=opendir('images/b/posters/');
	$poster = false;
    while ((false !== ($file = readdir($handle))) /*&& ($actions_img_poster=='')*/)
         {
         if (($file != ".") && ($file != "..")  && strstr($file,$data['id'].".") && (substr($file,0,strpos($file,$data['id']."."))==""))
                {
                if (strpos($file,$data['id'].".")==0/5) {
					$poster = true;
					$size = getimagesize('images/b/posters/'.$file);
					$actions_img_bw = $size[0];
					$actions_img_bh = $size[1];
					$actions_img_bsize = round(filesize('images/b/posters/'.$file)/1024);
					$filename = $file;
					/*if(!isset($skin_social_image))
						$skin_social_image = $url.'images/b/posters/'.$file;*/
					}
                }
         }
    closedir($handle);	
	
    $image_files = get_images('images/b/actions/');
    foreach ($image_files as $file)
         {
         if (($file != ".") && ($file != "..")  && strstr($file,$data['id']."_") && (substr($file,0,strpos($file,$data['id']."_"))==""))
                {
                if (strpos($file,$data['id']."_")==0/5) {
					$size = getimagesize('images/b/actions/'.$file);
					$actions_img_bw = $size[0];
					$actions_img_bh = $size[1];
					$actions_img_bsize = round(filesize('images/b/actions/'.$file)/1024);

					$actions_info_img .= preg_replace("/{%(\w+)%}/ee", "$\\1",_html("actions_info_img.htm",0));
					
					if(!isset($skin_social_image))
						$skin_social_image = $url.'images/b/actions/'.$file;
					}
                }
         }

	$result = query("SELECT * FROM `shedule` WHERE `datetime`>=NOW() AND `aid`='".$actions_id."';"); // QR
	
	if((mysql_num_rows($result)!=1 )|| $actions_type_id==1)
		$actions_qr = false;
	else {
		$actions_qr = true;
		$actions_qr_preview = urlencode($url.$actions_type_human."/".$actions_type_subhuman."/".$actions_id."/");
	}

	//$actions_qr = false;	
		
    if($actions_type_id==1) // Вывод с какого по какое фильм идет (только для фильмов!!!)
       { 
       $result2 = query("SELECT `shedule`.*, `firms`.`title`, `firms`.`type`, MIN(`shedule`.`datetime`) AS `from`, MAX(`shedule`.`datetime`) AS `to` FROM `shedule` LEFT JOIN `firms` ON `firms`.`id`=`shedule`.`fid` WHERE `shedule`.`aid`=".$data['id']." GROUP BY `shedule`.`fid`;");


       if (mysql_num_rows($result2)>0) {
            $actions_period_data = array();
			$actions_period = "";
            while($data2 = mysql_fetch_array($result2)) {
					if($data2['type']!="") {
						$firm_type_human = mysql_fetch_array(query("SELECT `human_id` FROM `firms_types` WHERE `id`=".$data2['type'])); 
						//var_dump($actions_period_data);
						$actions_period_firm_title = "<a href=\"/".$firm_type_human[0]."/".$data2['fid']."/\">".$data2['title']."</a>";
						
						if(date("G",strtotime($data2['from']))<TIME_WORK)
							$actions_period_firm_from = date("d.m.Y",strtotime($data2['from'])-43200);
						else
							$actions_period_firm_from = date("d.m.Y",strtotime($data2['from']));
						
						if((TIME - (TIME % 86400)) >= (strtotime($data2['to']) - (strtotime($data2['to']) % 86400)))
							if(date("G",strtotime($data2['to']))<TIME_WORK)
								$actions_period_firm_to = date("d.m.Y",strtotime($data2['to'])-43200);
							else
								$actions_period_firm_to = date("d.m.Y",strtotime($data2['to']));
						else
							$actions_period_firm_to = FALSE;

						$to_add = TRUE;
						
						//print $actions_period_firm_title.": ".$actions_period_firm_from."-".$actions_period_firm_to."<br>";
						//print sizeof($actions_period_data)."<br>";

						if(sizeof($actions_period_data)>0) {
							for($i=0;$i<sizeof($actions_period_data);$i++) {
							//print sizeof($actions_period_data)."<br>";
							
							//print $actions_period_firm_title.": ".$actions_period_firm_from."-".$actions_period_firm_to." VS ".$actions_period_data[$i][0].": ".$actions_period_data[$i][1]."-".$actions_period_data[$i][2]."<br>";
							
								if((($actions_period_data[$i][1]==$actions_period_firm_from) && ($actions_period_data[$i][2]==$actions_period_firm_to)) || (($actions_period_data[$i][1]==$actions_period_firm_from) && ($actions_period_firm_to!=FALSE))) {
									$actions_period_data[$i][0] = $actions_period_data[$i][0]." -- ".$actions_period_firm_title;
									$to_add=FALSE;
								}
							}
						}
						
						if($to_add==TRUE)
							$actions_period_data[] = array($actions_period_firm_title,$actions_period_firm_from,$actions_period_firm_to);
										 

					}
			}
			//var_dump($actions_period_data);
			foreach ($actions_period_data as $data) {

				if(substr_count($data[0],"> -- <")>1) {
					//$data[0] = str_replace("> и <",">, <",$data[0],(substr_count($data[0],"> и <")-1));
					
					$data[0] = explode(" -- ",$data[0]);
					
					$actions_period_firm = $data[0][0];
					
					for($i=1;$i<sizeof($data[0])-1;$i++) {
						$actions_period_firm .= ", ".$data[0][$i];
					}
					
					$actions_period_firm .= " и ".$data[0][sizeof($data[0])-1];
					

					
				}
				else {
					$actions_period_firm = str_replace("> -- <","> и <",$data[0]);
				}

				$actions_period_firm = str_replace("> и <",">&raquo; и &laquo;<",$actions_period_firm);
				$actions_period_firm = str_replace(">, <",">&raquo;, &laquo;<",$actions_period_firm);
//(strtotime($data[2])>TIME) && 
				if(!$data[2]) {
					if(strlen($actions_period)>0)
						$actions_period .= ", ";
					else
						$actions_period .= "<br />Смотрите ";
					$actions_period .= "в к/ц &laquo;".$actions_period_firm."&raquo; с <a href=\"/".date("d-m-Y",strtotime($data[1]))."/\">".$data[1]."</a>";
				}
				else {
					if(strlen($actions_period)>0)
						$actions_period .= ", ";
					else
						$actions_period .= "<br />Фильм был в прокате ";
					$actions_period .= "к/ц &laquo;".$actions_period_firm."&raquo; с <a href=\"/".date("d-m-Y",strtotime($data[1]))."/\">".$data[1]."</a> по <a href=\"/".date("d-m-Y",strtotime($data[2]))."/\">".$data[2]."</a>";
				}
			}
			
			
        }
		$actions_period .= ".";
       }
	if(!isset($actions_qr_preview))
		$actions_qr_preview = "";
	if(!isset($actions_www))
		$actions_www = "";
	if(!isset($filename))
		$filename = "";
	if(!isset($actions_img_bsize))
		$actions_img_bsize = "";
	if(!isset($actions_period))
		$actions_period = "";
	if(!isset($actions_img_poster))
		$actions_img_poster = "";
		
	if($actions_description!='')
		if(strlen(text_replace($actions_description))>300)
			$skin_social_description = mb_substr(text_replace($actions_description),0,300,'UTF-8')."...";
		else
			$skin_social_description = text_replace($actions_description);
		
    $temp_html = preg_replace("/{%(\w+)%}/ee", "$\\1",_html("actions_info.htm",0));

    if ($actions_genre=='') $temp_html = preg_replace("'<!-- genre -->.*?<!-- /genre -->'si","",$temp_html);
    if ($actions_country=='') $temp_html = preg_replace("'<!-- country -->.*?<!-- /country -->'si","",$temp_html);
    if ($actions_length=='') $temp_html = preg_replace("'<!-- length -->.*?<!-- /length -->'si","",$temp_html);
    if ($actions_author=='') $temp_html = preg_replace("'<!-- author -->.*?<!-- /author -->'si","",$temp_html);
    if ($actions_producer=='') $temp_html = preg_replace("'<!-- producer -->.*?<!-- /producer -->'si","",$temp_html);
    if ($actions_actors=='') $temp_html = preg_replace("'<!-- actors -->.*?<!-- /actors -->'si","",$temp_html);
    if ($actions_prime=='') $temp_html = preg_replace("'<!-- prime -->.*?<!-- /prime -->'si","",$temp_html);
    if ($actions_www=='') $temp_html = preg_replace("'<!-- www -->.*?<!-- /www -->'si","",$temp_html);
	if ($actions_age_limit=='') $temp_html = preg_replace("'<!-- age-limit -->.*?<!-- /age-limit -->'si","",$temp_html);
    if ($actions_period=='') $temp_html = preg_replace("'<!-- period -->.*?<!-- /period -->'si","",$temp_html);
    if (!$poster) $temp_html = preg_replace("'<!-- img_poster -->.*?<!-- /img_poster -->'si","",$temp_html);
    if ($actions_info_img=='' && $actions_img_poster=='') $temp_html = preg_replace("'<!-- img -->.*?<!-- /img -->'si","",$temp_html);
    if ($actions_description=='') $temp_html = preg_replace("'<!-- description -->.*?<!-- /description -->'si","",$temp_html);
    if ($actions_opinions_num==0) $temp_html = preg_replace("'<!-- opinions -->.*?<!-- /opinions -->'si","нет.",$temp_html);
	if (!$actions_qr) $temp_html = preg_replace("'<!-- qr -->.*?<!-- /qr -->'si","",$temp_html);

    $temp_html = preg_replace("'<!--.*?-->'si","",$temp_html);

    $search_date = date("Y-m-d",TIME)." ".TIME_WORK.":00:00";

    $actions_afisha = "";
	
	if (false /*cache_check(array('afisha_actions'),$actions_id.'.html','3600')*/)
		$actions_afisha = cache_read(array('afisha_actions'),$actions_id.'.html');
	else {
	
    for($i=0;$i<3;$i++)
        {
        $result = query("SELECT MIN(`datetime`) AS `curdate`, DATE_ADD(`datetime`, INTERVAL 1 DAY) AS `nextdate`, DATE_SUB(`datetime`, INTERVAL 1 DAY) AS `prevdate`, HOUR(`datetime`) AS `hour` FROM `shedule` WHERE `datetime`>='".$search_date."' AND `aid`=".$actions_id." GROUP BY `datetime` ORDER BY `datetime` LIMIT 1;");
        if (mysql_num_rows($result)>0)
            {
            $afisha_row = "";

            $data = mysql_fetch_array($result);
            if ($data['hour']>=TIME_WORK)
                {
                $cur_date = substr($data['curdate'],0,10)." ".TIME_WORK.":00:00";
                $search_date = substr($data['nextdate'],0,10)." ".TIME_WORK.":00:00";
                }
            else
                {
                $cur_date = substr($data['prevdate'],0,10)." ".TIME_WORK.":00:00";
                $search_date = substr($data['curdate'],0,10)." ".TIME_WORK.":00:00";
                }

            $result2 = query("SELECT `price` FROM `shedule` WHERE `datetime`>='".$cur_date."' AND `datetime`<'".$search_date."' AND `aid`=".$actions_id." GROUP BY `price` ORDER BY `datetime`;");

            while($data2 = mysql_fetch_array($result2))
                  {
                  $result3 = query("SELECT `shedule`.`fid`, `firms`.`title`, `firms`.`id`, `firms`.`type` FROM `shedule` LEFT JOIN `firms` ON `firms`.`id`=`shedule`.`fid` WHERE `shedule`.`datetime`>='".$cur_date."' AND `shedule`.`datetime`<'".$search_date."' AND `shedule`.`price`='".$data2['price']."' AND `aid`=".$actions_id." GROUP BY `shedule`.`fid` ORDER BY `shedule`.`datetime`;");

                  $price = $data2['price'];

                  while($data3 = mysql_fetch_array($result3))
                        {

                        $firms_title = $data3['title'];
                        $firms_id = $data3['id'];

                        $firms_type = mysql_fetch_array(query("SELECT `human_id` FROM `firms_types` WHERE `id`=".$data3['type'].";"));
                        $firms_type = $firms_type[0];
                        $firms_url = $firms_type."/".$firms_id."/";


                        $result4 = query("SELECT `datetime` FROM `shedule` WHERE `datetime`>='".$cur_date."' AND `datetime`<'".$search_date."' AND `fid`=".$data3['fid']." AND `price`='".$data2['price']."' AND `aid`=".$actions_id." ORDER BY `datetime`");

						if(($data2['price']=="?") && (mysql_num_rows($result4)==1) && ($data3['type']==1))
							$timetable_list = "премьера";
						else
							{
							$timetable_list = "";
							while($data4 = mysql_fetch_array($result4))
									{
									$timetable_list .= substr($data4['datetime'],11,5).", ";
									}
							$timetable_list = substr($timetable_list,0,strlen($timetable_list)-2);
							}


                        $afisha_row .= preg_replace("/{%(\w+)%}/ee", "$\\1",_html("actions_info_afisha_row.htm",0));
                        }
                  }
            $afisha_date = explode(" ",$cur_date);
            list($afisha_date_year,$afisha_date_mon,$afisha_date_day) = explode("-",$afisha_date[0]);
            $afisha_date = $afisha_date_day." ".skin_date_humanmon($afisha_date_mon)." ".$afisha_date_year." г.";

            $actions_afisha .= preg_replace("/{%(\w+)%}/ee", "$\\1",_html("actions_info_afisha.htm",0));
            }
          }
			cache_write(array('afisha_actions'),$actions_id.'.html',$actions_afisha);
		  }
		  
          $temp_html .= $actions_afisha;
        }
    }
else
    {
    $totalsize = mysql_fetch_array(query("SELECT COUNT(*) FROM `actions` WHERE `type`=".$actions_type_id.";"));

    $skin_span = skin_span(SPAN,$global_vars['page'],$totalsize[0],"/".$actions_type_human."/".$actions_type_subhuman."/");

    $result = query("SELECT * FROM `actions` WHERE `type`=".$actions_type_id." ORDER BY `title` LIMIT ".(($global_vars['page']-1)*SPAN).",".SPAN.";");

    if (mysql_num_rows($result)==0)
        error(404);

    $temp_html = "";
    while ($data = mysql_fetch_array($result))
       {
       $actions_rating = mysql_fetch_array(query("SELECT COUNT(`id`) AS `count`, SUM(`rate`)/COUNT(`id`) AS `rating` FROM `opinions` WHERE `aid`=".$data['id'].";"));

       $actions_opinions_num = $actions_rating['count'];
       $actions_opinions_rating = round($actions_rating['rating']);

       $actions_url = "/".$global_vars['request'][0]."/".$global_vars['request'][1]."/".$data['id']."/";

       $actions_title = $data['title'];
       $actions_producer = $data['producer'];
       $actions_actors = $data['actors'];

       $actions_row = preg_replace("/{%(\w+)%}/ee", "$\\1",_html("actions_row.htm",0));

       if ($actions_producer=='')
             $actions_row = preg_replace("'<!-- producer -->.*?<!-- /producer -->'si", "",$actions_row);
       if ($actions_actors=='')
             $actions_row = preg_replace("'<!-- actors -->.*?<!-- /actors -->'si","",$actions_row);
       if ($actions_opinions_num==0)
             $actions_row = preg_replace("'<!-- opinions -->.*?<!-- /opinions -->'si","нет.",$actions_row);

       $actions_row = preg_replace("'<!--.*?-->'si","",$actions_row);
       $temp_html .= $actions_row;
       }

    $temp_html = preg_replace("/{%(\w+)%}/ee", "$\\1",_html("actions.htm",0));
    }

_html_design($temp_html);

?>