-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfof-db.php
More file actions
executable file
·115 lines (85 loc) · 3.52 KB
/
fof-db.php
File metadata and controls
executable file
·115 lines (85 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/*
* This file is part of FEED ON FEEDS - http://feedonfeeds.com/
*
* db.php - (nearly) all of the DB specific code
*
*
* Copyright (C) 2004-2007 Stephen Minutillo
* steve@minutillo.com - http://minutillo.com/steve/
*
* Distributed under the GPL - see LICENSE
*
*/
require_once("init.php");
$FOF_FEED_TABLE = FOF_FEED_TABLE;
$FOF_ITEM_TABLE = FOF_ITEM_TABLE;
$FOF_ITEM_TAG_TABLE = FOF_ITEM_TAG_TABLE;
$FOF_SUBSCRIPTION_TABLE = FOF_SUBSCRIPTION_TABLE;
$FOF_FLAG_TABLE = FOF_FLAG_TABLE;
$FOF_USER_TABLE = FOF_USER_TABLE;
function fof_db_get_row($result)
{
return mysql_fetch_array($result);
}
function db_save_prefs($user_id, $prefs)
{
global $FOF_USER_TABLE, $fof_connection, $mc_user_id, $mc_user_name, $fof_user_level, $fof_user_prefs;
$prefs = mysql_escape_string(serialize($prefs));
$sql = "update $FOF_USER_TABLE set user_prefs = '$prefs' where user_id = $user_id";
fof_do_query($sql);
}
function fof_db_authenticate($user_name, $user_password_hash)
{
global $FOF_USER_TABLE, $FOF_ITEM_TABLE, $FOF_ITEM_TAG_TABLE, $fof_connection, $mc_user_id, $mc_user_name, $fof_user_level, $fof_user_prefs;
$sql = "select * from $FOF_USER_TABLE where user_name = '$user_name' and md5(user_password) = '" . mysql_escape_string($user_password_hash) . "'";
$result = fof_do_query($sql);
if(mysql_num_rows($result) == 0)
{
return false;
}
$row = mysql_fetch_array($result);
$mc_user_name = $row['user_name'];
$mc_user_id = $row['user_id'];
$fof_user_level = $row['user_level'];
$fof_user_prefs = unserialize($row['user_prefs']);
if(!is_array($fof_user_prefs)) $fof_user_prefs = array();
if(!isset($fof_user_prefs['favicons'])) $fof_user_prefs['favicons'] = false;
if(!isset($fof_user_prefs['keyboard'])) $fof_user_prefs['keyboard'] = false;
if(!isset($fof_user_prefs['frames'])) $fof_user_prefs['frames'] = false;
return true;
}
function fof_db_get_subscriptions($user_id)
{
global $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_SUBSCRIPTION_TABLE, $FOF_ITEM_TAG_TABLE;
return(fof_do_query("select * from $FOF_FEED_TABLE, $FOF_SUBSCRIPTION_TABLE where $FOF_SUBSCRIPTION_TABLE.user_id = $user_id and $FOF_FEED_TABLE.id = $FOF_SUBSCRIPTION_TABLE.feed_id order by $FOF_FEED_TABLE.title"));
}
function fof_db_add_subscription($user_id, $feed_id)
{
global $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_SUBSCRIPTION_TABLE, $fof_connection;
$sql = "insert into $FOF_SUBSCRIPTION_TABLE (feed_id, user_id) values ($feed_id, $user_id)";
fof_do_query($sql);
}
function fof_db_delete_subscription($user_id, $feed_id)
{
global $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_SUBSCRIPTION_TABLE, $fof_connection;
$sql = "delete from $FOF_SUBSCRIPTION_TABLE where feed_id = $feed_id and user_id = $user_id";
fof_do_query($sql);
}
function fof_db_get_subscribed_users($feed_id)
{
global $FOF_SUBSCRIPTION_TABLE;
return(fof_do_query("select user_id from $FOF_SUBSCRIPTION_TABLE where $FOF_SUBSCRIPTION_TABLE.feed_id = $feed_id"));
}
function fof_db_is_subscribed($user_id, $feed_url)
{
global $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_SUBSCRIPTION_TABLE, $FOF_ITEM_TAG_TABLE;
$safeurl = mysql_escape_string( $feed_url );
$result = fof_do_query("select $FOF_SUBSCRIPTION_TABLE.feed_id from $FOF_FEED_TABLE, $FOF_SUBSCRIPTION_TABLE where $FOF_FEED_TABLE.feed_url='$safeurl' and $FOF_SUBSCRIPTION_TABLE.feed_id = $FOF_FEED_TABLE.feed_id and $FOF_SUBSCRIPTION_TABLE.user_id = $user_id");
if(mysql_num_rows($result) == 0)
{
return false;
}
return true;
}
?>