Guest User

Untitled

a guest
Jul 13th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.30 KB | None | 0 0
  1. <?php
  2. ////////////////////////////////////////////////////////////////
  3. //
  4. //  Warning: Editing the following without instruction or
  5. //  knowledge of how it works may lead to errors in its
  6. //  execution, always consult me before editing any of this
  7. //
  8. //  ~David A Perez
  9. // 
  10. ////////////////////////////////////////////////////////////////
  11. require_once'utility_lib.php';
  12.    
  13. class dpEmailer_manager extends utility {
  14.     public $dpe_connect;
  15.     ////////////////////////////////////////////////////////////////
  16.     // Build Class object
  17.     ////////////////////////////////////////////////////////////////
  18.     function __construct(){
  19.         parent::__construct();
  20.         $db_host = "xxx";
  21.         $db_username = "xxx";
  22.         $db_password = "xxx";
  23.         $db_dbname = "xxx";
  24.         $this->dpe_connect = $this->open_dpe_connect($db_host,$db_username,$db_password,$db_dbname);
  25.        
  26.         echo "<pre>\n";
  27.             print_r($this);
  28.         echo "</pre>\n";
  29.     }
  30.    
  31.     ////////////////////////////////////////////////////////////////
  32.     // Destructor
  33.     ////////////////////////////////////////////////////////////////
  34.     function __destruct(){
  35.         $this->dpe_db_connect = $this->close_dpe_connect();
  36.     }
  37.    
  38.     ////////////////////////////////////////////////////////////////
  39.     // test
  40.     ////////////////////////////////////////////////////////////////
  41.     function test(){
  42.        
  43.         $query = "SELECT * FROM auth_codes";
  44.         $results = mysql_query($query,$this->dpe_connect);
  45.            
  46.         if(!$results){
  47.             $message = __METHOD__."() > Error fetching MySQL results: ".mysql_error()."<br />\n".$query;
  48.             die($message);
  49.         }
  50.         $count = mysql_num_rows($results);
  51.        
  52.         echo "This many results: ".$count;
  53.     }
  54.    
  55.     ////////////////////////////////////////////////////////////////
  56.     // Open DP Emailer DB connection
  57.     ////////////////////////////////////////////////////////////////
  58.     function open_dpe_connect($dbhost,$dbusername,$dbpassword,$dbname){
  59.        
  60.         $this->dpe_connect = mysql_connect($dbhost,$dbusername,$dbpassword);
  61.        
  62.         if(!$this->dpe_connect){
  63.             die('Error connecting to MySQL: '.mysql_error());
  64.         }  
  65.         mysql_select_db($dbname,$this->dpe_connect);
  66.     }
  67.    
  68.     ////////////////////////////////////////////////////////////////
  69.     // Close DP Emailer DB connection
  70.     ////////////////////////////////////////////////////////////////
  71.     function close_dpe_connect(){
  72.         mysql_close($this->dpe_connect);
  73.  
  74.     }
  75. }
  76. ?>
Add Comment
Please, Sign In to add comment