منتدى استراحات زايد

منتدى استراحات زايد (http://vb.ma7room.com/index.php)
-   منتدى أخبار المواقع والمنتديات العربية والأجنبية (http://vb.ma7room.com/forumdisplay.php?f=183)
-   -   الى العباقرة فى القسم طلب تعديل ملف FeedParser.php (http://vb.ma7room.com/showthread.php?t=1336377)

محروم.كوم 12-14-2013 07:20 PM

الى العباقرة فى القسم طلب تعديل ملف FeedParser.php
 
رمز PHP:
'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','DC:DATE');
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]


الساعة الآن 12:01 PM

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.5.2 TranZ By Almuhajir


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227