source: branches/2.2/expressoMail1_2/inc/class.rss.inc.php @ 3178

Revision 3178, 1.8 KB checked in by amuller, 14 years ago (diff)

Ticket #1158 - Implementação do leitor de RSS

  • Property svn:executable set to *
Line 
1<?php
2
3class rss
4{
5
6        function rss (){
7        }
8        // BEGIN of functions.
9        function getContent($param){
10                $daurl=$param['url'];
11                if (preg_match('/http(s)?:\/\//i',$daurl,$matches) == 0)
12                        $daurl = 'http://'.$daurl;
13
14                // Set your return content type
15                header('Content-type: application/xml');
16
17                // Get that website's content
18                $handle = fopen($daurl, "r");
19
20                // If there is something, read and return
21                if ($handle) {
22                        $buffer = fgets($handle, 4096);
23                        $pattern = '/<\?xml version=".\.0"( encoding="[A-Z\-0-9]+")?\ *\?>/i';
24                        if (preg_match($pattern,$buffer,$matches) == 0)
25                                exit;
26                        echo $buffer;
27                        while (!feof($handle)) {
28                                $buffer = fgets($handle, 4096);
29                                echo $buffer;
30                        }
31                        fclose($handle);
32                }
33                exit;
34        }
35        function getChannels(){
36                include('../header.inc.php');
37                $GLOBALS['phpgw']->db->query('SELECT rss_url,name FROM phpgw_userrss WHERE uid = '.$_SESSION['phpgw_session']['account_id']);
38                while($GLOBALS['phpgw']->db->next_record())
39                        $return[]=$GLOBALS['phpgw']->db->row();
40                return $return;
41        }
42        function addChannel($param){
43                include('../header.inc.php');
44                $name = $GLOBALS['phpgw']->db->db_addslashes(htmlentities($param['name']));
45                $url = $GLOBALS['phpgw']->db->db_addslashes($param['url']);
46                $GLOBALS['phpgw']->db->query('INSERT INTO phpgw_userrss values('.$_SESSION['phpgw_session']['account_id'].',\''.$url.'\',\''.$name.'\');',__LINE__,__FILE__);
47                if ($GLOBALS['phpgw']->db->Error)
48                            return "Error";
49                else
50                            return "Success";
51
52        }
53
54        function removeChannel($param){
55                include('../header.inc.php');
56                $url = $GLOBALS['phpgw']->db->db_addslashes($param['url']);
57                $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_userrss where rss_url = \''.$url.'\';',__LINE__,__FILE__);
58                if ($GLOBALS['phpgw']->db->Error)
59                            return "Error";
60                else
61                            return "Success";
62        }
63
64}
65?>
Note: See TracBrowser for help on using the repository browser.