SHARE
TWEET

Untitled

a guest Jun 5th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function GetLicense($userid, $product)
  4. {
  5. $server = 'localhost';
  6. $username = 'villaxxxxxxx';
  7. $password = 'xxxxxxxxxxxx';
  8. $database = 'xxxxxxxxxxxx';
  9.  
  10.    
  11.     $con = mysql_connect($server,$username,$password);
  12.     mysql_select_db($database, $con);
  13.  
  14.     /*
  15.     First check to see if the user has a license already
  16.     */
  17.  
  18.     $command = "SELECT Licence_No FROM vill_licences WHERE UserID=$userid and Application_No='$product' limit 1";
  19.     $result = mysql_query($command);
  20.  
  21.     if(mysql_num_rows($result) == 0)
  22.     {
  23.         /*
  24.         Next check if there are any licenses available
  25.         */
  26.         $command2 = "SELECT Licence_No FROM vill_licences WHERE UserID IS NULL AND Application_No='$product' limit 1";
  27.         $result = mysql_query($command2);
  28.         if(mysql_num_rows($result) > 0)
  29.         {
  30.             /*
  31.             set an unassigned code
  32.             */
  33.             $command1 = "UPDATE vill_licences SET UserID = $userid WHERE Licence_No  =(SELECT Licence_No FROM (select Licence_No from vill_licences WHERE UserID IS NULL AND Application_No='$product' limit 1) AS temp)";
  34.             $result = mysql_query($command1);
  35.         }
  36.         else
  37.         {
  38.             return "No License's available for this product.";
  39.         }
  40.     }
  41.     /*
  42.     Return code
  43.     */
  44.     $result = mysql_query($command);
  45.     return mysql_result($result,0);
  46.  
  47. }
  48.  
  49. function GetRemainingWS()
  50. {
  51. $server = 'localhost';
  52. $username = 'xxxxxxxxx';
  53. $password = 'jxxxxxxxxxxxxxxxxxx';
  54. $database = 'xxxxxxxxxxxxxxxx';
  55.  
  56.    
  57.     $con = mysql_connect($server,$username,$password);
  58.     mysql_select_db($database, $con);
  59.  
  60.     /*
  61.     First check to see if the user has a license already
  62.     */
  63.  
  64.     $command = "SELECT count(*) FROM vill_licences WHERE UserID IS NULL";
  65.     $result = mysql_query($command);
  66.  
  67.     return mysql_result($result,0);
  68.  
  69. }
  70.  
  71. function RetreiveLicense($userid, $product)
  72. {
  73. $server = 'localhost';
  74. $username = 'xxxxxxxxxxx';
  75. $password = 'xxxxxxxxxxxxxxxxxxx';
  76. $database = 'xxxxxxxxxxxxxxxx';
  77.     $con = mysql_connect($server,$username,$password);
  78.     mysql_select_db($database, $con);
  79.  
  80.    
  81.     $command = "SELECT Licence_No FROM vill_licences WHERE UserID=$userid and Application_No='$product' limit 1";
  82.     $result = mysql_query($command);
  83.     if(mysql_num_rows($result) == 0)
  84.         return "";
  85.     else
  86.         mysql_result($result,0);
  87. }
  88.  
  89.  
  90. /*
  91.     below is for sample make sure you sanatize the inputs so users cant fiddle with it
  92.  
  93. echo GetLicense($_GET['u'], 'WS')."\n";
  94.  
  95. echo "There are ".GetRemainingWS()." licences remaining";
  96. */
  97.  
  98. echo RetreiveLicense($_GET['u'], 'WS');
  99. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top