public function onCommand(CommandSender $sender, Command $command, $label, array $args) { if ($sender instanceof Player) { if (count($args) == 0) { $sender->sendMessage(TextFormat::RED . "Not enough arguments."); return; } if (count($args) == 1) { if ($this->getServer()->getPlayer($args[0])) { $location = $this->getServer()->getPlayer($args[0])->getLocation(); $sender->teleport($location); $sender->sendMessage(TextFormat::BLUE . "[Server] You have teleported to {$args['0']}"); return; } else { $sender->sendMessage(TextFormat::RED . "[Server] That player isn't online!"); return; } } if (count($args) == 2) { if ($this->getServer()->getPlayer($args[0]) & getLocation() && $this->getServer()->getPlayer($args[1])) { $location2 = $this->getServer()->getPlayer($args[1])->getLocation(); $player1 = $this->getServer()->getPlayer($args[0]); $player2 = $this->getServer()->getPlayer($args[1]); $player1->teleport($location2); $player1->sendMessage(TextFormat::BLUE . "[Server] You have teleported to {$args['1']}"); return; } } } }
private function getAndroidVideoUrl($vid) { $videoAddressUrl = ""; if (isset($vid) && !is_null($vid)) { $url = replaceStr(YouKuContent::BASE_URL, "{id}", $vid); //check gaoqing $hdurl = replaceStr($url, "{format}", "3gphd"); $location = getLocation($hdurl); // writetofile("daa.txt", $hdurl); $flag = false; if (!isN($location) && strpos($location, $this->notfound) === false) { $videoAddressUrl = $videoAddressUrl . MovieType::HIGH_CLEAR . MovieType::VIDEO_NAME_URL_SEP . $hdurl; $flag = true; } $hdurl = replaceStr($url, "{format}", "3gp"); $location = getLocation($hdurl); // writetofile("daa.txt", $hdurl); if (!isN($location) && strpos($location, $this->notfound) === false) { if ($flag) { $videoAddressUrl = $videoAddressUrl . MovieType::VIDEO_SEP_VERSION; } $videoAddressUrl = $videoAddressUrl . MovieType::NORMAL . MovieType::VIDEO_NAME_URL_SEP . $hdurl; } } return $videoAddressUrl; }
function catch_url($k) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.xiami.com/search?key=" . $k); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $output = curl_exec($ch); curl_close($ch); $regs = array(); //<a target="_blank" href="http://www.xiami.com/song/1773101670?spm=a1z1s.3521865.23309997.1.cT77HE" title="Palpitation!" data-spm-anchor-id="a1z1s.3521865.23309997.1">Palpitation!</a> preg_match_all("/href=\"http:\\/\\/www.xiami.com\\/song\\/(\\d+)/is", $output, $regs); $ids = $regs[1]; $index = 0; foreach ($ids as $item) { $xml_url = "http://www.xiami.com/widget/xml-single/uid/0/sid/" . $item; $info = getInfo($xml_url); $location = getLocation($info->location); ?> <audio controls="controls"> <source src="<?php echo $location; ?> " type="audio/mpeg" /> Your browser does not support the audio element. </audio> <span><?php echo $info->song_name; ?> </span><img src="<?php echo $info->album_cover; ?> "/></br> <input type="hidden" value="<?php echo $location; ?> "/> <span style="display:none;">src:<?php echo $location; ?> </span><br/> <?php echo '<span><input type="button" onclick="mpg(' . $index . ')" value="mpg it"/></span><br/>'; $index += 1; } }
/** * 删除用户 * * @param array|string $uids * @return boolean */ public function deleteUser($uids) { //防止误删 $uids = is_array($uids) ? $uids : explode(',', $uids); foreach ($uids as $k => $v) { if (!is_numeric($v)) { unset($uids[$k]); } } if (empty($uids)) { return false; }
public function edit() { $tid = intval($_GET['tid']); if ($this->checkFormSubmit()) { $tasknew = $_GET['tasknew']; if ($tasknew['title'] && $tasknew['contact'] && $tasknew['catid']) { $location = getLocation($tasknew['city'], $tasknew['address']); $tasknew['longitude'] = $location['longitude']; $tasknew['latitude'] = $location['latitude']; $this->t('task')->where(array('uid' => $this->uid, 'tid' => $tid))->update($tasknew); $pics = $_GET['pic']; if ($pics && is_array($pics)) { $this->t('task')->where(array('tid' => $tid))->update(array('pic' => $pics[0])); $this->t('image')->where(array('dataid' => $tid, 'datatype' => 'task'))->delete(); foreach ($pics as $pic) { $this->t('image')->insert(array('dataid' => $tid, 'datatype' => 'task', 'image' => $pic)); } } $this->showSuccess('save_succeed'); } else { $this->showError('undefined_action'); } } else { global $G, $lang; $task = $this->t('task')->where(array('uid' => $this->uid, 'tid' => $tid))->selectOne(); if (!$task) { $this->showError('page_notfound'); } $pics = $this->t('image')->where(array('dataid' => $tid, 'datatype' => 'task'))->select(); if ($pics) { $newlist = array(); foreach ($pics as $plist) { $plist['url'] = image($plist['image']); $newlist[] = $plist; } $pics = $newlist; unset($newlist); } $categorylist = $this->getCategoryList(); $category = new \Core\Category(); $category->dataList = $categorylist; $categoryoptions = $category->getOptions(0, $task['catid']); include template('task_form'); } }
function getLatLong($address) { echo "<fieldset><legend>Info about {$address}</legend>"; $geocodeURL = "https://maps.googleapis.com/maps/api/geocode/xml?"; $address = "address=" . urlencode($address); $key = "key=AIzaSyD66xa224cyoktCawBN9CfMjPwzG6JVoYM"; $geocoderequest = "{$geocodeURL}{$address}" . "&" . $key; //die( "The url is >" . $geocoderequest . "<" ); $xml = new SimpleXMLElement(file_get_contents($geocoderequest)); if ($xml->status != 'OK') { $status = $xml->error_message; die("bad result status {$status}"); } $loc = getLocation($xml); echo "<pre>"; print_r($xml); echo "</pre>"; return $loc; }
function userinfo() { if ($_POST) { $data['uname'] = t($_POST['nickname']); if (mb_strlen($data['uname'], 'UTF8') > 10) { $this->error('昵称不能超过10个字符'); } $data['sex'] = intval($_POST['sex']); $data['province'] = intval($_POST['area_province']); $data['city'] = intval($_POST['area_city']); $data['location'] = getLocation($data['province'], $data['city']); $data['is_init'] = 1; M('user')->where('uid=' . $this->mid)->data($data)->save(); redirect(U('home/public/followuser')); } else { $this->display(); } }
<?php error_reporting(E_ALL); if (isset($_GET['classLocationId'])) { $classLocationId = $_GET['classLocationId']; } $chooseState = getAllState($dbconn); $location = getLocation($dbconn, $classLocationId); $contactId = $location['contactId']; try { if (isset($_POST['edit'])) { //valildators $tlname = trim($_POST['locationName']); //eliminate accidental space if (empty($tlname)) { $errors['locationName'] = 'Please create a class name you will remember.'; } else { if (!preg_match("/^[a-zA-Z0-9’'. -]+\$/", $_POST['locationName'])) { $errors['locationName'] = 'Please use appropriate format. Letters and numbers only.'; } } $tadd = trim($_POST['address']); //eliminate accidental space if (empty($tadd)) { $errors['address'] = 'Please give us the address'; } else { if (!preg_match("/^[a-zA-Z0-9’'. -]+\$/", $_POST['address'])) { $errors['address'] = 'Please use appropriate format.'; } } $tadd2 = trim($_POST['address2']);
/** * Welcome page * * @return string */ public function welcome() { $oSession = $this->getInstance("oxSetupSession"); //setting admin area default language $sAdminLang = $oSession->getSessionParam('setup_lang'); $this->getInstance("oxSetupUtils")->setCookie("oxidadminlanguage", $sAdminLang, time() + 31536000, "/"); $oView = $this->getView(); $oView->setTitle('STEP_1_TITLE'); $oView->setViewParam("aCountries", getCountryList()); $oView->setViewParam("aLocations", getLocation()); $oView->setViewParam("sSetupLang", $this->getInstance("oxSetupLang")->getSetupLang()); $oView->setViewParam("sLocationLang", $oSession->getSessionParam('location_lang')); $oView->setViewParam("sCountryLang", $oSession->getSessionParam('country_lang')); return "welcome.php"; }
$markup .= <<<MARKUP <tr><td>{$key}</td><td>{$value}</td></tr> MARKUP; } $markup .= '</table>'; } if ($self) { return $markup; } else { echo $markup; } } if (!empty($_GET['ip'])) { getLocation(); } else { $result = getLocation(true); $html = <<<MARKUP <html> <head><title>IP Locator</title> <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.9.0/build/reset-fonts-grids/reset-fonts-grids.css"> <style type="text/css"> #bd{ margin-top: 25px; border: 1px solid #C0C0C0; border-radius: 8px 8px 8px 8px; margin-top: 25px; padding: 25px; } #submit_form{ text-align: center; }
private function listBetween($offerIn, $model, $is_calendar = true) { $now = time(); $collection = lib('collection'); $quantity = $offerIn->quantity; $options = $offerIn->options; $language = $offerIn->language; $distance_maxB = $offerIn->distance_max; $start = $offerIn->start; $tolerance = $offerIn->tolerance; $oresellerid = $offerIn->reseller_id; $segment_id = $offerIn->segment_id; $start = is_null($start) ? $now + 4 * 3600 : $start; $tolerance = is_null($tolerance) ? 0 : $tolerance; $distance_maxB = is_null($distance_maxB) ? 0 : (double) $distance_maxB; $delai = $start - $now; $livraison = false; if (isset($options['shipping_costs'])) { if (isset($options['shipping_costs']['default'])) { $livraison = 'oui' == $options['shipping_costs']['default'] ? true : false; } } if ($delai <= 0) { return []; } $delai /= 3600; $list = Arrays::get($model, 'formulaire_achat.elements.quantity.values', []); $unite = Arrays::get($model, 'formulaire_achat.elements.quantity.unite', 'heure'); $optionsPrice = Arrays::get($model, 'formulaire_achat.elements.quantity.options.price', []); $optionsDiscount = Arrays::get($model, 'formulaire_achat.elements.quantity.options.discount', []); $optionsFixedCosts = Arrays::get($model, 'formulaire_achat.elements.quantity.options.fixed_costs', []); $optionsTravelCosts = Arrays::get($model, 'formulaire_achat.elements.quantity.options.travel_costs', []); $optionsShippingCosts = Arrays::get($model, 'formulaire_achat.elements.quantity.options.shipping_costs', []); $locOfferIn = getLocation($offerIn); $queryproducts = Model::Product()->where(['segment_id', '=', $segment_id])->where(['sellzone_id', '=', $offerIn->sellzone_id]); if (!is_null($oresellerid)) { $queryproducts->where(['reseller_id', '=', (int) $oresellerid]); } $products = $queryproducts->exec(true); foreach ($products as $product) { $price = $product->price; $fixed_costs = $product->fixed_costs; $shipping_costs = $product->shipping_costs; $travel_costs = $product->travel_costs; $discount = $product->discount; $delai_presta = lib('option')->get('delai.intervention', $product, false); $montant_min = (double) lib('option')->get('montant.intervention', $product, 0); $distance_max = (double) lib('option')->get('zone.intervention', $product, 0); if (false !== $delai_presta) { if ($delai < $delai_presta) { continue; } } $fixed_costs_free_from_price = 0; if (is_null($fixed_costs) || !is_array($fixed_costs)) { $fixed_costs = 0; } else { if (isset($fixed_costs['default'])) { if (isset($fixed_costs['default']['value'])) { $fixed_costs = (double) $fixed_costs['default']['value']; } if (isset($fixed_costs['default']['free_from_price'])) { $fixed_costs_free_from_price = (double) $fixed_costs['default']['free_from_price']; } } else { $fixed_costs = 0; } } $travel_costs_free_from_price = 0; if (is_null($travel_costs) || !is_array($travel_costs)) { $travel_costs = 0; } else { if (isset($travel_costs['default'])) { if (isset($travel_costs['default']['value'])) { $travel_costs = (double) $travel_costs['default']['value']; } if (isset($travel_costs['default']['free_from_price'])) { $travel_costs_free_from_price = (double) $travel_costs['default']['free_from_price']; } } else { $travel_costs = 0; } } if (true === $livraison) { $shipping_costs_free_from_price = 0; if (is_null($shipping_costs) || !is_array($shipping_costs)) { $shipping_costs = 0; } else { if (isset($shipping_costs['default'])) { if (isset($shipping_costs['default']['value'])) { $shipping_costs = (double) $shipping_costs['default']['value']; } if (isset($shipping_costs['default']['free_from_price'])) { $shipping_costs_free_from_price = (double) $shipping_costs['default']['free_from_price']; } } else { $shipping_costs = 0; } } } if (!is_null($discount)) { $discount_quantity = 0; $discount_amount = 0; if (isset($discount['default'])) { if (isset($discount['default']['quantity'])) { $discount_quantity = (double) $discount['default']['quantity']; } if (isset($discount['default']['amount'])) { $discount_amount = (double) $discount['default']['amount']; } } } else { $discount_quantity = 0; $discount_amount = 0; } $reseller = Model::Reseller()->find($product->reseller_id); if ($reseller) { $min = isAke($quantity, 'min', false); $max = isAke($quantity, 'max', false); if (false === $min || false === $max) { return []; } foreach ($price as $productIndex => $productInfos) { $cost = isAke($productInfos, 'cost', false); if ($unite == 'minute') { $duration = isAke($productInfos, 'duration', false); if (false === $duration || false === $cost) { continue; } $min = (int) $min; $max = (int) $max; $duration = (int) $duration; $cost = (double) $cost; $checkContinue = $duration >= $min && $duration <= $max; } else { $cost = (double) $cost; $min = (double) $min; $max = (double) $max; $checkContinue = $cost >= $min && $cost <= $max; } if ($checkContinue) { $item = []; $amount = $cost; $amount = (double) $amount; if (true == $livraison && $shipping_costs > 0 && $shipping_costs_free_from_price > 0) { if ($shipping_costs_free_from_price <= $amount) { $shipping_costs = 0; } } if (true === $livraison) { $item['shipping_costs'] = $shipping_costs; } if ($travel_costs > 0 && $travel_costs_free_from_price > 0) { if ($travel_costs_free_from_price <= $amount) { $travel_costs = 0; } } if ($fixed_costs > 0 && $fixed_costs_free_from_price > 0) { if ($fixed_costs_free_from_price <= $amount) { $fixed_costs = 0; } } /* on calcule la ristourne sur la quantité si elle existe */ $everDiscount = false; if ($quantity >= $discount_quantity && 0 < $discount_amount) { $discountAmount = (double) ($amount * $discount_amount) / 100; $amount = (double) $amount - $discountAmount; $everDiscount = true; } /* si pas de ristourne quantité on regarde s'il ya une ristourne de prix */ if (!is_null($discount) && is_array($discount)) { $discountPrice = isAke($discount, 'price', false); if (false !== $discountPrice) { $discount_quantity = 0; $discount_amount = 0; if (isset($discountPrice['quantity'])) { $discount_quantity = (double) $discountPrice['quantity']; } if (isset($discountPrice['amount'])) { $discount_amount = (double) $discountPrice['amount']; } if ($amount >= $discount_quantity && 0 < $discount_amount) { $discountAmount = (double) ($amount * $discount_amount) / 100; $amount = (double) $amount - $discountAmount; $everDiscount = true; } } } /* on peut ajouter les frais fixes et de livraison */ $amount = $amount + $fixed_costs + $shipping_costs; $discountAmount = 0; $hasAgenda = lib('option')->get('agenda.partage.' . $segment_id, $reseller, false); /* on regarde si le revendeur a spécifié un montant minumum pour accepter une presta */ if (0 == $montant_min) { $montant_min = (double) lib('option')->get('montant.intervention.' . $segment_id, $reseller, 0); } /* si tel est le cas on s'assure que le montant minimum est atteint */ if (0 < $montant_min) { if ($amount < $montant_min) { continue; } } /* on regarde si le revendeur a spécifié un délai minumum pour accepter une presta */ if (false === $delai_presta) { $delai_presta = lib('option')->get('delai.intervention.' . $segment_id, $reseller, false); /* si tel est le cas on s'assure que le délai minimum est respecté */ if (false !== $delai_presta) { if ($delai < $delai_presta) { continue; } } } /* si une langue est demandée on vérifie si le revendeur la parle, sinon, on passe au suivant */ if (!is_null($language)) { $speak = lib('option')->get('langue.' . $segment_id . '.' . $language, $reseller, false); if (false === $speak) { continue; } } if (o == $distance_max) { $distance_max = lib('option')->get('zone.intervention.' . $segment_id, $reseller, 0); } $locReseller = getLocation($reseller); $distance = distanceKmMiles($locOfferIn['lng'], $locOfferIn['lat'], $locReseller['lng'], $locReseller['lat']); $km = (double) $distance['km']; /* si la distance maximale demandée par l'acheteur est supérieure à la distance calculée on ne prend pas cette offre */ if ($distance_maxB > 0) { if ($km > $distance_maxB) { continue; } } /* si la distance maximale demandée par le vendeur est supérieure à la distance calculée on ne prend pas cette offre */ if ($distance_max > 0) { if ($km > $distance_max) { continue; } } /* on ajoute les frais de déplacement le cas échéant */ if (0 < $travel_costs) { $travel_costs = (double) $travel_costs * $km; $amount += $travel_costs; } $item['quantity'] = $quantity; $item['amount'] = $amount; $item['discount'] = $discountAmount; $item['fixed_costs'] = $fixed_costs; $item['travel_costs'] = $travel_costs; $item['distance'] = $km; $item['reseller_id'] = $reseller->id; /* si c'est une presta calendrier et que le revendeur n'a pas de calendrier, on ajoute un attribut à l'item */ if (true === $is_calendar && false === $hasAgenda) { $item['reseller_calendar'] = false; } if (true === $is_calendar && false !== $hasAgenda) { $item['reseller_calendar'] = true; $duration = $this->duration($quantity, $unite, $offerIn->segment_id, $reseller->id); $startMin = (int) $start - $tolerance; $startMax = (int) $start + $tolerance; $endMin = (int) $startMin + $duration; $endMax = (int) $startMax + $duration; $availabilities = lib('agenda')->getAvailabilitiesByResellerId($startMin, $endMax, $reseller->id); if (!empty($availabilities)) { if (!is_null($language)) { $find = false; foreach ($availabilities as $availability) { $employee = Model::Reselleremployee()->find($availability['reselleremployee_id']); if ($employee) { $speak = lib('option')->get('langue.' . $language, $employee, false); if (false !== $speak) { $item['availability_id'] = $availability['id']; $item['availability_start'] = $availability['start']; $item['availability_end'] = $availability['end']; $item['reselleremployee_id'] = $availability['reselleremployee_id']; $find = true; break; } } } if (false === $find) { continue; } } else { $availability = Arrays::first($availabilities); $item['availability_id'] = $availability['id']; $item['availability_start'] = $availability['start']; $item['availability_end'] = $availability['end']; $item['reselleremployee_id'] = $availability['reselleremployee_id']; } } else { /* si pas de dispo on passe */ continue; } } /* on peut créer l'offre out et ajouter l'offre au retour */ $data = $item; $data['offerin_id'] = $offerIn->id; $data['account_id'] = $offerIn->account_id; $data['segment_id'] = $segment_id; $data['status_id'] = (int) lib('status')->getId('offerout', 'SHOWN'); $offerOut = Model::Offerout()->create($data)->save(); $item['offerout_id'] = $offerOut->id; $collection[] = $item; } } } } /* on ordonne les offres par distance décroissante si à domicile sinon par prix */ if ($collection->count() > 0) { if ($livraison) { $collection->sortBy('distance'); } else { $collection->sortBy('amount'); } } return $collection->toArray(); }
} elseif (preg_match('/Edge/i', $agente)) { $navegador = 'Microsoft Edge'; } elseif (preg_match('/Spartan/i', $agente)) { $navegador = 'Microsoft Spartan'; } elseif (preg_match('/Firefox/i', $agente)) { $navegador = 'Mozilla Firefox'; } elseif (preg_match('/Chromium/i', $agente)) { $navegador = "Chromium"; } elseif (preg_match('/Chrome/i', $agente)) { $navegador = "Chrome"; } elseif (preg_match('/Safari/i', $agente)) { $navegador = 'Safari'; } elseif (preg_match('/Opera Mini/i', $agente)) { $navegador = 'Opera Mini'; } elseif (preg_match('/Opera/i', $agente)) { $navegador = 'Opera'; } elseif (preg_match('/Netscape/i', $agente)) { $navegador = 'Netscape'; } elseif (preg_match('/UCBrowser/i', $agente)) { $navegador = 'UC Browser'; } else { $navegador = "Desconocido"; } return $navegador; } echo "<b>IP:</b> " . $_SERVER['REMOTE_ADDR'] . "<br>"; echo "<b>Ubicación</b>: " . getLocation('ciudad_pais') . "<br>"; echo "<b>Navegador:</b> " . getBrowser() . "<br>"; echo "<b>SO:</b> " . getSO() . " " . getArquitecture() . "<br>"; //echo($_SERVER['HTTP_USER_AGENT']); echo '</body></html>';
public function makeOffersOut($offerin) { $collection = []; $errors = []; $infos = []; $resellers = []; $minStartDelay = Config::get('offerin.delay', 115) * 60; $model = lib('model')->getStaticModel((int) $offerin->segment_id); $isCalendar = isAke($model, 'is_calendar', true); $now = time(); $isPro = false; if (!isset($offerin->sellzone_id)) { $offerin->sellzone_id = 1; $offerin->save(); } if (isset($offerin->company_id)) { $address = Model::Companyaddress()->findOrFail((int) $offerin->address_id); $isPro = true; } else { $address = Model::Accountaddress()->findOrFail((int) $offerin->address_id); } if (true === $isPro) { if (!isset($offerin->company_id)) { $offerin->company_id = (int) $address->company_id; $offerin = $offerin->save(); } } else { if (!isset($offerin->account_id)) { $offerin->account_id = (int) $address->account_id; $offerin = $offerin->save(); } } $locationOffer = lib('utils')->remember('get.location.address.' . $address->id, function ($address) { return getLocation($address); }, $isPro ? Model::Companyaddress()->getAge() : Model::Accountaddress()->getAge(), [$address]); if (empty($locationOffer)) { $coords = lib('geo')->getCoords($address->address . ' ' . $address->zip . ' ' . $address->city, 250); setLocation($address, $coords['lng'], $coords['lat']); $locationOffer = ['lng' => $coords['lng'], 'lat' => $coords['lat']]; } $segment_id = (int) $offerin->segment_id; $family = repo('segment')->getFamilyfromItem((int) $segment_id); if (!empty($family)) { $market = current($family); $market_id = (int) $market['id']; } else { $market_id = $segment_id; } $offer = $offerin->toArray(); if (isset($offer['date']) && isset($offer['time'])) { list($y, $m, $d) = explode('-', $offer['date'], 3); list($h, $i, $s) = explode(':', $offer['time'], 3); $start = mktime($h, $i, $s, $m, $d, $y); } else { $start = $offerin->created_at; } if ($start < $now) { $errors['starttime_error'] = 'Start time [' . date('Y-m-d H:i:s', $start) . '] is before now.'; } $delaySeconds = $start - $now; $delai = (double) round($delaySeconds / 3600, 2); if ($delaySeconds < $minStartDelay) { $errors['delay_incorrect'] = 'The delay is incorrect [' . $delaySeconds . ' seconds]. The delay me be at less egual to ' . $minStartDelay . ' seconds.'; return ['resellers' => $resellers, 'offers' => $collection, 'errors' => $errors, 'infos' => $infos]; } $langue = $offerin->langue; if (!strlen($langue) || empty($langue) || strtolower($langue) == 'non') { $langue = false; } if ($langue) { $langues = lib('forms')->getLanguagesFromSegmentId($segment_id); if (!in_array($langue, $langues)) { $langue = false; } } $this->cleanToPay($offerin->segment_id); $products = Model::Productdata()->where(['segment_id', '=', (int) $offerin->segment_id])->where(['sellzone_id', '=', (int) $offerin->sellzone_id])->cursor(); foreach ($products as $product) { $item = []; $reseller = Model::Reseller()->model($product['reseller']); $company = Model::Company()->model($product['company']); // $company = Model::Company()->where(['reseller_id', '=', (int) $product['reseller_id']])->first(true); if ($reseller && $company) { // $statusId = (int) lib('status')->getId('reseller', 'REGISTER'); if (false === $product['status']) { $infos[$reseller->id]['status'] = true; continue; } $infos[$reseller->id] = []; $options = $product['options']; $hasAgenda = isAke($options, 'has_agenda', false); // $hasAgenda = lib('option')->get('agenda.partage', $reseller, false); $item['reseller_calendar'] = $hasAgenda; $item['reseller_id'] = $reseller->id; $item['segment_id'] = $segment_id; if (true === $isPro) { $item['company_id'] = $offer['company_id']; } else { $item['account_id'] = $offer['account_id']; } $locationReseller = lib('utils')->remember('has.locations.companies.' . $product['reseller_id'], function ($reseller_id) { $company = Model::Company()->where(['reseller_id', '=', (int) $reseller_id])->first(true); $coords = lib('geo')->getCoordsMap($company->address . ' ' . $company->zip . ' ' . $company->city); $loc = ['lng' => $coords['lng'], 'lat' => $coords['lat']]; return $loc; }, Model::Company()->getAge(), [$product['reseller_id']]); $quantity = (double) $this->getQuantity($offer); /* si une langue est demandée on vérifie si le revendeur la parle, sinon, on passe au suivant */ if ($langue) { // $speak = lib('option')->get('langue.' . $market_id . '.' . $langue, $reseller, false); $speak = isAke($options['languages'], $langue, false); if (false === $speak) { $infos[$reseller->id]['language'] = true; continue; } } $distanceMaxOffer = isset($offer['distance_max']) ? (double) $offer['distance_max'] : 0; // $distanceMaxReseller = (double) lib('option')->get('zone.intervention.' . $market_id, $reseller, 0); $distanceMaxReseller = (double) isAke($options, 'distance_max', 0); $distance = distanceKmMiles($locationOffer['lng'], $locationOffer['lat'], $locationReseller['lng'], $locationReseller['lat']); $km = (double) $distance['km']; $item['distance'] = $km; if (0 < $distanceMaxOffer || 0 < $distanceMaxReseller) { if ($distanceMaxOffer < $km && $distanceMaxOffer > 0) { $infos[$reseller->id]['distance_reseller'] = true; continue; } if ($distanceMaxReseller < $km && $distanceMaxReseller > 0) { $infos[$reseller->id]['distance_buyer'] = true; continue; } } // $delai_presta = lib('option')->get('delai.intervention.' . $market_id, $reseller, 0); $delai_presta = isAke($options, 'delai_min', 0); $item['date_max_offer'] = (int) $start - 3600; if (0 < $delai_presta) { if ($delai < $delai_presta) { $infos[$reseller->id]['delay_reseller'] = true; continue; } else { $item['date_max_offer'] = (int) $start - $delai_presta * 3600; } } if ($hasAgenda) { $item['date_max_offer'] = $item['date_max_offer'] > $now + 3600 ? $now + 3600 : $item['date_max_offer']; } else { $item['date_max_offer'] = $item['date_max_offer'] > $now + 1800 ? $now + 1800 : $item['date_max_offer']; } $makePrice = $amount = (double) $this->makePrice($offer, $product['product']); $minAmount = isAke($options, 'amount_min', 0); if ($minAmount > $amount) { $infos[$reseller->id]['amount_reseller'] = true; continue; } $tva = isAke($product['product'], 'tva', 1); $discount_default_quantity = isAke($product['product'], 'discount_default_quantity', 0); $discount_default_amount = (double) isAke($product['product'], 'discount_default_amount', 0); $discount_price_quantity = isAke($product['product'], 'discount_price_quantity', 0); $discount_price_amount = (double) isAke($product['product'], 'discount_price_amount', 0); $fixed_costs_default = (double) isAke($product['product'], 'fixed_costs_default', 0); $travel_costs_default = (double) isAke($product['product'], 'travel_costs_default', 0); $shipping_costs_default = (double) isAke($product['product'], 'shipping_costs_default', 0); $item['fixed_costs'] = $fixed_costs_default; $item['travel_costs'] = $travel_costs_default; $item['shipping_costs'] = $shipping_costs_default; $item['discount'] = 0; $item['tva_id'] = (int) $tva; if ($discount_default_quantity > 0 && $discount_default_amount > 0) { if ($quantity >= $discount_default_quantity) { $discount = (double) round($amount * $discount_default_amount / 100, 2); $amount -= $discount; $item['discount'] = $discount; } } else { if ($discount_price_quantity > 0 && $discount_price_amount > 0) { if ($amount >= $discount_price_quantity) { $discount = (double) round($amount * $discount_price_amount / 100, 2); $amount -= $discount; $item['discount'] = $discount; } } } if (0 < $fixed_costs_default) { $amount += $fixed_costs_default; } if (0 < $shipping_costs_default) { $amount += $shipping_costs_default; } if (0 < $travel_costs_default) { $travel_costs = (double) $travel_costs_default * $km; $amount += $travel_costs; $item['travel_costs'] = $travel_costs; } $optionsOffer = $this->extractOptions($offer); if (!empty($optionsOffer)) { foreach ($optionsOffer as $opt) { $value = isAke($offer, $opt, 0); if ($value > 0) { $price = isAke($product['product'], $this->transform($opt), 0); $amountOption = (double) $price * $quantity; $amount += $amountOption; $item[$this->transform($opt)] = $amountOption; } } } $resellers[] = $reseller->id; $item['amount'] = (double) $amount; $item['offerin_id'] = (int) $offer['id']; if (true === $isCalendar) { if (isset($product['product']['taux_horaire'])) { $duration = (double) $makePrice / $product['product']['taux_horaire']; } else { $duration = $quantity; } $end = $start + 3600 * $duration; $item['duration'] = $end - $start; $employees = $this->getEmployeesCan((int) $start, (int) $end, (int) $product['reseller_id']); if (empty($employees)) { $infos[$reseller->id]['no_employee'] = true; Model::offerouttrash()->create($item)->save(); continue; } $item['reselleremployees'] = $employees; $item['start'] = $start; $item['end'] = $end; } else { $employees = Model::Reselleremployee()->where(['reseller_id', '=', (int) $reseller->id])->select('id')->cursor()->toArray(); $item['reselleremployees'] = $employees; } $item['status_id'] = (int) lib('status')->getId('offerout', 'SHOWN'); $offerOut = Model::Offerout()->create($item)->save(); $item['offerout_id'] = $offerOut->id; $collection[] = $item; } } $return = []; $return['resellers'] = $resellers; $return['offers'] = $collection; if (!empty($errors)) { $return['errors'] = $errors; } if (!empty($infos)) { $return['infos'] = $infos; } $offerin->resellers = $resellers; if (true === $isCalendar) { $offerin->start = $start; } $offerin->save(); return $return; }
public function showSpaceCard() { $uid = intval($_GET['uid']); if ($uid) { $data = getUserInfo($uid); $usertags = D('UserTag')->getUserTagList($this->uid); foreach ($usertags as $v) { $tags[] = '<a href="' . U('home/User/searchtag', array('k' => $v['tag_name'])) . '">' . $v['tag_name'] . '</a>'; } $data['location'] = getLocation($data['province'], $data['city']); if (!$data['location']) { $data['location'] = '<br />'; } $data['tags'] = !$tags ? 'None' : implode(' ', $tags); $data['following_url'] = U('home/Space/follow', array('type' => 'following', 'uid' => $uid)); $data['follower_url'] = U('home/Space/follow', array('type' => 'follower', 'uid' => $uid)); $data['space_url'] = U('home/Space/index', array('uid' => $uid)); $data['space_link'] = getUserSpace($uid, 'nocard', '_blank'); $data['follow_state'] = $this->mid == $uid ? 'self' : D('Follow', 'weibo')->getState($this->mid, $uid, 0); $this->ajaxReturn($data, L('get_success'), 1); } else { $this->ajaxReturn('', L('get_success'), 0); } }
function renderServerReport() { $aResult = array(); $iTotal = 0; $sFilter = '{$typeid_4}'; # typeid_4 = Server foreach (scanRealmByText('object', $sFilter) as $Result) { $aResult[$Result['id']] = array(); $aResult[$Result['id']]['sName'] = $Result['name']; // Create active links in comment $aResult[$Result['id']]['sComment'] = $Result['comment']; // Load additional attributes: $attributes = getAttrValues($Result['id']); $aResult[$Result['id']]['sContact'] = ''; if (isset($attributes['14']['a_value'])) { $aResult[$Result['id']]['sContact'] = $attributes['14']['a_value']; } $aResult[$Result['id']]['HWtype'] = ''; if (isset($attributes['2']['a_value'])) { $aResult[$Result['id']]['HWtype'] = $attributes['2']['a_value']; } $aResult[$Result['id']]['OEMSN'] = ''; if (isset($attributes['1']['a_value'])) { $aResult[$Result['id']]['OEMSN'] = $attributes['1']['a_value']; } $aResult[$Result['id']]['HWExpDate'] = ''; if (isset($attributes['22']['value'])) { $aResult[$Result['id']]['HWExpDate'] = date("Y-m-d", $attributes['22']['value']); } $aResult[$Result['id']]['sOS'] = ''; if (isset($attributes['4']['a_value'])) { $aResult[$Result['id']]['sOS'] = $attributes['4']['a_value']; } $aResult[$Result['id']]['sSlotNumber'] = 'unknown'; if (isset($attributes['28']['a_value']) && $attributes['28']['a_value'] != '') { $aResult[$Result['id']]['sSlotNumber'] = $attributes['28']['a_value']; } // Location $aResult[$Result['id']]['sLocation'] = getLocation($Result); // IP Informations $aResult[$Result['id']]['ipV4List'] = getObjectIPv4AllocationList($Result['id']); $aResult[$Result['id']]['ipV6List'] = getObjectIPv6AllocationList($Result['id']); // Port (MAC) Informations $aResult[$Result['id']]['ports'] = getObjectPortsAndLinks($Result['id']); $iTotal++; } if (isset($_GET['csv'])) { header('Content-type: text/csv'); header('Content-Disposition: attachment; filename=export_' . date("Ymdhis") . '.csv'); header('Pragma: no-cache'); header('Expires: 0'); $outstream = fopen("php://output", "w"); $aCSVRow = array('Name', 'MAC', 'IP(s)', 'Comment', 'Contact', 'Type', 'OEM', 'HW Expire Date', 'OS', 'Location'); fputcsv($outstream, $aCSVRow); foreach ($aResult as $id => $aRow) { $aCSVRow = array(); $aCSVRow[0] = $aRow['sName']; $aCSVRow[1] = ''; foreach ($aRow['ports'] as $portNumber => $aPortDetails) { if (trim($aPortDetails['l2address']) != '') { $aCSVRow[1] .= $aPortDetails['l2address'] . ' '; } } $aCSVRow[1] = trim($aCSVRow[1]); $aCSVRow[2] = ''; foreach ($aRow['ipV4List'] as $key => $aDetails) { if (function_exists('ip4_format')) { $key = ip4_format($key); } if (trim($key) != '') { $aCSVRow[2] .= $key . ' '; } } foreach ($aRow['ipV6List'] as $key => $aDetails) { if (function_exists('ip6_format')) { $key = ip6_format($key); } if (trim($key) != '') { $aCSVRow[2] .= $key . ' '; } } $aCSVRow[2] = trim($aCSVRow[2]); $aCSVRow[3] = str_replace('"', "'", $aRow['sComment']); $aCSVRow[4] = $aRow['sContact']; $aCSVRow[5] = $aRow['HWtype']; $aCSVRow[6] = $aRow['OEMSN']; $aCSVRow[7] = $aRow['HWExpDate']; $aCSVRow[8] = $aRow['sOS']; $aCSVRow[9] = preg_replace('/<a[^>]*>(.*)<\\/a>/iU', '$1', $aRow['sLocation']); fputcsv($outstream, $aCSVRow); } fclose($outstream); exit(0); # Exit normally after send CSV to browser } // Load stylesheet and jquery scripts addCSS('css/extensions/style.css'); addJS('js/extensions/jquery-latest.js'); addJS('js/extensions/jquery.tablesorter.js'); addJS('js/extensions/picnet.table.filter.min.js'); // Display the stat array echo '<h2>Server report (' . $iTotal . ')</h2><ul>'; echo '<a href="index.php?page=reports&tab=server&csv">CSV Export</a>'; echo '<table id="reportTable" class="tablesorter"> <thead> <tr> <th>Name</th> <th>MAC</th> <th>IP(s)</th> <th>Comment</th> <th>Contact</th> <th>Type</th> <th>OEM S/N</th> <th>HW Expire Date</th> <th>OS</th> <th>Location</th> </tr> </thead> <tbody>'; foreach ($aResult as $id => $aRow) { echo '<tr> <td><a href="' . makeHref(array('page' => 'object', 'object_id' => $id)) . '">' . $aRow['sName'] . '</a></td> <td>'; foreach ($aRow['ports'] as $portNumber => $aPortDetails) { if (trim($aPortDetails['l2address']) != '') { echo $aPortDetails['l2address'] . '<br/>'; } } echo ' </td> <td>'; foreach ($aRow['ipV4List'] as $key => $aDetails) { if (function_exists('ip4_format')) { $key = ip4_format($key); } if (trim($key) != '') { echo $key . '<br/>'; } } foreach ($aRow['ipV6List'] as $key => $aDetails) { if (function_exists('ip6_format')) { $key = ip6_format($key); } if (trim($key) != '') { echo $key . '<br/>'; } } echo '</td> <td>' . makeLinksInText($aRow['sComment']) . '</td> <td>' . $aRow['sContact'] . '</td> <td>' . $aRow['HWtype'] . '</td> <td>' . $aRow['OEMSN'] . '</td> <td>' . $aRow['HWExpDate'] . '</td> <td>' . $aRow['sOS'] . '</td> <td>' . $aRow['sLocation'] . '</td> </tr>'; } echo ' </tbody> </table>'; echo '<script type="text/javascript"> $(document).ready(function() { $.tablesorter.defaults.widgets = ["zebra"]; $("#reportTable").tablesorter( { headers: { 2: { sorter: "ipAddress" }, }, sortList: [[0,0]] } ) $("#reportTable").tableFilter(); }); </script>'; }
?> </TD> <td style="width: 22%"><?php echo $InventoryRow["product_name"]; ?> </td> <td style="width: 22%"><?php echo date("m/d/Y", strtotime($InventoryRow["DateAdded"])); ?> </td> <td style="width: 16%"><?php echo $InventoryRow["status_name"]; ?> </td> <td style="width: 28%; white-space:nowrap;"><?php echo getLocation($InventoryRow["invStatus"], $InventoryRow["invStatusData"]); ?> </td> </TR> <?php } } else { ?> <TR class="even"> <td colspan="5">No Matching Inventory Found</td> </TR> <?php } ?> </TBODY>
$city ="Los Angeles"; $state ="California"; echo("hello world"); getLocation($street,$city,$state,$degree);*/ if (isset($_GET["street"])) { $street = validate_data($_GET["street"]); } if (isset($_GET["city"])) { $city = validate_data($_GET["city"]); } if (isset($_GET["state"])) { $state = validate_data($_GET["state"]); } if (isset($_GET["degree"])) { $degree = validate_data($_GET["degree"]); getLocation($street, $city, $state, $degree); } function validate_data($input) { $input = trim($input); $input = stripslashes($input); $input = htmlspecialchars($input); return $input; } function getLocation($street, $city, $state, $degree) { $address = $street . "," . $city . "," . $state; $geo_api_key = "AIzaSyCo1QU56_MFxG2l-TPSUXYP9LrGAYWI5SY"; $request = urlencode($address) . "&key=" . $geo_api_key; $url = "https://maps.google.com/maps/api/geocode/xml?address=" . $request; $xml = file_get_contents($url);
function renderCustomReport() { # Get object list $phys_typelist = readChapter(CHAP_OBJTYPE, 'o'); $attibutes = getAttrMap(); $aTagList = getTagList(); if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['csv'])) { header('Content-type: text/csv'); header('Content-Disposition: attachment; filename=export_' . date("Ymdhis") . '.csv'); header('Pragma: no-cache'); header('Expires: 0'); $outstream = fopen("php://output", "w"); $aResult = getResult($_POST); // Get Result $_POST['name'] = validateColums($_POST); // Fix empty colums $csvDelimiter = isset($_POST['csvDelimiter']) ? $_POST['csvDelimiter'] : ','; /* Create Header */ $aCSVRow = array(); if (isset($_POST['sName']) && $_POST['sName']) { array_push($aCSVRow, "Name"); } if (isset($_POST['label'])) { array_push($aCSVRow, "Label"); } if (isset($_POST['type'])) { array_push($aCSVRow, "Type"); } if (isset($_POST['asset_no'])) { array_push($aCSVRow, "Asset Tag"); } if (isset($_POST['has_problems'])) { array_push($aCSVRow, "Has Problems"); } if (isset($_POST['comment'])) { array_push($aCSVRow, "Comment"); } if (isset($_POST['runs8021Q'])) { array_push($aCSVRow, "Runs 8021Q"); } if (isset($_POST['location'])) { array_push($aCSVRow, "Location"); } if (isset($_POST['MACs'])) { array_push($aCSVRow, "MACs"); } if (isset($_POST['IPs'])) { array_push($aCSVRow, "IPs"); } if (isset($_POST['attributeIDs'])) { foreach ($_POST['attributeIDs'] as $attributeID) { array_push($aCSVRow, $attibutes[$attributeID]['name']); } } if (isset($_POST['Tags'])) { array_push($aCSVRow, "Tags"); } if (isset($_POST['Ports'])) { array_push($aCSVRow, "Ports"); } if (isset($_POST['Containers'])) { array_push($aCSVRow, "Containers"); } if (isset($_POST['Childs'])) { array_push($aCSVRow, "Child objects"); } fputcsv($outstream, $aCSVRow, $csvDelimiter); /* Create data rows */ foreach ($aResult as $Result) { $aCSVRow = array(); if (isset($_POST['sName'])) { array_push($aCSVRow, $Result['name']); } if (isset($_POST['label'])) { array_push($aCSVRow, $Result['label']); } if (isset($_POST['type'])) { array_push($aCSVRow, $phys_typelist[$Result['objtype_id']]); } if (isset($_POST['asset_no'])) { array_push($aCSVRow, $Result['asset_no']); } if (isset($_POST['has_problems'])) { array_push($aCSVRow, $Result['has_problems']); } if (isset($_POST['comment'])) { array_push($aCSVRow, str_replace('"', "'", $Result['comment'])); } if (isset($_POST['runs8021Q'])) { array_push($aCSVRow, $Result['runs8021Q']); } if (isset($_POST['location'])) { array_push($aCSVRow, preg_replace('/<a[^>]*>(.*)<\\/a>/iU', '$1', getLocation($Result))); } if (isset($_POST['MACs'])) { $sTemp = ''; foreach (getObjectPortsAndLinks($Result['id']) as $portNumber => $aPortDetails) { if (trim($aPortDetails['l2address']) != '') { $sTemp .= $aPortDetails['l2address'] . ' '; } } array_push($aCSVRow, $sTemp); } if (isset($_POST['IPs'])) { $sTemp = ''; foreach (getObjectIPv4AllocationList($Result['id']) as $key => $aDetails) { if (function_exists('ip4_format')) { $key = ip4_format($key); } if (trim($key) != '') { $sTemp .= $key . ' '; } } foreach (getObjectIPv6AllocationList($Result['id']) as $key => $aDetails) { if (function_exists('ip6_format')) { $key = ip6_format($key); } else { $key = new IPv6Address($key); } if (trim($key) != '') { $sTemp .= $key . ' '; } } array_push($aCSVRow, $sTemp); } if (isset($_POST['attributeIDs'])) { $attributes = getAttrValues($Result['id']); foreach ($_POST['attributeIDs'] as $attributeID) { if (isset($attributes[$attributeID]['a_value'])) { array_push($aCSVRow, $attributes[$attributeID]['a_value']); } elseif ($attributes[$attributeID]['value'] != '' && $attributes[$attributeID]['type'] == 'date') { array_push($aCSVRow, date("Y-m-d", $attributes[$attributeID]['value'])); } else { array_push($aCSVRow, ''); } } } if (isset($_POST['Tags'])) { $sTemp = ''; foreach ($Result['tags'] as $aTag) { $sTemp .= $aTag['tag'] . ' '; } if (count($Result['itags']) > 0) { $sTemp .= '('; foreach ($Result['itags'] as $aTag) { $sTemp .= $aTag['tag'] . ' '; } $sTemp .= ')'; } array_push($aCSVRow, $sTemp); } if (isset($_POST['Ports'])) { $sTemp = ''; foreach ($Result['portsLinks'] as $port) { $sTemp .= $port['name'] . ': ' . $port['remote_object_name']; if (trim($port['cableid']) != '') { $sTemp .= ' Cable ID: ' . $port['cableid']; } $sTemp .= ' '; } $sTemp = trim($sTemp); array_push($aCSVRow, $sTemp); } if (isset($_POST['Containers'])) { $sTemp = ''; foreach (getObjectContainerList($Result['id']) as $key => $aDetails) { $sTemp .= trim($aDetails['container_name']) . ' '; } $sTemp = trim($sTemp); array_push($aCSVRow, $sTemp); } if (isset($_POST['Childs'])) { $sTemp = ''; foreach (getObjectChildObjectList($Result['id']) as $key => $aDetails) { $sTemp .= trim($aDetails['object_name']) . ' '; } $sTemp = trim($sTemp); array_push($aCSVRow, $sTemp); } fputcsv($outstream, $aCSVRow, $csvDelimiter); } fclose($outstream); exit(0); # Exit normally after send CSV to browser } echo '<h2>Custom report</h2><ul>'; // Load stylesheet and jquery scripts addCSS('css/extensions/style.css'); addJS('js/extensions/saveFormValues.js'); addJS('js/extensions/jquery-latest.js'); addJS('js/extensions/jquery.tablesorter.js'); addJS('js/extensions/picnet.table.filter.min.js'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { echo '<a href="#" class="show_hide">Show/hide search form</a><br/><br/>'; } echo '<div class="searchForm">'; echo '<form method="post" name="searchForm">'; echo '<table class="searchTable"> <tr> <th>Object Type</th> <th>Common Values</th> <th>Attributes</th> <th>Tags</th> <th>Misc</th> </tr> <tr>'; echo '<td valign="top"> <table class="searchTable">'; $i = 0; foreach ($phys_typelist as $objectTypeID => $sName) { if ($i % 2) { echo '<tr class="odd">'; } else { echo '<tr>'; } echo ' <td> <input type="checkbox" name="objectIDs[]" value="' . $objectTypeID . '"'; if (isset($_POST['objectIDs']) && in_array($objectTypeID, $_POST['objectIDs'])) { echo ' checked="checked"'; } echo ' > ' . $sName . ' </td> </tr>'; $i++; } echo ' </table> </td>'; echo '<td valign="top"> <table class="searchTable"> <tr><td><input type="checkbox" name="sName" value="1" '; if (isset($_POST['sName'])) { echo ' checked="checked"'; } echo '> Name</td></tr> <tr class="odd"><td><input type="checkbox" name="label" value="1" '; if (isset($_POST['label'])) { echo ' checked="checked"'; } echo '> Label</td></tr> <tr><td><input type="checkbox" name="type" value="1" '; if (isset($_POST['type'])) { echo ' checked="checked"'; } echo '> Type</td></tr> <tr class="odd"><td><input type="checkbox" name="asset_no" value="1" '; if (isset($_POST['asset_no'])) { echo ' checked="checked"'; } echo '> Asset Tag</td></tr> <tr><td><input type="checkbox" name="location" value="1" '; if (isset($_POST['location'])) { echo ' checked="checked"'; } echo '> Location</td></tr> <tr class="odd"><td><input type="checkbox" name="has_problems" value="1" '; if (isset($_POST['has_problems'])) { echo ' checked="checked"'; } echo '> Has Problems</td></tr> <tr><td><input type="checkbox" name="comment" value="1" '; if (isset($_POST['comment'])) { echo ' checked="checked"'; } echo '> Comment</td></tr> <tr class="odd"><td><input type="checkbox" name="runs8021Q" value="1" '; if (isset($_POST['runs8021Q'])) { echo ' checked="checked"'; } echo '> Runs 8021Q</td></tr> <tr><td><input type="checkbox" name="MACs" value="1" '; if (isset($_POST['MACs'])) { echo ' checked="checked"'; } echo '> MACs</td></tr> <tr class="odd"><td><input type="checkbox" name="IPs" value="1" '; if (isset($_POST['IPs'])) { echo ' checked="checked"'; } echo '> IPs</td></tr> <tr><td><input type="checkbox" name="Tags" value="1" '; if (isset($_POST['Tags'])) { echo ' checked="checked"'; } echo '> Tags</td></tr> <tr class="odd"><td><input type="checkbox" name="Ports" value="1" '; if (isset($_POST['Ports'])) { echo ' checked="checked"'; } echo '> Ports</td></tr> <tr><td><input type="checkbox" name="Containers" value="1" '; if (isset($_POST['Containers'])) { echo ' checked="checked"'; } echo '> Containers</td></tr> <tr class="odd"><td><input type="checkbox" name="Childs" value="1" '; if (isset($_POST['Childs'])) { echo ' checked="checked"'; } echo '> Child objects</td></tr> </table> </td>'; echo '<td valign="top"> <table class="searchTable">'; $i = 0; foreach ($attibutes as $attributeID => $aRow) { if ($i % 2) { echo '<tr class="odd">'; } else { echo '<tr>'; } echo ' <td> <input type="checkbox" name="attributeIDs[]" value="' . $attributeID . '"'; if (isset($_POST['attributeIDs']) && in_array($attributeID, $_POST['attributeIDs'])) { echo ' checked="checked"'; } echo '> ' . $aRow['name'] . ' </td> </tr>'; $i++; } echo ' </table> </td>'; echo '<td valign="top"> <table class="searchTable">'; $i = 0; foreach ($aTagList as $aTag) { echo '<tr ' . ($i % 2 ? 'class="odd"' : '') . '> <td> <input type="checkbox" name="tag[' . $aTag['id'] . ']" value="1" ' . (isset($_POST['tag'][$aTag['id']]) ? 'checked="checked" ' : '') . '> ' . $aTag['tag'] . ' </td> </tr>'; $i++; } if (count($aTagList) < 1) { echo '<tr><td><i>No Tags available</i></td></tr>'; } echo ' </table> </td>'; echo '<td valign="top"> <table class="searchTable"> <tr><td><input type="checkbox" name="csv" value="1"> CSV Export</td></tr> <tr><td><input type="text" name="csvDelimiter" value="," size="1"> CSV Delimiter</td></tr> <tr class="odd"><td>Name Filter: <i>(Regular Expression)</i></td></tr> <tr><td><input type="text" name="name_preg" value="'; if (isset($_POST['name_preg'])) { echo $_POST['name_preg']; } echo '" style="height: 11pt;"></td></tr> <tr class="odd"><td>Asset Tag Filter: <i>(Regular Expression)</i></td></tr> <tr><td><input type="text" name="tag_preg" value="'; if (isset($_POST['tag_preg'])) { echo $_POST['tag_preg']; } echo '" style="height: 11pt;"></td></tr> <tr class="odd"><td>Comment Filter: <i>(Regular Expression)</i></td></tr> <tr><td><input type="text" name="comment_preg" value="'; if (isset($_POST['comment_preg'])) { echo $_POST['comment_preg']; } echo '" style="height: 11pt;"></td></tr> <tr class="odd"><td> </td></tr> <tr> <td> Save: <input id="nameQuery" type="text" name="nameQuery" value="" style="height: 11pt; width:155px"/> <input type="button" value=" Ok " onclick="saveQuery();"> <br/> Load:<br/> <span id="loadButtons"></span> <script type="text/javascript"> loadButtons(); </script> </td> </tr> <tr class="odd"><td> </td></tr> <tr><td align="right"><input type="submit" value=" Search "></td></tr> </table> </td> </tr> </table>'; echo '</form>'; echo '</div>'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $aResult = getResult($_POST); // Get Result $_POST['sName'] = validateColums($_POST); // Fix empty colums if (count($aResult) > 0) { echo '<table id="customTable" class="tablesorter"> <thead> <tr>'; if (isset($_POST['sName']) && $_POST['sName']) { echo '<th>Name</th>'; } if (isset($_POST['label'])) { echo '<th>Label</th>'; } if (isset($_POST['type'])) { echo '<th>Type</th>'; } if (isset($_POST['asset_no'])) { echo '<th>Asset Tag</th>'; } if (isset($_POST['has_problems'])) { echo '<th>Has Problems</th>'; } if (isset($_POST['comment'])) { echo '<th>Comment</th>'; } if (isset($_POST['runs8021Q'])) { echo '<th>Runs 8021Q</th>'; } if (isset($_POST['location'])) { echo '<th>Location</th>'; } if (isset($_POST['MACs'])) { echo '<th>MACs</th>'; } if (isset($_POST['IPs'])) { echo '<th>IPs</th>'; } if (isset($_POST['attributeIDs'])) { foreach ($_POST['attributeIDs'] as $attributeID) { echo '<th>' . $attibutes[$attributeID]['name'] . '</th>'; } } if (isset($_POST['Tags'])) { echo '<th>Tags</th>'; } if (isset($_POST['Ports'])) { echo '<th>Ports</th>'; } if (isset($_POST['Containers'])) { echo '<th>Containers</th>'; } if (isset($_POST['Childs'])) { echo '<th>Child objects</th>'; } echo ' </tr> </thead> <tbody>'; foreach ($aResult as $Result) { echo '<tr>'; if (isset($_POST['sName'])) { echo '<td> <span class="object_' . str_replace('$', '', $Result['atags'][1]['tag']) . '">'; if (isset($Result['name'])) { echo '<a href="' . makeHref(array('page' => 'object', 'object_id' => $Result['id'])) . '">' . $Result['name'] . '</a>'; } else { echo ' '; } echo ' </span> </td>'; } if (isset($_POST['label'])) { echo '<td>'; if (isset($Result['label'])) { echo $Result['label']; } else { echo ' '; } echo '</td>'; } if (isset($_POST['type'])) { echo '<td>'; if (isset($Result['objtype_id'])) { echo $phys_typelist[$Result['objtype_id']]; } else { echo ' '; } echo '</td>'; } if (isset($_POST['asset_no'])) { echo '<td>'; if (isset($Result['asset_no'])) { echo $Result['asset_no']; } else { echo ' '; } echo '</td>'; } if (isset($_POST['has_problems'])) { echo '<td>'; if (isset($Result['has_problems'])) { echo $Result['has_problems']; } else { echo ' '; } echo '</td>'; } if (isset($_POST['comment'])) { echo '<td>'; if (isset($Result['comment'])) { echo makeLinksInText($Result['comment']); } else { echo ' '; } echo '</td>'; } if (isset($_POST['runs8021Q'])) { echo '<td>'; if (isset($Result['runs8021Q'])) { echo $Result['runs8021Q']; } else { echo ' '; } echo '</td>'; } if (isset($_POST['location'])) { echo '<td>'; echo getLocation($Result); echo '</td>'; } if (isset($_POST['MACs'])) { echo '<td>'; foreach (getObjectPortsAndLinks($Result['id']) as $portNumber => $aPortDetails) { if (trim($aPortDetails['l2address']) != '') { echo $aPortDetails['l2address'] . '<br/>'; } } echo '</td>'; } if (isset($_POST['IPs'])) { echo '<td>'; foreach (getObjectIPv4AllocationList($Result['id']) as $key => $aDetails) { if (function_exists('ip4_format')) { $key = ip4_format($key); } if (trim($key) != '') { echo $key . '<br/>'; } } foreach (getObjectIPv6AllocationList($Result['id']) as $key => $aDetails) { if (function_exists('ip6_format')) { $key = ip6_format($key); } else { $key = new IPv6Address($key); } if (trim($key) != '') { echo $key . '<br/>'; } } echo '</td>'; } if (isset($_POST['attributeIDs'])) { $attributes = getAttrValues($Result['id']); foreach ($_POST['attributeIDs'] as $attributeID) { echo '<td>'; if (isset($attributes[$attributeID]['a_value']) && $attributes[$attributeID]['a_value'] != '') { echo $attributes[$attributeID]['a_value']; } elseif ($attributes[$attributeID]['value'] != '' && $attributes[$attributeID]['type'] == 'date') { echo date("Y-m-d", $attributes[$attributeID]['value']); } else { echo ' '; } } } if (isset($_POST['Tags'])) { echo '<td>'; foreach ($Result['tags'] as $aTag) { echo '<a href="' . makeHref(array('page' => 'depot', 'tab' => 'default', 'andor' => 'and', 'cft[]' => $aTag['id'])) . '">' . $aTag['tag'] . '</a> '; } if (count($Result['itags']) > 0) { echo '('; foreach ($Result['itags'] as $aTag) { echo '<a href="' . makeHref(array('page' => 'depot', 'tab' => 'default', 'andor' => 'and', 'cft[]' => $aTag['id'])) . '">' . $aTag['tag'] . '</a> '; } echo ')'; } echo '</td>'; } if (isset($_POST['Ports'])) { echo '<td>'; foreach ($Result['portsLinks'] as $port) { echo $port['name'] . ': '; if ($port['remote_object_name'] != 'unknown') { echo formatPortLink($port['remote_object_id'], $port['remote_object_name'], $port['remote_id'], NULL); } else { echo $port['remote_object_name']; } if (trim($port['cableid']) != '') { echo ' Cable ID: ' . $port['cableid']; } echo '<br/>'; } echo '</td>'; } if (isset($_POST['Containers'])) { echo '<td>'; foreach (getObjectContainerList($Result['id']) as $key => $aDetails) { echo '<a href="' . makeHref(array('page' => 'object', 'object_id' => $key)) . '">' . $aDetails['container_name'] . '</a><br/>'; } echo '</td>'; } if (isset($_POST['Childs'])) { echo '<td>'; foreach (getObjectChildObjectList($Result['id']) as $key => $aDetails) { echo '<a href="' . makeHref(array('page' => 'object', 'object_id' => $key)) . '">' . $aDetails['object_name'] . '</a><br/>'; } echo '</td>'; } echo '</tr>'; } echo ' </tbody> </table> <script type="text/javascript">$(".searchForm").hide();</script>'; } else { echo '<br/><br/><div align="center" style="font-size:10pt;"><i>No items found !!!</i></div><br/>'; } echo '<script type="text/javascript"> $(document).ready(function() { $.tablesorter.defaults.widgets = ["zebra"]; $("#customTable").tablesorter( { headers: { }, sortList: [[0,0]] } ); $("#customTable").tableFilter(); $(".show_hide").show(); $(".show_hide").click(function(){ $(".searchForm").slideToggle(\'slow\'); }); } ); </script>'; } }
<?php // eine beliebige PHP-Funktion function getLocation($arg1, $arg2) { $db_id = mysql_connect("localhost", "web1162", "bX2KARTc"); if (!$db_id) { die("Verbindungsaufbau ist gescheitert"); } // mysql_query("use usr_web_1162_4"); $db_sel = mysql_select_db("usr_web1162_4", $db_id); if (!$db_sel) { die('Kann Datenbank nicht benutzen : ' . mysql_error()); } mysql_query("SET names 'utf8'"); mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'", $db_id); $locRecords = mysql_query("SELECT data.loc_id as id, data.text_val as ort, ACOS( SIN( RADIANS( src.lat ) ) * SIN( RADIANS( '{$arg2}' ) ) + COS( RADIANS( src.lat ) ) * COS( RADIANS( '{$arg2}' ) ) * COS( RADIANS( src.lon ) - RADIANS( '{$arg1}' ) ) ) *6380 AS distance\n\t\t\t\t\t\t\t\t\t\t FROM geodb_coordinates src, geodb_textdata data\n\t\t\t\t\t\t\t\t\t\t WHERE src.lat > '{$arg2}' - 0.5\n\t\t\t\t\t\t\t\t\t\t AND src.lat < '{$arg2}' + 0.5\n\t\t\t\t\t\t\t\t\t\t AND src.lon > '{$arg1}' - 0.5\n\t\t\t\t\t\t\t\t\t\t AND src.lon < '{$arg1}' + 0.5\n\t\t\t\t\t\t\t\t\t\t AND data.loc_id = src.loc_id\n\t\t\t\t\t\t\t\t\t\t AND data.text_type = 500100000\n\t\t\t\t\t\t\t\t\t\t HAVING distance <5\n\t\t\t\t\t\t\t\t\t\t ORDER BY distance asc\n\t\t\t\t\t\t\t\t\t\t LIMIT 1"); if (mysql_num_rows($locRecords) >= 1) { /* Tankstelle ermitteln */ while ($aktZeile = mysql_fetch_assoc($locRecords)) { printf("xyz"); echo $aktZeile['ort']; printf("zyx"); echo $aktZeile['distance']; } } } getLocation($_POST['longitude'], $_POST['latitude']); ?>
@chmod($pwd . $HTTP_POST_FILES[upfile][name][$i], 0707); } } getLocation("{$THIS_FILE}?pwd={$pwd}", "", ""); break; case "mk_perm": if (trim($perm)) { @exec("chmod {$perm} -R {$pwd}"); } getLocation("{$THIS_FILE}?pwd={$pwd}", "", ""); break; case "mk_user": if (trim($user)) { @exec("chown {$user} -R {$pwd}"); } getLocation("{$THIS_FILE}?pwd={$pwd}", "", ""); break; case "mk_permf": if (trim($perm)) { @exec("chmod {$perm} -R {$pwd}{$file}"); } getOpenerhref("{$THIS_FILE}?pwd={$pwd}"); break; case "mk_userf": if (trim($user)) { @exec("chown {$user} -R {$pwd}{$file}"); } getOpenerhref("{$THIS_FILE}?pwd={$pwd}"); break; } if ($query != 'down' && is_file("../admin/backup.tar.gz")) {
function renderSwitchReport() { $aResult = array(); $iTotal = 0; $sFilter = '{$typeid_8}'; # typeid_8 = Switches foreach (scanRealmByText('object', $sFilter) as $Result) { $aResult[$Result['id']] = array(); $aResult[$Result['id']]['sName'] = $Result['name']; // Create active links in comment $aResult[$Result['id']]['sComment'] = makeLinksInText($Result['comment']); // Load additional attributes: $attributes = getAttrValues($Result['id']); $aResult[$Result['id']]['sContact'] = ''; if (isset($attributes['14']['a_value'])) { $aResult[$Result['id']]['sContact'] = $attributes['14']['a_value']; } $aResult[$Result['id']]['HWtype'] = ''; if (isset($attributes['2']['a_value'])) { $aResult[$Result['id']]['HWtype'] = $attributes['2']['a_value']; } $aResult[$Result['id']]['OEMSN'] = ''; if (isset($attributes['1']['a_value'])) { $aResult[$Result['id']]['OEMSN'] = $attributes['1']['a_value']; } $aResult[$Result['id']]['HWExpDate'] = ''; if (isset($attributes['22']['value'])) { $aResult[$Result['id']]['HWExpDate'] = date("Y-m-d", $attributes['22']['value']); } $aResult[$Result['id']]['sOSVersion'] = ''; if (isset($attributes['5']['a_value'])) { $aResult[$Result['id']]['sOSVersion'] = $attributes['5']['a_value']; } $aResult[$Result['id']]['sSlotNumber'] = 'unknown'; if (isset($attributes['28']['a_value']) && $attributes['28']['a_value'] != '') { $aResult[$Result['id']]['sSlotNumber'] = $attributes['28']['a_value']; } // Location $aResult[$Result['id']]['sLocation'] = getLocation($Result); $iTotal++; } if (isset($_GET['csv'])) { header('Content-type: text/csv'); header('Content-Disposition: attachment; filename=export_' . date("Ymdhis") . '.csv'); header('Pragma: no-cache'); header('Expires: 0'); $outstream = fopen("php://output", "w"); $aCSVRow = array('Name', 'Comment', 'Contact', 'Type', 'OEM', 'HW Expire Date', 'OS Version', 'Location'); fputcsv($outstream, $aCSVRow); foreach ($aResult as $id => $aRow) { $aCSVRow = array(); $aCSVRow[0] = $aRow['sName']; $aCSVRow[1] = str_replace('"', "'", $aRow['sComment']); $aCSVRow[2] = $aRow['sContact']; $aCSVRow[3] = $aRow['HWtype']; $aCSVRow[4] = $aRow['OEMSN']; $aCSVRow[5] = $aRow['HWExpDate']; $aCSVRow[6] = $aRow['sOSVersion']; $aCSVRow[7] = preg_replace('/<a[^>]*>(.*)<\\/a>/iU', '$1', $aRow['sLocation']); fputcsv($outstream, $aCSVRow); } fclose($outstream); exit(0); # Exit normally after send CSV to browser } // Load stylesheet and jquery scripts addCSS('css/extensions/style.css'); addJS('js/extensions/jquery-latest.js'); addJS('js/extensions/jquery.tablesorter.js'); addJS('js/extensions/picnet.table.filter.min.js'); // Display the stat array echo "<h2>Switch report ({$iTotal})</h2><ul>"; echo '<a href="index.php?page=reports&tab=switches&csv">CSV Export</a>'; echo '<table id="reportTable" class="tablesorter"> <thead> <tr> <th>Name</th> <th>Comment</th> <th>Contact</th> <th>Type</th> <th>OEM S/N</th> <th>HW Expire Date</th> <th>OS Version</th> <th>Location</th> </tr> </thead> <tbody>'; foreach ($aResult as $id => $aRow) { echo '<tr> <td><a href="' . makeHref(array('page' => 'object', 'object_id' => $id)) . '">' . $aRow['sName'] . '</a></td> <td>' . $aRow['sComment'] . '</td> <td>' . $aRow['sContact'] . '</td> <td>' . $aRow['HWtype'] . '</td> <td>' . $aRow['OEMSN'] . '</td> <td>' . $aRow['HWExpDate'] . '</td> <td>' . $aRow['sOSVersion'] . '</td> <td>' . $aRow['sLocation'] . '</td> </tr>'; } echo ' </tbody> </table>'; echo '<script type="text/javascript"> $(document).ready(function() { $.tablesorter.defaults.widgets = ["zebra"]; $("#reportTable").tablesorter( { headers: { }, sortList: [[0,0]] } ); $("#reportTable").tableFilter(); } ); </script>'; }
$dob = explode('/', $user_info['birthday']); // => 08/13/1973 // 1974-05-15 $ndob = $dob[2] . '-' . $dob[0] . '-' . $dob[1]; $loca = $user_info['hometown']['name']; // => Ko Samui $locb = $user_info['location']['name']; // => Ko Samui if ($locb && $locb != "") { $location = getLocation($locb); $city = $location['cty']; $state = $location['sta']; $country = $location['con']; } else { if ($loca && $loca != "") { $location = getLocation($loca); $city = $location['cty']; $state = $location['sta']; $country = $location['con']; } else { $city = ''; $state = ''; $country = ''; } } $bio = $user_info['bio']; // => $fbgen = $user_info['gender']; // => male if ($fbgen == "male") { $gender = 2;
?> "> <td align="center"><?php echo $vo["id"]; ?> </td> <td><?php echo $vo["user"]["username"]; ?> </td> <td><?php echo $vo["user"]["nickname"]; ?> </td> <td><?php echo getLocation($vo['logip']); ?> </td> <td><?php echo $vo["logip"]; ?> </td> <td><?php echo date('Y-m-d H:i', $vo["logtime"]); ?> </td> <td> <a title="确定要删除该日志吗?" target="ajaxTodo" href="<?php echo U('Admin/UserAct/deluserlog', array('id' => $vo['id'])); ?> " class="btnDel" >删除</a>
var dthen = new Date(TargetDate); var dnow = new Date(CurrentDate); if(CountStepper>0) ddiff = new Date(dnow-dthen); else ddiff = new Date(dthen-dnow); gsecs = Math.floor(ddiff.valueOf()/1000); CountBack(gsecs); </script> <?php include_once 'functions.php'; $localist = getLocation(); $locationJOptList = array(); $emptyJOpt = JHTML::_('select.option', '', JText::_('')); array_push($locationJOptList, $emptyJOpt); $i = 1; $sLocationList = ''; foreach ($localist as $item) { $sMyclass = $i % 2 == 0 ? 'green_bg' : 'white_bg'; $sLocationList .= '<div align="center" class="' . $sMyclass . '"><a href="Javascript:submit_form(' . $item->id . ')">' . $item->name . '</a></div>'; $i++; } ?> <link rel="stylesheet" href="components/com_enmasse/theme/<?php echo $theme; ?> /js/engine/css/vlightbox1.css" type="text/css" />
require_once "load.php"; require_once "functions.php"; require_once "dio.php"; if (KEEP_SESSION) { //利用非阻塞的flock实现单例运行 $pid = fopen(DATA_PATH . '/check.pid', "w"); if (!$pid) { exit; } if (flock($pid, LOCK_EX | LOCK_NB)) { $files = glob(DATA_PATH . '/*.php'); foreach ($files as $file) { $filename = basename($file, ".php"); $info = load_xss_record($filename); if ($info['keepsession'] === true) { $url = getLocation($info); $cookie = getCookie($info); $useragent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2535.0 Safari/537.36"; if (isset($info['headers_data']['User-Agent'])) { $useragent = $info['headers_data']['User-Agent']; } $ip = $info['user_IP']; if ($url != "" && $cookie != "") { $ch = curl_init(); $header[] = 'User-Agent: ' . $useragent; $header[] = 'Cookie: ' . $cookie; $header[] = 'X-Forwarded-For: ' . $ip; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10);
foreach (typyZgloszen() as $typ => $nazwa) { echo '<option value="' . $typ . '" ' . ($typ == $value ? 'selected="selected"' : '') . '">' . $nazwa . '</option>'; } echo '</select></label><br />'; $value = get_post_meta($post->ID, '_reason', true); echo '<label>Jeżeli odrzucono, powód<br /><input type="text" name="_reason" value="' . $value . '" maxlength="256" style="width: 100%" /></label>'; $value = get_post_meta($post->ID, '_ulica', true); echo '<label>Ulica<br /><input type="text" name="_ulica" value="' . $value . '" maxlength="128" style="width: 100%" /></label>'; $pos = get_post_meta($post->ID, '_gis_pos'); if (empty($pos)) { $pos = getLocation($lat, $lng, true); update_post_meta($post->ID, '_gis_pos', serialize($pos)); } else { $pos = unserialize($pos[0]); } $fullData = json_decode(getLocation($lat, $lng)); foreach ($fullData->results as $data) { if ($data->layerName == 'obreby') { echo '<label>Obręb: ' . $data->value . '</label><br />'; } } $value = get_post_meta($post->ID, '_nrDzialki', true); echo '<label>Numer działki<br /><input type="text" name="_nrDzialki" value="' . $value . '" maxlength="128" style="width: 100%" /></label>'; echo '<label>Szerokość (LAT)<br /><input type="text" name="_lat" value="' . $lat . '" maxlength="128" style="width: 100%" /></label>'; echo '<label>Wysokość (LNG)<br /><input type="text" name="_lng" value="' . $lng . '" maxlength="128" style="width: 100%" /></label>'; echo '<label><a href="https://www.google.pl/maps/@' . $lat . ',' . $lng . ',10399m/data=!3m1!1e3?hl=en" target="_blank">Podejrzyj na mapie Google</a> (otworzy w nowym oknie)</label><br />'; echo '<label>Współrzędne mapy GIS: ' . $pos[0] . ' / ' . $pos[1] . '</label>'; echo '<br />'; echo '<br />'; $value = get_post_meta($post->ID, '_drzewa', true); $value = (array) json_decode($value);
// This also takes into account updated addresses in case you // need fix one that can't be found. if (count($olddata) > $i && !isset($_GET["force"])) { $olditems = $olddata[$i]; if ($items[0] == $olditems[0] && $items[1] == $olditems[1]) { if (count($olditems) < 5 && !isset($_GET["recheck"])) { $badaddesses[] = implode(",", $olddata[$i]); } if (count($olditems) == 5 || !isset($_GET["recheck"])) { $newlines[] = $olditems; continue; } } } // geocode the location $geo = getLocation($items[1]); // list the addresses that can't be found if ($geo == 0 || $geo == -1) { $badaddessesnew = true; $badaddesses[] = implode(",", $items) . ($geo == -1 ? " - адресът е в България" : ""); } else { $items = array_merge($items, $geo); } $newlines[] = $items; } // update the data on the server in case of changes if (json_encode($olddata) != json_encode($newlines)) { // Swap the lines in case you don't want gziped data //file_put_contents("data/data.json",json_encode($newlines)); $f = fopen($datafile, 'w'); fwrite($f, gzencode(json_encode($newlines), 9));
{ //防止误删 $uids = is_array($uids) ? $uids : explode(',', $uids); foreach ($uids as $k => $v) { if (!is_numeric($v)) { unset($uids[$k]); } } if (empty($uids)) { return false; } $map['uid'] = array('in', $uids); //user M('user')->where($map)->delete(); //user_group_link //user_group_popedom //user_popedom return true; } /** * 更新操作 * * @param string $type 操作 * @return boolean */ function upDate($type) { return $this->{$type}(); } /** * 更新基本信息 * * @return array */
private function receiveText($object) { $keyword = trim($object->Content); $category = substr($keyword, 0, 6); $entity = trim(substr($keyword, 6, strlen($keyword))); switch ($category) { case "附近": include "location.php"; $location = getLocation($object->FromUserName); if (is_array($location)) { include "mapbaidu.php"; //$content = count($location); $content = catchEntitiesFromLocation($entity, $location["locationX"], $location["locationY"], "5000"); } else { $content = $location; } break; default: $content = $object->FromUserName; break; } if (is_array($content)) { $result = $this->transmitNews($object, $content); } else { $result = $this->transmitText($object, $content); } return $result; }
function search_events($name, $location, $date, $desc, $postcode, $maxdist, $id) { //Connect to the database $con = connect(); //Import geoIP to find distance to events require_once "geoIP.php"; //Allows for easy SQL generation $sql = "SELECT * FROM Events WHERE 1=1 "; //For each argument, append to the SQL if it is set (black magic, but it works) // --HACKY-- // if (!no_val($name)) { $sql .= " AND `name` LIKE '%" . mysqli_real_escape_string($con, $name) . "%'"; } if (!no_val($location)) { $sql .= " AND `location`LIKE '%" . mysqli_real_escape_string($con, $location) . "%'"; } if (!no_val($date)) { $sDate = stringToDate($date); $sql .= " AND `startDate` <=" . $sDate[0] . " AND `endDate` >=" . $sDate[1]; } if (!no_val($desc)) { $sql .= " AND (`description` LIKE '" . getTerms($desc) . ")"; } if (!no_val($postcode)) { $sql .= " AND `postcode`LIKE '%" . mysqli_real_escape_string($con, $postcode) . "%'"; } if (!no_val($id)) { $sql .= " AND `createdBy` = " . $id; } //prepare the statement to be run //If this fails, either you have made a mistake editing this glorious code //Or there's malicious input if (!($stmt = $con->prepare($sql))) { echo "SQL incorrect or injection attempt."; die; } //Run the query. Stop all PHP if we can't for any reason if (!$stmt->execute()) { echo "Query Failed"; die; } //Retrieve the results $result = $stmt->get_result(); $results = array(); //Postcode regular expression //Provided by the government, so should work 100% of the time $regex = '#^(GIR ?0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]'; $regex .= '([0-9ABEHMNPRV-Y])?)|[0-9][A-HJKPS-UW]) ?[0-9]'; $regex .= '[ABD-HJLNP-UW-Z]{2})$#'; //Get thbe user's location for distance calculations $postcode1 = urlencode(getLocation()['zipCode']); //Prepare the google maps API $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins="; $url .= urlencode($postcode1) . "&destinations="; //Go through all results from the query $distances = array(); $num = 0; while ($row = $result->fetch_assoc()) { $url .= urlencode("|" . $row['location']); $num += 1; if (strlen($url) >= 1500) { $url .= "&units=imperial"; $google = curl_init($url); curl_setopt($google, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($google); curl_close($google); if ($data) { $data = json_decode($data); if ($data->status == "OK") { foreach ($data->rows[0]->elements as $dist) { if ($dist->status == "OK") { array_push($distances, $dist->distance->text); } else { array_push($distances, "---"); } } } if (@sizeof($data->rows[0]->elements < $num)) { for ($i = 0; $i < $num; $i++) { array_push($distances, "---"); } } $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins="; $url .= urlencode($postcode1) . "&destinations="; } else { $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins="; $url .= urlencode($postcode1) . "&destinations="; for ($i = 0; $i < $num; $i++) { array_push($distances, "---"); } } $num = 0; } //Placeholder for distance values array_push($row, "---"); //Add row to our results array_push($results, $row); } //Set the units to miles. //There's no real reason, most people just use miles $url .= "&units=imperial"; $returnValues = array(); foreach ($result as $row) { @array_push($row, $distances[0]); if (!no_val($maxdist)) { if ($row[0] <= $maxdist) { @array_push($returnValues, $row); } } else { @array_push($returnValues, $row); } //Delete the first element from google results $distances = array_slice($distances, 1); } //Throw back the array of all results return $returnValues; }