Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.30 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. require_once('./includes/config.php'); // global settings/vars
  5. require_once('./includes/skins.php'); // skin parser
  6. require_once('./includes/classes.php'); // main classes
  7.  
  8. $db = new mysqli($CONF['host'], $CONF['user'], $CONF['pass'], $CONF['name']); // connect to mysql db
  9. if ($db->connect_errno) {
  10.     echo "MySQL Error: (". $db->connect_errno .") ".$db->connect_error;
  11. }
  12. $db->set_charset("utf8");
  13.  
  14. $query = (isset($_GET['domain'])) ? $_GET['domain'] : 'onhive.net';
  15. $proxy = (isset($_GET['proxy']) && $_GET['proxy'] != 'local' && $_GET['proxy'] != '') ? $_GET['proxy'] : null;
  16.  
  17. if(isset($_GET['proxies'])) {
  18.  
  19.     $stmt = $db->prepare(sprintf("UPDATE `config` SET `proxies` = '%s'", $db->real_escape_string($_GET['proxies'])));
  20.  
  21.     // Execute the statement
  22.     $stmt->execute();
  23.    
  24. }
  25.  
  26. $data = array();
  27.  
  28. class Whois {
  29.     public $db;
  30.  
  31.     function checkWhois($variate = null) {
  32.         global $data, $query, $proxy;
  33.  
  34.         $domain = explode('.', $query);
  35.         $ex = $domain[(count($domain) - 1)];
  36.  
  37.         switch ($ex) {
  38.  
  39.             case 'br':
  40.  
  41.                     $page = $this->fetchUrl('https://registro.br/cgi-bin/whois/', $proxy, array('qr' => 'minecraft.com.br'));
  42.  
  43.                     $page = substr($page, strpos($page, trim($query).' domain'));
  44.                     $page = strip_tags($page);
  45.                     $page = utf8_encode($page);
  46.  
  47.                 //$data['raw'] = $page;
  48.                 $data['raw'] = $page;
  49.  
  50.                 $page = explode("\n", $page);
  51.  
  52.                 $this->validateRaw($page);
  53.  
  54.             break;
  55.            
  56.             default:
  57.  
  58.                 if($variate == null) {
  59.  
  60.                     $page = $this->fetchUrl('http://whoisdatabase.com/index.php?domain='.trim($query), $proxy);
  61.  
  62.                     $page = substr($page, strpos($page, trim($query).' domain'));
  63.                     $page = strip_tags($page);
  64.                     $page = utf8_encode($page);
  65.  
  66.                 } else {
  67.  
  68.                     $page = $this->fetchUrl('https://whoer.net/whois?host='.trim($query), $proxy);
  69.  
  70.                     $page = json_encode($page);
  71.                     $page = str_replace('<\/span>', ':', $page);
  72.                     $page = json_decode($page);
  73.  
  74.                 }
  75.  
  76.                 //$data['raw'] = $page;
  77.                 $data['raw'] = $page;
  78.  
  79.                 $page = explode("\n", $page);
  80.  
  81.                 $this->validateRaw($page);
  82.  
  83.                 break;
  84.  
  85.         }
  86.  
  87.         // if no contact, variate
  88.         if(!isset($data['contact']) && $variate == 0) {
  89.  
  90.             $this->checkWhois(1);
  91.             $data['refreshed'] = true;
  92.  
  93.         }
  94.  
  95.         //return $page;
  96.  
  97.     }
  98.  
  99.     function everything_in_tags($string, $tagname) {
  100.  
  101.         $pattern = "#<\s*?$tagname\b[^>]*>(.*?)</$tagname\b[^>]*>#s";
  102.         preg_match($pattern, $string, $matches);
  103.         return $matches[1];
  104.  
  105.     }
  106.  
  107.     function validateRaw($output) {
  108.         global $data;
  109.  
  110.         $info = 0;
  111.         $name = null;
  112.  
  113.         foreach ($output as $key => $row) {
  114.  
  115.             if((strpos($row, 'ame:') !== false || strpos($row, 'ome:') !== false || strpos($row, 'person:') !== false)) {
  116.  
  117.                 $name = explode(':', $row);
  118.                 $name = trim($name[1]);
  119.  
  120.             }
  121.  
  122.             if(strpos($row, 'mail:')) {
  123.  
  124.                 if($name != null) {
  125.  
  126.                     $mail = explode(':', $row);
  127.                     $mail = trim($mail[1]);
  128.                     //echo 'Has Mail<br>';
  129.  
  130.                     $data['contacter'][] = array('row' => $row, 'name' => $name, 'email' => $mail);
  131.  
  132.                     $name = null;
  133.  
  134.                 }
  135.                
  136.             }
  137.  
  138.         }
  139.  
  140.         return true;
  141.  
  142.     }
  143.  
  144.     function fetchUrl($url, $proxy = null, $params = null) {
  145.  
  146.         for ($i=0; $i < 5; $i++) {
  147.  
  148.             $ch = curl_init();
  149.             curl_setopt($ch, CURLOPT_URL,$url);
  150.             if($proxy != null) {
  151.                 curl_setopt($ch, CURLOPT_PROXY, $proxy);
  152.             }
  153.             if(is_array($params)) {
  154.                 curl_setopt($ch, CURLOPT_POST, 1);
  155.                 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
  156.                
  157.             }
  158.             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  159.             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  160.             //curl_setopt($ch, CURLOPT_HEADER, 1);
  161.             $curl_scraped_page = curl_exec($ch);
  162.  
  163.             if($curl_scraped_page == '') {
  164.  
  165.                 $page = 'CURL_ERROR';
  166.  
  167.             } else {
  168.  
  169.                 $page = $curl_scraped_page;
  170.                 break;
  171.                
  172.             }
  173.  
  174.         }
  175.  
  176.         curl_close($ch);
  177.         return $page;
  178.  
  179.     }
  180.    
  181. }
  182.  
  183. if(!isset($_POST['send'])) {
  184.  
  185.     $whois = new Whois();
  186.     $whois->db = $db;
  187.     $whois->checkWhois();
  188.  
  189.  
  190.     if(isset($data['contacter'])) {
  191.  
  192.         $data['contact'] = array();
  193.         $lastMail = '';
  194.  
  195.         foreach ($data['contacter'] as $key => $row) {
  196.  
  197.             if($row['email'] != $lastMail) {
  198.  
  199.                 $data['contact'][] = $data['contacter'][$key];
  200.                 $lastMail = $row['email'];
  201.  
  202.             }
  203.  
  204.         }
  205.        
  206.     }
  207.  
  208.     $data['error'] = false;
  209.  
  210.     echo json_encode($data);
  211.  
  212. } else {
  213.  
  214.     if(isset($_POST['data']) && isset($_POST['message']) && isset($_POST['title'])) {
  215.  
  216.         $data = explode('; ', $_POST['data']);
  217.         $header = explode('; ', $_POST['header']);
  218.  
  219.         require './vendor/phpmailer/phpmailer/PHPMailerAutoload.php';
  220.  
  221.         $mail = new PHPMailer;
  222.  
  223.         $message = $_POST['message'];
  224.         $user = array();
  225.  
  226.         foreach ($header as $key => $param) {
  227.            
  228.             $user[str_replace(array('<', '>'), '', $param)] = $data[$key];
  229.  
  230.         }
  231.  
  232.         foreach ($header as $key => $param) {
  233.            
  234.             $message = str_replace($param, $data[$key], $message);
  235.  
  236.         }
  237.  
  238.         $title = $_POST['title'];
  239.  
  240.         foreach ($header as $key => $param) {
  241.            
  242.             $title = str_replace($param, $data[$key], $title);
  243.  
  244.         }
  245.  
  246.  
  247.         $mail->isSMTP();                                      // Set mailer to use SMTP
  248.         $mail->Host = $CONF['smtp_host'];                     // Specify main and backup SMTP servers
  249.         $mail->SMTPAuth = true;                               // Enable SMTP authentication
  250.         $mail->Username = $CONF['smtp_user'];                 // SMTP username
  251.         $mail->Password = $CONF['smtp_pass'];                           // SMTP password
  252.         $mail->SMTPSecure = $CONF['smtp_ssl'];                            // Enable TLS encryption, `ssl` also accepted
  253.         $mail->Port = $CONF['smtp_port'];                                    // TCP port to connect to
  254.         $mail->CharSet = 'UTF-8';
  255.  
  256.         $mail->setFrom($_POST['from']);
  257.  
  258.         $mail->addAddress($user['e-mail'], $user['nome']);     // Add a recipient
  259.  
  260.         $mail->Subject = $title;
  261.         $mail->Body    = $message;
  262.  
  263.         if(!$mail->send()) {
  264.             echo json_encode(array('error' => $mail->ErrorInfo, 'domain' => $user['dominio'], 'status' => $mail->ErrorInfo));
  265.         } else {
  266.             echo json_encode(array('error' => false, 'domain' => $user['dominio'], 'status' => 'Sucesso'));
  267.         }
  268.    
  269.         //echo $message;
  270.  
  271.     }
  272.    
  273. }
  274.  
  275.  
  276. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement