Advertisement
Guest User

Untitled

a guest
May 4th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. function PreSearch($nick,$chan,$arg){
  2. //DB creds
  3. $dbHost = '***';
  4. $dbUser = '***';
  5. $dbPass = '***';
  6. $dbDatabase = '***';
  7. $dbTable = '***';
  8.  
  9. $link = mysql_connect($dbHost, $dbUser, $dbPass) or die("Failed to connect to MySQL Server. Error: " . mysql_error());
  10. mysql_select_db($dbDatabase) or die("Failed to connect to database {$dbDatabase}. Error: " . mysql_error());
  11.  
  12. $get_id = "select id FROM predb WHERE rlsname LIKE '%{$arg}%' ORDER BY FROM_UNIXTIME(ctime) DESC LIMIT 1";
  13.  
  14. $query_id = mysql_query($get_id);
  15. $result_id = mysql_result($query_id,id);
  16.  
  17. if ($result_id == NULL) {
  18. send("PRIVMSG",$chan,"[b][c]2,0PRE[b][c] Result [c]12,0::[c] Nothing found...\n");
  19. }
  20. else {
  21.  
  22. $get = "select FROM_UNIXTIME(ctime) FROM predb WHERE id =".$result_id." ORDER BY FROM_UNIXTIME(ctime) DESC LIMIT 1";
  23. $get2 = "select rlsname FROM predb WHERE id =".$result_id." ORDER BY FROM_UNIXTIME(ctime) DESC LIMIT 1";
  24. $get3 = "select section FROM predb WHERE id =".$result_id." ORDER BY FROM_UNIXTIME(ctime) DESC LIMIT 1";
  25. $get4 = "select size FROM predb WHERE id =".$result_id." ORDER BY FROM_UNIXTIME(ctime) DESC LIMIT 1";
  26. $get5 = "select files FROM predb WHERE id =".$result_id." ORDER BY FROM_UNIXTIME(ctime) DESC LIMIT 1";
  27.  
  28. $query = mysql_query($get);
  29. $query2 = mysql_query($get2);
  30. $query3 = mysql_query($get3);
  31. $query4 = mysql_query($get4);
  32. $query5 = mysql_query($get5);
  33.  
  34. $result = mysql_result($query,id);
  35. $result2 = mysql_result($query2,id);
  36. $result3 = mysql_result($query3,id);
  37. $result4 = mysql_result($query4,id);
  38. $result5 = mysql_result($query5,id);
  39.  
  40. $time = duration_time($result);
  41.  
  42. if( ($result == NULL) || ($result2 == NULL) || ($result3 == NULL) ) {
  43. send("PRIVMSG",$chan,"[b][c]2,0PRE[b][c] Result [c]12,0::[c] Nothing found...\n");
  44. }
  45. elseif ( ($result5 == NULL) && ($result4 == NULL) ) {
  46. send("PRIVMSG",$chan,"[b][c]2,0PRE[b][c] Result [c]12,0::[c] $result2 pre'd in $result3 $time ago. [b][c]12,0[[c][b] $result [b][c]12,0][b][c]\n");
  47. }
  48. elseif ( ($result5 == NULL) && ($result4 != NULL ) ) {
  49. send("PRIVMSG",$chan,"[b][c]2,0PRE[b][c] Result [c]12,0::[c] $result2 pre'd in $result3 $time ago. [b][c]12,0[[c][b] $result [b][c]12,0][b][c] [b][c]12,0[[c][b] $result4 MB [b][c]12,0][b][c]\n");
  50. }
  51. elseif ( ($result5 != NULL) && ($result4 == NULL ) ) {
  52. send("PRIVMSG",$chan,"[b][c]2,0PRE[b][c] Result [c]12,0::[c] $result2 pre'd in $result3 $time ago. [b][c]12,0[[c][b] $result [b][c]12,0][b][c] [b][c]12,0[[c][b] $result5 Files [b][c]12,0][b][c]\n");
  53. }
  54. else {
  55. send("PRIVMSG",$chan,"[b][c]2,0PRE[b][c] Result [c]12,0::[c] $result2 pre'd in $result3 $time ago. [b][c]12,0[[c][b] $result [b][c]12,0][b][c] [b][c]12,0[[c][b] $result4 MB in $result5 files. [b][c]12,0][b][c]\n");
  56. }
  57. }
  58.  
  59. mysql_close($link);
  60. }
  61.  
  62.  
  63.  
  64. //////////////// how it's passed
  65.  
  66. if($word[0] == ".pre") {
  67. if($chan == "#pre.admin") {
  68. PreSearch($nick,$chan,$word[1]);
  69. }
  70. elseif($chan == "#pre.search") {
  71. PreSearch($nick,$chan,$word[1]);
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement