Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. <?php
  2.  
  3. class mysql{
  4.  
  5.     public $ID;
  6.     private $website_ID;
  7.     private $host;
  8.     private $user;
  9.     private $password;
  10.     private $database;
  11.    
  12.     public function __construct($ID=0){
  13.         if ($ID){
  14.             $ID=(int)$this->ID;
  15.             $website_ID=(int)get_X("mysql","ID",$ID,"website_ID");
  16.             $host=htmlentities(get_X("mysql","ID",$ID,"host"));
  17.             $user=htmlentities(get_X("mysql","ID",$ID,"user"));
  18.             $password=htmlentities(get_X("mysql","ID",$ID,"password"));
  19.             $database=htmlentities(get_X("mysql","ID",$ID,"database"));
  20.         }
  21.     }
  22.  
  23.     //add: new, edit and delete mysql
  24.  
  25.     public function generate_code(){
  26.         if ($this->ID){
  27.             $code = "<?php\n";
  28.             $code .= "/* WebCMS.code.database.start */\n";
  29.             $code .= "//database connect code\n";
  30.             $code .= "mysql_connect(".$this->host.", ".$this->user.", ".$this->password, ");\n";
  31.             $code .= "mysql_select_db(".$this->database.");\n";
  32.             $code .= "//generated by WebCMS at ". date(time()); //fix date format;
  33.             $code .= "/* WebCMS.code.database.end */\n";
  34.             $code .= "?>";
  35.         }
  36.     }
  37.  
  38.     public function export_xml(){
  39.         if ($this->ID){
  40.             $xml = "<mysql>\n";
  41.             $xml = "\t<host>".$this->host."</host>\n";
  42.             $xml = "\t<user>".$this->user."</user>\n";
  43.             $xml = "\t<password>".$this->password."</password>\n";
  44.             $xml = "\t<database>".$this->database."</database>\n";
  45.             $xml .= "</mysql>\n";
  46.         }
  47.     }
  48.  
  49. }
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement