diff --git a/lib/scripts/distro_web_utils.php b/lib/scripts/distro_web_utils.php index 357d6bc..680598b 100644 --- a/lib/scripts/distro_web_utils.php +++ b/lib/scripts/distro_web_utils.php @@ -239,27 +239,27 @@ function print_APPLICATION_INFO(){ - Stop Backend Engine + Stop Backend Engine - Start Backend Engine + Start Backend Engine - Stop Web User Interface + Stop Web User Interface - Stop Web User Interface + Start Web User Interface - Wipe History Data - Reset to Factory Defaults + Wipe History Data + Reset to Factory Defaults
-
- + + + @@ -816,10 +816,17 @@ function print_GO_BACK(){ ?> -KOKO -array( 'id'=>1, 'identity'=>'3638eedfe4370b4b53285ae524b88343', 'site_id'=>1 ), + 'nodes'=>array(), + 'resources'=>array(), + 'sensors'=>array(), + 'cameras'=>array(), + 'modules'=>array(), + 'filters'=>array(), + 'system_props'=>array(), + 'users'=>array() + ); + $fid = fopen( '/srv/mojo/server.conf', "r" ); + if( $fid !== false ){ + while( !feof( $fid ) ){ + $CL = trim( fgets( $fid ) ); + $CL = str_replace( ' ', '', $CL ); + $CL = str_replace( '"', '', $CL ); + $CL = str_replace( ';', '', $CL ); + $TArr = explode('=', $CL ); + if( stripos( $CL, 'IDENTITY' ) !== false ){ + $DATA['server']['identity'] = $TArr[1]; + }; + if( stripos( $CL, 'SITE_ID' ) !== false ){ + $DATA['server']['site_id'] = $TArr[1]; + }; + }; + fclose( $fid ); + }; + $DB = new SQLite_DB('/srv/www/web/lib/controller/data/mysqlitedb.db'); + $QS = "SELECT * FROM `nodes`"; + $R = $DB->Query( $QS ); + foreach( $R as $T ){ + $CN = array(); + foreach( $T as $key=>$val ) $CN[$key] = $val; + $DATA['nodes'][] = $CN; + }; + $QS = "SELECT * FROM `resources`"; + $R = $DB->Query( $QS ); + foreach( $R as $T ){ + $CN = array(); + foreach( $T as $key=>$val ) $CN[$key] = $val; + switch( $CN['type'] ){ + case 1:{ + $QS = "SELECT * FROM `uart_settings` WHERE `id`={$CN['aux_id']}"; + $J = $DB->Query( $QS ); + $PP = array(); + foreach( $J[0] as $l=>$v ) $PP[$l]=$v; + $CN['private'] = $PP; + }; + }; + $DATA['resources'][] = $CN; + }; + $QS = "SELECT * FROM `cameras`"; + $R = $DB->Query( $QS ); + foreach( $R as $T ){ + $CN = array(); + foreach( $T as $key=>$val ) $CN[$key] = $val; + $QS = "SELECT * FROM `media_streams` WHERE `source_id`={$CN['id']}"; + $CN['streams'] = $DB->Query( $QS ); + $DATA['cameras'][] = $CN; + }; + $QS = "SELECT * FROM `lrf_sensors`"; + $R = $DB->Query( $QS ); + foreach( $R as $T ){ + $CN = array(); + foreach( $T as $key=>$val ) $CN[$key] = $val; + $QS = "SELECT * FROM `lrf_detection_profiles` WHERE `aux_id`={$CN['id']}"; + $CN['private'] = $DB->Query( $QS ); + $DATA['sensors'][] = $CN; + }; + $QS = "SELECT * FROM `modules`"; + $R = $DB->Query( $QS ); + foreach( $R as $T ){ + $CN = array(); + foreach( $T as $key=>$val ) $CN[$key] = $val; + switch( $CN['type'] ){ + case 8:{ + $PP = array(); + $QS = "SELECT * FROM `module_eve` WHERE `id`={$CN['aux_id']}"; + $K = $DB->Query( $QS ); + $PP = $K[0]; + $CN['private'] = $PP; + break; + }; + }; + $DATA['modules'][] = $CN; + }; + $QS = "SELECT * FROM `target_filters`"; + $R = $DB->Query( $QS ); + foreach( $R as $T ){ + $CN = array(); + foreach( $T as $key=>$val ) $CN[$key] = $val; + switch( $CN['type'] ){ + case 1:{ + $PP = array(); + $QS = "SELECT * FROM `target_filter_train` WHERE `id`={$CN['aux_id']}"; + $K = $DB->Query( $QS ); + $PP = $K[0]; + $CN['private'] = $PP; + break; + }; + }; + $DATA['filters'][] = $CN; + }; + $QS = "SELECT * FROM `system_props`"; + $R = $DB->Query( $QS ); + $DATA['system_props'] = $R[0]; + $QS = "SELECT * FROM `users`"; + $R = $DB->Query( $QS ); + foreach( $R as $T ){ + if( $T['id'] > 1 ){ + $CN = array(); + foreach( $T as $key=>$val ) $CN[$key] = $val; + $DATA['users'][] = $CN; + }; + }; + unset( $DB ); + return json_encode( $DATA ); +}; + +function apply_application_config( $A, $DBF ){ + $DB = new SQLite_DB( $DBF ); + $DATA = json_decode( $A, true ); + foreach( $DATA as $Key=>$Val ){ + switch( $Key ){ + case 'users':{ + foreach( $Val as $T ){ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $T as $A=>$B ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + $QS = "INSERT INTO `users`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + }; + break; + }; + case 'server':{ + foreach( $Val as $A=>$B ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + $QS = "INSERT INTO `servers`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + break; + }; + case 'nodes':{ + foreach( $Val as $T ){ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $T as $A=>$B ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + $QS = "INSERT INTO `nodes`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + }; + break; + }; + case 'resources':{ + foreach( $Val as $T ){ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $T as $A=>$B ){ + if( $A!='private' ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + }; + $QS = "INSERT INTO `resources`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + switch( $T['type'] ){ + case 1:{ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $T['private'] as $A=>$B ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + $QS = "INSERT INTO `uart_settings`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + break; + }; + }; + }; + break; + }; + case 'sensors':{ + foreach( $Val as $T ){ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $T as $A=>$B ){ + if( $A!='private' ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + }; + $QS = "INSERT INTO `lrf_sensors`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + if( count( $T['private'] ) ){ + foreach( $T['private'] as $P ){ + foreach( $P as $A=>$B ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + $QS = "INSERT INTO `lrf_detection_profiles`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + }; + }; + }; + break; + }; + case 'cameras':{ + foreach( $Val as $T ){ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $T as $A=>$B ){ + if( $A!='streams' ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + }; + $QS = "INSERT INTO `cameras`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + foreach( $T['streams'] as $S ){ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $S as $A=>$B ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + $QS = "INSERT INTO `media_streams`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + }; + }; + break; + }; + case 'modules':{ + foreach( $Val as $T ){ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $T as $A=>$B ){ + if( $A!='private' ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + }; + $QS = "INSERT INTO `modules`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + switch( $T['type'] ){ + case 8:{ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $T['private'] as $A=>$B ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + $QS = "INSERT INTO `module_eve`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + break; + }; + }; + }; + break; + }; + case 'filters':{ + foreach( $Val as $T ){ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $T as $A=>$B ){ + if( $A!='private' ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + }; + $QS = "INSERT INTO `target_filters`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + switch( $T['type'] ){ + case 1:{ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $T['private'] as $A=>$B ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + $QS = "INSERT INTO `target_filter_train`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + break; + }; + }; + }; + break; + }; + case 'system_props':{ + $flds = array(); + $values = array(); + $updates = array(); + foreach( $Val as $A=>$B ){ + $flds[] = "`{$A}`"; + $values[]="'{$B}'"; + if( $A!='id' ) $updates[] = "`{$A}`='{$B}'"; + }; + $QS = "INSERT INTO `system_props`(" . implode( ',', $flds ).") VALUES (".implode( ',', $values ).") ON CONFLICT(`id`) DO UPDATE SET ".implode( ',', $updates ); + $DB->Query( $QS ); + break; + }; + }; + }; + unset( $DB ); +}; + function set_factory_settings(){ stop_BACKEND_APPLICATION(); $R = `rm -f -R /srv/www/web/lib/controller/data/uploads/*`; diff --git a/lib/scripts/test.php b/lib/scripts/test.php index 5972875..98d5038 100644 --- a/lib/scripts/test.php +++ b/lib/scripts/test.php @@ -3,13 +3,13 @@ require_once('sys_utils.php'); //stop_BACKEND_APPLICATION(); //start_BACKEND_APPLICATION(); - set_factory_settings(); + //set_factory_settings(); //if( process_is_running( 'nginx', 'ag_nginx' ) ){ // echo "True!\n"; // } else { // echo "False!\n"; // }; - + apply_application_config( serialize_current_application_config() ); ?> \ No newline at end of file diff --git a/lib/sysroot/srv/etc/cron.php b/lib/sysroot/srv/etc/cron.php index bc2d010..e3d159b 100644 --- a/lib/sysroot/srv/etc/cron.php +++ b/lib/sysroot/srv/etc/cron.php @@ -110,14 +110,16 @@ case 10:{ set_NGINX_APP_ENABLE(); $SYS_CONFIG['NGINX_WEB_APP_ENABLED'] = true; - $L = `service nginx restart`; + $L = `service nginx start`; + $SYS_CONFIG['ARGUS_CONFIG']['webui_is_running'] = true; save_system_config(); break; }; case 11:{ set_NGINX_APP_DISABLE(); $SYS_CONFIG['NGINX_WEB_APP_ENABLED'] = false; - $L = `service nginx restart`; + $L = `service nginx stop`; + $SYS_CONFIG['ARGUS_CONFIG']['webui_is_running'] = false; save_system_config(); break; }; @@ -201,6 +203,10 @@ set_factory_settings(); break; }; + case 19:{ + clear_history(); + break; + }; }; }; ?> \ No newline at end of file diff --git a/lib/sysroot/srv/etc/crontab b/lib/sysroot/srv/etc/crontab new file mode 100644 index 0000000..2001fee --- /dev/null +++ b/lib/sysroot/srv/etc/crontab @@ -0,0 +1,28 @@ +# /etc/crontab: system-wide crontab +# Unlike any other crontab you don't have to run the `crontab' +# command to install the new version when you edit this file +# and files in /etc/cron.d. These files also have username fields, +# that none of the other crontabs do. + +SHELL=/bin/sh +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + +# Example of job definition: +# .---------------- minute (0 - 59) +# | .------------- hour (0 - 23) +# | | .---------- day of month (1 - 31) +# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... +# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat +# | | | | | +# * * * * * user-name command to be executed +17 * * * * root cd / && run-parts --report /etc/cron.hourly +25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) +47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) +52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) +* * * * * root /srv/etc/cron_job.sh +@reboot root /srv/etc/after_boot.sh +1 * * * * root /srv/etc/check_wifi.sh +16 * * * * root /srv/etc/check_wifi.sh +31 * * * * root /srv/etc/check_wifi.sh +46 * * * * root /srv/etc/check_wifi.sh +# diff --git a/lib/sysroot/srv/etc/system.json b/lib/sysroot/srv/etc/system.json index 00db451..89b90b3 100644 --- a/lib/sysroot/srv/etc/system.json +++ b/lib/sysroot/srv/etc/system.json @@ -1 +1 @@ -{"NET_CONFIG":{"lo":{"flags":{"hotplug":0,"auto":0},"net":[],"fam":"inet","mode":"loopback"},"eth0":{"flags":{"hotplug":1,"auto":1},"net":[],"fam":"inet","mode":"dhcp"}},"SAMBA_IS_ON":true,"ARGUS_CONFIG":{"app_is_running":false,"webui_is_running":true}} \ No newline at end of file +{"SAMBA_IS_ON":true,"ARGUS_CONFIG":{"app_is_running":false,"webui_is_running":true},"NET_CONFIG":{"lo":{"flags":{"hotplug":0,"auto":0},"net":[],"fam":"inet","mode":"loopback"},"eth0":{"flags":{"hotplug":1,"auto":1},"net":[],"fam":"inet","mode":"dhcp"}}} \ No newline at end of file diff --git a/task_wait.php b/task_wait.php index ba74fdc..a19f2cc 100644 --- a/task_wait.php +++ b/task_wait.php @@ -9,7 +9,7 @@ $CTID = intval( $_POST['TID'] ); }; if( $CTID > -1 ){ - switch( $CTID ){ + switch( $CTID ){ case 4: $CPARAM = intval( $_GET['CTS'] ); break; case 7: $CPARAM = $_POST['CTZ']; break; case 15: $CPARAM = $_POST['FID']; break;
Time Settings
Current Time ZoneSet Time Zone
Set Time Zone

Platform TimeSync To Browser