//session_start();
//$config[$mainurl] = "http://w3.30888.com.tw";
$NOW = time();
class CDbshell {
var $host = "";
var $user = "";
var $pass = "";
var $db = "";
var $dbh = 0;
var $rs = 0;
var $debug = 0;
var $version= "";
//-----------------------------------------------------------------------------------
function debugOn(){
$this->debug=0;
}
// MySQL Version
function getMysqlVersion()
{
if (!$this->version)
{
mysql_select_db($this->db);
$result = mysql_query('SELECT VERSION() AS version');
if ($result != FALSE && @mysql_num_rows($result) > 0)
{
$row = mysql_fetch_array($result);
$match = explode('.', $row['version']);
}
else
{
$result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
if ($result != FALSE && @mysql_num_rows($result) > 0)
{
$row = mysql_fetch_row($result);
$match = explode('.', $row[1]);
}
}
if (!isset($match) || !isset($match[0])) {
$match[0] = 3;
}
if (!isset($match[1])) {
$match[1] = 21;
}
if (!isset($match[2])) {
$match[2] = 0;
}
$this->version = (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2]));
unset($match);
}
}
/*function CDbshell() {
$this->host="localhost";
$this->user="uniqu_unique";
$this->pass="aWlb78&2";
$this->db="unique_localhost";
$this->connect();
}*/
// function CDbshell() {
// $this->host="54.64.155.150";
// $this->user="vedanUser";
// $this->pass="jLnq6nMv9evsDdCV";
// $this->db="z_vedan";
//
// $this->connect();
// }
function CDbshell() {
$this->host="127.0.0.1";
$this->user="deployer";
$this->pass="tornflewSeanative";
$this->db="2016weiweinoodle";
$this->connect();
}
//-----------------------------------------------------------------------------------
function connect()
{
$i=0;
while(!$this->dbh)
{
$this->dbh=@mysql_connect($this->host,$this->user,$this->pass);
if($this->dbh) break;
if($i==100) break;
$i++;
}
}
/*function autocommit($type)
{
$this->query("START TRANSACTION");
$this->query("SET autocommit=".$type);
}
function do_commit()
{
$this->query("COMMIT");
}
function do_rollback()
{
$this->query("ROLLBACK");
}*/
//-----------------------------------------------------------------------------------
function query($sqlstr)
{
// echo $sqlstr;
global $_SERVER,$username,$boardname;
mysql_select_db($this->db);
$this->rs=mysql_query($sqlstr);
if($this->debug && mysql_error())
{
//echo ":: SQL= $sqlstr
";
}
//echo mysql_error();
return $this->rs;
}
//-----------------------------------------------------------------------------------
function num_rows($rs=0)
{
if($rs)
$frs=$rs;
else
$frs=$this->rs;
if(!$frs) return 0;
return mysql_num_rows($frs);
}
//-----------------------------------------------------------------------------------
function fetch_array ($rs=0)
{
//if(!$this->rs) return 0;
if($rs)
$frs=$rs;
else
$frs=$this->rs;
return @mysql_fetch_array($frs);
}
function fetch_assoc ($rs=0)
{
//if(!$this->rs) return 0;
if($rs)
$frs=$rs;
else
$frs=$this->rs;
return @mysql_fetch_assoc($frs);
}
function close($rs=0)
{
if($rs)
$frs=$rs;
else
$frs=$this->rs;
@mysql_free_result($frs);
}
//-----------------------------------------------------------------------------------
function dooSQL($sql)
{
if(!isset($sql)) return 0;
return $this->query($sql);
}
//-----------------------------------------------------------------------------------
function insert_id ()
{
$id=-1;
if(!$this->rs) return 0;
return mysql_insert_id();
}
function Mkpassword($str)
{
$this->Query("SELECT PASSWORD('$str')");
$row=$this->fetch_array();
return $row[0];
}
//-----------------------------------------------------------------------------------
function insert($table,$field)
{
$md5_array = array(
'mPwd','userPwd','storePwd'
);
if(!is_array($field)) return 0;
$colstr = " ( ";
$valstr = " ( ";
foreach($field as $k => $v)
{
$colstr .= " ".$k.",";
$valstr .= (in_array($k,$md5_array)) ? " md5('".$v."')," : " '".$v."',";
}
$colstr = substr($colstr,0,-1)." ) ";
$valstr = substr($valstr,0,-1)." ) ";
$sql = "INSERT INTO ".$table." ".$colstr." values ".$valstr." ";
return $this->query($sql);
}
function insert_old($table,$field,$value)
{
if(!is_array($field)) return 0;
if(!is_array($value)) return 0;
count($field)==count($value) or die(count($field) .":". count($value) );
$sql="INSERT INTO $table ( ";
for($i=1;$i<=count($field);$i++)
{
$sql.=$field[$i-1];
if($i!=count($field)) $sql.=",";
}
$sql.=") values(";
for($i=1;$i<=count($value);$i++) {
$sql.="'".$value[$i-1]."'";
if($i!=count($value)) $sql.=",";
}
$sql.=")";
$this->query($sql);
}
//-----------------------------------------------------------------------------------
function update($table,$field,$where)
{
if(!is_array($field)) return 0;
$md5_array = array(
'mPwd','userPwd','storePwd'
);
$str1 = "";
foreach($field as $k => $v)
{
$str1 .= (in_array($k,$md5_array)) ? " ".$k." = md5('".$v."')," : " ".$k." = '".$v."',";
}
$str1 = substr($str1,0,-1);
$sql="update $table set ".$str1." ";
if(trim($where)!="")
$sql .= $where;
// echo $sql;
$this->query($sql);
}
function update_old($table,$field,$value,$where)
{
if(!is_array($field)) return 0;
if(!is_array($value)) return 0;
if(count($field)!=count($value)) return 0;
//global $charset;
//include_once("../BaseClass/CCharset.info3");
//$code=new CCharset;
$sql="update $table set ";
for($i=0;$iquery($sql);
}
//-----------------------------------------------------------------------------------
function GetAllFields($table)
{
$fields = mysql_list_fields($this->db, $table, $this->dbh);
$columns = mysql_num_fields($fields);
for ($i = 0; $i < $columns; $i++) {
$row[]= mysql_field_name($fields, $i) . "\n";;
}
return $row;
}
}
$_db=new CDbshell;
?>
Notice: Undefined variable: _db in /home/deployer/public_html/weiweinoodle/page2.php on line 4
Fatal error: Call to a member function query() on null in /home/deployer/public_html/weiweinoodle/page2.php on line 4