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/services/limonad.inc
<?

$xml = simplexml_load_file('http://kamkino.ru/export?token=MojzTYFm3ho7FeJh8rAQt2wb') or die("Can not load a file");

$shedule = array();
$new_movies = array();

foreach($xml as $movie) {
	
	$result = query("SELECT * FROM `actions_aliases` WHERE `title`='".$movie->title."';");
	if(mysql_num_rows($result)!=1) {
		$new_movies[] = $movie->title;
	}
	else {
		$result = mysql_fetch_array($result);
	
		foreach($movie->sessions->session as $session) {
			//print_r($session); exit;
			//print "<br>".$session->time;
			foreach($session->hall as $hall) {
				//print $hall['name'];
			
				$prices = array();
			
				foreach($hall->row as $row) {
				
					$prices[] = substr($row,0,strpos($row,"руб"));
				}

				$prices = array_unique($prices);
			
				$prices_text = implode("/",$prices);
				
				if(strpos($hall['name'],'VIP'))
					$prices_text = "VIP-".$prices_text;
			
				//print $session->time."-".$result['aid']."-".$prices_text."<br>";
				
				$shedule[substr($session->time,0,strpos($session->time," "))][] = array($session->time,$result['aid'],$prices_text);
			}

		}
	}
}

//var_dump($shedule);

if(sizeof($new_movies)>0) {
	mail("editor@afish-ka.ru","New movies on afish-ka.ru for Limonad",implode("\n",$new_movies));
	die("New movie is found, adding it to the DB by administrator is required!");
}
else {
	foreach($shedule as $day => $data) {
		
		$data_text = json_encode($data);
		//print "SELECT * FROM `shedule_limonad_cache` WHERE `date`='".$day."' AND `data`='".$data_text."';";
		$result = query("SELECT * FROM `shedule_limonad_cache` WHERE `date`='".$day."' AND `data`='".$data_text."';");
		
		
		print $day.": ".mysql_num_rows($result)."<br>";
		
		if(mysql_num_rows($result)==0) {
			
			$result2 = query("SELECT * FROM `shedule_limonad_cache` WHERE `date`='".$day."';");
			
			if(mysql_num_rows($result2)==0) {
				query("INSERT INTO `shedule_limonad_cache` (`id`, `date`, `data`, `added`) VALUES (NULL, '".$day."', '".$data_text."', NOW());");
			}
			else {
				query("UPDATE `shedule_limonad_cache` SET `data` = '".$data_text."', `updated`=NOW() WHERE `date` = '".$day."';");
			}
			
			query("DELETE FROM `shedule` WHERE `fid`=2 AND date(`datetime`)='".$day."';");
			
			foreach($data as $row) {			
				query("INSERT INTO `shedule` (`id`, `fid`, `aid`, `datetime`, `price`, `added`) VALUES (NULL, 2, '".$row[1]."', '".$row[0]."', '".$row[2]."', NOW());");
			}
		}
	}
}



?>