1 | <?php |
---|
2 | |
---|
3 | include('../header.inc.php'); |
---|
4 | |
---|
5 | class rss |
---|
6 | { |
---|
7 | // BEGIN of functions. |
---|
8 | function getContent($param) |
---|
9 | { |
---|
10 | $daurl=$param['url']; |
---|
11 | |
---|
12 | if (preg_match('/http(s)?:\/\//i',$daurl,$matches) == 0) |
---|
13 | $daurl = 'http://'.$daurl; |
---|
14 | |
---|
15 | // Set your return content type |
---|
16 | header('Content-type: application/xml'); |
---|
17 | |
---|
18 | // Get that website's content |
---|
19 | $handle = fopen($daurl, "r"); |
---|
20 | |
---|
21 | // If there is something, read and return |
---|
22 | if ($handle) { |
---|
23 | $buffer = fgets($handle, 4096); |
---|
24 | $pattern = '/<\?xml version=".\.0"( encoding="[A-Z\-0-9]+")?\ *\?>/i'; |
---|
25 | if (preg_match($pattern,$buffer,$matches) == 0) |
---|
26 | exit; |
---|
27 | echo $buffer; |
---|
28 | while (!feof($handle)) { |
---|
29 | $buffer = fgets($handle, 4096); |
---|
30 | echo $buffer; |
---|
31 | } |
---|
32 | fclose($handle); |
---|
33 | } |
---|
34 | exit; |
---|
35 | } |
---|
36 | |
---|
37 | function getChannels() |
---|
38 | { |
---|
39 | $query = "SELECT config_value FROM phpgw_config WHERE config_name = 'expressoMail_enabled_read_rss';"; |
---|
40 | |
---|
41 | if( $GLOBALS['phpgw']->db->query( $query ) ) |
---|
42 | { |
---|
43 | while( $GLOBALS['phpgw']->db->next_record() ) |
---|
44 | { |
---|
45 | $result = $GLOBALS['phpgw']->db->row(); |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | if( $result['config_value'] === 'true' ) |
---|
50 | { |
---|
51 | $query = "SELECT * FROM phpgw_config WHERE config_name = 'expressoMail_list_rss';"; |
---|
52 | |
---|
53 | if( $GLOBALS['phpgw']->db->query($query) ) |
---|
54 | { |
---|
55 | while( $GLOBALS['phpgw']->db->next_record() ) |
---|
56 | { |
---|
57 | $result = $GLOBALS['phpgw']->db->row(); |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | if( $result['config_value'] ) |
---|
62 | { |
---|
63 | $i = 0; |
---|
64 | $rss = unserialize($result['config_value']); |
---|
65 | |
---|
66 | foreach( $rss as $item ) |
---|
67 | { |
---|
68 | $tmp = explode( "|", $item ); |
---|
69 | $return[$i]['rss_url'] = $tmp[0]; |
---|
70 | $return[$i++]['name'] = $tmp[1]; |
---|
71 | } |
---|
72 | |
---|
73 | return $return; |
---|
74 | } |
---|
75 | else |
---|
76 | return ""; |
---|
77 | } |
---|
78 | } |
---|
79 | |
---|
80 | /*function addChannel($param) |
---|
81 | { |
---|
82 | |
---|
83 | $name = $GLOBALS['phpgw']->db->db_addslashes(htmlentities($param['name'])); |
---|
84 | $url = $GLOBALS['phpgw']->db->db_addslashes($param['url']); |
---|
85 | $query = 'INSERT INTO phpgw_userrss values('.$_SESSION['phpgw_session']['account_id'].',\''.$url.'\',\''.$name.'\');'; |
---|
86 | |
---|
87 | error_log( print_r( $query, true ), 3, "/tmp/log" ); |
---|
88 | |
---|
89 | $GLOBALS['phpgw']->db->query( $query ,__LINE__,__FILE__ ); |
---|
90 | if ($GLOBALS['phpgw']->db->Error) |
---|
91 | return "Error"; |
---|
92 | else |
---|
93 | return "Success"; |
---|
94 | |
---|
95 | } |
---|
96 | |
---|
97 | function removeChannel($param) |
---|
98 | { |
---|
99 | $url = $GLOBALS['phpgw']->db->db_addslashes($param['url']); |
---|
100 | $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_userrss where rss_url = \''.$url.'\';',__LINE__,__FILE__); |
---|
101 | if ($GLOBALS['phpgw']->db->Error) |
---|
102 | return "Error"; |
---|
103 | else |
---|
104 | return "Success"; |
---|
105 | }*/ |
---|
106 | |
---|
107 | } |
---|
108 | ?> |
---|