summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-03-15 19:54:18 +0400
committerAndrew Dolgov <[email protected]>2013-03-15 19:54:18 +0400
commit8c0496f74c60e47d9e2f87bb107d79b99c0070aa (patch)
tree4261c954aebeb4176074c8afc2f40b362ba56b15 /classes
parenta48d8533bf6a353972248720cf19ffb5ba55041f (diff)
Revert "Rewrote database support to classes, Fixed strict warning in sanitizedummy.php"
This reverts commit 65d0cc64a2ca1ce259fbba501b13deaf1870e540.
Diffstat (limited to 'classes')
-rw-r--r--classes/Db/Abstract.php56
-rw-r--r--classes/Db/Interface.php18
-rw-r--r--classes/Db/Mysql.php71
-rw-r--r--classes/Db/Pgsql.php80
-rw-r--r--classes/sanitizedummy.php2
5 files changed, 1 insertions, 226 deletions
diff --git a/classes/Db/Abstract.php b/classes/Db/Abstract.php
deleted file mode 100644
index d84701fd7..000000000
--- a/classes/Db/Abstract.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-
-abstract class Db_Abstract implements Db_Interface
-{
- private $dbconn;
- protected static $instance;
-
- private function __construct() { }
-
- public static function instance()
- {
- if (is_null(static::$instance)) {
- static::$instance = new static();
- }
-
- return static::$instance;
- }
-
- public function connect($host, $user, $pass, $db) { }
-
- public function getLink()
- {
- return $this->dbconn;
- }
-
- public function init() { }
-
- public function escape_string($s, $strip_tags = true) { }
-
- public function query($query, $die_on_error = true) { }
-
- public function fetch_assoc($result) { }
-
- public function num_rows($result) { }
-
- public function fetch_result($result, $row, $param) { }
-
- public function unescape_string($str)
- {
- $tmp = str_replace("\\\"", "\"", $str);
- $tmp = str_replace("\\'", "'", $tmp);
- return $tmp;
- }
-
- public function close() { }
-
- public function affected_rows($result) { }
-
- public function last_error() { }
-
- public function quote($str)
- {
- return("'$str'");
- }
-
-} \ No newline at end of file
diff --git a/classes/Db/Interface.php b/classes/Db/Interface.php
deleted file mode 100644
index c5bfad56f..000000000
--- a/classes/Db/Interface.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-interface Db_Interface
-{
- public function connect($host, $user, $pass, $db);
- public function getLink();
- public function init();
- public function escape_string($s, $strip_tags = true);
- public function query($query, $die_on_error = true);
- public function fetch_assoc($result);
- public function num_rows($result);
- public function fetch_result($result, $row, $param);
- public function unescape_string($str);
- public function close();
- public function affected_rows($result);
- public function last_error();
- public function quote($str);
-}
diff --git a/classes/Db/Mysql.php b/classes/Db/Mysql.php
deleted file mode 100644
index 170628304..000000000
--- a/classes/Db/Mysql.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-
-class Db_Mysql extends Db_Abstract
-{
- public function connect($host, $user, $pass, $db)
- {
- $link = mysql_connect($host, $user, $pass);
- if ($link) {
- $result = mysql_select_db($db, $link);
- if (!$result) {
- die("Can't select DB: " . mysql_error($link));
- }
- $this->dbconn = $link;
- return $link;
- } else {
- die("Unable to connect to database (as $user to $host, database $db): " . mysql_error());
- }
- }
-
- public function init()
- {
- db_query($this->dbconn, "SET time_zone = '+0:0'");
-
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($this->dbconn, "SET NAMES " . MYSQL_CHARSET);
- }
- }
-
- public function escape_string($s, $strip_tags = true)
- {
- if ($strip_tags) $s = strip_tags($s);
- return mysql_real_escape_string($s);
- }
-
- public function query($query, $die_on_error = true)
- {
- $result = mysql_query($query, $this->dbconn);
- if (!$result) {
- $query = htmlspecialchars($query);
- if ($die_on_error) {
- die("Query <i>$query</i> failed: " . ($this->dbconn ? mysql_error($this->dbconn) : "No connection"));
- }
- }
- return $result;
- }
-
- public function fetch_assoc($result) {
- return mysql_fetch_assoc($result);
- }
-
- public function num_rows($result) {
- return mysql_num_rows($result);
- }
-
- public function fetch_result($result, $row, $param) {
- // I hate incoherent naming of PHP functions
- return mysql_result($result, $row, $param);
- }
-
- public function close() {
- return mysql_close($this->dbconn);
- }
-
- public function affected_rows($result) {
- return mysql_affected_rows($this->dbconn);
- }
-
- public function last_error() {
- return mysql_error($this->dbconn);
- }
-}
diff --git a/classes/Db/Pgsql.php b/classes/Db/Pgsql.php
deleted file mode 100644
index 39ed181d7..000000000
--- a/classes/Db/Pgsql.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-class Db_Pgsql extends Db_Abstract
-{
- public function connect($host, $user, $pass, $db)
- {
- $string = "dbname=$db user=$user";
-
- if ($pass) {
- $string .= " password=$pass";
- }
-
- if ($host) {
- $string .= " host=$host";
- }
-
- if (defined('DB_PORT')) {
- $string = "$string port=" . DB_PORT;
- }
-
- $link = pg_connect($string);
-
- if (!$link) {
- die("Unable to connect to database (as $user to $host, database $db):" . pg_last_error());
- }
-
- $this->dbconn = $link;
- return $link;
- }
-
- public function init()
- {
- pg_query($this->dbconn, "set client_encoding = 'UTF-8'");
- pg_set_client_encoding("UNICODE");
- pg_query($this->dbconn, "set datestyle = 'ISO, european'");
- pg_query($this->dbconn, "set TIME ZONE 0");
- }
-
- public function escape_string($s, $strip_tags = true)
- {
- if ($strip_tags) $s = strip_tags($s);
- return pg_escape_string($s);
- }
-
- public function query($query, $die_on_error = true)
- {
- $result = pg_query($this->dbconn, $query);
- if (!$result) {
- $query = htmlspecialchars($query); // just in case
- if ($die_on_error) {
- die("Query <i>$query</i> failed [$result]: " . ($this->dbconn ? pg_last_error($this->dbconn) : "No connection"));
- }
- }
- return $result;
- }
-
- public function fetch_assoc($result) {
- return pg_fetch_assoc($result);
- }
-
- public function num_rows($result) {
- return pg_num_rows($result);
- }
-
- public function fetch_result($result, $row, $param) {
- return pg_fetch_result($result, $row, $param);
- }
-
- public function close() {
- return pg_close($this->dbconn);
- }
-
- public function affected_rows($result) {
- return pg_affected_rows($result);
- }
-
- public function last_error() {
- return pg_last_error($this->dbconn);
- }
-}
diff --git a/classes/sanitizedummy.php b/classes/sanitizedummy.php
index 7182fb7f5..a184bec30 100644
--- a/classes/sanitizedummy.php
+++ b/classes/sanitizedummy.php
@@ -1,6 +1,6 @@
<?php
class SanitizeDummy extends SimplePie_Sanitize {
- function sanitize($data, $type, $base = '') {
+ function sanitize($data, $type, $base) {
return $data;
}
}