Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $host = "localhost";
- $user = "abdoelte_root";
- $pass = "1WR--79.QIy2";
- $database = "abdoelte_db";
- $action = $_GET['action'];
- if($action == null || $action == ""){
- $action = $_POST['action'];
- }
- $uid = $_SESSION['uid'];
- $htop = "";
- $htop.= "<!DOCTYPE html>";
- $htop.= " <head>";
- $htop.= " <title>Abdoelmalik login</title>";
- $htop.= ' <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">';
- $htop.= ' <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />';
- $htop.= ' <script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>';
- $htop.= ' <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>';
- $htop.= ' <style>';
- $htop.= ' #map { height: 100vh; }';
- $htop.= ' </style>';
- $htop.= " </head>";
- $htop.= " <body>";
- $htop.= ' <div class= "container">';
- $hbot = "";
- $hbot.= ' </div>';
- $hbot.= " </body>";
- $hbot.= "</html>";
- if($action == "login"){
- $username = $_POST['username'];
- $password = $_POST['password'];
- $db = mysql_connect($host,$user,$pass);
- mysql_select_db($database) or die("Unable to select database");
- mysql_query("SET NAMES utf8", $db);
- mysql_query( "SET CHARACTER SET utf8", $db );
- mysql_query("");
- $sql = "SELECT * FROM users WHERE username='".$username."' AND password=MD5('".$password."') LIMIT 1";
- $res = mysql_query($sql);
- if(mysql_numrows($res) > 0){
- $_SESSION['uid'] = mysql_result($res, 0, "id");
- header("location: index.php");
- }else {
- $h = '<h2>Uw gegevens komen niet overeen! Probeer het nog eens.</h2>';
- echo $htop;
- echo $h;
- echo $hbot;
- }
- }
- if($action == "logout"){
- session_destroy();
- $_SESSION['uid'] = "";
- header("location: index.php");
- }
- if($uid != null || $uid != ""){
- if($action == "json"){
- $db = mysql_connect($host,$user,$pass);
- mysql_select_db($database) or die("Unable to select database");
- mysql_query("SET NAMES utf8", $db);
- mysql_query( "SET CHARACTER SET utf8", $db );
- mysql_query("");
- $sql = "SELECT * FROM companies";
- $res = mysql_query($sql);
- $data = array();
- for($i=0;$i<mysql_numrows($res);$i++){
- $loc = array();
- $res1 = mysql_query("SELECT * FROM locations WHERE id='".mysql_result($res,$i,"lID")."'");
- for($q=0;$q<mysql_numrows($res1);$q++){
- $locs = array(
- "id" => mysql_result($res1,$q,"id"),
- "lat" => mysql_result($res1,$q,"latitude"),
- "lon" => mysql_result($res1,$q,"longitude")
- );
- array_push($loc, $locs);
- }
- $item = array(
- "id" => mysql_result($res,$i,"id"),
- "name" => mysql_result($res,$i,"name"),
- "tel" => mysql_result($res,$i,"tel"),
- "loc" => $loc
- );
- array_push($data, $item);
- }
- $retval = array(
- "status" => "200",
- "url" => "?action=".$action,
- "data" => $data
- );
- echo json_encode($retval, true);
- }elseif($action == "json1"){
- $db = mysql_connect($host,$user,$pass);
- mysql_select_db($database) or die("Unable to select database");
- mysql_query("SET NAMES utf8", $db);
- mysql_query( "SET CHARACTER SET utf8", $db );
- mysql_query("");
- $sql = "SELECT * FROM winkels";
- $res = mysql_query($sql);
- $shop = array();
- for($j=0;$j<mysql_numrows($res2);$j++){
- $category = array();
- $res3 = mysql_query("SELECT * FROM winkelsCategorien WHERE id='".mysql_result($res3,$p,"winkelID")."'");
- for($p=0;$p<mysql_numrows($res3);$p++){
- $categorien = array(
- "id" => mysql_result($res3,$p,"id"),
- "name" => mysql_result($res3,$p,"name"),
- "winkelID" => mysql_result($res3,$p,"winkelID")
- );
- array_push($category, $categorien);
- }
- $winkel = array(
- "id" => mysql_result($res2,$j,"id"),
- "name" => mysql_result($res2,$j,"name"),
- "email" => mysql_result($res2,$j,"email"),
- );
- array_push($shop, $winkel);
- }
- $retval = array(
- "status" => "200",
- "url" => "?action=".$action,
- "data" => $shop
- );
- echo json_encode($retval, true);
- }else{
- $h = "";
- $db = mysql_connect($host,$user,$pass);
- mysql_select_db($database) or die("Unable to select database");
- mysql_query("SET NAMES utf8", $db);
- mysql_query( "SET CHARACTER SET utf8", $db );
- mysql_query("");
- $sql = "SELECT * FROM locations WHERE status='Y'";
- $res = mysql_query($sql);
- $h.= ' <script>';
- $h.= ' jQuery(document).ready(function(){';
- $h.= ' var map = L.map("map").setView([52.9, 4.89098], 17);';
- $h.= ' L.tileLayer("https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}", {';
- $h.= ' attribution: "Map data © <a href=\'http://openstreetmap.org\'>OpenStreetMap</a> contributors, <a href=\'http://creativecommons.org/licenses/by-sa/2.0/\'>CC-BY-SA</a>, Imagery © <a href=\'http://mapbox.com\'>Mapbox</a>",';
- $h.= ' maxZoom: 18,';
- $h.= ' id: "glimworm.cigc127z202zivlm40pxvwa9s",';
- $h.= ' accessToken: "pk.eyJ1IjoiZ2xpbXdvcm0iLCJhIjoiY2lnYzEyODcyMDJ6dHZ1bTUyemZ5c2N2bSJ9.FDMQQKXFJo6R5cUqoYmUPA"';
- $h.= ' }).addTo(map);';
- for($i=0;$i<mysql_numrows($res);$i++){
- $h.= ' var marker = L.marker(['.mysql_result($res, $i, "latitude").', '.mysql_result($res, $i, "longitude").']).addTo(map);';
- }
- $h.= ' });';
- $h.= ' </script>';
- $h.= '<a href="?action=logout" class="btn btn-danger btn-lg">LOGOUT</a> <a href="?action=json" class="btn btn-primary btn-lg">json</a> <a href="?action=json1" class="btn btn-primary btn-lg">json1</a>';
- $h.= '<div id="map"></div>';
- echo $htop;
- echo $h;
- echo $hbot;
- }
- }else{
- $h = "";
- $h.= '<form method="post" action="" class="form-signin">';
- $h.= ' <input type="hidden" name="action" value="login"/><br/><br />';
- $h.= ' <input class="form-control" placeholder="Username" required="" name="username" autofocus="" type="text"> <br/><br />';
- $h.= ' <input class="form-control" placeholder="Password" required="" name="password" type="password"><br /><br />';
- $h.= ' <input class="btn btn-lg btn-primary btn-block" type="submit" value="Log in">';
- $h.= '</form>';
- echo $htop;
- echo $h;
- echo $hbot;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement