]> git.wh0rd.org Git - tt-rss.git/commitdiff
add db-prefs.php
authorAndrew Dolgov <fox@bah.spb.su>
Wed, 16 Nov 2005 16:57:08 +0000 (17:57 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Wed, 16 Nov 2005 16:57:08 +0000 (17:57 +0100)
backend.php
db-prefs.php [new file with mode: 0644]

index 83a0ab51d04f32c303a3782bb652577ac0f014ee..954c4dacacf4a05a13ee14ac38aa67a177e60909 100644 (file)
@@ -9,12 +9,14 @@
 
        require_once "config.php";
        require_once "db.php";
+       require_once "db-prefs.php";
        require_once "functions.php";
        require_once "magpierss/rss_fetch.inc";
 
        $script_started = getmicrotime();
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
+       $dbprefs_link = $link;
 
        if (!$link) {
                if (DB_TYPE == "mysql") {
diff --git a/db-prefs.php b/db-prefs.php
new file mode 100644 (file)
index 0000000..c0f6159
--- /dev/null
@@ -0,0 +1,25 @@
+<?
+
+       require_once "config.php";
+       require_once "db.php";
+
+       global $dbprefs_link;
+
+       function get_pref($pref_name) {
+
+               $pref_name = db_escape_string($pref_name);
+
+               $result = db_query($dbprefs_link, "SELECT 
+                       value,ttrss_prefs_types.id as type_name 
+                       FROM ttrss_prefs,ttrss_prefs_types
+                       WHERE pref_name = '$pref_name' AND ttrss_prefs_types.id = type_id");
+
+               if (db_num_rows($result) > 0) {
+                       $value = db_fetch_result($result, 0, "value");
+                       return $value;
+               } else {                
+                       die("Fatal error, unknown preferences key: $pref_name");                        
+               }
+       }
+
+?>