Ejemplo n.º 1
0
 /**
  * @param $id
  * @param $data
  */
 public function update($id, $data, $code = NULL)
 {
     //$this->cleanData($data);
     $coords = \Geolocation::getCoordsFromText($data['map_coords']);
     $data['lat'] = $coords[0];
     $data['lon'] = $coords[1];
     $to_code = isset($data['locality_nickname']) ? $data['name'] . " " . $data['locality_nickname'] : $data['name'];
     $data['code'] = $code ? $code : \Nette\Utils\Strings::webalize($to_code);
     $data['stroller'] = isset($data['stroller']) && $data['stroller'] == 1 ? 1 : 0;
     $data['visible'] = isset($data['visible']) && $data['visible'] == 1 ? 1 : 0;
     $data['ad_onhomepage'] = isset($data['ad_onhomepage']) && $data['ad_onhomepage'] == 1 ? 1 : 0;
     $data['ad'] = isset($data['ad']) && $data['ad'] == 1 ? 1 : 0;
     $data['show_in_catalogue'] = isset($data['show_in_catalogue']) && $data['show_in_catalogue'] == 1 ? 1 : 0;
     $data['show_in_calendar'] = isset($data['show_in_calendar']) && $data['show_in_calendar'] == 1 ? 1 : 0;
     //$data['ad_shire'] = isset($data['ad_shire']) && $data['ad_shire'] == 0 ? null : $data['ad_shire'];
     //$data['ad_category'] = isset($data['ad_category']) && $data['ad_category'] == 0 ? null : $data['ad_category'];
     $cats = $data['categories'];
     dibi::begin();
     dibi::query('DELETE FROM [subject_x_category] WHERE [subject_id]=%i', $id);
     foreach ($cats as $k => $n) {
         dibi::query('INSERT INTO [subject_x_category] SET [subject_id]=%i', $id, ', [category_id]=%i', $n);
     }
     unset($data['categories']);
     dibi::query('UPDATE [subject] SET', $data, 'WHERE [id]=%i', $id);
     dibi::commit();
 }
Ejemplo n.º 2
0
 protected function compile()
 {
     if (REQUEST_TOKEN == "REQUEST_TOKEN") {
         $strRequestToken = "";
     } else {
         $strRequestToken = REQUEST_TOKEN;
     }
     $strJS = "<script type=\"text/javascript\">";
     $strJS .= "window.addEvent('domready', function(){";
     $strJS .= "if (typeof(RunGeolocation) != 'undefined') RunGeolocation.addInfoElement('geoInfo_" . $this->id . "');";
     $strJS .= "GeoUpdater.setMessages({";
     $strJS .= "changing:'{$GLOBALS['TL_LANG']['MSC']['geo_msc_Changing']}',";
     $strJS .= "noConnection:'{$GLOBALS['TL_LANG']['ERR']['geo_err_NoConnection']}',";
     $strJS .= "});";
     $strJS .= "GeoUpdater.setRequestToken('" . $strRequestToken . "');";
     $strJS .= "GeoUpdater.setSession('" . session_id() . "');";
     $strJS .= "});";
     $strJS .= "</script>";
     // Add location object
     $this->Template->UserGeolocation = Geolocation::getInstance()->getUserGeolocation();
     // Add JS
     $this->Template->strJS = $strJS;
     $this->Template->strId = $this->id;
     $this->Template->lang = $GLOBALS['TL_LANGUAGE'];
     $this->Template->geoChosen = $this->geo_chosen;
 }
Ejemplo n.º 3
0
 public function beforeSave()
 {
     // Let's Geocode the postcode
     $geo = Geolocation::getInstance();
     $location = $geo->geoLocate($this->postcode);
     $this->lat = $location["lat"];
     $this->lng = $location["lng"];
 }
Ejemplo n.º 4
0
 public function contactPage()
 {
     $this->view()->loadTemplate('contact');
     $this->commitReplace($this->view()->render(), '#content');
     $location = Geolocation::getCoordinates('Evaristo da Veiga', '582', 'Canoas', '92420080', 'BR');
     #Html::initGMap('map', $location['lat'], $location['lng'], 14);
     #Html::addGMapMarker('map', $location['lat'], $location['lng'], '', '');
 }
 /**
  * Check for redirects.
  * 
  * @return void
  */
 public function geolocationRedirect()
 {
     // Load current url.
     $strUrl = $this->getCurrentUrl();
     // Seach for an entry in the database.
     $strSQL = 'SELECT *
                 FROM tl_geolocation_redirect
                 WHERE published=?
                     AND ( (rgxp="" AND url=?) OR (rgxp="1" AND ? REGEXP url) )
                     AND ( host=? OR CONCAT("www.",host)=? OR host="" )
                 ORDER BY priority, url';
     $objTarget = Database::getInstance()->prepare($strSQL)->limit(1)->execute('1', $strUrl, $strUrl, $this->Environment->host, $this->Environment->host);
     // Check if we have some values.
     if ($objTarget->numRows == 0) {
         $this->log(vsprintf('Could not found a match for: %s', $strUrl), __CLASS__ . ' | ' . __FUNCTION__, TL_GENERAL);
         return;
     }
     // Chose a jump to method. Direct per page id or pattern url.
     if ($objTarget->jumpToType == 'jumpToUrl') {
         $targetURL = $objTarget->jumpToUrl;
         // replace regex-params
         if ($objTarget->rgxp == '1' && preg_match("~{$objTarget->url}~i", $strUrl)) {
             preg_match("~{$objTarget->url}~i", $strUrl, $arrErg);
             foreach ($arrErg as $i => $param) {
                 $targetURL = str_replace('$' . $i, $param, $targetURL);
             }
         }
         // TL knows only "303: see other", no "307: temporary"
         $type = $objTarget->type == '301' ? '301' : '303';
         // Get all countries.
         $arrCountries = deserialize($objTarget->countries, true);
         Geolocation::getInstance()->setUserGeolocationByShortCountries($arrCountries);
         // Redirect to page
         $this->redirect($targetURL, $type);
     } else {
         if ($objTarget->jumpToType == 'jumpTo') {
             // Search for the jumpTo page.
             $objJumpTo = Database::getInstance()->prepare("SELECT id, alias FROM tl_page WHERE id=?")->limit(1)->execute($objTarget->jumpTo);
             // Check if we have a jumpTo page.
             if ($objJumpTo->numRows == 0) {
                 $this->log(vsprintf('Could not found the jump to page for: "%s" with ID: %s ', $strUrl, $objTarget->jumpTo), __CLASS__ . ' | ' . __FUNCTION__, TL_ERROR);
                 return;
             }
             // TL knows only "303: see other", no "307: temporary".
             $type = $objTarget->type == '301' ? '301' : '303';
             // set objPage cause we need the rootLanguage there for generateFrontendUrl
             $GLOBALS['objPage'] = $this->getPageDetails($objJumpTo->id);
             // Get all countries.
             $arrCountries = deserialize($objTarget->countries, true);
             Geolocation::getInstance()->setUserGeolocationByShortCountries($arrCountries);
             // Redirect.
             $this->redirect($this->generateFrontendUrl($objJumpTo->row()), $type);
         }
     }
 }
Ejemplo n.º 6
0
 public function checkPermission($objElement, $strBuffer)
 {
     //check if geoprotection is enabled
     if ($objElement->gp_protected && TL_MODE != 'BE') {
         $objGeo = Geolocation::getInstance()->getUserGeolocation();
         $country = $objGeo->getCountryShort() != '' ? $objGeo->getCountryShort() : 'xx';
         //the geoContainser has a country and matches one of the group countries
         if (in_array($country, deserialize($objElement->gp_group_countries))) {
             if ($objElement->gp_mode == "gp_show") {
                 return in_array($country, deserialize($objElement->gp_countries)) ? $strBuffer : '';
             }
             return in_array($country, deserialize($objElement->gp_countries)) ? '' : $strBuffer;
         } else {
             //use Fallback
             return $objElement->gp_mode == "gp_show" && $objElement->gp_fallback || $objElement->gp_mode != "gp_show" && !$objElement->gp_fallback ? $strBuffer : '';
         }
     }
     return $strBuffer;
 }
Ejemplo n.º 7
0
require_once 'av_init.php';
Session::logcheck("analysis-menu", "ControlPanelAlarms");
/* connect to db */
$db = new ossim_db(TRUE);
$conn = $db->connect();
$origin = GET('prefix');
ossim_valid($origin, "src", "dst", 'illegal:' . _("Prefix"));
if (ossim_error()) {
    die(ossim_error());
}
$data = $_SESSION['_alarm_stats'][$origin];
$event_info = $_SESSION['_alarm_stats']['event_info'];
$ctx = $event_info['agent_ctx'];
$hosts_ids = array();
// Do not delete, this var is used in single_ip.php
$geoloc = new Geolocation('/usr/share/geoip/GeoLiteCity.dat');
$geoloc_org = NULL;
if (Session::is_pro() && file_exists('/usr/share/geoip/GeoIPOrg.dat')) {
    $geoloc_org = new Geolocation('/usr/share/geoip/GeoIPOrg.dat');
}
?>
	<style type='text/css'>

		.ui-widget {
			font-family: Arial;
			color: #333;
		}
		
		.ui-widget-header, .ui-widget-content a {
			color: #333;
		}
Ejemplo n.º 8
0
 public function actionDelGeo($id)
 {
     Geolocation::model()->findByPk($id)->delete();
     echo "success";
     app()->end();
 }
Ejemplo n.º 9
0
* On Debian GNU/Linux systems, the complete text of the GNU General
* Public License can be found in `/usr/share/common-licenses/GPL-2'.
*
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt
*
*/
set_time_limit(0);
require_once 'av_init.php';
$path = '/usr/share/ossim/www/report/os_reports/';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Common/functions.php';
require_once 'Various/general.php';
// DB
$db = new ossim_db();
$conn = $db->connect();
$geoloc = new Geolocation('/usr/share/geoip/GeoLiteCity.dat');
//Initialize var
$report_name = $report_data['report_name'];
$subreport_name = $report_data['subreports'][$subreport_id]['name'];
$date_from = POST($report_data['parameters'][0]['date_from_id']);
$date_to = POST($report_data['parameters'][0]['date_to_id']);
ossim_valid($date_from, OSS_DATE, OSS_NULLABLE, 'illegal:' . _('Date From'));
ossim_valid($date_to, OSS_DATE, OSS_NULLABLE, 'illegal:' . _('Date To'));
if (ossim_error()) {
    echo 'error###' . ossim_get_error_clean();
    exit;
}
$query_temp = array();
//
// select src_ip from alarm table and not defined into nets
//
Ejemplo n.º 10
0
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA  02110-1301  USA
*
*
* On Debian GNU/Linux systems, the complete text of the GNU General
* Public License can be found in `/usr/share/common-licenses/GPL-2'.
*
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt
*
*/
require_once 'av_init.php';
Session::useractive("../session/login.php");
require_once 'classes/DateDiff.inc';
$db = new ossim_db();
$conn = $db->connect();
$geoloc = new Geolocation('/usr/share/geoip/GeoLiteCity.dat');
$version = $conf->get_conf('ossim_server_version');
$pro = Session::is_pro();
$my_session = session_id();
function get_country($ccode)
{
    if ($ccode == '') {
        $flag = '';
    } else {
        if ($ccode == 'local') {
            $flag = '../forensics/images/homelan.png';
        } else {
            $flag = '../pixmaps/flags/' . $ccode . '.png';
        }
    }
    return $flag;
Ejemplo n.º 11
0
 private function addGeolocations($person_id, $postedData){
     if(!is_array($postedData)){
        $postedData = array($postedData); 
     }
     foreach ($postedData as &$data) {
         try{
             if($data->locname === null) $data->locname = 'Not Given';
              $attributes = array(
                              "person_id" => $person_id,
                              "lng" => $data->lng,
                              "lat" => $data->lat,
                              "locname" => $data->locname,
                              "captured_at" => $data->captured_at
                              );
              \Geolocation::create($attributes);
         }
         catch (\Slim\Exception $ex) {                    
         }
         catch (\Exception $ex) {
         }
     }
 }
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model=Geolocation::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
Ejemplo n.º 13
0
ossim_valid($from, OSS_DIGIT, 'illegal: iDisplayStart');
ossim_valid($order, OSS_ALPHA, 'illegal: iSortCol_0');
ossim_valid($torder, OSS_LETTER, 'illegal: sSortDir_0');
ossim_valid($search_str, OSS_INPUT, OSS_NULLABLE, 'illegal: sSearch');
ossim_valid($sec, OSS_DIGIT, 'illegal: sEcho');
if (ossim_error()) {
    Util::response_bad_request(ossim_get_error_clean());
}
// Check Asset Type
$asset_types = array('asset' => 'asset_host', 'network' => 'asset_net', 'group' => 'asset_group');
// Order by column
$orders_by_columns = array('0' => "a.timestamp {$torder}", '2' => "ki.name {$torder}, ca.name {$torder}, a.timestamp {$torder}", '3' => "ta.subcategory {$torder}, a.timestamp {$torder}", '4' => "a.risk {$torder}, a.timestamp {$torder}");
try {
    $db = new ossim_db();
    $conn = $db->connect();
    $geoloc = new Geolocation('/usr/share/geoip/GeoLiteCity.dat');
    $no_resolv = FALSE;
    if (isset($_POST['asset_id']) && isset($_POST['asset_type'])) {
        if (!array_key_exists($asset_type, $asset_types)) {
            Av_exception::throw_error(Av_exception::USER_ERROR, _('Error! Invalid Asset Type'));
        }
        $class_name = $asset_types[$_POST['asset_type']];
        // Check Asset Permission
        if (method_exists($class_name, 'is_allowed') && !$class_name::is_allowed($conn, $asset_id)) {
            $error = sprintf(_('Error! %s is not allowed'), ucwords($asset_type));
            Av_exception::throw_error(Av_exception::USER_ERROR, $error);
        }
        $asset_object = $class_name::get_object($conn, $asset_id);
        //Alarm filters
        if (array_key_exists($order, $orders_by_columns)) {
            $order = $orders_by_columns[$order];
Ejemplo n.º 14
0
$asset_id = POST('asset_id');
$asset_ip = POST('asset_ip');
$asset_id = strtoupper(str_replace('0x', '', $asset_id));
if (!valid_hex32($asset_id)) {
    $asset_id = '';
}
ossim_valid($backlog_id, OSS_HEX, 'illegal:' . _("Backlog ID"));
ossim_valid($asset_ip, OSS_IP_ADDR_0, 'illegal:' . _("Asset IP"));
if (ossim_error()) {
    Util::response_bad_request(ossim_get_error_clean());
}
$response = array();
try {
    $db = new ossim_db(TRUE);
    $conn = $db->connect();
    $gloc = new Geolocation('/usr/share/geoip/GeoLiteCity.dat');
    if (Session::is_pro() && file_exists('/usr/share/geoip/GeoIPOrg.dat')) {
        $gorg = new Geolocation('/usr/share/geoip/GeoIPOrg.dat');
    }
    $asset = Asset_host::get_object($conn, $asset_id);
    if ($asset) {
        $groups = $networks = array();
        //Getting Groups
        list($_groups, $_t) = $asset->get_related_groups($conn);
        foreach ($_groups as $g_id => $g) {
            $groups[$g_id] = array('name' => $g->get_name());
        }
        //Getting Nets
        $_networks = $asset->get_nets($conn);
        foreach ($_networks as $n_id => $n) {
            $networks[$n_id] = array('name' => $n['name']);
Ejemplo n.º 15
0
require ("base_conf.php");
require ("vars_session.php");
require ("$BASE_path/includes/base_constants.inc.php");
require ("$BASE_path/includes/base_include.inc.php");
include_once ("$BASE_path/base_db_common.php");
include_once ("$BASE_path/base_common.php");
include_once ("$BASE_path/base_qry_common.php");
set_time_limit(300);

if (GET('sensor') != "") ossim_valid(GET('sensor'), OSS_DIGIT, 'illegal:' . _("sensor"));;

$_SESSION["siem_default_group"] = "base_stat_country.php";

// Geoip
$geoloc = new Geolocation("/usr/share/geoip/GeoLiteCity.dat");

//$addr_type = ImportHTTPVar("addr_type", VAR_DIGIT);
$addr_type = 1;
$submit = ImportHTTPVar("submit", VAR_ALPHA | VAR_SPACE, array(
    gettext("Delete Selected"),
    gettext("Delete ALL on Screen"),
    _ENTIREQUERY
));
$dst_ip = NULL;
// Check role out and redirect if needed -- Kevin
$roleneeded = 10000;
#$BUser = new BaseUser();
#if (($BUser->hasRole($roleneeded) == 0) && ($Use_Auth_System == 1)) base_header("Location: " . $BASE_urlpath . "/index.php");
$et = new EventTiming($debug_time_mode);
// The below three lines were moved from line 87 because of the odd errors some users were having
Ejemplo n.º 16
0
         while (!$rg->EOF) {
             if ($rg->fields['name'] == '') {
                 $rg->fields['name'] = _("Unknown plugin");
             }
             $url = Menu::get_menu_url($f_url . "&plugin=" . $rg->fields["plugin_id"], 'analysis', 'security_events', 'security_events');
             $data .= "['<a class=\"no_text_decoration\" href=\"{$url}\">" . str_replace('_', ' ', $rg->fields['name']) . "</a>'," . $rg->fields['num_events'] . "],";
             $urls .= "'{$url}',";
             $rg->MoveNext();
         }
     }
     $colors = '"#FFFBCF","#EEE8AA","#F0E68C","#FFD700","#FF8C00","#DAA520","#D2691E","#B8860B","#7F631F"';
     break;
     // Honeypot Countries - Last Week
 // Honeypot Countries - Last Week
 case "honeypot_countries":
     $geoloc = new Geolocation("/usr/share/geoip/GeoLiteCity.dat");
     $nodata_text .= _(" for <i>Honeypot</i>");
     $sqlgraph = "select INET_NTOA(a.ip_src) as ip, sum(cnt) as num_events FROM alienvault_siem.po_acid_event a, alienvault.plugin pl, alienvault.plugin_sid p WHERE p.plugin_id=a.plugin_id AND p.sid=a.plugin_sid AND p.plugin_id=pl.id AND p.category_id=19 AND a.timestamp BETWEEN '" . gmdate("Y-m-d H:i:s", gmdate("U") - $range) . "' AND '" . gmdate("Y-m-d H:i:s") . "' {$sensor_where} group by a.ip_src order by num_events desc";
     //echo $sqlgraph;
     $countries = array();
     $country_names = array();
     //echo $sqlgraph;
     if (!($rg = $conn->CacheExecute($sqlgraph))) {
         print $conn->ErrorMsg();
     } else {
         while (!$rg->EOF && count($countries) < 10) {
             $_country_aux = $geoloc->get_country_by_host($conn, $rg->fields['ip']);
             $country = strtolower($_country_aux[0]);
             $country_name = $_country_aux[1];
             if ($country_name != '') {
                 $countries[$country] += $rg->fields['num_events'];
Ejemplo n.º 17
0
*
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt
*
*/
require_once 'av_init.php';
Session::logcheck("analysis-menu", "ControlPanelAlarms");
$h_id = GET('id');
$h_ip = GET('ip');
$prefix = GET('prefix');
ossim_valid($h_id, OSS_HEX, OSS_NULLABLE, 'illegal:' . _("Asset ID"));
ossim_valid($h_ip, OSS_IP_ADDR_0, OSS_NULLABLE, 'illegal:' . _("Ip"));
ossim_valid($prefix, 'src', 'dst', 'illegal:' . _("Prefix"));
if (ossim_error()) {
    die(ossim_error());
}
$gloc = new Geolocation('/usr/share/geoip/GeoLiteCity.dat');
$data = $_SESSION['_alarm_stats'][$prefix];
/* connect to db */
$db = new ossim_db(TRUE);
$conn = $db->connect();
$h_obj = Asset_host::get_object($conn, $h_id, TRUE);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title><?php 
echo gettext("OSSIM Framework");
?>
</title>
	
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
Ejemplo n.º 18
0
 /**
  * @param $id
  * @param $data
  */
 public function update($id, $data)
 {
     $this->cleanData($data);
     if (isset($data['map_coords'])) {
         $coords = Geolocation::getCoordsFromText($data['map_coords']);
         $data['lat'] = $coords[0];
         $data['lon'] = $coords[1];
     }
     $data['code'] = \Nette\Utils\Strings::webalize($data['name']);
     return dibi::query('UPDATE [locality] SET', $data, 'WHERE [id]=%i', $id);
 }
Ejemplo n.º 19
0
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt
*
*/
require_once 'av_init.php';
Session::logcheck("analysis-menu", "ReportsAlarmReport");
$limit = GET('hosts');
$target = GET('target');
$type = GET('type');
$date_from = GET('date_from') != "" ? GET('date_from') : strftime("%d/%m/%Y %H:%M:%S", time() - 24 * 60 * 60);
$date_to = GET('date_to') != "" ? GET('date_to') : strftime("%d/%m/%Y %H:%M:%S", time());
ossim_valid($limit, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("Limit"));
ossim_valid($type, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("Report type"));
ossim_valid($target, OSS_ALPHA, OSS_SPACE, OSS_SCORE, 'illegal:' . _("Target"));
ossim_valid($date_from, OSS_DIGIT, OSS_SCORE, OSS_NULLABLE, 'illegal:' . _("from date"));
ossim_valid($date_to, OSS_DIGIT, OSS_SCORE, OSS_NULLABLE, 'illegal:' . _("to date"));
$geoloc = new Geolocation("/usr/share/geoip/GeoLiteCity.dat");
$runorder = intval(GET('runorder'));
if ($runorder == 0) {
    $runorder = "";
}
if (ossim_error()) {
    die(ossim_error());
}
/* hosts to show */
if (empty($limit)) {
    $limit = 11;
}
if (empty($type)) {
    $type = "event";
}
if (!$type == "event") {
Ejemplo n.º 20
0
 /**
  * Get current instance from GeoProtection
  * 
  * @return Geolocation 
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new Geolocation();
     }
     return self::$instance;
 }
Ejemplo n.º 21
0
**
** Built upon work by Roman Danyliw <*****@*****.**>, <*****@*****.**>
** Built upon work by the BASE Project Team <*****@*****.**>
*/
require "base_conf.php";
require "vars_session.php";
require "{$BASE_path}/includes/base_constants.inc.php";
require "{$BASE_path}/includes/base_include.inc.php";
include_once "{$BASE_path}/base_db_common.php";
include_once "{$BASE_path}/base_common.php";
include_once "{$BASE_path}/base_stat_common.php";
include_once "{$BASE_path}/base_qry_common.php";
include_once "{$BASE_path}/base_ag_common.php";
include_once "geoip.inc";
$_SESSION["siem_default_group"] = "base_stat_sensor.php?sort_order=occur_d";
$geoloc = new Geolocation("/usr/share/geoip/GeoLiteCity.dat");
$et = new EventTiming($debug_time_mode);
$cs = new CriteriaState("base_stat_sensor.php");
$cs->ReadState();
$qs = new QueryState();
// Check role out and redirect if needed -- Kevin
$roleneeded = 10000;
#$BUser = new BaseUser();
#if (($BUser->hasRole($roleneeded) == 0) && ($Use_Auth_System == 1)) base_header("Location: " . $BASE_urlpath . "/index.php");
$submit = ImportHTTPVar("submit", VAR_ALPHA | VAR_SPACE, array(gettext("Delete Selected"), gettext("Delete ALL on Screen"), _ENTIREQUERY));
$export = intval(ImportHTTPVar("complete", VAR_DIGIT));
// Called from report_launcher.php
$qs->MoveView($submit);
/* increment the view if necessary */
$page_title = gettext("Sensor Listing");
/* Connect to the Alert database */
Ejemplo n.º 22
0
 public function actionGeolocations()
 {
     $rtn = false;
     $trans = Yii::app()->db->beginTransaction();
     try
     {
         $postedData = $this->getPostedData();
         if(empty($postedData[0]))
         {//single object one job-onestatus
             $postedData =array($postedData);
         }
         else
         {
             //multiple as array of jobid=status
         }
         foreach($postedData as $single)
         {
             $longitude = (isset($single['lng'])?$single['lng']:null);
             $latitude = (isset($single['lat'])?$single['lat']:null);
             $capturedat = (isset($single['captured_at'])?$single['captured_at']:null);
             $capturedat = Yii::app()->controller->getMysqlFormattedDatetime($capturedat);
             if(empty($capturedat))
             {
                 $capturedat = date('Y-m-d H:i:s');
             }
             $person_id = $this->mobileUser->person->id;
             $model = new Geolocation;
             $model->lng = $longitude;
             $model->lat = $latitude;
             $model->captured_at = $capturedat;
             $model->person_id = $person_id;
             $rtn = $model->save();
             if(!$rtn) break;
         }
     }
     catch (Exception $e)
     {
         $rtn = false;
     }
     if($rtn)
     {
         $trans->commit();
         $rtnCode = Helper::CONST_Error_None;
         $message = Helper::CONST_PERSON_GPS_SAVED;
     }
     else
     {
         $trans->rollback();
         $rtnCode = Helper::CONST_SaveError;
         $message = Helper::CONST_PERSON_GPS_SAVE_FAIL;
     }
     $this->returnJsonResponse($rtnCode, array(), $message);
 }