| 1 | <?php |
|---|
| 2 | ############################################################################### |
|---|
| 3 | # Gregarius - A PHP based RSS aggregator. |
|---|
| 4 | # Copyright (C) 2003 - 2006 Marco Bonetti |
|---|
| 5 | # |
|---|
| 6 | ############################################################################### |
|---|
| 7 | # This program is free software and open source software; you can redistribute |
|---|
| 8 | # it and/or modify it under the terms of the GNU General Public License as |
|---|
| 9 | # published by the Free Software Foundation; either version 2 of the License, |
|---|
| 10 | # or (at your option) any later version. |
|---|
| 11 | # |
|---|
| 12 | # This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 14 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 15 | # more details. |
|---|
| 16 | # |
|---|
| 17 | # You should have received a copy of the GNU General Public License along |
|---|
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 19 | # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit |
|---|
| 20 | # http://www.gnu.org/licenses/gpl.html |
|---|
| 21 | # |
|---|
| 22 | ############################################################################### |
|---|
| 23 | # E-mail: mbonetti at gmail dot com |
|---|
| 24 | # Web page: http://gregarius.net/ |
|---|
| 25 | # |
|---|
| 26 | ############################################################################### |
|---|
| 27 | |
|---|
| 28 | if (!@include_once('dbinit.php')) { |
|---|
| 29 | header('Location: install.php'); |
|---|
| 30 | exit(); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | if (!defined('DBTYPE')) { |
|---|
| 34 | define ('DBTYPE','mysql'); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | require_once('cls/db/db.'.DBTYPE.'.php'); |
|---|
| 38 | $dbcls = ucfirst(DBTYPE)."DB"; |
|---|
| 39 | $GLOBALS['rss_db'] = new $dbcls; |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | function rss_query ($query, $dieOnError=true, $preventRecursion=false) { |
|---|
| 43 | $pf = defined('PROFILING_DB') && PROFILING_DB && function_exists('_pf'); |
|---|
| 44 | if ($pf) { |
|---|
| 45 | list ($usec, $sec) = explode(" ", microtime()); |
|---|
| 46 | } |
|---|
| 47 | $rs = $GLOBALS['rss_db']->rss_query ($query, $dieOnError, $preventRecursion); |
|---|
| 48 | if ($pf) { |
|---|
| 49 | list ($usec2, $sec2) = explode(" ", microtime()); |
|---|
| 50 | _pf("Query took " . (($sec2-$sec) + ($usec2-$usec)) . " seconds:\n\t\t\t" |
|---|
| 51 | . preg_replace('/\'[a-z0-9]+\'/i','\'[removed]\'',$query)); |
|---|
| 52 | } |
|---|
| 53 | return $rs; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | function rss_fetch_row($rs) { |
|---|
| 57 | return $GLOBALS['rss_db']->rss_fetch_row($rs); |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | function rss_fetch_assoc($rs) { |
|---|
| 61 | return $GLOBALS['rss_db']->rss_fetch_assoc($rs); |
|---|
| 62 | } |
|---|
| 63 | function rss_num_rows($rs) { |
|---|
| 64 | return $GLOBALS['rss_db']->rss_num_rows($rs); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | function rss_sql_error() { |
|---|
| 68 | return $GLOBALS['rss_db']->rss_sql_error(); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | function rss_sql_error_message () { |
|---|
| 72 | return $GLOBALS['rss_db']->rss_sql_error_message(); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | function rss_insert_id() { |
|---|
| 76 | return $GLOBALS['rss_db']->rss_insert_id(); |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | function rss_real_escape_string($string) { |
|---|
| 80 | return $GLOBALS['rss_db']->rss_real_escape_string($string); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | function getTable($tableName) { |
|---|
| 84 | return $GLOBALS['rss_db']->getTable($tableName); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | function rss_is_sql_error($kind) { |
|---|
| 88 | return $GLOBALS['rss_db']-> rss_is_sql_error($kind); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | function rss_invalidate_cache() { |
|---|
| 92 | $sql = 'update ' . getTable('cache') . " set timestamp=now() where cachekey='data_ts'"; |
|---|
| 93 | $GLOBALS['rss_db']->rss_query ($sql, false, false); |
|---|
| 94 | return true; |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | ?> |
|---|