Advertisement
KuJoe

WHMCS search_ip

Jun 14th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined("WHMCS"))
  4. die("This file cannot be accessed directly");
  5.  
  6. function search_ip_config() {
  7. $configarray = array(
  8. "name" => "Search IP",
  9. "description" => "Search for IPs in WHMCS.",
  10. "version" => "1.0",
  11. "author" => "3rd Party",
  12. "language" => "english"
  13. );
  14. return $configarray;
  15. }
  16.  
  17. function search_ip_activate() {
  18.  
  19. # Return Result
  20. return array('status'=>'success','description'=>'Success!');
  21. return array('status'=>'error','description'=>'Failure!');
  22. return array('status'=>'info','description'=>'Search for IP addresses.');
  23.  
  24. }
  25.  
  26. function search_ip_deactivate() {
  27.  
  28. # Return Result
  29. return array('status'=>'success','description'=>'Success!');
  30. return array('status'=>'error','description'=>'Failure!');
  31. return array('status'=>'info','description'=>'Search for IP addresses.');
  32.  
  33. }
  34.  
  35. function search_ip_output() {
  36. if ($_POST["ip"]) {
  37. foreach ($_POST["ip"] AS $clientid=>$ip) {
  38. $clientid = sanitize($clientid);
  39. $ip = sanitize($ip);
  40. $date = sanitize($date);
  41. }
  42. }
  43. $filtertype = sanitize($_POST["filtertype"]);
  44. $filtervalue = sanitize($_POST["filtervalue"]);
  45. echo '
  46.  
  47. <center><form method="post" action="'.$modulelink.'">
  48. <p align="center">Search for IP Address that <select name="filtertype">
  49. <option';
  50. if ($filtertype=="starts with") { echo ' selected'; }
  51. echo '>starts with</option>
  52. <option';
  53. if ($filtertype=="ends with") { echo ' selected'; }
  54. echo '>ends with</option>
  55. <option';
  56. if ($filtertype=="contains") { echo ' selected'; }
  57. echo '>contains</option>
  58. </select> <input type="text" name="filtervalue" size="30" value="'.$filtervalue.'"> <input type="submit" value="Filter"></p>
  59. <table width="50%" cellspacing="1" bgcolor="#cccccc"><tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>ID</td><td width="120">IP Address</td><td>Last Login</td></tr>
  60. ';
  61.  
  62. if ($filtervalue == NULL){
  63.  
  64. echo '<tr bgcolor="#ffffff"><td colspan="3" align="center">Please start your search.</td></tr>';
  65.  
  66. }else{
  67.  
  68. $clientid="";
  69. $query = "SELECT * FROM tbllogins";
  70. $query.= " WHERE ip";
  71. if ($filtertype=="starts with") {
  72. $query.= " LIKE '$filtervalue%'";
  73. } elseif ($filtertype=="ends with") {
  74. $query.= " LIKE '%$filtervalue'";
  75. } else {
  76. $query.= " LIKE '%$filtervalue%'";
  77. }
  78. $query.= " ORDER BY ip ASC";
  79. $result=mysql_query($query);
  80. while ($data = mysql_fetch_array($result)) {
  81. $clientid = $data["clientid"];
  82. $ip = $data["ip"];
  83. $lastlogin = $data["date"];
  84.  
  85. echo '<tr style="text-align:center;" bgcolor="#ffffff"><td><a href="clientssummary.php?userid='.$clientid.'">'.$clientid.'</a></td><td>'.$ip.'</td><td>'.$lastlogin.'</td></tr>';
  86. }
  87. }
  88. if (!$clientid) {
  89. echo '<tr bgcolor="#ffffff"><td colspan="3" align="center">No Data Found</td></tr>';
  90. }
  91. echo '
  92. </table>
  93. </form><br />
  94. <p>This module allows you to quickly search for IP addresses that may belong to clients.</p>
  95.  
  96. <p><strong>Ported from <a href="http://www.whmcs.com/appstore/52/Search-IP.html">this addon</a> by Joe D. || Requires <a href="http://vpsboard.com/topic/134-whmcs-extended-login-tracking/">this database change</a> to work.</strong></p></center>';
  97. }
  98. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement