public function setSubSections() { $trails_ids = implode(",", array_keys($this->allTrailAssigned)); $data = array(); if (!empty($trails_ids)) { $sql = "SELECT trail_id, series from settings WHERE trail_id in ({$trails_ids})"; $records = $this->db->run($sql); if (sizeof($records) > 0) { foreach ($records as $key => $val) { if (!empty($val["series"])) { $series_arr = explode(",", $val["series"]); foreach ($series_arr as $k => $seria) { if (!in_array(trim($seria), $data) && !empty($seria)) { $data[] = trim($seria); } } } } return $data; } else { logDebugMessages($sql); return false; } } else { return false; } }
function exec_sql($sql) { try { $res = mysql_catchquery($sql); return $res; } catch (Exception $e) { logDebugMessages($e->getMessage()); return false; } }
public function getMapboxDefaultStyle() { $sql = "SELECT * FROM mapbox_styles_assignments WHERE type = 'def_trails'"; $records = $this->db->run($sql); if (sizeof($records) > 0) { return (object) $records[0]; } else { logDebugMessages($sql); return false; } }
public function setNextScene() { $records = array(); if (!$this->scene || empty($this->params->trailid)) { return false; } $sql = "SELECT * FROM scenes AS s\n WHERE s.trail_id = '{$this->params->trailid}' AND title > '{$this->scene->title}'\n ORDER BY title ASC\n LIMIT 1"; $records = $this->db->run($sql); if (sizeof($records) > 0) { return (object) $records[0]; } else { logDebugMessages($sql); return false; } }
public function getParkDetatls($parks_array = null) { $records = array(); $parks_ids = implode(",", $parks_array); if (!empty($parks_ids)) { // $sql = "SELECT * FROM park_settings WHERE park_id in (" . $parks_ids . ")"; $sql = "SELECT id as ID, post_title as name FROM wp_posts WHERE id in (" . $parks_ids . ")"; $records = $this->wp_db->run($sql); if (sizeof($records) > 0) { return $records[0]; } else { logDebugMessages($sql); return false; } } }
public function run($sql, $bind = "") { $this->sql = trim($sql); $this->bind = $this->cleanup($bind); $this->error = ""; try { $pdostmt = $this->prepare($this->sql); if ($pdostmt->execute($this->bind) !== false) { if (preg_match("/^(" . implode("|", array("select", "describe", "pragma")) . ") /i", $this->sql)) { return $pdostmt->fetchAll(PDO::FETCH_ASSOC); } elseif (preg_match("/^(" . implode("|", array("delete", "insert", "update")) . ") /i", $this->sql)) { return $pdostmt->rowCount(); } } } catch (PDOException $e) { $this->error = $e->getMessage(); logDebugMessages($e->getMessage(), DEV_MOD); $this->debug(); return false; } }
public function getResult() { if (!$this->trail) { logDebugMessages("No trail found"); return false; } $autorotate = !empty($this->settings->autorotate) && $this->settings->autorotate ? 'True' : 'False'; $speed = !empty($this->settings->speed) ? $this->settings->speed : '1.0'; //$row = $this - scene //broken compass workaround if (empty($this->scene->getScene()->name3) && strpos($this->scene->getScene()->name2, 'pointer')) { $this->scene->getScene()->name3 = $this->scene->getScene()->name2; $this->scene->getScene()->name2 = str_replace('_pointer', '', $this->scene->getScene()->name2); } // START OUTPUT $output_json = array(); $current_scene = $this->scene->getScene(); $output_json['ID'] = !empty($this->trail->ID) ? $this->trail->ID : null; $output_json['trail_name'] = !empty($this->trail->post_title) ? $this->trail->post_title : null; $output_json['trail_description'] = !empty($this->trail->post_content) ? $this->trail->post_content : null; $output_json['mapbox_style'] = !empty($this->mapbox_style->mapbox_style_id) ? $this->mapbox_style->mapbox_style_id : null; $output_json['prev_scene'] = !empty($this->scene->getPrevScene()->scene_name) ? $this->scene->getPrevScene()->scene_name : null; $output_json['curr_scene'] = $current_scene->scene_name; $output_json['next_scene'] = $this->scene->getNextScene()->scene_name; $output_json['elevation'] = $current_scene->elevation; $output_json['latitude'] = $current_scene->latitude; $output_json['longitude'] = $current_scene->longitude; $output_json['bearing'] = $current_scene->bearing; $output_json['hlookat'] = $current_scene->view_hlookat; $output_json['vlookat'] = $current_scene->view_vlookat; $output_json['mobile_url'] = $current_scene->mobile; $output_json['nexttrail_id'] = ''; $output_json['prevtrail_id'] = ''; if (is_object($this->next_trail) && !empty($this->next_trail->guid)) { //workaround for using wp posts table with mixed domain prefixes - .terrain360, www.terrain360, wp.terrain360 if ($_SERVER['HTTP_HOST'] == 'wp.terrain360.com') { $this->next_trail->guid = str_replace('www.terrain360', 'wp.terrain360', $this->next_trail->guid); } else { $this->next_trail->guid = str_replace('wp.terrain360', 'www.terrain360', $this->next_trail->guid); } $next_url = parseUrl($this->next_trail->guid); $output_json['nexttrail_id'] = $next_url[1]; } if (is_object($this->prev_trail) && !empty($this->prev_trail->guid)) { if ($_SERVER['HTTP_HOST'] == 'wp.terrain360.com') { $this->prev_trail->guid = str_replace('www.terrain360', 'wp.terrain360', $this->prev_trail->guid); } else { $this->prev_trail->guid = str_replace('wp.terrain360', 'www.terrain360', $this->prev_trail->guid); } $prev_url = parseUrl($this->prev_trail->guid); $output_json['prevtrail_id'] = $prev_url[1]; } $output_json['zip'] = $this->weather->location->zip; $output_json['weather_data'] = $this->weather->weather_data; $output_json['t360shortURL'] = "http://t360.it/" . shortURL::encode($this->params->trailid) . $current_scene->title; $parks = new parksModel($this->params); if (!empty($parks)) { $output_json['parks'] = $parks->getAssignedParks(); } $rivers = new riversModel($this->params); if (!empty($rivers)) { $output_json['rivers'] = $rivers->getAssignedRivers(); } if (!empty($this->settings->series)) { $at_array = (object) explode(', ', $this->settings->series); $output_json['series'] = $at_array; } return $output_json; }