static function getSpot($id) { $spot = Spot::_getSpotById($id); if ($spot) { $arr = array('places' => $spot, 'errno' => 0, 'error' => ''); } else { $arr = array('errno' => -1, 'error' => 'System error'); } return $arr; }
public function getSpot($id) { if (is_array($id)) { $count = 1; $translate = array('sysName' => 'systemName', 'tplSpotId' => 'tplSpotId'); foreach ($id as $key => $value) { if (isset($translate[$key])) { $key = $translate[$key]; } if ($key == 'tplSpotId') { $innerjoin = " INNER JOIN ink_template_spots B ON (A.spotId = B.spotId)"; $letter = "B."; $tplSpotIdSelector = ", B.tplSpotId"; } else { $innerjoin = ""; $letter = "A."; $tplSpotIdSelector = ""; } $where = $letter . $key . " = '" . $value . "'"; $where .= $count != count($id) ? ' AND ' : ';'; } } else { $where = 'spotId = ' . $id . ';'; $innerjoin = ""; $tplSpotIdSelector = ""; } $sql = "SELECT A.*{$tplSpotIdSelector} FROM ink_spots A {$innerjoin} WHERE {$where}"; $row = $this->runSingleQuery($sql); if (isset($row['spotId'])) { $properties = array('id' => $row['spotId'], 'name' => $row['name'], 'uservalue' => $row['uservalue'], 'sysName' => $row['systemName'], 'availableConfigs' => $this->getAvailableconfigs($row['spotId'])); if (isset($row['tplSpotId'])) { $properties['configs'] = $this->getConfigs($row['tplSpotId']); } $spot = new Spot(); $spot->setProperties($properties); return $spot; } return false; }
$this->state = "few"; }else{ $this->state = "many"; } } function dumpJSon(){ return "{\"name\":\"".$this->name."\",\"count\":\"".$this->count."\",\"free\":\"".$this->free."\",\"state\":\"".$this->state."\",\"forecast\":\"".$this->forecast."\"}"; } } $site = new DOMDocument(); $site->loadHTML(file_get_contents("http://www.pls-zh.ch/plsFeed/rss")); $spotlist = $site->getElementsByTagName('item'); $spots = array(); foreach($spotlist as $spot){ $s = new Spot(); $s->name=$spot->getElementsByTagName('title')->item(0)->nodeValue; $s->free=str_replace(" ", "", explode(" / ",$spot->getElementsByTagName('description')->item(0)->nodeValue)[1]); $s->evalMax(); $s->checkForecast(); $s->calcState(); if(str_replace(" ", "", explode(" / ", $spot->getElementsByTagName('description')->item(0)->nodeValue)[0]) != "open"){ $s->state = "closed"; } $spots[] = $s; } $json = "[{\"name\":\"Zürich\",\"lots\":["; foreach($spots as $spot){ $json = $json.$spot->dumpJSon().","; }
$stmt->setFetchMode(PDO::FETCH_ASSOC); $res = $stmt->fetchAll(); foreach ($res as $k => $v) { $this->res[$k]['bannerList'] = explode(',', $v['picture']); $this->res[$k]['info']['name'] = $v['name']; $this->res[$k]['info']['describe'] = $v['description']; $this->res[$k]['info']['commentNum'] = $v['comment_number']; $this->res[$k]['info']['goneNum'] = $v['went_number']; $this->res[$k]['info']['wantNum'] = $v['want_number']; $sql_views = "SELECT * FROM ft_view WHERE spot_id=:spot_id"; $stmt_views = $this->db->prepare($sql_views); $stmt_views->execute(array(':spot_id' => $v['spot_id'])); $stmt->setFetchMode(PDO::FETCH_ASSOC); $views = $stmt_views->fetchAll(); $this->res[$k]['info']['viewList'] = $views; } if ($res) { $this->res['code'] = 0; $this->res['message'] = 'success'; } else { $this->res['code'] = 1055; $this->res['message'] = '查询数据库失败'; } } function __destruct() { $this->die_json($this->res); } } $spot = new Spot(); $spot->index();
static function update() { if (isset($_POST["new"])) { switch ($_GET["sub"]) { case "spots": echo "kurwa"; Spot::createSpot(); break; case "menus": case "subscriptions": break; } } }
/** * Return list of PrevisionDate for one day (date) for the spot for all website * @param Spot $spot * @param DateTime $date */ public function getPrevDateAllWebSiteOneDay($spot, $date) { $queryBuilder = $this->createQueryBuilder('previsionDate'); $queryBuilder->where($queryBuilder->expr()->andx($queryBuilder->expr()->eq('previsionDate.dataWindPrev.spot_id', $spot->getId()), $queryBuilder->expr()->eq('previsionDate.datePrev', $date))); //TODO:check for houre try { return $queryBuilder->getQuery()->getResult(); } catch (\Doctrine\ORM\NoResultException $e) { return null; } }
public function getThumbnailImage() { $photos = $this->photos; if (count($photos) == 0) { return Spot::missingSpotImage(); } else { return $photos[0]; } }
static function testSpot() { $logout = User::logout(); $spot = new Spot(); $uid = $_SESSION["uid"] = "378984"; if (($create = $spot->createSpot()) !== NULL) { echo 'CREATE SPOT: <font color="green">STWORZONO: ' . $create . '</font></br>'; } else { echo 'CREATE SPOT: <font color="red">ERROR!</font></br>'; return false; } if ($spot->getSpots() !== NULL) { echo 'GET SPOTS: <font color="green">ODNALEZIONO</font></br>'; } else { echo 'GET SPOTS: <font color="red">ERROR!</font></br>'; return false; } if ($spot->getSpotsByUser() !== NULL) { echo 'GET SPOTS BY USER: <font color="green">ODNALEZIONO</font></br>'; } else { echo 'GET SPOTS BY USER: <font color="red">ERROR!</font></br>'; return false; } if ($spot->getSpotById($create) !== NULL) { echo 'GET SPOTS BY ID: <font color="green">ODNALEZIONO</font></br>'; } else { echo 'GET SPOTS BY ID: <font color="red">ERROR!</font></br>'; return false; } $spot = $spot->getSpotById($create); $oldMapIcon = $spot->map_icon; $oldBanner = $spot->map_banner; $oldLat = $spot->lat; $oldLng = $spot->lng; $oldAddress = $spot->address; $string = self::generateRandomString(); $spot->updateTitle($string); $spot = $spot->getSpotById($create); if ($spot->title == $string) { echo 'UPDATE TITLE: <font color="green">UDANE</font></br>'; } else { echo 'UPDATE TITLE: <font color="red">ERROR!</font></br>'; return false; } $spot->updateMapIcon("312312"); $spot = $spot->getSpotById($create); if ($oldMapIcon !== $spot->map_icon) { echo 'UPDATE MAP ICON: <font color="green">UDANE</font></br>'; } else { echo 'UPDATE MAP ICON: <font color="red">ERROR!</font></br>'; return false; } $spot->updateBanner("312312"); $spot = $spot->getSpotById($create); if ($oldBanner !== $spot->map_banner) { echo 'UPDATE BANNER: <font color="green">UDANE</font></br>'; } else { echo 'UPDATE BANNER: <font color="red">ERROR!</font></br>'; return false; } $spot->updateLocation("312312", "312312", "312312"); $spot = $spot->getSpotById($create); if ($oldLat !== $spot->lat && $oldLng !== $spot->lng && $oldAddress !== $spot->address) { echo 'UPDATE LOCATION: <font color="green">UDANE</font></br>'; } else { echo 'UPDATE LOCATION: <font color="red">ERROR!</font></br>'; return false; } $_POST["id"] = $create; $spot->deleteSpot(); if (($spot = $spot->getSpotById($create)) == NULL) { echo 'DELETE SPOT: <font color="green">UDANE</font></br>'; } else { echo 'DELETE SPOT: <font color="red">ERROR!</font></br>'; return false; } return true; }
<?php require_once 'Connections.php'; require_once 'models/User.php'; require_once 'models/Spot.php'; (new Database())->reinstall(); $_POST["login"] = "******"; $_POST["pass"] = "******"; $_POST["email"] = "*****@*****.**"; User::createUser(); User::login(); assert(User::checkLogin()); $id = Spot::createSpot(); echo "spot id:" . $id; $spot = Spot::getSpotById($id); assert($spot->id == $id);
/** * Get the direction to another spot in degrees * * @param Post $other * @param integer $abs the round-precision in decimals * * @return double */ public function getBearingTo(Spot $other, $precision = 0) { $lat1 = $this->lat; $lon1 = $this->lon; $lat2 = $other->latitude(); $lon2 = $other->longitude(); $dLon = deg2rad($lon2) - deg2rad($lon1); //difference in the phi of latitudinal coordinates $dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4)); //we need to recalculate $dLon if it is greater than pi if (abs($dLon) > pi()) { if ($dLon > 0) { $dLon = (2 * pi() - $dLon) * -1; } else { $dLon = 2 * pi() + $dLon; } } //return the angle, normalized return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; }
public function updateAllSpotsToSoftDelete() { echo "Total before soft delete: " . Spot::all()->count() . "<br>"; foreach (Spot::withTrashed()->get() as $spot) { if ($spot->status == 'Delete') { $spot->delete(); } } echo "Total after soft delete: " . Spot::all()->count() . "<br>"; }