sudo apt-get install apache2 php5 mysql-server libapache2-mod-php5 libapache2-mod-auth-mysql php5-mysql ffmpeg
<?php $dbhost = "localhost"; $dbname = "name"; $dbuser = "user"; $dbpass = "password"; mysql_connect($dbhost, $dbuser, $dbpass); mysql_query("set character_set_client='utf8'"); mysql_query("set character_set_results='utf8'"); mysql_query("set collation_connection='utf8_general_ci'"); mysql_select_db($dbname); ?>
<?php include "dbinit.php"; $query = "SELECT * FROM `name`"; $result = mysql_query($query); if (!$result) { print "<center>:" . mysql_error() . "</center>"; } elseif (mysql_num_rows($result) == 0) { print ""; } else { $rows = array(); while ($row = mysql_fetch_assoc($result)) { $rows[]= $row; } foreach($rows as $row) { echo exec('/usr/bin/timeout 20s /usr/bin/time -f %U -o /var/www/tmp/'.$row['name'].'.txt /usr/bin/ffmpeg -i udp://@'.$row['mcast'].' -y -f image2 -sameq -t 0.001 -ss 00:00:4 -s 120*80 /var/www/screen/'.$row['mcast'].'.jpg'); echo exec('/bin/cp -f /var/www/tmp/'.$row['mcast'].'.txt /var/www/rez/'); } ?>
/usr/bin/time -f %U -o /var/www/tmp/'.$row['name'].'.txt
/usr/bin/ffmpeg -i udp://@'.$row['name'].' -y -f image2 -sameq -t 0.001 -ss 00:00:4 -s 120*80 /var/www/screen/'.$row['name'].'.jpg
<?php $lines = file ('rez/'.$row['mcast'].'.txt'); if ($lines[0]=='') { $last_result=mysql_result(mysql_query("select state from name where name='".$row['name']."' order by date desc limit 0,1"),0); if($last_result=='true') { $query = "INSERT INTO `name` (`date`, `name`, `state`) VALUES ('{$date}', '{$row['name']}', 'false');"; mysql_query($query) or die(mysql_error()); } foreach ($A as $v) { echo exec('/usr/bin/perl /usr/local/scripts/jabber_alert.pl -e '.$v.'@jabber.server -n tv@jabber.server -w password -y '.translitIt ($row['name']).'-'.$row['mcast'].' << "EOF" read -d "^D" input'); } } else { $last_result=mysql_result(mysql_query("select state from name where name='".$row['name']."' order by date desc limit 0,1"),0); echo $last_result; if($last_result=='false') { $query = "INSERT INTO `name` (`date`, `name`, `state`) VALUES ('{$date}', '{$row['name']}', 'true');"; mysql_query($query) or die(mysql_error()); } echo $row['name']." ". $lines[1]." "; } ?>
echo exec('/usr/bin/perl /usr/local/scripts/jabber_alert.pl -e '.$v.'@jabber.server -n tv@jabber.server -w password -y '.translitIt ($row['name']).'-'.$row['mcast'].' << "EOF" read -d "^D" input');
<?php foreach($rows as $row) { $work=mysql_result(mysql_query("select date from name where date>'".$row['date']." order by date limit 0,1'"),0); $date1 = new DateTime($work); $date2 = new DateTime($row['date']); $interval = $date2->diff($date1); if($work=="") { $style="red"; } else { $style="";} echo "<tr><td style='color:".$style."'><font color='red'>".$row['date']; if($work!="") { echo "</font> - <font color='green'>".$work."</font>"; } echo "</td><td>"; if($interval->format("%h") != 0) { echo $interval->format("%h. "); } echo $interval->format("%i. %s.")."</td><td style='color:".$style."'>".$row['name']."</td></tr>"; } ?>
Source: https://habr.com/ru/post/145151/
All Articles