Пример #1
0
 public function getuserLocation()
 {
     $ip = "";
     //Retrieving user ip
     $client = @$_SERVER['HTTP_CLIENT_IP'];
     $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
     $remote = $_SERVER['REMOTE_ADDR'];
     if (filter_var($client, FILTER_VALIDATE_IP)) {
         $ip = $client;
     } elseif (filter_var($forward, FILTER_VALIDATE_IP)) {
         $ip = $forward;
     } else {
         $ip = $remote;
     }
     //$tags = $this->getLocationByIp($ip);
     $tags = get_meta_tags('http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=' . $ip);
     $location = new Location();
     $city_id = "";
     //getting the values from the tags
     $location->setCountryName($tags['country']);
     $location->setProvinceName($tags['region']);
     $location->setCityName($tags['city']);
     //passing the values to the variables
     $countryname = $location->getCountryName();
     $provincename = $location->getProvinceName();
     $cityname = $location->getCityName();
     //Finding if the countries, and cities already exist
     $country_res = $this->getCountryByName($countryname);
     $province_res = $this->getProvinceByName($provincename);
     $city_res = $this->getCityByName($cityname);
     //If the information is not in the databse, then add it
     if ($country_res->getCountryName() == "" && $province_res->getProvinceName() == "" && $city_res->getCityName() == "") {
         $city_id = $this->addLocation($location);
         echo "All Empty Result";
     } else {
         if ($country_res->getCountryName() != "" && $province_res->getProvinceName() == "" && $city_res->getCityName() == "") {
             $provinceid = addProvince($provincename, $country_res->getCountryId());
             addCity($cityname, $provinceid);
         } else {
             if ($country_res->getCountryName() != "" && $province_res->getProvinceName() != "" && $city_res->getCityName() == "") {
                 $provinceid = addProvince($provincename, $country_res->getCountryId());
                 $city_id = addCity($cityname);
             } else {
                 $cityres = $this->getCityByName($cityname);
                 $city_id = $cityres->getCityId();
             }
         }
     }
     //Return city Id at the end
     return $city_id;
 }
Пример #2
0
} elseif ($act == "addAdmin") {
    $mes = addAdmin();
} elseif ($act == "editAdmin") {
    $mes = editAdmin($id);
} elseif ($act == "delAdmin") {
    $mes = delAdmin($id);
} elseif ($act == "addProv") {
    $mes = addProv();
} elseif ($act == "editProv") {
    $where = "id={$id}";
    $mes = editProv($where);
} elseif ($act == "delProv") {
    $where = "id={$id}";
    $mes = delProv($where);
} elseif ($act == "addCity") {
    $mes = addCity();
} elseif ($act == "editCity") {
    $where = "id={$id}";
    $mes = editCity($where);
} elseif ($act == "delCity") {
    $where = "id={$id}";
    $mes = delCity($where);
} elseif ($act == "addUser") {
    $mes = addUser();
} elseif ($act == "editUser") {
    $mes = editUser($id);
} elseif ($act == "delUser") {
    $mes = delUser($id);
}
?>
Пример #3
0
 function getCities($dojobs = false)
 {
     $cities = array();
     function addCity(&$cities, $doc)
     {
         if (isset($doc['city']) and isset($doc['state'])) {
             $city = getCity($doc['city'] . ', ' . $doc['state']);
         } else {
             $city = getCity($doc['location']);
         }
         if ($city != null) {
             if (isset($cities[$city])) {
                 $cities[$city]++;
             } else {
                 $cities[$city] = 1;
             }
         }
     }
     $sublets = $this->dbstudent->listings->find();
     foreach ($sublets as $doc) {
         addCity($cities, $doc);
     }
     if ($dojobs) {
         $jobs = $this->db->jobs->find();
         foreach ($jobs as $doc) {
             addCity($cities, $doc);
         }
     }
     return $cities;
 }
$tarif = $_POST["tarif"];
$lastvisit = $_POST["date_inscription"];
$temps = $_POST["temps"];
//date de renouvellement adhesion automatiquement crée
$daterenouv = date_create($date);
date_add($daterenouv, date_interval_create_from_date_string('365 days'));
$daterenouv = date_format($daterenouv, 'Y-m-d');
$newsletter = "0";
$ville = $_POST["ville"];
$codepost = $_POST["codepostal"];
$commune = addslashes($_POST["commune"]);
$pays = addslashes($_POST["pays"]);
if (isset($_POST["submit"])) {
    //1 ajout de la ville en plus si besoin
    if ($ville == 0) {
        $idnewcity == addCity($commune, $codepost, $pays);
        if (FALSE == $idnewcity) {
            echo getError(0);
            $ville = 0;
        } else {
            $ville = $idnewcity;
        }
    } else {
        $ville = $_POST["ville"];
    }
    if (FALSE == checkLogin($login)) {
        $mess = getError(5);
    } else {
        if (!$nom || !$prenom || !$annee || !$adresse || !$login) {
            $mess = getError(4);
            exit;
  include/admin_city.php V0.1
*/
// Gestion des villes
//
// traitement des post
$act = $_GET["act"];
$idcity = $_GET["idcity"];
if (isset($_GET["act"])) {
    switch ($act) {
        case 1:
            // creation
            $nom = addslashes($_POST["newcity"]);
            $codepost = $_POST["newcodepost"];
            $pays = addslashes($_POST["newpays"]);
            if (FALSE == addCity($nom, $codepost, $pays)) {
                echo getError(0);
            } else {
                header("Location:index.php?a=41");
            }
            break;
        case 2:
            // modification
            $nom = $_POST["city"];
            $codepost = $_POST["codepost"];
            $pays = $_POST["pays"];
            error_log("nom = " . $nom . " / codepost = " . $codepost . " / pays = " . $pays . " / idcity = " . $idcity);
            if (FALSE == modCity($idcity, $nom, $codepost, $pays)) {
                echo getError(0);
            } else {
                header("Location:index.php?a=41");
Пример #6
0
function addCity_action($mysqli)
{
    $data = addCity($mysqli);
    require "templates/addCity.php";
}