Esempio n. 1
0
 public function districtbyparishAction()
 {
     if ($this->_getParam('term', false)) {
         $parishes = new Places();
         $response = $parishes->getDistrictByParish($this->_getParam('term'));
     } else {
         $response = array('id' => NULL, 'term' => 'No parish specified');
     }
     echo Zend_Json::encode($response);
 }
Esempio n. 2
0
 /** Index page for smrs
  */
 public function indexAction()
 {
     $monumentName = $this->_getParam('monumentName');
     $county = $this->_getParam('county');
     $district = $this->_getParam('district');
     $parish = $this->_getParam('parish');
     $page = $this->_getParam('page');
     $smrs = new ScheduledMonuments();
     $this->view->smrs = $smrs->getSmrs($page, $county, $district, $parish, $monumentName);
     $form = new SAMFilterForm();
     $this->view->form = $form;
     if (!is_null($county)) {
         $districts = new Places();
         $district_list = $districts->getDistrictList($county);
         $form->district->addMultiOptions(array(NULL => NULL, 'Choose district' => $district_list));
         if (!is_null($district)) {
             $parish_list = $districts->getParishList($district);
             $form->parish->addMultiOptions(array(NULL => NULL, 'Choose parish' => $parish_list));
         }
     }
     $form->monumentName->setValue($monumentName);
     $form->district->setValue($district);
     $form->parish->setValue($parish);
     $form->county->setValue($county);
     if ($this->_request->isPost() && !is_null($this->_getParam('submit'))) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $params = array_filter($formData);
             unset($params['submit']);
             unset($params['action']);
             unset($params['controller']);
             unset($params['module']);
             unset($params['page']);
             unset($params['csrf']);
             $where = array();
             foreach ($params as $key => $value) {
                 if (!is_null($value)) {
                     $where[] = $key . '/' . urlencode(strip_tags($value));
                 }
             }
             $whereString = implode('/', $where);
             $query = $whereString;
             $this->_redirect(self::REDIRECT . 'index/' . $query . '/');
         } else {
             $form->populate($formData);
         }
     }
 }
Esempio n. 3
0
 public function renderDefault()
 {
     // vyhledavani
     if ($this->q) {
         $this->places->where("subject.name LIKE ? OR user.email LIKE ?", "%" . $this->q . "%", "%" . $this->q . "%");
         $this['search']['q']->setDefaultValue($this->q);
         $this->template->search = TRUE;
     } else {
         $this->template->search = FALSE;
     }
     switch ($this->what) {
         case self::UPDATED:
             $this->places->group('subject.id')->having('DATEDIFF(NOW(), subject.changed) < ' . self::TIME_UPDATED);
             $this->template->what = self::UPDATED;
             break;
         case self::RECENT:
             $this->places->group('subject.id')->having('DATEDIFF(NOW(), subject.created) < ' . self::TIME_RECENT);
             $this->template->what = self::RECENT;
             break;
         case self::TOREVIEW:
             $this->places->group('subject.id')->having('subject.reviewed = 0 && subject.deleted = 0 ');
             $this->template->what = self::TOREVIEW;
             break;
         case self::DELETED:
             $this->template->what = self::DELETED;
             $this->places->fetchDeleted();
             break;
         default:
             $this->template->what = self::ALL;
     }
     if (!$this->what == self::DELETED) {
         $this->places->fetchUnDeleted();
     }
     if ($this->orderBy == '' && $this->user->isInRole('administrator')) {
         $this->orderBy = self::MODIFICATION;
     }
     switch ($this->orderBy) {
         case self::MODIFICATION:
             $this->places->order('changed DESC, created DESC');
             $this->template->orderBy = self::MODIFICATION;
             break;
         case self::ALPHABET:
         default:
             $this->places->order('name');
             $this->template->orderBy = self::ALPHABET;
             break;
     }
     // strankovani
     $this->pagerPlaces->itemCount = $this->places->count();
     $this->places->limit($this->pagerPlaces->getLimit(), $this->pagerPlaces->getOffset());
     // vypis
     $this->template->places = $this->places;
 }
 public function optionsAddClone()
 {
     $findspots = new Findspots();
     $findspot = $findspots->getLastRecord($this->_getIdentity());
     $data = $findspot[0];
     $this->_view->form->populate($data);
     Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->addMessage('Your last record data has been cloned');
     if (!is_null($data['county'])) {
         $districts = new Places();
         $district = $districts->getDistrictList($data['county']);
         if ($district) {
             $this->_view->form->district->addMultiOptions(array(NULL => 'Choose district', 'Available districts' => $district));
         }
         if (!is_null($data['district'])) {
             $parishes = $districts->getParishList($data['district']);
             $this->_view->form->parish->addMultiOptions(array(NULL => 'Choose parish', 'Available parishes' => $parishes));
         }
         if (!is_null($data['county'])) {
             $cnts = new Counties();
             $region_list = $cnts->getRegionsList($data['county']);
             $this->_view->form->regionID->addMultiOptions(array(NULL => 'Choose region', 'Available regions' => $region_list));
         }
     }
     if (!is_null($data['landusevalue'])) {
         $landcodes = new Landuses();
         $landusecode_options = $landcodes->getLandusesChildList($data['landusevalue']);
         $this->_view->form->landusecode->addMultiOptions(array(NULL => 'Choose code', 'Available landuses' => $landusecode_options));
     }
     if (!is_null($findspot['landowner'])) {
         $finders = new Peoples();
         $finders = $finders->getName($findspot['landowner']);
         foreach ($finders as $finder) {
             $form->landownername->setValue($finder['term']);
         }
     }
 }
 /**
  * This method will do main work.
  */
 public function start($task)
 {
     /* Start task and set timeout */
     $task->status = 'in-progress';
     $task->dead_time = new \DateTime('now +' . $this->deadTime . ' seconds');
     $task->save();
     $task->refresh();
     /* Do work */
     $places = Places::find()->approved()->all();
     foreach ($places as $place) {
         $place->importFromFacebook();
     }
     /* Finish task */
     $task->status = 'finished';
     return true;
 }
 public function actionDelete($id)
 {
     $place = Places::model()->findByPk($id);
     if (null === $place) {
         $this->_sendResponse(404, CJSON::encode(array('message' => 'Could not find place with id = ' . $id)));
         return;
     }
     if (!Yii::app()->user->checkAccess('deletePlace', array('place' => $place))) {
         $this->_sendResponse(403);
         return;
     }
     if ($place->delete()) {
         $this->_sendResponse(200, CJSON::encode($place));
     } else {
         $this->_sendResponse(500, CJSON::encode(array('message' => 'Could not delete place', 'errors' => $place->getErrors())));
     }
 }
Esempio n. 7
0
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
 * @version    ##VERSION##, ##DATE##
 */
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
/** PHPExcel_IOFactory */
require_once dirname(__FILE__) . '/includes/PHPExcel/Classes/PHPExcel/IOFactory.php';
require_once 'libs/config.php';
//Archivo con configuraciones.
$system = System::singleton();
require_once dirname(__FILE__) . '/libs/apps/places/class.places.php';
$places = new Places();
echo date('H:i:s'), " Load from Excel5 template", EOL;
$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load("includes/template.xls");
echo date('H:i:s'), " Add new data to the template", EOL;
$data = $places->previewReport(null, 0);
echo "<pre>";
print_r($data['message'][0]);
echo "</pre>";
/*$data = array(array('cpro_dgc'		=> 'Excel for dummies',
			'price'		=> 17.99,
			'quantity'	=> 2
		   ),
	  array('title'		=> 'PHP for dummies',
			'price'		=> 15.99,
			'quantity'	=> 1
Esempio n. 8
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../src/Places.php';
session_start();
if (empty($_SESSION['list_of_city_info'])) {
    $_SESSION['list_of_city_info'] = array();
}
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('content.html.twig', array('content' => Places::getAll()));
});
$app->post("/Place_Info", function () use($app) {
    $place = new Places($_POST['Place_Name'], $_POST['Stay_Time']);
    $place->save();
    return $app['twig']->render('create_place.html.twig', array('newplace' => $place));
});
return $app;
 /** Edit crime details
  * @todo messy rewrite
  */
 public function editAction()
 {
     if ($this->_getParam('id', false)) {
         $form = new HeritageCrimeForm();
         $form->submit->setLabel('Update crime');
         $this->view->form = $form;
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $ngr = $form->getValue('gridref');
                 if (!is_null($ngr) || $ngr != "") {
                     $results = $this->GridCalc($ngr);
                     $fourFigure = $this->FourFigure($ngr);
                     $place = new Pas_Service_Geo_Geoplanet($this->_appid);
                     $findelevation = $place->getElevation(NULL, $results['Latitude'], $results['Longitude']);
                     $findwoeid = $place->reverseGeoCode($results['Latitude'], $results['Longitude']);
                     $elevation = $findelevation['elevation'];
                     $woeid = $findwoeid['woeid'];
                 } else {
                     $elevation = NULL;
                     $woeid = NULL;
                 }
                 $updateData = array('subject' => $form->getValue('subject'), 'reporterID' => $form->getValue('reporterID'), 'incidentDate' => $form->getValue('incidentDate'), 'crimeType' => $form->getValue('crimeType'), 'gridref' => $form->getValue('gridref'), 'latitude' => $results['Latitude'], 'longitude' => $results['Longitude'], 'easting' => $results['Easting'], 'northing' => $results['Northing'], 'map10k' => $results['Tenk'], 'map25k' => $results['2pt5K'], 'fourFigure' => $fourFigure, 'description' => $form->getValue('description'), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms(), 'woeid' => $woeid, 'elevation' => $elevation, 'samID' => $form->getValue('samID'), 'evaluation' => $form->getValue('evaluation'), 'reliability' => $form->getValue('reliability'), 'county' => $form->getValue('county'), 'district' => $form->getValue('district'), 'parish' => $form->getValue('parish'), 'intellEvaluation' => $form->getValue('intellEvaluation'), 'reportSubject' => $form->getValue('reportSubject'), 'subjectDetails' => $form->getValue('subjectDetails'), 'reportingPerson' => $form->getValue('reportingPerson'));
                 foreach ($updateData as $key => $value) {
                     if (is_null($value) || $value == "") {
                         $updateData[$key] = NULL;
                     }
                 }
                 $where = array();
                 $where[] = $this->_crimes->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                 $this->_crimes->update($updateData, $where);
                 $returnID = $this->_getParam('id');
                 $this->_flashMessenger->addMessage('Crime details updated!');
                 $this->_redirect(self::REDIRECT . 'crime/id/' . $returnID);
             } else {
                 $id = (int) $this->_request->getParam('id', 0);
                 if ($id > 0) {
                     $crime = $this->_crimes->getCrime($this->_getParam('id'));
                     if (!is_null($crime['0']['county'])) {
                         $districts = new Places();
                         $district_list = $districts->getDistrictList($crime['0']['county']);
                         $form->district->addMultiOptions(array(NULL => 'Choose district', 'Available districts' => $district_list));
                         if (!is_null($crime['0']['district'])) {
                             $parish_list = $districts->getParishList($crime['0']['district']);
                             $form->parish->addMultiOptions(array(NULL => 'Choose parish', 'Available parishes' => $parish_list));
                         }
                     }
                     $form->populate($formData);
                 }
             }
         } else {
             $id = (int) $this->_request->getParam('id', 0);
             if ($id > 0) {
                 $crime = $this->_crimes->getCrime($this->_getParam('id'));
                 if (!is_null($crime['0']['county'])) {
                     $districts = new Places();
                     $district_list = $districts->getDistrictList($crime['0']['county']);
                     $form->district->addMultiOptions(array(NULL => 'Choose district', 'Available districts' => $district_list));
                     if (!is_null($crime['0']['district'])) {
                         $parish_list = $districts->getParishList($crime['0']['district']);
                         $form->parish->addMultiOptions(array(NULL => 'Choose parish', 'Available parishes' => $parish_list));
                     }
                 }
                 $form->populate($crime['0']);
             }
         }
     } else {
         throw new Exception($this->_missingParameter);
     }
 }
Esempio n. 10
0
 /**
  * Use this to calculate the distance of a zipcode's central point to some lat/long pair
  * @param {double} $lat
  * @param {double} $long
  */
 function distanceToZipcode($zipcode)
 {
     return Places::distance($this->latitude, $this->longitude, $zipcode->latitude, $zipcode->longitude);
 }
Esempio n. 11
0
 /**
  * Fetch (and create, if necessary) stream on which messages are posted relating
  * to things happening a given number of $miles around the given location.
  * @method stream
  * @static
  * @param {double} $latitude The latitude of the coordinates to search around
  * @param {double} $longitude The longitude of the coordinates to search around
  * @param {double} $miles The radius, in miles, around this location.
  *  Should be one of the array values in the Places/nearby/miles config.
  * @param {string} $publisherId The id of the publisher to publish this stream
  *  Defaults to the app name in Q/app config.
  * @param {string} $streamName The name of the stream to create.
  *  Defaults to Places_Nearby::streamName($latitude, $longitude, $miles).
  * @return {Streams_Stream} Returns the stream object that was created or fetched.
  */
 static function stream($latitude, $longitude, $miles, $publisherId = null, $streamName = null)
 {
     list($latitude, $longGrid) = Places::quantize($latitude, $longitude, $miles);
     $zipcodes = Places_Zipcode::nearby($latitude, $longitude, $miles, 1);
     if (!isset($publisherId)) {
         $publisherId = Users::communityId();
     }
     if (!isset($streamName)) {
         $streamName = self::streamName($latitude, $longitude, $miles);
     }
     if ($stream = Streams::fetchOne(null, $publisherId, $streamName)) {
         return $stream;
     }
     $zipcode = $zipcodes ? reset($zipcodes) : null;
     $attributes = compact('latitude', 'longitude');
     if ($zipcode) {
         foreach (array('zipcode', 'placeName', 'state') as $attr) {
             $attributes[$attr] = $zipcode->{$attr};
         }
     }
     $stream = Streams::create($publisherId, $publisherId, 'Places/nearby', array('name' => $streamName, 'title' => $zipcode ? "Nearby ({$latitude}, {$longitude}): {$zipcode->placeName}, zipcode {$zipcode->zipcode}" : "Nearby ({$latitude}, {$longitude})", 'attributes' => Q::json_encode($attributes)));
     return $stream;
 }
Esempio n. 12
0
 /**
  * Fetch a stream on which messages are posted relating to things happening
  * a given number of $miles around the given location.
  * If it doesn't exist, create it.
  * @method stream
  * @static
  * @param {double} $latitude The latitude of the coordinates to search around
  * @param {double} $longitude The longitude of the coordinates to search around
  * @param {double} $miles The radius, in miles, around this location.
  *  Should be one of the array values in the Places/nearby/miles config.
  * @param {string} $publisherId The id of the publisher to publish this stream
  *  Defaults to the app name in Q/app config.
  * @param {string} $streamName The name of the stream to create.
  *  Defaults to Places_Nearby::streamName($latitude, $longitude, $miles).
  * @return {Streams_Stream} Returns the stream object that was created or fetched.
  */
 static function stream($latitude, $longitude, $miles, $publisherId = null, $streamName = null)
 {
     list($latitude, $longGrid) = Places::quantize($latitude, $longitude, $miles);
     $zipcodes = Places_Zipcode::nearby($latitude, $longitude, $miles, 1);
     if (!isset($publisherId)) {
         $publisherId = Q_Config::expect('Q', 'app');
     }
     if (!isset($streamName)) {
         $streamName = self::streamName($latitude, $longitude, $miles);
     }
     if ($stream = Streams::fetchOne(null, $publisherId, $streamName)) {
         return $stream;
     }
     $zipcode = $zipcodes ? reset($zipcodes) : null;
     $stream = new Streams_Stream();
     $stream->publisherId = $publisherId;
     $stream->name = $streamName;
     $stream->type = "Places/nearby";
     $stream->title = $zipcode ? "Nearby ({$latitude}, {$longitude}): {$zipcode->placeName}, zipcode {$zipcode->zipcode}" : "Nearby ({$latitude}, {$longitude})";
     $stream->setAttribute('latitude', $latitude);
     $stream->setAttribute('longitude', $longitude);
     if ($zipcode) {
         $stream->setAttribute('zipcode', $zipcode->zipcode);
         $stream->setAttribute('placeName', $zipcode->placeName);
         $stream->setAttribute('state', $zipcode->state);
     }
     $stream->save();
     return $stream;
 }
<?php

$words = new MOD_words();
$thumbPathMember = MOD_layoutbits::PIC_30_30($_SESSION['Username'], '', $style = 'float_left framed');
//$imagePathMember = MOD_user::getImage();
$_newMessagesNumber = $this->model->getNewMessagesNumber($_SESSION['IdMember']);
if ($_newMessagesNumber > 0) {
    $_mainPageNewMessagesMessage = $words->getFormatted('MainPageNewMessages', $_newMessagesNumber);
}
$LayoutBits = new MOD_layoutbits();
$ShowDonateBar = $LayoutBits->getParams('ToggleDonateBar');
$notify_widget = new NotifyMemberWidget();
$notify_widget->model = new NotifyModel();
$notify_widget->items_per_page = 4;
$inbox_widget = new MailboxWidget_Personalstart();
$inbox_widget->model = new MessagesModel();
$inbox_widget->items_per_page = 4;
$Trip = new Trip();
$TripcallbackId = $Trip->createProcess();
$editing = false;
$Places = new Places();
$Countries = $Places->getAllCountries();
Esempio n. 14
0
 public function indexAction()
 {
     $this->view->headTitle('Welcome');
     $placeFinder = new Places();
     $this->view->places = $placeFinder->fetchLatest();
 }
Esempio n. 15
0
 function __construct()
 {
     header('Content-Type: application/json');
     require_once 'libs/config.php';
     //Archivo con configuraciones.
     $this->_system = System::singleton();
     //contiene objeto system
     $_POST = json_decode(file_get_contents('php://input'), true);
     require_once 'libs/apps/places/class.places.php';
     $places = new Places();
     $what = empty($_POST['what']) ? null : $_POST['what'];
     $token = empty($_POST['token']) ? null : $_POST['token'];
     if ($token === session_id()) {
         if ($what === "LIST_PROVINCES") {
             $data = array();
             $provinces = $places->listProvinces($data);
             echo json_encode($provinces);
         } else {
             if ($what === "LIST_TOWNS") {
                 $id_province = empty($_POST['id']) ? 0 : $this->_system->nohacker($_POST['id']);
                 $towns = $places->listTowns($id_province);
                 echo json_encode($towns);
             } else {
                 if ($what === "LIST_TOWNS_FROM_NAME") {
                     $town_name = empty($_POST['town_name']) ? null : $this->_system->nohacker($_POST['town_name']);
                     $section = empty($_POST['section']) ? null : $this->_system->nohacker($_POST['section']);
                     $towns = $places->listTownsFromName($town_name, $section);
                     echo json_encode($towns);
                 } else {
                     if ($what === "TOWN_INFO") {
                         $id_town = empty($_POST['id']) ? 0 : $this->_system->nohacker($_POST['id']);
                         $town_name = empty($_POST['town_name']) ? null : $this->_system->nohacker($_POST['town_name']);
                         $town = $places->getTownInfo($id_town, $town_name);
                         echo json_encode($town);
                     } else {
                         if ($what === "UPDATE_TOWN") {
                             if ((int) $_SESSION['update'] === 1) {
                                 $id_town = empty($_POST['id_town']) ? null : $this->_system->nohacker($_POST['id_town']);
                                 $town_water_provider = empty($_POST['town_water_provider']) ? null : $this->_system->nohacker($_POST['town_water_provider']);
                                 $town_w_contract_init = empty($_POST['town_w_contract_init']) ? null : $this->_system->nohacker($_POST['town_w_contract_init']);
                                 $town_w_contract_end = empty($_POST['town_w_contract_end']) ? null : $this->_system->nohacker($_POST['town_w_contract_end']);
                                 $town_sanity_provider = empty($_POST['town_sanity_provider']) ? null : $this->_system->nohacker($_POST['town_sanity_provider']);
                                 $town_s_contract_init = empty($_POST['town_s_contract_init']) ? null : $this->_system->nohacker($_POST['town_s_contract_init']);
                                 $town_s_contract_end = empty($_POST['town_s_contract_end']) ? null : $this->_system->nohacker($_POST['town_s_contract_end']);
                                 $town_observations = empty($_POST['town_observations']) ? null : $this->_system->nohacker($_POST['town_observations']);
                                 $town_govern = empty($_POST['town_govern']) ? null : $this->_system->nohacker($_POST['town_govern']);
                                 $prox_prorroga = empty($_POST['prox_prorroga']) ? null : $this->_system->nohacker($_POST['prox_prorroga']);
                                 $prox_concurso = empty($_POST['prox_concurso']) ? null : $this->_system->nohacker($_POST['prox_concurso']);
                                 $fut_prorroga = empty($_POST['fut_prorroga']) ? null : $this->_system->nohacker($_POST['fut_prorroga']);
                                 $cartera = empty($_POST['cartera']) ? null : $this->_system->nohacker($_POST['cartera']);
                                 $neg_2016 = empty($_POST['neg_2016']) ? null : $this->_system->nohacker($_POST['neg_2016']);
                                 $neg_2017 = empty($_POST['neg_2017']) ? null : $this->_system->nohacker($_POST['neg_2017']);
                                 $neg_2018 = empty($_POST['neg_2018']) ? null : $this->_system->nohacker($_POST['neg_2018']);
                                 $inv_2016 = empty($_POST['inv_2016']) ? null : $this->_system->nohacker($_POST['inv_2016']);
                                 $inv_2017 = empty($_POST['inv_2017']) ? null : $this->_system->nohacker($_POST['inv_2017']);
                                 $inv_2018 = empty($_POST['inv_2018']) ? null : $this->_system->nohacker($_POST['inv_2018']);
                                 $inv_resto = empty($_POST['inv_resto']) ? null : $this->_system->nohacker($_POST['inv_resto']);
                                 $neg_resto = empty($_POST['neg_resto']) ? null : $this->_system->nohacker($_POST['neg_resto']);
                                 $inv_total = empty($_POST['inv_total']) ? null : $this->_system->nohacker($_POST['inv_total']);
                                 $cmun5_ine = empty($_POST['cmun5_ine']) ? null : $this->_system->nohacker($_POST['cmun5_ine']);
                                 $data = array('sub_aqp' => $town_water_provider, 'sub_cla' => $town_sanity_provider, 'gobierno' => $town_govern, 'observaciones' => $town_observations);
                                 $dataConcesion = array('prox_prorroga' => $prox_prorroga, 'prox_concurso' => $prox_concurso, 'fut_prorroga' => $fut_prorroga, 'cartera' => $cartera, 'neg_2016' => $neg_2016, 'neg_2017' => $neg_2017, 'neg_2018' => $neg_2018, 'inv_2016' => $inv_2016, 'inv_2017' => $inv_2017, 'inv_2018' => $inv_2018, 'inv_resto' => $inv_resto, 'neg_resto' => $neg_resto, 'inv_total' => $inv_total);
                                 if ($town_w_contract_init) {
                                     $data['ap_data_ini'] = $town_w_contract_init;
                                 }
                                 if ($town_w_contract_end) {
                                     $data['ap_data_fi'] = $town_w_contract_end;
                                 }
                                 if ($town_s_contract_init) {
                                     $data['cla_data_ini'] = $town_s_contract_init;
                                 }
                                 if ($town_s_contract_end) {
                                     $data['cla_data_fi'] = $town_s_contract_end;
                                 }
                                 if ($id_town) {
                                     $town = $places->updateTown($data, $id_town);
                                     $concesion = $places->updateConcesion($dataConcesion, $cmun5_ine);
                                     echo json_encode($town);
                                 } else {
                                     echo json_encode(array("status" => "Failed", "message" => "id_town can't be null", "code" => 501));
                                 }
                             } else {
                                 echo json_encode(array("status" => "Failed", "message" => "Permission denied. User can't update", "code" => 501));
                             }
                         } else {
                             if ($what === "PREVIEW_REPORT") {
                                 $cpro_dgc = empty($_POST['cpro_dgc']) ? null : $this->_system->nohacker($_POST['cpro_dgc']);
                                 $area_km2 = empty($_POST['area_km2']) ? null : $this->_system->nohacker($_POST['area_km2']);
                                 $habitantes = empty($_POST['habitantes']) ? null : $this->_system->nohacker($_POST['habitantes']);
                                 $sub_aqp = empty($_POST['sub_aqp']) ? null : $this->_system->nohacker($_POST['sub_aqp']);
                                 $ap_data_ini = empty($_POST['ap_data_ini']) ? null : $this->_system->nohacker($_POST['ap_data_ini']);
                                 $ap_data_fi = empty($_POST['ap_data_fi']) ? null : $this->_system->nohacker($_POST['ap_data_fi']);
                                 $sub_cla = empty($_POST['sub_cla']) ? null : $this->_system->nohacker($_POST['sub_cla']);
                                 $cla_data_ini = empty($_POST['cla_data_ini']) ? null : $this->_system->nohacker($_POST['cla_data_ini']);
                                 $cla_data_fi = empty($_POST['cla_data_fi']) ? null : $this->_system->nohacker($_POST['cla_data_fi']);
                                 $prox_concurso = empty($_POST['prox_concurso']) ? null : $this->_system->nohacker($_POST['prox_concurso']);
                                 $fut_prorroga = empty($_POST['fut_prorroga']) ? null : $this->_system->nohacker($_POST['fut_prorroga']);
                                 $cartera = empty($_POST['cartera']) ? null : $this->_system->nohacker($_POST['cartera']);
                                 $neg_2016 = empty($_POST['neg_2016']) ? null : $this->_system->nohacker($_POST['neg_2016']);
                                 $neg_2017 = empty($_POST['neg_2017']) ? null : $this->_system->nohacker($_POST['neg_2017']);
                                 $neg_2018 = empty($_POST['neg_2018']) ? null : $this->_system->nohacker($_POST['neg_2018']);
                                 $neg_resto = empty($_POST['neg_resto']) ? null : $this->_system->nohacker($_POST['neg_resto']);
                                 $inv_2016 = empty($_POST['inv_2016']) ? null : $this->_system->nohacker($_POST['inv_2016']);
                                 $inv_2017 = empty($_POST['inv_2017']) ? null : $this->_system->nohacker($_POST['inv_2017']);
                                 $inv_2018 = empty($_POST['inv_2018']) ? null : $this->_system->nohacker($_POST['inv_2018']);
                                 $inv_resto = empty($_POST['inv_resto']) ? null : $this->_system->nohacker($_POST['inv_resto']);
                                 $inv_total = empty($_POST['inv_total']) ? null : $this->_system->nohacker($_POST['inv_total']);
                                 $createFile = empty($_POST['createFile']) ? null : $this->_system->nohacker($_POST['createFile']);
                                 $limit = empty($_POST['limit']) ? null : $this->_system->nohacker($_POST['limit']);
                                 $data = array('cpro_dgc' => $cpro_dgc, 'habitantes' => $habitantes, 'area_km2' => $area_km2, 'sub_aqp' => $sub_aqp, 'ap_data_ini' => $ap_data_ini, 'ap_data_fi' => $ap_data_fi, 'sub_cla' => $sub_cla, 'cla_data_ini' => $cla_data_ini, 'cla_data_fi' => $cla_data_fi, 'prox_concurso' => $prox_concurso, 'fut_prorroga' => $fut_prorroga, 'cartera' => $cartera, 'neg_2016' => $neg_2016, 'neg_2017' => $neg_2017, 'neg_2018' => $neg_2018, 'neg_resto' => $neg_resto, 'inv_2016' => $inv_2016, 'inv_2017' => $inv_2017, 'inv_2018' => $inv_2018, 'inv_resto' => $inv_resto, 'inv_total' => $inv_total);
                                 $report = $places->previewReport($data, $createFile, $limit);
                                 echo json_encode($report);
                             } else {
                                 if ($what === "CREATE_REPORT") {
                                     //				$id_province     	= (empty($_POST['province_id'])) 			? 0 	: $this->_system->nohacker($_POST['province_id']);
                                     //				$report				= $places->createReport($id_province);
                                     //				echo json_encode($report);
                                 } else {
                                     if ($what === "GET_TOWN_EXTRA_INFO") {
                                         $cmun5_ine = empty($_POST['cmun5_ine']) ? null : $this->_system->nohacker($_POST['cmun5_ine']);
                                         $extra = $places->getExtraInfoFromTown($cmun5_ine);
                                         echo json_encode($extra);
                                     } else {
                                         if ($what === "ADD_NOTE") {
                                             $municipio_id = empty($_POST['municipio_id']) ? 0 : $this->_system->nohacker($_POST['municipio_id']);
                                             $mensaje = empty($_POST['mensaje']) ? 0 : $this->_system->nohacker($_POST['mensaje']);
                                             $data = array("mensaje" => $mensaje, "municipio_id" => $municipio_id, "user_id" => $_SESSION['id']);
                                             $extra = $places->addNote($data);
                                             echo json_encode($extra);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         echo json_encode(array("status" => "Failed", "message" => "Cross site injection detected", "code" => 501));
     }
 }
Esempio n. 16
0
 /** Edit individual rally details
  */
 public function editAction()
 {
     if ($this->_getParam('id', false)) {
         $form = new RallyForm();
         $form->submit->setLabel('Update details');
         $this->view->form = $form;
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $results = $this->GridCalc($form->getValue('gridref'));
                 $fourFigure = $this->FourFigure($form->getValue('gridref'));
                 $updateData = array('rally_name' => $form->getValue('rally_name'), 'organiser' => $form->getValue('organiser'), 'county' => $form->getValue('county'), 'district' => $form->getValue('district'), 'parish' => $form->getValue('parish'), 'gridref' => $form->getValue('gridref'), 'easting' => $results['Easting'], 'northing' => $results['Northing'], 'latitude' => $results['Latitude'], 'longitude' => $results['Longitude'], 'map10k' => $results['Tenk'], 'map25k' => $results['2pt5K'], 'fourFigure' => $fourFigure, 'comments' => $form->getValue('comments'), 'record_method' => $form->getValue('record_method'), 'date_from' => $form->getValue('date_from'), 'date_to' => $form->getValue('date_to'), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms());
                 $where = array();
                 $where[] = $this->_rallies->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                 $update = $this->_rallies->update($updateData, $where);
                 $this->_cache->remove('rallydd');
                 $this->_flashMessenger->addMessage('Rally information updated!');
                 $this->_redirect(self::URL . 'rally/id/' . $this->_getParam('id'));
             } else {
                 if (!is_null($formData['district'])) {
                     $districts = new Places();
                     $district_list = $districts->getDistrictList($formData['county']);
                     $form->district->addMultiOptions(array(NULL => NULL, 'Choose district' => $district_list));
                     $parish_list = $districts->getParishList($formData['district']);
                     $form->parish->addMultiOptions(array(NULL => NULL, 'Choose parish' => $parish_list));
                 }
                 $form->populate($formData);
             }
         } else {
             // find id is expected in $params['id']
             $id = (int) $this->_request->getParam('id', 0);
             if ($id > 0) {
                 $rallies = new Rallies();
                 $rally = $rallies->fetchRow('id=' . $id);
                 if (count($rally)) {
                     $form->populate($rally->toArray());
                 } else {
                     throw new Exception($this->_nothingFound);
                 }
                 if (!is_null($rally['district'])) {
                     $districts = new Places();
                     $district_list = $districts->getDistrictList($rally['county']);
                     $form->district->addMultiOptions(array(NULL => NULL, 'Choose district' => $district_list));
                     $parish_list = $districts->getParishList($rally['district']);
                     $form->parish->addMultiOptions(array(NULL => NULL, 'Choose parish' => $parish_list));
                 }
                 if (!is_null($rally['organiser'])) {
                     $organisers = new Peoples();
                     $organisers = $organisers->getName($rally['organiser']);
                     foreach ($organisers as $organiser) {
                         $form->organisername->setValue($organiser['term']);
                     }
                 }
             }
         }
     } else {
         throw new Exception($this->_missingParameter);
     }
 }
Esempio n. 17
0
function Places_autocomplete_response_results()
{
    $r = Q::take($_REQUEST, array('input' => '', 'types' => null, 'latitude' => null, 'longitude' => null, 'miles' => 25));
    return Places::autocomplete($r['input'], true, $r['types'], $r['latitude'], $r['longitude'], $r['miles']);
}
Esempio n. 18
0
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Places.php";
session_start();
if (empty($_SESSION['list_of_places'])) {
    $_SESSION['list_of_places'] = array();
}
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('places.html.twig', array('places' => Places::getAll()));
});
$app->post("/places", function () use($app) {
    $places = new Places($_POST['place'], $_POST['duration']);
    $places->save();
    return $app['twig']->render('create_place.html.twig', array('newplace' => $places));
});
$app->post("/delete_place", function () use($app) {
    Places::deleteAll();
    return $app['twig']->render('delete_place.html.twig');
});
return $app;