|
إنضمامك إلي منتديات استراحات زايد يحقق لك معرفة كل ماهو جديد في عالم الانترنت ...
انضم الينا
#1
| ||
| ||
رمز PHP:
__DEFINE_LIKE_SHARE__
'RSS 1.0', 'http://purl.org/rss/1.0/modules/content/' => 'RSS 2.0', 'http://www.w3.org/2005/Atom' => 'ATOM 1', ); // Namespaces to detact feed version private $itemTags = array('ITEM','ENTRY'); // List of tag names which holds a feed item private $channelTags = array('CHANNEL','FEED'); // List of tag names which holds all channel elements private $dateTags = array('UPDATED','PUBDATE','DCATE'); private $hasSubTags = array('IMAGE','AUTHOR'); // List of tag names which have sub tags private $channels = array(); private $items = array(); private $itemIndex = 0; private $url = null; // The parsed url private $version = 'RSS 2.0'; // Detected feed version /** * Constructor - Initialize and set event handler functions to xmlParser */ function __construct() { $this->xmlParser = xml_parser_create(); xml_set_object($this->xmlParser, $this); xml_set_element_handler($this->xmlParser, "startElement", "endElement"); xml_set_character_data_handler($this->xmlParser, "characterData"); } /*-----------------------------------------------------------------------+ | Public functions. Use to parse feed and get informations. | +-----------------------------------------------------------------------*/ /** * Get all channel elements * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess public * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn array - All chennels as associative array */ public function getChannels() { return $this->channels; } /** * Get all feed items * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess public * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn array - All feed items as associative array */ public function getItems() { return $this->items; } /** * Get total number of feed items * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess public * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn number */ public function getTotalItems() { return count($this->items); } /** * Get a feed item by index * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess public * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam number index of feed item * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn array feed item as associative array of it's elements */ public function getItem($index) { if($index getTotalItems()) { return $this->items[$index]; } } /** * Get a channel element by name * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess public * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam string the name of channel tag * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn string */ public function getChannel($tagName) { if(array_key_exists(strtoupper($tagName), $this->channels)) { return $this->channels[strtoupper($tagName)]; } } /** * Get the parsed URL * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess public * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn string */ public function getParsedUrl() { return $this->url; } /** * Get the detected Feed version * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess public * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn string */ public function getFeedVersion() { return $this->version; } /** * Parses a feed url * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess public * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam srting teh feed url * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn void */ public function parse($url) { $this->url = $url; $URLContent = $this->getUrlContent(); if($URLContent) { if(الى العباقرة فى القسم طلب تعديل ملف FeedParser.php!stristr($URLContent,"content:encoded")) { $URLContent = str_replace("description", "CONTENT:ENCODED", $URLContent); } $segments = str_split($URLContent, 4096); foreach($segments as $index=>$data) { $lastPiese = ((count($segments)-1) == $index)? true : false; xml_parse($this->xmlParser, $data, $lastPiese); } xml_parser_free($this->xmlParser); } //else //{ //die('Sorry! cannot load the feed url.'); //} //if(empty($this->version)) //{ //die('Sorry! cannot detect the feed version.'); //} } // End public functions ------------------------------------------------- /*-----------------------------------------------------------------------+ | Private functions. Be careful to edit them. | +-----------------------------------------------------------------------*/ /** * Load the whole contents of a RSS/ATOM page * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess private * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn string */ private function getUrlContent() { if(empty($this->url)) { //throw new Exception("URL to parse is empty!."); //return false; } if($content = الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpfile_get_contents($this->url)) { return $content; } else { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $content = curl_exec($ch); $error = curl_error($ch); curl_close($ch); if($content) { return $content; } else { //throw new Exception("Erroe occured while loading url by cURL. \n" . $error) ; //return false; } } } /** * Handle the start event of a tag while parsing * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess private * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam object the xmlParser object * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam string name of currently entering tag * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam array array of attributes * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn void */ private function startElement($parser, $tagName, $attrs) { if(!$this->version) { $this->findVersion($tagName, $attrs); } array_push($this->insideItem, $tagName); $this->currentTag = $tagName; $this->currentAttr = $attrs; } /** * Handle the end event of a tag while parsing * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess private * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam object the xmlParser object * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam string name of currently ending tag * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn void */ private function endElement($parser, $tagName) { if (in_array($tagName, $this->itemTags)) { $this->itemIndex++; } array_pop($this->insideItem); $this->currentTag = $this->insideItem[count($this->insideItem)-1]; } /** * Handle character data of a tag while parsing * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess private * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam object the xmlParser object * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam string tag value * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn void */ private function characterData($parser, $data) { //Converting all date formats to timestamp if(in_array($this->currentTag, $this->dateTags)) { $data = strtotime($data); } if($this->inChannel()) { // If has subtag, make current element an array and assign subtags as it's element if(in_array($this->getParentTag(), $this->hasSubTags)) { if(! is_array($this->channels[$this->getParentTag()])) { $this->channels[$this->getParentTag()] = array(); } $this->channels[$this->getParentTag()][$this->currentTag] .= strip_tags($this->html2bb((trim($data)))); return; } else { if(! in_array($this->currentTag, $this->hasSubTags)) { $this->channels[$this->currentTag] .= strip_tags($this->html2bb((trim($data)))); } } if(!empty($this->currentAttr)) { $this->channels[$this->currentTag . '_ATTRS'] = $this->currentAttr; //If the tag has no value if(strlen($this->channels[$this->currentTag]) currentAttr) == 1) { foreach($this->currentAttr as $attrVal) { $this->channels[$this->currentTag] = $attrVal; } } //If there are multiple attributes, assign the attributs array as channel value else { $this->channels[$this->currentTag] = $this->currentAttr; } } } } elseif($this->inItem()) { // If has subtag, make current element an array and assign subtags as it's elements if(in_array($this->getParentTag(), $this->hasSubTags)) { if(! is_array($this->items[$this->itemIndex][$this->getParentTag()])) { $this->items[$this->itemIndex][$this->getParentTag()] = array(); } $this->items[$this->itemIndex][$this->getParentTag()][$this->currentTag] .= strip_tags($this->html2bb((trim($data)))); return; } else { if(! in_array($this->currentTag, $this->hasSubTags)) { $this->items[$this->itemIndex][$this->currentTag] .= strip_tags($this->html2bb((trim($data)))); } } if(!empty($this->currentAttr)) { $this->items[$this->itemIndex][$this->currentTag . '_ATTRS'] = $this->currentAttr; //If the tag has no value if(strlen($this->items[$this->itemIndex][$this->currentTag]) items[$this->itemIndex][$this->currentTag] = $this->currentAttr; } } } } } /** * Find out the feed version * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess private * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam string name of current tag * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam array array of attributes * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn void */ private function findVersion($tagName, $attrs) { $namespace = array_values($attrs); foreach($this->namespaces as $value =>$version) { if(in_array($value, $namespace)) { $this->version = $version; return; } } } private function getParentTag() { return $this->insideItem[count($this->insideItem) - 2]; } /** * Detect if current position is in channel element * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess private * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn bool */ private function inChannel() { if($this->version == 'RSS 1.0') { if(in_array('CHANNEL', $this->insideItem) && $this->currentTag != 'CHANNEL') return TRUE; } elseif($this->version == 'RSS 2.0') { if(in_array('CHANNEL', $this->insideItem) && !in_array('ITEM', $this->insideItem) && $this->currentTag != 'CHANNEL') return TRUE; } elseif($this->version == 'ATOM 1') { if(in_array('FEED', $this->insideItem) && !in_array('ENTRY', $this->insideItem) && $this->currentTag != 'FEED') return TRUE; } return FALSE; } /** * Detect if current position is in Item element * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess private * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn bool */ private function inItem() { if($this->version == 'RSS 1.0' || $this->version == 'RSS 2.0') { if(in_array('ITEM', $this->insideItem) && $this->currentTag != 'ITEM') return TRUE; } elseif($this->version == 'ATOM 1') { if(in_array('ENTRY', $this->insideItem) && $this->currentTag != 'ENTRY') return TRUE; } return FALSE; } //This function is taken from lastRSS /** * Replace HTML entities &something; by real characters * * * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpaccess private * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpauthor Vojtech Semecky * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phplink http://lastrss.oslab.net/ * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpparam string * الى العباقرة فى القسم طلب تعديل ملف FeedParser.phpreturn string */ private function unhtmlentities($string) { // Get HTML entities table $trans_tbl = get_html_translation_table (HTML_ENTITIES, ENT_QUOTES); // Flip keysvalues $trans_tbl = array_flip ($trans_tbl); // Add support for ' entity (missing in HTML_ENTITIES) $trans_tbl += array(''' => "'"); // Replace entities by values return strtr ($string, $trans_tbl); } // HTML conversion common to both bbcode and text result function html_common($string) { // First extract just the body of the message if (stristr($string, "]+>#i', '', $string); // Replace image references $string = preg_replace('##iUe', "'[img]'.trim('$1').'[/img]'", $string); // Remove all remaining HTML tags $string = preg_replace('#]*>#', '', $string); // Convert HTML entities //$string = html_entity_decode($string); // Convert quotes if (get_magic_quotes_gpc()) { return stripslashes($string); } else { return ($string); } } } ?> [/size] مقدمة اولا: مشكلة كبيرة واجهتنى فى المنتدى vb بعد تعب وعناء اصبحت منتديات فى بى عرضة فى مهب الريح بعد الهجمة الاخيرة الشرسة من الشركة على السيرفرات المجانية واغلاق كل المواقع التى تحتوى على نسخ مجانية وليس النسخة فقط المهم بحثت ووجدت ضالتى منتدى شبيه تماما بفى بى يلبى والحمد كل احتياجات عملى المهم واجهتنى مشكلة فى ملف جلب الموضوعات فى البداية الملف كان يرفض جلب اى موضوعات من المواقع او المنتديات وتظهر هذه الرسالة لا يمكن جلب هذه التغذية لوجود اخطاء عدم توافق معايير RSS على هذا الرابط منتديات شبكة اسلام الكون لاختبار روابط التغذية RSS والتأكد من عملها وكشف الاخطاء توجه لهذا الرابط : RSS Feed Validator ولا يوجد اى جلب نهائى مع ان الرابط تمام التمام ومواقع كثيرة تقبله من جالب التغذية فى الفيس بوك وتوتير فيد وغيرها ووجدت الملف الذى رفعته يقبل من جريدة المصريون فقط فارجو من العباقرة تحرير هذا الملف من القيود الى العباقرة فى القسم طلب تعديل ملف FeedParser.php حتى يعمل على جميع المواقع والمنتديات جزيل الشكر ووافر الاحترام والسلام عليكم ورحمة الله وبركاته[/SIZE] |
مواقع النشر (المفضلة) |
| |
المواضيع المتشابهه | ||||
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
[ طلب تعديل ] مطلوب تعديل اضافة اسم القسم | محروم.كوم | منتدى أخبار المواقع والمنتديات العربية والأجنبية | 0 | 08-15-2013 06:30 PM |
الان ميز القسم الرمضاني بحركه رائعه غير تلوين القسم ادخل وشوف | محروم.كوم | منتدى أخبار المواقع والمنتديات العربية والأجنبية | 0 | 08-30-2009 06:08 PM |
الان ميز القسم الرمضاني بحركه رائعه غير تلوين القسم ادخل وشوف | محروم.كوم | منتدى أخبار المواقع والمنتديات العربية والأجنبية | 0 | 08-25-2009 12:20 PM |
الان ميز القسم الرمضاني بحركه رائعه غير تلوين القسم ادخل وشوف | محروم.كوم | منتدى أخبار المواقع والمنتديات العربية والأجنبية | 0 | 08-25-2009 12:00 PM |
برنامج حظر المكالمات (تم تعديل العنوان و نقله الى القسم الصحيح) | محروم.كوم | منتدى أخبار المواقع والمنتديات العربية والأجنبية | 0 | 05-06-2009 07:00 PM |