Whois, locations

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
IAD
Forum Commoner
Posts: 42
Joined: Wed Dec 28, 2005 12:36 pm
Location: Israel, Soon Canada :)

Whois, locations

Post by IAD »

Hey,

I just built a whois class, simple, and i have a problem, for example, when i'm in: ?a=css, it will add to the DB : a=css, and then in for printing a=css real location [ editing css files ], no pro, but, when i got: ?a=css&w=new, i have a problem, the data is on $data [?a=css&w=new] but how can i make a simple replacement?


The whois class:

Code: Select all

class whois{


		private $doSearch; // checking if the user is not yet signed in at the DB storage
		private $IP; // client's ip
		private $expent; // will be in use when we will need to get the client's location
		private $time; // linux time [time();]
		private $username;
		private $status;
		private $sess_value;
		private $sess_name = "admin_sess";

		public function checkTime(){

			global $DB;

				$time = time(); // 3000 - 2700 >= 300

				$DB -> query("DELETE FROM `pmaker_whois` WHERE '$time' - timestamps >= '300'");

		}

		public function OnPageLoad(){

			global $DB,$Err;

				$this -> checkTime();

				$this -> IP = $_SERVER['REMOTE_ADDR'];

				$this -> doSearch = $DB -> query("SELECT * FROM `pmaker_whois` WHERE ip = '{$this -> IP}'");
				
					
						

						if(preg_match("/.?./" ,$_SERVER['REQUEST_URI'])){

						$this -> expent = str_replace("?","/",$_SERVER['REQUEST_URI']);

							$this -> location = basename($this -> expent);
						}
						else
						{
							$this -> location = $_SERVER['REQUEST_URI'];
						}
							$this -> time = time();
							$this -> date = date("H:i:s");

						if(empty($_SESSION)){
				
							$this -> sess_value = 0;

						}
						else{

							$this -> sess_value = $_SESSION[$this -> sess_name];

						}
							
								if($DB -> count($this -> doSearch) == 1){

									$DB -> query("UPDATE `pmaker_whois` SET location = '{$this -> location}', timestamps = '{$this -> time}',ip = '{$this -> IP}', sess_value = '{$this -> sess_value}'   WHERE ip = '{$this -> IP}' ");

								}
								else
								{	
		
									$DB -> query("INSERT INTO `pmaker_whois` (location,timestamps,date,ip,sess_value) VALUES ('{$this -> location}','{$this -> time}','{$this -> date}','{$this -> IP}','{$this -> sess_value}')");

								}


		}
}


Tal.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

out of curiosity, what do you think your preg_match() call does where you access REQUEST_URI ?
IAD
Forum Commoner
Posts: 42
Joined: Wed Dec 28, 2005 12:36 pm
Location: Israel, Soon Canada :)

Post by IAD »

when i got: admin\index.php, it will insert it regulary, but when i got in the REQEST_URI: admin.php?a=css i want to take only the a=css so then i'm taking it with it basename only.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

parse_url() may be of interest.
Post Reply