Changeset 1155 for trunk/rss/util.php
- Timestamp:
- 01/07/06 15:15:26 (3 years ago)
- Files:
-
- 1 modified
-
trunk/rss/util.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/rss/util.php
r1151 r1155 158 158 return array (magpie_error(), array ()); 159 159 } 160 elseif (!$rss ) {161 continue; 160 elseif (!$rss || !($rss->rss_origin & MAGPIE_FEED_ORIGIN_HTTP_200) ) { 161 continue; // no need to do anything if we do not get a 200 OK from the feed 162 162 } 163 163 … … 175 175 if(!isset($item)) 176 176 continue; 177 // item title: strip out html tags, shouldn't supposed 178 // to have any, should it? 179 //$title = strip_tags($item['title']); 177 178 // item title: strip out html tags 180 179 $title = array_key_exists('title', $item) ? strip_tags($item['title']) : ""; 181 180 //$title = str_replace('& ', '& ', $title); 181 182 183 $description = ""; 182 184 // item content, if any 183 185 if (array_key_exists('content', $item) && is_array($item['content']) && array_key_exists('encoded', $item['content'])) { 184 $description = kses($item['content']['encoded'], $kses_allowed);186 $description = $item['content']['encoded']; 185 187 } 186 188 elseif (array_key_exists('description', $item)) { 187 $description = kses($item['description'], $kses_allowed);189 $description = $item['description']; 188 190 } 189 191 elseif (array_key_exists('atom_content', $item)) { 190 $description = kses($item['atom_content'], $kses_allowed);192 $description = $item['atom_content']; 191 193 } 192 194 elseif (array_key_exists('summary', $item)) { 193 $description = kses($item['summary'], $kses_allowed);195 $description = $item['summary']; 194 196 } 195 197 else { … … 197 199 } 198 200 199 if ($description != "" && $baseUrl != "") { 200 //$description = make_abs($description, $baseUrl); 201 $description = relative_to_absolute($description, $baseUrl); 201 $md5sum = ""; 202 $guid = ""; 203 204 if(array_key_exists('guid', $item) && $item['guid'] != "") { 205 $guid = $item['guid']; 206 } 207 elseif(array_key_exists('id', $item) && $item['id'] != "") { 208 $guid = $item['id']; 202 209 } 203 210 204 211 if ($description != "") { 205 $description = rss_plugin_hook('rss.plugins.import.description', $description); 206 } 212 $md5sum = md5($description); 213 $description = kses($description, $kses_allowed); // strip out tags 214 215 if ($baseUrl != "") { 216 $description = relative_to_absolute($description, $baseUrl); 217 } 218 } 219 220 // Now let plugins modify the description 221 $description = rss_plugin_hook('rss.plugins.import.description', $description); 222 207 223 208 224 // link … … 272 288 continue; 273 289 } 290 274 291 $dbtitle = rss_real_escape_string($title); 275 292 if (strlen($dbtitle) >= 255) { 276 293 $dbtitle=substr($dbtitle,0,254); 277 294 } 278 // check wether we already have this item279 $sql = "select id,length(description),unread from ".getTable("item")." where cid=$cid and url='$url' and title='$dbtitle'";280 $subres = rss_query($sql);281 list ($indb, $dbdesc_len, $state) = rss_fetch_row($subres);282 295 283 296 if ($cDate > 0) { … … 287 300 } 288 301 289 if ($indb == "") { 290 291 list ($cid, $dbtitle, $url, $description) 292 = rss_plugin_hook('rss.plugins.items.new', array ($cid, $dbtitle, $url, $description)); 302 // check whether we already have this item 303 if ($guid) { 304 $sql = "select id,unread, md5sum, guid, pubdate from ".getTable("item") 305 ." where cid=$cid and guid='$guid'"; 306 } else { 307 $sql = "select id,unread, md5sum, guid, pubdate from ".getTable("item") 308 ." where cid=$cid and url='$url' and title='$dbtitle'" 309 ." and (pubdate is NULL OR pubdate=$sec)"; 310 } 311 $subres = rss_query($sql); 312 list ($indb, $state, $dbmd5sum, $dbGuid, $dbPubDate) = rss_fetch_row($subres); 313 314 if ($indb && !($state & RSS_MODE_DELETED_STATE) && $md5sum != $dbmd5sum) { 315 // the md5sums do not match. 316 if(getConfig('rss.input.allowupdates')) { // Are we allowed update items in the db? 317 list ($cid, $indb, $description) = 318 rss_plugin_hook('rss.plugins.items.updated', array ($cid, $indb, $description)); 319 320 $sql = "update ".getTable("item") 321 ." set "." description='".rss_real_escape_string($description)."', " 322 ." unread = unread | ".RSS_MODE_UNREAD_STATE 323 .", md5sum='$md5sum'" . " where cid=$cid and id=$indb"; 324 325 rss_query($sql); 326 $updatedIds[] = $indb; 327 continue; 328 } 329 } 330 331 if ($indb == "") { // This must be new item then. In you go. 332 333 list ($cid, $dbtitle, $url, $description) = 334 rss_plugin_hook('rss.plugins.items.new', array ($cid, $dbtitle, $url, $description)); 293 335 294 336 $sql = "insert into ".getTable("item") 295 337 ." (cid, added, title, url, enclosure," 296 ." description, author, unread, pubdate ) "338 ." description, author, unread, pubdate, md5sum, guid) " 297 339 ." values ("."$cid, now(), '$dbtitle', " 298 340 ." '$url', '".rss_real_escape_string($enclosure)."', '" 299 341 .rss_real_escape_string($description)."', '" 300 342 .rss_real_escape_string($author)."', " 301 ."$mode, $sec )";343 ."$mode, $sec, '$md5sum', '$guid')"; 302 344 303 345 rss_query($sql); 304 305 346 306 347 $newIid = rss_insert_id(); 307 348 $updatedIds[] = $newIid; 308 /*309 * Ticket #26: Add hook to modify the item just after it310 * has been inserted into the database311 */312 349 rss_plugin_hook('rss.plugins.items.newiid',array($newIid,$item,$cid)); 313 350 } 314 elseif (!($state & RSS_MODE_DELETED_STATE) && 315 getConfig('rss.input.allowupdates') && 316 strlen($description) > $dbdesc_len) { 317 318 list ($cid, $indb, $description) = 319 rss_plugin_hook('rss.plugins.items.updated', array ($cid, $indb, $description)); 320 321 $sql = "update ".getTable("item") 322 ." set "." description='".rss_real_escape_string($description)."', " 323 ." unread = unread | ".RSS_MODE_UNREAD_STATE." where cid=$cid and id=$indb"; 324 325 rss_query($sql); 326 $updatedIds[] = $indb; 327 } 351 328 352 } 329 353 } … … 557 581 static $ret; 558 582 if ($ret === NULL) { 559 $ret = dirname($_SERVER['PHP_SELF']);560 if (defined('RSS_FILE_LOCATION') && eregi(RSS_FILE_LOCATION."\$", $ret)) {561 $ret = substr($ret, 0, strlen($ret) - strlen(RSS_FILE_LOCATION));562 }563 if (substr($ret, -1) != "/") {564 $ret .= "/";565 }583 $ret = dirname($_SERVER['PHP_SELF']); 584 if (defined('RSS_FILE_LOCATION') && eregi(RSS_FILE_LOCATION."\$", $ret)) { 585 $ret = substr($ret, 0, strlen($ret) - strlen(RSS_FILE_LOCATION)); 586 } 587 if (substr($ret, -1) != "/") { 588 $ret .= "/"; 589 } 566 590 } 567 591 return $ret; 568 592 569 593 } 570 594 $dummy = getPath();
