Guest User

Untitled

a guest
Jul 3rd, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <?php
  2. $username="not doing";
  3. $password="that again.";
  4. $database="heh...";
  5.  
  6. mysql_connect("localhost:/tmp/mysql5.sock",$username,$password);
  7. @mysql_select_db($database) or die ("Unable to connect to database");
  8.  
  9. $query="SELECT * FROM soi_voting ORDER BY Time_Voted";
  10. $result=mysql_query($query);
  11.  
  12. if ( !$result ) {
  13. die('Could not query:' . mysql_error());
  14. }
  15.  
  16. $num = mysql_numrows($result);
  17.  
  18. $visitor_ip=@$REMOTE_ADDR;
  19.  
  20. $now = time();
  21.  
  22. $found = False;
  23. for ( $i = 0; $i < $num; $i++){
  24. if ( mysql_result($result, $i, "IP") == $visitor_ip){
  25. $found = True;
  26. $update_query="UPDATE soi_voting SET Time_Voted = ".$now." WHERE IP = '".$visitor_ip."'";
  27. mysql_query($update_query);
  28. }
  29. }
  30. if ($found = False){
  31. $insert_query = "INSERT INTO soi_voting VALUES(\"" . $visitor_ip . "\"" . "," . $now . ")";
  32. mysql_query($insert_query);
  33. }
  34. ?>
Add Comment
Please, Sign In to add comment