Advertisement
zenware

Here

Oct 14th, 2012
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2.    
  3.     //Usually this would be in a seperate "require('config.php');" for organization, but meh...
  4.     $db['host'] = "whateverhost";
  5.     $db['name'] = "whatevername";
  6.     $db['user'] = "whateveruser";
  7.     $db['pass'] = "whateverpass";
  8.  
  9.  
  10.     $mysqli = new mysqli($db['host'], $db['user'], $db['pass'], $db['name']);
  11.  
  12.         if ($mysqli->connect_error) {
  13.             die('Connect Error (' . $mysqli->connect_errno . ') '
  14.                     . $mysqli->connect_error);
  15.     /**
  16.     * Usage:
  17.     * getDomain();
  18.     * returns "example.com" ... "othersite.com" ... etc and insterts directly to a database
  19.     *
  20.     */
  21.     function getDomain()
  22.     {
  23.  
  24.         $content = file_get_contents('http://mailinator.com/randomdomain.jsp');
  25.         $pattern = '^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}$';
  26.  
  27.         preg_match($pattern, $content, $match);
  28.         $domain = $match[1];
  29.  
  30.         $query = "SELECT FROM `tablename` WHERE domain='$domain'";
  31.         $results = $mysqli->query($query);
  32.  
  33.         while($results) //This is me trying to figure out how to do a thing
  34.         {
  35.             $content = file_get_contents('http://mailinator.com/randomdomain.jsp');
  36.  
  37.             preg_match($pattern, $content, $match);
  38.             $domain = $match[1];
  39.  
  40.             $query = "SELECT FROM `tablename` WHERE domain='$domain'";
  41.             $results = $mysqli->query($query);
  42.         }
  43.  
  44.         $query = "INSERT INTO `tablename` (domain) VALUES ('$domain')" //This needs to be modified
  45.         $results = $mysqli->query($query);
  46.         $results->free();
  47.         $mysqli->close();
  48.  
  49.         return $domain;
  50.     }
  51.  
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement