}

  $file = `cat $group_thread_conf`;
  $video = ''; 
  $sp = split("\n",$file); 
  for ($i=count($sp)-1 ; $i >= 0 ; $i--){
    $val = trim($sp[$i]);
    if ($val != ""){
       $id_g = split('=',$val);
       $id = $id_g[0];
       $dt = `cat $thread_path/thread$id.conf | head -1`;
       $on = `cat $thread_path/thread$id.conf | grep "#on_movie_start"`;
       $on = ($on == '' ? 'checked' : '');
       $dt_val = split(' ',$dt);
       $type = ($dt_val[0] == "videodevice" ? "dev" : "ip");
       $video .= gen_video($id,$id_g[1],$type,$dt_val[0],$dt_val[1],$on);
    }
  }
?>
<div class="setting_div" >
  <font size="2">
  <fieldset class="fieldset_setting">
    <legend class="legend_setting">Add / Edit Video Setting</legend>
      <fieldset class="fieldset_setting" style="width:90%">
        <!--Add video--!>
        <div class="div_in_leg">
          <label><b>New Video.</b></label><br />
          <label>Select video mode : </label>
          <input id="dev_id" value="dev" name="mode" type="radio" safari=1 checked>
          <label>Device</label>
          <input id="ip_id" value="ip" name="mode" type="radio" safari=1>
Пример #2
0
function add_video()
{
    global $FILE_GROUP_THREAD;
    global $PATH_THREAD;
    $type = trim($_POST['type']);
    $d_ip = trim($_POST['dev_ip']);
    $name = trim($_POST['name']);
    $port = trim($_POST['port']);
    $user = trim($_POST['user']);
    $pass = trim($_POST['password']);
    $group = trim($_POST['group']);
    $user_pass = $user == '' && $pass == '' ? "#netcam_userpass :"******"netcam_userpass {$user}:{$pass}";
    $text = $type == "dev" ? 'videodevice ' . $d_ip . "\n" : 'netcam_url ' . $d_ip . "\n" . $user_pass . "\n";
    $text .= 'text_left ' . $name . "\n";
    $text .= 'webcam_port ' . $port . "\n";
    $text .= isset($_POST['alert']) ? 'on_movie_start /usr/local/bin/motion-web-alert-plugin/alert.sh %f' : '#on_movie_start /usr/local/bin/motion-web-alert-plugin/alert.sh %f';
    $num = split(' ', $name);
    $num = $num[1];
    if (`cat {$FILE_GROUP_THREAD} | cut -b1-2 | grep "^{$num}\$"` != '') {
        exit;
    }
    $msg = "{$num}={$group}";
    `echo "{$msg}" >> {$FILE_GROUP_THREAD}`;
    `echo "{$text}" > {$PATH_THREAD}/thread{$num}.conf`;
    /*add /etc/motion/motion.conf*/
    `echo "thread {$PATH_THREAD}/thread{$num}.conf" >> /etc/motion/motion.conf`;
    `/usr/local/bin/motion-web-alert-plugin/motion-restart.sh`;
    echo gen_video($num, $group, $type, $d_ip, isset($_POST['alert']) ? 'checked' : '');
}