コード例 #1
0
ファイル: Event.php プロジェクト: schrorg/ZoneMinder
 public function __construct($IdOrRow)
 {
     $row = NULL;
     if ($IdOrRow) {
         if (is_integer($IdOrRow) or is_numeric($IdOrRow)) {
             $row = dbFetchOne('SELECT *,unix_timestamp(StartTime) as Time FROM Events WHERE Id=?', NULL, array($IdOrRow));
             if (!$row) {
                 Error("Unable to load Event record for Id=" . $IdOrRow);
             }
         } elseif (is_array($IdOrRow)) {
             $row = $IdOrRow;
         } else {
             Error("Unknown argument passed to Event Constructor ({$IdOrRow})");
             return;
         }
     }
     # end if isset($IdOrRow)
     if ($row) {
         foreach ($row as $k => $v) {
             $this->{$k} = $v;
         }
     } else {
         Error("No row for Event " . $IdOrRow);
     }
 }
コード例 #2
0
ファイル: Frame.php プロジェクト: schrorg/ZoneMinder
 public function __construct($IdOrRow)
 {
     $row = NULL;
     if ($IdOrRow) {
         if (is_integer($IdOrRow) or is_numeric($IdOrRow)) {
             $row = dbFetchOne('SELECT * FROM Frames WHERE Id=?', NULL, array($IdOrRow));
             if (!$row) {
                 Error("Unable to load Frame record for Id=" . $IdOrRow);
             }
         } elseif (is_array($IdOrRow)) {
             $row = $IdOrRow;
         } else {
             Error("Unknown argument passed to Frame Constructor ({$IdOrRow})");
             return;
         }
     }
     # end if isset($IdOrRow)
     if ($row) {
         foreach ($row as $k => $v) {
             $this->{$k} = $v;
         }
     } else {
         Error("No row for Frame " . $IdOrRow);
     }
 }
コード例 #3
0
ファイル: Monitor.php プロジェクト: schrorg/ZoneMinder
 public function __construct($IdOrRow)
 {
     $row = NULL;
     if ($IdOrRow) {
         if (is_integer($IdOrRow) or is_numeric($IdOrRow)) {
             $row = dbFetchOne('SELECT * FROM Monitors WHERE Id=?', NULL, array($IdOrRow));
             if (!$row) {
                 Error("Unable to load Server record for Id=" . $IdOrRow);
             }
         } elseif (is_array($IdOrRow)) {
             $row = $IdOrRow;
         } else {
             Error("Unknown argument passed to Monitor Constructor ({$IdOrRow})");
             return;
         }
     }
     # end if isset($IdOrRow)
     if ($row) {
         foreach ($row as $k => $v) {
             $this->{$k} = $v;
         }
         if ($this->{'Controllable'}) {
             $s = dbFetchOne('SELECT * FROM Controls WHERE Id=?', NULL, array($this->{'ControlId'}));
             foreach ($s as $k => $v) {
                 if ($k == 'Id') {
                     continue;
                 }
                 $this->{$k} = $v;
             }
         }
     } else {
         Error("No row for Monitor " . $IdOrRow);
     }
 }
コード例 #4
0
ファイル: functions.php プロジェクト: OverByThere/modern
function getUserDefaultPresetId($userId)
{
    $query = "SELECT * FROM Users WHERE Id='{$userId}'";
    $result = dbFetchOne($query);
    if (array_key_exists('defaultPreset', $result)) {
        return $result['defaultPreset'];
    } else {
        return false;
    }
}
コード例 #5
0
ファイル: Invoice_model.php プロジェクト: nmadipati/si-ksc
 function total()
 {
     $sql = "select count(id) total from " . $this->table;
     $data = dbFetchOne($sql);
     return isset($data['total']) ? $data['total'] : false;
     if (!$this->db->simple_query($sql)) {
         logCreate('sql:' . $sql . '|' . $this->db->error(), 'error');
         return false;
     } else {
         $query = $this->db->query($sql);
         if ($query->num_rows() > 0) {
             $row = $query->row_array();
             return $row['total'];
         }
     }
     return false;
 }
コード例 #6
0
ファイル: Storage.php プロジェクト: schrorg/ZoneMinder
 public function __construct($IdOrRow = NULL)
 {
     $row = NULL;
     if ($IdOrRow) {
         if (is_integer($IdOrRow) or is_numeric($IdOrRow)) {
             $row = dbFetchOne('SELECT * FROM Storage WHERE Id=?', NULL, array($IdOrRow));
             if (!$row) {
                 Error("Unable to load Storage record for Id=" . $IdOrRow);
             }
         } elseif (is_array($IdOrRow)) {
             $row = $IdOrRow;
         }
     }
     if ($row) {
         foreach ($row as $k => $v) {
             $this->{$k} = $v;
         }
     } else {
         $this->{'Name'} = '';
         $this->{'Path'} = '';
     }
 }
コード例 #7
0
ファイル: db_helper.php プロジェクト: nmadipati/secure
 function dbId($name = "id", $start = 10, $counter = 1)
 {
     $CI =& get_instance();
     $CI->load->dbforge();
     if ($name == '') {
         $name = 'id';
     }
     if ($name != 'id') {
         $name .= "_id";
     } else {
     }
     if (!$CI->db->table_exists($name)) {
         $CI->dbforge->add_field('id');
         $CI->dbforge->create_table($name, TRUE);
         $str = $CI->db->last_query();
         logConfig("create table:{$str}", 'logDB');
     } else {
     }
     $CI->db->reset_query();
     $sql = "select count(id) c, max(id) max from {$name}";
     $data = dbFetchOne($sql);
     if ($data['c'] == 0) {
         $data = array('id' => $start);
         $sql = $CI->db->insert_string($name, $data);
         dbQuery($sql, 1);
         $num = $start;
     } else {
         $num = $data['max'] + $counter;
         $where = "id=" . $data['max'];
         $data = array('id' => $num);
         $sql = $CI->db->update_string($name, $data, $where);
         dbQuery($sql, 1);
     }
     $str = $CI->db->last_query();
     logConfig("dbId sql:{$str}", 'logDB');
     $CI->db->reset_query();
     return $num;
 }
コード例 #8
0
ファイル: cycle.php プロジェクト: moeiscool/ZoneMinder-video
    return;
}
if (empty($_REQUEST['mode'])) {
    if (canStream()) {
        $mode = "stream";
    } else {
        $mode = "still";
    }
} else {
    $mode = validHtmlStr($_REQUEST['mode']);
}
$group = '';
$groupSql = '';
if (!empty($_REQUEST['group'])) {
    $group = validInt($_REQUEST['group']);
    $row = dbFetchOne('SELECT * FROM Groups WHERE Id = ?', NULL, array($group));
    $groupSql = " and find_in_set( Id, '" . $row['MonitorIds'] . "' )";
}
$sql = "SELECT * FROM Monitors WHERE Function != 'None'{$groupSql} ORDER BY Sequence";
$monitors = array();
$monIdx = 0;
foreach (dbFetchAll($sql) as $row) {
    if (!visibleMonitor($row['Id'])) {
        continue;
    }
    if (isset($_REQUEST['mid']) && $row['Id'] == $_REQUEST['mid']) {
        $monIdx = count($monitors);
    }
    $row['ScaledWidth'] = reScale($row['Width'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
    $row['ScaledHeight'] = reScale($row['Height'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
    $monitors[] = $row;
コード例 #9
0
ファイル: frame.php プロジェクト: mondychan/modern
    $view = "error";
    return;
}
$eid = validInt($_REQUEST['eid']);
if (!empty($_REQUEST['fid'])) {
    $fid = validInt($_REQUEST['fid']);
}
$sql = "select E.*,M.Name as MonitorName,M.Width,M.Height,M.DefaultScale from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = '" . dbEscape($eid) . "'";
$event = dbFetchOne($sql);
if (!empty($fid)) {
    $sql = "select * from Frames where EventId = '" . dbEscape($eid) . "' and FrameId = '" . dbEscape($fid) . "'";
    if (!($frame = dbFetchOne($sql))) {
        $frame = array('FrameId' => $fid, 'Type' => 'Normal', 'Score' => 0);
    }
} else {
    $frame = dbFetchOne("select * from Frames where EventId = '" . dbEscape($eid) . "' and Score = '" . $event['MaxScore'] . "'");
}
$maxFid = $event['Frames'];
$firstFid = 1;
$prevFid = $frame['FrameId'] - 1;
$nextFid = $frame['FrameId'] + 1;
$lastFid = $maxFid;
$alarmFrame = $frame['Type'] == 'Alarm';
if (isset($_REQUEST['scale'])) {
    $scale = validInt($_REQUEST['scale']);
} else {
    $scale = max(reScale(SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE), SCALE_BASE);
}
$imageData = getImageSrc($event, $frame, $scale, isset($_REQUEST['show']) && $_REQUEST['show'] == "capt");
$imagePath = $imageData['thumbPath'];
$eventPath = $imageData['eventPath'];
コード例 #10
0
function exportFileList($eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc)
{
    if (canView('Events') && $eid) {
        $sql = 'SELECT E.Id,E.MonitorId,M.Name AS MonitorName,M.Width,M.Height,E.Name,E.Cause,E.Notes,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE E.Id = ?';
        $event = dbFetchOne($sql, NULL, array($eid));
        $eventPath = ZM_DIR_EVENTS . '/' . mygetEventPath($event);
        $files = array();
        if ($dir = opendir($eventPath)) {
            while (($file = readdir($dir)) !== false) {
                if (is_file($eventPath . "/" . $file)) {
                    $files[$file] = $file;
                }
            }
            closedir($dir);
        }
        $exportFileList = array();
        if ($exportDetail) {
            $file = "zmEventDetail.html";
            if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
                Fatal("Can't open event detail export file '{$file}'");
            }
            fwrite($fp, exportEventDetail($event, $exportFrames, $exportImages));
            fclose($fp);
            $exportFileList[$file] = $eventPath . "/" . $file;
        }
        if ($exportFrames) {
            $file = "zmEventFrames.html";
            if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
                Fatal("Can't open event frames export file '{$file}'");
            }
            fwrite($fp, exportEventFrames($event, $exportDetail, $exportImages));
            fclose($fp);
            $exportFileList[$file] = $eventPath . "/" . $file;
        }
        if ($exportImages) {
            $filesLeft = array();
            $myfilelist = array();
            foreach ($files as $file) {
                if (preg_match("/-(?:capture|analyse).jpg\$/", $file)) {
                    $exportFileList[$file] = $eventPath . "/" . $file;
                    $myfilelist[$file] = $eventPath . "/" . $file;
                } else {
                    $filesLeft[$file] = $file;
                }
            }
            $files = $filesLeft;
            // create an image slider
            if (!empty($myfilelist)) {
                $file = "zmEventImages.html";
                if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
                    Fatal("Can't open event images export file '{$file}'");
                }
                fwrite($fp, exportEventImages($event, $exportDetail, $exportFrames, $myfilelist));
                fclose($fp);
                $exportFileList[$file] = $eventPath . "/" . $file;
            }
        }
        if ($exportVideo) {
            $filesLeft = array();
            foreach ($files as $file) {
                if (preg_match("/\\.(?:mpg|mpeg|avi|asf|3gp)\$/", $file)) {
                    $exportFileList[$file] = $eventPath . "/" . $file;
                } else {
                    $filesLeft[$file] = $file;
                }
            }
            $files = $filesLeft;
        }
        if ($exportMisc) {
            foreach ($files as $file) {
                $exportFileList[$file] = $eventPath . "/" . $file;
            }
            $files = array();
        }
    }
    return array_values($exportFileList);
}
コード例 #11
0
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
if (!canView('Stream')) {
    $view = "error";
    return;
}
$groupSql = "";
if (!empty($_REQUEST['group'])) {
    $row = dbFetchOne('select * from Groups where Id = ?', NULL, array($_REQUEST['group']));
    $sql = "select * from Monitors where Function != 'None' and find_in_set( Id, '" . $row['MonitorIds'] . "' ) order by Sequence";
} else {
    $sql = "select * from Monitors where Function != 'None' order by Sequence";
}
$maxWidth = 0;
$maxHeight = 0;
$showControl = false;
$index = 0;
$monitors = array();
foreach (dbFetchAll($sql) as $row) {
    if (!visibleMonitor($row['Id'])) {
        continue;
    }
    if (isset($_REQUEST['scale'])) {
        $scale = validInt($_REQUEST['scale']);
コード例 #12
0
ファイル: login.php プロジェクト: OverByThere/modern
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
if (isset($_SESSION['user'])) {
    if (!isset($_POST['view'])) {
        $_POST['view'] = "playback";
    }
    $response = dbFetchOne("SELECT * FROM Users WHERE Id={$_SESSION['user']['Id']} LIMIT 1");
    if (!$response) {
        $error = "ERROR: Failed to fully autheticate user, please contact your system administrator!";
    } elseif (isset($_SESSION['user']['Username'])) {
        header("Location: ?view={$_POST['view']}");
    }
}
xhtmlHeaders(__FILE__, $SLANG['Login']);
?>
<body class="zm">
  
  <div class="view-wrapper"> <!-- begin view-wrapper -->

    <div class="container">
    <form name="loginForm" id="loginForm" method="post" class="form-signin" action="<?php 
echo $_SERVER['PHP_SELF'];
コード例 #13
0
ファイル: montage.php プロジェクト: ardiqghenatya/koptel2
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
if (!canView('Stream')) {
    $view = "error";
    return;
}
$groupSql = "";
if (!empty($_REQUEST['group'])) {
    $sql = "select * from Groups where Id = '" . dbEscape($_REQUEST['group']) . "'";
    $row = dbFetchOne($sql);
    $groupSql = " and find_in_set( Id, '" . $row['MonitorIds'] . "' )";
}
$sql = "select * from Monitors where Function != 'None'{$groupSql} order by Sequence";
$maxWidth = 0;
$maxHeight = 0;
$showControl = false;
$index = 0;
$monitors = array();
foreach (dbFetchAll($sql) as $row) {
    if (!visibleMonitor($row['Id'])) {
        continue;
    }
    if (isset($_REQUEST['scale'])) {
        $scale = validInt($_REQUEST['scale']);
    } else {
コード例 #14
0
ファイル: console.php プロジェクト: ardiqghenatya/koptel2
        foreach (dbFetchAll(escapeSql($eventsSql)) as $event) {
            xml_tag_sec("EVENT", 1);
            xml_tag_val("ID", $event['Id']);
            xml_tag_val("NAME", $event['Name']);
            xml_tag_val("TIME", strftime(STRF_FMT_DATETIME_SHORTER, strtotime($event['StartTime'])));
            xml_tag_val("DURATION", $event['Length']);
            xml_tag_val("FRAMES", $event['Frames']);
            xml_tag_val("FPS", $event['Length'] > 0 ? ceil($event['Frames'] / $event['Length']) : 0);
            xml_tag_val("TOTSCORE", $event['TotScore']);
            xml_tag_val("AVGSCORE", $event['AvgScore']);
            xml_tag_val("MAXSCORE", $event['MaxScore']);
            /* Grab the max frame-id from Frames table. If AlarmFrames = 0, don't try
             * to grab any frames, and just signal the max frame index as index 0 */
            $fridx = 1;
            $alarmFrames = 1;
            if ($event['AlarmFrames']) {
                $framesSql = "select FrameId from Frames where (Type = 'Alarm') and (EventId = " . $event['Id'] . ") order by Score desc limit 1";
                $fr = dbFetchOne($framesSql);
                $fridx = $fr['FrameId'];
                $alarmFrames = $event['AlarmFrames'];
            }
            xml_tag_val("ALARMFRAMES", $alarmFrames);
            xml_tag_val("MAXFRAMEID", $fridx);
            xml_tag_sec("EVENT", 0);
        }
    }
    xml_tag_sec("EVENTS", 0);
    xml_tag_sec("MONITOR", 0);
}
xml_tag_sec("MONITOR_LIST", 0);
xml_tag_sec("ZM_XML", 0);
コード例 #15
0
ファイル: frames.php プロジェクト: ardiqghenatya/koptel2
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
if (!canView('Events')) {
    $view = "error";
    return;
}
$sql = "select E.*,M.Name as MonitorName,M.Width,M.Height from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = '" . dbEscape($_REQUEST['eid']) . "'";
$event = dbFetchOne($sql);
$sql = "select *, unix_timestamp( TimeStamp ) as UnixTimeStamp from Frames where EventID = '" . dbEscape($_REQUEST['eid']) . "' order by FrameId";
$frames = dbFetchAll($sql);
$focusWindow = true;
xhtmlHeaders(__FILE__, $SLANG['Frames'] . " - " . $event['Id']);
?>
<body>
  <div id="page">
    <div id="header">
      <div id="headerButtons"><a href="#" onclick="closeWindow();"><?php 
echo $SLANG['Close'];
?>
</a></div>
      <h2><?php 
echo $SLANG['Frames'];
?>
コード例 #16
0
ファイル: montage.php プロジェクト: bill-mcgonigle/ZoneMinder
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
if (!canView('Stream')) {
    $_REQUEST['view'] = "error";
    return;
}
$imagesPerLine = 2;
$sql = "select * from Groups where Name = 'Mobile'";
$group = dbFetchOne($sql);
$sql = "select * from Monitors where Function != 'None' order by Sequence";
$monitors = array();
$maxWidth = 0;
$maxHeight = 0;
foreach (dbFetchAll($sql) as $row) {
    if (!visibleMonitor($row['Id'])) {
        continue;
    }
    if ($group && $group['MonitorIds'] && !in_array($row['Id'], explode(',', $group['MonitorIds']))) {
        continue;
    }
    if ($maxWidth < $row['Width']) {
        $maxWidth = $row['Width'];
    }
    if ($maxHeight < $row['Height']) {
コード例 #17
0
    }
}
ksort($monitorIds, SORT_NUMERIC);
ksort($monEventSlots, SORT_NUMERIC);
ksort($monFrameSlots, SORT_NUMERIC);
// No longer needed?
if (false) {
    // Add on missing frames
    foreach (array_keys($monFrameSlots) as $monitorId) {
        unset($currFrameSlots);
        $currFrameSlots =& $monFrameSlots[$monitorId];
        for ($i = 0; $i < $chart['graph']['width']; $i++) {
            if (isset($currFrameSlots[$i])) {
                if (!isset($currFrameSlots[$i]['frame'])) {
                    $framesSql = "select FrameId,Score from Frames where EventId = ? and Score > 0 order by FrameId limit 1";
                    $currFrameSlots[$i]['frame'] = dbFetchOne($framesSql, NULL, array($currFrameSlots[$i]['event']['Id']));
                }
            }
        }
    }
}
$chart['data']['y']['range'] = $chart['data']['y']['hi'] - $chart['data']['y']['lo'] + 1;
$chart['data']['y']['density'] = $chart['data']['y']['range'] / $chart['graph']['height'];
$majYScale = getYScale($chart['data']['y']['range'], $chart['grid']['y']['major']['min'], $chart['grid']['y']['major']['max']);
$maxWidth = 0;
$maxHeight = 0;
foreach (array_keys($monitorIds) as $monitorId) {
    if ($maxWidth < $monitors[$monitorId]['Width']) {
        $maxWidth = $monitors[$monitorId]['Width'];
    }
    if ($maxHeight < $monitors[$monitorId]['Height']) {
コード例 #18
0
$sql = "SELECT * FROM Monitors WHERE Function != 'None' AND Controllable = 1{$groupSql} ORDER BY Sequence";
$mids = array();
foreach (dbFetchAll($sql) as $row) {
    if (!visibleMonitor($row['Id'])) {
        continue;
    }
    if (empty($mid)) {
        $mid = $row['Id'];
    }
    $mids[$row['Id']] = $row['Name'];
}
foreach (getSkinIncludes('includes/control_functions.php') as $includeFile) {
    require_once $includeFile;
}
$sql = 'SELECT C.*,M.* FROM Monitors AS M INNER JOIN Controls AS C ON (M.ControlId = C.Id ) WHERE M.Id = ?';
$monitor = dbFetchOne($sql, NULL, array($mid));
$focusWindow = true;
xhtmlHeaders(__FILE__, $SLANG['Control']);
?>
<body>
  <div id="page">
    <div id="header">
      <div id="headerButtons">
        <a href="#" onclick="closeWindow();"><?php 
echo $SLANG['Close'];
?>
</a>
      </div>
      <h2><?php 
echo $SLANG['Control'];
?>
コード例 #19
0
ファイル: database.php プロジェクト: ardiqghenatya/koptel2
function dbFetchGroup($gid)
{
    return dbFetchOne("select * from Groups where Id = '" . dbEscape($gid) . "'");
}
コード例 #20
0
ファイル: plugin.php プロジェクト: rodoviario/ZoneMinder
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
if (!canView('Monitors')) {
    $view = "error";
    return;
}
$mid = validInt($_REQUEST['mid']);
$zid = !empty($_REQUEST['zid']) ? validInt($_REQUEST['zid']) : 0;
if ($zid > 0) {
    $newZone = dbFetchOne('SELECT * FROM Zones WHERE MonitorId = ? AND Id = ?', NULL, array($mid, $zid));
} else {
    $view = "error";
    return;
}
$monitor = dbFetchMonitor($mid);
$plugin = $_REQUEST['pl'];
$plugin_path = dirname(ZM_PLUGINS_CONFIG_PATH) . "/" . $plugin;
$focusWindow = true;
xhtmlHeaders(__FILE__, translate('Plugin'));
$pluginOptions = array('Enabled' => array('Type' => 'select', 'Name' => 'Enabled', 'Choices' => 'yes,no', 'Value' => 'no'));
$optionNames = array();
if (file_exists($plugin_path . "/config.php")) {
    include_once $plugin_path . "/config.php";
}
$sql = 'SELECT * FROM PluginsConfig WHERE MonitorId=? AND ZoneId=? AND pluginName=?';
コード例 #21
0
ファイル: actions.php プロジェクト: ralfoide/ZoneMinder
         }
         if (!empty($_REQUEST['gid'])) {
             dbQuery("delete from Groups where Id = ?", array($_REQUEST['gid']));
             if (isset($_COOKIE['zmGroup'])) {
                 if ($_REQUEST['gid'] == $_COOKIE['zmGroup']) {
                     unset($_COOKIE['zmGroup']);
                     setcookie("zmGroup", "", time() - 3600 * 24 * 2);
                     $refreshParent = true;
                 }
             }
         }
     }
 } else {
     if (ZM_USER_SELF_EDIT && $action == "user") {
         $uid = $user['Id'];
         $dbUser = dbFetchOne("select Id, Password, Language from Users where Id = ?", NULL, array($uid));
         $types = array();
         $changes = getFormChanges($dbUser, $_REQUEST['newUser'], $types);
         if (!empty($_REQUEST['newUser']['Password'])) {
             $changes['Password'] = "******" . dbEscape($_REQUEST['newUser']['Password']) . ")";
         } else {
             unset($changes['Password']);
         }
         if (count($changes)) {
             dbQuery("update Users set " . implode(", ", $changes) . " where Id=?", array($uid));
             $refreshParent = true;
         }
         $view = 'none';
     }
 }
 if ($action == "reset") {
コード例 #22
0
ファイル: status.php プロジェクト: bill-mcgonigle/ZoneMinder
function getNearEvents()
{
    global $user, $sortColumn, $sortOrder;
    $eventId = $_REQUEST['id'];
    $event = dbFetchOne('select * from Events where Id = ?', NULL, array($eventId));
    parseFilter($_REQUEST['filter']);
    parseSort();
    if ($user['MonitorIds']) {
        $midSql = " and MonitorId in (" . join(",", preg_split('/["\'\\s]*,["\'\\s]*/', $user['MonitorIds'])) . ")";
    } else {
        $midSql = '';
    }
    $sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where {$sortColumn} " . ($sortOrder == 'asc' ? '<=' : '>=') . " '" . $event[$_REQUEST['sort_field']] . "'" . $_REQUEST['filter']['sql'] . $midSql . " order by {$sortColumn} " . ($sortOrder == 'asc' ? 'desc' : 'asc');
    $result = dbQuery($sql);
    while ($id = dbFetchNext($result, 'Id')) {
        if ($id == $eventId) {
            $prevEvent = dbFetchNext($result);
            break;
        }
    }
    $sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where {$sortColumn} " . ($sortOrder == 'asc' ? '>=' : '<=') . " '" . $event[$_REQUEST['sort_field']] . "'" . $_REQUEST['filter']['sql'] . $midSql . " order by {$sortColumn} {$sortOrder}";
    $result = dbQuery($sql);
    while ($id = dbFetchNext($result, 'Id')) {
        if ($id == $eventId) {
            $nextEvent = dbFetchNext($result);
            break;
        }
    }
    $result = array('EventId' => $eventId);
    $result['PrevEventId'] = empty($prevEvent) ? 0 : $prevEvent['Id'];
    $result['NextEventId'] = empty($nextEvent) ? 0 : $nextEvent['Id'];
    $result['PrevEventDefVideoPath'] = empty($prevEvent) ? 0 : getEventDefaultVideoPath($prevEvent);
    $result['NextEventDefVideoPath'] = empty($nextEvent) ? 0 : getEventDefaultVideoPath($nextEvent);
    return $result;
}
コード例 #23
0
function dbFetchGroup($gid)
{
    return dbFetchOne("select * from Groups where Id = ?", NULL, array($gid));
}
コード例 #24
0
ファイル: monitor.php プロジェクト: jbudding/ZoneMinder
    }
} else {
    $newMonitor = $monitor;
    $newMonitor['Triggers'] = explode(',', isset($monitor['Triggers']) ? $monitor['Triggers'] : "");
    if (ZM_OPT_X10) {
        $newX10Monitor = $x10Monitor;
    }
}
if ($newMonitor['MaxFPS'] == '0.00') {
    $newMonitor['MaxFPS'] = '';
}
if ($newMonitor['AlarmMaxFPS'] == '0.00') {
    $newMonitor['AlarmMaxFPS'] = '';
}
if (!empty($_REQUEST['preset'])) {
    $preset = dbFetchOne('SELECT Type, Device, Channel, Format, Protocol, Method, Host, Port, Path, Width, Height, Palette, MaxFPS, Controllable, ControlId, ControlDevice, ControlAddress, DefaultRate, DefaultScale FROM MonitorPresets WHERE Id = ?', NULL, array($_REQUEST['preset']));
    foreach ($preset as $name => $value) {
        if (isset($value)) {
            $newMonitor[$name] = $value;
        }
    }
}
if (!empty($_REQUEST['probe'])) {
    $probe = unserialize(base64_decode($_REQUEST['probe']));
    foreach ($probe as $name => $value) {
        if (isset($value)) {
            $newMonitor[$name] = $value;
        }
    }
    if (ZM_HAS_V4L && $newMonitor['Type'] == 'Local') {
        $newMonitor['Palette'] = fourCC(substr($newMonitor['Palette'], 0, 1), substr($newMonitor['Palette'], 1, 1), substr($newMonitor['Palette'], 2, 1), substr($newMonitor['Palette'], 3, 1));
コード例 #25
0
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
if (!canView('Events')) {
    $_REQUEST['view'] = "error";
    return;
}
$event = dbFetchOne('select E.*,M.Name as MonitorName from Events as E, Monitors as M where E.Id = ? and E.MonitorId = M.Id', NULL, array($_REQUEST['eid']));
$frame = dbFetchOne('select * from Frames where EventID = ? and Score = ?', NULL, array($_REQUEST['eid'], $event['MaxScore']));
$scale = getDeviceScale($event['Width'], $event['Height'], 2.2);
$image1 = getImageSrc($event, 1, $scale);
if ($frame['Type'] == 'Alarm') {
    $image2 = getImageSrc($event, $frame['FrameId'], $scale);
} else {
    $image2 = getImageSrc($event, intval($event['Frames'] / 2), $scale);
}
xhtmlHeaders(__FILE__, translate('Event') . ' - ' . $_REQUEST['eid']);
?>
<body>
  <div id="page">
    <div id="content">
      <table id="contentTable" class="major">
        <tr>
          <th scope="row"><?php 
コード例 #26
0
ファイル: eventdetail.php プロジェクト: rodoviario/ZoneMinder
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
if (!canEdit('Events')) {
    $view = "error";
    return;
}
if (isset($_REQUEST['eid'])) {
    $mode = 'single';
    $eid = validInt($_REQUEST['eid']);
    $newEvent = dbFetchOne('SELECT E.* FROM Events AS E WHERE E.Id = ?', NULL, array($eid));
} elseif (isset($_REQUEST['eids'])) {
    $mode = 'multi';
    $sql = 'SELECT E.* FROM Events AS E WHERE ';
    $sqlWhere = array();
    $sqlValues = array();
    foreach ($_REQUEST['eids'] as $eid) {
        $sqlWhere[] = 'E.Id = ?';
        $sqlValues[] = $eid;
    }
    unset($eid);
    $sql .= join(" or ", $sqlWhere);
    foreach (dbFetchAll($sql, NULL, $sqlValues) as $row) {
        if (!isset($newEvent)) {
            $newEvent = $row;
        } else {
コード例 #27
0
ファイル: frame.php プロジェクト: rodoviario/ZoneMinder
    $view = "error";
    return;
}
$eid = validInt($_REQUEST['eid']);
if (!empty($_REQUEST['fid'])) {
    $fid = validInt($_REQUEST['fid']);
}
$sql = 'SELECT E.*,M.Name AS MonitorName,M.DefaultScale FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?';
$event = dbFetchOne($sql, NULL, array($eid));
if (!empty($fid)) {
    $sql = 'SELECT * FROM Frames WHERE EventId = ? AND FrameId = ?';
    if (!($frame = dbFetchOne($sql, NULL, array($eid, $fid)))) {
        $frame = array('FrameId' => $fid, 'Type' => 'Normal', 'Score' => 0);
    }
} else {
    $frame = dbFetchOne('SELECT * FROM Frames WHERE EventId = ? AND Score = ?', NULL, array($eid, $event['MaxScore']));
}
$maxFid = $event['Frames'];
$firstFid = 1;
$prevFid = $frame['FrameId'] - 1;
$nextFid = $frame['FrameId'] + 1;
$lastFid = $maxFid;
$alarmFrame = $frame['Type'] == 'Alarm';
if (isset($_REQUEST['scale'])) {
    $scale = validInt($_REQUEST['scale']);
} else {
    $scale = max(reScale(SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE), SCALE_BASE);
}
$imageData = getImageSrc($event, $frame, $scale, isset($_REQUEST['show']) && $_REQUEST['show'] == "capt");
$imagePath = $imageData['thumbPath'];
$eventPath = $imageData['eventPath'];
コード例 #28
0
ファイル: video.php プロジェクト: rodoviario/ZoneMinder
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
if (!canView('Events')) {
    $_REQUEST['view'] = "error";
    return;
}
if ($user['MonitorIds']) {
    $midSql = " and MonitorId in (" . join(",", preg_split('/["\'\\s]*,["\'\\s]*/', $user['MonitorIds'])) . ")";
} else {
    $midSql = '';
}
$sql = 'SELECT E.*,M.Name AS MonitorName,M.DefaultRate FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?' . $midSql;
$event = dbFetchOne($sql, NULL, array($_REQUEST['eid']));
$deviceWidth = isset($device) && !empty($device['width']) ? $device['width'] : DEVICE_WIDTH;
$deviceHeight = isset($device) && !empty($device['height']) ? $device['height'] : DEVICE_HEIGHT;
if ($deviceWidth >= 352 && $deviceHeight >= 288) {
    $videoSize = "352x288";
} elseif ($deviceWidth >= 176 && $deviceHeight >= 144) {
    $videoSize = "176x144";
} else {
    $videoSize = "128x96";
}
$eventWidth = $event['Width'];
$eventHeight = $event['Height'];
if (!isset($rate)) {
    $_REQUEST['rate'] = reScale(RATE_BASE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE);
}
$eventPath = ZM_DIR_EVENTS . '/' . getEventPath($event);
コード例 #29
0
ファイル: events.php プロジェクト: rodoviario/ZoneMinder
if ($_REQUEST['filter']['sql']) {
    $countSql .= $_REQUEST['filter']['sql'];
    $eventsSql .= $_REQUEST['filter']['sql'];
}
$eventsSql .= " ORDER BY {$sortColumn} {$sortOrder}";
if (isset($_REQUEST['page'])) {
    $page = validInt($_REQUEST['page']);
} else {
    $page = 0;
}
if (isset($_REQUEST['limit'])) {
    $limit = validInt($_REQUEST['limit']);
} else {
    $limit = 0;
}
$nEvents = dbFetchOne($countSql, 'EventCount');
if (!empty($limit) && $nEvents > $limit) {
    $nEvents = $limit;
}
$pages = (int) ceil($nEvents / ZM_WEB_EVENTS_PER_PAGE);
if ($pages > 1) {
    if (!empty($page)) {
        if ($page < 0) {
            $page = 1;
        }
        if ($page > $pages) {
            $page = $pages;
        }
    }
}
if (!empty($page)) {
コード例 #30
0
ファイル: console.php プロジェクト: kunkku/ZoneMinder
 }
 if ($monitors[$i]['Sequence'] > $maxSequence) {
     $maxSequence = $monitors[$i]['Sequence'];
 }
 $monitors[$i]['zmc'] = zmcStatus($monitors[$i]);
 $monitors[$i]['zma'] = zmaStatus($monitors[$i]);
 $monitors[$i]['ZoneCount'] = dbFetchOne('select count(Id) as ZoneCount from Zones where MonitorId = ?', 'ZoneCount', array($monitors[$i]['Id']));
 $counts = array();
 for ($j = 0; $j < count($eventCounts); $j++) {
     $filter = addFilterTerm($eventCounts[$j]['filter'], count($eventCounts[$j]['filter']['terms']), array("cnj" => "and", "attr" => "MonitorId", "op" => "=", "val" => $monitors[$i]['Id']));
     parseFilter($filter);
     $counts[] = "count(if(1" . $filter['sql'] . ",1,NULL)) as EventCount{$j}";
     $monitors[$i]['eventCounts'][$j]['filter'] = $filter;
 }
 $sql = "select " . join($counts, ", ") . " from Events as E where MonitorId = ?";
 $counts = dbFetchOne($sql, NULL, array($monitors[$i]['Id']));
 if ($monitors[$i]['Function'] != 'None') {
     $cycleCount++;
     $scaleWidth = reScale($monitors[$i]['Width'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
     $scaleHeight = reScale($monitors[$i]['Height'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
     if ($maxWidth < $scaleWidth) {
         $maxWidth = $scaleWidth;
     }
     if ($maxHeight < $scaleHeight) {
         $maxHeight = $scaleHeight;
     }
 }
 if ($counts) {
     $monitors[$i] = array_merge($monitors[$i], $counts);
 }
 $seqIdList[] = $monitors[$i]['Id'];