Jump to content

woody79

Members
  • Posts

    58
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

woody79's Achievements

Member

Member (2/5)

0

Reputation

  1. I performed that little test and the session id shows all the time.
  2. Sorry about that I took that code out of my archive and modified it a bit. There is actually two class files: maxlogin.4.php and maxlogin.5.php. The php4 class just has var instead of private and public plus MaxLogin instead of __construct.
  3. I have a page that sets a two sessions and one that reads them. The page that reads them looks like this: <?php session_start(); if (isset($_SESSION['maxauth'])) { print_r(unserialize($_SESSION['maxinfo'])); } else { echo "No"; } ?> When I refresh the page it sometimes gives me print_r(unserialize($_SESSION['maxinfo'])); , but otherwise No. I have refreshed the page 10 times and 2 times out of 10 the session was recognized. My dev server (Windows-PHP5) gets 10 out of 10, but my actual host (Unix-PHP4) gets 2 out of 10. Why is this?
  4. By the way it works fine on my dev machine running Apache 2.2.9 and PHP 5.2.6, but on my actual hosting server it doesn't which is running Apache 1.3.33 and PHP 4.3.10. Does this mean that I will have to write my login class again?
  5. I have a login that when the user enters details they are redirected to a page that checks if they are logged in and if not sends them to the login page. After you login (that is if it accepts you) the main page is readable, but if you refresh the page you are sent back to the login. It's as if the session is lost. There is also an error where when you login you end up back at the login. Am I doing something wrong? If so what is it and how can I fix it? Login Class: <?php class MaxLogin { public $authrealm = "Welcome"; private $authtype; private $mysqlhost; private $mysqluser; private $mysqlpass; private $mysqldata; private $maxid; private $maxfname; private $maxsurname; private $maxusr; private $maxpwd; private $maxip; private $maxemail; private $maxprivileges; function __construct($authtype = "web", $mysqlhost = "localhost", $mysqluser = "root", $mysqlpass, $mysqldata) { $this->authtype = $authtype; $this->mysqlhost = $mysqlhost; $this->mysqluser = $mysqluser; $this->mysqlpass = $mysqlpass; $this->mysqldata = $mysqldata; mysql_connect($mysqlhost, $mysqluser, $mysqlpass) or die('Could not connect: ' . mysql_error()); mysql_select_db($mysqldata) or die('Could not select database: ' . mysql_error()); session_start(); } function __get($property) { return $this->$property; } function isNotLoggedIn() { if(!isset($_SESSION['maxauth'])) { return 1; } else { return 0; } } function checkLogin($maxuser = "maxgrade-username", $maxpass = "maxgrade-password") { if ($this->authtype == "web") { if (!isset($_POST[$maxuser]) || !isset($_POST[$maxpass])) { return 0; } else { $maxsql = "SELECT * FROM users WHERE "; $maxsql .= "(username = '" . addslashes($_POST[$maxuser]) . "') "; $maxsql .= "AND "; $maxsql .= "(password = '" . addslashes($_POST[$maxpass]) . "')"; $maxquery = mysql_query($maxsql); $maxnumrows = mysql_num_rows($maxquery); if ($maxnumrows > 0) { while($maxrow = mysql_fetch_assoc($maxquery)) { $_SESSION['maxauth'] = $maxrow['id']; $_SESSION['maxinfo'] = serialize( array( "id" => $maxrow['id'], "fname" => $maxrow['fname'], "surname" => $maxrow['surname'], "username" => $maxrow['username'], "password" => $maxrow['password'], "ip" => $_SERVER['REMOTE_ADDR'], "email" => $maxrow['email'], "privileges" => $maxrow['privileges'] ) ); $this->maxid = $maxrow['id']; $this->maxfname = $maxrow['fname']; $this->maxsurname = $maxrow['surname']; $this->maxusr = $maxrow['username']; $this->maxpwd = $maxrow['password']; $this->maxip = $_SERVER['REMOTE_ADDR']; $this->maxemail = $maxrow['email']; $this->maxprivileges = $maxrow['privileges']; mysql_query("UPDATE users SET ip='" . $_SERVER['REMOTE_ADDR'] . "' WHERE id='" . $maxrow['id'] . "'"); return 1; } } else { return 0; } } } else if ($this->authtype == "realm") { if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="' . $this->authrealm . '"'); return 0; } else { $maxsql = "SELECT * FROM users WHERE "; $maxsql .= "(username = '" . addslashes($_SERVER['PHP_AUTH_USER']) . "') "; $maxsql .= "AND "; $maxsql .= "(password = '" . addslashes($_SERVER['PHP_AUTH_PW']) . "')"; $maxquery = mysql_query($maxsql); $maxnumrows = mysql_num_rows($maxquery); if ($maxnumrows > 0) { while($maxrow = mysql_fetch_assoc($maxquery)) { $_SESSION['maxauth'] = $maxrow['id']; $_SESSION['maxinfo'] = serialize( array( "id" => $maxrow['id'], "fname" => $maxrow['fname'], "surname" => $maxrow['surname'], "username" => $maxrow['username'], "password" => $maxrow['password'], "ip" => $_SERVER['REMOTE_ADDR'], "email" => $maxrow['email'], "privileges" => $maxrow['privileges'] ) ); $this->maxid = $maxrow['id']; $this->maxfname = $maxrow['fname']; $this->maxsurname = $maxrow['surname']; $this->maxusr = $maxrow['username']; $this->maxpwd = $maxrow['password']; $this->maxip = $_SERVER['REMOTE_ADDR']; $this->maxemail = $maxrow['email']; $this->maxprivileges = $maxrow['privileges']; mysql_query("UPDATE users SET ip='" . $_SERVER['REMOTE_ADDR'] . "' WHERE id='" . $maxrow['id'] . "'"); return 1; } } else { header('WWW-Authenticate: Basic realm="' . $this->authrealm . '"'); return 0; } } } } function destroyLogin() { session_destroy(); } } ?> index.php (login): include("./maxgrade_includes/maxlogin.5.php"); $login = new MaxLogin("web", "localhost", "root", "", "sitedb"); if (isset($_GET['action'])) { if ($_GET['action'] == "signout") { $login->destroyLogin(); header("Location: index.php"); } } else if ($login->checkLogin("maxgrade-username", "maxgrade-password")) { header("Location: main.php"); } main.php: include("./maxgrade_includes/maxlogin.5.php"); $login = new MaxLogin("web", "localhost", "root", "", "sitedb"); if ($login->isNotLoggedIn()) { header("Location: index.php"); }
  6. What I meant by: Was that I have a "lightbox" that appears when somebody using IE6 opens the page and offers something like
  7. Personally I don't because I believe that if they haven't updated there web browser there internet viewing privileges should be revoked. PS. Whilst writing this I thought about checking the User Agent String for IE6 and then denying access.
  8. Personally I prefer PHP because I don't want to specify void, static, integer, string, boolean, decimal, float or any others.
  9. I have this world map(attached) that php loads and crops it down to 320x240 and the x and y coordinates can be changed. When the x or y coordinates go out side the picture i would like it to wrap around. at the moment i am only concentratring on the x coordinate. i can't get the wrap around part to work correctly. Help would be greatly appreciated. map.php <?php // The file $filename = 'world32k.jpg'; $percent = 0.5; // Content type header('Content-type: image/jpeg'); //create $image_p = imagecreatetruecolor(320, 240); $image_q = imagecreatetruecolor(320, 240); $white = imagecolorallocate($image_q, 255, 255, 255); imagefill($image_q, 0, 0, $white); $image = imagecreatefromjpeg($filename); //mask var list($width, $height) = getimagesize($filename); $x = 1100; $y = 350; if(($width-($x+320)) < 0) { imagecopyresampled($image_p, $image, 0, 0, $x, $y, 320, 240, 320, 240); imagecopyresampled($image_q, $image, 0, 0, (($width-($x+320))*2), $y, 320, 240, 320, 240); imagecopymerge($image_p, $image_q, 110, 0, 0, 0, 320, 240, 100); //imagejpeg($image_p, null, 100); imagejpeg($image_p, null, 100); } //mask //imagecopyresampled($image_p, $image, 0, 0, 1100, 350, 320, 240, 320, 240); // Output //imagejpeg($image_p, null, 100); ?> [attachment deleted by admin]
  10. I am creating a project and part of it is that it takes videos from the web using this format: http://cache.googlevideo.com/get_video?video_id= I am still trying to work out how to make php download this file to a directory. I was wondering if antbody could help me out with this problem?
  11. i have a feeling it is with the mktime
  12. Would anybody know where i have gone wrong in this script? $tm7781=date ("d:m:Y H:i:s", mktime (date("H"),date("i"),date("s"),date("m"),date("d")-1,date("Y"))); mysql_query("DELETE FROM tracker WHERE endsession < '$tm7781'");
  13. How do i preg_match a single space
  14. function weddingser() { document.getElementById('bar').style.backgroundImage = "url(images/logo20.png)"; } Anyone know why the image does not change
  15. Apologies to wildteen, you were talking about the first $trackid and i thought you meant the sceond one. Thank you everyone
×
×
  • 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.