Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php defined("\102\101\123\x45\x50\101\x54\110") or die("\x4e\x6f\x20\x64\x69\x72\145\x6..

Decoded Output download

<?php
 defined("BASEPATH") or die("No direct script access allowed"); class CI_DB_postgre_driver extends CI_DB { public $dbdriver = "postgre"; public $schema = "public"; protected $_random_keyword = array("RANDOM()", "RANDOM()"); protected function _build_dsn() { $this->dsn === '' or $this->dsn = ''; if (strpos($this->hostname, "/") !== FALSE) { $this->port = ''; } $this->hostname === '' or $this->dsn = "host=" . $this->hostname . " "; if (!empty($this->port) && ctype_digit($this->port)) { $this->dsn .= "port=" . $this->port . " "; } if ($this->username !== '') { $this->dsn .= "user=" . $this->username . " "; $this->password === NULL or $this->dsn .= "password='" . $this->password . "' "; } $this->database === '' or $this->dsn .= "dbname=" . $this->database . " "; foreach (array("connect_timeout", "options", "sslmode", "service") as $key) { if (isset($this->{$key}) && is_string($this->{$key}) && $this->{$key} !== '') { $this->dsn .= $key . "='" . $this->{$key} . "' "; } } $this->dsn = rtrim($this->dsn); } public function db_connect($persistent = FALSE) { empty($this->dsn) && $this->_build_dsn(); $this->conn_id = $persistent === TRUE ? pg_pconnect($this->dsn) : pg_connect($this->dsn); if ($this->conn_id !== FALSE) { if ($persistent === TRUE && pg_connection_status($this->conn_id) === PGSQL_CONNECTION_BAD && pg_ping($this->conn_id) === FALSE) { return FALSE; } if (pg_set_client_encoding($this->conn_id, $this->char_set) !== 0) { log_message("error", "Database: Unable to set the configured connection charset ('{$this->char_set}')."); pg_close($this->conn_id); return $this->db->db_debug ? $this->display_error("db_unable_to_set_charset", $this->char_set) : FALSE; } empty($this->schema) or $this->simple_query("SET search_path TO " . $this->schema . ",public"); } return $this->conn_id; } public function reconnect() { if (pg_ping($this->conn_id) === FALSE) { $this->conn_id = FALSE; } } public function version() { if (isset($this->data_cache["version"])) { return $this->data_cache["version"]; } if (!$this->conn_id or ($pg_version = pg_version($this->conn_id)) === FALSE) { return FALSE; } return isset($pg_version["server"]) && preg_match("#^(\d+\.\d+)#", $pg_version["server"], $match) ? $this->data_cache["version"] = $match[1] : parent::version(); } protected function _execute($sql) { return pg_query($this->conn_id, $sql); } protected function _trans_begin() { return (bool) pg_query($this->conn_id, "BEGIN"); } protected function _trans_commit() { return (bool) pg_query($this->conn_id, "COMMIT"); } protected function _trans_rollback() { return (bool) pg_query($this->conn_id, "ROLLBACK"); } public function is_write_type($sql) { if (preg_match("#^(INSERT|UPDATE).*RETURNING\s.+(\,\s?.+)*$#is", $sql)) { return FALSE; } return parent::is_write_type($sql); } protected function _escape_str($str) { return pg_escape_string($this->conn_id, $str); } public function escape($str) { if (is_string($str) or is_object($str) && method_exists($str, "__toString")) { return pg_escape_literal($this->conn_id, $str); } elseif (is_bool($str)) { return $str ? "TRUE" : "FALSE"; } return parent::escape($str); } public function affected_rows() { return pg_affected_rows($this->result_id); } public function insert_id() { $v = $this->version(); $table = func_num_args() > 0 ? func_get_arg(0) : NULL; $column = func_num_args() > 1 ? func_get_arg(1) : NULL; if ($table === NULL && $v >= "8.1") { $sql = "SELECT LASTVAL() AS ins_id"; } elseif ($table !== NULL) { if ($column !== NULL && $v >= "8.0") { $sql = "SELECT pg_get_serial_sequence('" . $table . "', '" . $column . "') AS seq"; $query = $this->query($sql); $query = $query->row(); $seq = $query->seq; } else { $seq = $table; } $sql = "SELECT CURRVAL('" . $seq . "') AS ins_id"; } else { return pg_last_oid($this->result_id); } $query = $this->query($sql); $query = $query->row(); return (int) $query->ins_id; } protected function _list_tables($prefix_limit = FALSE) { $sql = "SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = '" . $this->schema . "'"; if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql . " AND "table_name" LIKE '" . $this->escape_like_str($this->dbprefix) . "%' " . sprintf($this->_like_escape_str, $this->_like_escape_chr); } return $sql; } protected function _list_columns($table = '') { return "SELECT "column_name"\xa	\x9	FROM "information_schema"."columns"
\x9\x9\x9WHERE "table_schema" = '" . $this->schema . "' AND LOWER("table_name") = " . $this->escape(strtolower($table)); } public function field_data($table) { $sql = "SELECT "column_name", "data_type", "character_maximum_length", "numeric_precision", "column_default"
\x9	\x9FROM "information_schema"."columns"\xa	\x9\x9WHERE "table_schema" = '" . $this->schema . "' AND LOWER("table_name") = " . $this->escape(strtolower($table)); if (($query = $this->query($sql)) === FALSE) { return FALSE; } $query = $query->result_object(); $retval = array(); for ($i = 0, $c = count($query); $i < $c; $i++) { $retval[$i] = new stdClass(); $retval[$i]->name = $query[$i]->column_name; $retval[$i]->type = $query[$i]->data_type; $retval[$i]->max_length = $query[$i]->character_maximum_length > 0 ? $query[$i]->character_maximum_length : $query[$i]->numeric_precision; $retval[$i]->default = $query[$i]->column_default; } return $retval; } public function error() { return array("code" => '', "message" => pg_last_error($this->conn_id)); } public function order_by($orderby, $direction = '', $escape = NULL) { $direction = strtoupper(trim($direction)); if ($direction === "RANDOM") { if (!is_float($orderby) && ctype_digit((string) $orderby)) { $orderby = $orderby > 1 ? (double) "0." . $orderby : (double) $orderby; } if (is_float($orderby)) { $this->simple_query("SET SEED " . $orderby); } $orderby = $this->_random_keyword[0]; $direction = ''; $escape = FALSE; } return parent::order_by($orderby, $direction, $escape); } protected function _update($table, $values) { $this->qb_limit = FALSE; $this->qb_orderby = array(); return parent::_update($table, $values); } protected function _update_batch($table, $values, $index) { $ids = array(); foreach ($values as $key => $val) { $ids[] = $val[$index]["value"]; foreach (array_keys($val) as $field) { if ($field !== $index) { $final[$val[$field]["field"]][] = "WHEN " . $val[$index]["value"] . " THEN " . $val[$field]["value"]; } } } $cases = ''; foreach ($final as $k => $v) { $cases .= $k . " = (CASE " . $val[$index]["field"] . "\xa" . implode("
", $v) . "\xa" . "ELSE " . $k . " END), "; } $this->where($val[$index]["field"] . " IN(" . implode(",", $ids) . ")", NULL, FALSE); return "UPDATE " . $table . " SET " . substr($cases, 0, -2) . $this->_compile_wh("qb_where"); } protected function _delete($table) { $this->qb_limit = FALSE; return parent::_delete($table); } protected function _limit($sql) { return $sql . " LIMIT " . $this->qb_limit . ($this->qb_offset ? " OFFSET " . $this->qb_offset : ''); } protected function _close() { pg_close($this->conn_id); } } ?>

Did this file decode correctly?

Original Code

<?php
 defined("\102\101\123\x45\x50\101\x54\110") or die("\x4e\x6f\x20\x64\x69\x72\145\x63\x74\40\163\x63\x72\151\160\164\x20\x61\x63\x63\145\x73\163\40\x61\154\154\157\x77\145\x64"); class CI_DB_postgre_driver extends CI_DB { public $dbdriver = "\x70\157\x73\164\147\162\x65"; public $schema = "\160\x75\142\154\x69\143"; protected $_random_keyword = array("\x52\x41\116\x44\117\x4d\50\51", "\122\x41\116\x44\x4f\115\x28\51"); protected function _build_dsn() { $this->dsn === '' or $this->dsn = ''; if (strpos($this->hostname, "\x2f") !== FALSE) { $this->port = ''; } $this->hostname === '' or $this->dsn = "\x68\x6f\x73\164\x3d" . $this->hostname . "\x20"; if (!empty($this->port) && ctype_digit($this->port)) { $this->dsn .= "\x70\157\x72\164\x3d" . $this->port . "\40"; } if ($this->username !== '') { $this->dsn .= "\165\163\x65\x72\x3d" . $this->username . "\40"; $this->password === NULL or $this->dsn .= "\160\x61\163\163\x77\x6f\162\x64\x3d\x27" . $this->password . "\47\40"; } $this->database === '' or $this->dsn .= "\144\x62\x6e\141\155\145\x3d" . $this->database . "\x20"; foreach (array("\143\157\x6e\x6e\x65\x63\x74\137\164\151\155\145\157\165\164", "\157\x70\164\151\157\156\x73", "\163\x73\x6c\155\x6f\144\145", "\163\x65\x72\166\151\143\x65") as $key) { if (isset($this->{$key}) && is_string($this->{$key}) && $this->{$key} !== '') { $this->dsn .= $key . "\75\47" . $this->{$key} . "\x27\x20"; } } $this->dsn = rtrim($this->dsn); } public function db_connect($persistent = FALSE) { empty($this->dsn) && $this->_build_dsn(); $this->conn_id = $persistent === TRUE ? pg_pconnect($this->dsn) : pg_connect($this->dsn); if ($this->conn_id !== FALSE) { if ($persistent === TRUE && pg_connection_status($this->conn_id) === PGSQL_CONNECTION_BAD && pg_ping($this->conn_id) === FALSE) { return FALSE; } if (pg_set_client_encoding($this->conn_id, $this->char_set) !== 0) { log_message("\x65\x72\162\157\162", "\104\141\x74\141\142\141\163\145\72\40\x55\156\x61\142\154\x65\x20\164\157\x20\x73\145\164\x20\164\150\145\x20\143\x6f\156\x66\151\147\165\x72\145\x64\40\x63\x6f\x6e\156\x65\143\x74\x69\x6f\x6e\x20\x63\150\141\x72\163\x65\164\x20\50\47{$this->char_set}\47\51\x2e"); pg_close($this->conn_id); return $this->db->db_debug ? $this->display_error("\x64\142\x5f\x75\156\141\x62\x6c\x65\137\x74\x6f\x5f\163\x65\x74\x5f\x63\x68\x61\x72\x73\x65\164", $this->char_set) : FALSE; } empty($this->schema) or $this->simple_query("\123\x45\x54\40\163\x65\141\162\143\150\137\160\141\164\150\40\124\x4f\x20" . $this->schema . "\x2c\160\x75\x62\x6c\151\x63"); } return $this->conn_id; } public function reconnect() { if (pg_ping($this->conn_id) === FALSE) { $this->conn_id = FALSE; } } public function version() { if (isset($this->data_cache["\x76\x65\x72\163\x69\157\156"])) { return $this->data_cache["\166\x65\x72\x73\x69\x6f\x6e"]; } if (!$this->conn_id or ($pg_version = pg_version($this->conn_id)) === FALSE) { return FALSE; } return isset($pg_version["\x73\x65\x72\166\x65\162"]) && preg_match("\43\x5e\50\134\x64\x2b\134\x2e\x5c\144\53\x29\x23", $pg_version["\x73\145\162\x76\x65\x72"], $match) ? $this->data_cache["\166\x65\162\163\151\x6f\156"] = $match[1] : parent::version(); } protected function _execute($sql) { return pg_query($this->conn_id, $sql); } protected function _trans_begin() { return (bool) pg_query($this->conn_id, "\102\105\107\111\116"); } protected function _trans_commit() { return (bool) pg_query($this->conn_id, "\103\x4f\115\x4d\111\x54"); } protected function _trans_rollback() { return (bool) pg_query($this->conn_id, "\122\x4f\x4c\x4c\x42\101\x43\x4b"); } public function is_write_type($sql) { if (preg_match("\43\136\50\111\x4e\123\105\x52\124\174\x55\120\104\101\x54\x45\x29\x2e\52\x52\105\124\125\122\x4e\111\116\x47\134\x73\x2e\53\x28\x5c\54\x5c\163\77\x2e\53\x29\52\x24\x23\151\163", $sql)) { return FALSE; } return parent::is_write_type($sql); } protected function _escape_str($str) { return pg_escape_string($this->conn_id, $str); } public function escape($str) { if (is_string($str) or is_object($str) && method_exists($str, "\x5f\137\164\157\123\164\x72\x69\156\147")) { return pg_escape_literal($this->conn_id, $str); } elseif (is_bool($str)) { return $str ? "\x54\x52\125\x45" : "\x46\101\x4c\123\x45"; } return parent::escape($str); } public function affected_rows() { return pg_affected_rows($this->result_id); } public function insert_id() { $v = $this->version(); $table = func_num_args() > 0 ? func_get_arg(0) : NULL; $column = func_num_args() > 1 ? func_get_arg(1) : NULL; if ($table === NULL && $v >= "\x38\56\x31") { $sql = "\123\x45\114\105\x43\124\40\114\x41\x53\x54\x56\101\x4c\x28\51\x20\101\123\40\x69\156\163\x5f\x69\x64"; } elseif ($table !== NULL) { if ($column !== NULL && $v >= "\70\56\x30") { $sql = "\123\x45\114\x45\103\x54\x20\x70\x67\137\x67\x65\164\137\163\x65\x72\151\x61\x6c\x5f\x73\x65\x71\165\x65\156\x63\x65\x28\47" . $table . "\x27\x2c\40\x27" . $column . "\x27\51\x20\x41\x53\40\x73\145\x71"; $query = $this->query($sql); $query = $query->row(); $seq = $query->seq; } else { $seq = $table; } $sql = "\123\x45\114\105\x43\124\40\103\125\x52\x52\126\x41\x4c\50\x27" . $seq . "\47\x29\x20\x41\123\40\x69\x6e\x73\137\x69\x64"; } else { return pg_last_oid($this->result_id); } $query = $this->query($sql); $query = $query->row(); return (int) $query->ins_id; } protected function _list_tables($prefix_limit = FALSE) { $sql = "\x53\105\x4c\105\103\x54\40\42\164\141\x62\154\x65\137\156\141\x6d\145\x22\x20\x46\x52\x4f\x4d\40\x22\x69\156\146\157\x72\155\141\164\151\x6f\x6e\x5f\163\143\150\x65\155\x61\x22\x2e\42\x74\x61\x62\x6c\x65\163\x22\40\127\110\x45\122\x45\40\x22\x74\141\x62\x6c\x65\137\163\143\150\145\x6d\141\42\40\75\x20\47" . $this->schema . "\47"; if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql . "\40\101\116\104\40\x22\x74\141\142\154\x65\x5f\156\141\155\145\42\x20\x4c\x49\x4b\105\40\x27" . $this->escape_like_str($this->dbprefix) . "\45\47\40" . sprintf($this->_like_escape_str, $this->_like_escape_chr); } return $sql; } protected function _list_columns($table = '') { return "\123\105\x4c\105\x43\124\x20\x22\x63\x6f\x6c\165\155\156\137\x6e\x61\x6d\x65\x22\xa\11\x9\11\x46\122\x4f\x4d\x20\42\x69\x6e\146\157\x72\155\141\x74\151\x6f\x6e\x5f\163\143\150\145\x6d\x61\42\x2e\42\143\157\x6c\x75\x6d\x6e\163\x22\12\x9\x9\x9\127\110\105\122\105\40\x22\164\x61\x62\x6c\x65\x5f\163\x63\x68\x65\155\141\x22\x20\75\40\47" . $this->schema . "\47\40\101\x4e\x44\40\114\x4f\127\105\122\x28\x22\x74\141\x62\154\x65\x5f\156\x61\155\x65\x22\x29\40\x3d\40" . $this->escape(strtolower($table)); } public function field_data($table) { $sql = "\x53\x45\x4c\x45\x43\124\40\x22\143\x6f\154\x75\155\156\137\x6e\141\x6d\145\x22\54\40\x22\x64\141\164\x61\x5f\x74\x79\x70\145\42\54\x20\x22\x63\x68\141\162\x61\143\164\x65\162\137\155\x61\170\151\x6d\x75\x6d\x5f\154\x65\x6e\147\164\150\42\x2c\40\x22\156\165\x6d\145\x72\151\143\x5f\160\162\x65\x63\x69\163\151\157\156\x22\54\x20\x22\x63\x6f\154\165\155\x6e\x5f\144\145\x66\141\165\x6c\x74\42\12\x9\11\x9\106\x52\117\x4d\40\x22\151\156\146\157\x72\155\141\x74\151\x6f\x6e\x5f\x73\x63\x68\x65\x6d\x61\x22\x2e\42\x63\157\154\165\x6d\156\x73\x22\xa\11\x9\x9\127\x48\105\x52\x45\x20\x22\x74\141\142\x6c\145\137\x73\143\x68\x65\x6d\141\42\40\75\x20\x27" . $this->schema . "\x27\40\x41\x4e\x44\x20\114\117\x57\105\122\x28\x22\x74\141\x62\154\145\x5f\x6e\141\x6d\x65\42\x29\x20\75\x20" . $this->escape(strtolower($table)); if (($query = $this->query($sql)) === FALSE) { return FALSE; } $query = $query->result_object(); $retval = array(); for ($i = 0, $c = count($query); $i < $c; $i++) { $retval[$i] = new stdClass(); $retval[$i]->name = $query[$i]->column_name; $retval[$i]->type = $query[$i]->data_type; $retval[$i]->max_length = $query[$i]->character_maximum_length > 0 ? $query[$i]->character_maximum_length : $query[$i]->numeric_precision; $retval[$i]->default = $query[$i]->column_default; } return $retval; } public function error() { return array("\x63\x6f\144\145" => '', "\x6d\145\163\x73\141\147\145" => pg_last_error($this->conn_id)); } public function order_by($orderby, $direction = '', $escape = NULL) { $direction = strtoupper(trim($direction)); if ($direction === "\122\x41\x4e\x44\x4f\x4d") { if (!is_float($orderby) && ctype_digit((string) $orderby)) { $orderby = $orderby > 1 ? (double) "\60\x2e" . $orderby : (double) $orderby; } if (is_float($orderby)) { $this->simple_query("\123\x45\x54\40\123\105\105\104\40" . $orderby); } $orderby = $this->_random_keyword[0]; $direction = ''; $escape = FALSE; } return parent::order_by($orderby, $direction, $escape); } protected function _update($table, $values) { $this->qb_limit = FALSE; $this->qb_orderby = array(); return parent::_update($table, $values); } protected function _update_batch($table, $values, $index) { $ids = array(); foreach ($values as $key => $val) { $ids[] = $val[$index]["\x76\x61\x6c\x75\145"]; foreach (array_keys($val) as $field) { if ($field !== $index) { $final[$val[$field]["\146\x69\x65\x6c\144"]][] = "\x57\x48\x45\x4e\40" . $val[$index]["\166\x61\x6c\x75\145"] . "\x20\124\110\105\116\40" . $val[$field]["\166\141\154\x75\145"]; } } } $cases = ''; foreach ($final as $k => $v) { $cases .= $k . "\x20\75\40\x28\103\101\x53\x45\40" . $val[$index]["\146\x69\x65\154\x64"] . "\xa" . implode("\12", $v) . "\xa" . "\x45\x4c\x53\x45\40" . $k . "\x20\105\116\x44\51\x2c\40"; } $this->where($val[$index]["\146\x69\x65\154\144"] . "\40\111\x4e\x28" . implode("\54", $ids) . "\51", NULL, FALSE); return "\125\x50\x44\x41\x54\x45\40" . $table . "\40\x53\105\x54\x20" . substr($cases, 0, -2) . $this->_compile_wh("\161\x62\x5f\x77\x68\145\162\x65"); } protected function _delete($table) { $this->qb_limit = FALSE; return parent::_delete($table); } protected function _limit($sql) { return $sql . "\x20\114\x49\x4d\111\x54\x20" . $this->qb_limit . ($this->qb_offset ? "\x20\x4f\106\x46\x53\x45\124\x20" . $this->qb_offset : ''); } protected function _close() { pg_close($this->conn_id); } }

Function Calls

None

Variables

None

Stats

MD5 fedd80b76a4ddccbdd04b9a3a2970ad4
Eval Count 0
Decode Time 117 ms