Ejemplo n.º 1
0
/**
 * @param $period
 * @param $gain
 * @param $hour_lable
 * @param $sw
 */
function set_night_cam($period, $gain, $hour_lable, $sw)
{
    //	 if ((date("Hi") == $period) && (file_get_contents("st") == 'on')){
    if ($period <= date('Hi') && date('Hi') <= $period + 1 && file_get_contents("./st") == 'on') {
        // echo "wer";
        global $ip_adresses;
        global $cam_gain;
        foreach ($ip_adresses as $ip_adress) {
            if (!file_exists($ip_adress['file'])) {
                file_put_contents($ip_adress['file'], '');
            }
            if (file_get_contents($ip_adress['file']) != $hour_lable) {
                //				echo "add";
                log_cam("-----------------------------------------");
                if (ssh_exec($ip_adress['ip'], $ip_adress['port_cam'], "settings/night_vision?set={$sw}")) {
                    log_cam("Night: Sent to {$ip_adress['ip']} port {$ip_adress['port_cam']} [ night_{$sw} ]");
                    // echo date('H:i:s')." - "."Night: Sent to {$ip_adress['ip']} port {$ip_adress['port_cam']} [ night_{$sw} ] <br>";
                    if ($sw === 'on') {
                        $gain = $cam_gain[$hour_lable][$ip_adress['name']];
                        if (ssh_exec($ip_adress['ip'], $ip_adress['port_cam'], "settings/night_vision_gain?set={$gain}")) {
                            log_cam("Night: Sent to {$ip_adress['ip']} port {$ip_adress['port_cam']} [ night_gain = {$gain} ]");
                            // echo date('H:i:s')." - "."Sent to {$ip_adress['ip']} port {$ip_adress['port_cam']} [ night_gain = {$gain} ]<br />";
                            file_put_contents($ip_adress['file'], $hour_lable);
                        } else {
                            log_cam("Night: Error sent to {$ip_adress['ip']} port {$ip_adress['port_cam']} [ night_gain = {$gain} ]", 'error');
                            // echo date('H:i:s')." - "."Night: Error sent to {$ip_adress['ip']} port {$ip_adress['port_cam']} [ night_gain = {$gain} ]<br>";
                        }
                    } elseif ($sw === 'off') {
                        file_put_contents($ip_adress['file'], $hour_lable);
                    }
                } else {
                    log_cam("Night: Error sent to {$ip_adress['ip']} port {$ip_adress['port_cam']} [ night_{$sw} ]", 'error');
                    // echo date('H:i:s')." - "."<b>Night: Error sent to {$ip_adress['ip']} port {$ip_adress['port_cam']} [ night_{$sw} ]</b><br>";
                }
            }
        }
    }
}
Ejemplo n.º 2
0
<?php

include "ssh_cam.php";
//header('Refresh:1;url=./cam.php');
header('Location: cam.php');
$file_name = 'st';
if (isset($_POST['status'])) {
    $st = $_POST['status'];
    if ($st == "off" || $st == "on") {
        file_put_contents($file_name, $st);
        foreach ($ip_adresses as $ip_adress) {
            log_cam("-----------------------------------------");
            if (ssh_exec($ip_adress['ip'], $ip_adress['port_ssh'], "index.php?status={$st}")) {
                log_cam("Webcam {$ip_adress['ip']} port {$ip_adress['port_ssh']} is [ {$st} ]", 'send');
                // echo date('H:i:s')." - "."Webcam {$ip_adress['ip']} port {$ip_adress['port_ssh']} is [ {$st} ]<br />";
            } else {
                log_cam("Error [ send {$st} ] Webcam {$ip_adress['ip']} port {$ip_adress['port_ssh']}", 'error');
                // echo date('H:i:s')." - "."<b>Error [ send {$st} ] Webcam {$ip_adress['ip']} port {$ip_adress['port_ssh']}</b><br />";
            }
        }
    }
}
//echo file_get_contents($file_name);