示例#1
0
 public function destroy(Town $town)
 {
     $town->setPopulation(-self::POP);
     $town->setPopulationMax(-self::POP);
     $town->setProsperity(-4);
     //retirer en bdd l'id et les coordonnées du batiment pour qu'il disparaisse
 }
示例#2
0
 public function post_register()
 {
     $rules = array('regName' => 'required|match:/[a-z]+/', 'regLastName' => 'required|match:/[a-z]+/', 'regMail' => 'required|unique:users,email', 'regMail2' => 'required', 'regPassword' => 'required|max:18|min:3', 'regPassword2' => 'same:regPassword', 'regDate' => 'before:01/01/1998', 'regCell' => 'required');
     $vld = Validator::make(Input::all(), $rules);
     if ($vld->fails()) {
         $getCity = City::all();
         $get1stTowns = Town::where('city_id', '=', 1)->get();
         return View::make('user.register')->with('city', $getCity)->with('towns', $get1stTowns);
     }
     $data = Input::all();
     //Gender Validation
     if ($data['regGender'] === 'Woman') {
         $data['regGender'] = 0;
     } elseif ($data['regGender'] === 'Man') {
         $data['regGender'] = 1;
     } else {
         $data['regGender'] = -1;
     }
     //Date Validation
     $MySQLDate = date('Y-m-d', strtotime(str_replace('/', '-', $data['regDate'])));
     try {
         // create the user
         $user = Sentry::user()->register(array('email' => $data['regMail'], 'password' => $data['regPassword'], 'metadata' => array('first_name' => $data['regName'], 'last_name' => $data['regLastName'], 'birth_date' => $MySQLDate, 'city' => $data['regCity'], 'town' => $data['regTown'], 'phone' => $data['regPhone'], 'cell_phone' => $data['regCell'], 'sex' => $data['regGender'])));
         if ($user) {
             // the user was created
             $_user = Sentry::user($user['id']);
             $link = URL::Base() . '/user/activate/' . $user['hash'];
             $name = $_user->metadata['first_name'] . ' ' . $_user->metadata['last_name'];
             $to = $_user['email'];
             sendActivation($to, $name, $link);
         } else {
             return Response::error('500');
         }
     } catch (Sentry\SentryException $e) {
         return View::make('user.register')->with('error', $e->getMessage());
     }
     return View::make('user.register-complete');
 }
示例#3
0
    public function hookAdminOrder($params)
    {
        $versionSpecialClass = '';
        if (!file_exists(_PS_MODULE_DIR_ . 'seur/img/logonew_32.png') && file_exists(_PS_MODULE_DIR_ . 'seur/img/logonew.png')) {
            ImageManager::resize(_PS_MODULE_DIR_ . 'seur/img/logonew.png', _PS_MODULE_DIR_ . 'seur/img/logonew_32.png', 32, 32, 'png');
        }
        if (version_compare(_PS_VERSION_, '1.5', '<')) {
            $versionSpecialClass = 'ver14';
        }
        $this->displayWarning();
        if (Configuration::get('SEUR_Configured') == 1) {
            $cookie = $this->context->cookie;
            $token = Tools::getValue('token');
            $back = Tools::safeOutput($_SERVER['REQUEST_URI']);
            $seur_carriers = SeurLib::getSeurCarriers(false);
            $ids_seur_carriers = array();
            foreach ($seur_carriers as $value) {
                $ids_seur_carriers[] = (int) $value['id'];
            }
            $order = new Order((int) $params['id_order']);
            $address_saved = DB::getInstance()->getValue('
				SELECT `id_address_delivery`
				FROM `' . _DB_PREFIX_ . 'seur_order`
				WHERE `id_order` = "' . (int) $order->id . '"
			');
            if ($address_saved === '0') {
                $this->context->smarty->assign('pickup_point_warning', true);
            }
            if (!Validate::isLoadedObject($order)) {
                return false;
            }
            $delivery_price = $order_weigth = 0;
            $products = $order->getProductsDetail();
            foreach ($products as $product) {
                $order_weigth += (double) $product['product_weight'] * (double) $product['product_quantity'];
            }
            $order_weigth = $order_weigth < 1.0 ? 1.0 : (double) $order_weigth;
            $customer = new Customer((int) $order->id_customer);
            $address_delivery = new Address((int) $order->id_address_delivery, (int) $cookie->id_lang);
            if (!Validate::isLoadedObject($address_delivery)) {
                return false;
            }
            $iso_country = Country::getIsoById((int) $address_delivery->id_country);
            if ($iso_country == 'PT') {
                $post_code = explode(' ', $address_delivery->postcode);
                $post_code = $post_code[0];
            } else {
                $post_code = $address_delivery->postcode;
            }
            $international_orders = SeurLib::getConfigurationField('international_orders');
            $date_calculate = strtotime('-14 day', strtotime(date('Y-m-d')));
            $date_display = date('Y-m-d H:m:i', $date_calculate);
            if (strtotime($order->date_add) > strtotime($date_display) && in_array((int) $order->id_carrier, $ids_seur_carriers)) {
                if (!$international_orders && ($iso_country == 'ES' || $iso_country == 'PT' || $iso_country == 'AD') || $international_orders) {
                    if (!SeurLib::getSeurOrder((int) $order->id)) {
                        SeurLib::setSeurOrder((int) $order->id, 1, $order_weigth, null);
                    } elseif (Tools::getValue('numBultos') && Tools::getValue('pesoBultos')) {
                        SeurLib::setSeurOrder((int) $order->id, (int) Tools::getValue('numBultos'), str_replace(',', '.', Tools::getValue('pesoBultos')), null);
                    }
                    $order_data = SeurLib::getSeurOrder((int) $order->id);
                    $response_post_code = Town::getTowns($post_code);
                    $order_weigth = (double) $order_weigth != $order_data['peso_bultos'] ? (double) $order_data['peso_bultos'] : (double) $order_weigth;
                    if (is_object($response_post_code)) {
                        $towns = array();
                        $num = (int) $response_post_code->attributes()->NUM[0];
                        for ($i = 1; $i <= $num; $i++) {
                            $name = 'REG' . $i;
                            $towns[] = utf8_decode((string) $response_post_code->{$name}->NOM_POBLACION);
                        }
                    }
                    $name = $address_delivery->firstname . ' ' . $address_delivery->lastname;
                    $direccion = $address_delivery->address1 . ' ' . $address_delivery->address2;
                    $newcountry = new Country((int) $address_delivery->id_country, (int) $cookie->id_lang);
                    $iso_merchant = SeurLib::getMerchantField('country');
                    $rate_data = array('town' => $address_delivery->city, 'peso' => (double) $order_weigth, 'post_code' => $post_code, 'bultos' => $order_data['numero_bultos'], 'ccc' => SeurLib::getMerchantField('ccc'), 'franchise' => SeurLib::getMerchantField('franchise'), 'iso' => $newcountry->iso_code, 'iso_merchant' => $iso_merchant, 'id_employee' => $cookie->id_employee, 'token' => Tools::getAdminTokenLite('AdminOrders'), 'back' => $back);
                    $order_messages_str = '';
                    $info_adicional_str = $address_delivery->other;
                    $order_messages = Message::getMessagesByOrderId((int) $params['id_order']);
                    if (is_array($order_messages)) {
                        foreach ($order_messages as $order_messag_tmp) {
                            $order_messages_str .= "\n" . $order_messag_tmp['message'];
                        }
                        if (substr_count($order_messages_str, "\n") > 5) {
                            $order_messages_str = str_replace(array("\r", "\n"), ' | ', $order_messages_str);
                        }
                        if (Tools::strlen($order_messages_str) > 250) {
                            $order_messages_str = Tools::substr($order_messages_str, 0, 247) . '...';
                        }
                        $order_messages_str = trim($order_messages_str);
                    }
                    if (!empty($order_messages_str)) {
                        $info_adicional_str = $order_messages_str;
                    }
                    $label_data = array('pedido' => sprintf('%06d', (int) $order->id), 'total_bultos' => $order_data['numero_bultos'], 'total_kilos' => (double) $order_weigth, 'direccion_consignatario' => $direccion, 'consignee_town' => $address_delivery->city, 'codPostal_consignatario' => $post_code, 'telefono_consignatario' => !empty($address_delivery->phone_mobile) ? $address_delivery->phone_mobile : $address_delivery->phone, 'movil' => $address_delivery->phone_mobile, 'name' => $name, 'companyia' => !empty($address_delivery->company) ? $address_delivery->company : '', 'email_consignatario' => Validate::isLoadedObject($customer) ? $customer->email : '', 'dni' => $address_delivery->dni, 'info_adicional' => $info_adicional_str, 'country' => $newcountry->name, 'iso' => $newcountry->iso_code, 'iso_merchant' => $iso_merchant, 'admin_dir' => utf8_encode(_PS_ADMIN_DIR_), 'id_employee' => $cookie->id_employee, 'token' => Tools::getAdminTokenLite('AdminOrders'), 'back' => $back);
                    if (strcmp($order->module, 'seurcashondelivery') == 0) {
                        $rate_data['reembolso'] = (double) $order->total_paid;
                        $label_data['reembolso'] = (double) $order->total_paid;
                    }
                    $carrier_pos = SeurLib::getSeurCarrier('SEP');
                    $datospos = '';
                    if ((int) $order->id_carrier == $carrier_pos['id']) {
                        $datospos = SeurLib::getOrderPos((int) $order->id_cart);
                        if (!empty($datospos)) {
                            $label_data = array('pedido' => sprintf('%06d', (int) $order->id), 'total_bultos' => $order_data['numero_bultos'], 'total_kilos' => (double) $order_weigth, 'direccion_consignatario' => $direccion, 'consignee_town' => $datospos['city'], 'codPostal_consignatario' => $datospos['postal_code'], 'telefono_consignatario' => !empty($address_delivery->phone_mobile) ? $address_delivery->phone_mobile : $address_delivery->phone, 'movil' => $address_delivery->phone_mobile, 'name' => $name, 'companyia' => $datospos['company'], 'email_consignatario' => Validate::isLoadedObject($customer) ? $customer->email : '', 'dni' => $address_delivery->dni, 'info_adicional' => $info_adicional_str, 'country' => $newcountry->name, 'iso' => $newcountry->iso_code, 'cod_centro' => $datospos['id_seur_pos'], 'iso_merchant' => $iso_merchant);
                            $rate_data['cod_centro'] = $datospos['id_seur_pos'];
                        }
                    }
                    if ($iso_country == 'ES' || $iso_country == 'PT' || $iso_country == 'AD') {
                        $xml = Rate::getPrivateRate($rate_data);
                        if (is_object($xml)) {
                            foreach ($xml as $tarifa) {
                                $delivery_price += (double) $tarifa->VALOR;
                            }
                        }
                    }
                    if (Tools::getValue('submitLabel')) {
                        if ($this->isPrinted((int) $order->id)) {
                            $success = true;
                        } else {
                            $success = Label::createLabels($label_data, 'pdf');
                        }
                        if ($success === true) {
                            if (!$this->setAsPrinted((int) $order->id)) {
                                $this->context->smarty->assign('error', $this->l('Could not set printed value for this order'));
                            } else {
                                $this->printLabel((int) $order->id, 'pdf');
                            }
                        } else {
                            $this->context->smarty->assign('error', $success);
                        }
                    }
                    if (Tools::getValue('submitPrint')) {
                        if ($this->isPrinted((int) $order->id, true)) {
                            $success = true;
                        } else {
                            $success = Label::createLabels($label_data, 'zebra');
                        }
                        if ($success === true) {
                            if (!$this->setAsPrinted((int) $order->id, true)) {
                                $this->context->smarty->assign('error', $this->l('Could not set printed value for this order'));
                            } else {
                                $this->printLabel((int) $order->id, 'txt');
                            }
                        } else {
                            $this->context->smarty->assign('error', $success);
                        }
                    }
                    $seur_carriers = SeurLib::getSeurCarriers(false);
                    $pickup = Pickup::getLastPickup();
                    if (!empty($pickup)) {
                        $pickup_date = explode(' ', $pickup['date']);
                        $pickup_date = $pickup_date[0];
                    }
                    $address_error = 0;
                    if (!empty($towns) && !in_array(mb_strtoupper($this->replaceAccentedChars($address_delivery->city), 'UTF-8'), $towns)) {
                        $address_error = 1;
                    }
                    $pickup_s = 0;
                    if ($pickup && strtotime(date('Y-m-d')) == strtotime($pickup_date)) {
                        $pickup_s = 1;
                    }
                    $state = Expedition::getExpeditions(array('reference_number' => sprintf('%06d', (int) $order->id)));
                    $is_empty_state = false;
                    $xml_s = false;
                    if (!empty($state->out)) {
                        $is_empty_state = true;
                    } else {
                        $string_xml = htmlspecialchars_decode($state->out);
                        $string_xml = str_replace('&', '&amp; ', $string_xml);
                        $xml_s = simplexml_load_string($string_xml);
                    }
                    $rate_data_ajax = Tools::jsonEncode($rate_data);
                    $path = '../modules/seur/js/';
                    $file = (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/seur/files/deliveries_labels/' . sprintf('%06d', (int) $order->id) . '.txt';
                    $filePath = _PS_MODULE_DIR_ . 'seur/files/deliveries_labels/' . sprintf('%06d', (int) $order->id) . '.txt';
                    $label_data['file'] = $file;
                    $this->context->smarty->assign(array('path' => $this->_path, 'request_uri' => $_SERVER['REQUEST_URI'], 'module_instance' => $this, 'address_error' => $address_error, 'address_error_message' => $this->l('Addressess error, please check the customer address.'), 'pickup_s' => $pickup_s, 'pickup' => $pickup, 'isEmptyState' => $is_empty_state, 'xml' => $xml_s, 'order_data' => $order_data, 'iso_country' => $iso_country, 'order_weigth' => $order_weigth, 'delivery_price' => $delivery_price, 'rate_data_ajax' => $rate_data_ajax, 'js_path' => $path, 'token' => $token, 'order' => $order, 'label_data' => $label_data, 'fileExists' => file_exists($filePath), 'file' => $file, 'datospos' => $datospos, 'versionSpecialClass' => $versionSpecialClass, 'configured' => (int) Configuration::get('SEUR_Configured'), 'printed' => (bool) ($this->isPrinted((int) $order->id) || $this->isPrinted((int) $order->id, true))));
                    return $this->display(__FILE__, 'views/templates/admin/orders.tpl');
                }
            }
        } else {
            $this->context->smarty->assign(array('configured' => Configuration::get('SEUR_Configured'), 'path' => $this->_path, 'configuration_warning_message' => $this->l('Please, first configure your SEUR module as a merchant.')));
            return $this->display(__FILE__, 'views/templates/admin/orders.tpl');
        }
    }
示例#4
0
文件: town.php 项目: asbilyk/town
        }
        return $this->population;
    }
    public function display()
    {
        if (isset($this->town_name)) {
            echo "<h3>Информация о городе:</h3>";
        }
        if (isset($this->town_name)) {
            echo "Название города - " . $this->town_name . "<br>";
        }
        if (isset($this->foundation_year)) {
            echo "Год основания - " . $this->foundation_year . "г.<br>";
        }
        if (isset($this->latitude)) {
            echo "Координаты города - " . $this->latitude . ", " . $this->longitude . "<br>";
        }
        if (isset($this->number_of_streets)) {
            echo "Количество улиц - " . $this->number_of_streets . "<br>";
        }
        if (isset($this->number_of_streets)) {
            echo "Бюджет города: " . $this->calculate_budget() . " грн.<br>";
        }
        if (isset($this->number_of_streets)) {
            echo "Количество жителей в городе: " . $this->calculate_population() . " чел.<br><br>";
        }
    }
}
$town = new Town($town_name, $foundation_year, $latitude, $longitude, $number_of_streets);
$town->add_streets();
echo $town->display();
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Town the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Town::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#6
0
/*
	File: query.php
	Purpose: process ajax requests
*/
include 'include/lang.php';
include 'include/lib.php';
include 'include/config.php';
include 'include/usr.class.php';
include 'include/db.php';
if ($_GET['cmd'] == 'getTown') {
    if (!isset($_GET['town'])) {
        echo "0";
        exit;
    }
    $town = new Town($_GET['town']);
    echo $town->getSimpleMapData();
    exit;
}
if (isset($_GET['cmd'])) {
    $cmd = $_GET['cmd'];
}
if (isset($_POST['cmd'])) {
    $cmd = $_POST['cmd'];
}
if (!isset($cmd)) {
    echo "0";
    exit;
}
if (!($usr = initUser())) {
    echo "0";
示例#7
0
        return array('townNameRand' => rand(0, 3), 'streetCountRand' => rand(5, 25));
    }
    public static function getApartmentOptions()
    {
        return array('roomRand' => rand(1, 3), 'squareRand' => rand(25, 35), 'tenantRand' => rand(1, 5), 'gasRand' => rand(0, 1), 'kvtRand' => rand(0, 999));
    }
    public static function getStreetOptions()
    {
        return array('streetNameRand' => rand(0, 4), 'streetLengthRand' => rand(200, 4999), 'streetCoordsRand' => rand(48, 50) . "&deg" . rand(00, 59) . "&acute" . " с. ш. " . rand(30, 37) . "&deg" . rand(00, 59) . "&acute" . " в.д.", 'houseCountRand' => rand(9, 19));
    }
    public static function getBuildingOptions()
    {
        return array('houseNumberRand' => rand(1, 9), 'floorCountRand' => rand(0, 2), 'porchCountRand' => rand(2, 4));
    }
}
$town = new Town();
echo "<h4>" . 'Информация о населенном пункте :' . "</h4>";
echo 'Название населенного пункта: ' . $town->townName . "<br>";
echo 'Год основания: ' . $town->foundYear . " г.<br>";
echo 'Географические координаты: ' . $town->townCoords . "<br>";
echo 'Количество улиц: ' . count($town->streetCount) . "<br>";
echo "Бюджет населенного пункта полученный от налога на землю: " . $town->townLandTax() . " грн.<br>";
echo "Размер коммунальных платежей составляет " . $town->townTax() . " грн.<br>";
echo "Население " . $town->peopleCount() . " человек(а)<br><br>";
$street = $town->streetCount[0];
echo "<h4>" . 'Информация об улице:' . "</h4>";
echo "Название улицы: " . $street->streetName . "<br>";
echo "Протяженность: " . $street->streetLength . " м<br>";
echo "Координаты улицы: " . $street->streetCoords . "<br>";
echo "Кол-во домов на улице: " . count($street->houseCount) . "<br>";
echo "Кол-во дворников, обслуживающих улицу: " . $street->yardManCount() . " чел.<br>";
示例#8
0
 public function post_user_town()
 {
     $data = Input::all();
     $towns = Town::where('city_id', '=', $data['id'])->get();
     return Response::eloquent($towns);
 }
示例#9
0
<?php

include '../auth/lock.php';
require '../cfg/Coordinates.php';
require '../cfg/Town.php';
$towns = array(new Town("Gludio", new Coordinates(1, 2, 3)), new Town("Giran", new Coordinates(4, 6, 2)), new Town("Aden", new Coordinates(4, 2, 3)), new Town("Schuttgart", new Coordinates(1, 2, 3)), new Town("Rune", new Coordinates(1, 2, 3)), new Town("Goddard", new Coordinates(1, 2, 3)), new Town("Dion", new Coordinates(1, 2, 3)), new Town("Oren", new Coordinates(1, 2, 3)));
if (isset($_POST['submit'])) {
    $r = '';
    if (!empty($_POST['character']) and isset($_POST['character'])) {
        if (isset($_POST['town']) and !empty($_POST['town'])) {
            $who = $_POST['character'];
            $to = $_POST['town'];
            foreach ($towns as $value) {
                if ($value->getTitle() == $to) {
                    $town = new Town($to, $value->getCoordinates());
                    break;
                }
            }
            $current_coords = $town->getCoordinates();
            $sql = "UPDATE  `characters` SET  `x` =" . $current_coords->getX() . ",\n                                              `y` = " . $current_coords->getY() . ",\n                                              `z` = " . $current_coords->getZ() . "\n                    WHERE  `account_name` =  '" . $login_session . "'\n                            AND\n                           `char_name` =  '" . $who . "'";
            $query = mysqli_query($conn, $sql);
            if ($query) {
                $r = "Character " . $who . " has been teleported to " . $to;
            } else {
                $r = "Error occurred!";
            }
        }
    }
}
?>
<!DOCTYPE html>