Jump to content

Lamez

Members
  • Posts

    1,686
  • Joined

  • Last visited

    Never

Everything posted by Lamez

  1. I wonder how they know...
  2. See I did that, and it did not turn out the way I wanted, but maybe it is my code structure. What I am doing is making a login script to force users to login to use my internet via HTTP requests. I think I am going to rewrite it for the third time here is what I have so far: <?php include('gatewayLogin.php'); ob_start(); session_start(); echo '<title>My Internets</title>'; function checkHost($host){ $q = mysql_query("SELECT * FROM allowed_host WHERE hostname = '$host'"); $n = mysql_num_rows($q); if($n > 0){ if(justDay <= (justDay()+5)){ return true; }else{ removeHost($host); return false; } }else{ return false; } } function allowHost($host){ if(!checkHost($host)){ $date = justDay(); $time = currentTime(); mysql_query("INSERT INTO allowed_host (hostname, date, time) VALUES ('$host', '$date', '$time')"); $_SESSION['allow'] = $host; } } function removeHost($host){ if(checkHost($host)){ mysql_query("DELETE FROM allowed_host WHERE hostname = '$host'"); } } function getPassword(){ $q = mysql_query("SELECT password FROM password"); $n = mysql_num_rows($q); if($n > 0){ $f = mysql_fetch_array($q); return $f['password']; } } function justDay(){ return date("j"); } function currentDate(){ return date("M j Y"); } function currentTime(){ return date("g:i a"); } function logInfo($host, $value){ $date = currentDate(); $time = currentTime(); mysql_query("INSERT INTO logs (hostname, date, time, value) VALUES ('$host', '$date', '$time', '$value')"); } $host = $_SERVER['REMOTE_ADDR']; if($_GET['cmd'] == "check"){ if(md5($_POST['password']) === md5(getPassword())){ allowHost($host); header("Location: ?"); }else{ if(isset($_SESSION['failLimit']) && $_SESSION['failLimit'] >= 5){ logInfo($host, "Reached Fail Limit"); header("Location: ?cmd=limit"); }else if(isset($_SESSION['failLimit'])){ $_SESSION['failLimit']++; }else{ $_SESSION['failLimit'] = 0; } logInfo($host, "Incorrect Password"); header("Location: ?show=fail"); } }else if($_GET['cmd'] == "limit"){ echo '<font color="red">You have reached the limit on incorrect passwords, try again later!</font>'; }else if($_GET['cmd'] == 8675309){ unset($_SESSION['failLimit']); unset($_SESSION['allow']); header("Location: ?"); }else{ if(isset($_SESSION['allow']) && $_SESSION['allow'] == $host){ header("Location: http://www.google.com"); }else{ if($_GET['show'] == "fail"){ echo '<font color="red">The password you entered is incorrect.</font>'; } if(checkHost($host)){ if(isset($_GET['url'])){ header("Location: http//".$_GET['url']); }else{ header("Location: http://www.google.com"); } }else{ echo ' <form action="?cmd=check" method="post" />Enter Password: <input type="password"" name="password" /><input type="submit" name="submit" value="Login" /></form>'; } } } echo "<br /><i>".currentDate()."</i> - <i>".currentTime()."</i>"; ?>
  3. Is there a way to see what the last page the user requested? Say I go to the phpfreaks website, then I go to my script, and my script displays: phpfreaks.com or phpfreaks.com/forums/index.php?action=post. Thanks!
  4. Looks great!
  5. Lamez

    very strange

    :'( :-\ :suicide:
  6. no do it like this <?php $userInfo = array('username' => $a1['username'], 'password' = $a1['password']); echo $userInfo['username']; ?>
  7. Thanks for the (not needed) help, I guess I had a brainfart (again), here is how I fixed it: <?php function makeSportList($sportList, $name = ""){ $list = '<select name="sport" id="sport">'; $list .= '<option value="-1">All Sports</option>'; for ($i=0;$i<=count($sportList);$i++){ if(md5(strtolower($name)) === md5(strtolower($sportList[$i]))){ $sel = "SELECTED"; }else{ $sel = ""; } $list .= '<option value="'.$sportList[$i].'" '.$sel.'>'.$sportList[$i].'</option>'; } return $list.'</select>'; } echo makeSportList($sport_list); echo "<br />"; echo makeSportList($sport_list, "football"); ?>
  8. Like I mention, I think I mentioned, that returns a error: Its the $foo = $bar. Wait, I think I figured out how do this.
  9. I am working on a function that makes a list out of an existing array, this website was pre-made, and I cannot locate the list for the life of me. How can I make a default value in function based off of a variable? <?php function makeSportList($name = "", $sportList = $sport_list){ $list = '<select name="sport" id="sport">'; $list .= '<option value="-1">All Sports</option>'; for ($i=0;$i<=count($sportList);$i++){ if(md5(strtolower($name)) == md5(strtolower($sportList[$i]))){ $sel = "SELECTED"; }else{ $sel = ""; } $list .= '<option value="'.$sportList[$i].'" '.$sel.'>'.$sportList[$i].'</option>'; } return $list.'</select>'; } ?> The manual says nothing of this. :/ -thanks!
  10. You are trying to learn PHP and MySQL? Take a look here: http://www.tizag.com/phpT/ http://www.tizag.com/mysqlTutorial/ Reference: http://www.php.net http://www.php.net/manual/en/index.php http://www.php.net/docs.php These are the things that helped me the most, I am still learning. I am about to start learning classes. The biggest thing that helped me was trial and error. Oh and phpfreaks. Take a look at my posts in my profile, over half of them are php and mysql questions.
  11. after thinking about it, I most likely did not help you out at all. Sorry.
  12. Here is a XML write, I wrote for a ticker feed. It displayed scores and team names, along with the date and type of sport. Maybe you can edit it to suit your needs. Also remember to give it 0777 permission <?php //Re-Written to show only rows with ticker set = 1 or whatever is in manual_ticker $db_host = '?'; # The host of your server, normally localhost $db_user = '?'; # The user name you use to connect to the server $db_pass = '?'; # The password you use to connect $db_name = '?'; # The name of a database $fileName = "ticker/data.xml"; # The name of the XML file for the test2.swf $dbh = mysql_connect ($db_host, $db_user, $db_pass) or die (mysql_error()); mysql_select_db ($db_name); function findTeam($id){ $q = mysql_query("SELECT name FROM schools WHERE id = '$id'"); if(mysql_num_rows($q) > 0){ $f = mysql_fetch_array($q); return checkName($f['name']); }else{ return checkName("Unknown Name"); } } function checkName($name){ if(strlen($name) > 12){ return substr($name, 0, 12); }else{ return $name; } } function noGameInfo(){ $Info = "<item>\n"; $Info .= "<team1>None</team1>\n"; $Info .= "<team2>None</team2>\n"; $Info .= "<score1>NA</score1>\n"; $Info .= "<score2>NA</score2>\n"; $Info .= "<date>NA</date>\n"; $Info .= "<sport>No Games to Display.</sport>\n"; $Info .= "</item>\n"; return $Info; } function checkItem($item){ if(empty($item) || !isset($item) || $item == null || $item == NULL && $item != 0){ return "NA"; }else{ return $item; } } $fileInfo = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" charset=\"us-ascii\" ?>"; $fileInfo = "<images>\n"; $q = mysql_query("SELECT * FROM games WHERE ticker = '1'"); $n = mysql_num_rows($q); $q2 = mysql_query("SELECT * FROM manual_ticker"); $n2 = mysql_num_rows($q2); if($n > 0 || $n2 > 0){ if($n > 0){ while($f = mysql_fetch_array($q)){ $fileInfo .= "<item>\n"; $fileInfo .= "<team1>".findTeam($f['hsid'])."</team1>\n"; $fileInfo .= "<team2>".findTeam($f['vsid'])."</team2>\n"; $fileInfo .= "<score1>".checkItem($f['homescore'])."</score1>\n"; $fileInfo .= "<score2>".checkItem($f['visitorscore'])."</score2>\n"; $fileInfo .= "<date>".checkItem($f['date'])."</date>\n"; $fileInfo .= "<sport>".checkItem($f['sport'])."</sport>\n"; $fileInfo .= "</item>\n"; } } if($n2 > 0){ while($f = mysql_fetch_array($q2)){ $fileInfo .= "<item>\n"; $fileInfo .= "<team1>".findTeam($f['team1'])."</team1>\n"; $fileInfo .= "<team2>".findTeam($f['team2'])."</team2>\n"; $fileInfo .= "<score1>".checkItem($f['score1'])."</score1>\n"; $fileInfo .= "<score2>".checkItem($f['score2'])."</score2>\n"; $fileInfo .= "<date>".checkItem($f['date'])."</date>\n"; $fileInfo .= "<sport>".checkItem($f['sport'])."</sport>\n"; $fileInfo .= "</item>\n"; } } }else{ $fileInfo .= noGameInfo(); } $fileInfo .= '</images>'; $fileHandle = fopen($fileName, 'w') or die("Error Reading File: ".$fileName); fwrite($fileHandle, $fileInfo); fclose($fileHandle); ?>
  13. Lamez

    very strange

    That is the best thing I have ever seen. Lets hope we get quantum computing down before the sun explodes.
  14. Lamez

    very strange

    I notice you said integer. You can use a long integer? http://en.wikipedia.org/wiki/Long_integer
  15. Lamez

    very strange

    I am talking about Y2K. What was the big deal in 1969?
  16. One word: AJAX. I bet you can find some sorta pre-made script that watches the DB and 'pushes' the new info when it is added\changed.
  17. I consider my self semi-advanced, drifting from the noob stage. I know more PHP than I do SQL, so if the code could be condense, I am all for it. Could you explain your query to me a little more? What is this timestamp + 300?, what is this now(), is it like time()? -Thanks!
  18. Lamez

    very strange

    Yep CV is. So why was the roll-over from '69 to '70 a big deal? Was it like from '99 to '00?
  19. Back, again, So I have this function to check users if they are inactive for a certain length of time, then it marks them as offline, and vise-versa (did I spell that right?). The problem is it is marking everyone as offline! I checked the logic, and the queries. It all checks out. I do not grasp the complete concept of the time() function, other than it produces some sorta time stamp. From my understanding, it is in seconds. So to get a 5 minuets ahead you would do: time()+(5*60); Right? Well any who, here is my function: <?php //Note: The echos are for debuggin' purposes function checkStaleUsers($checkInt, $idleTime){ $time = time(); if(!isset($_SESSION['~serverTimeCheck'])){ $_SESSION['~serverTimeCheck'] = time()+($checkInt*60); } if(time() >= $_SESSION['~serverTimeCheck']){ unset($_SESSION['~serverTimeCheck']); $q = mysql_query("SELECT * FROM ".TBL_PEOPLE." WHERE timestamp > '0' AND activated = '1' AND ban = '0'"); $n = mysql_num_rows($q); if($n > 0){ while($f = mysql_fetch_array($q)){ if($f['timestamp'] <= $time+($idleTime*60) && $f['online'] == 1){ mysql_query("UPDATE ".TBL_PEOPLE." SET online = '0' WHERE id = '".$f['id']."'"); echo "SET OFFLINE FOR: ".$f['email']."<BR>"; }else if($f['timestamp'] >= $time+($idleTime*60) && $f['online'] == 0){ mysql_query("UDPATE ".TBL_PEOPLE." SET online = '1' WHERE id = '".$f['id']."'"); echo "SET ONLINE FOR: ".$f['email']."<BR>"; }else{ echo $f['online']; echo "<BR>"; echo $f['email']; echo "<BR>"; echo $f['timestamp']; echo "<BR>"; echo $time; echo "<HR>"; } } } } } checkStaleUsers(5, 10); //Check every five minuets for users that are idle for ten minuets or more. ?> -Thanks, again.
  20. Lamez

    very strange

    Well dang it, lets just say its an easter egg.
  21. You can make a decent website without a lot of images. CSS allows a lot of really neat stuff. Take a look at my site (http://www.lamezz.com), I am not the best at making websites, but do you notice something? There is a total of 5 images on the index. The background, the logo, the user avatar, the site statistics icon and the newest member icon. I would try making your website more updated using Web 2.0 concepts. http://www.webdesignfromscratch.com/web-design/web-2.0-design-style-guide.php Hoped I helped.
  22. Lamez

    very strange

    I am talking about that. I found that very strange. I wonder if is a easter egg of sorts?
  23. I was bored this morning, I started to mess around on the website, then I found this: (The image was too big, here is a direct link) http://uploads.lamezz.com/what.jpg
  24. okay so I did some updates. You can now resend confirmation emails and forgot password emails up to a limit of five times before getting a error. The website loads now in IE, the problem was due to a time check function that left it in a loop. I did some other subtle changes, but I have forgotten them. -Thanks!
  25. The database is not installed? Not sure, maybe it has something to do with that p in mysql_pconnect()
×
×
  • 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.