[3178] | 1 | <?php |
---|
| 2 | |
---|
[4957] | 3 | include('../header.inc.php'); |
---|
| 4 | |
---|
[3178] | 5 | class rss |
---|
| 6 | { |
---|
| 7 | // BEGIN of functions. |
---|
[4957] | 8 | function getContent($param) |
---|
| 9 | { |
---|
[3178] | 10 | $daurl=$param['url']; |
---|
[4957] | 11 | |
---|
[3178] | 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 | } |
---|
[4688] | 36 | |
---|
| 37 | function getChannels() |
---|
| 38 | { |
---|
[4957] | 39 | $query = "SELECT config_value FROM phpgw_config WHERE config_name = 'expressoMail_enabled_read_rss';"; |
---|
[4688] | 40 | |
---|
[4957] | 41 | if( $GLOBALS['phpgw']->db->query( $query ) ) |
---|
[4688] | 42 | { |
---|
| 43 | while( $GLOBALS['phpgw']->db->next_record() ) |
---|
| 44 | { |
---|
[4957] | 45 | $result = $GLOBALS['phpgw']->db->row(); |
---|
[4688] | 46 | } |
---|
[4957] | 47 | } |
---|
| 48 | |
---|
| 49 | if( $result['config_value'] === 'true' ) |
---|
| 50 | { |
---|
| 51 | $query = "SELECT * FROM phpgw_config WHERE config_name = 'expressoMail_list_rss';"; |
---|
[4688] | 52 | |
---|
[4957] | 53 | if( $GLOBALS['phpgw']->db->query($query) ) |
---|
[4688] | 54 | { |
---|
[4957] | 55 | while( $GLOBALS['phpgw']->db->next_record() ) |
---|
[4688] | 56 | { |
---|
[4957] | 57 | $result = $GLOBALS['phpgw']->db->row(); |
---|
[4688] | 58 | } |
---|
| 59 | } |
---|
[4957] | 60 | |
---|
| 61 | if( $result['config_value'] ) |
---|
[4688] | 62 | { |
---|
[4957] | 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; |
---|
[4688] | 74 | } |
---|
[4957] | 75 | else |
---|
| 76 | return ""; |
---|
[4688] | 77 | } |
---|
[3178] | 78 | } |
---|
[4688] | 79 | |
---|
[4957] | 80 | /*function addChannel($param) |
---|
[4688] | 81 | { |
---|
[4957] | 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__ ); |
---|
[3178] | 90 | if ($GLOBALS['phpgw']->db->Error) |
---|
[4957] | 91 | return "Error"; |
---|
[3178] | 92 | else |
---|
[4957] | 93 | return "Success"; |
---|
[3178] | 94 | |
---|
| 95 | } |
---|
| 96 | |
---|
[4688] | 97 | function removeChannel($param) |
---|
| 98 | { |
---|
[3178] | 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"; |
---|
[4957] | 105 | }*/ |
---|
[3178] | 106 | |
---|
| 107 | } |
---|
[4957] | 108 | ?> |
---|