Jump to content

blacknight

Members
  • Posts

    271
  • Joined

  • Last visited

Posts posted by blacknight

  1. this is teh funny part..

    Array ( [0] => 5b526b535b979265ee138cd3ade1c085 
    [sess_id] => 5b526b535b979265ee138cd3ade1c085 
    [1] => 6m7js82r848kk2s90sjfmuj325 
    [session_id] => 6m7js82r848kk2s90sjfmuj325 
    [2] => 0 
    [session_user_id] => 0 
    [3] => 0 
    [session_last_visit] => 0 
    [4] => 1331567561 
    [session_start] => 1331567561 
    [5] => 1331568461 
    [session_time] => 1331568461 
    [6] => 127.0.0.1 
    [session_ip] => 127.0.0.1 
    [7] => Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
    [session_browser] => Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) 
    [8] => 
    [session_forwarded_for] => 
    [9] => index.php 
    [session_page] => index.php 
    [10] => 0 
    [session_viewonline] => 0 
    [11] => 0 
    [session_autologin] => 0 
    [12] => 0 
    [session_admin] => 0 )

    the var dump is normal the insert is normal the data mutates after entry

  2. the whole function

    function UserTracker ($table="UTracker",$cookie="roster_hash",$minutes=15)
    {
    	global $roster;
    
    	if($minutes<15)
    		$minutes=15;
    	$this->expireTime=$minutes;
    	$this->cookieName=$cookie;
    	$this->time_now				= time();
    	$this->cookie_data			= array('u' => '', 'k' => '');
    
    	$this->browser				= (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : '';
    	$this->referer				= (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : '';
    	$this->forwarded_for		= (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? htmlspecialchars((string) $_SERVER['HTTP_X_FORWARDED_FOR']) : '';
    
    	$this->host					= $this->extract_current_hostname();
    	$this->page					= $this->extract_current_page($roster->config['website_address']);
    
    
    	//remove all the expired sessions . no need to keep them . cookies are long gone anyway .
    	$queryd="DELETE FROM `".$roster->db->table('sessions')."` WHERE `session_time`  <= '".(time())."'";
    	//echo $queryd.'<br>';
    	$resultd = $roster->db->query($queryd);
    	$roster->db->free_result($resultd);
    
    	$this->trackerID= (isset($this->uuid) ? $this->uuid : md5($_SERVER["HTTP_USER_AGENT"].$_SERVER["REMOTE_ADDR"]) );
    
    	$aquery="SELECT * FROM `".$roster->db->table('sessions')."` WHERE `session_id`='".session_id()."'";
    
    	$result = $roster->db->query($aquery);
    
    	$rows = $roster->db->num_rows($result);
    	$rec = array();
    	if ($rows == 1)
    	{
    		$rec = $roster->db->fetch($result);
    	}
    	$roster->db->free_result($result);
    
    	if(isset($rec['session_id']) && $rec['session_id'] == session_id())
    	{
    
    		$page = implode('-',$roster->pages);
    		//make the life of the cookie longer and update time and IP .
    		$xsql = "UPDATE `". $roster->db->table('sessions') ."` SET	`session_user_id` = '".$this->uid."', `session_last_visit` = '".time()."', `session_browser` = '".$this->browser."', `session_ip` = '".$this->getIP()."', `session_time` = '".(time()+60*15)."',
    		`session_page` = '".substr($this->page['page'], 0, 199)."' WHERE `session_id` = '" . session_id() . "'";
    		$rx = $roster->db->query($xsql);
    		$roster->db->free_result($rx);
    
    		$this->newSession=0;
    		return true;
    	}
    	else if ($rows == 0)
    	{
    		$domain = $_SERVER['HTTP_HOST'];
    		$url = "http://" . $_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI'];
    		$p = parse_url($url);
    		$page = $p['query'];
    		$xsql_ary = array(
    			'sess_id'				=> $this->trackerID,
    			'session_id'				=> session_id(),
    			'session_user_id'		=> $this->uid,
    			'session_start'			=> (int) time(),
    			'session_last_visit'	=> (int) $this->data['session_last_visit'],
    			'session_time'			=> (int) time()+(60*15),
    			'session_page'			=> substr($this->page['page'], 0, 199),
    			'session_browser'		=> (string) trim(substr($this->browser, 0, 149)),
    			'session_forwarded_for'	=> (string) $this->forwarded_for,
    			'session_ip'			=> (string) $this->getIP(),
    			'session_autologin'		=> ($session_autologin) ? 1 : 0,
    			'session_admin'			=> ($set_admin) ? 1 : 0,
    			'session_viewonline'	=> ($viewonline) ? 1 : 0,
    		);
    
    		// this allways errors out because the session exists... i hate this class....
    		$sql = 'REPLACE INTO `' . $roster->db->table('sessions') . '` ' . $roster->db->build_query('INSERT', $xsql_ary);
    		$s = $roster->db->query($sql);
    		$qry1 = "UPDATE `" . $roster->db->table('user_members') . "` SET `online` = '1' WHERE `id` = '".$sql_ary['session_user_id']."'";
    		$q = $roster->db->query($qry1);
    
    		$this->newSession=1;
    		return true;
    	}
    	else
    	{
    		$roster->set_message( ' An erroro has occured in your session it will now be reset', 'Sessions', 'notice' );
    	}
    }
    

  3. 		$xsql = "UPDATE `". $roster->db->table('sessions') ."` SET	`session_user_id` = '".$this->uid."', `session_last_visit` = '".time()."', `session_browser` = '', `session_ip` = '".$this->getIP()."', `session_time` = '".(time()+60*15)."',`session_page` = '".nl2br($page)."' WHERE `session_id` = '" . session_id() . "'";
    		$rx = $roster->db->query($xsql);
    		if (!$rx) {
    			$message  = 'Invalid query: ' . mysql_error() . "\n";
    			$message .= 'Whole query: ' . $xsql;
    			die($message);
    		}
    		$roster->db->free_result($rx);
    

    is the update query i free every query result in the script after its used..

  4. so i work on wowroster.net making upgrades to roster

    i have created a user lib for the sit and im now adding sessions but im getten some odd issues....

     

    this is one of the inserts and sent to mysql_query

    example

    UPDATE `roster_sessions` SET 
    `session_user_id` = '0', 
    `session_last_visit` = '1331544818', 
    `session_browser` = '', 
    `session_ip` = '127.0.0.1', 
    `session_time` = '1331545718',
    `session_page` = 'p=guild-main&a=g:1'
    WHERE `session_id` = '6m7js82r848kk2s90sjfmuj325'
    

    YET.. this is what i get in my database

    sql dump from my admin

    INSERT INTO `roster_sessions` (`sess_id`, `session_id`, `session_user_id`, `session_last_visit`, `session_start`, `session_time`, `session_ip`, `session_browser`, `session_forwarded_for`, `session_page`, `session_viewonline`, `session_autologin`, `session_admin`) VALUES
    ('5764d5713a7f24c82b30d271460bf68c', '6m7js82r848kk2s90sjfmuj325', '3', 0, 1331544818, 1331545718, '127.0.0.1', '', '', 'addons-main-images-shadow', 0, 0, 0);
    
    

     

    any clue at all...

     

  5. uploading multiple files is easy on the field name for the files add [] for an array for multiple

     

    this is a function i use in my phpbb download section..

    while(list($key,$value) = each($_FILES[upload_image][name]))
    		{
    			if(!empty($value))
    			{   // this will check if any blank field is entered
    				$filename = $value;    // filename stores the value
    
    				$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
    				$fanme = $dlid . "_" . $filename;
    				//$target_path = "../dlfiles/screens/" . $fanme;
    				$this->setMessage($target_path);
    				$sql = "INSERT INTO `".DL_SS_TABLE."` (`did`, `url`, `uploaded`) VALUES ('" . $dlid . "', '" . $target_url . "','1')";
    				$this->setMessage($sql);
    
    				//*
    				if (move_uploaded_file ( $_FILES ['upload_image'] ['tmp_name'], $target_path )) 
    				{
    					$this->setMessage("The image " . $_FILES ['upload_image'] ['name'] . " has been uploaded");
    
    					$this->makethumb ( $_FILES ['upload_image'] ['name'], $target_path, $id2 );
    
    					$sql = "INSERT INTO `".DL_SS_TABLE."` (`did`, `url`, `uploaded`) VALUES ('" . $dlid . "', '" . $target_path . "','1')";
    					$result = $db->sql_query ( $sql );
    				} 
    				else 
    				{
    					$this->setMessage("Your uploaded was unseccessful");
    					exit ();
    				}
    				//*/
    
    			}
    		}
    

    upload_image is ofcourse the name of my file field on my form i hope this helps..

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.