Share Pastebin
Guest
Public paste!

Flippz

By: a guest | Feb 9th, 2010 | Syntax: None | Size: 1.28 KB | Hits: 38 | Expires: Never
Copy text to clipboard
  1. <?php
  2. /* ###########################################################
  3.  * File brought to you by kkz
  4.  * There are big ships
  5.  * There are small ships
  6.  * but the best ship
  7.  * is friendship!
  8.  * Sharing is caring... please pass this along but leave this
  9.   ##############################################################*/
  10. $userId=$_REQUEST["userId"];
  11.  
  12. include('config.inc.php');
  13. include('database.inc.php');
  14. $randomUserId=0;
  15.  
  16. $result      =mysql_query("SELECT * FROM chats WHERE userId = $userId ");
  17.  
  18. while ($row=mysql_fetch_array($result))
  19.     {
  20.     $randomUserId=$row["randomUserId"];
  21.     }
  22.  
  23. if ($randomUserId == 0)
  24.     {
  25.     $result=mysql_query("SELECT * FROM users WHERE id <> $userId AND inchat like 'N' ORDER BY RAND() LIMIT 1");
  26.  
  27.     while ($row=mysql_fetch_array($result))
  28.         {
  29.         $randomUserId=$row["id"];
  30.         }
  31.  
  32.     if ($randomUserId != 0)
  33.         {
  34.         mysql_query("INSERT INTO chats (userId,randomUserId) values($userId, $randomUserId) ");
  35.         mysql_query("INSERT INTO chats (userId,randomUserId) values($randomUserId, $userId) ");
  36.  
  37.         mysql_query("UPDATE users SET inchat='Y' WHERE id = $userId ");
  38.         mysql_query("UPDATE users SET inchat='Y' WHERE id = $randomUserId ");
  39.         }
  40.     }
  41.  
  42. echo $randomUserId;
  43. mysql_close($con);
  44. ?>