(file) Return to import.php CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / mysqlinks

 1 rizwank 1.1 <?php
 2                 blogroll($_GET['f']);
 3                 
 4             
 5                 function blogroll($file) {
 6                     global $_BLOGROLL, $linkID;
 7                     $_BLOGROLL = array();
 8                     if (! parse_opml($file)) {
 9                         echo "bad parse";
10                         return false;            
11                     }
12                     if ($_BLOGROLL) {
13                         ksort($_BLOGROLL);
14                         foreach ($_BLOGROLL as $blog) {
15                             if (isset($blog['DESCRIPTION']) && $blog['DESCRIPTION']) {
16                                 $alt = HTMLentities($blog['DESCRIPTION']);
17                             }
18                             else {
19                                 $alt = HTMLentities($attr['TITLE']);
20                             }
21                             include_once('db.php');
22 rizwank 1.1                 $sql = "insert into feeds (address, site) values ('$blog[XMLURL]', '$blog[TITLE]')";
23                             $buff = mysql_query($sql, $linkID);
24                             if($buff)
25                             {
26                                 //echo "good<br/>";
27                                 $good_counter++;
28                             }    
29                             else
30                             {
31                                 //echo "bad<br/>";
32                                 $bad_counter++;
33                             }                                 
34                         }
35                     }
36                     $status = count($_BLOGROLL);
37                     $_BLOGROLL = null;
38                     echo "added $good_counter, didn't add $bad_counter";
39                     return $status;
40                 }
41                 function parse_opml($file) {
42                     $fp = @fopen($file, 'rB');
43 rizwank 1.1         if (! $fp) {
44                         return false;
45                     }
46                     $opml = fread($fp, 1000000);
47                     $xp = xml_parser_create();
48                     xml_set_element_handler($xp, '_xml_startElement', '_xml_endElement');
49                     xml_parse($xp, $opml, true);
50                     xml_parser_free($xp);
51                     return true;
52                 }
53                 
54               
55                 function _xml_startElement($xp, $element, $attr) {
56                     global $_BLOGROLL;
57             
58                     if (strcasecmp('outline', $element)) {
59                         return;
60                     }
61                     $_BLOGROLL[$attr['TITLE']] = $attr;
62                 }
63                 function _xml_endElement($xp, $element) {
64 rizwank 1.1         return;
65                 }
66             ?> 

Rizwan Kassim
Powered by
ViewCVS 0.9.2