From 831c10d03192413b75ee2be21fb314e0797fdc23 Mon Sep 17 00:00:00 2001 From: Hakan Sandell Date: Sat, 2 Oct 2010 17:06:59 +0200 Subject: [PATCH 001/110] Fixed bug FS2030 JpegMeta dies on parsing XMP --- inc/JpegMeta.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php index 98453131e..fa05f6859 100644 --- a/inc/JpegMeta.php +++ b/inc/JpegMeta.php @@ -1488,6 +1488,8 @@ class JpegMeta { * @author Hakan Sandell */ function _parseXmpNode($values, &$i, &$meta) { + if ($values[$i]['type'] == 'close') return; + if ($values[$i]['type'] == 'complete') { // Simple Type property $meta = $values[$i]['value']; @@ -1501,14 +1503,16 @@ class JpegMeta { while ($values[++$i]['tag'] == 'rdf:li') { $this->_parseXmpNode($values, $i, $meta[]); } - $i++; // skip closing tag + $i++; // skip closing Bag/Seq tag } elseif ($values[$i]['tag'] == 'rdf:Alt') { // Language Alternative property, only the first (default) value is used - $i++; - $this->_parseXmpNode($values, $i, $meta); - while ($values[++$i]['tag'] != 'rdf:Alt'); - $i++; // skip closing tag + if ($values[$i]['type'] == 'open') { + $i++; + $this->_parseXmpNode($values, $i, $meta); + while ($values[++$i]['tag'] != 'rdf:Alt'); + $i++; // skip closing Alt tag + } } else { // Structure property From c277a6bdf6a2286eadaba9b8ad5c638b9d50922b Mon Sep 17 00:00:00 2001 From: Tom N Harris Date: Thu, 21 Oct 2010 13:20:08 -0400 Subject: [PATCH 002/110] Deprecate html_attbuild in favor of buildAttributes --- inc/form.php | 4 ++-- inc/html.php | 1 + lib/plugins/acl/admin.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/inc/form.php b/inc/form.php index 70190d2b4..e614d2f30 100644 --- a/inc/form.php +++ b/inc/form.php @@ -252,7 +252,7 @@ class Doku_Form { global $lang; $form = ''; $this->params['accept-charset'] = $lang['encoding']; - $form .= '
params) . '>
' . DOKU_LF; + $form .= 'params,true) . '>
' . DOKU_LF; if (!empty($this->_hidden)) { foreach ($this->_hidden as $name=>$value) $form .= form_hidden(array('name'=>$name, 'value'=>$value)); @@ -597,7 +597,7 @@ function form_makeListboxField($name, $values, $selected='', $label=null, $id='' * @author Tom N Harris */ function form_tag($attrs) { - return '<'.$attrs['_tag'].' '.buildAttributes($attrs).'/>'; + return '<'.$attrs['_tag'].' '.buildAttributes($attrs,true).'/>'; } /** diff --git a/inc/html.php b/inc/html.php index 02afa00e9..a02cc020d 100644 --- a/inc/html.php +++ b/inc/html.php @@ -26,6 +26,7 @@ function html_wikilink($id,$name=null,$search=''){ /** * Helps building long attribute lists * + * @deprecated Use buildAttributes instead * @author Andreas Gohr */ function html_attbuild($attributes){ diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php index 84932f7ac..3e7bd8121 100644 --- a/lib/plugins/acl/admin.php +++ b/lib/plugins/acl/admin.php @@ -765,7 +765,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { //build code $ret .= ''.NL; } From ba9418bca378a6759305e3b388926df4f5a0af9c Mon Sep 17 00:00:00 2001 From: Hakan Sandell Date: Sat, 13 Nov 2010 18:20:28 +0100 Subject: [PATCH 003/110] Added XMLRPC dokuwiki:appendPage --- lib/exe/xmlrpc.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index f06792361..8c2bec6f9 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -7,7 +7,7 @@ if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); /** * Increased whenever the API is changed */ -define('DOKU_XMLRPC_API_VERSION',4); +define('DOKU_XMLRPC_API_VERSION',5); require_once(DOKU_INC.'inc/init.php'); session_write_close(); //close session @@ -143,6 +143,13 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { true ); + $this->addCallback( + 'dokuwiki.appendPage', + 'this:appendPage', + array('int', 'string', 'string', 'struct'), + 'Append text to a wiki page.' + ); + /* Wiki API v2 http://www.jspwiki.org/wiki/WikiRPCInterface2 */ $this->addCallback( 'wiki.getRPCVersionSupported', @@ -577,6 +584,17 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return 0; } + /** + * Appends text to a wiki page. + */ + function appendPage($id, $text, $params) { + $currentpage = $this->rawPage($id); + if (!is_string($currentpage)) { + return $currentpage; + } + return $this->putPage($id, $currentpage.$text, $params); + } + /** * Uploads a file to the wiki. * From dc9bdeadf4b4eeacd7b6c7a51269a4400e4d25d8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 18 Nov 2010 22:42:42 +0100 Subject: [PATCH 004/110] Improve native JSON usage This patch does two things: It makes sure the native json_decode() will honor the JSON_LOOSETYPE option of the class and it also adds way to skip the use of the native function completely. The latter is necessary for slightly non-standard JSON data. --- inc/JSON.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/inc/JSON.php b/inc/JSON.php index d1fbd404a..2dea44003 100644 --- a/inc/JSON.php +++ b/inc/JSON.php @@ -112,6 +112,16 @@ define('JSON_STRICT_TYPE', 11); * @deprecated */ class JSON { + + /** + * Disables the use of PHP5's native json_decode() + * + * You shouldn't change this usually because the native function is much + * faster. However, this non-native will also parse slightly broken JSON + * which might be handy when talking to a non-conform endpoint + */ + public $skipnative = false; + /** * constructs a new JSON instance * @@ -366,7 +376,10 @@ class JSON { * @access public */ function decode($str) { - if (function_exists('json_decode')) return json_decode($str); + if (!$this->skipnative && function_exists('json_decode')){ + return json_decode($str,($this->use == JSON_LOOSE_TYPE)); + } + $str = $this->reduce_string($str); switch (strtolower($str)) { From 7ae265d3e681ebbb637211616aac15b18b8689a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20=C5=A0vec?= Date: Thu, 18 Nov 2010 22:46:18 +0100 Subject: [PATCH 005/110] Czech language update --- inc/lang/cs/lang.php | 4 ++-- inc/lang/cs/subscr_form.txt | 2 +- lib/plugins/config/lang/cs/intro.txt | 2 +- lib/plugins/config/lang/cs/lang.php | 10 +++++----- lib/plugins/plugin/lang/cs/lang.php | 4 ++-- lib/plugins/popularity/lang/cs/intro.txt | 2 +- lib/plugins/revert/lang/cs/intro.txt | 2 +- lib/plugins/usermanager/lang/cs/lang.php | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/inc/lang/cs/lang.php b/inc/lang/cs/lang.php index 33c6db01a..749a41a5b 100644 --- a/inc/lang/cs/lang.php +++ b/inc/lang/cs/lang.php @@ -242,7 +242,7 @@ $lang['i_wikiname'] = 'Název wiki'; $lang['i_enableacl'] = 'Zapnout ACL (doporučeno)'; $lang['i_superuser'] = 'Správce'; $lang['i_problems'] = 'Instalátor narazil na níže popsané problémy. Nelze pokračovat v instalaci, dokud je neopravíte.'; -$lang['i_modified'] = 'Instalátor bude z bezpečnostních důvodů pracovat pouze s čistou a ještě neupravenou instalací DokuWiki. Buď znovu rozbalte souboru z instalačního balíčku nebo se zkuste poradit s instrukcemi pro instalci DokuWiki.'; +$lang['i_modified'] = 'Instalátor bude z bezpečnostních důvodů pracovat pouze s čistou a ještě neupravenou instalací DokuWiki. Buď znovu rozbalte souboru z instalačního balíčku nebo se zkuste poradit s instrukcemi pro instalaci DokuWiki.'; $lang['i_funcna'] = 'PHP funkce %s není dostupná. Váš webhosting ji možná z nějakého důvodu vypnul.'; $lang['i_phpver'] = 'Verze vaší instalace PHP %s je nižší než požadovaná %s. Budete muset aktualizovat svou instalaci PHP.'; $lang['i_permfail'] = 'DokuWiki nemůže zapisovat do %s. Budete muset opravit práva k tomuto adresáři.'; @@ -268,7 +268,7 @@ $lang['mu_toobig'] = 'příliš velké'; $lang['mu_ready'] = 'připraveno k načtení'; $lang['mu_done'] = 'hotovo'; $lang['mu_fail'] = 'selhalo'; -$lang['mu_authfail'] = 'vypršla session'; +$lang['mu_authfail'] = 'vypršela session'; $lang['mu_progress'] = '@PCT@% načten'; $lang['mu_filetypes'] = 'Povolené typy souborů'; $lang['mu_info'] = 'soubory načteny.'; diff --git a/inc/lang/cs/subscr_form.txt b/inc/lang/cs/subscr_form.txt index b786ac137..d051b646f 100644 --- a/inc/lang/cs/subscr_form.txt +++ b/inc/lang/cs/subscr_form.txt @@ -1,3 +1,3 @@ ====== Správa odběratelů změn ====== -Tato stránka Vám umožnuje spravovat uživatele přihlášené k odběru změn aktuální stránky nebo jmenného prostoru. \ No newline at end of file +Tato stránka Vám umožňuje spravovat uživatele přihlášené k odběru změn aktuální stránky nebo jmenného prostoru. \ No newline at end of file diff --git a/lib/plugins/config/lang/cs/intro.txt b/lib/plugins/config/lang/cs/intro.txt index bad92ac8e..63381b84e 100644 --- a/lib/plugins/config/lang/cs/intro.txt +++ b/lib/plugins/config/lang/cs/intro.txt @@ -2,7 +2,7 @@ Tuto stránku můžete používat ke správě nastavení vaší instalace DokuWiki. Nápovědu pro konkrétní položky nastavení naleznete na [[doku>config]]. Pro další detaily o tomto pluginu viz [[doku>plugin:config]]. -Položky se světle červeným pozadím jsou chráněné a nelze je upravovat tímto pluginem. Položky s modrým pozadím jsou výchozí hodnoty a položky s bílým pozadím byly nastaveny lokálně v této konktétní instalaci. Modré i bílé položky je možné upravovat. +Položky se světle červeným pozadím jsou chráněné a nelze je upravovat tímto pluginem. Položky s modrým pozadím jsou výchozí hodnoty a položky s bílým pozadím byly nastaveny lokálně v této konkrétní instalaci. Modré i bílé položky je možné upravovat. Než opustíte tuto stránku, nezapomeňte stisknout tlačítko **Uložit**, jinak budou změny ztraceny. diff --git a/lib/plugins/config/lang/cs/lang.php b/lib/plugins/config/lang/cs/lang.php index 3f8c05f26..06839c1d0 100644 --- a/lib/plugins/config/lang/cs/lang.php +++ b/lib/plugins/config/lang/cs/lang.php @@ -11,7 +11,7 @@ */ $lang['menu'] = 'Správa nastavení'; $lang['error'] = 'Nastavení nebyla změněna kvůli alespoň jedné neplatné položce, -zkotrolujte prosím své úpravy a odešlete je znovu.
+zkontrolujte prosím své úpravy a odešlete je znovu.
Neplatné hodnoty se zobrazí v červeném rámečku.'; $lang['updated'] = 'Nastavení byla úspěšně upravena.'; $lang['nochoice'] = '(nejsou k dispozici žádné další volby)'; @@ -69,10 +69,10 @@ $lang['useheading'] = 'Používat první nadpis jako název stránky' $lang['refcheck'] = 'Kontrolovat odkazy na média (před vymazáním)'; $lang['refshow'] = 'Počet zobrazených odkazů na média'; $lang['allowdebug'] = 'Povolit debugování. Vypněte, pokud to nepotřebujete!'; -$lang['usewordblock'] = 'Blokovat spam za použítí seznamu známých spamových slov'; +$lang['usewordblock'] = 'Blokovat spam za použití seznamu známých spamových slov'; $lang['indexdelay'] = 'Časová prodleva před indexací (v sekundách)'; $lang['relnofollow'] = 'Používat rel="nofollow" na externí odkazy'; -$lang['mailguard'] = 'Metoda "zamaskování" emailových addres'; +$lang['mailguard'] = 'Metoda "zamaskování" emailových adres'; $lang['iexssprotect'] = 'Zkontrolovat nahrané soubory vůči možnému škodlivému JavaScriptu či HTML'; $lang['showuseras'] = 'Co se má přesně zobrazit, když se ukazuje uživatel, který naposledy editoval stránku'; $lang['useacl'] = 'Používat přístupová práva (ACL)'; @@ -95,7 +95,7 @@ vnořené jmenné prostory, k nimž právo má, budou přesto skryty. To může mít za následek, že index bude při některých nastaveních ACL nepoužitelný.'; $lang['auth_security_timeout'] = 'Časový limit pro autentikaci (v sekundách)'; -$lang['securecookie'] = 'Má prohlížeč posílat cookies nastavené přes HTTPS opět jen přes HTTPS? Vypňete tuto volbu, pokud chcete, aby bylo pomocí SSL zabezpečeno pouze přihlašování do wiki, ale obsah budete prohlížet nezabezpečeně.'; +$lang['securecookie'] = 'Má prohlížeč posílat cookies nastavené přes HTTPS opět jen přes HTTPS? Vypněte tuto volbu, pokud chcete, aby bylo pomocí SSL zabezpečeno pouze přihlašování do wiki, ale obsah budete prohlížet nezabezpečeně.'; $lang['xmlrpc'] = 'Povolit/Zakázat rozhraní XML-RPC.'; $lang['xmlrpcuser'] = 'Omezit přístup pomocí XML-RPC pouze na zde zadané skupiny či uživatele (oddělené čárkami). Necháte-li pole prázdné, dáte přístup komukoliv.'; $lang['updatecheck'] = 'Kontrolovat aktualizace a bezpečnostní varování? DokuWiki potřebuje pro tuto funkci přístup k splitbrain.org'; @@ -112,7 +112,7 @@ $lang['locktime'] = 'Maximální životnost zámkových souborů (v $lang['fetchsize'] = 'Maximální velikost souboru (v bajtech), co ještě fetch.php bude stahovat z externích zdrojů'; $lang['notify'] = 'Posílat oznámení o změnách na následující emailovou adresu'; $lang['registernotify'] = 'Posílat informace o nově registrovaných uživatelích na tuto mailovou adresu'; -$lang['mailfrom'] = 'Emailová addresa, která se bude používat pro automatické maily'; +$lang['mailfrom'] = 'Emailová adresa, která se bude používat pro automatické maily'; $lang['gzip_output'] = 'Používat pro xhtml Content-Encoding gzip'; $lang['gdlib'] = 'Verze GD knihovny'; $lang['im_convert'] = 'Cesta k nástroji convert z balíku ImageMagick'; diff --git a/lib/plugins/plugin/lang/cs/lang.php b/lib/plugins/plugin/lang/cs/lang.php index c15a5ca21..54de0ff18 100644 --- a/lib/plugins/plugin/lang/cs/lang.php +++ b/lib/plugins/plugin/lang/cs/lang.php @@ -26,7 +26,7 @@ $lang['source'] = 'Zdroj:'; $lang['unknown'] = 'neznámý'; $lang['updating'] = 'Aktualizuji ...'; $lang['updated'] = 'Modul %s úspěšně aktualizován'; -$lang['updates'] = 'Následjící pluginy byly úspěšně aktualizovány'; +$lang['updates'] = 'Následující pluginy byly úspěšně aktualizovány'; $lang['update_none'] = 'Žádné aktualizace nenalezeny.'; $lang['deleting'] = 'Probíhá mazání ...'; $lang['deleted'] = 'Plugin %s smazán.'; @@ -49,7 +49,7 @@ $lang['error_download'] = 'Nelze stáhnout soubor s pluginem: %s'; $lang['error_badurl'] = 'URL je zřejmě chybná - nelze z ní určit název souboru'; $lang['error_dircreate'] = 'Nelze vytvořit dočasný adresář ke stažení dat'; $lang['error_decompress'] = 'Správce pluginů nemůže rozbalit stažený soubor. Toto může být způsobeno chybou při stahování. Můžete se pokusit stahování opakovat. Chyba může být také v kompresním formátu souboru. V tom případě bude nutné stáhnout a nainstalovat plugin ručně.'; -$lang['error_copy'] = 'Došlo k chybě při instalaci pluginu %s. Je možné, že na disku není volné místo, nebo mohou být špatně nastavena přístupová práva. Pozor, mohlo dojít k častečné a tudíž chybné instalaci pluginu a tím může být ohrožena stabilita wiki.'; +$lang['error_copy'] = 'Došlo k chybě při instalaci pluginu %s. Je možné, že na disku není volné místo, nebo mohou být špatně nastavena přístupová práva. Pozor, mohlo dojít k částečné a tudíž chybné instalaci pluginu a tím může být ohrožena stabilita wiki.'; $lang['error_delete'] = 'Došlo k chybě při pokusu o smazání pluginu %s. Nejspíše je chyba v nastavení přístupových práv k některým souborům či adresářům.'; $lang['enabled'] = 'Plugin %s aktivován.'; $lang['notenabled'] = 'Plugin %s nelze aktivovat, zkontrolujte práva k souborům.'; diff --git a/lib/plugins/popularity/lang/cs/intro.txt b/lib/plugins/popularity/lang/cs/intro.txt index 70cf1a42c..4b386568a 100644 --- a/lib/plugins/popularity/lang/cs/intro.txt +++ b/lib/plugins/popularity/lang/cs/intro.txt @@ -1,6 +1,6 @@ ===== Průzkum používání ===== -Tento nástroj jednorázově shromáží anonymní data o vaší wiki a umožní vám odeslat je vývojářům DokuWiki. To jim pomůže lépe porozumět, jak uživatelé DokuWiki používají, a jejich rozhodnutí při dalším vývoji budou založena na statistikách z reálného používání DokuWiki. +Tento nástroj jednorázově shromáždí anonymní data o vaší wiki a umožní vám odeslat je vývojářům DokuWiki. To jim pomůže lépe porozumět, jak uživatelé DokuWiki používají, a jejich rozhodnutí při dalším vývoji budou založena na statistikách z reálného používání DokuWiki. Chcete-li pomoci vývojářům, čas od času, jak vaše wiki poroste, použijte tento nástroj. Vaše data budou pokaždé označena stejným anonymním identifikátorem. diff --git a/lib/plugins/revert/lang/cs/intro.txt b/lib/plugins/revert/lang/cs/intro.txt index bbc0df25a..1e1cd0fd8 100644 --- a/lib/plugins/revert/lang/cs/intro.txt +++ b/lib/plugins/revert/lang/cs/intro.txt @@ -1,3 +1,3 @@ ====== Obnova zaspamovaných stránek ====== -Tato stránka pomůže při automatické obnově po spamovém útoku. Pro nalezení seznamu zaspamovaných stránek nedřív zadejte hledaný výraz (např. spamové URL) a pak potvrďte, že nalezené stránky opravdu obsahují spam a mohou být obnoveny. +Tato stránka pomůže při automatické obnově po spamovém útoku. Pro nalezení seznamu zaspamovaných stránek nejdříve zadejte hledaný výraz (např. spamové URL) a pak potvrďte, že nalezené stránky opravdu obsahují spam a mohou být obnoveny. diff --git a/lib/plugins/usermanager/lang/cs/lang.php b/lib/plugins/usermanager/lang/cs/lang.php index 9c5a2abc9..7d8e4599d 100644 --- a/lib/plugins/usermanager/lang/cs/lang.php +++ b/lib/plugins/usermanager/lang/cs/lang.php @@ -45,7 +45,7 @@ $lang['edit_usermissing'] = 'Vybraný uživatel nebyl nalezen, zadané uži $lang['user_notify'] = 'Upozornit uživatele'; $lang['note_notify'] = 'Maily s upozorněním se budou posílat pouze, když uživatel dostává nové heslo.'; $lang['note_group'] = 'Noví uživatelé budou přidáváni do této výchozí skupiny (%s), pokud pro ně není uvedena žádná skupina.'; -$lang['note_pass'] = 'Heslo bude automaticky vygenerováno pokud je pole ponacháno prázdné a je zapnutá notifikace uživatele.'; +$lang['note_pass'] = 'Heslo bude automaticky vygenerováno pokud je pole ponecháno prázdné a je zapnutá notifikace uživatele.'; $lang['add_ok'] = 'Uživatel úspěšně vytvořen'; $lang['add_fail'] = 'Vytvoření uživatele selhalo'; $lang['notify_ok'] = 'Odeslán mail s upozorněním'; From 11d7187b1b2e7bddc70324b865e01e750c5df162 Mon Sep 17 00:00:00 2001 From: YooS C Date: Thu, 18 Nov 2010 22:47:25 +0100 Subject: [PATCH 006/110] Korean language update --- inc/lang/ko/adminplugins.txt | 1 + inc/lang/ko/edit.txt | 2 +- inc/lang/ko/lang.php | 80 +++++++++++++++++++----- inc/lang/ko/register.txt | 2 +- inc/lang/ko/subscr_digest.txt | 18 ++++++ inc/lang/ko/subscr_form.txt | 3 + inc/lang/ko/subscr_list.txt | 15 +++++ inc/lang/ko/subscr_single.txt | 21 +++++++ lib/plugins/acl/lang/ko/lang.php | 1 + lib/plugins/config/lang/ko/lang.php | 8 ++- lib/plugins/plugin/lang/ko/lang.php | 1 + lib/plugins/popularity/lang/ko/lang.php | 1 + lib/plugins/revert/lang/ko/lang.php | 1 + lib/plugins/usermanager/lang/ko/lang.php | 1 + 14 files changed, 137 insertions(+), 18 deletions(-) create mode 100644 inc/lang/ko/adminplugins.txt create mode 100644 inc/lang/ko/subscr_digest.txt create mode 100644 inc/lang/ko/subscr_form.txt create mode 100644 inc/lang/ko/subscr_list.txt create mode 100644 inc/lang/ko/subscr_single.txt diff --git a/inc/lang/ko/adminplugins.txt b/inc/lang/ko/adminplugins.txt new file mode 100644 index 000000000..5312cf357 --- /dev/null +++ b/inc/lang/ko/adminplugins.txt @@ -0,0 +1 @@ +===== 부가적인 플러그인 ===== \ No newline at end of file diff --git a/inc/lang/ko/edit.txt b/inc/lang/ko/edit.txt index d73f935fe..9b59524f7 100644 --- a/inc/lang/ko/edit.txt +++ b/inc/lang/ko/edit.txt @@ -1,2 +1,2 @@ -페이지를 편집하고 **저장**을 누르십시오. 위키 구문은 [[wiki:syntax]] 혹은 [[syntax|(한글) 구문]]을 참고하십시오. 이 페이지를 **더 낫게 만들 자신이 있을** 때에만 편집하십시오. 실험을 하고 싶을 때에는, 먼저 [[playground:playground|연습장]] 에 가서 연습해 보십시오. +페이지를 편집하고 **저장**을 누르십시오. 위키 구문은 [[wiki:syntax]] 혹은 [[wiki:ko_syntax|(한글) 구문]]을 참고하십시오. 이 페이지를 **더 낫게 만들 자신이 있을** 때에만 편집하십시오. 실험을 하고 싶을 때에는, 먼저 [[playground:playground|연습장]] 에 가서 연습해 보십시오. diff --git a/inc/lang/ko/lang.php b/inc/lang/ko/lang.php index 83014c151..3765dd011 100644 --- a/inc/lang/ko/lang.php +++ b/inc/lang/ko/lang.php @@ -8,6 +8,7 @@ * @author dongnak@gmail.com * @author Song Younghwan * @author SONG Younghwan + * @author Seung-Chul Yoo */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'ltr'; @@ -41,15 +42,13 @@ $lang['btn_back'] = '뒤로'; $lang['btn_backlink'] = '이전 링크'; $lang['btn_backtomedia'] = '미디어 파일 선택으로 돌아가기'; $lang['btn_subscribe'] = '구독 신청'; -$lang['btn_unsubscribe'] = '구독 신청 해지'; -$lang['btn_subscribens'] = '네임스페이스 구독 신청'; -$lang['btn_unsubscribens'] = '네임스페이스 구독 신청 해지'; $lang['btn_profile'] = '개인정보 변경'; $lang['btn_reset'] = '초기화'; $lang['btn_resendpwd'] = '새 패스워드 보내기'; $lang['btn_draft'] = '문서초안 편집'; $lang['btn_recover'] = '문서초안 복구'; $lang['btn_draftdel'] = '문서초안 삭제'; +$lang['btn_revert'] = '복원'; $lang['loggedinas'] = '다음 사용자로 로그인'; $lang['user'] = '사용자'; $lang['pass'] = '패스워드'; @@ -88,13 +87,45 @@ $lang['resendpwdconfirm'] = '확인 링크를 이메일로 보냈습니다. $lang['resendpwdsuccess'] = '새로운 패스워드는 이메일로 보내드립니다.'; $lang['license'] = '이 위키의 내용은 다음의 라이센스에 따릅니다 :'; $lang['licenseok'] = '주의 : 이 페이지를 수정한다는 다음의 라이센스에 동의함을 의미합니다 :'; +$lang['searchmedia'] = '파일이름 찾기:'; +$lang['searchmedia_in'] = ' %에서 검색'; $lang['txt_upload'] = '업로드 파일을 선택합니다.'; $lang['txt_filename'] = '업로드 파일 이름을 입력합니다.(선택 사항)'; $lang['txt_overwrt'] = '새로운 파일로 이전 파일을 교체합니다.'; $lang['lockedby'] = '현재 잠금 사용자'; $lang['lockexpire'] = '잠금 해제 시간'; $lang['willexpire'] = '잠시 후 편집 잠금이 해제됩니다.\n편집 충돌을 피하려면 미리보기를 눌러 잠금 시간을 다시 설정하기 바랍니다.'; -$lang['js']['notsavedyet'] = "저장하지 않은 변경은 지워집니다.\n계속하시겠습니까?"; +$lang['js']['notsavedyet'] = '저장하지 않은 변경은 지워집니다. +계속하시겠습니까?'; +$lang['js']['searchmedia'] = '파일 찾기'; +$lang['js']['keepopen'] = '선택할 때 윈도우를 열어놓으시기 바랍니다.'; +$lang['js']['hidedetails'] = '자세한 정보 감추기'; +$lang['js']['mediatitle'] = '링크 설정'; +$lang['js']['mediadisplay'] = '링크 형태'; +$lang['js']['mediaalign'] = '배치'; +$lang['js']['mediasize'] = '그림 크기'; +$lang['js']['mediatarget'] = '링크 목표'; +$lang['js']['mediaclose'] = '닫기'; +$lang['js']['mediainsert'] = '삽입'; +$lang['js']['mediadisplayimg'] = '그림보기'; +$lang['js']['mediasmall'] = '작게'; +$lang['js']['mediamedium'] = '중간'; +$lang['js']['medialarge'] = '크게'; +$lang['js']['mediaoriginal'] = '원본'; +$lang['js']['medialnk'] = '세부정보페이지로 링크'; +$lang['js']['mediadirect'] = '원본으로 직접 링크'; +$lang['js']['medianolnk'] = '링크 없슴'; +$lang['js']['medianolink'] = '그림을 링크하지 않음'; +$lang['js']['medialeft'] = '왼쪽 배치'; +$lang['js']['mediaright'] = '오른쪽 배치'; +$lang['js']['mediacenter'] = '중앙 배치'; +$lang['js']['medianoalign'] = '배치 없슴'; +$lang['js']['nosmblinks'] = '윈도우 공유 파일과의 연결은 MS 인터넷 익스플로러에서만 동작합니다. +그러나 링크를 복사하거나 붙여넣기를 할 수 있습니다.'; +$lang['js']['linkwiz'] = '링크 마법사'; +$lang['js']['linkto'] = '다음으로 연결:'; +$lang['js']['del_confirm'] = '정말로 선택된 항목(들)을 삭제하시겠습니까?'; +$lang['js']['mu_btn'] = '여러 파일들을 한번에 업로드합니다.'; $lang['rssfailed'] = 'feed 가져오기 실패: '; $lang['nothingfound'] = '아무 것도 없습니다.'; $lang['mediaselect'] = '미디어 파일 선택'; @@ -112,11 +143,7 @@ $lang['deletefail'] = '"%s" 파일을 삭제할 수 없습니다. - $lang['mediainuse'] = '"%s" 파일을 삭제할 수 없습니다. - 아직 사용 중입니다.'; $lang['namespaces'] = '네임스페이스'; $lang['mediafiles'] = '사용 가능한 파일 목록'; -$lang['js']['keepopen'] = '선택할 때 윈도우를 열어놓으시기 바랍니다.'; -$lang['js']['hidedetails'] = '자세한 정보 감추기'; -$lang['js']['nosmblinks'] = '윈도우 공유 파일과의 연결은 MS 인터넷 익스플로러에서만 동작합니다. -그러나 링크를 복사하거나 붙여넣기를 할 수 있습니다.'; -$lang['js']['mu_btn'] = '여러 파일들을 한번에 업로드합니다.'; +$lang['accessdenied'] = '이 페이지를 볼 권한이 없습니다.'; $lang['mediausage'] = '이 파일을 참조하려면 다음 문법을 사용하기 바랍니다:'; $lang['mediaview'] = '원본 파일 보기'; $lang['mediaroot'] = '루트(root)'; @@ -143,8 +170,10 @@ $lang['restored'] = '옛 버전 복구'; $lang['external_edit'] = '외부 편집기'; $lang['summary'] = '편집 요약'; $lang['noflash'] = '이 컨텐츠를 표시하기 위해서 Adobe Flash Plugin이 필요합니다.'; +$lang['download'] = '조각 다운로드'; $lang['mail_newpage'] = '페이지 추가:'; $lang['mail_changed'] = '페이지 변경:'; +$lang['mail_subscribe_list'] = '네임스페이스에서 변경된 페이지:'; $lang['mail_new_user'] = '새로운 사용자:'; $lang['mail_upload'] = '파일 첨부:'; $lang['qb_bold'] = '굵은 글'; @@ -157,6 +186,11 @@ $lang['qb_h2'] = '2단계 헤드라인'; $lang['qb_h3'] = '3단계 헤드라인'; $lang['qb_h4'] = '4단계 헤드라인'; $lang['qb_h5'] = '5단계 헤드라인'; +$lang['qb_h'] = '표제'; +$lang['qb_hs'] = '표제 선택'; +$lang['qb_hplus'] = '상위 표제'; +$lang['qb_hminus'] = '하위 표제'; +$lang['qb_hequal'] = '동급 표제'; $lang['qb_link'] = '내부 링크'; $lang['qb_extlink'] = '외부 링크'; $lang['qb_hr'] = '수평선'; @@ -166,7 +200,7 @@ $lang['qb_media'] = '이미지와 기타 파일 추가'; $lang['qb_sig'] = '서명 추가'; $lang['qb_smileys'] = '이모티콘'; $lang['qb_chars'] = '특수문자'; -$lang['js']['del_confirm'] = '정말로 선택된 항목(들)을 삭제하시겠습니까?'; +$lang['upperns'] = '상위 네임스페이스로 이동'; $lang['admin_register'] = '새로운 사용자 추가'; $lang['metaedit'] = '메타 데이타를 편집합니다.'; $lang['metasaveerr'] = '메타 데이타 쓰기가 실패했습니다.'; @@ -182,11 +216,16 @@ $lang['img_copyr'] = '저작권'; $lang['img_format'] = '포맷'; $lang['img_camera'] = '카메라'; $lang['img_keywords'] = '키워드'; -$lang['subscribe_success'] = '%s를 추가했습니다. (%s의 구독 목록)'; -$lang['subscribe_error'] = '%s를 추가하는데 실패했습니다.(%s의 구독 목록)'; -$lang['subscribe_noaddress'] = '로그인 정보에 이메일 주소가 없습니다, 구독 목록에 추가할 수 없습니다.'; -$lang['unsubscribe_success'] = '%s를 제외시켰습니다. (%s의 구독 목록)'; -$lang['unsubscribe_error'] = '%s를 제외시키는데 실패했습니다.(%s의 구독 목록)'; +$lang['subscr_subscribe_noaddress'] = '등록된 주소가 없기 때문에 구독목록에 등록되지 않았습니다.'; +$lang['subscr_m_not_subscribed'] = '현재의 페이지나 네임스페이스에 구독등록이 되어있지 않습니다.'; +$lang['subscr_m_new_header'] = '구독 추가'; +$lang['subscr_m_current_header'] = '현재 구독중인 것들'; +$lang['subscr_m_unsubscribe'] = '구독 취소'; +$lang['subscr_m_subscribe'] = '구독'; +$lang['subscr_m_receive'] = '받기'; +$lang['subscr_style_every'] = '모든 변화를 이메일로 받기'; +$lang['subscr_style_digest'] = '각 페이지의 변화를 요약 (매 %.2f 일 마다)'; +$lang['subscr_style_list'] = '마지막 이메일 이후 변화된 페이지의 목록 (매 %.2f 일 마다)'; $lang['authmodfailed'] = '잘못된 사용자 인증 설정입니다. 관리자에게 문의하기 바랍니다.'; $lang['authtempfail'] = '사용자 인증이 일시적으로 불가능합니다. 만일 계속해서 문제가 발생하면 관리자에게 문의하기 바랍니다.'; $lang['i_chooselang'] = '사용하는 언어를 선택합니다.'; @@ -213,6 +252,7 @@ $lang['i_pol0'] = '개방형 위키 (누구나 읽기/쓰기/업 $lang['i_pol1'] = '공개형 위키 (누구나 읽을 수 있지만, 등록된 사용자만 쓰기/업로드가 가능합니다.)'; $lang['i_pol2'] = '폐쇄형 위키 (등록된 사용자만 읽기/쓰기/업로드가 가능합니다.)'; $lang['i_retry'] = '다시 시도'; +$lang['i_license'] = '내용의 배포를 위한 라이센스를 선택하세요.'; $lang['mu_intro'] = '여러 파일을 한번에 업로드할 수 있습니다. 파일 목록에 추가하려면 "찾기" 버튼을 클릭합니다. 파일 목록 추가 작업이 끝나면 "업로드" 버튼을 클릭하기 바랍니다. '; $lang['mu_gridname'] = '파일명'; $lang['mu_gridsize'] = '크기'; @@ -226,4 +266,14 @@ $lang['mu_fail'] = '업로드가 실패했습니다.'; $lang['mu_authfail'] = '세션 기간이 종료되었습니다.'; $lang['mu_progress'] = '@PCT@% 업로드되었습니다.'; $lang['mu_filetypes'] = '허용된 파일타입'; +$lang['mu_info'] = '업로드 되었습니다.'; +$lang['mu_lasterr'] = '마지막 에러:'; $lang['recent_global'] = '%s 네임스페이스를 구독중입니다. 전체위키 변경사항 도 보실수 있습니다.'; +$lang['years'] = '%d 년 전'; +$lang['months'] = '%d 개월 전'; +$lang['weeks'] = '%d 주 전'; +$lang['days'] = '%d 일 전'; +$lang['hours'] = '%d 시간 전'; +$lang['minutes'] = '%d 분 전'; +$lang['seconds'] = '%d 초 전'; +$lang['wordblock'] = '스팸 문구를 포함하고 있어서 저장되지 않았습니다.'; diff --git a/inc/lang/ko/register.txt b/inc/lang/ko/register.txt index 999073a1d..24105efeb 100644 --- a/inc/lang/ko/register.txt +++ b/inc/lang/ko/register.txt @@ -1,4 +1,4 @@ ====== 새 사용자 등록 ====== -이 위키에 새 계정을 만들려면 아래의 모든 내용을 입력하십시오. **제대로 된 이메일 주소**를 사용하십시오. 그러나, 아래 내용을 입력했다고 해서 계정을 만들 수 있으리라고는 믿지 마십시오. 이곳은 내가 개인적으로 사용하는 곳이며, 계정을 만들어 주고 안주고는 내 마음입니다. 차라리, 내게 이메일을 보내서 신청하는 편이 더 나을 것입니다. 패스워드는 이 이메일로 보내집니다. 사용자명은 올바른 [[doku>pagename|pagename]] 이어야 합니다. +이 위키에 새 계정을 만들려면 아래의 모든 내용을 입력하세요. **제대로 된 이메일 주소**를 사용하세요. 암호를 입력하는 곳이 없다면 암호는 이 이메일로 보내집니다. 사용자명은 올바른 [[doku>pagename|pagename]] 이어야 합니다. diff --git a/inc/lang/ko/subscr_digest.txt b/inc/lang/ko/subscr_digest.txt new file mode 100644 index 000000000..2e9c87848 --- /dev/null +++ b/inc/lang/ko/subscr_digest.txt @@ -0,0 +1,18 @@ +안녕하세요! + +@TITLE@ 라는 제목의 페이지 @PAGE@ 가 변경되었습니다. + +변경사항은 다음과 같습니다: + +-------------------------------------------------------- +@DIFF@ +-------------------------------------------------------- + +옛날 것: @OLDPAGE@ +새 것: @NEWPAGE@ + +이 페이지 변경알림의 설정을 바구려면, @DOKUWIKIURL@에 로그인한 뒤 +@SUBSCRIBE@ 를 방문하여 페이지나 이름공간의 구독을 취소하세요. + +-- +@DOKUWIKIURL@의 DokuWiki가 자동으로 만들어낸 메일입니다. \ No newline at end of file diff --git a/inc/lang/ko/subscr_form.txt b/inc/lang/ko/subscr_form.txt new file mode 100644 index 000000000..31470f372 --- /dev/null +++ b/inc/lang/ko/subscr_form.txt @@ -0,0 +1,3 @@ +====== 구독 관리 ====== + +이 페이지는 현재의 페이지와 네임스페이스의 구독을 관리할 수있도록 해줍니다. \ No newline at end of file diff --git a/inc/lang/ko/subscr_list.txt b/inc/lang/ko/subscr_list.txt new file mode 100644 index 000000000..2661a6a15 --- /dev/null +++ b/inc/lang/ko/subscr_list.txt @@ -0,0 +1,15 @@ +안녕하세요! + +@TITLE@ 라는 제목의 페이지 @PAGE@ 가 변경되었습니다. + +변경사항은 다음과 같습니다: + +-------------------------------------------------------- +@DIFF@ +-------------------------------------------------------- + +이 페이지 변경알림의 설정을 바구려면, @DOKUWIKIURL@에 로그인한 뒤 +@SUBSCRIBE@ 를 방문하여 페이지나 이름공간의 구독을 취소하세요. + +-- +@DOKUWIKIURL@의 DokuWiki가 자동으로 만들어낸 메일입니다. \ No newline at end of file diff --git a/inc/lang/ko/subscr_single.txt b/inc/lang/ko/subscr_single.txt new file mode 100644 index 000000000..1aa4d7efa --- /dev/null +++ b/inc/lang/ko/subscr_single.txt @@ -0,0 +1,21 @@ +안녕하세요! + +@TITLE@ 라는 제목의 페이지 @PAGE@ 가 변경되었습니다. + +변경사항은 다음과 같습니다: + +-------------------------------------------------------- +@DIFF@ +-------------------------------------------------------- + +날짜 : @DATE@ +사용자 : @USER@ +편집 요약 : @SUMMARY@ +구 버전 : @OLDPAGE@ +새 버전 : @NEWPAGE@ + +이 페이지 변경알림의 설정을 바구려면, @DOKUWIKIURL@에 로그인한 뒤 t +@NEWPAGE@ 를 방문하여 페이지나 이름공간의 구독을 취소하세요. + +-- +@DOKUWIKIURL@의 DokuWiki가 자동으로 만들어낸 메일입니다. \ No newline at end of file diff --git a/lib/plugins/acl/lang/ko/lang.php b/lib/plugins/acl/lang/ko/lang.php index 43a5ceeeb..6f4e991cb 100644 --- a/lib/plugins/acl/lang/ko/lang.php +++ b/lib/plugins/acl/lang/ko/lang.php @@ -10,6 +10,7 @@ * @author dongnak@gmail.com * @author Song Younghwan * @author SONG Younghwan + * @author Seung-Chul Yoo */ $lang['admin_acl'] = '접근 제어 목록 관리'; $lang['acl_group'] = '그룹'; diff --git a/lib/plugins/config/lang/ko/lang.php b/lib/plugins/config/lang/ko/lang.php index efac643ab..13f5efefe 100644 --- a/lib/plugins/config/lang/ko/lang.php +++ b/lib/plugins/config/lang/ko/lang.php @@ -7,6 +7,7 @@ * @author dongnak@gmail.com * @author Song Younghwan * @author SONG Younghwan + * @author Seung-Chul Yoo */ $lang['menu'] = '환경 설정'; $lang['error'] = '잘못된 값때문에 설정들을 변경할 수 없습니다. 수정한 값들을 검사하고 확인을 누르기 바랍니다. @@ -89,12 +90,15 @@ $lang['sneaky_index'] = '기본적으로, DokuWiki는 색인 목록에 특정 ACL 설정은 색인 사용이 불가능하게 할 수도 있습니다.'; $lang['auth_security_timeout'] = '인증 보안 초과 시간(초)'; $lang['securecookie'] = 'HTTPS로 보내진 쿠키는 HTTPS에만 적용 할까요? 위키의 로그인 페이지만 SSL로 암호화 하고 위키 페이지는 그렇지 않은경우 꺼야 합니다.'; +$lang['xmlrpc'] = 'XML-RPC 인터페이스 지원/무시'; +$lang['xmlrpcuser'] = '주어진 그룹이나 유저들에게만 XML-RPC접근을 허락하려면 컴마로 구분하여 적으세요. 비어두면 모두에게 허용됩니다.'; $lang['updatecheck'] = '업데이트와 보안 문제를 검사(DokuWiki를 splitbrain.org에 연결해야 합니다.)'; $lang['userewrite'] = 'URL rewriting기능 사용'; $lang['useslash'] = 'URL에서 네임스페이스 구분자로 슬래쉬 문자 사용'; $lang['usedraft'] = '편집하는 동안 자동으로 문서 초안 저장'; $lang['sepchar'] = '페이지 이름 단어 구분자'; $lang['canonical'] = '완전한 canonical URL 사용'; +$lang['fnencode'] = '아스키가 아닌 파일이르믈 인코딩 하는 방법.'; $lang['autoplural'] = '링크 연결시 plural폼 검사'; $lang['compression'] = 'attic파일 압축 방법 선택'; $lang['cachetime'] = '최대 캐쉬 생존 시간(초)'; @@ -108,6 +112,7 @@ $lang['gdlib'] = 'GD 라이브러리 버전'; $lang['im_convert'] = 'ImageMagick 위치'; $lang['jpg_quality'] = 'JPG 압축 품질 (0-100)'; $lang['subscribers'] = '페이지 갱신 알람 기능'; +$lang['subscribe_time'] = ' 구독 목록과 요약이 보내질 경과 시간 (초); 이 것은 recent_days에서 설정된 시간보다 작아야 합니다.'; $lang['compress'] = '최적화된 CSS, javascript 출력'; $lang['hidepages'] = '매칭된 페이지 숨기기(정규표현식)'; $lang['send404'] = '존재하지 않는 페이지에 대해 "HTTP 404/Page Not Found" 응답'; @@ -115,7 +120,6 @@ $lang['sitemap'] = '구글 사이트맵 생성(날짜)'; $lang['broken_iua'] = '설치된 시스템에서 ignore_user_abort 기능에 문제가 있으면 색인이 정상적으로 동작하지 않습니다. 이 기능이 IIS+PHP/CGI에서 문제가 있는 것으로 알려졌습니다. 자세한 정보는 Bug 852를 참고하기 바랍니다.'; $lang['xsendfile'] = '웹 서버 static 파일 전송 지원을 위해 X-Sendfile 헤더를 사용한다면 이 옵션을 사용합니다. 웹 서버가 이 기능을 지원해야 합니다.'; -$lang['xmlrpc'] = 'XML-RPC 인터페이스 지원/무시'; $lang['renderer_xhtml'] = '주 (xhtml) 위키 출력 처리기'; $lang['renderer__core'] = '%s (DokuWiki 내부 기능)'; $lang['renderer__plugin'] = '%s (DokuWiki 플러그인)'; @@ -136,6 +140,7 @@ $lang['proxy____port'] = '프록시 서버 포트'; $lang['proxy____user'] = '프록시 사용자 이름'; $lang['proxy____pass'] = '프록시 패스워드'; $lang['proxy____ssl'] = '프록시 연결시 ssl사용'; +$lang['proxy____except'] = '프록시설정이 무시될 URL주소들의 RegEx형식표현'; $lang['safemodehack'] = 'safemode hack기능 사용'; $lang['ftp____host'] = 'safemode hack의 FTP 서버'; $lang['ftp____port'] = 'safemode hack의 FTP port'; @@ -183,3 +188,4 @@ $lang['useheading_o_0'] = '아니요'; $lang['useheading_o_navigation'] = '네비게이션에만'; $lang['useheading_o_content'] = '위키 내용에만'; $lang['useheading_o_1'] = '항상'; +$lang['readdircache'] = 'readdir 캐쉬를 위한 최대 시간 (초)'; diff --git a/lib/plugins/plugin/lang/ko/lang.php b/lib/plugins/plugin/lang/ko/lang.php index af14a0cd2..72c04ddab 100644 --- a/lib/plugins/plugin/lang/ko/lang.php +++ b/lib/plugins/plugin/lang/ko/lang.php @@ -7,6 +7,7 @@ * @author dongnak@gmail.com * @author Song Younghwan * @author SONG Younghwan + * @author Seung-Chul Yoo */ $lang['menu'] = '플러그인 관리자'; $lang['download'] = '새로운 플러그인 다운로드 및 설치'; diff --git a/lib/plugins/popularity/lang/ko/lang.php b/lib/plugins/popularity/lang/ko/lang.php index 3a28b1b0e..91d798a5f 100644 --- a/lib/plugins/popularity/lang/ko/lang.php +++ b/lib/plugins/popularity/lang/ko/lang.php @@ -6,6 +6,7 @@ * @author dongnak@gmail.com * @author Song Younghwan * @author SONG Younghwan + * @author Seung-Chul Yoo */ $lang['name'] = '인기도 조사 (불러오는데 시간이 걸릴 수 있습니다.)'; $lang['submit'] = '자료 보내기'; diff --git a/lib/plugins/revert/lang/ko/lang.php b/lib/plugins/revert/lang/ko/lang.php index 5e070de92..0163d2754 100644 --- a/lib/plugins/revert/lang/ko/lang.php +++ b/lib/plugins/revert/lang/ko/lang.php @@ -6,6 +6,7 @@ * @author dongnak@gmail.com * @author Song Younghwan * @author SONG Younghwan + * @author Seung-Chul Yoo */ $lang['menu'] = '복구 관리자'; $lang['filter'] = '스팸 페이지 검색 '; diff --git a/lib/plugins/usermanager/lang/ko/lang.php b/lib/plugins/usermanager/lang/ko/lang.php index eeb8eb791..f2322414a 100644 --- a/lib/plugins/usermanager/lang/ko/lang.php +++ b/lib/plugins/usermanager/lang/ko/lang.php @@ -6,6 +6,7 @@ * @author dongnak@gmail.com * @author Song Younghwan * @author SONG Younghwan + * @author Seung-Chul Yoo */ $lang['menu'] = '사용자 관리자'; $lang['noauth'] = '(사용자 인증이 불가능합니다.)'; From 7deca91be61f76ac935c147107c82982252a688a Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Wed, 27 Oct 2010 11:46:27 -0400 Subject: [PATCH 007/110] White space fixes only - no functional changes --- inc/DifferenceEngine.php | 167 ++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 92 deletions(-) diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php index 7b14e4463..7eae8bd93 100644 --- a/inc/DifferenceEngine.php +++ b/inc/DifferenceEngine.php @@ -30,7 +30,7 @@ class _DiffOp { class _DiffOp_Copy extends _DiffOp { var $type = 'copy'; - function _DiffOp_Copy ($orig, $closing = false) { + function _DiffOp_Copy($orig, $closing = false) { if (!is_array($closing)) $closing = $orig; $this->orig = $orig; @@ -45,7 +45,7 @@ class _DiffOp_Copy extends _DiffOp { class _DiffOp_Delete extends _DiffOp { var $type = 'delete'; - function _DiffOp_Delete ($lines) { + function _DiffOp_Delete($lines) { $this->orig = $lines; $this->closing = false; } @@ -58,7 +58,7 @@ class _DiffOp_Delete extends _DiffOp { class _DiffOp_Add extends _DiffOp { var $type = 'add'; - function _DiffOp_Add ($lines) { + function _DiffOp_Add($lines) { $this->closing = $lines; $this->orig = false; } @@ -71,7 +71,7 @@ class _DiffOp_Add extends _DiffOp { class _DiffOp_Change extends _DiffOp { var $type = 'change'; - function _DiffOp_Change ($orig, $closing) { + function _DiffOp_Change($orig, $closing) { $this->orig = $orig; $this->closing = $closing; } @@ -104,7 +104,7 @@ class _DiffOp_Change extends _DiffOp { */ class _DiffEngine { - function diff ($from_lines, $to_lines) { + function diff($from_lines, $to_lines) { $n_from = count($from_lines); $n_to = count($to_lines); @@ -135,7 +135,7 @@ class _DiffEngine { $xhash[$from_lines[$xi]] = 1; for ($yi = $skip; $yi < $n_to - $endskip; $yi++) { $line = $to_lines[$yi]; - if ( ($this->ychanged[$yi] = empty($xhash[$line])) ) + if (($this->ychanged[$yi] = empty($xhash[$line]))) continue; $yhash[$line] = 1; $this->yv[] = $line; @@ -143,7 +143,7 @@ class _DiffEngine { } for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { $line = $from_lines[$xi]; - if ( ($this->xchanged[$xi] = empty($yhash[$line])) ) + if (($this->xchanged[$xi] = empty($yhash[$line]))) continue; $this->xv[] = $line; $this->xind[] = $xi; @@ -165,8 +165,7 @@ class _DiffEngine { // Skip matching "snake". $copy = array(); - while ( $xi < $n_from && $yi < $n_to - && !$this->xchanged[$xi] && !$this->ychanged[$yi]) { + while ($xi < $n_from && $yi < $n_to && !$this->xchanged[$xi] && !$this->ychanged[$yi]) { $copy[] = $from_lines[$xi++]; ++$yi; } @@ -210,15 +209,14 @@ class _DiffEngine { * match. The caller must trim matching lines from the beginning and end * of the portions it is going to specify. */ - function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks) { + function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) { $flip = false; if ($xlim - $xoff > $ylim - $yoff) { // Things seems faster (I'm not sure I understand why) // when the shortest sequence in X. $flip = true; - list ($xoff, $xlim, $yoff, $ylim) - = array( $yoff, $ylim, $xoff, $xlim); + list ($xoff, $xlim, $yoff, $ylim) = array($yoff, $ylim, $xoff, $xlim); } if ($flip) @@ -284,7 +282,7 @@ class _DiffEngine { return array($this->lcs, $seps); } - function _lcs_pos ($ypos) { + function _lcs_pos($ypos) { $end = $this->lcs; if ($end == 0 || $ypos > $this->seq[$end]) { $this->seq[++$this->lcs] = $ypos; @@ -295,7 +293,7 @@ class _DiffEngine { $beg = 1; while ($beg < $end) { $mid = (int)(($beg + $end) / 2); - if ( $ypos > $this->seq[$mid] ) + if ($ypos > $this->seq[$mid]) $beg = $mid + 1; else $end = $mid; @@ -321,17 +319,15 @@ class _DiffEngine { * Note that XLIM, YLIM are exclusive bounds. * All line numbers are origin-0 and discarded lines are not counted. */ - function _compareseq ($xoff, $xlim, $yoff, $ylim) { + function _compareseq($xoff, $xlim, $yoff, $ylim) { // Slide down the bottom initial diagonal. - while ($xoff < $xlim && $yoff < $ylim - && $this->xv[$xoff] == $this->yv[$yoff]) { + while ($xoff < $xlim && $yoff < $ylim && $this->xv[$xoff] == $this->yv[$yoff]) { ++$xoff; ++$yoff; } // Slide up the top initial diagonal. - while ($xlim > $xoff && $ylim > $yoff - && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) { + while ($xlim > $xoff && $ylim > $yoff && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) { --$xlim; --$ylim; } @@ -379,7 +375,7 @@ class _DiffEngine { * * This is extracted verbatim from analyze.c (GNU diffutils-2.7). */ - function _shift_boundaries ($lines, &$changed, $other_changed) { + function _shift_boundaries($lines, &$changed, $other_changed) { $i = 0; $j = 0; @@ -519,7 +515,7 @@ class Diff { * @return object A Diff object representing the inverse of the * original diff. */ - function reverse () { + function reverse() { $rev = $this; $rev->edits = array(); foreach ($this->edits as $edit) { @@ -533,7 +529,7 @@ class Diff { * * @return bool True iff two sequences were identical. */ - function isEmpty () { + function isEmpty() { foreach ($this->edits as $edit) { if ($edit->type != 'copy') return false; @@ -548,7 +544,7 @@ class Diff { * * @return int The length of the LCS. */ - function lcs () { + function lcs() { $lcs = 0; foreach ($this->edits as $edit) { if ($edit->type == 'copy') @@ -598,7 +594,7 @@ class Diff { * * This is here only for debugging purposes. */ - function _check ($from_lines, $to_lines) { + function _check($from_lines, $to_lines) { if (serialize($from_lines) != serialize($this->orig())) trigger_error("Reconstructed original doesn't match", E_USER_ERROR); if (serialize($to_lines) != serialize($this->closing())) @@ -612,7 +608,7 @@ class Diff { $prevtype = 'none'; foreach ($this->edits as $edit) { - if ( $prevtype == $edit->type ) + if ($prevtype == $edit->type) trigger_error("Edit sequence is non-optimal", E_USER_ERROR); $prevtype = $edit->type; } @@ -649,8 +645,7 @@ class MappedDiff extends Diff { * @param $mapped_to_lines array This array should * have the same number of elements as $to_lines. */ - function MappedDiff($from_lines, $to_lines, - $mapped_from_lines, $mapped_to_lines) { + function MappedDiff($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) { assert(count($from_lines) == count($mapped_from_lines)); assert(count($to_lines) == count($mapped_to_lines)); @@ -727,9 +722,7 @@ class DiffFormatter { $context = array_slice($edit->orig, 0, $ntrail); $block[] = new _DiffOp_Copy($context); } - $this->_block($x0, $ntrail + $xi - $x0, - $y0, $ntrail + $yi - $y0, - $block); + $this->_block($x0, $ntrail + $xi - $x0, $y0, $ntrail + $yi - $y0, $block); $block = false; } } @@ -754,9 +747,7 @@ class DiffFormatter { } if (is_array($block)) - $this->_block($x0, $xi - $x0, - $y0, $yi - $y0, - $block); + $this->_block($x0, $xi - $x0, $y0, $yi - $y0, $block); return $this->_end_diff(); } @@ -836,14 +827,14 @@ class DiffFormatter { define('NBSP', "\xC2\xA0"); // utf-8 non-breaking space. class _HWLDF_WordAccumulator { - function _HWLDF_WordAccumulator () { + function _HWLDF_WordAccumulator() { $this->_lines = array(); $this->_line = ''; $this->_group = ''; $this->_tag = ''; } - function _flushGroup ($new_tag) { + function _flushGroup($new_tag) { if ($this->_group !== '') { if ($this->_tag == 'mark') $this->_line .= ''.$this->_group.''; @@ -854,14 +845,14 @@ class _HWLDF_WordAccumulator { $this->_tag = $new_tag; } - function _flushLine ($new_tag) { + function _flushLine($new_tag) { $this->_flushGroup($new_tag); if ($this->_line != '') $this->_lines[] = $this->_line; $this->_line = ''; } - function addWords ($words, $tag = '') { + function addWords($words, $tag = '') { if ($tag != $this->_tag) $this->_flushGroup($tag); @@ -887,46 +878,44 @@ class _HWLDF_WordAccumulator { class WordLevelDiff extends MappedDiff { - function WordLevelDiff ($orig_lines, $closing_lines) { + function WordLevelDiff($orig_lines, $closing_lines) { list ($orig_words, $orig_stripped) = $this->_split($orig_lines); list ($closing_words, $closing_stripped) = $this->_split($closing_lines); - $this->MappedDiff($orig_words, $closing_words, - $orig_stripped, $closing_stripped); + $this->MappedDiff($orig_words, $closing_words, $orig_stripped, $closing_stripped); } function _split($lines) { - if (!preg_match_all('/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs', - implode("\n", $lines), - $m)) { + if (!preg_match_all('/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs', + implode("\n", $lines), $m)) { return array(array(''), array('')); - } - return array($m[0], $m[1]); - } + } + return array($m[0], $m[1]); + } - function orig () { - $orig = new _HWLDF_WordAccumulator; + function orig() { + $orig = new _HWLDF_WordAccumulator; - foreach ($this->edits as $edit) { + foreach ($this->edits as $edit) { if ($edit->type == 'copy') - $orig->addWords($edit->orig); + $orig->addWords($edit->orig); elseif ($edit->orig) - $orig->addWords($edit->orig, 'mark'); - } - return $orig->getLines(); - } + $orig->addWords($edit->orig, 'mark'); + } + return $orig->getLines(); + } - function closing () { - $closing = new _HWLDF_WordAccumulator; + function closing() { + $closing = new _HWLDF_WordAccumulator; - foreach ($this->edits as $edit) { - if ($edit->type == 'copy') - $closing->addWords($edit->closing); - elseif ($edit->closing) - $closing->addWords($edit->closing, 'mark'); - } - return $closing->getLines(); - } + foreach ($this->edits as $edit) { + if ($edit->type == 'copy') + $closing->addWords($edit->closing); + elseif ($edit->closing) + $closing->addWords($edit->closing, 'mark'); + } + return $closing->getLines(); + } } /** @@ -986,76 +975,70 @@ class TableDiffFormatter extends DiffFormatter { return $text; } - function _block_header( $xbeg, $xlen, $ybeg, $ylen ) { + function _block_header($xbeg, $xlen, $ybeg, $ylen) { global $lang; $l1 = $lang['line'].' '.$xbeg; $l2 = $lang['line'].' '.$ybeg; - $r = ''.$l1.":\n" . - ''.$l2.":\n"; + $r = ''.$l1.':\n'. + ' '.$l2.":\n'. + '\n"; return $r; } - function _start_block( $header ) { - print( $header ); + function _start_block($header) { + print($header); } function _end_block() { } - function _lines( $lines, $prefix=' ', $color="white" ) { + function _lines($lines, $prefix=' ', $color="white") { } - function addedLine( $line ) { - return '+' . - $line.''; - + function addedLine($line) { + return '+' . $line.''; } - function deletedLine( $line ) { - return '-' . - $line.''; + function deletedLine($line) { + return '-' . $line.''; } function emptyLine() { return ' '; } - function contextLine( $line ) { + function contextLine($line) { return ' '.$line.''; } function _added($lines) { foreach ($lines as $line) { - print( '' . $this->emptyLine() . - $this->addedLine( $line ) . "\n" ); + print('' . $this->emptyLine() . $this->addedLine($line) . "\n"); } } function _deleted($lines) { foreach ($lines as $line) { - print( '' . $this->deletedLine( $line ) . - $this->emptyLine() . "\n" ); + print('' . $this->deletedLine($line) . $this->emptyLine() . "\n"); } } - function _context( $lines ) { + function _context($lines) { foreach ($lines as $line) { - print( '' . $this->contextLine( $line ) . - $this->contextLine( $line ) . "\n" ); + print('' . $this->contextLine($line) . $this->contextLine($line) . "\n"); } } - function _changed( $orig, $closing ) { - $diff = new WordLevelDiff( $orig, $closing ); + function _changed($orig, $closing) { + $diff = new WordLevelDiff($orig, $closing); $del = $diff->orig(); $add = $diff->closing(); - while ( $line = array_shift( $del ) ) { - $aline = array_shift( $add ); - print( '' . $this->deletedLine( $line ) . - $this->addedLine( $aline ) . "\n" ); + while ($line = array_shift($del)) { + $aline = array_shift($add); + print('' . $this->deletedLine($line) . $this->addedLine($aline) . "\n"); } - $this->_added( $add ); # If any leftovers + $this->_added($add); # If any leftovers } } From 812bb04e971a47bee7e0da80d93831f1660efafb Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sat, 20 Nov 2010 11:53:38 +0100 Subject: [PATCH 008/110] Add support for inline diff formatting This patch only adds the capability to the Difference Engine lib, not to the user interface, yet. --- inc/DifferenceEngine.php | 115 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php index 7eae8bd93..a56fe9f6e 100644 --- a/inc/DifferenceEngine.php +++ b/inc/DifferenceEngine.php @@ -838,6 +838,10 @@ class _HWLDF_WordAccumulator { if ($this->_group !== '') { if ($this->_tag == 'mark') $this->_line .= ''.$this->_group.''; + elseif ($this->_tag == 'add') + $this->_line .= ''.$this->_group.''; + elseif ($this->_tag == 'del') + $this->_line .= ''.$this->_group.''; else $this->_line .= $this->_group; } @@ -918,6 +922,42 @@ class WordLevelDiff extends MappedDiff { } } +class InlineWordLevelDiff extends MappedDiff { + + function InlineWordLevelDiff($orig_lines, $closing_lines) { + list ($orig_words, $orig_stripped) = $this->_split($orig_lines); + list ($closing_words, $closing_stripped) = $this->_split($closing_lines); + + $this->MappedDiff($orig_words, $closing_words, $orig_stripped, $closing_stripped); + } + + function _split($lines) { + if (!preg_match_all('/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs', + implode("\n", $lines), $m)) { + return array(array(''), array('')); + } + return array($m[0], $m[1]); + } + + function inline() { + $orig = new _HWLDF_WordAccumulator; + foreach ($this->edits as $edit) { + if ($edit->type == 'copy') + $orig->addWords($edit->orig); + elseif ($edit->type == 'change'){ + $orig->addWords($edit->orig, 'del'); + $orig->addWords($edit->closing, 'add'); + } elseif ($edit->type == 'delete') + $orig->addWords($edit->orig, 'del'); + elseif ($edit->type == 'add') + $orig->addWords($edit->closing, 'add'); + elseif ($edit->orig) + $orig->addWords($edit->orig, 'del'); + } + return $orig->getLines(); + } +} + /** * "Unified" diff formatter. * @@ -1042,5 +1082,80 @@ class TableDiffFormatter extends DiffFormatter { } } +/** + * Inline style diff formatter. + * + */ +class InlineDiffFormatter extends DiffFormatter { + + function InlineDiffFormatter() { + $this->leading_context_lines = 2; + $this->trailing_context_lines = 2; + } + + function format($diff) { + // Preserve whitespaces by converting some to non-breaking spaces. + // Do not convert all of them to allow word-wrap. + $val = parent::format($diff); + $val = str_replace(' ','  ', $val); + $val = preg_replace('/ (?=<)|(?<=[ >]) /', ' ', $val); + return $val; + } + + function _pre($text){ + $text = htmlspecialchars($text); + return $text; + } + + function _block_header($xbeg, $xlen, $ybeg, $ylen) { + global $lang; + if ($xlen != 1) + $xbeg .= "," . $xlen; + if ($ylen != 1) + $ybeg .= "," . $ylen; + $r = '@@ '.$lang['line']." -$xbeg +$ybeg @@"; + $r .= ' '.$lang['deleted'].''; + $r .= ' '.$lang['created'].''; + $r .= "\n"; + return $r; + } + + function _start_block($header) { + print($header."\n"); + } + + function _end_block() { + } + + function _lines($lines, $prefix=' ', $color="white") { + } + + function _added($lines) { + foreach ($lines as $line) { + print(''. $line . "\n"); + } + } + + function _deleted($lines) { + foreach ($lines as $line) { + print('' . $line . "\n"); + } + } + + function _context($lines) { + foreach ($lines as $line) { + print(''.$line."\n"); + } + } + + function _changed($orig, $closing) { + $diff = new InlineWordLevelDiff($orig, $closing); + $add = $diff->inline(); + + foreach ($add as $line) + print(''.$line."\n"); + } +} + //Setup VIM: ex: et ts=4 enc=utf-8 : From 4064e2d30906d01e696c5de106fd9ff356980a93 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sat, 20 Nov 2010 13:13:21 +0100 Subject: [PATCH 009/110] Handle do=check before ACL checking --- inc/actions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/inc/actions.php b/inc/actions.php index 9db7d5f24..7a6d2eb85 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -50,6 +50,12 @@ function act_dispatch(){ } } + //display some infos + if($ACT == 'check'){ + check(); + $ACT = 'show'; + } + //check permissions $ACT = act_permcheck($ACT); @@ -120,12 +126,6 @@ function act_dispatch(){ if(substr($ACT,0,7) == 'export_') $ACT = act_export($ACT); - //display some infos - if($ACT == 'check'){ - check(); - $ACT = 'show'; - } - //handle admin tasks if($ACT == 'admin'){ // retrieve admin plugin name from $_REQUEST['page'] From 85dcda20ffd82becbe69a7ca5d99e4b6fd99c9ea Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sat, 20 Nov 2010 13:17:00 +0100 Subject: [PATCH 010/110] Send 403 header for permission denied screens when send404 is enabled --- inc/actions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inc/actions.php b/inc/actions.php index 7a6d2eb85..fb2ae452f 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -20,6 +20,7 @@ function act_dispatch(){ global $ID; global $QUERY; global $lang; + global $conf; $preact = $ACT; @@ -143,6 +144,10 @@ function act_dispatch(){ $ACT = act_permcheck($ACT); } // end event ACTION_ACT_PREPROCESS default action $evt->advise_after(); + // Make sure plugs can handle 'denied' + if($conf['send404'] && $ACT == 'denied') { + header('HTTP/1.0 403 Forbidden'); + } unset($evt); // when action 'show', the intial not 'show' and POST, do a redirect From ba6984cf400bde3cbdd7e1f203602cb0d04eb7d2 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 20 Nov 2010 15:35:17 +0100 Subject: [PATCH 011/110] Turkish language update --- inc/lang/tr/lang.php | 8 +++++--- lib/plugins/acl/lang/tr/lang.php | 5 ++--- lib/plugins/config/lang/tr/lang.php | 5 ++--- lib/plugins/plugin/lang/tr/lang.php | 5 ++--- lib/plugins/popularity/lang/tr/lang.php | 5 ++--- lib/plugins/revert/lang/tr/lang.php | 5 ++--- lib/plugins/usermanager/lang/tr/lang.php | 5 ++--- 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/inc/lang/tr/lang.php b/inc/lang/tr/lang.php index c6d20c805..0c8c1ff3f 100644 --- a/inc/lang/tr/lang.php +++ b/inc/lang/tr/lang.php @@ -4,11 +4,10 @@ * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Selim Farsakoğlu - * @author Aydın Coşkuner aydinweb@gmail.com * @author Aydın Coşkuner - * @author yavuzselim@gmail.com - * @author Cihan Kahveci kahvecicihan@gmail.com + * @author Cihan Kahveci * @author Yavuz Selim + * @author Caleb Maclennan */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'ltr'; @@ -186,6 +185,9 @@ $lang['qb_h2'] = '2. Seviye Başlık'; $lang['qb_h3'] = '3. Seviye Başlık'; $lang['qb_h4'] = '4. Seviye Başlık'; $lang['qb_h5'] = '5. Seviye Başlık'; +$lang['qb_h'] = 'Başlık'; +$lang['qb_hs'] = 'Başlığı seç'; +$lang['qb_hplus'] = 'Daha yüksek başlık'; $lang['qb_link'] = 'İç Bağlantı'; $lang['qb_extlink'] = 'Dış Bağlantı'; $lang['qb_hr'] = 'Yatay Çizgi'; diff --git a/lib/plugins/acl/lang/tr/lang.php b/lib/plugins/acl/lang/tr/lang.php index 45fbe7489..de96d2906 100644 --- a/lib/plugins/acl/lang/tr/lang.php +++ b/lib/plugins/acl/lang/tr/lang.php @@ -4,11 +4,10 @@ * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Selim Farsakoğlu - * @author Aydın Coşkuner aydinweb@gmail.com * @author Aydın Coşkuner - * @author yavuzselim@gmail.com - * @author Cihan Kahveci kahvecicihan@gmail.com + * @author Cihan Kahveci * @author Yavuz Selim + * @author Caleb Maclennan */ $lang['admin_acl'] = 'Erişim Kontrol Listesi (ACL) Yönetimi'; $lang['acl_group'] = 'Grup'; diff --git a/lib/plugins/config/lang/tr/lang.php b/lib/plugins/config/lang/tr/lang.php index 9929c663e..6d7d7cc2e 100644 --- a/lib/plugins/config/lang/tr/lang.php +++ b/lib/plugins/config/lang/tr/lang.php @@ -2,11 +2,10 @@ /** * Turkish language file * - * @author Aydın Coşkuner aydinweb@gmail.com * @author Aydın Coşkuner - * @author yavuzselim@gmail.com - * @author Cihan Kahveci kahvecicihan@gmail.com + * @author Cihan Kahveci * @author Yavuz Selim + * @author Caleb Maclennan */ $lang['menu'] = 'Site Ayarları'; $lang['error'] = 'Ayarlar yanlış bir değer girildiği için güncellenemedi. Lütfen değişikliklerinizi gözden geçirin ve tekrar gönderin. diff --git a/lib/plugins/plugin/lang/tr/lang.php b/lib/plugins/plugin/lang/tr/lang.php index 28db9109d..9a655e400 100644 --- a/lib/plugins/plugin/lang/tr/lang.php +++ b/lib/plugins/plugin/lang/tr/lang.php @@ -2,11 +2,10 @@ /** * Turkish language file * - * @author Aydın Coşkuner aydinweb@gmail.com * @author Aydın Coşkuner - * @author yavuzselim@gmail.com - * @author Cihan Kahveci kahvecicihan@gmail.com + * @author Cihan Kahveci * @author Yavuz Selim + * @author Caleb Maclennan */ $lang['menu'] = 'Eklenti Yönetimi'; $lang['download'] = 'Yeni bir eklenti indirip kur'; diff --git a/lib/plugins/popularity/lang/tr/lang.php b/lib/plugins/popularity/lang/tr/lang.php index 682b51218..fe87d1548 100644 --- a/lib/plugins/popularity/lang/tr/lang.php +++ b/lib/plugins/popularity/lang/tr/lang.php @@ -2,11 +2,10 @@ /** * Turkish language file * - * @author Aydın Coşkuner aydinweb@gmail.com * @author Aydın Coşkuner - * @author yavuzselim@gmail.com - * @author Cihan Kahveci kahvecicihan@gmail.com + * @author Cihan Kahveci * @author Yavuz Selim + * @author Caleb Maclennan */ $lang['name'] = 'Popülerlik Geribeslemesi (yüklemesi uzun sürebilir)'; $lang['submit'] = 'Verileri Gönder'; diff --git a/lib/plugins/revert/lang/tr/lang.php b/lib/plugins/revert/lang/tr/lang.php index 164a8ec4f..aa1458a95 100644 --- a/lib/plugins/revert/lang/tr/lang.php +++ b/lib/plugins/revert/lang/tr/lang.php @@ -2,11 +2,10 @@ /** * Turkish language file * - * @author Aydın Coşkuner aydinweb@gmail.com * @author Aydın Coşkuner - * @author yavuzselim@gmail.com - * @author Cihan Kahveci kahvecicihan@gmail.com + * @author Cihan Kahveci * @author Yavuz Selim + * @author Caleb Maclennan */ $lang['menu'] = 'Eskiye Döndürme'; $lang['filter'] = 'Spam bulunan sayfaları ara'; diff --git a/lib/plugins/usermanager/lang/tr/lang.php b/lib/plugins/usermanager/lang/tr/lang.php index 28127d9d0..b9c9cfc52 100644 --- a/lib/plugins/usermanager/lang/tr/lang.php +++ b/lib/plugins/usermanager/lang/tr/lang.php @@ -2,11 +2,10 @@ /** * Turkish language file * - * @author Aydın Coşkuner aydinweb@gmail.com * @author Aydın Coşkuner - * @author yavuzselim@gmail.com - * @author Cihan Kahveci kahvecicihan@gmail.com + * @author Cihan Kahveci * @author Yavuz Selim + * @author Caleb Maclennan */ $lang['menu'] = 'Kullanıcı Yönetimi'; $lang['noauth'] = '(kullanıcı onaylaması yoktur)'; From 91d55b797acf64322fa396dbfea34a78ea6b970f Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Sun, 21 Nov 2010 12:16:21 +0100 Subject: [PATCH 012/110] First step to upgrade to SimplePie 1.2 --- inc/FeedParser.php | 1 + inc/SimplePie.php | 10404 ++++++++++++++++++++++++++++++------------- 2 files changed, 7290 insertions(+), 3115 deletions(-) diff --git a/inc/FeedParser.php b/inc/FeedParser.php index 9d00e7abf..b98350da7 100644 --- a/inc/FeedParser.php +++ b/inc/FeedParser.php @@ -49,6 +49,7 @@ class FeedParser_File extends SimplePie_File { */ function FeedParser_File($url, $timeout=10, $redirects=5, $headers=null, $useragent=null, $force_fsockopen=false) { + parent::__construct(); $this->http = new DokuHTTPClient(); $this->success = $this->http->sendRequest($url); diff --git a/inc/SimplePie.php b/inc/SimplePie.php index 99c9f3226..1bbc2c0ec 100644 --- a/inc/SimplePie.php +++ b/inc/SimplePie.php @@ -5,7 +5,7 @@ * A PHP-Based RSS and Atom Feed Framework. * Takes the hard work out of managing a complete RSS/Atom solution. * - * Copyright (c) 2004-2007, Ryan Parman and Geoffrey Sneddon + * Copyright (c) 2004-2009, Ryan Parman and Geoffrey Sneddon * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are @@ -33,8 +33,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @package SimplePie - * @version "Razzleberry" - * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon + * @version 1.2.1-dev + * @copyright 2004-2009 Ryan Parman, Geoffrey Sneddon * @author Ryan Parman * @author Geoffrey Sneddon * @link http://simplepie.org/ SimplePie @@ -51,18 +51,18 @@ define('SIMPLEPIE_NAME', 'SimplePie'); /** * SimplePie Version */ -define('SIMPLEPIE_VERSION', '1.0.1'); +define('SIMPLEPIE_VERSION', '1.2.1-dev'); /** * SimplePie Build * @todo Hardcode for release (there's no need to have to call SimplePie_Misc::parse_date() only every load of simplepie.inc) */ -define('SIMPLEPIE_BUILD', 20070719221955); +define('SIMPLEPIE_BUILD', gmdate('YmdHis', SimplePie_Misc::parse_date(substr('$Date$', 7, 25)) ? SimplePie_Misc::parse_date(substr('$Date$', 7, 25)) : filemtime(__FILE__))); /** * SimplePie Website URL */ -define('SIMPLEPIE_URL', 'http://simplepie.org/'); +define('SIMPLEPIE_URL', 'http://simplepie.org'); /** * SimplePie Useragent @@ -242,10 +242,25 @@ define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32); */ define('SIMPLEPIE_CONSTRUCT_ALL', 63); +/** + * Don't change case + */ +define('SIMPLEPIE_SAME_CASE', 1); + +/** + * Change to lowercase + */ +define('SIMPLEPIE_LOWERCASE', 2); + +/** + * Change to uppercase + */ +define('SIMPLEPIE_UPPERCASE', 4); + /** * PCRE for HTML attributes */ -define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[a-z0-9\-._:]*)))?)*)\s*'); +define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*'); /** * PCRE for XML attributes @@ -287,6 +302,12 @@ define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/'); */ define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/'); +/** + * RSS 2.0 Namespace + * (Stupid, I know, but I'm certain it will confuse people less with support.) + */ +define('SIMPLEPIE_NAMESPACE_RSS_20', ''); + /** * DC 1.0 Namespace */ @@ -312,6 +333,11 @@ define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss'); */ define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/'); +/** + * Wrong Media RSS Namespace + */ +define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss'); + /** * iTunes RSS Namespace */ @@ -332,15 +358,40 @@ define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignment */ define('SIMPLEPIE_PHP5', version_compare(PHP_VERSION, '5.0.0', '>=')); +/** + * No file source + */ +define('SIMPLEPIE_FILE_SOURCE_NONE', 0); + +/** + * Remote file source + */ +define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1); + +/** + * Local file source + */ +define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2); + +/** + * fsockopen() file source + */ +define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4); + +/** + * cURL file source + */ +define('SIMPLEPIE_FILE_SOURCE_CURL', 8); + +/** + * file_get_contents() file source + */ +define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16); + /** * SimplePie * * @package SimplePie - * @version "Razzleberry" - * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon - * @author Ryan Parman - * @author Geoffrey Sneddon - * @todo Option for type of fetching (cache, not modified header, fetch, etc.) */ class SimplePie { @@ -406,6 +457,14 @@ class SimplePie */ var $force_fsockopen = false; + /** + * @var bool Force the given data/URL to be treated as a feed no matter what + * it appears like + * @see SimplePie::force_feed() + * @access private + */ + var $force_feed = false; + /** * @var bool Enable/Disable XML dump * @see SimplePie::enable_xml_dump() @@ -561,6 +620,20 @@ class SimplePie */ var $restriction_class = 'SimplePie_Restriction'; + /** + * @var string Class used for content-type sniffing + * @see SimplePie::set_content_type_sniffer_class() + * @access private + */ + var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer'; + + /** + * @var string Class used for item sources. + * @see SimplePie::set_source_class() + * @access private + */ + var $source_class = 'SimplePie_Source'; + /** * @var mixed Set javascript query string parameter (false, or * anything type-cast to false, disables this feature) @@ -576,6 +649,13 @@ class SimplePie */ var $max_checked_feeds = 10; + /** + * @var array All the feeds found during the autodiscovery process + * @see SimplePie::get_all_discovered_feeds() + * @access private + */ + var $all_discovered_feeds = array(); + /** * @var string Web-accessible path to the handler_favicon.php file. * @see SimplePie::set_favicon_handler() @@ -610,6 +690,13 @@ class SimplePie */ var $config_settings = null; + /** + * @var integer Stores the number of items to return per-feed with multifeeds. + * @see SimplePie::set_item_limit() + * @access private + */ + var $item_limit = 0; + /** * @var array Stores the default attributes to be stripped by strip_attributes(). * @see SimplePie::strip_attributes() @@ -677,6 +764,45 @@ class SimplePie return md5(serialize($this->data)); } + /** + * Remove items that link back to this before destroying this object + */ + function __destruct() + { + if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) + { + if (!empty($this->data['items'])) + { + foreach ($this->data['items'] as $item) + { + $item->__destruct(); + } + unset($item, $this->data['items']); + } + if (!empty($this->data['ordered_items'])) + { + foreach ($this->data['ordered_items'] as $item) + { + $item->__destruct(); + } + unset($item, $this->data['ordered_items']); + } + } + } + + /** + * Force the given data/URL to be treated as a feed no matter what it + * appears like + * + * @access public + * @since 1.1 + * @param bool $enable Force the given data/URL to be treated as a feed + */ + function force_feed($enable = false) + { + $this->force_feed = (bool) $enable; + } + /** * This is the URL of the feed you want to parse. * @@ -718,7 +844,7 @@ class SimplePie */ function set_file(&$file) { - if (SimplePie_Misc::is_a($file, 'SimplePie_File')) + if (is_a($file, 'SimplePie_File')) { $this->feed_url = $file->url; $this->file =& $file; @@ -741,7 +867,7 @@ class SimplePie */ function set_raw_data($data) { - $this->raw_data = trim($data); + $this->raw_data = $data; } /** @@ -1156,6 +1282,44 @@ class SimplePie return false; } + /** + * Allows you to change which class SimplePie uses for content-type sniffing. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Content_Type_Sniffer')) + { + $this->content_type_sniffer_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses item sources. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_source_class($class = 'SimplePie_Source') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Source')) + { + $this->source_class = $class; + return true; + } + return false; + } + /** * Allows you to override the default user agent string. * @@ -1294,7 +1458,7 @@ class SimplePie */ function set_favicon_handler($page = false, $qs = 'i') { - if ($page != false) + if ($page !== false) { $this->favicon_handler = $page . '?' . $qs . '='; } @@ -1313,7 +1477,7 @@ class SimplePie */ function set_image_handler($page = false, $qs = 'i') { - if ($page != false) + if ($page !== false) { $this->sanitize->set_image_handler($page . '?' . $qs . '='); } @@ -1323,47 +1487,44 @@ class SimplePie } } + /** + * Set the limit for items returned per-feed with multifeeds. + * + * @access public + * @param integer $limit The maximum number of items to return. + */ + function set_item_limit($limit = 0) + { + $this->item_limit = (int) $limit; + } + function init() { - if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.1.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre')) + // Check absolute bare minimum requirements. + if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre')) { return false; } + // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader. + elseif (!extension_loaded('xmlreader')) + { + static $xml_is_sane = null; + if ($xml_is_sane === null) + { + $parser_check = xml_parser_create(); + xml_parse_into_struct($parser_check, '&', $values); + xml_parser_free($parser_check); + $xml_is_sane = isset($values[0]['value']); + } + if (!$xml_is_sane) + { + return false; + } + } + if (isset($_GET[$this->javascript])) { - if (function_exists('ob_gzhandler')) - { - ob_start('ob_gzhandler'); - } - header('Content-type: text/javascript; charset: UTF-8'); - header('Cache-Control: must-revalidate'); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days - ?> -function embed_odeo(link) { - document.writeln(''); -} - -function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { - if (placeholder != '') { - document.writeln(''); - } - else { - document.writeln(''); - } -} - -function embed_flash(bgcolor, width, height, link, loop, type) { - document.writeln(''); -} - -function embed_flv(width, height, link, placeholder, loop, player) { - document.writeln(''); -} - -function embed_wmedia(width, height, link) { - document.writeln(''); -} - cache && $parsed_feed_url['scheme'] !== '') { - $cache = new $this->cache_class($this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc'); + $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc'); } // If it's enabled and we don't want an XML dump, use the cache if ($cache && !$this->xml_dump) @@ -1393,13 +1554,13 @@ function embed_wmedia(width, height, link) { if (!empty($this->data)) { // If the cache is for an outdated build of SimplePie - if (!isset($this->data['build']) || $this->data['build'] != SIMPLEPIE_BUILD) + if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) { $cache->unlink(); $this->data = array(); } // If we've hit a collision just rerun it with caching disabled - elseif (isset($this->data['url']) && $this->data['url'] != $this->feed_url) + elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url) { $cache = false; $this->data = array(); @@ -1411,7 +1572,7 @@ function embed_wmedia(width, height, link) { if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) { // Do not need to do feed autodiscovery yet. - if ($this->data['feed_url'] == $this->data['url']) + if ($this->data['feed_url'] === $this->data['url']) { $cache->unlink(); $this->data = array(); @@ -1436,12 +1597,12 @@ function embed_wmedia(width, height, link) { } if (isset($this->data['headers']['etag'])) { - $headers['if-none-match'] = $this->data['headers']['etag']; + $headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"'; } $file = new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen); if ($file->success) { - if ($file->status_code == 304) + if ($file->status_code === 304) { $cache->touch(); return true; @@ -1473,7 +1634,7 @@ function embed_wmedia(width, height, link) { // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it. if (!isset($file)) { - if (SimplePie_Misc::is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url) + if (is_a($this->file, 'SimplePie_File') && $this->file->url === $this->feed_url) { $file =& $this->file; } @@ -1483,7 +1644,7 @@ function embed_wmedia(width, height, link) { } } // If the file connection has an error, set SimplePie::error to that and quit - if (!$file->success) + if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) { $this->error = $file->error; if (!empty($this->data)) @@ -1496,148 +1657,150 @@ function embed_wmedia(width, height, link) { } } - // Check if the supplied URL is a feed, if it isn't, look for it. - $locate = new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds); - if (!$locate->is_feed($file)) + if (!$this->force_feed) { - // We need to unset this so that if SimplePie::set_file() has been called that object is untouched - unset($file); - if ($file = $locate->find($this->autodiscovery)) + // Check if the supplied URL is a feed, if it isn't, look for it. + $locate = new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class); + if (!$locate->is_feed($file)) { - if ($cache) + // We need to unset this so that if SimplePie::set_file() has been called that object is untouched + unset($file); + if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds)) { - if (!$cache->save(array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD))) + if ($cache) { - trigger_error("$cache->name is not writeable", E_USER_WARNING); + $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD); + if (!$cache->save($this)) + { + trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); + } + $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc'); } - $cache = new $this->cache_class($this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc'); + $this->feed_url = $file->url; + } + else + { + $this->error = "A feed could not be found at $this->feed_url. A feed with an invalid mime type may fall victim to this error, or " . SIMPLEPIE_NAME . " was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed."; + SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); + return false; } - $this->feed_url = $file->url; - } - else - { - $this->error = "A feed could not be found at $this->feed_url"; - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); - return false; } + $locate = null; } - $locate = null; $headers = $file->headers; - $data = trim($file->body); - unset($file); + $data = $file->body; + $sniffer = new $this->content_type_sniffer_class($file); + $sniffed = $sniffer->get_type(); } else { $data = $this->raw_data; } + // Set up array of possible encodings + $encodings = array(); + // First check to see if input has been overridden. if ($this->input_encoding !== false) { - $encoding = $this->input_encoding; - } - // Second try HTTP headers - elseif (isset($headers['content-type']) && preg_match('/;[\x09\x20]*charset=([^;]*)/i', $headers['content-type'], $charset)) - { - $encoding = $charset[1]; - } - // Then prolog, if at the very start of the document - elseif (preg_match("/^<\?xml[\x20\x9\xD\xA]+version([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"1.0\"|'1.0'|\"1.1\"|'1.1')[\x20\x9\xD\xA]+encoding([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"[A-Za-z][A-Za-z0-9._\-]*\"|'[A-Za-z][A-Za-z0-9._\-]*')([\x20\x9\xD\xA]+standalone([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"(yes|no)\"|'(yes|no)'))?([\x20\x9\xD\xA]+)?\?>/", $data, $prolog)) - { - $encoding = substr($prolog[6], 1, -1); - } - // UTF-32 Big Endian BOM - elseif (strpos($data, "\x0\x0\xFE\xFF") === 0) - { - $encoding = 'UTF-32be'; - } - // UTF-32 Little Endian BOM - elseif (strpos($data, "\xFF\xFE\x0\x0") === 0) - { - $encoding = 'UTF-32'; - } - // UTF-16 Big Endian BOM - elseif (strpos($data, "\xFE\xFF") === 0) - { - $encoding = 'UTF-16be'; - } - // UTF-16 Little Endian BOM - elseif (strpos($data, "\xFF\xFE") === 0) - { - $encoding = 'UTF-16le'; - } - // UTF-8 BOM - elseif (strpos($data, "\xEF\xBB\xBF") === 0) - { - $encoding = 'UTF-8'; - } - // Fallback to the default (US-ASCII for text/xml, ISO-8859-1 for text/* MIME types, UTF-8 otherwise) - elseif (isset($headers['content-type']) && strtolower(SimplePie_Misc::parse_mime($headers['content-type'])) == 'text/xml') - { - $encoding = 'US-ASCII'; - } - elseif (isset($headers['content-type']) && SimplePie_Misc::stripos(SimplePie_Misc::parse_mime($headers['content-type']), 'text/') === 0) - { - $encoding = 'ISO-8859-1'; - } - else - { - $encoding = 'UTF-8'; + $encodings[] = $this->input_encoding; } - // Change the encoding to UTF-8 (as we always use UTF-8 internally) - if ($encoding != 'UTF-8') + $application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity'); + $text_types = array('text/xml', 'text/xml-external-parsed-entity'); + + // RFC 3023 (only applies to sniffed content) + if (isset($sniffed)) { - $data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8'); + if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml') + { + if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) + { + $encodings[] = strtoupper($charset[1]); + } + $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data)); + $encodings[] = 'UTF-8'; + } + elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml') + { + if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) + { + $encodings[] = $charset[1]; + } + $encodings[] = 'US-ASCII'; + } + // Text MIME-type default + elseif (substr($sniffed, 0, 5) === 'text/') + { + $encodings[] = 'US-ASCII'; + } } - // Strip illegal characters - $data = SimplePie_Misc::utf8_bad_replace($data); + // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1 + $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data)); + $encodings[] = 'UTF-8'; + $encodings[] = 'ISO-8859-1'; - $parser = new $this->parser_class(); - $parser->pre_process($data, 'UTF-8'); - // If we want the XML, just output that and quit + // There's no point in trying an encoding twice + $encodings = array_unique($encodings); + + // If we want the XML, just output that with the most likely encoding and quit if ($this->xml_dump) { - header('Content-type: text/xml; charset=UTF-8'); + header('Content-type: text/xml; charset=' . $encodings[0]); echo $data; exit; } - // If it's parsed fine - elseif ($parser->parse($data)) - { - unset($data); - $this->data = $parser->get_data(); - if (isset($this->data['child'])) - { - if (isset($headers)) - { - $this->data['headers'] = $headers; - } - $this->data['build'] = SIMPLEPIE_BUILD; - // Cache the file if caching is enabled - if ($cache && !$cache->save($this->data)) - { - trigger_error("$cache->name is not writeable", E_USER_WARNING); - } - return true; - } - else + // Loop through each possible encoding, till we return something, or run out of possibilities + foreach ($encodings as $encoding) + { + // Change the encoding to UTF-8 (as we always use UTF-8 internally) + if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8')) { - $this->error = "A feed could not be found at $this->feed_url"; - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); - return false; + // Create new parser + $parser = new $this->parser_class(); + + // If it's parsed fine + if ($parser->parse($utf8_data, 'UTF-8')) + { + $this->data = $parser->get_data(); + if ($this->get_type() & ~SIMPLEPIE_TYPE_NONE) + { + if (isset($headers)) + { + $this->data['headers'] = $headers; + } + $this->data['build'] = SIMPLEPIE_BUILD; + + // Cache the file if caching is enabled + if ($cache && !$cache->save($this)) + { + trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); + } + return true; + } + else + { + $this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed."; + SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); + return false; + } + } } } - // If we have an error, just set SimplePie::error to it and quit + if (isset($parser)) + { + // We have an error, just set SimplePie_Misc::error to it and quit + $this->error = sprintf('This XML document is invalid, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); + } else { - $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); - return false; + $this->error = 'The data could not be converted to UTF-8. You MUST have either the iconv or mbstring extension installed. Upgrading to PHP 5.x (which includes iconv) is highly recommended.'; } + SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); + return false; } elseif (!empty($this->multifeed_url)) { @@ -1730,18 +1893,18 @@ function embed_wmedia(width, height, link) { $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090; } } - elseif (isset($this->data['child']['']['rss'])) + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'])) { $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL; - if (isset($this->data['child']['']['rss'][0]['attribs']['']['version'])) + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) { - switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version'])) + switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) { case '0.91': $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091; - if (isset($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data'])) + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) { - switch (trim($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data'])) + switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) { case '0': $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE; @@ -1783,6 +1946,7 @@ function embed_wmedia(width, height, link) { /** * Returns the URL for the favicon of the feed's website. * + * @todo Cache atom:icon * @access public * @since 1.0 */ @@ -1798,26 +1962,36 @@ function embed_wmedia(width, height, link) { if ($this->cache && $this->favicon_handler) { - $cache = new $this->cache_class($this->cache_location, call_user_func($this->cache_name_function, $favicon), 'spi'); + $favicon_filename = call_user_func($this->cache_name_function, $favicon); + $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $favicon_filename, 'spi'); if ($cache->load()) { - return $this->sanitize($this->favicon_handler . rawurlencode($favicon), SIMPLEPIE_CONSTRUCT_IRI); + return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI); } else { $file = new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); - if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0) + if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0) { - if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) + $sniffer = new $this->content_type_sniffer_class($file); + if (substr($sniffer->get_type(), 0, 6) === 'image/') { - return $this->sanitize($this->favicon_handler . rawurlencode($favicon), SIMPLEPIE_CONSTRUCT_IRI); + if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) + { + return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + trigger_error("$cache->name is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); + return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI); + } } + // not an image else { - trigger_error("$cache->name is not writeable", E_USER_WARNING); - return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI); + return false; } } } @@ -1863,7 +2037,7 @@ function embed_wmedia(width, height, link) { { if ($this->feed_url !== null) { - return 'outlook' . $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI); + return $this->sanitize('outlook' . SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI); } else { @@ -1908,12 +2082,12 @@ function embed_wmedia(width, height, link) { { if ($this->subscribe_url()) { - $return = $this->sanitize($feed_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->subscribe_url()); + $return = $feed_url . rawurlencode($this->feed_url); if ($site_url !== null && $this->get_link() !== null) { - $return .= $this->sanitize($site_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_link()); + $return .= $site_url . rawurlencode($this->get_link()); } - return $return; + return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI); } else { @@ -1928,7 +2102,7 @@ function embed_wmedia(width, height, link) { function subscribe_bloglines() { - return urldecode($this->subscribe_service('http://www.bloglines.com/sub/')); + return $this->subscribe_service('http://www.bloglines.com/sub/'); } function subscribe_eskobo() @@ -2022,9 +2196,9 @@ function embed_wmedia(width, height, link) { } if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) { - if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag])) + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag])) { - return $this->data['child']['']['rss'][0]['child'][$namespace][$tag]; + return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]; } } return null; @@ -2062,7 +2236,7 @@ function embed_wmedia(width, height, link) { } if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) { - if ($channel = $this->get_feed_tags('', 'channel')) + if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel')) { if (isset($channel[0]['child'][$namespace][$tag])) { @@ -2098,7 +2272,7 @@ function embed_wmedia(width, height, link) { } if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) { - if ($image = $this->get_channel_tags('', 'image')) + if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image')) { if (isset($image[0]['child'][$namespace][$tag])) { @@ -2119,10 +2293,6 @@ function embed_wmedia(width, height, link) { { return $this->get_link(); } - elseif (isset($this->data['headers']['content-location'])) - { - return SimplePie_Misc::absolutize_url($this->data['headers']['content-location'], $this->subscribe_url()); - } else { return $this->subscribe_url(); @@ -2152,7 +2322,7 @@ function embed_wmedia(width, height, link) { { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - elseif ($return = $this->get_channel_tags('', 'title')) + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } @@ -2170,6 +2340,230 @@ function embed_wmedia(width, height, link) { } } + function get_category($key = 0) + { + $categories = $this->get_categories(); + if (isset($categories[$key])) + { + return $categories[$key]; + } + else + { + return null; + } + } + + function get_categories() + { + $categories = array(); + + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['attribs']['']['term'])) + { + $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = new $this->category_class($term, $scheme, $label); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) + { + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] = new $this->category_class($term, $scheme, null); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) + { + $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) + { + $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + + if (!empty($categories)) + { + return SimplePie_Misc::array_unique($categories); + } + else + { + return null; + } + } + + function get_author($key = 0) + { + $authors = $this->get_authors(); + if (isset($authors[$key])) + { + return $authors[$key]; + } + else + { + return null; + } + } + + function get_authors() + { + $authors = array(); + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) + { + $name = null; + $uri = null; + $email = null; + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $authors[] = new $this->author_class($name, $uri, $email); + } + } + if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) + { + $name = null; + $url = null; + $email = null; + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $authors[] = new $this->author_class($name, $url, $email); + } + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) + { + $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) + { + $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) + { + $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + + if (!empty($authors)) + { + return SimplePie_Misc::array_unique($authors); + } + else + { + return null; + } + } + + function get_contributor($key = 0) + { + $contributors = $this->get_contributors(); + if (isset($contributors[$key])) + { + return $contributors[$key]; + } + else + { + return null; + } + } + + function get_contributors() + { + $contributors = array(); + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) + { + $name = null; + $uri = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $contributors[] = new $this->author_class($name, $uri, $email); + } + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) + { + $name = null; + $url = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $contributors[] = new $this->author_class($name, $url, $email); + } + } + + if (!empty($contributors)) + { + return SimplePie_Misc::array_unique($contributors); + } + else + { + return null; + } + } + function get_link($key = 0, $rel = 'alternate') { $links = $this->get_links($rel); @@ -2227,7 +2621,7 @@ function embed_wmedia(width, height, link) { { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } - if ($links = $this->get_channel_tags('', 'link')) + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } @@ -2247,7 +2641,7 @@ function embed_wmedia(width, height, link) { $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; } } - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) { $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; } @@ -2265,6 +2659,11 @@ function embed_wmedia(width, height, link) { } } + function get_all_discovered_feeds() + { + return $this->all_discovered_feeds; + } + function get_description() { if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) @@ -2283,9 +2682,9 @@ function embed_wmedia(width, height, link) { { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - elseif ($return = $this->get_channel_tags('', 'description')) + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) { @@ -2315,7 +2714,11 @@ function embed_wmedia(width, height, link) { { return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); } - elseif ($return = $this->get_channel_tags('', 'copyright')) + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } @@ -2335,7 +2738,7 @@ function embed_wmedia(width, height, link) { function get_language() { - if ($return = $this->get_channel_tags('', 'language')) + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } @@ -2371,11 +2774,12 @@ function embed_wmedia(width, height, link) { function get_latitude() { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) { return (float) $return[0]['data']; } - elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) + elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) { return (float) $match[1]; } @@ -2395,7 +2799,7 @@ function embed_wmedia(width, height, link) { { return (float) $return[0]['data']; } - elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) + elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) { return (float) $match[2]; } @@ -2415,7 +2819,7 @@ function embed_wmedia(width, height, link) { { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - elseif ($return = $this->get_image_tags('', 'title')) + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } @@ -2455,7 +2859,7 @@ function embed_wmedia(width, height, link) { { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } - elseif ($return = $this->get_image_tags('', 'url')) + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } @@ -2475,7 +2879,7 @@ function embed_wmedia(width, height, link) { { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } - elseif ($return = $this->get_image_tags('', 'link')) + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } @@ -2487,11 +2891,11 @@ function embed_wmedia(width, height, link) { function get_image_width() { - if ($return = $this->get_image_tags('', 'width')) + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width')) { return round($return[0]['data']); } - elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url')) + elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { return 88.0; } @@ -2503,11 +2907,11 @@ function embed_wmedia(width, height, link) { function get_image_height() { - if ($return = $this->get_image_tags('', 'height')) + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height')) { return round($return[0]['data']); } - elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url')) + elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { return 31.0; } @@ -2519,8 +2923,9 @@ function embed_wmedia(width, height, link) { function get_item_quantity($max = 0) { + $max = (int) $max; $qty = count($this->get_items()); - if ($max == 0) + if ($max === 0) { return $qty; } @@ -2545,50 +2950,54 @@ function embed_wmedia(width, height, link) { function get_items($start = 0, $end = 0) { - if (!empty($this->multifeed_objects)) + if (!isset($this->data['items'])) { - return SimplePie::merge_items($this->multifeed_objects, $start, $end); - } - elseif (!isset($this->data['items'])) - { - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) + if (!empty($this->multifeed_objects)) { - $keys = array_keys($items); - foreach ($keys as $key) - { - $this->data['items'][] = new $this->item_class($this, $items[$key]); - } + $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit); } - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) + else { - $keys = array_keys($items); - foreach ($keys as $key) + $this->data['items'] = array(); + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) { - $this->data['items'][] = new $this->item_class($this, $items[$key]); + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = new $this->item_class($this, $items[$key]); + } } - } - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) - { - $keys = array_keys($items); - foreach ($keys as $key) + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) { - $this->data['items'][] = new $this->item_class($this, $items[$key]); + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = new $this->item_class($this, $items[$key]); + } } - } - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) - { - $keys = array_keys($items); - foreach ($keys as $key) + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) { - $this->data['items'][] = new $this->item_class($this, $items[$key]); + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = new $this->item_class($this, $items[$key]); + } } - } - if ($items = $this->get_channel_tags('', 'item')) - { - $keys = array_keys($items); - foreach ($keys as $key) + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) { - $this->data['items'][] = new $this->item_class($this, $items[$key]); + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = new $this->item_class($this, $items[$key]); + } + } + if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = new $this->item_class($this, $items[$key]); + } } } } @@ -2596,7 +3005,7 @@ function embed_wmedia(width, height, link) { if (!empty($this->data['items'])) { // If we want to order it by date, check if all items have a date, and then sort it - if ($this->order_by_date) + if ($this->order_by_date && empty($this->multifeed_objects)) { if (!isset($this->data['ordered_items'])) { @@ -2624,7 +3033,7 @@ function embed_wmedia(width, height, link) { } // Slice the data as desired - if ($end == 0) + if ($end === 0) { return array_slice($items, $start); } @@ -2639,21 +3048,27 @@ function embed_wmedia(width, height, link) { } } + /** + * @static + */ function sort_items($a, $b) { return $a->get_date('U') <= $b->get_date('U'); } - function merge_items($urls, $start = 0, $end = 0) + /** + * @static + */ + function merge_items($urls, $start = 0, $end = 0, $limit = 0) { if (is_array($urls) && sizeof($urls) > 0) { $items = array(); foreach ($urls as $arg) { - if (SimplePie_Misc::is_a($arg, 'SimplePie')) + if (is_a($arg, 'SimplePie')) { - $items = array_merge($items, $arg->get_items()); + $items = array_merge($items, $arg->get_items(0, $limit)); } else { @@ -2676,7 +3091,7 @@ function embed_wmedia(width, height, link) { usort($items, array('SimplePie', 'sort_items')); } - if ($end == 0) + if ($end === 0) { return array_slice($items, $start); } @@ -2709,6 +3124,17 @@ class SimplePie_Item return md5(serialize($this->data)); } + /** + * Remove items that link back to this before destroying this object + */ + function __destruct() + { + if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) + { + unset($this->feed); + } + } + function get_item_tags($namespace, $tag) { if (isset($this->data['child'][$namespace][$tag])) @@ -2738,78 +3164,85 @@ class SimplePie_Item function get_id($hash = false) { - if ($hash) + if (!$hash) { - return $this->__toString(); + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (($return = $this->get_permalink()) !== null) + { + return $return; + } + elseif (($return = $this->get_title()) !== null) + { + return $return; + } } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id')) + if ($this->get_permalink() !== null || $this->get_title() !== null) { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags('', 'guid')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (($return = $this->get_permalink()) !== null) - { - return $return; - } - elseif (($return = $this->get_title()) !== null) - { - return $return; + return md5($this->get_permalink() . $this->get_title()); } else { - return $this->__toString(); + return md5(serialize($this->data)); } } function get_title() { - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) + if (!isset($this->data['title'])) { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags('', 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - return null; + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $this->data['title'] = null; + } } + return $this->data['title']; } function get_description($description_only = false) @@ -2826,7 +3259,7 @@ class SimplePie_Item { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - elseif ($return = $this->get_item_tags('', 'description')) + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); } @@ -2916,9 +3349,20 @@ class SimplePie_Item } $categories[] = new $this->feed->category_class($term, $scheme, $label); } - foreach ((array) $this->get_item_tags('', 'category') as $category) + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) { - $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] = new $this->feed->category_class($term, $scheme, null); } foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) { @@ -2952,9 +3396,77 @@ class SimplePie_Item } } - /** - * @todo Atom inheritance (item author, source author, feed author) - */ + function get_contributor($key = 0) + { + $contributors = $this->get_contributors(); + if (isset($contributors[$key])) + { + return $contributors[$key]; + } + else + { + return null; + } + } + + function get_contributors() + { + $contributors = array(); + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) + { + $name = null; + $uri = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $contributors[] = new $this->feed->author_class($name, $uri, $email); + } + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) + { + $name = null; + $url = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $contributors[] = new $this->feed->author_class($name, $url, $email); + } + } + + if (!empty($contributors)) + { + return SimplePie_Misc::array_unique($contributors); + } + else + { + return null; + } + } + function get_authors() { $authors = array(); @@ -2991,18 +3503,18 @@ class SimplePie_Item } if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) { - $uri = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); } if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) { $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - if ($name !== null || $email !== null || $uri !== null) + if ($name !== null || $email !== null || $url !== null) { $authors[] = new $this->feed->author_class($name, $url, $email); } } - if ($author = $this->get_item_tags('', 'author')) + if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author')) { $authors[] = new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); } @@ -3023,6 +3535,34 @@ class SimplePie_Item { return SimplePie_Misc::array_unique($authors); } + elseif (($source = $this->get_source()) && ($authors = $source->get_authors())) + { + return $authors; + } + elseif ($authors = $this->feed->get_authors()) + { + return $authors; + } + else + { + return null; + } + } + + function get_copyright() + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } else { return null; @@ -3053,7 +3593,7 @@ class SimplePie_Item { $this->data['date']['raw'] = $return[0]['data']; } - elseif ($return = $this->get_item_tags('', 'pubDate')) + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) { $this->data['date']['raw'] = $return[0]['data']; } @@ -3068,7 +3608,8 @@ class SimplePie_Item if (!empty($this->data['date']['raw'])) { - $this->data['date']['parsed'] = SimplePie_Misc::parse_date($this->data['date']['raw']); + $parser = SimplePie_Parse_Date::get(); + $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']); } else { @@ -3173,13 +3714,13 @@ class SimplePie_Item { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } - if ($links = $this->get_item_tags('', 'link')) + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } - if ($links = $this->get_item_tags('', 'guid')) + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) { - if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) == 'true') + if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } @@ -3200,7 +3741,7 @@ class SimplePie_Item $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; } } - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) { $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; } @@ -3241,7 +3782,6 @@ class SimplePie_Item * At this point, we're pretty much assuming that all enclosures for an item are the same content. Anything else is too complicated to properly support. * * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4). - * @todo Add support for itunes: tags. These should be relatively simple compared to media:. * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists). */ function get_enclosures() @@ -3767,7 +4307,7 @@ class SimplePie_Item $restriction_relationship = 'allow'; $restriction_type = null; $restriction_value = 'itunes'; - if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes') + if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') { $restriction_relationship = 'deny'; } @@ -3803,7 +4343,7 @@ class SimplePie_Item $restriction_relationship = 'allow'; $restriction_type = null; $restriction_value = 'itunes'; - if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes') + if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') { $restriction_relationship = 'deny'; } @@ -3856,624 +4396,657 @@ class SimplePie_Item // Clear the memory unset($parent); + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + // Elements + $captions = null; + $categories = null; + $copyrights = null; + $credits = null; + $description = null; + $hashes = null; + $keywords = null; + $player = null; + $ratings = null; + $restrictions = null; + $thumbnails = null; + $title = null; + // If we have media:group tags, loop through them. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) { - // If we have media:content tags, loop through them. - foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) + if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) { - if (isset($content['attribs']['']['url'])) + // If we have media:content tags, loop through them. + foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) { - // Attributes - $bitrate = null; - $channels = null; - $duration = null; - $expression = null; - $framerate = null; - $height = null; - $javascript = null; - $lang = null; - $length = null; - $medium = null; - $samplingrate = null; - $type = null; - $url = null; - $width = null; + if (isset($content['attribs']['']['url'])) + { + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; - // Elements - $captions = null; - $categories = null; - $copyrights = null; - $credits = null; - $description = null; - $hashes = null; - $keywords = null; - $player = null; - $ratings = null; - $restrictions = null; - $thumbnails = null; - $title = null; + // Elements + $captions = null; + $categories = null; + $copyrights = null; + $credits = null; + $description = null; + $hashes = null; + $keywords = null; + $player = null; + $ratings = null; + $restrictions = null; + $thumbnails = null; + $title = null; - // Start checking the attributes of media:content - if (isset($content['attribs']['']['bitrate'])) - { - $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['channels'])) - { - $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['duration'])) - { - $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $duration = $duration_parent; - } - if (isset($content['attribs']['']['expression'])) - { - $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['framerate'])) - { - $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['height'])) - { - $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['lang'])) - { - $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['fileSize'])) - { - $length = ceil($content['attribs']['']['fileSize']); - } - if (isset($content['attribs']['']['medium'])) - { - $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['samplingrate'])) - { - $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['type'])) - { - $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['width'])) - { - $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + // Start checking the attributes of media:content + if (isset($content['attribs']['']['bitrate'])) + { + $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['channels'])) + { + $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['duration'])) + { + $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $duration = $duration_parent; + } + if (isset($content['attribs']['']['expression'])) + { + $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['framerate'])) + { + $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['height'])) + { + $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['lang'])) + { + $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['fileSize'])) + { + $length = ceil($content['attribs']['']['fileSize']); + } + if (isset($content['attribs']['']['medium'])) + { + $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['samplingrate'])) + { + $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['type'])) + { + $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['width'])) + { + $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - // Checking the other optional media: elements. Priority: media:content, media:group, item, channel + // Checking the other optional media: elements. Priority: media:content, media:group, item, channel - // CAPTIONS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) + // CAPTIONS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) { - $caption_type = null; - $caption_lang = null; - $caption_startTime = null; - $caption_endTime = null; - $caption_text = null; - if (isset($caption['attribs']['']['type'])) + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) { - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); } - if (isset($caption['attribs']['']['lang'])) + if (is_array($captions)) { - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + $captions = array_values(SimplePie_Misc::array_unique($captions)); } - if (isset($caption['attribs']['']['start'])) - { - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['end'])) - { - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['data'])) - { - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); } - if (is_array($captions)) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) { - $captions = array_values(SimplePie_Misc::array_unique($captions)); + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) + { + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + } + if (is_array($captions)) + { + $captions = array_values(SimplePie_Misc::array_unique($captions)); + } } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) + else { - $caption_type = null; - $caption_lang = null; - $caption_startTime = null; - $caption_endTime = null; - $caption_text = null; - if (isset($caption['attribs']['']['type'])) - { - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['lang'])) - { - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['start'])) - { - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['end'])) - { - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['data'])) - { - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + $captions = $captions_parent; } - if (is_array($captions)) - { - $captions = array_values(SimplePie_Misc::array_unique($captions)); - } - } - else - { - $captions = $captions_parent; - } - // CATEGORIES - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) - { - foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) + // CATEGORIES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) { - $term = null; - $scheme = null; - $label = null; - if (isset($category['data'])) + foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) { - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = new $this->feed->category_class($term, $scheme, $label); } - if (isset($category['attribs']['']['scheme'])) - { - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $scheme = 'http://search.yahoo.com/mrss/category_schema'; - } - if (isset($category['attribs']['']['label'])) - { - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $categories[] = new $this->feed->category_class($term, $scheme, $label); } - } - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) - { - foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) { - $term = null; - $scheme = null; - $label = null; - if (isset($category['data'])) + foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) { - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = new $this->feed->category_class($term, $scheme, $label); } - if (isset($category['attribs']['']['scheme'])) - { - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $scheme = 'http://search.yahoo.com/mrss/category_schema'; - } - if (isset($category['attribs']['']['label'])) - { - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $categories[] = new $this->feed->category_class($term, $scheme, $label); } - } - if (is_array($categories) && is_array($categories_parent)) - { - $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent))); - } - elseif (is_array($categories)) - { - $categories = array_values(SimplePie_Misc::array_unique($categories)); - } - elseif (is_array($categories_parent)) - { - $categories = array_values(SimplePie_Misc::array_unique($categories_parent)); - } + if (is_array($categories) && is_array($categories_parent)) + { + $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent))); + } + elseif (is_array($categories)) + { + $categories = array_values(SimplePie_Misc::array_unique($categories)); + } + elseif (is_array($categories_parent)) + { + $categories = array_values(SimplePie_Misc::array_unique($categories_parent)); + } - // COPYRIGHTS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) - { - $copyright_url = null; - $copyright_label = null; - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) + // COPYRIGHTS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) { - $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + $copyright_url = null; + $copyright_label = null; + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) + { + $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); } - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) { - $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $copyright_url = null; + $copyright_label = null; + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) + { + $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); } - $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) - { - $copyright_url = null; - $copyright_label = null; - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) + else { - $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + $copyrights = $copyrights_parent; } - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) - { - $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); - } - else - { - $copyrights = $copyrights_parent; - } - // CREDITS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) + // CREDITS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) { - $credit_role = null; - $credit_scheme = null; - $credit_name = null; - if (isset($credit['attribs']['']['role'])) + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) { - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); } - if (isset($credit['attribs']['']['scheme'])) + if (is_array($credits)) { - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + $credits = array_values(SimplePie_Misc::array_unique($credits)); } - else - { - $credit_scheme = 'urn:ebu'; - } - if (isset($credit['data'])) - { - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); } - if (is_array($credits)) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) { - $credits = array_values(SimplePie_Misc::array_unique($credits)); + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) + { + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + } + if (is_array($credits)) + { + $credits = array_values(SimplePie_Misc::array_unique($credits)); + } } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) + else { - $credit_role = null; - $credit_scheme = null; - $credit_name = null; - if (isset($credit['attribs']['']['role'])) - { - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($credit['attribs']['']['scheme'])) - { - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $credit_scheme = 'urn:ebu'; - } - if (isset($credit['data'])) - { - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + $credits = $credits_parent; } - if (is_array($credits)) - { - $credits = array_values(SimplePie_Misc::array_unique($credits)); - } - } - else - { - $credits = $credits_parent; - } - // DESCRIPTION - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) - { - $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) - { - $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $description = $description_parent; - } + // DESCRIPTION + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) + { + $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) + { + $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $description = $description_parent; + } - // HASHES - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) + // HASHES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) { - $value = null; - $algo = null; - if (isset($hash['data'])) + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) { - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes[] = $algo.':'.$value; } - if (isset($hash['attribs']['']['algo'])) + if (is_array($hashes)) { - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + $hashes = array_values(SimplePie_Misc::array_unique($hashes)); } - else - { - $algo = 'md5'; - } - $hashes[] = $algo.':'.$value; } - if (is_array($hashes)) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) { - $hashes = array_values(SimplePie_Misc::array_unique($hashes)); + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) + { + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes[] = $algo.':'.$value; + } + if (is_array($hashes)) + { + $hashes = array_values(SimplePie_Misc::array_unique($hashes)); + } } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) + else { - $value = null; - $algo = null; - if (isset($hash['data'])) - { - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($hash['attribs']['']['algo'])) - { - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $algo = 'md5'; - } - $hashes[] = $algo.':'.$value; + $hashes = $hashes_parent; } - if (is_array($hashes)) - { - $hashes = array_values(SimplePie_Misc::array_unique($hashes)); - } - } - else - { - $hashes = $hashes_parent; - } - // KEYWORDS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) - { - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) + // KEYWORDS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) { - $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - foreach ($temp as $word) + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) { - $keywords[] = trim($word); + $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords[] = trim($word); + } + unset($temp); } - unset($temp); - } - if (is_array($keywords)) - { - $keywords = array_values(SimplePie_Misc::array_unique($keywords)); - } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) - { - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) - { - $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - foreach ($temp as $word) + if (is_array($keywords)) { - $keywords[] = trim($word); + $keywords = array_values(SimplePie_Misc::array_unique($keywords)); } - unset($temp); } - if (is_array($keywords)) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) { - $keywords = array_values(SimplePie_Misc::array_unique($keywords)); + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) + { + $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords[] = trim($word); + } + unset($temp); + } + if (is_array($keywords)) + { + $keywords = array_values(SimplePie_Misc::array_unique($keywords)); + } + } + else + { + $keywords = $keywords_parent; } - } - else - { - $keywords = $keywords_parent; - } - // PLAYER - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) - { - $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) - { - $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - else - { - $player = $player_parent; - } + // PLAYER + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) + { + $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) + { + $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + $player = $player_parent; + } - // RATINGS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) + // RATINGS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) { - $rating_scheme = null; - $rating_value = null; - if (isset($rating['attribs']['']['scheme'])) + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) { - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); } - else + if (is_array($ratings)) { - $rating_scheme = 'urn:simple'; + $ratings = array_values(SimplePie_Misc::array_unique($ratings)); } - if (isset($rating['data'])) - { - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); } - if (is_array($ratings)) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) { - $ratings = array_values(SimplePie_Misc::array_unique($ratings)); + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) + { + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); + } + if (is_array($ratings)) + { + $ratings = array_values(SimplePie_Misc::array_unique($ratings)); + } } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) + else { - $rating_scheme = null; - $rating_value = null; - if (isset($rating['attribs']['']['scheme'])) - { - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $rating_scheme = 'urn:simple'; - } - if (isset($rating['data'])) - { - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); + $ratings = $ratings_parent; } - if (is_array($ratings)) - { - $ratings = array_values(SimplePie_Misc::array_unique($ratings)); - } - } - else - { - $ratings = $ratings_parent; - } - // RESTRICTIONS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) + // RESTRICTIONS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) { - $restriction_relationship = null; - $restriction_type = null; - $restriction_value = null; - if (isset($restriction['attribs']['']['relationship'])) + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) { - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); } - if (isset($restriction['attribs']['']['type'])) + if (is_array($restrictions)) { - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); } - if (isset($restriction['data'])) - { - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); } - if (is_array($restrictions)) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) { - $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) + { + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + } + if (is_array($restrictions)) + { + $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); + } } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) + else { - $restriction_relationship = null; - $restriction_type = null; - $restriction_value = null; - if (isset($restriction['attribs']['']['relationship'])) - { - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['attribs']['']['type'])) - { - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['data'])) - { - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + $restrictions = $restrictions_parent; } - if (is_array($restrictions)) - { - $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); - } - } - else - { - $restrictions = $restrictions_parent; - } - // THUMBNAILS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) + // THUMBNAILS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) { - $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) + { + $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + if (is_array($thumbnails)) + { + $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); + } } - if (is_array($thumbnails)) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) { - $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) + { + $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + if (is_array($thumbnails)) + { + $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); + } } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) + else { - $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + $thumbnails = $thumbnails_parent; } - if (is_array($thumbnails)) - { - $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); - } - } - else - { - $thumbnails = $thumbnails_parent; - } - // TITLES - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) - { - $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) - { - $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $title = $title_parent; - } + // TITLES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) + { + $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) + { + $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $title = $title_parent; + } - $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width); + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width); + } } } } @@ -4884,7 +5457,7 @@ class SimplePie_Item foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) { - if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure') + if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') { // Attributes $bitrate = null; @@ -4919,7 +5492,7 @@ class SimplePie_Item foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) { - if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure') + if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') { // Attributes $bitrate = null; @@ -4952,7 +5525,7 @@ class SimplePie_Item } } - if ($enclosure = $this->get_item_tags('', 'enclosure')) + if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure')) { if (isset($enclosure[0]['attribs']['']['url'])) { @@ -4986,6 +5559,13 @@ class SimplePie_Item $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); } } + + if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) + { + // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); + } + $this->data['enclosures'] = array_values(SimplePie_Misc::array_unique($this->data['enclosures'])); } if (!empty($this->data['enclosures'])) @@ -5004,7 +5584,7 @@ class SimplePie_Item { return (float) $return[0]['data']; } - elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) + elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) { return (float) $match[1]; } @@ -5024,7 +5604,7 @@ class SimplePie_Item { return (float) $return[0]['data']; } - elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) + elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) { return (float) $match[2]; } @@ -5034,6 +5614,18 @@ class SimplePie_Item } } + function get_source() + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source')) + { + return new $this->feed->source_class($this, $return[0]); + } + else + { + return null; + } + } + /** * Creates the add_to_* methods' return data * @@ -5043,16 +5635,20 @@ class SimplePie_Item * (and suffix to the item permalink) * @return mixed URL if feed exists, false otherwise */ - function add_to_service($item_url, $title_url = null) + function add_to_service($item_url, $title_url = null, $summary_url = null) { if ($this->get_permalink() !== null) { - $return = $this->sanitize($item_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_permalink()); + $return = $item_url . rawurlencode($this->get_permalink()); if ($title_url !== null && $this->get_title() !== null) { - $return .= $this->sanitize($title_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_title()); + $return .= $title_url . rawurlencode($this->get_title()); } - return $return; + if ($summary_url !== null && $this->get_description() !== null) + { + $return .= $summary_url . rawurlencode($this->get_description()); + } + return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI); } else { @@ -5072,12 +5668,12 @@ class SimplePie_Item function add_to_delicious() { - return $this->add_to_service('http://del.icio.us/post/?v=3&url=', '&title='); + return $this->add_to_service('http://del.icio.us/post/?v=4&url=', '&title='); } function add_to_digg() { - return $this->add_to_service('http://digg.com/submit?phase=2&URL='); + return $this->add_to_service('http://digg.com/submit?url=', '&title=', '&bodytext='); } function add_to_furl() @@ -5131,6 +5727,557 @@ class SimplePie_Item } } +class SimplePie_Source +{ + var $item; + var $data = array(); + + function SimplePie_Source($item, $data) + { + $this->item = $item; + $this->data = $data; + } + + function __toString() + { + return md5(serialize($this->data)); + } + + function get_source_tags($namespace, $tag) + { + if (isset($this->data['child'][$namespace][$tag])) + { + return $this->data['child'][$namespace][$tag]; + } + else + { + return null; + } + } + + function get_base($element = array()) + { + return $this->item->get_base($element); + } + + function sanitize($data, $type, $base = '') + { + return $this->item->sanitize($data, $type, $base); + } + + function get_item() + { + return $this->item; + } + + function get_title() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + function get_category($key = 0) + { + $categories = $this->get_categories(); + if (isset($categories[$key])) + { + return $categories[$key]; + } + else + { + return null; + } + } + + function get_categories() + { + $categories = array(); + + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['attribs']['']['term'])) + { + $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = new $this->item->feed->category_class($term, $scheme, $label); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) + { + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] = new $this->item->feed->category_class($term, $scheme, null); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) + { + $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) + { + $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + + if (!empty($categories)) + { + return SimplePie_Misc::array_unique($categories); + } + else + { + return null; + } + } + + function get_author($key = 0) + { + $authors = $this->get_authors(); + if (isset($authors[$key])) + { + return $authors[$key]; + } + else + { + return null; + } + } + + function get_authors() + { + $authors = array(); + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) + { + $name = null; + $uri = null; + $email = null; + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $authors[] = new $this->item->feed->author_class($name, $uri, $email); + } + } + if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) + { + $name = null; + $url = null; + $email = null; + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $authors[] = new $this->item->feed->author_class($name, $url, $email); + } + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) + { + $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) + { + $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) + { + $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + + if (!empty($authors)) + { + return SimplePie_Misc::array_unique($authors); + } + else + { + return null; + } + } + + function get_contributor($key = 0) + { + $contributors = $this->get_contributors(); + if (isset($contributors[$key])) + { + return $contributors[$key]; + } + else + { + return null; + } + } + + function get_contributors() + { + $contributors = array(); + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) + { + $name = null; + $uri = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $contributors[] = new $this->item->feed->author_class($name, $uri, $email); + } + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) + { + $name = null; + $url = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $contributors[] = new $this->item->feed->author_class($name, $url, $email); + } + } + + if (!empty($contributors)) + { + return SimplePie_Misc::array_unique($contributors); + } + else + { + return null; + } + } + + function get_link($key = 0, $rel = 'alternate') + { + $links = $this->get_links($rel); + if (isset($links[$key])) + { + return $links[$key]; + } + else + { + return null; + } + } + + /** + * Added for parity between the parent-level and the item/entry-level. + */ + function get_permalink() + { + return $this->get_link(0); + } + + function get_links($rel = 'alternate') + { + if (!isset($this->data['links'])) + { + $this->data['links'] = array(); + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) + { + foreach ($links as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + } + } + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) + { + foreach ($links as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + + } + } + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + + $keys = array_keys($this->data['links']); + foreach ($keys as $key) + { + if (SimplePie_Misc::is_isegment_nz_nc($key)) + { + if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); + $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; + } + else + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; + } + } + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + { + $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; + } + $this->data['links'][$key] = array_unique($this->data['links'][$key]); + } + } + + if (isset($this->data['links'][$rel])) + { + return $this->data['links'][$rel]; + } + else + { + return null; + } + } + + function get_description() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + else + { + return null; + } + } + + function get_copyright() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + function get_language() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['xml_lang'])) + { + return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + function get_latitude() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) + { + return (float) $match[1]; + } + else + { + return null; + } + } + + function get_longitude() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) + { + return (float) $return[0]['data']; + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) + { + return (float) $match[2]; + } + else + { + return null; + } + } + + function get_image_url() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) + { + return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + else + { + return null; + } + } +} + class SimplePie_Author { var $name; @@ -5851,11 +6998,11 @@ class SimplePie_Enclosure $mime = $mime[0]; // Process values for 'auto' - if ($width == 'auto') + if ($width === 'auto') { - if ($mime == 'video') + if ($mime === 'video') { - if ($height == 'auto') + if ($height === 'auto') { $width = 480; } @@ -5874,15 +7021,15 @@ class SimplePie_Enclosure } } - if ($height == 'auto') + if ($height === 'auto') { - if ($mime == 'audio') + if ($mime === 'audio') { $height = 0; } - elseif ($mime == 'video') + elseif ($mime === 'video') { - if ($width == 'auto') + if ($width === 'auto') { if ($widescreen) { @@ -5907,17 +7054,17 @@ class SimplePie_Enclosure $height = 376; } } - elseif ($mime == 'audio') + elseif ($mime === 'audio') { $height = 0; } // Set proper placeholder value - if ($mime == 'audio') + if ($mime === 'audio') { $placeholder = $audio; } - elseif ($mime == 'video') + elseif ($mime === 'video') { $placeholder = $video; } @@ -5936,7 +7083,7 @@ class SimplePie_Enclosure } // Odeo Feed MP3's - if ($handler == 'odeo') + if ($handler === 'odeo') { if ($native) { @@ -5949,7 +7096,7 @@ class SimplePie_Enclosure } // Flash - elseif ($handler == 'flash') + elseif ($handler === 'flash') { if ($native) { @@ -5963,7 +7110,7 @@ class SimplePie_Enclosure // Flash Media Player file types. // Preferred handler for MP3 file types. - elseif ($handler == 'fmedia' || ($handler == 'mp3' && $mediaplayer != '')) + elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) { $height += 20; if ($native) @@ -5978,15 +7125,17 @@ class SimplePie_Enclosure // QuickTime 7 file types. Need to test with QuickTime 6. // Only handle MP3's if the Flash Media Player is not present. - elseif ($handler == 'quicktime' || ($handler == 'mp3' && $mediaplayer == '')) + elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) { $height += 16; if ($native) { - if ($placeholder != ""){ + if ($placeholder !== '') + { $embed .= "get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\">"; } - else { + else + { $embed .= "get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\">"; } } @@ -5997,7 +7146,7 @@ class SimplePie_Enclosure } // Windows Media - elseif ($handler == 'wmedia') + elseif ($handler === 'wmedia') { $height += 45; if ($native) @@ -6019,14 +7168,14 @@ class SimplePie_Enclosure function get_real_type($find_handler = false) { // If it's Odeo, let's get it out of the way. - if (substr(strtolower($this->get_link()), 0, 15) == 'http://odeo.com') + if (substr(strtolower($this->get_link()), 0, 15) === 'http://odeo.com') { return 'odeo'; } // Mime-types by handler. $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash - $types_fmedia = array('video/flv', 'video/x-flv'); // Flash Media Player + $types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3 @@ -6236,9 +7385,9 @@ class SimplePie_Caption function get_language() { - if ($this->language !== null) + if ($this->lang !== null) { - return $this->language; + return $this->lang; } else { @@ -6496,7 +7645,7 @@ class SimplePie_File var $status_code; var $redirects = 0; var $error; - var $method; + var $method = SIMPLEPIE_FILE_SOURCE_NONE; function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) { @@ -6519,9 +7668,9 @@ class SimplePie_File { $headers = array(); } - if (!$force_fsockopen && extension_loaded('curl')) + if (!$force_fsockopen && function_exists('curl_exec')) { - $this->method = 'curl'; + $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL; $fp = curl_init(); $headers2 = array(); foreach ($headers as $key => $value) @@ -6547,7 +7696,7 @@ class SimplePie_File } $this->headers = curl_exec($fp); - if (curl_errno($fp) == 23 || curl_errno($fp) == 61) + if (curl_errno($fp) === 23 || curl_errno($fp) === 61) { curl_setopt($fp, CURLOPT_ENCODING, 'none'); $this->headers = curl_exec($fp); @@ -6569,17 +7718,10 @@ class SimplePie_File $this->headers = $parser->headers; $this->body = $parser->body; $this->status_code = $parser->status_code; - if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) + if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) { $this->redirects++; - if (isset($this->headers['content-location'])) - { - $location = SimplePie_Misc::absolutize_url($this->headers['location'], SimplePie_Misc::absolutize_url($this->headers['content-location'], $url)); - } - else - { - $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); - } + $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); } } @@ -6587,9 +7729,9 @@ class SimplePie_File } else { - $this->method = 'fsockopen'; + $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN; $url_parts = parse_url($url); - if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) == 'https') + if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') { $url_parts['host'] = "ssl://$url_parts[host]"; $url_parts['port'] = 443; @@ -6598,7 +7740,7 @@ class SimplePie_File { $url_parts['port'] = 80; } - $fp = fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout); + $fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout); if (!$fp) { $this->error = 'fsockopen error: ' . $errstr; @@ -6606,14 +7748,7 @@ class SimplePie_File } else { - if (function_exists('stream_set_timeout')) - { - stream_set_timeout($fp, $timeout); - } - else - { - socket_set_timeout($fp, $timeout); - } + stream_set_timeout($fp, $timeout); if (isset($url_parts['path'])) { if (isset($url_parts['query'])) @@ -6632,9 +7767,9 @@ class SimplePie_File $out = "GET $get HTTP/1.0\r\n"; $out .= "Host: $url_parts[host]\r\n"; $out .= "User-Agent: $useragent\r\n"; - if (function_exists('gzinflate')) + if (extension_loaded('zlib')) { - $out .= "Accept-Encoding: gzip,deflate\r\n"; + $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n"; } if (isset($url_parts['user']) && isset($url_parts['pass'])) @@ -6648,27 +7783,13 @@ class SimplePie_File $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); - if (function_exists('stream_get_meta_data')) - { - $info = stream_get_meta_data($fp); - } - else - { - $info = socket_get_status($fp); - } + $info = stream_get_meta_data($fp); $this->headers = ''; while (!$info['eof'] && !$info['timed_out']) { $this->headers .= fread($fp, 1160); - if (function_exists('stream_get_meta_data')) - { - $info = stream_get_meta_data($fp); - } - else - { - $info = socket_get_status($fp); - } + $info = stream_get_meta_data($fp); } if (!$info['timed_out']) { @@ -6678,26 +7799,47 @@ class SimplePie_File $this->headers = $parser->headers; $this->body = $parser->body; $this->status_code = $parser->status_code; - if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) + if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) { $this->redirects++; - if (isset($this->headers['content-location'])) - { - $location = SimplePie_Misc::absolutize_url($this->headers['location'], SimplePie_Misc::absolutize_url($this->headers['content-location'], $url)); - } - else - { - $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); - } + $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); } - if (isset($this->headers['content-encoding']) && ($this->headers['content-encoding'] == 'gzip' || $this->headers['content-encoding'] == 'deflate')) + if (isset($this->headers['content-encoding'])) { - if (substr($this->body, 0, 8) == "\x1f\x8b\x08\x00\x00\x00\x00\x00") + // Hey, we act dumb elsewhere, so let's do that here too + switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) { - $this->body = substr($this->body, 10); + case 'gzip': + case 'x-gzip': + $decoder = new SimplePie_gzdecode($this->body); + if (!$decoder->parse()) + { + $this->error = 'Unable to decode HTTP "gzip" stream'; + $this->success = false; + } + else + { + $this->body = $decoder->data; + } + break; + + case 'deflate': + if (($body = gzuncompress($this->body)) === false) + { + if (($body = gzinflate($this->body)) === false) + { + $this->error = 'Unable to decode HTTP "deflate" stream'; + $this->success = false; + } + } + $this->body = $body; + break; + + default: + $this->error = 'Unknown content coding'; + $this->success = false; } - $this->body = gzinflate($this->body); } } } @@ -6710,33 +7852,15 @@ class SimplePie_File } } } - elseif (function_exists('file_get_contents')) + else { - $this->method = 'file_get_contents'; + $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS; if (!$this->body = file_get_contents($url)) { $this->error = 'file_get_contents could not read the file'; $this->success = false; } } - else - { - $this->method = 'fopen'; - if (($fp = fopen($url, 'rb')) === false) - { - $this->error = 'failed to open stream: No such file or directory'; - $this->success = false; - } - else - { - $this->body = ''; - while (!feof($fp)) - { - $this->body .= fread($fp, 8192); - } - fclose($fp); - } - } } } @@ -6744,7 +7868,6 @@ class SimplePie_File * HTTP Response Parser * * @package SimplePie - * @todo Support HTTP Requests */ class SimplePie_HTTP_Parser { @@ -6752,17 +7875,17 @@ class SimplePie_HTTP_Parser * HTTP Version * * @access public - * @var string + * @var float */ - var $http_version = ''; + var $http_version = 0.0; /** * Status code * * @access public - * @var string + * @var int */ - var $status_code = ''; + var $status_code = 0; /** * Reason phrase @@ -6794,7 +7917,7 @@ class SimplePie_HTTP_Parser * @access private * @var string */ - var $state = 'start'; + var $state = 'http_version'; /** * Input data @@ -6815,8 +7938,8 @@ class SimplePie_HTTP_Parser /** * Current position of the pointer * - * @access private * @var int + * @access private */ var $position = 0; @@ -6856,13 +7979,13 @@ class SimplePie_HTTP_Parser */ function parse() { - while ($this->state && $this->state != 'emit' && $this->has_data()) + while ($this->state && $this->state !== 'emit' && $this->has_data()) { $state = $this->state; $this->$state(); } $this->data = ''; - if ($this->state == 'emit') + if ($this->state === 'emit' || $this->state === 'body') { return true; } @@ -6870,6 +7993,7 @@ class SimplePie_HTTP_Parser { $this->http_version = ''; $this->status_code = ''; + $this->reason = ''; $this->headers = array(); $this->body = ''; return false; @@ -6895,119 +8019,108 @@ class SimplePie_HTTP_Parser */ function is_linear_whitespace() { - return (bool) (strspn($this->data, "\x09\x20", $this->position, 1) - || (substr($this->data, $this->position, 2) == "\r\n" && strspn($this->data, "\x09\x20", $this->position + 2, 1)) - || (strspn($this->data, "\r\n", $this->position, 1) && strspn($this->data, "\x09\x20", $this->position + 1, 1))); + return (bool) ($this->data[$this->position] === "\x09" + || $this->data[$this->position] === "\x20" + || ($this->data[$this->position] === "\x0A" + && isset($this->data[$this->position + 1]) + && ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20"))); } /** - * The starting state of the state machine, see if the data is a response or request - * - * @access private - */ - function start() - { - $this->state = 'http_version_response'; - } - - /** - * Parse an HTTP-version string + * Parse the HTTP version * * @access private */ function http_version() { - if (preg_match('/^HTTP\/([0-9]+\.[0-9]+)/i', substr($this->data, $this->position, strcspn($this->data, "\r\n", $this->position)), $match)) + if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/') { - $this->position += strlen($match[0]); - $this->http_version = $match[1]; - return true; + $len = strspn($this->data, '0123456789.', 5); + $this->http_version = substr($this->data, 5, $len); + $this->position += 5 + $len; + if (substr_count($this->http_version, '.') <= 1) + { + $this->http_version = (float) $this->http_version; + $this->position += strspn($this->data, "\x09\x20", $this->position); + $this->state = 'status'; + } + else + { + $this->state = false; + } } else { - return false; + $this->state = false; } } /** - * Parse LWS, replacing consecutive characters with a single space + * Parse the status code * * @access private */ - function linear_whitespace() + function status() { - do + if ($len = strspn($this->data, '0123456789', $this->position)) { - if (substr($this->data, $this->position, 2) == "\r\n") - { - $this->position += 2; - } - elseif (strspn($this->data, "\r\n", $this->position, 1)) - { - $this->position++; - } - $this->position += strspn($this->data, "\x09\x20", $this->position); - } while ($this->is_linear_whitespace()); - $this->value .= "\x20"; + $this->status_code = (int) substr($this->data, $this->position, $len); + $this->position += $len; + $this->state = 'reason'; + } + else + { + $this->state = false; + } } /** - * Parse an HTTP-version string within a response + * Parse the reason phrase * * @access private */ - function http_version_response() + function reason() { - if ($this->http_version() && $this->data[$this->position] == "\x20") + $len = strcspn($this->data, "\x0A", $this->position); + $this->reason = trim(substr($this->data, $this->position, $len), "\x09\x0D\x20"); + $this->position += $len + 1; + $this->state = 'new_line'; + } + + /** + * Deal with a new line, shifting data around as needed + * + * @access private + */ + function new_line() + { + $this->value = trim($this->value, "\x0D\x20"); + if ($this->name !== '' && $this->value !== '') + { + $this->name = strtolower($this->name); + if (isset($this->headers[$this->name])) + { + $this->headers[$this->name] .= ', ' . $this->value; + } + else + { + $this->headers[$this->name] = $this->value; + } + } + $this->name = ''; + $this->value = ''; + if (substr($this->data[$this->position], 0, 2) === "\x0D\x0A") + { + $this->position += 2; + $this->state = 'body'; + } + elseif ($this->data[$this->position] === "\x0A") { - $this->state = 'status_code'; $this->position++; + $this->state = 'body'; } else { - $this->state = false; - } - } - - /** - * Parse a status code - * - * @access private - */ - function status_code() - { - if (strspn($this->data, '1234567890', $this->position, 3) == 3) - { - $this->status_code = substr($this->data, $this->position, 3); - $this->state = 'reason_phrase'; - $this->position += 3; - } - else - { - $this->state = false; - } - } - - /** - * Skip over the reason phrase (it has no normative value, and you can send absolutely anything here) - * - * @access private - */ - function reason_phrase() - { - $len = strcspn($this->data, "\r\n", $this->position); - $this->reason = substr($this->data, $this->position, $len); - $this->position += $len; - if ($this->has_data()) - { - if (substr($this->data, $this->position, 2) == "\r\n") - { - $this->position += 2; - } - elseif (strspn($this->data, "\r\n", $this->position, 1)) - { - $this->position++; - } $this->state = 'name'; } } @@ -7019,14 +8132,20 @@ class SimplePie_HTTP_Parser */ function name() { - $len = strcspn($this->data, ':', $this->position); - $this->name = substr($this->data, $this->position, $len); - $this->position += $len; - - if ($this->has_data() && $this->data[$this->position] == ':') + $len = strcspn($this->data, "\x0A:", $this->position); + if (isset($this->data[$this->position + $len])) { - $this->state = 'value_next'; - $this->position++; + if ($this->data[$this->position + $len] === "\x0A") + { + $this->position += $len; + $this->state = 'new_line'; + } + else + { + $this->name = substr($this->data, $this->position, $len); + $this->position += $len + 1; + $this->state = 'value'; + } } else { @@ -7035,34 +8154,56 @@ class SimplePie_HTTP_Parser } /** - * See what state to move the state machine to while within non-quoted header values + * Parse LWS, replacing consecutive LWS characters with a single space * * @access private */ - function value_next() + function linear_whitespace() + { + do + { + if (substr($this->data, $this->position, 2) === "\x0D\x0A") + { + $this->position += 2; + } + elseif ($this->data[$this->position] === "\x0A") + { + $this->position++; + } + $this->position += strspn($this->data, "\x09\x20", $this->position); + } while ($this->has_data() && $this->is_linear_whitespace()); + $this->value .= "\x20"; + } + + /** + * See what state to move to while within non-quoted header values + * + * @access private + */ + function value() { if ($this->is_linear_whitespace()) { - $this->state = 'value_linear_whitespace'; - } - elseif ($this->data[$this->position] == '"') - { - $this->state = 'value_quote_next'; - $this->position++; - } - elseif (substr($this->data, $this->position, 2) == "\r\n") - { - $this->state = 'end_crlf'; - $this->position += 2; - } - elseif (strspn($this->data, "\r\n", $this->position, 1)) - { - $this->state = 'end_crlf'; - $this->position++; + $this->linear_whitespace(); } else { - $this->state = 'value_no_quote'; + switch ($this->data[$this->position]) + { + case '"': + $this->position++; + $this->state = 'quote'; + break; + + case "\x0A": + $this->position++; + $this->state = 'new_line'; + break; + + default: + $this->state = 'value_char'; + break; + } } } @@ -7071,52 +8212,46 @@ class SimplePie_HTTP_Parser * * @access private */ - function value_no_quote() + function value_char() { - $len = strcspn($this->data, "\x09\x20\r\n\"", $this->position); + $len = strcspn($this->data, "\x09\x20\x0A\"", $this->position); $this->value .= substr($this->data, $this->position, $len); - $this->state = 'value_next'; $this->position += $len; + $this->state = 'value'; } /** - * Parse LWS outside quotes + * See what state to move to while within quoted header values * * @access private */ - function value_linear_whitespace() - { - $this->linear_whitespace(); - $this->state = 'value_next'; - } - - /** - * See what state to move the state machine to while within quoted header values - * - * @access private - */ - function value_quote_next() + function quote() { if ($this->is_linear_whitespace()) { - $this->state = 'value_linear_whitespace_quote'; + $this->linear_whitespace(); } else { switch ($this->data[$this->position]) { case '"': - $this->state = 'value_next'; $this->position++; + $this->state = 'value'; + break; + + case "\x0A": + $this->position++; + $this->state = 'new_line'; break; case '\\': - $this->state = 'value_quote_char'; $this->position++; + $this->state = 'quote_escaped'; break; default: - $this->state = 'value_quote'; + $this->state = 'quote_char'; break; } } @@ -7127,12 +8262,12 @@ class SimplePie_HTTP_Parser * * @access private */ - function value_quote() + function quote_char() { - $len = strcspn($this->data, "\x09\x20\r\n\"\\", $this->position); + $len = strcspn($this->data, "\x09\x20\x0A\"\\", $this->position); $this->value .= substr($this->data, $this->position, $len); $this->position += $len; - $this->state = 'value_quote_next'; + $this->state = 'value'; } /** @@ -7140,90 +8275,407 @@ class SimplePie_HTTP_Parser * * @access private */ - function value_quote_char() + function quote_escaped() { $this->value .= $this->data[$this->position]; - $this->state = 'value_quote_next'; $this->position++; + $this->state = 'quote'; } /** - * Parse LWS within quotes + * Parse the body * * @access private */ - function value_linear_whitespace_quote() + function body() { - $this->linear_whitespace(); - $this->state = 'value_quote_next'; + $this->body = substr($this->data, $this->position); + $this->state = 'emit'; + } +} + +/** + * gzdecode + * + * @package SimplePie + */ +class SimplePie_gzdecode +{ + /** + * Compressed data + * + * @access private + * @see gzdecode::$data + */ + var $compressed_data; + + /** + * Size of compressed data + * + * @access private + */ + var $compressed_size; + + /** + * Minimum size of a valid gzip string + * + * @access private + */ + var $min_compressed_size = 18; + + /** + * Current position of pointer + * + * @access private + */ + var $position = 0; + + /** + * Flags (FLG) + * + * @access private + */ + var $flags; + + /** + * Uncompressed data + * + * @access public + * @see gzdecode::$compressed_data + */ + var $data; + + /** + * Modified time + * + * @access public + */ + var $MTIME; + + /** + * Extra Flags + * + * @access public + */ + var $XFL; + + /** + * Operating System + * + * @access public + */ + var $OS; + + /** + * Subfield ID 1 + * + * @access public + * @see gzdecode::$extra_field + * @see gzdecode::$SI2 + */ + var $SI1; + + /** + * Subfield ID 2 + * + * @access public + * @see gzdecode::$extra_field + * @see gzdecode::$SI1 + */ + var $SI2; + + /** + * Extra field content + * + * @access public + * @see gzdecode::$SI1 + * @see gzdecode::$SI2 + */ + var $extra_field; + + /** + * Original filename + * + * @access public + */ + var $filename; + + /** + * Human readable comment + * + * @access public + */ + var $comment; + + /** + * Don't allow anything to be set + * + * @access public + */ + function __set($name, $value) + { + trigger_error("Cannot write property $name", E_USER_ERROR); } /** - * Parse a CRLF, and see whether we have a further header, or whether we are followed by the body + * Set the compressed string and related properties * - * @access private + * @access public */ - function end_crlf() + function SimplePie_gzdecode($data) { - $this->name = strtolower($this->name); - $this->value = trim($this->value, "\x20"); - if (isset($this->headers[$this->name])) - { - $this->headers[$this->name] .= ', ' . $this->value; - } - else - { - $this->headers[$this->name] = $this->value; - } + $this->compressed_data = $data; + $this->compressed_size = strlen($data); + } - if (substr($this->data, $this->position, 2) == "\r\n") + /** + * Decode the GZIP stream + * + * @access public + */ + function parse() + { + if ($this->compressed_size >= $this->min_compressed_size) { - $this->body = substr($this->data, $this->position + 2); - $this->state = 'emit'; - } - elseif (strspn($this->data, "\r\n", $this->position, 1)) - { - $this->body = substr($this->data, $this->position + 1); - $this->state = 'emit'; + // Check ID1, ID2, and CM + if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08") + { + return false; + } + + // Get the FLG (FLaGs) + $this->flags = ord($this->compressed_data[3]); + + // FLG bits above (1 << 4) are reserved + if ($this->flags > 0x1F) + { + return false; + } + + // Advance the pointer after the above + $this->position += 4; + + // MTIME + $mtime = substr($this->compressed_data, $this->position, 4); + // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness + if (current(unpack('S', "\x00\x01")) === 1) + { + $mtime = strrev($mtime); + } + $this->MTIME = current(unpack('l', $mtime)); + $this->position += 4; + + // Get the XFL (eXtra FLags) + $this->XFL = ord($this->compressed_data[$this->position++]); + + // Get the OS (Operating System) + $this->OS = ord($this->compressed_data[$this->position++]); + + // Parse the FEXTRA + if ($this->flags & 4) + { + // Read subfield IDs + $this->SI1 = $this->compressed_data[$this->position++]; + $this->SI2 = $this->compressed_data[$this->position++]; + + // SI2 set to zero is reserved for future use + if ($this->SI2 === "\x00") + { + return false; + } + + // Get the length of the extra field + $len = current(unpack('v', substr($this->compressed_data, $this->position, 2))); + $position += 2; + + // Check the length of the string is still valid + $this->min_compressed_size += $len + 4; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Set the extra field to the given data + $this->extra_field = substr($this->compressed_data, $this->position, $len); + $this->position += $len; + } + else + { + return false; + } + } + + // Parse the FNAME + if ($this->flags & 8) + { + // Get the length of the filename + $len = strcspn($this->compressed_data, "\x00", $this->position); + + // Check the length of the string is still valid + $this->min_compressed_size += $len + 1; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Set the original filename to the given string + $this->filename = substr($this->compressed_data, $this->position, $len); + $this->position += $len + 1; + } + else + { + return false; + } + } + + // Parse the FCOMMENT + if ($this->flags & 16) + { + // Get the length of the comment + $len = strcspn($this->compressed_data, "\x00", $this->position); + + // Check the length of the string is still valid + $this->min_compressed_size += $len + 1; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Set the original comment to the given string + $this->comment = substr($this->compressed_data, $this->position, $len); + $this->position += $len + 1; + } + else + { + return false; + } + } + + // Parse the FHCRC + if ($this->flags & 2) + { + // Check the length of the string is still valid + $this->min_compressed_size += $len + 2; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Read the CRC + $crc = current(unpack('v', substr($this->compressed_data, $this->position, 2))); + + // Check the CRC matches + if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc) + { + $this->position += 2; + } + else + { + return false; + } + } + else + { + return false; + } + } + + // Decompress the actual data + if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) + { + return false; + } + else + { + $this->position = $this->compressed_size - 8; + } + + // Check CRC of data + $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4))); + $this->position += 4; + /*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc)) + { + return false; + }*/ + + // Check ISIZE of data + $isize = current(unpack('V', substr($this->compressed_data, $this->position, 4))); + $this->position += 4; + if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize)) + { + return false; + } + + // Wow, against all odds, we've actually got a valid gzip string + return true; } else { - $this->name = ''; - $this->value = ''; - $this->state = 'name'; + return false; } } } class SimplePie_Cache +{ + /** + * Don't call the constructor. Please. + * + * @access private + */ + function SimplePie_Cache() + { + trigger_error('Please call SimplePie_Cache::create() instead of the constructor', E_USER_ERROR); + } + + /** + * Create a new SimplePie_Cache object + * + * @static + * @access public + */ + function create($location, $filename, $extension) + { + $location_iri = new SimplePie_IRI($location); + switch ($location_iri->get_scheme()) + { + case 'mysql': + if (extension_loaded('mysql')) + { + return new SimplePie_Cache_MySQL($location_iri, $filename, $extension); + } + break; + + default: + return new SimplePie_Cache_File($location, $filename, $extension); + } + } +} + +class SimplePie_Cache_File { var $location; var $filename; var $extension; var $name; - function SimplePie_Cache($location, $filename, $extension) + function SimplePie_Cache_File($location, $filename, $extension) { $this->location = $location; - $this->filename = rawurlencode($filename); - $this->extension = rawurlencode($extension); - $this->name = "$location/$this->filename.$this->extension"; + $this->filename = $filename; + $this->extension = $extension; + $this->name = "$this->location/$this->filename.$this->extension"; } function save($data) { if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location)) { + if (is_a($data, 'SimplePie')) + { + $data = $data->data; + } + + $data = serialize($data); + if (function_exists('file_put_contents')) { - return (bool) file_put_contents($this->name, serialize($data)); + return (bool) file_put_contents($this->name, $data); } else { $fp = fopen($this->name, 'wb'); if ($fp) { - fwrite($fp, serialize($data)); + fwrite($fp, $data); fclose($fp); return true; } @@ -7236,20 +8688,7 @@ class SimplePie_Cache { if (file_exists($this->name) && is_readable($this->name)) { - if (function_exists('file_get_contents')) - { - return unserialize(file_get_contents($this->name)); - } - elseif (($fp = fopen($this->name, 'rb')) !== false) - { - $data = ''; - while (!feof($fp)) - { - $data .= fread($fp, 8192); - } - fclose($fp); - return unserialize($data); - } + return unserialize(file_get_contents($this->name)); } return false; } @@ -7282,6 +8721,358 @@ class SimplePie_Cache } } +class SimplePie_Cache_DB +{ + function prepare_simplepie_object_for_cache($data) + { + $items = $data->get_items(); + $items_by_id = array(); + + if (!empty($items)) + { + foreach ($items as $item) + { + $items_by_id[$item->get_id()] = $item; + } + + if (count($items_by_id) !== count($items)) + { + $items_by_id = array(); + foreach ($items as $item) + { + $items_by_id[$item->get_id(true)] = $item; + } + } + + if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]; + } + else + { + $channel = null; + } + + if ($channel !== null) + { + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']); + } + } + if (isset($data->data['items'])) + { + unset($data->data['items']); + } + if (isset($data->data['ordered_items'])) + { + unset($data->data['ordered_items']); + } + } + return array(serialize($data->data), $items_by_id); + } +} + +class SimplePie_Cache_MySQL extends SimplePie_Cache_DB +{ + var $mysql; + var $options; + var $id; + + function SimplePie_Cache_MySQL($mysql_location, $name, $extension) + { + $host = $mysql_location->get_host(); + if (SimplePie_Misc::stripos($host, 'unix(') === 0 && substr($host, -1) === ')') + { + $server = ':' . substr($host, 5, -1); + } + else + { + $server = $host; + if ($mysql_location->get_port() !== null) + { + $server .= ':' . $mysql_location->get_port(); + } + } + + if (strpos($mysql_location->get_userinfo(), ':') !== false) + { + list($username, $password) = explode(':', $mysql_location->get_userinfo(), 2); + } + else + { + $username = $mysql_location->get_userinfo(); + $password = null; + } + + if ($this->mysql = mysql_connect($server, $username, $password)) + { + $this->id = $name . $extension; + $this->options = SimplePie_Misc::parse_str($mysql_location->get_query()); + if (!isset($this->options['prefix'][0])) + { + $this->options['prefix'][0] = ''; + } + + if (mysql_select_db(ltrim($mysql_location->get_path(), '/')) + && mysql_query('SET NAMES utf8') + && ($query = mysql_unbuffered_query('SHOW TABLES'))) + { + $db = array(); + while ($row = mysql_fetch_row($query)) + { + $db[] = $row[0]; + } + + if (!in_array($this->options['prefix'][0] . 'cache_data', $db)) + { + if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))')) + { + $this->mysql = null; + } + } + + if (!in_array($this->options['prefix'][0] . 'items', $db)) + { + if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))')) + { + $this->mysql = null; + } + } + } + else + { + $this->mysql = null; + } + } + } + + function save($data) + { + if ($this->mysql) + { + $feed_id = "'" . mysql_real_escape_string($this->id) . "'"; + + if (is_a($data, 'SimplePie')) + { + if (SIMPLEPIE_PHP5) + { + // This keyword needs to defy coding standards for PHP4 compatibility + $data = clone($data); + } + + $prepared = $this->prepare_simplepie_object_for_cache($data); + + if ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql)) + { + if (mysql_num_rows($query)) + { + $items = count($prepared[1]); + if ($items) + { + $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = ' . $items . ', `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id; + } + else + { + $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id; + } + + if (!mysql_query($sql, $this->mysql)) + { + return false; + } + } + elseif (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(' . $feed_id . ', ' . count($prepared[1]) . ', \'' . mysql_real_escape_string($prepared[0]) . '\', ' . time() . ')', $this->mysql)) + { + return false; + } + + $ids = array_keys($prepared[1]); + if (!empty($ids)) + { + foreach ($ids as $id) + { + $database_ids[] = mysql_real_escape_string($id); + } + + if ($query = mysql_unbuffered_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'items` WHERE `id` = \'' . implode('\' OR `id` = \'', $database_ids) . '\' AND `feed_id` = ' . $feed_id, $this->mysql)) + { + $existing_ids = array(); + while ($row = mysql_fetch_row($query)) + { + $existing_ids[] = $row[0]; + } + + $new_ids = array_diff($ids, $existing_ids); + + foreach ($new_ids as $new_id) + { + if (!($date = $prepared[1][$new_id]->get_date('U'))) + { + $date = time(); + } + + if (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(' . $feed_id . ', \'' . mysql_real_escape_string($new_id) . '\', \'' . mysql_real_escape_string(serialize($prepared[1][$new_id]->data)) . '\', ' . $date . ')', $this->mysql)) + { + return false; + } + } + return true; + } + } + else + { + return true; + } + } + } + elseif ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql)) + { + if (mysql_num_rows($query)) + { + if (mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = 0, `data` = \'' . mysql_real_escape_string(serialize($data)) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id, $this->mysql)) + { + return true; + } + } + elseif (mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(\'' . mysql_real_escape_string($this->id) . '\', 0, \'' . mysql_real_escape_string(serialize($data)) . '\', ' . time() . ')', $this->mysql)) + { + return true; + } + } + } + return false; + } + + function load() + { + if ($this->mysql && ($query = mysql_query('SELECT `items`, `data` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query))) + { + $data = unserialize($row[1]); + + if (isset($this->options['items'][0])) + { + $items = (int) $this->options['items'][0]; + } + else + { + $items = (int) $row[0]; + } + + if ($items !== 0) + { + if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]; + } + else + { + $feed = null; + } + + if ($feed !== null) + { + $sql = 'SELECT `data` FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . '\' ORDER BY `posted` DESC'; + if ($items > 0) + { + $sql .= ' LIMIT ' . $items; + } + + if ($query = mysql_unbuffered_query($sql, $this->mysql)) + { + while ($row = mysql_fetch_row($query)) + { + $feed['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'][] = unserialize($row[0]); + } + } + else + { + return false; + } + } + } + return $data; + } + return false; + } + + function mtime() + { + if ($this->mysql && ($query = mysql_query('SELECT `mtime` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query))) + { + return $row[0]; + } + else + { + return false; + } + } + + function touch() + { + if ($this->mysql && ($query = mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `mtime` = ' . time() . ' WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && mysql_affected_rows($this->mysql)) + { + return true; + } + else + { + return false; + } + } + + function unlink() + { + if ($this->mysql && ($query = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($query2 = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql))) + { + return true; + } + else + { + return false; + } + } +} + class SimplePie_Misc { function time_hms($seconds) @@ -7314,89 +9105,14 @@ class SimplePie_Misc function absolutize_url($relative, $base) { - if ($relative !== '') - { - $relative = SimplePie_Misc::parse_url($relative); - if ($relative['scheme'] !== '') - { - $target = $relative; - } - elseif ($base !== '') - { - $base = SimplePie_Misc::parse_url($base); - $target = SimplePie_Misc::parse_url(''); - if ($relative['authority'] !== '') - { - $target = $relative; - $target['scheme'] = $base['scheme']; - } - else - { - $target['scheme'] = $base['scheme']; - $target['authority'] = $base['authority']; - if ($relative['path'] !== '') - { - if (strpos($relative['path'], '/') === 0) - { - $target['path'] = $relative['path']; - } - elseif (($target['path'] = dirname("$base[path].")) == '/') - { - $target['path'] .= $relative['path']; - } - else - { - $target['path'] .= '/' . $relative['path']; - } - if ($relative['query'] !== '') - { - $target['query'] = $relative['query']; - } - } - else - { - if ($base['path'] !== '') - { - $target['path'] = $base['path']; - } - else - { - $target['path'] = '/'; - } - if ($relative['query'] !== '') - { - $target['query'] = $relative['query']; - } - elseif ($base['query'] !== '') - { - $target['query'] = $base['query']; - } - } - } - if ($relative['fragment'] !== '') - { - $target['fragment'] = $relative['fragment']; - } - } - else - { - // No base URL, just return the relative URL - $target = $relative; - } - $return = SimplePie_Misc::compress_parse_url($target['scheme'], $target['authority'], $target['path'], $target['query'], $target['fragment']); - } - else - { - $return = $base; - } - $return = SimplePie_Misc::normalize_url($return); - return $return; + $iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative); + return $iri->get_iri(); } function remove_dot_segments($input) { $output = ''; - while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input == '.' || $input == '..') + while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') { // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, if (strpos($input, '../') === 0) @@ -7412,7 +9128,7 @@ class SimplePie_Misc { $input = substr_replace($input, '/', 0, 3); } - elseif ($input == '/.') + elseif ($input === '/.') { $input = '/'; } @@ -7422,13 +9138,13 @@ class SimplePie_Misc $input = substr_replace($input, '/', 0, 4); $output = substr_replace($output, '', strrpos($output, '/')); } - elseif ($input == '/..') + elseif ($input === '/..') { $input = '/'; $output = substr_replace($output, '', strrpos($output, '/')); } // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, - elseif ($input == '.' || $input == '..') + elseif ($input === '.' || $input === '..') { $input = ''; } @@ -7468,11 +9184,11 @@ class SimplePie_Misc $return[$i]['content'] = $matches[$i][4][0]; } $return[$i]['attribs'] = array(); - if (isset($matches[$i][2][0]) && preg_match_all('/((?:[^\s:]+:)?[^\s:]+)(?:\s*=\s*(?:"([^"]*)"|\'([^\']*)\'|([a-z0-9\-._:]*)))?\s/U', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) + if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) { for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) { - if (count($attribs[$j]) == 2) + if (count($attribs[$j]) === 2) { $attribs[$j][2] = $attribs[$j][1]; } @@ -7505,22 +9221,42 @@ class SimplePie_Misc function error($message, $level, $file, $line) { - switch ($level) + if ((ini_get('error_reporting') & $level) > 0) { - case E_USER_ERROR: - $note = 'PHP Error'; - break; - case E_USER_WARNING: - $note = 'PHP Warning'; - break; - case E_USER_NOTICE: - $note = 'PHP Notice'; - break; - default: - $note = 'Unknown Error'; - break; + switch ($level) + { + case E_USER_ERROR: + $note = 'PHP Error'; + break; + case E_USER_WARNING: + $note = 'PHP Warning'; + break; + case E_USER_NOTICE: + $note = 'PHP Notice'; + break; + default: + $note = 'Unknown Error'; + break; + } + + $log_error = true; + if (!function_exists('error_log')) + { + $log_error = false; + } + + $log_file = @ini_get('error_log'); + if (!empty($log_file) && ('syslog' != $log_file) && !@is_writable($log_file)) + { + $log_error = false; + } + + if ($log_error) + { + @error_log("$note: $message in $file on line $line", 0); + } } - error_log("$note: $message in $file on line $line", 0); + return $message; } @@ -7543,16 +9279,23 @@ class SimplePie_Misc * @param str $cache_class Name of the cache-handling class being used * in SimplePie. Defaults to 'SimplePie_Cache', and should be left * as-is unless you've overloaded the class. - * @param str $cache_name_function Function that converts the filename - * for saving. Defaults to 'md5'. + * @param str $cache_name_function Obsolete. Exists for backwards + * compatibility reasons only. */ function display_cached_file($identifier_url, $cache_location = './cache', $cache_extension = 'spc', $cache_class = 'SimplePie_Cache', $cache_name_function = 'md5') { - $cache = new $cache_class($cache_location, call_user_func($cache_name_function, $identifier_url), $cache_extension); + $cache = call_user_func(array($cache_class, 'create'), $cache_location, $identifier_url, $cache_extension); if ($file = $cache->load()) { - header('Content-type:' . $file['headers']['content-type']); + if (isset($file['headers']['content-type'])) + { + header('Content-type:' . $file['headers']['content-type']); + } + else + { + header('Content-type: application/octet-stream'); + } header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days echo $file['body']; exit; @@ -7565,7 +9308,7 @@ class SimplePie_Misc { $url = SimplePie_Misc::normalize_url($url); $parsed = SimplePie_Misc::parse_url($url); - if ($parsed['scheme'] !== '' && $parsed['scheme'] != 'http' && $parsed['scheme'] != 'https') + if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https') { return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http); } @@ -7575,15 +9318,15 @@ class SimplePie_Misc return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http); } - if ($http == 2 && $parsed['scheme'] !== '') + if ($http === 2 && $parsed['scheme'] !== '') { return "feed:$url"; } - elseif ($http == 3 && strtolower($parsed['scheme']) == 'http') + elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') { return substr_replace($url, 'podcast', 0, 4); } - elseif ($http == 4 && strtolower($parsed['scheme']) == 'http') + elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') { return substr_replace($url, 'itpc', 0, 4); } @@ -7595,68 +9338,37 @@ class SimplePie_Misc function parse_url($url) { - static $cache = array(); - if (isset($cache[$url])) - { - return $cache[$url]; - } - elseif (preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $url, $match)) - { - for ($i = count($match); $i <= 9; $i++) - { - $match[$i] = ''; - } - return $cache[$url] = array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]); - } - else - { - return $cache[$url] = array('scheme' => '', 'authority' => '', 'path' => '', 'query' => '', 'fragment' => ''); - } + $iri = new SimplePie_IRI($url); + return array( + 'scheme' => (string) $iri->get_scheme(), + 'authority' => (string) $iri->get_authority(), + 'path' => (string) $iri->get_path(), + 'query' => (string) $iri->get_query(), + 'fragment' => (string) $iri->get_fragment() + ); } function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '') { - $return = ''; - if ($scheme !== '') - { - $return .= "$scheme:"; - } - if ($authority !== '') - { - $return .= "//$authority"; - } - if ($path !== '') - { - $return .= $path; - } - if ($query !== '') - { - $return .= "?$query"; - } - if ($fragment !== '') - { - $return .= "#$fragment"; - } - return $return; + $iri = new SimplePie_IRI(''); + $iri->set_scheme($scheme); + $iri->set_authority($authority); + $iri->set_path($path); + $iri->set_query($query); + $iri->set_fragment($fragment); + return $iri->get_iri(); } function normalize_url($url) { - $url = preg_replace_callback('/%([0-9A-Fa-f]{2})/', array('SimplePie_Misc', 'percent_encoding_normalization'), $url); - $url = SimplePie_Misc::parse_url($url); - $url['scheme'] = strtolower($url['scheme']); - if ($url['authority'] !== '') - { - $url['authority'] = strtolower($url['authority']); - $url['path'] = SimplePie_Misc::remove_dot_segments($url['path']); - } - return SimplePie_Misc::compress_parse_url($url['scheme'], $url['authority'], $url['path'], $url['query'], $url['fragment']); + $iri = new SimplePie_IRI($url); + return $iri->get_iri(); } function percent_encoding_normalization($match) { $integer = hexdec($match[1]); - if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer == 0x2D || $integer == 0x2E || $integer == 0x5F || $integer == 0x7E) + if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E) { return chr($integer); } @@ -7679,16 +9391,15 @@ class SimplePie_Misc */ function utf8_bad_replace($str) { - if (function_exists('iconv')) + if (function_exists('iconv') && ($return = @iconv('UTF-8', 'UTF-8//IGNORE', $str))) { - $out = iconv('UTF-8', 'UTF-8//IGNORE', $str); - if($out !== false) return $out; + return $return; } - if (function_exists('mb_convert_encoding')) + elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($str, 'UTF-8', 'UTF-8'))) { - return mb_convert_encoding($str, 'UTF-8', 'UTF-8'); + return $return; } - elseif (preg_match_all('/([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})/', $str, $matches)) + elseif (preg_match_all('/(?:[\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})+/', $str, $matches)) { return implode("\xEF\xBF\xBD", $matches[0]); } @@ -7702,1372 +9413,1375 @@ class SimplePie_Misc } } + /** + * Converts a Windows-1252 encoded string to a UTF-8 encoded string + * + * @static + * @access public + * @param string $string Windows-1252 encoded string + * @return string UTF-8 encoded string + */ + function windows_1252_to_utf8($string) + { + static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF"); + + return strtr($string, $convert_table); + } + function change_encoding($data, $input, $output) { $input = SimplePie_Misc::encoding($input); $output = SimplePie_Misc::encoding($output); - if (function_exists('iconv') && ($return = @iconv($input, "$output//IGNORE", $data))) + // We fail to fail on non US-ASCII bytes + if ($input === 'US-ASCII') + { + static $non_ascii_octects = ''; + if (!$non_ascii_octects) + { + for ($i = 0x80; $i <= 0xFF; $i++) + { + $non_ascii_octects .= chr($i); + } + } + $data = substr($data, 0, strcspn($data, $non_ascii_octects)); + } + + // This is first, as behaviour of this is completely predictable + if ($input === 'Windows-1252' && $output === 'UTF-8') + { + return SimplePie_Misc::windows_1252_to_utf8($data); + } + // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported). + elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && ($return = @mb_convert_encoding($data, $output, $input))) { return $return; } + // This is last, as behaviour of this varies with OS userland and PHP version elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data))) { return $return; } - elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($data, $output, $input))) + // If we can't do anything, just fail + else { - return $return; + return false; } - elseif ($input == 'ISO-8859-1' && $output == 'UTF-8') - { - return utf8_encode($data); - } - elseif ($input == 'UTF-8' && $output == 'ISO-8859-1') - { - return utf8_decode($data); - } - return $data; } - function encoding($encoding) + function encoding($charset) { - // Character sets are case-insensitive (though we'll return them in the form given in their registration) - switch (strtoupper($encoding)) + // Normalization from UTS #22 + switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) { - case 'ANSI_X3.4-1968': - case 'ISO-IR-6': - case 'ANSI_X3.4-1986': - case 'ISO_646.IRV:1991': - case 'ASCII': - case 'ISO646-US': - case 'US-ASCII': - case 'US': - case 'IBM367': - case 'CP367': - case 'CSASCII': - return 'US-ASCII'; - - case 'ISO_8859-1:1987': - case 'ISO-IR-100': - case 'ISO_8859-1': - case 'ISO-8859-1': - case 'LATIN1': - case 'L1': - case 'IBM819': - case 'CP819': - case 'CSISOLATIN1': - return 'ISO-8859-1'; - - case 'ISO_8859-2:1987': - case 'ISO-IR-101': - case 'ISO_8859-2': - case 'ISO-8859-2': - case 'LATIN2': - case 'L2': - case 'CSISOLATIN2': - return 'ISO-8859-2'; - - case 'ISO_8859-3:1988': - case 'ISO-IR-109': - case 'ISO_8859-3': - case 'ISO-8859-3': - case 'LATIN3': - case 'L3': - case 'CSISOLATIN3': - return 'ISO-8859-3'; - - case 'ISO_8859-4:1988': - case 'ISO-IR-110': - case 'ISO_8859-4': - case 'ISO-8859-4': - case 'LATIN4': - case 'L4': - case 'CSISOLATIN4': - return 'ISO-8859-4'; - - case 'ISO_8859-5:1988': - case 'ISO-IR-144': - case 'ISO_8859-5': - case 'ISO-8859-5': - case 'CYRILLIC': - case 'CSISOLATINCYRILLIC': - return 'ISO-8859-5'; - - case 'ISO_8859-6:1987': - case 'ISO-IR-127': - case 'ISO_8859-6': - case 'ISO-8859-6': - case 'ECMA-114': - case 'ASMO-708': - case 'ARABIC': - case 'CSISOLATINARABIC': - return 'ISO-8859-6'; - - case 'ISO_8859-7:1987': - case 'ISO-IR-126': - case 'ISO_8859-7': - case 'ISO-8859-7': - case 'ELOT_928': - case 'ECMA-118': - case 'GREEK': - case 'GREEK8': - case 'CSISOLATINGREEK': - return 'ISO-8859-7'; - - case 'ISO_8859-8:1988': - case 'ISO-IR-138': - case 'ISO_8859-8': - case 'ISO-8859-8': - case 'HEBREW': - case 'CSISOLATINHEBREW': - return 'ISO-8859-8'; - - case 'ISO_8859-9:1989': - case 'ISO-IR-148': - case 'ISO_8859-9': - case 'ISO-8859-9': - case 'LATIN5': - case 'L5': - case 'CSISOLATIN5': - return 'ISO-8859-9'; - - case 'ISO-8859-10': - case 'ISO-IR-157': - case 'L6': - case 'ISO_8859-10:1992': - case 'CSISOLATIN6': - case 'LATIN6': - return 'ISO-8859-10'; - - case 'ISO_6937-2-ADD': - case 'ISO-IR-142': - case 'CSISOTEXTCOMM': - return 'ISO_6937-2-add'; - - case 'JIS_X0201': - case 'X0201': - case 'CSHALFWIDTHKATAKANA': - return 'JIS_X0201'; - - case 'JIS_ENCODING': - case 'CSJISENCODING': - return 'JIS_Encoding'; - - case 'SHIFT_JIS': - case 'MS_KANJI': - case 'CSSHIFTJIS': - return 'Shift_JIS'; - - case 'EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE': - case 'CSEUCPKDFMTJAPANESE': - case 'EUC-JP': - return 'EUC-JP'; - - case 'EXTENDED_UNIX_CODE_FIXED_WIDTH_FOR_JAPANESE': - case 'CSEUCFIXWIDJAPANESE': - return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; - - case 'BS_4730': - case 'ISO-IR-4': - case 'ISO646-GB': - case 'GB': - case 'UK': - case 'CSISO4UNITEDKINGDOM': - return 'BS_4730'; - - case 'SEN_850200_C': - case 'ISO-IR-11': - case 'ISO646-SE2': - case 'SE2': - case 'CSISO11SWEDISHFORNAMES': - return 'SEN_850200_C'; - - case 'IT': - case 'ISO-IR-15': - case 'ISO646-IT': - case 'CSISO15ITALIAN': - return 'IT'; - - case 'ES': - case 'ISO-IR-17': - case 'ISO646-ES': - case 'CSISO17SPANISH': - return 'ES'; - - case 'DIN_66003': - case 'ISO-IR-21': - case 'DE': - case 'ISO646-DE': - case 'CSISO21GERMAN': - return 'DIN_66003'; - - case 'NS_4551-1': - case 'ISO-IR-60': - case 'ISO646-NO': - case 'NO': - case 'CSISO60DANISHNORWEGIAN': - case 'CSISO60NORWEGIAN1': - return 'NS_4551-1'; - - case 'NF_Z_62-010': - case 'ISO-IR-69': - case 'ISO646-FR': - case 'FR': - case 'CSISO69FRENCH': - return 'NF_Z_62-010'; - - case 'ISO-10646-UTF-1': - case 'CSISO10646UTF1': - return 'ISO-10646-UTF-1'; - - case 'ISO_646.BASIC:1983': - case 'REF': - case 'CSISO646BASIC1983': - return 'ISO_646.basic:1983'; - - case 'INVARIANT': - case 'CSINVARIANT': - return 'INVARIANT'; - - case 'ISO_646.IRV:1983': - case 'ISO-IR-2': - case 'IRV': - case 'CSISO2INTLREFVERSION': - return 'ISO_646.irv:1983'; - - case 'NATS-SEFI': - case 'ISO-IR-8-1': - case 'CSNATSSEFI': - return 'NATS-SEFI'; - - case 'NATS-SEFI-ADD': - case 'ISO-IR-8-2': - case 'CSNATSSEFIADD': - return 'NATS-SEFI-ADD'; - - case 'NATS-DANO': - case 'ISO-IR-9-1': - case 'CSNATSDANO': - return 'NATS-DANO'; - - case 'NATS-DANO-ADD': - case 'ISO-IR-9-2': - case 'CSNATSDANOADD': - return 'NATS-DANO-ADD'; - - case 'SEN_850200_B': - case 'ISO-IR-10': - case 'FI': - case 'ISO646-FI': - case 'ISO646-SE': - case 'SE': - case 'CSISO10SWEDISH': - return 'SEN_850200_B'; - - case 'KS_C_5601-1987': - case 'ISO-IR-149': - case 'KS_C_5601-1989': - case 'KSC_5601': - case 'KOREAN': - case 'CSKSC56011987': - return 'KS_C_5601-1987'; - - case 'ISO-2022-KR': - case 'CSISO2022KR': - return 'ISO-2022-KR'; - - case 'EUC-KR': - case 'CSEUCKR': - return 'EUC-KR'; - - case 'ISO-2022-JP': - case 'CSISO2022JP': - return 'ISO-2022-JP'; - - case 'ISO-2022-JP-2': - case 'CSISO2022JP2': - return 'ISO-2022-JP-2'; - - case 'JIS_C6220-1969-JP': - case 'JIS_C6220-1969': - case 'ISO-IR-13': - case 'KATAKANA': - case 'X0201-7': - case 'CSISO13JISC6220JP': - return 'JIS_C6220-1969-jp'; - - case 'JIS_C6220-1969-RO': - case 'ISO-IR-14': - case 'JP': - case 'ISO646-JP': - case 'CSISO14JISC6220RO': - return 'JIS_C6220-1969-ro'; - - case 'PT': - case 'ISO-IR-16': - case 'ISO646-PT': - case 'CSISO16PORTUGUESE': - return 'PT'; - - case 'GREEK7-OLD': - case 'ISO-IR-18': - case 'CSISO18GREEK7OLD': - return 'greek7-old'; - - case 'LATIN-GREEK': - case 'ISO-IR-19': - case 'CSISO19LATINGREEK': - return 'latin-greek'; - - case 'NF_Z_62-010_(1973)': - case 'ISO-IR-25': - case 'ISO646-FR1': - case 'CSISO25FRENCH': - return 'NF_Z_62-010_(1973)'; - - case 'LATIN-GREEK-1': - case 'ISO-IR-27': - case 'CSISO27LATINGREEK1': - return 'Latin-greek-1'; - - case 'ISO_5427': - case 'ISO-IR-37': - case 'CSISO5427CYRILLIC': - return 'ISO_5427'; - - case 'JIS_C6226-1978': - case 'ISO-IR-42': - case 'CSISO42JISC62261978': - return 'JIS_C6226-1978'; - - case 'BS_VIEWDATA': - case 'ISO-IR-47': - case 'CSISO47BSVIEWDATA': - return 'BS_viewdata'; - - case 'INIS': - case 'ISO-IR-49': - case 'CSISO49INIS': - return 'INIS'; - - case 'INIS-8': - case 'ISO-IR-50': - case 'CSISO50INIS8': - return 'INIS-8'; - - case 'INIS-CYRILLIC': - case 'ISO-IR-51': - case 'CSISO51INISCYRILLIC': - return 'INIS-cyrillic'; - - case 'ISO_5427:1981': - case 'ISO-IR-54': - case 'ISO5427CYRILLIC1981': - return 'ISO_5427:1981'; - - case 'ISO_5428:1980': - case 'ISO-IR-55': - case 'CSISO5428GREEK': - return 'ISO_5428:1980'; - - case 'GB_1988-80': - case 'ISO-IR-57': - case 'CN': - case 'ISO646-CN': - case 'CSISO57GB1988': - return 'GB_1988-80'; - - case 'GB_2312-80': - case 'ISO-IR-58': - case 'CHINESE': - case 'CSISO58GB231280': - return 'GB_2312-80'; - - case 'NS_4551-2': - case 'ISO646-NO2': - case 'ISO-IR-61': - case 'NO2': - case 'CSISO61NORWEGIAN2': - return 'NS_4551-2'; - - case 'VIDEOTEX-SUPPL': - case 'ISO-IR-70': - case 'CSISO70VIDEOTEXSUPP1': - return 'videotex-suppl'; - - case 'PT2': - case 'ISO-IR-84': - case 'ISO646-PT2': - case 'CSISO84PORTUGUESE2': - return 'PT2'; - - case 'ES2': - case 'ISO-IR-85': - case 'ISO646-ES2': - case 'CSISO85SPANISH2': - return 'ES2'; - - case 'MSZ_7795.3': - case 'ISO-IR-86': - case 'ISO646-HU': - case 'HU': - case 'CSISO86HUNGARIAN': - return 'MSZ_7795.3'; - - case 'JIS_C6226-1983': - case 'ISO-IR-87': - case 'X0208': - case 'JIS_X0208-1983': - case 'CSISO87JISX0208': - return 'JIS_C6226-1983'; - - case 'GREEK7': - case 'ISO-IR-88': - case 'CSISO88GREEK7': - return 'greek7'; - - case 'ASMO_449': - case 'ISO_9036': - case 'ARABIC7': - case 'ISO-IR-89': - case 'CSISO89ASMO449': - return 'ASMO_449'; - - case 'ISO-IR-90': - case 'CSISO90': - return 'iso-ir-90'; - - case 'JIS_C6229-1984-A': - case 'ISO-IR-91': - case 'JP-OCR-A': - case 'CSISO91JISC62291984A': - return 'JIS_C6229-1984-a'; - - case 'JIS_C6229-1984-B': - case 'ISO-IR-92': - case 'ISO646-JP-OCR-B': - case 'JP-OCR-B': - case 'CSISO92JISC62991984B': - return 'JIS_C6229-1984-b'; - - case 'JIS_C6229-1984-B-ADD': - case 'ISO-IR-93': - case 'JP-OCR-B-ADD': - case 'CSISO93JIS62291984BADD': - return 'JIS_C6229-1984-b-add'; - - case 'JIS_C6229-1984-HAND': - case 'ISO-IR-94': - case 'JP-OCR-HAND': - case 'CSISO94JIS62291984HAND': - return 'JIS_C6229-1984-hand'; - - case 'JIS_C6229-1984-HAND-ADD': - case 'ISO-IR-95': - case 'JP-OCR-HAND-ADD': - case 'CSISO95JIS62291984HANDADD': - return 'JIS_C6229-1984-hand-add'; - - case 'JIS_C6229-1984-KANA': - case 'ISO-IR-96': - case 'CSISO96JISC62291984KANA': - return 'JIS_C6229-1984-kana'; - - case 'ISO_2033-1983': - case 'ISO-IR-98': - case 'E13B': - case 'CSISO2033': - return 'ISO_2033-1983'; - - case 'ANSI_X3.110-1983': - case 'ISO-IR-99': - case 'CSA_T500-1983': - case 'NAPLPS': - case 'CSISO99NAPLPS': - return 'ANSI_X3.110-1983'; - - case 'T.61-7BIT': - case 'ISO-IR-102': - case 'CSISO102T617BIT': - return 'T.61-7bit'; - - case 'T.61-8BIT': - case 'T.61': - case 'ISO-IR-103': - case 'CSISO103T618BIT': - return 'T.61-8bit'; - - case 'ECMA-CYRILLIC': - case 'ISO-IR-111': - case 'KOI8-E': - case 'CSISO111ECMACYRILLIC': - return 'ECMA-cyrillic'; - - case 'CSA_Z243.4-1985-1': - case 'ISO-IR-121': - case 'ISO646-CA': - case 'CSA7-1': - case 'CA': - case 'CSISO121CANADIAN1': - return 'CSA_Z243.4-1985-1'; - - case 'CSA_Z243.4-1985-2': - case 'ISO-IR-122': - case 'ISO646-CA2': - case 'CSA7-2': - case 'CSISO122CANADIAN2': - return 'CSA_Z243.4-1985-2'; - - case 'CSA_Z243.4-1985-GR': - case 'ISO-IR-123': - case 'CSISO123CSAZ24341985GR': - return 'CSA_Z243.4-1985-gr'; - - case 'ISO_8859-6-E': - case 'CSISO88596E': - case 'ISO-8859-6-E': - return 'ISO-8859-6-E'; - - case 'ISO_8859-6-I': - case 'CSISO88596I': - case 'ISO-8859-6-I': - return 'ISO-8859-6-I'; - - case 'T.101-G2': - case 'ISO-IR-128': - case 'CSISO128T101G2': - return 'T.101-G2'; - - case 'ISO_8859-8-E': - case 'CSISO88598E': - case 'ISO-8859-8-E': - return 'ISO-8859-8-E'; - - case 'ISO_8859-8-I': - case 'CSISO88598I': - case 'ISO-8859-8-I': - return 'ISO-8859-8-I'; - - case 'CSN_369103': - case 'ISO-IR-139': - case 'CSISO139CSN369103': - return 'CSN_369103'; - - case 'JUS_I.B1.002': - case 'ISO-IR-141': - case 'ISO646-YU': - case 'JS': - case 'YU': - case 'CSISO141JUSIB1002': - return 'JUS_I.B1.002'; - - case 'IEC_P27-1': - case 'ISO-IR-143': - case 'CSISO143IECP271': - return 'IEC_P27-1'; - - case 'JUS_I.B1.003-SERB': - case 'ISO-IR-146': - case 'SERBIAN': - case 'CSISO146SERBIAN': - return 'JUS_I.B1.003-serb'; - - case 'JUS_I.B1.003-MAC': - case 'MACEDONIAN': - case 'ISO-IR-147': - case 'CSISO147MACEDONIAN': - return 'JUS_I.B1.003-mac'; - - case 'GREEK-CCITT': - case 'ISO-IR-150': - case 'CSISO150': - case 'CSISO150GREEKCCITT': - return 'greek-ccitt'; - - case 'NC_NC00-10:81': - case 'CUBA': - case 'ISO-IR-151': - case 'ISO646-CU': - case 'CSISO151CUBA': - return 'NC_NC00-10:81'; - - case 'ISO_6937-2-25': - case 'ISO-IR-152': - case 'CSISO6937ADD': - return 'ISO_6937-2-25'; - - case 'GOST_19768-74': - case 'ST_SEV_358-88': - case 'ISO-IR-153': - case 'CSISO153GOST1976874': - return 'GOST_19768-74'; - - case 'ISO_8859-SUPP': - case 'ISO-IR-154': - case 'LATIN1-2-5': - case 'CSISO8859SUPP': - return 'ISO_8859-supp'; - - case 'ISO_10367-BOX': - case 'ISO-IR-155': - case 'CSISO10367BOX': - return 'ISO_10367-box'; - - case 'LATIN-LAP': - case 'LAP': - case 'ISO-IR-158': - case 'CSISO158LAP': - return 'latin-lap'; - - case 'JIS_X0212-1990': - case 'X0212': - case 'ISO-IR-159': - case 'CSISO159JISX02121990': - return 'JIS_X0212-1990'; - - case 'DS_2089': - case 'DS2089': - case 'ISO646-DK': - case 'DK': - case 'CSISO646DANISH': - return 'DS_2089'; - - case 'US-DK': - case 'CSUSDK': - return 'us-dk'; - - case 'DK-US': - case 'CSDKUS': - return 'dk-us'; - - case 'KSC5636': - case 'ISO646-KR': - case 'CSKSC5636': - return 'KSC5636'; - - case 'UNICODE-1-1-UTF-7': - case 'CSUNICODE11UTF7': - return 'UNICODE-1-1-UTF-7'; - - case 'ISO-2022-CN': - return 'ISO-2022-CN'; - - case 'ISO-2022-CN-EXT': - return 'ISO-2022-CN-EXT'; - - case 'UTF-8': - return 'UTF-8'; - - case 'ISO-8859-13': - return 'ISO-8859-13'; - - case 'ISO-8859-14': - case 'ISO-IR-199': - case 'ISO_8859-14:1998': - case 'ISO_8859-14': - case 'LATIN8': - case 'ISO-CELTIC': - case 'L8': - return 'ISO-8859-14'; - - case 'ISO-8859-15': - case 'ISO_8859-15': - case 'LATIN-9': - return 'ISO-8859-15'; - - case 'ISO-8859-16': - case 'ISO-IR-226': - case 'ISO_8859-16:2001': - case 'ISO_8859-16': - case 'LATIN10': - case 'L10': - return 'ISO-8859-16'; - - case 'GBK': - case 'CP936': - case 'MS936': - case 'WINDOWS-936': - return 'GBK'; - - case 'GB18030': - return 'GB18030'; - - case 'OSD_EBCDIC_DF04_15': - return 'OSD_EBCDIC_DF04_15'; - - case 'OSD_EBCDIC_DF03_IRV': - return 'OSD_EBCDIC_DF03_IRV'; - - case 'OSD_EBCDIC_DF04_1': - return 'OSD_EBCDIC_DF04_1'; - - case 'ISO-11548-1': - case 'ISO_11548-1': - case 'ISO_TR_11548-1': - case 'CSISO115481': - return 'ISO-11548-1'; - - case 'KZ-1048': - case 'STRK1048-2002': - case 'RK1048': - case 'CSKZ1048': - return 'KZ-1048'; - - case 'ISO-10646-UCS-2': - case 'CSUNICODE': - return 'ISO-10646-UCS-2'; - - case 'ISO-10646-UCS-4': - case 'CSUCS4': - return 'ISO-10646-UCS-4'; - - case 'ISO-10646-UCS-BASIC': - case 'CSUNICODEASCII': - return 'ISO-10646-UCS-Basic'; - - case 'ISO-10646-UNICODE-LATIN1': - case 'CSUNICODELATIN1': - case 'ISO-10646': - return 'ISO-10646-Unicode-Latin1'; - - case 'ISO-10646-J-1': - return 'ISO-10646-J-1'; - - case 'ISO-UNICODE-IBM-1261': - case 'CSUNICODEIBM1261': - return 'ISO-Unicode-IBM-1261'; - - case 'ISO-UNICODE-IBM-1268': - case 'CSUNICODEIBM1268': - return 'ISO-Unicode-IBM-1268'; - - case 'ISO-UNICODE-IBM-1276': - case 'CSUNICODEIBM1276': - return 'ISO-Unicode-IBM-1276'; - - case 'ISO-UNICODE-IBM-1264': - case 'CSUNICODEIBM1264': - return 'ISO-Unicode-IBM-1264'; - - case 'ISO-UNICODE-IBM-1265': - case 'CSUNICODEIBM1265': - return 'ISO-Unicode-IBM-1265'; - - case 'UNICODE-1-1': - case 'CSUNICODE11': - return 'UNICODE-1-1'; - - case 'SCSU': - return 'SCSU'; - - case 'UTF-7': - return 'UTF-7'; - - case 'UTF-16BE': - return 'UTF-16BE'; - - case 'UTF-16LE': - return 'UTF-16LE'; - - case 'UTF-16': - return 'UTF-16'; - - case 'CESU-8': - case 'CSCESU-8': - return 'CESU-8'; - - case 'UTF-32': - return 'UTF-32'; - - case 'UTF-32BE': - return 'UTF-32BE'; - - case 'UTF-32LE': - return 'UTF-32LE'; - - case 'BOCU-1': - case 'CSBOCU-1': - return 'BOCU-1'; - - case 'ISO-8859-1-WINDOWS-3.0-LATIN-1': - case 'CSWINDOWS30LATIN1': - return 'ISO-8859-1-Windows-3.0-Latin-1'; - - case 'ISO-8859-1-WINDOWS-3.1-LATIN-1': - case 'CSWINDOWS31LATIN1': - return 'ISO-8859-1-Windows-3.1-Latin-1'; - - case 'ISO-8859-2-WINDOWS-LATIN-2': - case 'CSWINDOWS31LATIN2': - return 'ISO-8859-2-Windows-Latin-2'; - - case 'ISO-8859-9-WINDOWS-LATIN-5': - case 'CSWINDOWS31LATIN5': - return 'ISO-8859-9-Windows-Latin-5'; - - case 'HP-ROMAN8': - case 'ROMAN8': - case 'R8': - case 'CSHPROMAN8': - return 'hp-roman8'; - - case 'ADOBE-STANDARD-ENCODING': - case 'CSADOBESTANDARDENCODING': + case 'adobestandardencoding': + case 'csadobestandardencoding': return 'Adobe-Standard-Encoding'; - case 'VENTURA-US': - case 'CSVENTURAUS': - return 'Ventura-US'; - - case 'VENTURA-INTERNATIONAL': - case 'CSVENTURAINTERNATIONAL': - return 'Ventura-International'; - - case 'DEC-MCS': - case 'DEC': - case 'CSDECMCS': - return 'DEC-MCS'; - - case 'IBM850': - case 'CP850': - case '850': - case 'CSPC850MULTILINGUAL': - return 'IBM850'; - - case 'PC8-DANISH-NORWEGIAN': - case 'CSPC8DANISHNORWEGIAN': - return 'PC8-Danish-Norwegian'; - - case 'IBM862': - case 'CP862': - case '862': - case 'CSPC862LATINHEBREW': - return 'IBM862'; - - case 'PC8-TURKISH': - case 'CSPC8TURKISH': - return 'PC8-Turkish'; - - case 'IBM-SYMBOLS': - case 'CSIBMSYMBOLS': - return 'IBM-Symbols'; - - case 'IBM-THAI': - case 'CSIBMTHAI': - return 'IBM-Thai'; - - case 'HP-LEGAL': - case 'CSHPLEGAL': - return 'HP-Legal'; - - case 'HP-PI-FONT': - case 'CSHPPIFONT': - return 'HP-Pi-font'; - - case 'HP-MATH8': - case 'CSHPMATH8': - return 'HP-Math8'; - - case 'ADOBE-SYMBOL-ENCODING': - case 'CSHPPSMATH': + case 'adobesymbolencoding': + case 'cshppsmath': return 'Adobe-Symbol-Encoding'; - case 'HP-DESKTOP': - case 'CSHPDESKTOP': - return 'HP-DeskTop'; - - case 'VENTURA-MATH': - case 'CSVENTURAMATH': - return 'Ventura-Math'; - - case 'MICROSOFT-PUBLISHING': - case 'CSMICROSOFTPUBLISHING': - return 'Microsoft-Publishing'; - - case 'WINDOWS-31J': - case 'CSWINDOWS31J': - return 'Windows-31J'; - - case 'GB2312': - case 'CSGB2312': - return 'GB2312'; - - case 'BIG5': - case 'CSBIG5': - return 'Big5'; - - case 'MACINTOSH': - case 'MAC': - case 'CSMACINTOSH': - return 'macintosh'; - - case 'IBM037': - case 'CP037': - case 'EBCDIC-CP-US': - case 'EBCDIC-CP-CA': - case 'EBCDIC-CP-WT': - case 'EBCDIC-CP-NL': - case 'CSIBM037': - return 'IBM037'; - - case 'IBM038': - case 'EBCDIC-INT': - case 'CP038': - case 'CSIBM038': - return 'IBM038'; - - case 'IBM273': - case 'CP273': - case 'CSIBM273': - return 'IBM273'; - - case 'IBM274': - case 'EBCDIC-BE': - case 'CP274': - case 'CSIBM274': - return 'IBM274'; - - case 'IBM275': - case 'EBCDIC-BR': - case 'CP275': - case 'CSIBM275': - return 'IBM275'; - - case 'IBM277': - case 'EBCDIC-CP-DK': - case 'EBCDIC-CP-NO': - case 'CSIBM277': - return 'IBM277'; - - case 'IBM278': - case 'CP278': - case 'EBCDIC-CP-FI': - case 'EBCDIC-CP-SE': - case 'CSIBM278': - return 'IBM278'; - - case 'IBM280': - case 'CP280': - case 'EBCDIC-CP-IT': - case 'CSIBM280': - return 'IBM280'; - - case 'IBM281': - case 'EBCDIC-JP-E': - case 'CP281': - case 'CSIBM281': - return 'IBM281'; - - case 'IBM284': - case 'CP284': - case 'EBCDIC-CP-ES': - case 'CSIBM284': - return 'IBM284'; - - case 'IBM285': - case 'CP285': - case 'EBCDIC-CP-GB': - case 'CSIBM285': - return 'IBM285'; - - case 'IBM290': - case 'CP290': - case 'EBCDIC-JP-KANA': - case 'CSIBM290': - return 'IBM290'; - - case 'IBM297': - case 'CP297': - case 'EBCDIC-CP-FR': - case 'CSIBM297': - return 'IBM297'; - - case 'IBM420': - case 'CP420': - case 'EBCDIC-CP-AR1': - case 'CSIBM420': - return 'IBM420'; - - case 'IBM423': - case 'CP423': - case 'EBCDIC-CP-GR': - case 'CSIBM423': - return 'IBM423'; - - case 'IBM424': - case 'CP424': - case 'EBCDIC-CP-HE': - case 'CSIBM424': - return 'IBM424'; - - case 'IBM437': - case 'CP437': - case '437': - case 'CSPC8CODEPAGE437': - return 'IBM437'; - - case 'IBM500': - case 'CP500': - case 'EBCDIC-CP-BE': - case 'EBCDIC-CP-CH': - case 'CSIBM500': - return 'IBM500'; - - case 'IBM851': - case 'CP851': - case '851': - case 'CSIBM851': - return 'IBM851'; - - case 'IBM852': - case 'CP852': - case '852': - case 'CSPCP852': - return 'IBM852'; - - case 'IBM855': - case 'CP855': - case '855': - case 'CSIBM855': - return 'IBM855'; - - case 'IBM857': - case 'CP857': - case '857': - case 'CSIBM857': - return 'IBM857'; - - case 'IBM860': - case 'CP860': - case '860': - case 'CSIBM860': - return 'IBM860'; - - case 'IBM861': - case 'CP861': - case '861': - case 'CP-IS': - case 'CSIBM861': - return 'IBM861'; - - case 'IBM863': - case 'CP863': - case '863': - case 'CSIBM863': - return 'IBM863'; - - case 'IBM864': - case 'CP864': - case 'CSIBM864': - return 'IBM864'; - - case 'IBM865': - case 'CP865': - case '865': - case 'CSIBM865': - return 'IBM865'; - - case 'IBM868': - case 'CP868': - case 'CP-AR': - case 'CSIBM868': - return 'IBM868'; - - case 'IBM869': - case 'CP869': - case '869': - case 'CP-GR': - case 'CSIBM869': - return 'IBM869'; - - case 'IBM870': - case 'CP870': - case 'EBCDIC-CP-ROECE': - case 'EBCDIC-CP-YU': - case 'CSIBM870': - return 'IBM870'; - - case 'IBM871': - case 'CP871': - case 'EBCDIC-CP-IS': - case 'CSIBM871': - return 'IBM871'; - - case 'IBM880': - case 'CP880': - case 'EBCDIC-CYRILLIC': - case 'CSIBM880': - return 'IBM880'; - - case 'IBM891': - case 'CP891': - case 'CSIBM891': - return 'IBM891'; - - case 'IBM903': - case 'CP903': - case 'CSIBM903': - return 'IBM903'; - - case 'IBM904': - case 'CP904': - case '904': - case 'CSIBBM904': - return 'IBM904'; - - case 'IBM905': - case 'CP905': - case 'EBCDIC-CP-TR': - case 'CSIBM905': - return 'IBM905'; - - case 'IBM918': - case 'CP918': - case 'EBCDIC-CP-AR2': - case 'CSIBM918': - return 'IBM918'; - - case 'IBM1026': - case 'CP1026': - case 'CSIBM1026': - return 'IBM1026'; - - case 'EBCDIC-AT-DE': - case 'CSIBMEBCDICATDE': - return 'EBCDIC-AT-DE'; - - case 'EBCDIC-AT-DE-A': - case 'CSEBCDICATDEA': - return 'EBCDIC-AT-DE-A'; - - case 'EBCDIC-CA-FR': - case 'CSEBCDICCAFR': - return 'EBCDIC-CA-FR'; - - case 'EBCDIC-DK-NO': - case 'CSEBCDICDKNO': - return 'EBCDIC-DK-NO'; - - case 'EBCDIC-DK-NO-A': - case 'CSEBCDICDKNOA': - return 'EBCDIC-DK-NO-A'; - - case 'EBCDIC-FI-SE': - case 'CSEBCDICFISE': - return 'EBCDIC-FI-SE'; - - case 'EBCDIC-FI-SE-A': - case 'CSEBCDICFISEA': - return 'EBCDIC-FI-SE-A'; - - case 'EBCDIC-FR': - case 'CSEBCDICFR': - return 'EBCDIC-FR'; - - case 'EBCDIC-IT': - case 'CSEBCDICIT': - return 'EBCDIC-IT'; - - case 'EBCDIC-PT': - case 'CSEBCDICPT': - return 'EBCDIC-PT'; - - case 'EBCDIC-ES': - case 'CSEBCDICES': - return 'EBCDIC-ES'; - - case 'EBCDIC-ES-A': - case 'CSEBCDICESA': - return 'EBCDIC-ES-A'; - - case 'EBCDIC-ES-S': - case 'CSEBCDICESS': - return 'EBCDIC-ES-S'; - - case 'EBCDIC-UK': - case 'CSEBCDICUK': - return 'EBCDIC-UK'; - - case 'EBCDIC-US': - case 'CSEBCDICUS': - return 'EBCDIC-US'; - - case 'UNKNOWN-8BIT': - case 'CSUNKNOWN8BIT': - return 'UNKNOWN-8BIT'; - - case 'MNEMONIC': - case 'CSMNEMONIC': - return 'MNEMONIC'; - - case 'MNEM': - case 'CSMNEM': - return 'MNEM'; - - case 'VISCII': - case 'CSVISCII': - return 'VISCII'; - - case 'VIQR': - case 'CSVIQR': - return 'VIQR'; - - case 'KOI8-R': - case 'CSKOI8R': - return 'KOI8-R'; - - case 'HZ-GB-2312': - return 'HZ-GB-2312'; - - case 'IBM866': - case 'CP866': - case '866': - case 'CSIBM866': - return 'IBM866'; - - case 'IBM775': - case 'CP775': - case 'CSPC775BALTIC': - return 'IBM775'; - - case 'KOI8-U': - return 'KOI8-U'; - - case 'IBM00858': - case 'CCSID00858': - case 'CP00858': - case 'PC-MULTILINGUAL-850+EURO': - return 'IBM00858'; - - case 'IBM00924': - case 'CCSID00924': - case 'CP00924': - case 'EBCDIC-LATIN9--EURO': - return 'IBM00924'; - - case 'IBM01140': - case 'CCSID01140': - case 'CP01140': - case 'EBCDIC-US-37+EURO': - return 'IBM01140'; - - case 'IBM01141': - case 'CCSID01141': - case 'CP01141': - case 'EBCDIC-DE-273+EURO': - return 'IBM01141'; - - case 'IBM01142': - case 'CCSID01142': - case 'CP01142': - case 'EBCDIC-DK-277+EURO': - case 'EBCDIC-NO-277+EURO': - return 'IBM01142'; - - case 'IBM01143': - case 'CCSID01143': - case 'CP01143': - case 'EBCDIC-FI-278+EURO': - case 'EBCDIC-SE-278+EURO': - return 'IBM01143'; - - case 'IBM01144': - case 'CCSID01144': - case 'CP01144': - case 'EBCDIC-IT-280+EURO': - return 'IBM01144'; - - case 'IBM01145': - case 'CCSID01145': - case 'CP01145': - case 'EBCDIC-ES-284+EURO': - return 'IBM01145'; - - case 'IBM01146': - case 'CCSID01146': - case 'CP01146': - case 'EBCDIC-GB-285+EURO': - return 'IBM01146'; - - case 'IBM01147': - case 'CCSID01147': - case 'CP01147': - case 'EBCDIC-FR-297+EURO': - return 'IBM01147'; - - case 'IBM01148': - case 'CCSID01148': - case 'CP01148': - case 'EBCDIC-INTERNATIONAL-500+EURO': - return 'IBM01148'; - - case 'IBM01149': - case 'CCSID01149': - case 'CP01149': - case 'EBCDIC-IS-871+EURO': - return 'IBM01149'; - - case 'BIG5-HKSCS': - return 'Big5-HKSCS'; - - case 'IBM1047': - case 'IBM-1047': - return 'IBM1047'; - - case 'PTCP154': - case 'CSPTCP154': - case 'PT154': - case 'CP154': - case 'CYRILLIC-ASIAN': - return 'PTCP154'; - - case 'AMIGA-1251': - case 'AMI1251': - case 'AMIGA1251': - case 'AMI-1251': + case 'ami1251': + case 'amiga1251': return 'Amiga-1251'; - case 'KOI7-SWITCHED': - return 'KOI7-switched'; + case 'ansix31101983': + case 'csat5001983': + case 'csiso99naplps': + case 'isoir99': + case 'naplps': + return 'ANSI_X3.110-1983'; - case 'BRF': - case 'CSBRF': + case 'arabic7': + case 'asmo449': + case 'csiso89asmo449': + case 'iso9036': + case 'isoir89': + return 'ASMO_449'; + + case 'big5': + case 'csbig5': + case 'xxbig5': + return 'Big5'; + + case 'big5hkscs': + return 'Big5-HKSCS'; + + case 'bocu1': + case 'csbocu1': + return 'BOCU-1'; + + case 'brf': + case 'csbrf': return 'BRF'; - case 'TSCII': - case 'CSTSCII': + case 'bs4730': + case 'csiso4unitedkingdom': + case 'gb': + case 'iso646gb': + case 'isoir4': + case 'uk': + return 'BS_4730'; + + case 'bsviewdata': + case 'csiso47bsviewdata': + case 'isoir47': + return 'BS_viewdata'; + + case 'cesu8': + case 'cscesu8': + return 'CESU-8'; + + case 'ca': + case 'csa71': + case 'csaz243419851': + case 'csiso121canadian1': + case 'iso646ca': + case 'isoir121': + return 'CSA_Z243.4-1985-1'; + + case 'csa72': + case 'csaz243419852': + case 'csiso122canadian2': + case 'iso646ca2': + case 'isoir122': + return 'CSA_Z243.4-1985-2'; + + case 'csaz24341985gr': + case 'csiso123csaz24341985gr': + case 'isoir123': + return 'CSA_Z243.4-1985-gr'; + + case 'csiso139csn369103': + case 'csn369103': + case 'isoir139': + return 'CSN_369103'; + + case 'csdecmcs': + case 'dec': + case 'decmcs': + return 'DEC-MCS'; + + case 'csiso21german': + case 'de': + case 'din66003': + case 'iso646de': + case 'isoir21': + return 'DIN_66003'; + + case 'csdkus': + case 'dkus': + return 'dk-us'; + + case 'csiso646danish': + case 'dk': + case 'ds2089': + case 'iso646dk': + return 'DS_2089'; + + case 'csibmebcdicatde': + case 'ebcdicatde': + return 'EBCDIC-AT-DE'; + + case 'csebcdicatdea': + case 'ebcdicatdea': + return 'EBCDIC-AT-DE-A'; + + case 'csebcdiccafr': + case 'ebcdiccafr': + return 'EBCDIC-CA-FR'; + + case 'csebcdicdkno': + case 'ebcdicdkno': + return 'EBCDIC-DK-NO'; + + case 'csebcdicdknoa': + case 'ebcdicdknoa': + return 'EBCDIC-DK-NO-A'; + + case 'csebcdices': + case 'ebcdices': + return 'EBCDIC-ES'; + + case 'csebcdicesa': + case 'ebcdicesa': + return 'EBCDIC-ES-A'; + + case 'csebcdicess': + case 'ebcdicess': + return 'EBCDIC-ES-S'; + + case 'csebcdicfise': + case 'ebcdicfise': + return 'EBCDIC-FI-SE'; + + case 'csebcdicfisea': + case 'ebcdicfisea': + return 'EBCDIC-FI-SE-A'; + + case 'csebcdicfr': + case 'ebcdicfr': + return 'EBCDIC-FR'; + + case 'csebcdicit': + case 'ebcdicit': + return 'EBCDIC-IT'; + + case 'csebcdicpt': + case 'ebcdicpt': + return 'EBCDIC-PT'; + + case 'csebcdicuk': + case 'ebcdicuk': + return 'EBCDIC-UK'; + + case 'csebcdicus': + case 'ebcdicus': + return 'EBCDIC-US'; + + case 'csiso111ecmacyrillic': + case 'ecmacyrillic': + case 'isoir111': + case 'koi8e': + return 'ECMA-cyrillic'; + + case 'csiso17spanish': + case 'es': + case 'iso646es': + case 'isoir17': + return 'ES'; + + case 'csiso85spanish2': + case 'es2': + case 'iso646es2': + case 'isoir85': + return 'ES2'; + + case 'cseucfixwidjapanese': + case 'extendedunixcodefixedwidthforjapanese': + return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; + + case 'cseucpkdfmtjapanese': + case 'eucjp': + case 'extendedunixcodepackedformatforjapanese': + return 'Extended_UNIX_Code_Packed_Format_for_Japanese'; + + case 'gb18030': + return 'GB18030'; + + case 'chinese': + case 'cp936': + case 'csgb2312': + case 'csiso58gb231280': + case 'gb2312': + case 'gb231280': + case 'gbk': + case 'isoir58': + case 'ms936': + case 'windows936': + return 'GBK'; + + case 'cn': + case 'csiso57gb1988': + case 'gb198880': + case 'iso646cn': + case 'isoir57': + return 'GB_1988-80'; + + case 'csiso153gost1976874': + case 'gost1976874': + case 'isoir153': + case 'stsev35888': + return 'GOST_19768-74'; + + case 'csiso150': + case 'csiso150greekccitt': + case 'greekccitt': + case 'isoir150': + return 'greek-ccitt'; + + case 'csiso88greek7': + case 'greek7': + case 'isoir88': + return 'greek7'; + + case 'csiso18greek7old': + case 'greek7old': + case 'isoir18': + return 'greek7-old'; + + case 'cshpdesktop': + case 'hpdesktop': + return 'HP-DeskTop'; + + case 'cshplegal': + case 'hplegal': + return 'HP-Legal'; + + case 'cshpmath8': + case 'hpmath8': + return 'HP-Math8'; + + case 'cshppifont': + case 'hppifont': + return 'HP-Pi-font'; + + case 'cshproman8': + case 'hproman8': + case 'r8': + case 'roman8': + return 'hp-roman8'; + + case 'hzgb2312': + return 'HZ-GB-2312'; + + case 'csibmsymbols': + case 'ibmsymbols': + return 'IBM-Symbols'; + + case 'csibmthai': + case 'ibmthai': + return 'IBM-Thai'; + + case 'ccsid858': + case 'cp858': + case 'ibm858': + case 'pcmultilingual850euro': + return 'IBM00858'; + + case 'ccsid924': + case 'cp924': + case 'ebcdiclatin9euro': + case 'ibm924': + return 'IBM00924'; + + case 'ccsid1140': + case 'cp1140': + case 'ebcdicus37euro': + case 'ibm1140': + return 'IBM01140'; + + case 'ccsid1141': + case 'cp1141': + case 'ebcdicde273euro': + case 'ibm1141': + return 'IBM01141'; + + case 'ccsid1142': + case 'cp1142': + case 'ebcdicdk277euro': + case 'ebcdicno277euro': + case 'ibm1142': + return 'IBM01142'; + + case 'ccsid1143': + case 'cp1143': + case 'ebcdicfi278euro': + case 'ebcdicse278euro': + case 'ibm1143': + return 'IBM01143'; + + case 'ccsid1144': + case 'cp1144': + case 'ebcdicit280euro': + case 'ibm1144': + return 'IBM01144'; + + case 'ccsid1145': + case 'cp1145': + case 'ebcdices284euro': + case 'ibm1145': + return 'IBM01145'; + + case 'ccsid1146': + case 'cp1146': + case 'ebcdicgb285euro': + case 'ibm1146': + return 'IBM01146'; + + case 'ccsid1147': + case 'cp1147': + case 'ebcdicfr297euro': + case 'ibm1147': + return 'IBM01147'; + + case 'ccsid1148': + case 'cp1148': + case 'ebcdicinternational500euro': + case 'ibm1148': + return 'IBM01148'; + + case 'ccsid1149': + case 'cp1149': + case 'ebcdicis871euro': + case 'ibm1149': + return 'IBM01149'; + + case 'cp37': + case 'csibm37': + case 'ebcdiccpca': + case 'ebcdiccpnl': + case 'ebcdiccpus': + case 'ebcdiccpwt': + case 'ibm37': + return 'IBM037'; + + case 'cp38': + case 'csibm38': + case 'ebcdicint': + case 'ibm38': + return 'IBM038'; + + case 'cp273': + case 'csibm273': + case 'ibm273': + return 'IBM273'; + + case 'cp274': + case 'csibm274': + case 'ebcdicbe': + case 'ibm274': + return 'IBM274'; + + case 'cp275': + case 'csibm275': + case 'ebcdicbr': + case 'ibm275': + return 'IBM275'; + + case 'csibm277': + case 'ebcdiccpdk': + case 'ebcdiccpno': + case 'ibm277': + return 'IBM277'; + + case 'cp278': + case 'csibm278': + case 'ebcdiccpfi': + case 'ebcdiccpse': + case 'ibm278': + return 'IBM278'; + + case 'cp280': + case 'csibm280': + case 'ebcdiccpit': + case 'ibm280': + return 'IBM280'; + + case 'cp281': + case 'csibm281': + case 'ebcdicjpe': + case 'ibm281': + return 'IBM281'; + + case 'cp284': + case 'csibm284': + case 'ebcdiccpes': + case 'ibm284': + return 'IBM284'; + + case 'cp285': + case 'csibm285': + case 'ebcdiccpgb': + case 'ibm285': + return 'IBM285'; + + case 'cp290': + case 'csibm290': + case 'ebcdicjpkana': + case 'ibm290': + return 'IBM290'; + + case 'cp297': + case 'csibm297': + case 'ebcdiccpfr': + case 'ibm297': + return 'IBM297'; + + case 'cp420': + case 'csibm420': + case 'ebcdiccpar1': + case 'ibm420': + return 'IBM420'; + + case 'cp423': + case 'csibm423': + case 'ebcdiccpgr': + case 'ibm423': + return 'IBM423'; + + case 'cp424': + case 'csibm424': + case 'ebcdiccphe': + case 'ibm424': + return 'IBM424'; + + case '437': + case 'cp437': + case 'cspc8codepage437': + case 'ibm437': + return 'IBM437'; + + case 'cp500': + case 'csibm500': + case 'ebcdiccpbe': + case 'ebcdiccpch': + case 'ibm500': + return 'IBM500'; + + case 'cp775': + case 'cspc775baltic': + case 'ibm775': + return 'IBM775'; + + case '850': + case 'cp850': + case 'cspc850multilingual': + case 'ibm850': + return 'IBM850'; + + case '851': + case 'cp851': + case 'csibm851': + case 'ibm851': + return 'IBM851'; + + case '852': + case 'cp852': + case 'cspcp852': + case 'ibm852': + return 'IBM852'; + + case '855': + case 'cp855': + case 'csibm855': + case 'ibm855': + return 'IBM855'; + + case '857': + case 'cp857': + case 'csibm857': + case 'ibm857': + return 'IBM857'; + + case '860': + case 'cp860': + case 'csibm860': + case 'ibm860': + return 'IBM860'; + + case '861': + case 'cp861': + case 'cpis': + case 'csibm861': + case 'ibm861': + return 'IBM861'; + + case '862': + case 'cp862': + case 'cspc862latinhebrew': + case 'ibm862': + return 'IBM862'; + + case '863': + case 'cp863': + case 'csibm863': + case 'ibm863': + return 'IBM863'; + + case 'cp864': + case 'csibm864': + case 'ibm864': + return 'IBM864'; + + case '865': + case 'cp865': + case 'csibm865': + case 'ibm865': + return 'IBM865'; + + case '866': + case 'cp866': + case 'csibm866': + case 'ibm866': + return 'IBM866'; + + case 'cp868': + case 'cpar': + case 'csibm868': + case 'ibm868': + return 'IBM868'; + + case '869': + case 'cp869': + case 'cpgr': + case 'csibm869': + case 'ibm869': + return 'IBM869'; + + case 'cp870': + case 'csibm870': + case 'ebcdiccproece': + case 'ebcdiccpyu': + case 'ibm870': + return 'IBM870'; + + case 'cp871': + case 'csibm871': + case 'ebcdiccpis': + case 'ibm871': + return 'IBM871'; + + case 'cp880': + case 'csibm880': + case 'ebcdiccyrillic': + case 'ibm880': + return 'IBM880'; + + case 'cp891': + case 'csibm891': + case 'ibm891': + return 'IBM891'; + + case 'cp903': + case 'csibm903': + case 'ibm903': + return 'IBM903'; + + case '904': + case 'cp904': + case 'csibbm904': + case 'ibm904': + return 'IBM904'; + + case 'cp905': + case 'csibm905': + case 'ebcdiccptr': + case 'ibm905': + return 'IBM905'; + + case 'cp918': + case 'csibm918': + case 'ebcdiccpar2': + case 'ibm918': + return 'IBM918'; + + case 'cp1026': + case 'csibm1026': + case 'ibm1026': + return 'IBM1026'; + + case 'ibm1047': + return 'IBM1047'; + + case 'csiso143iecp271': + case 'iecp271': + case 'isoir143': + return 'IEC_P27-1'; + + case 'csiso49inis': + case 'inis': + case 'isoir49': + return 'INIS'; + + case 'csiso50inis8': + case 'inis8': + case 'isoir50': + return 'INIS-8'; + + case 'csiso51iniscyrillic': + case 'iniscyrillic': + case 'isoir51': + return 'INIS-cyrillic'; + + case 'csinvariant': + case 'invariant': + return 'INVARIANT'; + + case 'iso2022cn': + return 'ISO-2022-CN'; + + case 'iso2022cnext': + return 'ISO-2022-CN-EXT'; + + case 'csiso2022jp': + case 'iso2022jp': + return 'ISO-2022-JP'; + + case 'csiso2022jp2': + case 'iso2022jp2': + return 'ISO-2022-JP-2'; + + case 'csiso2022kr': + case 'iso2022kr': + return 'ISO-2022-KR'; + + case 'cswindows30latin1': + case 'iso88591windows30latin1': + return 'ISO-8859-1-Windows-3.0-Latin-1'; + + case 'cswindows31latin1': + case 'iso88591windows31latin1': + return 'ISO-8859-1-Windows-3.1-Latin-1'; + + case 'csisolatin2': + case 'iso88592': + case 'iso885921987': + case 'isoir101': + case 'l2': + case 'latin2': + return 'ISO-8859-2'; + + case 'cswindows31latin2': + case 'iso88592windowslatin2': + return 'ISO-8859-2-Windows-Latin-2'; + + case 'csisolatin3': + case 'iso88593': + case 'iso885931988': + case 'isoir109': + case 'l3': + case 'latin3': + return 'ISO-8859-3'; + + case 'csisolatin4': + case 'iso88594': + case 'iso885941988': + case 'isoir110': + case 'l4': + case 'latin4': + return 'ISO-8859-4'; + + case 'csisolatincyrillic': + case 'cyrillic': + case 'iso88595': + case 'iso885951988': + case 'isoir144': + return 'ISO-8859-5'; + + case 'arabic': + case 'asmo708': + case 'csisolatinarabic': + case 'ecma114': + case 'iso88596': + case 'iso885961987': + case 'isoir127': + return 'ISO-8859-6'; + + case 'csiso88596e': + case 'iso88596e': + return 'ISO-8859-6-E'; + + case 'csiso88596i': + case 'iso88596i': + return 'ISO-8859-6-I'; + + case 'csisolatingreek': + case 'ecma118': + case 'elot928': + case 'greek': + case 'greek8': + case 'iso88597': + case 'iso885971987': + case 'isoir126': + return 'ISO-8859-7'; + + case 'csisolatinhebrew': + case 'hebrew': + case 'iso88598': + case 'iso885981988': + case 'isoir138': + return 'ISO-8859-8'; + + case 'csiso88598e': + case 'iso88598e': + return 'ISO-8859-8-E'; + + case 'csiso88598i': + case 'iso88598i': + return 'ISO-8859-8-I'; + + case 'cswindows31latin5': + case 'iso88599windowslatin5': + return 'ISO-8859-9-Windows-Latin-5'; + + case 'csisolatin6': + case 'iso885910': + case 'iso8859101992': + case 'isoir157': + case 'l6': + case 'latin6': + return 'ISO-8859-10'; + + case 'iso885913': + return 'ISO-8859-13'; + + case 'iso885914': + case 'iso8859141998': + case 'isoceltic': + case 'isoir199': + case 'l8': + case 'latin8': + return 'ISO-8859-14'; + + case 'iso885915': + case 'latin9': + return 'ISO-8859-15'; + + case 'iso885916': + case 'iso8859162001': + case 'isoir226': + case 'l10': + case 'latin10': + return 'ISO-8859-16'; + + case 'iso10646j1': + return 'ISO-10646-J-1'; + + case 'csunicode': + case 'iso10646ucs2': + return 'ISO-10646-UCS-2'; + + case 'csucs4': + case 'iso10646ucs4': + return 'ISO-10646-UCS-4'; + + case 'csunicodeascii': + case 'iso10646ucsbasic': + return 'ISO-10646-UCS-Basic'; + + case 'csunicodelatin1': + case 'iso10646': + case 'iso10646unicodelatin1': + return 'ISO-10646-Unicode-Latin1'; + + case 'csiso10646utf1': + case 'iso10646utf1': + return 'ISO-10646-UTF-1'; + + case 'csiso115481': + case 'iso115481': + case 'isotr115481': + return 'ISO-11548-1'; + + case 'csiso90': + case 'isoir90': + return 'iso-ir-90'; + + case 'csunicodeibm1261': + case 'isounicodeibm1261': + return 'ISO-Unicode-IBM-1261'; + + case 'csunicodeibm1264': + case 'isounicodeibm1264': + return 'ISO-Unicode-IBM-1264'; + + case 'csunicodeibm1265': + case 'isounicodeibm1265': + return 'ISO-Unicode-IBM-1265'; + + case 'csunicodeibm1268': + case 'isounicodeibm1268': + return 'ISO-Unicode-IBM-1268'; + + case 'csunicodeibm1276': + case 'isounicodeibm1276': + return 'ISO-Unicode-IBM-1276'; + + case 'csiso646basic1983': + case 'iso646basic1983': + case 'ref': + return 'ISO_646.basic:1983'; + + case 'csiso2intlrefversion': + case 'irv': + case 'iso646irv1983': + case 'isoir2': + return 'ISO_646.irv:1983'; + + case 'csiso2033': + case 'e13b': + case 'iso20331983': + case 'isoir98': + return 'ISO_2033-1983'; + + case 'csiso5427cyrillic': + case 'iso5427': + case 'isoir37': + return 'ISO_5427'; + + case 'iso5427cyrillic1981': + case 'iso54271981': + case 'isoir54': + return 'ISO_5427:1981'; + + case 'csiso5428greek': + case 'iso54281980': + case 'isoir55': + return 'ISO_5428:1980'; + + case 'csiso6937add': + case 'iso6937225': + case 'isoir152': + return 'ISO_6937-2-25'; + + case 'csisotextcomm': + case 'iso69372add': + case 'isoir142': + return 'ISO_6937-2-add'; + + case 'csiso8859supp': + case 'iso8859supp': + case 'isoir154': + case 'latin125': + return 'ISO_8859-supp'; + + case 'csiso10367box': + case 'iso10367box': + case 'isoir155': + return 'ISO_10367-box'; + + case 'csiso15italian': + case 'iso646it': + case 'isoir15': + case 'it': + return 'IT'; + + case 'csiso13jisc6220jp': + case 'isoir13': + case 'jisc62201969': + case 'jisc62201969jp': + case 'katakana': + case 'x2017': + return 'JIS_C6220-1969-jp'; + + case 'csiso14jisc6220ro': + case 'iso646jp': + case 'isoir14': + case 'jisc62201969ro': + case 'jp': + return 'JIS_C6220-1969-ro'; + + case 'csiso42jisc62261978': + case 'isoir42': + case 'jisc62261978': + return 'JIS_C6226-1978'; + + case 'csiso87jisx208': + case 'isoir87': + case 'jisc62261983': + case 'jisx2081983': + case 'x208': + return 'JIS_C6226-1983'; + + case 'csiso91jisc62291984a': + case 'isoir91': + case 'jisc62291984a': + case 'jpocra': + return 'JIS_C6229-1984-a'; + + case 'csiso92jisc62991984b': + case 'iso646jpocrb': + case 'isoir92': + case 'jisc62291984b': + case 'jpocrb': + return 'JIS_C6229-1984-b'; + + case 'csiso93jis62291984badd': + case 'isoir93': + case 'jisc62291984badd': + case 'jpocrbadd': + return 'JIS_C6229-1984-b-add'; + + case 'csiso94jis62291984hand': + case 'isoir94': + case 'jisc62291984hand': + case 'jpocrhand': + return 'JIS_C6229-1984-hand'; + + case 'csiso95jis62291984handadd': + case 'isoir95': + case 'jisc62291984handadd': + case 'jpocrhandadd': + return 'JIS_C6229-1984-hand-add'; + + case 'csiso96jisc62291984kana': + case 'isoir96': + case 'jisc62291984kana': + return 'JIS_C6229-1984-kana'; + + case 'csjisencoding': + case 'jisencoding': + return 'JIS_Encoding'; + + case 'cshalfwidthkatakana': + case 'jisx201': + case 'x201': + return 'JIS_X0201'; + + case 'csiso159jisx2121990': + case 'isoir159': + case 'jisx2121990': + case 'x212': + return 'JIS_X0212-1990'; + + case 'csiso141jusib1002': + case 'iso646yu': + case 'isoir141': + case 'js': + case 'jusib1002': + case 'yu': + return 'JUS_I.B1.002'; + + case 'csiso147macedonian': + case 'isoir147': + case 'jusib1003mac': + case 'macedonian': + return 'JUS_I.B1.003-mac'; + + case 'csiso146serbian': + case 'isoir146': + case 'jusib1003serb': + case 'serbian': + return 'JUS_I.B1.003-serb'; + + case 'koi7switched': + return 'KOI7-switched'; + + case 'cskoi8r': + case 'koi8r': + return 'KOI8-R'; + + case 'koi8u': + return 'KOI8-U'; + + case 'csksc5636': + case 'iso646kr': + case 'ksc5636': + return 'KSC5636'; + + case 'cskz1048': + case 'kz1048': + case 'rk1048': + case 'strk10482002': + return 'KZ-1048'; + + case 'csiso19latingreek': + case 'isoir19': + case 'latingreek': + return 'latin-greek'; + + case 'csiso27latingreek1': + case 'isoir27': + case 'latingreek1': + return 'Latin-greek-1'; + + case 'csiso158lap': + case 'isoir158': + case 'lap': + case 'latinlap': + return 'latin-lap'; + + case 'csmacintosh': + case 'mac': + case 'macintosh': + return 'macintosh'; + + case 'csmicrosoftpublishing': + case 'microsoftpublishing': + return 'Microsoft-Publishing'; + + case 'csmnem': + case 'mnem': + return 'MNEM'; + + case 'csmnemonic': + case 'mnemonic': + return 'MNEMONIC'; + + case 'csiso86hungarian': + case 'hu': + case 'iso646hu': + case 'isoir86': + case 'msz77953': + return 'MSZ_7795.3'; + + case 'csnatsdano': + case 'isoir91': + case 'natsdano': + return 'NATS-DANO'; + + case 'csnatsdanoadd': + case 'isoir92': + case 'natsdanoadd': + return 'NATS-DANO-ADD'; + + case 'csnatssefi': + case 'isoir81': + case 'natssefi': + return 'NATS-SEFI'; + + case 'csnatssefiadd': + case 'isoir82': + case 'natssefiadd': + return 'NATS-SEFI-ADD'; + + case 'csiso151cuba': + case 'cuba': + case 'iso646cu': + case 'isoir151': + case 'ncnc1081': + return 'NC_NC00-10:81'; + + case 'csiso69french': + case 'fr': + case 'iso646fr': + case 'isoir69': + case 'nfz62010': + return 'NF_Z_62-010'; + + case 'csiso25french': + case 'iso646fr1': + case 'isoir25': + case 'nfz620101973': + return 'NF_Z_62-010_(1973)'; + + case 'csiso60danishnorwegian': + case 'csiso60norwegian1': + case 'iso646no': + case 'isoir60': + case 'no': + case 'ns45511': + return 'NS_4551-1'; + + case 'csiso61norwegian2': + case 'iso646no2': + case 'isoir61': + case 'no2': + case 'ns45512': + return 'NS_4551-2'; + + case 'osdebcdicdf3irv': + return 'OSD_EBCDIC_DF03_IRV'; + + case 'osdebcdicdf41': + return 'OSD_EBCDIC_DF04_1'; + + case 'osdebcdicdf415': + return 'OSD_EBCDIC_DF04_15'; + + case 'cspc8danishnorwegian': + case 'pc8danishnorwegian': + return 'PC8-Danish-Norwegian'; + + case 'cspc8turkish': + case 'pc8turkish': + return 'PC8-Turkish'; + + case 'csiso16portuguese': + case 'iso646pt': + case 'isoir16': + case 'pt': + return 'PT'; + + case 'csiso84portuguese2': + case 'iso646pt2': + case 'isoir84': + case 'pt2': + return 'PT2'; + + case 'cp154': + case 'csptcp154': + case 'cyrillicasian': + case 'pt154': + case 'ptcp154': + return 'PTCP154'; + + case 'scsu': + return 'SCSU'; + + case 'csiso10swedish': + case 'fi': + case 'iso646fi': + case 'iso646se': + case 'isoir10': + case 'se': + case 'sen850200b': + return 'SEN_850200_B'; + + case 'csiso11swedishfornames': + case 'iso646se2': + case 'isoir11': + case 'se2': + case 'sen850200c': + return 'SEN_850200_C'; + + case 'csshiftjis': + case 'mskanji': + case 'shiftjis': + return 'Shift_JIS'; + + case 'csiso102t617bit': + case 'isoir102': + case 't617bit': + return 'T.61-7bit'; + + case 'csiso103t618bit': + case 'isoir103': + case 't61': + case 't618bit': + return 'T.61-8bit'; + + case 'csiso128t101g2': + case 'isoir128': + case 't101g2': + return 'T.101-G2'; + + case 'cstscii': + case 'tscii': return 'TSCII'; - case 'WINDOWS-1250': + case 'csunicode11': + case 'unicode11': + return 'UNICODE-1-1'; + + case 'csunicode11utf7': + case 'unicode11utf7': + return 'UNICODE-1-1-UTF-7'; + + case 'csunknown8bit': + case 'unknown8bit': + return 'UNKNOWN-8BIT'; + + case 'ansix341968': + case 'ansix341986': + case 'ascii': + case 'cp367': + case 'csascii': + case 'ibm367': + case 'iso646irv1991': + case 'iso646us': + case 'isoir6': + case 'us': + case 'usascii': + return 'US-ASCII'; + + case 'csusdk': + case 'usdk': + return 'us-dk'; + + case 'utf7': + return 'UTF-7'; + + case 'utf8': + return 'UTF-8'; + + case 'utf16': + return 'UTF-16'; + + case 'utf16be': + return 'UTF-16BE'; + + case 'utf16le': + return 'UTF-16LE'; + + case 'utf32': + return 'UTF-32'; + + case 'utf32be': + return 'UTF-32BE'; + + case 'utf32le': + return 'UTF-32LE'; + + case 'csventurainternational': + case 'venturainternational': + return 'Ventura-International'; + + case 'csventuramath': + case 'venturamath': + return 'Ventura-Math'; + + case 'csventuraus': + case 'venturaus': + return 'Ventura-US'; + + case 'csiso70videotexsupp1': + case 'isoir70': + case 'videotexsuppl': + return 'videotex-suppl'; + + case 'csviqr': + case 'viqr': + return 'VIQR'; + + case 'csviscii': + case 'viscii': + return 'VISCII'; + + case 'cswindows31j': + case 'windows31j': + return 'Windows-31J'; + + case 'iso885911': + case 'tis620': + return 'windows-874'; + + case 'cseuckr': + case 'csksc56011987': + case 'euckr': + case 'isoir149': + case 'korean': + case 'ksc5601': + case 'ksc56011987': + case 'ksc56011989': + case 'windows949': + return 'windows-949'; + + case 'windows1250': return 'windows-1250'; - case 'WINDOWS-1251': + case 'windows1251': return 'windows-1251'; - case 'WINDOWS-1252': + case 'cp819': + case 'csisolatin1': + case 'ibm819': + case 'iso88591': + case 'iso885911987': + case 'isoir100': + case 'l1': + case 'latin1': + case 'windows1252': return 'windows-1252'; - case 'WINDOWS-1253': + case 'windows1253': return 'windows-1253'; - case 'WINDOWS-1254': + case 'csisolatin5': + case 'iso88599': + case 'iso885991989': + case 'isoir148': + case 'l5': + case 'latin5': + case 'windows1254': return 'windows-1254'; - case 'WINDOWS-1255': + case 'windows1255': return 'windows-1255'; - case 'WINDOWS-1256': + case 'windows1256': return 'windows-1256'; - case 'WINDOWS-1257': + case 'windows1257': return 'windows-1257'; - case 'WINDOWS-1258': + case 'windows1258': return 'windows-1258'; default: - return (string) $encoding; + return $charset; } } @@ -9077,11 +10791,11 @@ class SimplePie_Misc { $curl = $curl['version']; } - elseif (substr($curl, 0, 5) == 'curl/') + elseif (substr($curl, 0, 5) === 'curl/') { $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5)); } - elseif (substr($curl, 0, 8) == 'libcurl/') + elseif (substr($curl, 0, 8) === 'libcurl/') { $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8)); } @@ -9094,7 +10808,7 @@ class SimplePie_Misc function is_subclass_of($class1, $class2) { - if (func_num_args() != 2) + if (func_num_args() !== 2) { trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING); } @@ -9111,7 +10825,7 @@ class SimplePie_Misc $class2 = strtolower($class2); while ($class1 = strtolower(get_parent_class($class1))) { - if ($class1 == $class2) + if ($class1 === $class2) { return true; } @@ -9120,7 +10834,7 @@ class SimplePie_Misc } else { - trigger_error('Unknown class passed as parameter', E_USER_WARNING); + trigger_error('Unknown class passed as parameter', E_USER_WARNNG); } } return false; @@ -9151,303 +10865,10 @@ class SimplePie_Misc return $output . $data; } - function parse_date($dt, $rfc822_tz = true) + function parse_date($dt) { - static $cache = array(); - if (!isset($cache[$dt][$rfc822_tz])) - { - $dt = SimplePie_Misc::uncomment_rfc822($dt); - /* - Capturing subpatterns: - 1: RFC 822 date - 2: RFC 822 day - 3: RFC 822 month - 4: RFC 822 year - 5: ISO 8601 date - 6: ISO 8601 century - 7: ISO 8601 year - 8: ISO 8601 month - 9: ISO 8601 day - 10: ISO 8601 ordinal day - 11: ISO 8601 month - 12: ISO 8601 day - 13: ISO 8601 week - 14: ISO 8601 day of week - 15: Time - 16: Hour - 17: Hour Decimal - 18: Minute - 19: Minute Decimal - 20: Second - 21: Second Decimal - 22: Timezone - 23: Diff ± - 24: Hour - 25: Hour Decimal - 26: Minute - 27: Minute Decimal - 28: Alphabetic Timezone - */ - if (preg_match('/^(?:(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)[,\s]+)?(([0-9]{1,2})\s*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*([0-9]{4}|[0-9]{2}))|(([0-9]{2})(?:([0-9]{2})(?:(?:-|\s)*(?:([0-9]{2})([0-9]{2})|([0-9]{3})|([0-9]{2})(?:(?:-|\s)*([0-9]{2}))?|W([0-9]{2})(?:(?:-|\s)*([0-9]))?))?)?))((?:T|\s)+([0-9]{2})(?:(?:,|\.)([0-9]*)|(?:\:|\s)*([0-9]{2})(?:(?:,|\.)([0-9]*)|(?:\:|\s)*([0-9]{2})(?:(?:,|\.)([0-9]*))?)?)?(?:\s)*((?:(\+|-)([0-9]{2})(?:(?:,|\.)([0-9]*)|(?:\:|\s)*(?:([0-9]{2})(?:(?:,|\.)([0-9]*))?))?)|(UTC|GMT|EST|CST|MST|PST|EDT|CDT|MDT|PDT|UT|[A-IK-Z]))?)?$/i', $dt, $match)) - { - // Fill all matches - for ($i = count($match); $i <= 28; $i++) - { - $match[$i] = ''; - } - - // Set blank vars - $year = 1970; - $month = 1; - $day = 1; - $hour = 0; - $minute = 0; - $second = 0; - $timezone = false; - - // RFC 822 - if ($match[1] !== '') - { - if (strlen($match[4]) == 2) - { - $year = ($match[4] < 70) ? "20$match[4]" : "19$match[4]"; - } - else - { - $year = $match[4]; - } - switch (strtolower($match[3])) - { - case 'jan': - $month = 1; - break; - - case 'feb': - $month = 2; - break; - - case 'mar': - $month = 3; - break; - - case 'apr': - $month = 4; - break; - - case 'may': - $month = 5; - break; - - case 'jun': - $month = 6; - break; - - case 'jul': - $month = 7; - break; - - case 'aug': - $month = 8; - break; - - case 'sep': - $month = 9; - break; - - case 'oct': - $month = 10; - break; - - case 'nov': - $month = 11; - break; - - case 'dec': - $month = 12; - break; - } - $day = $match[2]; - } - // ISO 8601 - else - { - // Year - if ($match[7] !== '') - { - $year = "$match[6]$match[7]"; - - // Two Digit Month/Day - if ($match[11] !== '') - { - $month = $match[11]; - if ($match[12] !== '') - { - $day = $match[12]; - } - } - - // Four Digit Month/Day - elseif ($match[8] !== '') - { - $month = $match[8]; - $day = $match[9]; - } - - // Ordinal Day - elseif ($match[10] !== '') - { - $day = $match[10]; - } - - // Week Date - elseif ($match[13] !== '') - { - // Week Day - if ($match[14] !== '') - { - $day = $match[14]; - } - - $first_day_of_year = date('w', mktime(0, 0, 0, 1, 1, $year)); - if ($first_day_of_year == 0) - { - $first_day_of_year = 7; - } - - $day = 7 * ($match[13] - 1) + $day - ($first_day_of_year - 1); - } - } - else - { - $year = "$match[6]00"; - } - } - // Time - if ($match[15] !== '') - { - $time = 0; - $time += ($match[16] + ('.' . $match[17])) * 3600; - $time += ($match[18] + ('.' . $match[19])) * 60; - $time += $match[20] + ('.' . $match[21]); - $hour = floor($time / 3600); - $time -= $hour * 3600; - $minute = floor($time / 60); - $time -= $minute * 60; - $second = round($time); - - // Timezone - if ($match[22] !== '') - { - // Alphabetic Timezone - if ($match[28] !== '') - { - // Military - if (strlen($match[28]) == 1) - { - if ($match[28] == 'Z' || $match[28] == 'z' || !$rfc822_tz) - { - $timezone = 0; - } - else - { - $timezone = ord(strtoupper($match[28])); - - if ($timezone > 74) - { - $timezone--; - } - - if ($timezone <= 76) - { - $timezone = -($timezone - 64); - } - else - { - $timezone -= 76; - } - - $timezone *= 3600; - } - } - // Code - else - { - switch (strtoupper($match[28])) - { - case 'UT': - case 'UTC': - case 'GMT': - $timezone = 0; - break; - - case 'EST': - $timezone = -18000; - break; - - case 'CST': - $timezone = -21600; - break; - - case 'MST': - $timezone = -25200; - break; - - case 'PST': - $timezone = -28800; - break; - - case 'EDT': - $timezone = -14400; - break; - - case 'CDT': - $timezone = -18000; - break; - - case 'MDT': - $timezone = -21600; - break; - - case 'PDT': - $timezone = -25200; - break; - } - } - } - // Timezone difference from UTC - else - { - $timezone = 0; - $timezone += ($match[24] + ('.' . $match[25])) * 3600; - $timezone += ($match[26] + ('.' . $match[27])) * 60; - $timezone = (int) round($timezone); - - if ($match[23] == '-') - { - $timezone = -$timezone; - } - } - } - } - if ($timezone === false) - { - $cache[$dt][$rfc822_tz] = mktime($hour, $minute, $second, $month, $day, $year); - } - else - { - $cache[$dt][$rfc822_tz] = gmmktime($hour, $minute, $second, $month, $day, $year) - $timezone; - } - } - elseif (($time = strtotime($dt)) > 0) - { - $cache[$dt][$rfc822_tz] = $time; - } - else - { - $cache[$dt][$rfc822_tz] = false; - } - } - return $cache[$dt][$rfc822_tz]; + $parser = SimplePie_Parse_Date::get(); + return $parser->parse($dt); } /** @@ -9467,27 +10888,62 @@ class SimplePie_Misc /** * Remove RFC822 comments * - * @author Tomas V.V.Cox - * @author Pierre-Alain Joye - * @author Amir Mohammad Saied - * @copyright 1997-2006 Pierre-Alain Joye,Tomas V.V.Cox,Amir Mohammad Saied - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Validate.php,v 1.104 2006/11/17 16:32:06 amir Exp $ - * @link http://pear.php.net/package/Validate * @access public * @param string $data Data to strip comments from * @return string Comment stripped string */ - function uncomment_rfc822($data) + function uncomment_rfc822($string) { - if ((version_compare(PHP_VERSION, '4.4.6', '>=') && version_compare(PHP_VERSION, '5', '<')) || version_compare(PHP_VERSION, '5.2.2', '>=')) + $string = (string) $string; + $position = 0; + $length = strlen($string); + $depth = 0; + + $output = ''; + + while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) { - return $data; - } - else - { - return preg_replace('/((?:(?:\\\\"|[^("])*(?:"(?:[^"\\\\\r]|\\\\.)*"\s*)?)*)((?> 6)) . chr(0x80 | ($codepoint & 0x3f)); + return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); } else if ($codepoint <= 0xffff) { - return $cache[$codepoint] = chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); + return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); } else if ($codepoint <= 0x10ffff) { - return $cache[$codepoint] = chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); + return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); } else { // U+FFFD REPLACEMENT CHARACTER - return $cache[$codepoint] = "\xEF\xBF\xBD"; + return "\xEF\xBF\xBD"; } } - /** - * Re-implementation of PHP 4.2.0's is_a() - * - * @static - * @access public - * @param object $object The tested object - * @param string $class_name The class name - * @return bool Returns true if the object is of this class or has this class as one of its parents, false otherwise - */ - function is_a($object, $class_name) - { - if (function_exists('is_a')) - { - return is_a($object, $class_name); - } - elseif (!is_object($object)) - { - return false; - } - elseif (get_class($object) == strtolower($class_name)) - { - return true; - } - else - { - return is_subclass_of($object, $class_name); - } - } - /** * Re-implementation of PHP 5's stripos() * @@ -9758,31 +11180,207 @@ class SimplePie_Misc * relative to the beginning of haystack. * @return bool If needle is not found, stripos() will return boolean false. */ - function stripos($haystack, $needle, $offset = 0) - { - if (function_exists('stripos')) - { - return stripos($haystack, $needle, $offset); - } - else - { - if (is_string($needle)) - { - $needle = strtolower($needle); - } - elseif (is_int($needle) || is_bool($needle) || is_double($needle)) - { - $needle = strtolower(chr($needle)); - } - else - { - trigger_error('needle is not a string or an integer', E_USER_WARNING); - return false; - } + function stripos($haystack, $needle, $offset = 0) + { + if (function_exists('stripos')) + { + return stripos($haystack, $needle, $offset); + } + else + { + if (is_string($needle)) + { + $needle = strtolower($needle); + } + elseif (is_int($needle) || is_bool($needle) || is_double($needle)) + { + $needle = strtolower(chr($needle)); + } + else + { + trigger_error('needle is not a string or an integer', E_USER_WARNING); + return false; + } - return strpos(strtolower($haystack), $needle, $offset); - } - } + return strpos(strtolower($haystack), $needle, $offset); + } + } + + /** + * Similar to parse_str() + * + * Returns an associative array of name/value pairs, where the value is an + * array of values that have used the same name + * + * @static + * @access string + * @param string $str The input string. + * @return array + */ + function parse_str($str) + { + $return = array(); + $str = explode('&', $str); + + foreach ($str as $section) + { + if (strpos($section, '=') !== false) + { + list($name, $value) = explode('=', $section, 2); + $return[urldecode($name)][] = urldecode($value); + } + else + { + $return[urldecode($section)][] = null; + } + } + + return $return; + } + + /** + * Detect XML encoding, as per XML 1.0 Appendix F.1 + * + * @todo Add support for EBCDIC + * @param string $data XML data + * @return array Possible encodings + */ + function xml_encoding($data) + { + // UTF-32 Big Endian BOM + if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") + { + $encoding[] = 'UTF-32BE'; + } + // UTF-32 Little Endian BOM + elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") + { + $encoding[] = 'UTF-32LE'; + } + // UTF-16 Big Endian BOM + elseif (substr($data, 0, 2) === "\xFE\xFF") + { + $encoding[] = 'UTF-16BE'; + } + // UTF-16 Little Endian BOM + elseif (substr($data, 0, 2) === "\xFF\xFE") + { + $encoding[] = 'UTF-16LE'; + } + // UTF-8 BOM + elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") + { + $encoding[] = 'UTF-8'; + } + // UTF-32 Big Endian Without BOM + elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C") + { + if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E")) + { + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8')); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-32BE'; + } + // UTF-32 Little Endian Without BOM + elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00") + { + if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00")) + { + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8')); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-32LE'; + } + // UTF-16 Big Endian Without BOM + elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C") + { + if ($pos = strpos($data, "\x00\x3F\x00\x3E")) + { + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8')); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-16BE'; + } + // UTF-16 Little Endian Without BOM + elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00") + { + if ($pos = strpos($data, "\x3F\x00\x3E\x00")) + { + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8')); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-16LE'; + } + // US-ASCII (or superset) + elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C") + { + if ($pos = strpos($data, "\x3F\x3E")) + { + $parser = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5)); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-8'; + } + // Fallback to UTF-8 + else + { + $encoding[] = 'UTF-8'; + } + return $encoding; + } + + function output_javascript() + { + if (function_exists('ob_gzhandler')) + { + ob_start('ob_gzhandler'); + } + header('Content-type: text/javascript; charset: UTF-8'); + header('Cache-Control: must-revalidate'); + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days + ?> +function embed_odeo(link) { + document.writeln(''); +} + +function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { + if (placeholder != '') { + document.writeln(''); + } + else { + document.writeln(''); + } +} + +function embed_flash(bgcolor, width, height, link, loop, type) { + document.writeln(''); +} + +function embed_flv(width, height, link, placeholder, loop, player) { + document.writeln(''); +} + +function embed_wmedia(width, height, link) { + document.writeln(''); +} + consumed = false; return false; } } @@ -9884,7 +11481,6 @@ class SimplePie_Decode_HTML_Entities } else { - $this->consumed = false; return false; } } @@ -9958,7 +11554,7 @@ class SimplePie_Decode_HTML_Entities $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); } - if ($this->consume() != ';') + if (!in_array($this->consume(), array(';', false), true)) { $this->unconsume(); } @@ -9972,7 +11568,7 @@ class SimplePie_Decode_HTML_Entities default: static $entities = array('Aacute' => "\xC3\x81", 'aacute' => "\xC3\xA1", 'Aacute;' => "\xC3\x81", 'aacute;' => "\xC3\xA1", 'Acirc' => "\xC3\x82", 'acirc' => "\xC3\xA2", 'Acirc;' => "\xC3\x82", 'acirc;' => "\xC3\xA2", 'acute' => "\xC2\xB4", 'acute;' => "\xC2\xB4", 'AElig' => "\xC3\x86", 'aelig' => "\xC3\xA6", 'AElig;' => "\xC3\x86", 'aelig;' => "\xC3\xA6", 'Agrave' => "\xC3\x80", 'agrave' => "\xC3\xA0", 'Agrave;' => "\xC3\x80", 'agrave;' => "\xC3\xA0", 'alefsym;' => "\xE2\x84\xB5", 'Alpha;' => "\xCE\x91", 'alpha;' => "\xCE\xB1", 'AMP' => "\x26", 'amp' => "\x26", 'AMP;' => "\x26", 'amp;' => "\x26", 'and;' => "\xE2\x88\xA7", 'ang;' => "\xE2\x88\xA0", 'apos;' => "\x27", 'Aring' => "\xC3\x85", 'aring' => "\xC3\xA5", 'Aring;' => "\xC3\x85", 'aring;' => "\xC3\xA5", 'asymp;' => "\xE2\x89\x88", 'Atilde' => "\xC3\x83", 'atilde' => "\xC3\xA3", 'Atilde;' => "\xC3\x83", 'atilde;' => "\xC3\xA3", 'Auml' => "\xC3\x84", 'auml' => "\xC3\xA4", 'Auml;' => "\xC3\x84", 'auml;' => "\xC3\xA4", 'bdquo;' => "\xE2\x80\x9E", 'Beta;' => "\xCE\x92", 'beta;' => "\xCE\xB2", 'brvbar' => "\xC2\xA6", 'brvbar;' => "\xC2\xA6", 'bull;' => "\xE2\x80\xA2", 'cap;' => "\xE2\x88\xA9", 'Ccedil' => "\xC3\x87", 'ccedil' => "\xC3\xA7", 'Ccedil;' => "\xC3\x87", 'ccedil;' => "\xC3\xA7", 'cedil' => "\xC2\xB8", 'cedil;' => "\xC2\xB8", 'cent' => "\xC2\xA2", 'cent;' => "\xC2\xA2", 'Chi;' => "\xCE\xA7", 'chi;' => "\xCF\x87", 'circ;' => "\xCB\x86", 'clubs;' => "\xE2\x99\xA3", 'cong;' => "\xE2\x89\x85", 'COPY' => "\xC2\xA9", 'copy' => "\xC2\xA9", 'COPY;' => "\xC2\xA9", 'copy;' => "\xC2\xA9", 'crarr;' => "\xE2\x86\xB5", 'cup;' => "\xE2\x88\xAA", 'curren' => "\xC2\xA4", 'curren;' => "\xC2\xA4", 'Dagger;' => "\xE2\x80\xA1", 'dagger;' => "\xE2\x80\xA0", 'dArr;' => "\xE2\x87\x93", 'darr;' => "\xE2\x86\x93", 'deg' => "\xC2\xB0", 'deg;' => "\xC2\xB0", 'Delta;' => "\xCE\x94", 'delta;' => "\xCE\xB4", 'diams;' => "\xE2\x99\xA6", 'divide' => "\xC3\xB7", 'divide;' => "\xC3\xB7", 'Eacute' => "\xC3\x89", 'eacute' => "\xC3\xA9", 'Eacute;' => "\xC3\x89", 'eacute;' => "\xC3\xA9", 'Ecirc' => "\xC3\x8A", 'ecirc' => "\xC3\xAA", 'Ecirc;' => "\xC3\x8A", 'ecirc;' => "\xC3\xAA", 'Egrave' => "\xC3\x88", 'egrave' => "\xC3\xA8", 'Egrave;' => "\xC3\x88", 'egrave;' => "\xC3\xA8", 'empty;' => "\xE2\x88\x85", 'emsp;' => "\xE2\x80\x83", 'ensp;' => "\xE2\x80\x82", 'Epsilon;' => "\xCE\x95", 'epsilon;' => "\xCE\xB5", 'equiv;' => "\xE2\x89\xA1", 'Eta;' => "\xCE\x97", 'eta;' => "\xCE\xB7", 'ETH' => "\xC3\x90", 'eth' => "\xC3\xB0", 'ETH;' => "\xC3\x90", 'eth;' => "\xC3\xB0", 'Euml' => "\xC3\x8B", 'euml' => "\xC3\xAB", 'Euml;' => "\xC3\x8B", 'euml;' => "\xC3\xAB", 'euro;' => "\xE2\x82\xAC", 'exist;' => "\xE2\x88\x83", 'fnof;' => "\xC6\x92", 'forall;' => "\xE2\x88\x80", 'frac12' => "\xC2\xBD", 'frac12;' => "\xC2\xBD", 'frac14' => "\xC2\xBC", 'frac14;' => "\xC2\xBC", 'frac34' => "\xC2\xBE", 'frac34;' => "\xC2\xBE", 'frasl;' => "\xE2\x81\x84", 'Gamma;' => "\xCE\x93", 'gamma;' => "\xCE\xB3", 'ge;' => "\xE2\x89\xA5", 'GT' => "\x3E", 'gt' => "\x3E", 'GT;' => "\x3E", 'gt;' => "\x3E", 'hArr;' => "\xE2\x87\x94", 'harr;' => "\xE2\x86\x94", 'hearts;' => "\xE2\x99\xA5", 'hellip;' => "\xE2\x80\xA6", 'Iacute' => "\xC3\x8D", 'iacute' => "\xC3\xAD", 'Iacute;' => "\xC3\x8D", 'iacute;' => "\xC3\xAD", 'Icirc' => "\xC3\x8E", 'icirc' => "\xC3\xAE", 'Icirc;' => "\xC3\x8E", 'icirc;' => "\xC3\xAE", 'iexcl' => "\xC2\xA1", 'iexcl;' => "\xC2\xA1", 'Igrave' => "\xC3\x8C", 'igrave' => "\xC3\xAC", 'Igrave;' => "\xC3\x8C", 'igrave;' => "\xC3\xAC", 'image;' => "\xE2\x84\x91", 'infin;' => "\xE2\x88\x9E", 'int;' => "\xE2\x88\xAB", 'Iota;' => "\xCE\x99", 'iota;' => "\xCE\xB9", 'iquest' => "\xC2\xBF", 'iquest;' => "\xC2\xBF", 'isin;' => "\xE2\x88\x88", 'Iuml' => "\xC3\x8F", 'iuml' => "\xC3\xAF", 'Iuml;' => "\xC3\x8F", 'iuml;' => "\xC3\xAF", 'Kappa;' => "\xCE\x9A", 'kappa;' => "\xCE\xBA", 'Lambda;' => "\xCE\x9B", 'lambda;' => "\xCE\xBB", 'lang;' => "\xE3\x80\x88", 'laquo' => "\xC2\xAB", 'laquo;' => "\xC2\xAB", 'lArr;' => "\xE2\x87\x90", 'larr;' => "\xE2\x86\x90", 'lceil;' => "\xE2\x8C\x88", 'ldquo;' => "\xE2\x80\x9C", 'le;' => "\xE2\x89\xA4", 'lfloor;' => "\xE2\x8C\x8A", 'lowast;' => "\xE2\x88\x97", 'loz;' => "\xE2\x97\x8A", 'lrm;' => "\xE2\x80\x8E", 'lsaquo;' => "\xE2\x80\xB9", 'lsquo;' => "\xE2\x80\x98", 'LT' => "\x3C", 'lt' => "\x3C", 'LT;' => "\x3C", 'lt;' => "\x3C", 'macr' => "\xC2\xAF", 'macr;' => "\xC2\xAF", 'mdash;' => "\xE2\x80\x94", 'micro' => "\xC2\xB5", 'micro;' => "\xC2\xB5", 'middot' => "\xC2\xB7", 'middot;' => "\xC2\xB7", 'minus;' => "\xE2\x88\x92", 'Mu;' => "\xCE\x9C", 'mu;' => "\xCE\xBC", 'nabla;' => "\xE2\x88\x87", 'nbsp' => "\xC2\xA0", 'nbsp;' => "\xC2\xA0", 'ndash;' => "\xE2\x80\x93", 'ne;' => "\xE2\x89\xA0", 'ni;' => "\xE2\x88\x8B", 'not' => "\xC2\xAC", 'not;' => "\xC2\xAC", 'notin;' => "\xE2\x88\x89", 'nsub;' => "\xE2\x8A\x84", 'Ntilde' => "\xC3\x91", 'ntilde' => "\xC3\xB1", 'Ntilde;' => "\xC3\x91", 'ntilde;' => "\xC3\xB1", 'Nu;' => "\xCE\x9D", 'nu;' => "\xCE\xBD", 'Oacute' => "\xC3\x93", 'oacute' => "\xC3\xB3", 'Oacute;' => "\xC3\x93", 'oacute;' => "\xC3\xB3", 'Ocirc' => "\xC3\x94", 'ocirc' => "\xC3\xB4", 'Ocirc;' => "\xC3\x94", 'ocirc;' => "\xC3\xB4", 'OElig;' => "\xC5\x92", 'oelig;' => "\xC5\x93", 'Ograve' => "\xC3\x92", 'ograve' => "\xC3\xB2", 'Ograve;' => "\xC3\x92", 'ograve;' => "\xC3\xB2", 'oline;' => "\xE2\x80\xBE", 'Omega;' => "\xCE\xA9", 'omega;' => "\xCF\x89", 'Omicron;' => "\xCE\x9F", 'omicron;' => "\xCE\xBF", 'oplus;' => "\xE2\x8A\x95", 'or;' => "\xE2\x88\xA8", 'ordf' => "\xC2\xAA", 'ordf;' => "\xC2\xAA", 'ordm' => "\xC2\xBA", 'ordm;' => "\xC2\xBA", 'Oslash' => "\xC3\x98", 'oslash' => "\xC3\xB8", 'Oslash;' => "\xC3\x98", 'oslash;' => "\xC3\xB8", 'Otilde' => "\xC3\x95", 'otilde' => "\xC3\xB5", 'Otilde;' => "\xC3\x95", 'otilde;' => "\xC3\xB5", 'otimes;' => "\xE2\x8A\x97", 'Ouml' => "\xC3\x96", 'ouml' => "\xC3\xB6", 'Ouml;' => "\xC3\x96", 'ouml;' => "\xC3\xB6", 'para' => "\xC2\xB6", 'para;' => "\xC2\xB6", 'part;' => "\xE2\x88\x82", 'permil;' => "\xE2\x80\xB0", 'perp;' => "\xE2\x8A\xA5", 'Phi;' => "\xCE\xA6", 'phi;' => "\xCF\x86", 'Pi;' => "\xCE\xA0", 'pi;' => "\xCF\x80", 'piv;' => "\xCF\x96", 'plusmn' => "\xC2\xB1", 'plusmn;' => "\xC2\xB1", 'pound' => "\xC2\xA3", 'pound;' => "\xC2\xA3", 'Prime;' => "\xE2\x80\xB3", 'prime;' => "\xE2\x80\xB2", 'prod;' => "\xE2\x88\x8F", 'prop;' => "\xE2\x88\x9D", 'Psi;' => "\xCE\xA8", 'psi;' => "\xCF\x88", 'QUOT' => "\x22", 'quot' => "\x22", 'QUOT;' => "\x22", 'quot;' => "\x22", 'radic;' => "\xE2\x88\x9A", 'rang;' => "\xE3\x80\x89", 'raquo' => "\xC2\xBB", 'raquo;' => "\xC2\xBB", 'rArr;' => "\xE2\x87\x92", 'rarr;' => "\xE2\x86\x92", 'rceil;' => "\xE2\x8C\x89", 'rdquo;' => "\xE2\x80\x9D", 'real;' => "\xE2\x84\x9C", 'REG' => "\xC2\xAE", 'reg' => "\xC2\xAE", 'REG;' => "\xC2\xAE", 'reg;' => "\xC2\xAE", 'rfloor;' => "\xE2\x8C\x8B", 'Rho;' => "\xCE\xA1", 'rho;' => "\xCF\x81", 'rlm;' => "\xE2\x80\x8F", 'rsaquo;' => "\xE2\x80\xBA", 'rsquo;' => "\xE2\x80\x99", 'sbquo;' => "\xE2\x80\x9A", 'Scaron;' => "\xC5\xA0", 'scaron;' => "\xC5\xA1", 'sdot;' => "\xE2\x8B\x85", 'sect' => "\xC2\xA7", 'sect;' => "\xC2\xA7", 'shy' => "\xC2\xAD", 'shy;' => "\xC2\xAD", 'Sigma;' => "\xCE\xA3", 'sigma;' => "\xCF\x83", 'sigmaf;' => "\xCF\x82", 'sim;' => "\xE2\x88\xBC", 'spades;' => "\xE2\x99\xA0", 'sub;' => "\xE2\x8A\x82", 'sube;' => "\xE2\x8A\x86", 'sum;' => "\xE2\x88\x91", 'sup;' => "\xE2\x8A\x83", 'sup1' => "\xC2\xB9", 'sup1;' => "\xC2\xB9", 'sup2' => "\xC2\xB2", 'sup2;' => "\xC2\xB2", 'sup3' => "\xC2\xB3", 'sup3;' => "\xC2\xB3", 'supe;' => "\xE2\x8A\x87", 'szlig' => "\xC3\x9F", 'szlig;' => "\xC3\x9F", 'Tau;' => "\xCE\xA4", 'tau;' => "\xCF\x84", 'there4;' => "\xE2\x88\xB4", 'Theta;' => "\xCE\x98", 'theta;' => "\xCE\xB8", 'thetasym;' => "\xCF\x91", 'thinsp;' => "\xE2\x80\x89", 'THORN' => "\xC3\x9E", 'thorn' => "\xC3\xBE", 'THORN;' => "\xC3\x9E", 'thorn;' => "\xC3\xBE", 'tilde;' => "\xCB\x9C", 'times' => "\xC3\x97", 'times;' => "\xC3\x97", 'TRADE;' => "\xE2\x84\xA2", 'trade;' => "\xE2\x84\xA2", 'Uacute' => "\xC3\x9A", 'uacute' => "\xC3\xBA", 'Uacute;' => "\xC3\x9A", 'uacute;' => "\xC3\xBA", 'uArr;' => "\xE2\x87\x91", 'uarr;' => "\xE2\x86\x91", 'Ucirc' => "\xC3\x9B", 'ucirc' => "\xC3\xBB", 'Ucirc;' => "\xC3\x9B", 'ucirc;' => "\xC3\xBB", 'Ugrave' => "\xC3\x99", 'ugrave' => "\xC3\xB9", 'Ugrave;' => "\xC3\x99", 'ugrave;' => "\xC3\xB9", 'uml' => "\xC2\xA8", 'uml;' => "\xC2\xA8", 'upsih;' => "\xCF\x92", 'Upsilon;' => "\xCE\xA5", 'upsilon;' => "\xCF\x85", 'Uuml' => "\xC3\x9C", 'uuml' => "\xC3\xBC", 'Uuml;' => "\xC3\x9C", 'uuml;' => "\xC3\xBC", 'weierp;' => "\xE2\x84\x98", 'Xi;' => "\xCE\x9E", 'xi;' => "\xCE\xBE", 'Yacute' => "\xC3\x9D", 'yacute' => "\xC3\xBD", 'Yacute;' => "\xC3\x9D", 'yacute;' => "\xC3\xBD", 'yen' => "\xC2\xA5", 'yen;' => "\xC2\xA5", 'yuml' => "\xC3\xBF", 'Yuml;' => "\xC5\xB8", 'yuml;' => "\xC3\xBF", 'Zeta;' => "\xCE\x96", 'zeta;' => "\xCE\xB6", 'zwj;' => "\xE2\x80\x8D", 'zwnj;' => "\xE2\x80\x8C"); - for ($i = 0, $match = null; $i < 9 && $this->consume(); $i++) + for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) { $consumed = substr($this->consumed, 1); if (isset($entities[$consumed])) @@ -9991,6 +11587,2489 @@ class SimplePie_Decode_HTML_Entities } } +/** + * IRI parser/serialiser + * + * @package SimplePie + */ +class SimplePie_IRI +{ + /** + * Scheme + * + * @access private + * @var string + */ + var $scheme; + + /** + * User Information + * + * @access private + * @var string + */ + var $userinfo; + + /** + * Host + * + * @access private + * @var string + */ + var $host; + + /** + * Port + * + * @access private + * @var string + */ + var $port; + + /** + * Path + * + * @access private + * @var string + */ + var $path; + + /** + * Query + * + * @access private + * @var string + */ + var $query; + + /** + * Fragment + * + * @access private + * @var string + */ + var $fragment; + + /** + * Whether the object represents a valid IRI + * + * @access private + * @var array + */ + var $valid = array(); + + /** + * Return the entire IRI when you try and read the object as a string + * + * @access public + * @return string + */ + function __toString() + { + return $this->get_iri(); + } + + /** + * Create a new IRI object, from a specified string + * + * @access public + * @param string $iri + * @return SimplePie_IRI + */ + function SimplePie_IRI($iri) + { + $iri = (string) $iri; + if ($iri !== '') + { + $parsed = $this->parse_iri($iri); + $this->set_scheme($parsed['scheme']); + $this->set_authority($parsed['authority']); + $this->set_path($parsed['path']); + $this->set_query($parsed['query']); + $this->set_fragment($parsed['fragment']); + } + } + + /** + * Create a new IRI object by resolving a relative IRI + * + * @static + * @access public + * @param SimplePie_IRI $base Base IRI + * @param string $relative Relative IRI + * @return SimplePie_IRI + */ + function absolutize($base, $relative) + { + $relative = (string) $relative; + if ($relative !== '') + { + $relative = new SimplePie_IRI($relative); + if ($relative->get_scheme() !== null) + { + $target = $relative; + } + elseif ($base->get_iri() !== null) + { + if ($relative->get_authority() !== null) + { + $target = $relative; + $target->set_scheme($base->get_scheme()); + } + else + { + $target = new SimplePie_IRI(''); + $target->set_scheme($base->get_scheme()); + $target->set_userinfo($base->get_userinfo()); + $target->set_host($base->get_host()); + $target->set_port($base->get_port()); + if ($relative->get_path() !== null) + { + if (strpos($relative->get_path(), '/') === 0) + { + $target->set_path($relative->get_path()); + } + elseif (($base->get_userinfo() !== null || $base->get_host() !== null || $base->get_port() !== null) && $base->get_path() === null) + { + $target->set_path('/' . $relative->get_path()); + } + elseif (($last_segment = strrpos($base->get_path(), '/')) !== false) + { + $target->set_path(substr($base->get_path(), 0, $last_segment + 1) . $relative->get_path()); + } + else + { + $target->set_path($relative->get_path()); + } + $target->set_query($relative->get_query()); + } + else + { + $target->set_path($base->get_path()); + if ($relative->get_query() !== null) + { + $target->set_query($relative->get_query()); + } + elseif ($base->get_query() !== null) + { + $target->set_query($base->get_query()); + } + } + } + $target->set_fragment($relative->get_fragment()); + } + else + { + // No base URL, just return the relative URL + $target = $relative; + } + } + else + { + $target = $base; + } + return $target; + } + + /** + * Parse an IRI into scheme/authority/path/query/fragment segments + * + * @access private + * @param string $iri + * @return array + */ + function parse_iri($iri) + { + preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $iri, $match); + for ($i = count($match); $i <= 9; $i++) + { + $match[$i] = ''; + } + return array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]); + } + + /** + * Remove dot segments from a path + * + * @access private + * @param string $input + * @return string + */ + function remove_dot_segments($input) + { + $output = ''; + while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') + { + // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, + if (strpos($input, '../') === 0) + { + $input = substr($input, 3); + } + elseif (strpos($input, './') === 0) + { + $input = substr($input, 2); + } + // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise, + elseif (strpos($input, '/./') === 0) + { + $input = substr_replace($input, '/', 0, 3); + } + elseif ($input === '/.') + { + $input = '/'; + } + // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise, + elseif (strpos($input, '/../') === 0) + { + $input = substr_replace($input, '/', 0, 4); + $output = substr_replace($output, '', strrpos($output, '/')); + } + elseif ($input === '/..') + { + $input = '/'; + $output = substr_replace($output, '', strrpos($output, '/')); + } + // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, + elseif ($input === '.' || $input === '..') + { + $input = ''; + } + // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer + elseif (($pos = strpos($input, '/', 1)) !== false) + { + $output .= substr($input, 0, $pos); + $input = substr_replace($input, '', 0, $pos); + } + else + { + $output .= $input; + $input = ''; + } + } + return $output . $input; + } + + /** + * Replace invalid character with percent encoding + * + * @access private + * @param string $string Input string + * @param string $valid_chars Valid characters + * @param int $case Normalise case + * @return string + */ + function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE) + { + // Normalise case + if ($case & SIMPLEPIE_LOWERCASE) + { + $string = strtolower($string); + } + elseif ($case & SIMPLEPIE_UPPERCASE) + { + $string = strtoupper($string); + } + + // Store position and string length (to avoid constantly recalculating this) + $position = 0; + $strlen = strlen($string); + + // Loop as long as we have invalid characters, advancing the position to the next invalid character + while (($position += strspn($string, $valid_chars, $position)) < $strlen) + { + // If we have a % character + if ($string[$position] === '%') + { + // If we have a pct-encoded section + if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2) + { + // Get the the represented character + $chr = chr(hexdec(substr($string, $position + 1, 2))); + + // If the character is valid, replace the pct-encoded with the actual character while normalising case + if (strpos($valid_chars, $chr) !== false) + { + if ($case & SIMPLEPIE_LOWERCASE) + { + $chr = strtolower($chr); + } + elseif ($case & SIMPLEPIE_UPPERCASE) + { + $chr = strtoupper($chr); + } + $string = substr_replace($string, $chr, $position, 3); + $strlen -= 2; + $position++; + } + + // Otherwise just normalise the pct-encoded to uppercase + else + { + $string = substr_replace($string, strtoupper(substr($string, $position + 1, 2)), $position + 1, 2); + $position += 3; + } + } + // If we don't have a pct-encoded section, just replace the % with its own esccaped form + else + { + $string = substr_replace($string, '%25', $position, 1); + $strlen += 2; + $position += 3; + } + } + // If we have an invalid character, change into its pct-encoded form + else + { + $replacement = sprintf("%%%02X", ord($string[$position])); + $string = str_replace($string[$position], $replacement, $string); + $strlen = strlen($string); + } + } + return $string; + } + + /** + * Check if the object represents a valid IRI + * + * @access public + * @return bool + */ + function is_valid() + { + return array_sum($this->valid) === count($this->valid); + } + + /** + * Set the scheme. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @access public + * @param string $scheme + * @return bool + */ + function set_scheme($scheme) + { + if ($scheme === null || $scheme === '') + { + $this->scheme = null; + } + else + { + $len = strlen($scheme); + switch (true) + { + case $len > 1: + if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-.', 1)) + { + $this->scheme = null; + $this->valid[__FUNCTION__] = false; + return false; + } + + case $len > 0: + if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 0, 1)) + { + $this->scheme = null; + $this->valid[__FUNCTION__] = false; + return false; + } + } + $this->scheme = strtolower($scheme); + } + $this->valid[__FUNCTION__] = true; + return true; + } + + /** + * Set the authority. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @access public + * @param string $authority + * @return bool + */ + function set_authority($authority) + { + if (($userinfo_end = strrpos($authority, '@')) !== false) + { + $userinfo = substr($authority, 0, $userinfo_end); + $authority = substr($authority, $userinfo_end + 1); + } + else + { + $userinfo = null; + } + + if (($port_start = strpos($authority, ':')) !== false) + { + $port = substr($authority, $port_start + 1); + $authority = substr($authority, 0, $port_start); + } + else + { + $port = null; + } + + return $this->set_userinfo($userinfo) && $this->set_host($authority) && $this->set_port($port); + } + + /** + * Set the userinfo. + * + * @access public + * @param string $userinfo + * @return bool + */ + function set_userinfo($userinfo) + { + if ($userinfo === null || $userinfo === '') + { + $this->userinfo = null; + } + else + { + $this->userinfo = $this->replace_invalid_with_pct_encoding($userinfo, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:'); + } + $this->valid[__FUNCTION__] = true; + return true; + } + + /** + * Set the host. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @access public + * @param string $host + * @return bool + */ + function set_host($host) + { + if ($host === null || $host === '') + { + $this->host = null; + $this->valid[__FUNCTION__] = true; + return true; + } + elseif ($host[0] === '[' && substr($host, -1) === ']') + { + if (Net_IPv6::checkIPv6(substr($host, 1, -1))) + { + $this->host = $host; + $this->valid[__FUNCTION__] = true; + return true; + } + else + { + $this->host = null; + $this->valid[__FUNCTION__] = false; + return false; + } + } + else + { + $this->host = $this->replace_invalid_with_pct_encoding($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=', SIMPLEPIE_LOWERCASE); + $this->valid[__FUNCTION__] = true; + return true; + } + } + + /** + * Set the port. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @access public + * @param string $port + * @return bool + */ + function set_port($port) + { + if ($port === null || $port === '') + { + $this->port = null; + $this->valid[__FUNCTION__] = true; + return true; + } + elseif (strspn($port, '0123456789') === strlen($port)) + { + $this->port = (int) $port; + $this->valid[__FUNCTION__] = true; + return true; + } + else + { + $this->port = null; + $this->valid[__FUNCTION__] = false; + return false; + } + } + + /** + * Set the path. + * + * @access public + * @param string $path + * @return bool + */ + function set_path($path) + { + if ($path === null || $path === '') + { + $this->path = null; + $this->valid[__FUNCTION__] = true; + return true; + } + elseif (substr($path, 0, 2) === '//' && $this->userinfo === null && $this->host === null && $this->port === null) + { + $this->path = null; + $this->valid[__FUNCTION__] = false; + return false; + } + else + { + $this->path = $this->replace_invalid_with_pct_encoding($path, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=@/'); + if ($this->scheme !== null) + { + $this->path = $this->remove_dot_segments($this->path); + } + $this->valid[__FUNCTION__] = true; + return true; + } + } + + /** + * Set the query. + * + * @access public + * @param string $query + * @return bool + */ + function set_query($query) + { + if ($query === null || $query === '') + { + $this->query = null; + } + else + { + $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?'); + } + $this->valid[__FUNCTION__] = true; + return true; + } + + /** + * Set the fragment. + * + * @access public + * @param string $fragment + * @return bool + */ + function set_fragment($fragment) + { + if ($fragment === null || $fragment === '') + { + $this->fragment = null; + } + else + { + $this->fragment = $this->replace_invalid_with_pct_encoding($fragment, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?'); + } + $this->valid[__FUNCTION__] = true; + return true; + } + + /** + * Get the complete IRI + * + * @access public + * @return string + */ + function get_iri() + { + $iri = ''; + if ($this->scheme !== null) + { + $iri .= $this->scheme . ':'; + } + if (($authority = $this->get_authority()) !== null) + { + $iri .= '//' . $authority; + } + if ($this->path !== null) + { + $iri .= $this->path; + } + if ($this->query !== null) + { + $iri .= '?' . $this->query; + } + if ($this->fragment !== null) + { + $iri .= '#' . $this->fragment; + } + + if ($iri !== '') + { + return $iri; + } + else + { + return null; + } + } + + /** + * Get the scheme + * + * @access public + * @return string + */ + function get_scheme() + { + return $this->scheme; + } + + /** + * Get the complete authority + * + * @access public + * @return string + */ + function get_authority() + { + $authority = ''; + if ($this->userinfo !== null) + { + $authority .= $this->userinfo . '@'; + } + if ($this->host !== null) + { + $authority .= $this->host; + } + if ($this->port !== null) + { + $authority .= ':' . $this->port; + } + + if ($authority !== '') + { + return $authority; + } + else + { + return null; + } + } + + /** + * Get the user information + * + * @access public + * @return string + */ + function get_userinfo() + { + return $this->userinfo; + } + + /** + * Get the host + * + * @access public + * @return string + */ + function get_host() + { + return $this->host; + } + + /** + * Get the port + * + * @access public + * @return string + */ + function get_port() + { + return $this->port; + } + + /** + * Get the path + * + * @access public + * @return string + */ + function get_path() + { + return $this->path; + } + + /** + * Get the query + * + * @access public + * @return string + */ + function get_query() + { + return $this->query; + } + + /** + * Get the fragment + * + * @access public + * @return string + */ + function get_fragment() + { + return $this->fragment; + } +} + +/** + * Class to validate and to work with IPv6 addresses. + * + * @package SimplePie + * @copyright 2003-2005 The PHP Group + * @license http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/package/Net_IPv6 + * @author Alexander Merz + * @author elfrink at introweb dot nl + * @author Josh Peck + * @author Geoffrey Sneddon + */ +class SimplePie_Net_IPv6 +{ + /** + * Removes a possible existing netmask specification of an IP address. + * + * @param string $ip the (compressed) IP as Hex representation + * @return string the IP the without netmask + * @since 1.1.0 + * @access public + * @static + */ + function removeNetmaskSpec($ip) + { + if (strpos($ip, '/') !== false) + { + list($addr, $nm) = explode('/', $ip); + } + else + { + $addr = $ip; + } + return $addr; + } + + /** + * Uncompresses an IPv6 address + * + * RFC 2373 allows you to compress zeros in an address to '::'. This + * function expects an valid IPv6 address and expands the '::' to + * the required zeros. + * + * Example: FF01::101 -> FF01:0:0:0:0:0:0:101 + * ::1 -> 0:0:0:0:0:0:0:1 + * + * @access public + * @static + * @param string $ip a valid IPv6-address (hex format) + * @return string the uncompressed IPv6-address (hex format) + */ + function Uncompress($ip) + { + $uip = SimplePie_Net_IPv6::removeNetmaskSpec($ip); + $c1 = -1; + $c2 = -1; + if (strpos($ip, '::') !== false) + { + list($ip1, $ip2) = explode('::', $ip); + if ($ip1 === '') + { + $c1 = -1; + } + else + { + $pos = 0; + if (($pos = substr_count($ip1, ':')) > 0) + { + $c1 = $pos; + } + else + { + $c1 = 0; + } + } + if ($ip2 === '') + { + $c2 = -1; + } + else + { + $pos = 0; + if (($pos = substr_count($ip2, ':')) > 0) + { + $c2 = $pos; + } + else + { + $c2 = 0; + } + } + if (strstr($ip2, '.')) + { + $c2++; + } + // :: + if ($c1 === -1 && $c2 === -1) + { + $uip = '0:0:0:0:0:0:0:0'; + } + // ::xxx + else if ($c1 === -1) + { + $fill = str_repeat('0:', 7 - $c2); + $uip = str_replace('::', $fill, $uip); + } + // xxx:: + else if ($c2 === -1) + { + $fill = str_repeat(':0', 7 - $c1); + $uip = str_replace('::', $fill, $uip); + } + // xxx::xxx + else + { + $fill = str_repeat(':0:', 6 - $c2 - $c1); + $uip = str_replace('::', $fill, $uip); + $uip = str_replace('::', ':', $uip); + } + } + return $uip; + } + + /** + * Splits an IPv6 address into the IPv6 and a possible IPv4 part + * + * RFC 2373 allows you to note the last two parts of an IPv6 address as + * an IPv4 compatible address + * + * Example: 0:0:0:0:0:0:13.1.68.3 + * 0:0:0:0:0:FFFF:129.144.52.38 + * + * @access public + * @static + * @param string $ip a valid IPv6-address (hex format) + * @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format) + */ + function SplitV64($ip) + { + $ip = SimplePie_Net_IPv6::Uncompress($ip); + if (strstr($ip, '.')) + { + $pos = strrpos($ip, ':'); + $ip[$pos] = '_'; + $ipPart = explode('_', $ip); + return $ipPart; + } + else + { + return array($ip, ''); + } + } + + /** + * Checks an IPv6 address + * + * Checks if the given IP is IPv6-compatible + * + * @access public + * @static + * @param string $ip a valid IPv6-address + * @return bool true if $ip is an IPv6 address + */ + function checkIPv6($ip) + { + $ipPart = SimplePie_Net_IPv6::SplitV64($ip); + $count = 0; + if (!empty($ipPart[0])) + { + $ipv6 = explode(':', $ipPart[0]); + for ($i = 0; $i < count($ipv6); $i++) + { + $dec = hexdec($ipv6[$i]); + $hex = strtoupper(preg_replace('/^[0]{1,3}(.*[0-9a-fA-F])$/', '\\1', $ipv6[$i])); + if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex === strtoupper(dechex($dec))) + { + $count++; + } + } + if ($count === 8) + { + return true; + } + elseif ($count === 6 && !empty($ipPart[1])) + { + $ipv4 = explode('.', $ipPart[1]); + $count = 0; + foreach ($ipv4 as $ipv4_part) + { + if ($ipv4_part >= 0 && $ipv4_part <= 255 && preg_match('/^\d{1,3}$/', $ipv4_part)) + { + $count++; + } + } + if ($count === 4) + { + return true; + } + } + else + { + return false; + } + + } + else + { + return false; + } + } +} + +/** + * Date Parser + * + * @package SimplePie + */ +class SimplePie_Parse_Date +{ + /** + * Input data + * + * @access protected + * @var string + */ + var $date; + + /** + * List of days, calendar day name => ordinal day number in the week + * + * @access protected + * @var array + */ + var $day = array( + // English + 'mon' => 1, + 'monday' => 1, + 'tue' => 2, + 'tuesday' => 2, + 'wed' => 3, + 'wednesday' => 3, + 'thu' => 4, + 'thursday' => 4, + 'fri' => 5, + 'friday' => 5, + 'sat' => 6, + 'saturday' => 6, + 'sun' => 7, + 'sunday' => 7, + // Dutch + 'maandag' => 1, + 'dinsdag' => 2, + 'woensdag' => 3, + 'donderdag' => 4, + 'vrijdag' => 5, + 'zaterdag' => 6, + 'zondag' => 7, + // French + 'lundi' => 1, + 'mardi' => 2, + 'mercredi' => 3, + 'jeudi' => 4, + 'vendredi' => 5, + 'samedi' => 6, + 'dimanche' => 7, + // German + 'montag' => 1, + 'dienstag' => 2, + 'mittwoch' => 3, + 'donnerstag' => 4, + 'freitag' => 5, + 'samstag' => 6, + 'sonnabend' => 6, + 'sonntag' => 7, + // Italian + 'lunedì' => 1, + 'martedì' => 2, + 'mercoledì' => 3, + 'giovedì' => 4, + 'venerdì' => 5, + 'sabato' => 6, + 'domenica' => 7, + // Spanish + 'lunes' => 1, + 'martes' => 2, + 'miércoles' => 3, + 'jueves' => 4, + 'viernes' => 5, + 'sábado' => 6, + 'domingo' => 7, + // Finnish + 'maanantai' => 1, + 'tiistai' => 2, + 'keskiviikko' => 3, + 'torstai' => 4, + 'perjantai' => 5, + 'lauantai' => 6, + 'sunnuntai' => 7, + // Hungarian + 'hétfő' => 1, + 'kedd' => 2, + 'szerda' => 3, + 'csütörtok' => 4, + 'péntek' => 5, + 'szombat' => 6, + 'vasárnap' => 7, + // Greek + 'Δευ' => 1, + 'Τρι' => 2, + 'Τετ' => 3, + 'Πεμ' => 4, + 'Παρ' => 5, + 'Σαβ' => 6, + 'Κυρ' => 7, + ); + + /** + * List of months, calendar month name => calendar month number + * + * @access protected + * @var array + */ + var $month = array( + // English + 'jan' => 1, + 'january' => 1, + 'feb' => 2, + 'february' => 2, + 'mar' => 3, + 'march' => 3, + 'apr' => 4, + 'april' => 4, + 'may' => 5, + // No long form of May + 'jun' => 6, + 'june' => 6, + 'jul' => 7, + 'july' => 7, + 'aug' => 8, + 'august' => 8, + 'sep' => 9, + 'september' => 8, + 'oct' => 10, + 'october' => 10, + 'nov' => 11, + 'november' => 11, + 'dec' => 12, + 'december' => 12, + // Dutch + 'januari' => 1, + 'februari' => 2, + 'maart' => 3, + 'april' => 4, + 'mei' => 5, + 'juni' => 6, + 'juli' => 7, + 'augustus' => 8, + 'september' => 9, + 'oktober' => 10, + 'november' => 11, + 'december' => 12, + // French + 'janvier' => 1, + 'février' => 2, + 'mars' => 3, + 'avril' => 4, + 'mai' => 5, + 'juin' => 6, + 'juillet' => 7, + 'août' => 8, + 'septembre' => 9, + 'octobre' => 10, + 'novembre' => 11, + 'décembre' => 12, + // German + 'januar' => 1, + 'februar' => 2, + 'märz' => 3, + 'april' => 4, + 'mai' => 5, + 'juni' => 6, + 'juli' => 7, + 'august' => 8, + 'september' => 9, + 'oktober' => 10, + 'november' => 11, + 'dezember' => 12, + // Italian + 'gennaio' => 1, + 'febbraio' => 2, + 'marzo' => 3, + 'aprile' => 4, + 'maggio' => 5, + 'giugno' => 6, + 'luglio' => 7, + 'agosto' => 8, + 'settembre' => 9, + 'ottobre' => 10, + 'novembre' => 11, + 'dicembre' => 12, + // Spanish + 'enero' => 1, + 'febrero' => 2, + 'marzo' => 3, + 'abril' => 4, + 'mayo' => 5, + 'junio' => 6, + 'julio' => 7, + 'agosto' => 8, + 'septiembre' => 9, + 'setiembre' => 9, + 'octubre' => 10, + 'noviembre' => 11, + 'diciembre' => 12, + // Finnish + 'tammikuu' => 1, + 'helmikuu' => 2, + 'maaliskuu' => 3, + 'huhtikuu' => 4, + 'toukokuu' => 5, + 'kesäkuu' => 6, + 'heinäkuu' => 7, + 'elokuu' => 8, + 'suuskuu' => 9, + 'lokakuu' => 10, + 'marras' => 11, + 'joulukuu' => 12, + // Hungarian + 'január' => 1, + 'február' => 2, + 'március' => 3, + 'április' => 4, + 'május' => 5, + 'június' => 6, + 'július' => 7, + 'augusztus' => 8, + 'szeptember' => 9, + 'október' => 10, + 'november' => 11, + 'december' => 12, + // Greek + 'Ιαν' => 1, + 'Φεβ' => 2, + 'Μάώ' => 3, + 'Μαώ' => 3, + 'Απρ' => 4, + 'Μάι' => 5, + 'Μαϊ' => 5, + 'Μαι' => 5, + 'Ιούν' => 6, + 'Ιον' => 6, + 'Ιούλ' => 7, + 'Ιολ' => 7, + 'Αύγ' => 8, + 'Αυγ' => 8, + 'Σεπ' => 9, + 'Οκτ' => 10, + 'Νοέ' => 11, + 'Δεκ' => 12, + ); + + /** + * List of timezones, abbreviation => offset from UTC + * + * @access protected + * @var array + */ + var $timezone = array( + 'ACDT' => 37800, + 'ACIT' => 28800, + 'ACST' => 34200, + 'ACT' => -18000, + 'ACWDT' => 35100, + 'ACWST' => 31500, + 'AEDT' => 39600, + 'AEST' => 36000, + 'AFT' => 16200, + 'AKDT' => -28800, + 'AKST' => -32400, + 'AMDT' => 18000, + 'AMT' => -14400, + 'ANAST' => 46800, + 'ANAT' => 43200, + 'ART' => -10800, + 'AZOST' => -3600, + 'AZST' => 18000, + 'AZT' => 14400, + 'BIOT' => 21600, + 'BIT' => -43200, + 'BOT' => -14400, + 'BRST' => -7200, + 'BRT' => -10800, + 'BST' => 3600, + 'BTT' => 21600, + 'CAST' => 18000, + 'CAT' => 7200, + 'CCT' => 23400, + 'CDT' => -18000, + 'CEDT' => 7200, + 'CET' => 3600, + 'CGST' => -7200, + 'CGT' => -10800, + 'CHADT' => 49500, + 'CHAST' => 45900, + 'CIST' => -28800, + 'CKT' => -36000, + 'CLDT' => -10800, + 'CLST' => -14400, + 'COT' => -18000, + 'CST' => -21600, + 'CVT' => -3600, + 'CXT' => 25200, + 'DAVT' => 25200, + 'DTAT' => 36000, + 'EADT' => -18000, + 'EAST' => -21600, + 'EAT' => 10800, + 'ECT' => -18000, + 'EDT' => -14400, + 'EEST' => 10800, + 'EET' => 7200, + 'EGT' => -3600, + 'EKST' => 21600, + 'EST' => -18000, + 'FJT' => 43200, + 'FKDT' => -10800, + 'FKST' => -14400, + 'FNT' => -7200, + 'GALT' => -21600, + 'GEDT' => 14400, + 'GEST' => 10800, + 'GFT' => -10800, + 'GILT' => 43200, + 'GIT' => -32400, + 'GST' => 14400, + 'GST' => -7200, + 'GYT' => -14400, + 'HAA' => -10800, + 'HAC' => -18000, + 'HADT' => -32400, + 'HAE' => -14400, + 'HAP' => -25200, + 'HAR' => -21600, + 'HAST' => -36000, + 'HAT' => -9000, + 'HAY' => -28800, + 'HKST' => 28800, + 'HMT' => 18000, + 'HNA' => -14400, + 'HNC' => -21600, + 'HNE' => -18000, + 'HNP' => -28800, + 'HNR' => -25200, + 'HNT' => -12600, + 'HNY' => -32400, + 'IRDT' => 16200, + 'IRKST' => 32400, + 'IRKT' => 28800, + 'IRST' => 12600, + 'JFDT' => -10800, + 'JFST' => -14400, + 'JST' => 32400, + 'KGST' => 21600, + 'KGT' => 18000, + 'KOST' => 39600, + 'KOVST' => 28800, + 'KOVT' => 25200, + 'KRAST' => 28800, + 'KRAT' => 25200, + 'KST' => 32400, + 'LHDT' => 39600, + 'LHST' => 37800, + 'LINT' => 50400, + 'LKT' => 21600, + 'MAGST' => 43200, + 'MAGT' => 39600, + 'MAWT' => 21600, + 'MDT' => -21600, + 'MESZ' => 7200, + 'MEZ' => 3600, + 'MHT' => 43200, + 'MIT' => -34200, + 'MNST' => 32400, + 'MSDT' => 14400, + 'MSST' => 10800, + 'MST' => -25200, + 'MUT' => 14400, + 'MVT' => 18000, + 'MYT' => 28800, + 'NCT' => 39600, + 'NDT' => -9000, + 'NFT' => 41400, + 'NMIT' => 36000, + 'NOVST' => 25200, + 'NOVT' => 21600, + 'NPT' => 20700, + 'NRT' => 43200, + 'NST' => -12600, + 'NUT' => -39600, + 'NZDT' => 46800, + 'NZST' => 43200, + 'OMSST' => 25200, + 'OMST' => 21600, + 'PDT' => -25200, + 'PET' => -18000, + 'PETST' => 46800, + 'PETT' => 43200, + 'PGT' => 36000, + 'PHOT' => 46800, + 'PHT' => 28800, + 'PKT' => 18000, + 'PMDT' => -7200, + 'PMST' => -10800, + 'PONT' => 39600, + 'PST' => -28800, + 'PWT' => 32400, + 'PYST' => -10800, + 'PYT' => -14400, + 'RET' => 14400, + 'ROTT' => -10800, + 'SAMST' => 18000, + 'SAMT' => 14400, + 'SAST' => 7200, + 'SBT' => 39600, + 'SCDT' => 46800, + 'SCST' => 43200, + 'SCT' => 14400, + 'SEST' => 3600, + 'SGT' => 28800, + 'SIT' => 28800, + 'SRT' => -10800, + 'SST' => -39600, + 'SYST' => 10800, + 'SYT' => 7200, + 'TFT' => 18000, + 'THAT' => -36000, + 'TJT' => 18000, + 'TKT' => -36000, + 'TMT' => 18000, + 'TOT' => 46800, + 'TPT' => 32400, + 'TRUT' => 36000, + 'TVT' => 43200, + 'TWT' => 28800, + 'UYST' => -7200, + 'UYT' => -10800, + 'UZT' => 18000, + 'VET' => -14400, + 'VLAST' => 39600, + 'VLAT' => 36000, + 'VOST' => 21600, + 'VUT' => 39600, + 'WAST' => 7200, + 'WAT' => 3600, + 'WDT' => 32400, + 'WEST' => 3600, + 'WFT' => 43200, + 'WIB' => 25200, + 'WIT' => 32400, + 'WITA' => 28800, + 'WKST' => 18000, + 'WST' => 28800, + 'YAKST' => 36000, + 'YAKT' => 32400, + 'YAPT' => 36000, + 'YEKST' => 21600, + 'YEKT' => 18000, + ); + + /** + * Cached PCRE for SimplePie_Parse_Date::$day + * + * @access protected + * @var string + */ + var $day_pcre; + + /** + * Cached PCRE for SimplePie_Parse_Date::$month + * + * @access protected + * @var string + */ + var $month_pcre; + + /** + * Array of user-added callback methods + * + * @access private + * @var array + */ + var $built_in = array(); + + /** + * Array of user-added callback methods + * + * @access private + * @var array + */ + var $user = array(); + + /** + * Create new SimplePie_Parse_Date object, and set self::day_pcre, + * self::month_pcre, and self::built_in + * + * @access private + */ + function SimplePie_Parse_Date() + { + $this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')'; + $this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')'; + + static $cache; + if (!isset($cache[get_class($this)])) + { + $all_methods = get_class_methods($this); + + foreach ($all_methods as $method) + { + if (strtolower(substr($method, 0, 5)) === 'date_') + { + $cache[get_class($this)][] = $method; + } + } + } + + foreach ($cache[get_class($this)] as $method) + { + $this->built_in[] = $method; + } + } + + /** + * Get the object + * + * @access public + */ + function get() + { + static $object; + if (!$object) + { + $object = new SimplePie_Parse_Date; + } + return $object; + } + + /** + * Parse a date + * + * @final + * @access public + * @param string $date Date to parse + * @return int Timestamp corresponding to date string, or false on failure + */ + function parse($date) + { + foreach ($this->user as $method) + { + if (($returned = call_user_func($method, $date)) !== false) + { + return $returned; + } + } + + foreach ($this->built_in as $method) + { + if (($returned = call_user_func(array(&$this, $method), $date)) !== false) + { + return $returned; + } + } + + return false; + } + + /** + * Add a callback method to parse a date + * + * @final + * @access public + * @param callback $callback + */ + function add_callback($callback) + { + if (is_callable($callback)) + { + $this->user[] = $callback; + } + else + { + trigger_error('User-supplied function must be a valid callback', E_USER_WARNING); + } + } + + /** + * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as + * well as allowing any of upper or lower case "T", horizontal tabs, or + * spaces to be used as the time seperator (including more than one)) + * + * @access protected + * @return int Timestamp + */ + function date_w3cdtf($date) + { + static $pcre; + if (!$pcre) + { + $year = '([0-9]{4})'; + $month = $day = $hour = $minute = $second = '([0-9]{2})'; + $decimal = '([0-9]*)'; + $zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))'; + $pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/'; + } + if (preg_match($pcre, $date, $match)) + { + /* + Capturing subpatterns: + 1: Year + 2: Month + 3: Day + 4: Hour + 5: Minute + 6: Second + 7: Decimal fraction of a second + 8: Zulu + 9: Timezone ± + 10: Timezone hours + 11: Timezone minutes + */ + + // Fill in empty matches + for ($i = count($match); $i <= 3; $i++) + { + $match[$i] = '1'; + } + + for ($i = count($match); $i <= 7; $i++) + { + $match[$i] = '0'; + } + + // Numeric timezone + if (isset($match[9]) && $match[9] !== '') + { + $timezone = $match[10] * 3600; + $timezone += $match[11] * 60; + if ($match[9] === '-') + { + $timezone = 0 - $timezone; + } + } + else + { + $timezone = 0; + } + + // Convert the number of seconds to an integer, taking decimals into account + $second = round($match[6] + $match[7] / pow(10, strlen($match[7]))); + + return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone; + } + else + { + return false; + } + } + + /** + * Remove RFC822 comments + * + * @access protected + * @param string $data Data to strip comments from + * @return string Comment stripped string + */ + function remove_rfc2822_comments($string) + { + $string = (string) $string; + $position = 0; + $length = strlen($string); + $depth = 0; + + $output = ''; + + while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) + { + $output .= substr($string, $position, $pos - $position); + $position = $pos + 1; + if ($string[$pos - 1] !== '\\') + { + $depth++; + while ($depth && $position < $length) + { + $position += strcspn($string, '()', $position); + if ($string[$position - 1] === '\\') + { + $position++; + continue; + } + elseif (isset($string[$position])) + { + switch ($string[$position]) + { + case '(': + $depth++; + break; + + case ')': + $depth--; + break; + } + $position++; + } + else + { + break; + } + } + } + else + { + $output .= '('; + } + } + $output .= substr($string, $position); + + return $output; + } + + /** + * Parse RFC2822's date format + * + * @access protected + * @return int Timestamp + */ + function date_rfc2822($date) + { + static $pcre; + if (!$pcre) + { + $wsp = '[\x09\x20]'; + $fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)'; + $optional_fws = $fws . '?'; + $day_name = $this->day_pcre; + $month = $this->month_pcre; + $day = '([0-9]{1,2})'; + $hour = $minute = $second = '([0-9]{2})'; + $year = '([0-9]{2,4})'; + $num_zone = '([+\-])([0-9]{2})([0-9]{2})'; + $character_zone = '([A-Z]{1,5})'; + $zone = '(?:' . $num_zone . '|' . $character_zone . ')'; + $pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i'; + } + if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match)) + { + /* + Capturing subpatterns: + 1: Day name + 2: Day + 3: Month + 4: Year + 5: Hour + 6: Minute + 7: Second + 8: Timezone ± + 9: Timezone hours + 10: Timezone minutes + 11: Alphabetic timezone + */ + + // Find the month number + $month = $this->month[strtolower($match[3])]; + + // Numeric timezone + if ($match[8] !== '') + { + $timezone = $match[9] * 3600; + $timezone += $match[10] * 60; + if ($match[8] === '-') + { + $timezone = 0 - $timezone; + } + } + // Character timezone + elseif (isset($this->timezone[strtoupper($match[11])])) + { + $timezone = $this->timezone[strtoupper($match[11])]; + } + // Assume everything else to be -0000 + else + { + $timezone = 0; + } + + // Deal with 2/3 digit years + if ($match[4] < 50) + { + $match[4] += 2000; + } + elseif ($match[4] < 1000) + { + $match[4] += 1900; + } + + // Second is optional, if it is empty set it to zero + if ($match[7] !== '') + { + $second = $match[7]; + } + else + { + $second = 0; + } + + return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone; + } + else + { + return false; + } + } + + /** + * Parse RFC850's date format + * + * @access protected + * @return int Timestamp + */ + function date_rfc850($date) + { + static $pcre; + if (!$pcre) + { + $space = '[\x09\x20]+'; + $day_name = $this->day_pcre; + $month = $this->month_pcre; + $day = '([0-9]{1,2})'; + $year = $hour = $minute = $second = '([0-9]{2})'; + $zone = '([A-Z]{1,5})'; + $pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i'; + } + if (preg_match($pcre, $date, $match)) + { + /* + Capturing subpatterns: + 1: Day name + 2: Day + 3: Month + 4: Year + 5: Hour + 6: Minute + 7: Second + 8: Timezone + */ + + // Month + $month = $this->month[strtolower($match[3])]; + + // Character timezone + if (isset($this->timezone[strtoupper($match[8])])) + { + $timezone = $this->timezone[strtoupper($match[8])]; + } + // Assume everything else to be -0000 + else + { + $timezone = 0; + } + + // Deal with 2 digit year + if ($match[4] < 50) + { + $match[4] += 2000; + } + else + { + $match[4] += 1900; + } + + return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone; + } + else + { + return false; + } + } + + /** + * Parse C99's asctime()'s date format + * + * @access protected + * @return int Timestamp + */ + function date_asctime($date) + { + static $pcre; + if (!$pcre) + { + $space = '[\x09\x20]+'; + $wday_name = $this->day_pcre; + $mon_name = $this->month_pcre; + $day = '([0-9]{1,2})'; + $hour = $sec = $min = '([0-9]{2})'; + $year = '([0-9]{4})'; + $terminator = '\x0A?\x00?'; + $pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i'; + } + if (preg_match($pcre, $date, $match)) + { + /* + Capturing subpatterns: + 1: Day name + 2: Month + 3: Day + 4: Hour + 5: Minute + 6: Second + 7: Year + */ + + $month = $this->month[strtolower($match[2])]; + return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]); + } + else + { + return false; + } + } + + /** + * Parse dates using strtotime() + * + * @access protected + * @return int Timestamp + */ + function date_strtotime($date) + { + $strtotime = strtotime($date); + if ($strtotime === -1 || $strtotime === false) + { + return false; + } + else + { + return $strtotime; + } + } +} + +/** + * Content-type sniffing + * + * @package SimplePie + */ +class SimplePie_Content_Type_Sniffer +{ + /** + * File object + * + * @var SimplePie_File + * @access private + */ + var $file; + + /** + * Create an instance of the class with the input file + * + * @access public + * @param SimplePie_Content_Type_Sniffer $file Input file + */ + function SimplePie_Content_Type_Sniffer($file) + { + $this->file = $file; + } + + /** + * Get the Content-Type of the specified file + * + * @access public + * @return string Actual Content-Type + */ + function get_type() + { + if (isset($this->file->headers['content-type'])) + { + if (!isset($this->file->headers['content-encoding']) + && ($this->file->headers['content-type'] === 'text/plain' + || $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1' + || $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1')) + { + return $this->text_or_binary(); + } + + if (($pos = strpos($this->file->headers['content-type'], ';')) !== false) + { + $official = substr($this->file->headers['content-type'], 0, $pos); + } + else + { + $official = $this->file->headers['content-type']; + } + $official = strtolower($official); + + if ($official === 'unknown/unknown' + || $official === 'application/unknown') + { + return $this->unknown(); + } + elseif (substr($official, -4) === '+xml' + || $official === 'text/xml' + || $official === 'application/xml') + { + return $official; + } + elseif (substr($official, 0, 6) === 'image/') + { + if ($return = $this->image()) + { + return $return; + } + else + { + return $official; + } + } + elseif ($official === 'text/html') + { + return $this->feed_or_html(); + } + else + { + return $official; + } + } + else + { + return $this->unknown(); + } + } + + /** + * Sniff text or binary + * + * @access private + * @return string Actual Content-Type + */ + function text_or_binary() + { + if (substr($this->file->body, 0, 2) === "\xFE\xFF" + || substr($this->file->body, 0, 2) === "\xFF\xFE" + || substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF" + || substr($this->file->body, 0, 3) === "\xEF\xBB\xBF") + { + return 'text/plain'; + } + elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body)) + { + return 'application/octect-stream'; + } + else + { + return 'text/plain'; + } + } + + /** + * Sniff unknown + * + * @access private + * @return string Actual Content-Type + */ + function unknown() + { + $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20"); + if (strtolower(substr($this->file->body, $ws, 14)) === 'file->body, $ws, 5)) === 'file->body, $ws, 7)) === 'file->body, 0, 5) === '%PDF-') + { + return 'application/pdf'; + } + elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-') + { + return 'application/postscript'; + } + elseif (substr($this->file->body, 0, 6) === 'GIF87a' + || substr($this->file->body, 0, 6) === 'GIF89a') + { + return 'image/gif'; + } + elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") + { + return 'image/png'; + } + elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") + { + return 'image/jpeg'; + } + elseif (substr($this->file->body, 0, 2) === "\x42\x4D") + { + return 'image/bmp'; + } + else + { + return $this->text_or_binary(); + } + } + + /** + * Sniff images + * + * @access private + * @return string Actual Content-Type + */ + function image() + { + if (substr($this->file->body, 0, 6) === 'GIF87a' + || substr($this->file->body, 0, 6) === 'GIF89a') + { + return 'image/gif'; + } + elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") + { + return 'image/png'; + } + elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") + { + return 'image/jpeg'; + } + elseif (substr($this->file->body, 0, 2) === "\x42\x4D") + { + return 'image/bmp'; + } + else + { + return false; + } + } + + /** + * Sniff HTML + * + * @access private + * @return string Actual Content-Type + */ + function feed_or_html() + { + $len = strlen($this->file->body); + $pos = strspn($this->file->body, "\x09\x0A\x0D\x20"); + + while ($pos < $len) + { + switch ($this->file->body[$pos]) + { + case "\x09": + case "\x0A": + case "\x0D": + case "\x20": + $pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos); + continue 2; + + case '<': + $pos++; + break; + + default: + return 'text/html'; + } + + if (substr($this->file->body, $pos, 3) === '!--') + { + $pos += 3; + if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false) + { + $pos += 3; + } + else + { + return 'text/html'; + } + } + elseif (substr($this->file->body, $pos, 1) === '!') + { + if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false) + { + $pos++; + } + else + { + return 'text/html'; + } + } + elseif (substr($this->file->body, $pos, 1) === '?') + { + if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false) + { + $pos += 2; + } + else + { + return 'text/html'; + } + } + elseif (substr($this->file->body, $pos, 3) === 'rss' + || substr($this->file->body, $pos, 7) === 'rdf:RDF') + { + return 'application/rss+xml'; + } + elseif (substr($this->file->body, $pos, 4) === 'feed') + { + return 'application/atom+xml'; + } + else + { + return 'text/html'; + } + } + + return 'text/html'; + } +} + +/** + * Parses the XML Declaration + * + * @package SimplePie + */ +class SimplePie_XML_Declaration_Parser +{ + /** + * XML Version + * + * @access public + * @var string + */ + var $version = '1.0'; + + /** + * Encoding + * + * @access public + * @var string + */ + var $encoding = 'UTF-8'; + + /** + * Standalone + * + * @access public + * @var bool + */ + var $standalone = false; + + /** + * Current state of the state machine + * + * @access private + * @var string + */ + var $state = 'before_version_name'; + + /** + * Input data + * + * @access private + * @var string + */ + var $data = ''; + + /** + * Input data length (to avoid calling strlen() everytime this is needed) + * + * @access private + * @var int + */ + var $data_length = 0; + + /** + * Current position of the pointer + * + * @var int + * @access private + */ + var $position = 0; + + /** + * Create an instance of the class with the input data + * + * @access public + * @param string $data Input data + */ + function SimplePie_XML_Declaration_Parser($data) + { + $this->data = $data; + $this->data_length = strlen($this->data); + } + + /** + * Parse the input data + * + * @access public + * @return bool true on success, false on failure + */ + function parse() + { + while ($this->state && $this->state !== 'emit' && $this->has_data()) + { + $state = $this->state; + $this->$state(); + } + $this->data = ''; + if ($this->state === 'emit') + { + return true; + } + else + { + $this->version = ''; + $this->encoding = ''; + $this->standalone = ''; + return false; + } + } + + /** + * Check whether there is data beyond the pointer + * + * @access private + * @return bool true if there is further data, false if not + */ + function has_data() + { + return (bool) ($this->position < $this->data_length); + } + + /** + * Advance past any whitespace + * + * @return int Number of whitespace characters passed + */ + function skip_whitespace() + { + $whitespace = strspn($this->data, "\x09\x0A\x0D\x20", $this->position); + $this->position += $whitespace; + return $whitespace; + } + + /** + * Read value + */ + function get_value() + { + $quote = substr($this->data, $this->position, 1); + if ($quote === '"' || $quote === "'") + { + $this->position++; + $len = strcspn($this->data, $quote, $this->position); + if ($this->has_data()) + { + $value = substr($this->data, $this->position, $len); + $this->position += $len + 1; + return $value; + } + } + return false; + } + + function before_version_name() + { + if ($this->skip_whitespace()) + { + $this->state = 'version_name'; + } + else + { + $this->state = false; + } + } + + function version_name() + { + if (substr($this->data, $this->position, 7) === 'version') + { + $this->position += 7; + $this->skip_whitespace(); + $this->state = 'version_equals'; + } + else + { + $this->state = false; + } + } + + function version_equals() + { + if (substr($this->data, $this->position, 1) === '=') + { + $this->position++; + $this->skip_whitespace(); + $this->state = 'version_value'; + } + else + { + $this->state = false; + } + } + + function version_value() + { + if ($this->version = $this->get_value()) + { + $this->skip_whitespace(); + if ($this->has_data()) + { + $this->state = 'encoding_name'; + } + else + { + $this->state = 'emit'; + } + } + else + { + $this->state = false; + } + } + + function encoding_name() + { + if (substr($this->data, $this->position, 8) === 'encoding') + { + $this->position += 8; + $this->skip_whitespace(); + $this->state = 'encoding_equals'; + } + else + { + $this->state = 'standalone_name'; + } + } + + function encoding_equals() + { + if (substr($this->data, $this->position, 1) === '=') + { + $this->position++; + $this->skip_whitespace(); + $this->state = 'encoding_value'; + } + else + { + $this->state = false; + } + } + + function encoding_value() + { + if ($this->encoding = $this->get_value()) + { + $this->skip_whitespace(); + if ($this->has_data()) + { + $this->state = 'standalone_name'; + } + else + { + $this->state = 'emit'; + } + } + else + { + $this->state = false; + } + } + + function standalone_name() + { + if (substr($this->data, $this->position, 10) === 'standalone') + { + $this->position += 10; + $this->skip_whitespace(); + $this->state = 'standalone_equals'; + } + else + { + $this->state = false; + } + } + + function standalone_equals() + { + if (substr($this->data, $this->position, 1) === '=') + { + $this->position++; + $this->skip_whitespace(); + $this->state = 'standalone_value'; + } + else + { + $this->state = false; + } + } + + function standalone_value() + { + if ($standalone = $this->get_value()) + { + switch ($standalone) + { + case 'yes': + $this->standalone = true; + break; + + case 'no': + $this->standalone = false; + break; + + default: + $this->state = false; + return; + } + + $this->skip_whitespace(); + if ($this->has_data()) + { + $this->state = false; + } + else + { + $this->state = 'emit'; + } + } + else + { + $this->state = false; + } + } +} + class SimplePie_Locator { var $useragent; @@ -10005,23 +14084,34 @@ class SimplePie_Locator var $base_location = 0; var $checked_feeds = 0; var $max_checked_feeds = 10; + var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer'; - function SimplePie_Locator(&$file, $timeout = 10, $useragent = null, $file_class = 'SimplePie_File', $max_checked_feeds = 10) + function SimplePie_Locator(&$file, $timeout = 10, $useragent = null, $file_class = 'SimplePie_File', $max_checked_feeds = 10, $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer') { $this->file =& $file; $this->file_class = $file_class; $this->useragent = $useragent; $this->timeout = $timeout; $this->max_checked_feeds = $max_checked_feeds; + $this->content_type_sniffer_class = $content_type_sniffer_class; } - function find($type = SIMPLEPIE_LOCATOR_ALL) + function find($type = SIMPLEPIE_LOCATOR_ALL, &$working) { if ($this->is_feed($this->file)) { return $this->file; } + if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) + { + $sniffer = new $this->content_type_sniffer_class($this->file); + if ($sniffer->get_type() !== 'text/html') + { + return null; + } + } + if ($type & ~SIMPLEPIE_LOCATOR_NONE) { $this->get_base(); @@ -10029,7 +14119,7 @@ class SimplePie_Locator if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery()) { - return $working; + return $working[0]; } if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links()) @@ -10059,24 +14149,32 @@ class SimplePie_Locator function is_feed(&$file) { - $body = SimplePie_Misc::strip_comments($file->body); - if (preg_match('/<([^\s:]+:)?(rss|RDF|feed)' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/i', $body)) + if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) + { + $sniffer = new $this->content_type_sniffer_class($file); + $sniffed = $sniffer->get_type(); + if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml'))) + { + return true; + } + else + { + return false; + } + } + elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL) { return true; } - return false; + else + { + return false; + } } function get_base() { - if (isset($this->file->headers['content-location'])) - { - $this->http_base = SimplePie_Misc::absolutize_url(trim($this->file->headers['content-location']), $this->file->url); - } - else - { - $this->http_base = $this->file->url; - } + $this->http_base = $this->file->url; $this->base = $this->http_base; $elements = SimplePie_Misc::get_element('base', $this->file->body); foreach ($elements as $element) @@ -10094,9 +14192,10 @@ class SimplePie_Locator { $links = array_merge(SimplePie_Misc::get_element('link', $this->file->body), SimplePie_Misc::get_element('a', $this->file->body), SimplePie_Misc::get_element('area', $this->file->body)); $done = array(); + $feeds = array(); foreach ($links as $link) { - if ($this->checked_feeds == $this->max_checked_feeds) + if ($this->checked_feeds === $this->max_checked_feeds) { break; } @@ -10113,19 +14212,26 @@ class SimplePie_Locator $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base); } - if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml')))) + if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) { $this->checked_feeds++; $feed = new $this->file_class($href, $this->timeout, 5, null, $this->useragent); - if ($this->is_feed($feed)) + if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) { - return $feed; + $feeds[$href] = $feed; } } $done[] = $href; } } - return null; + + if (!empty($feeds)) + { + return array_values($feeds); + } + else { + return null; + } } function get_links() @@ -10150,7 +14256,7 @@ class SimplePie_Locator $current = SimplePie_Misc::parse_url($this->file->url); - if ($parsed['authority'] === '' || $parsed['authority'] == $current['authority']) + if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) { $this->local[] = $href; } @@ -10174,7 +14280,7 @@ class SimplePie_Locator { foreach ($array as $key => $value) { - if ($this->checked_feeds == $this->max_checked_feeds) + if ($this->checked_feeds === $this->max_checked_feeds) { break; } @@ -10182,7 +14288,7 @@ class SimplePie_Locator { $this->checked_feeds++; $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent); - if ($this->is_feed($feed)) + if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) { return $feed; } @@ -10199,7 +14305,7 @@ class SimplePie_Locator { foreach ($array as $key => $value) { - if ($this->checked_feeds == $this->max_checked_feeds) + if ($this->checked_feeds === $this->max_checked_feeds) { break; } @@ -10207,7 +14313,7 @@ class SimplePie_Locator { $this->checked_feeds++; $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent); - if ($this->is_feed($feed)) + if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) { return $feed; } @@ -10223,14 +14329,12 @@ class SimplePie_Locator class SimplePie_Parser { - var $xml; var $error_code; var $error_string; var $current_line; var $current_column; var $current_byte; var $separator = ' '; - var $feed = false; var $namespace = array(''); var $element = array(''); var $xml_base = array(''); @@ -10241,10 +14345,10 @@ class SimplePie_Parser var $current_xhtml_construct = -1; var $encoding; - function pre_process(&$data, $encoding) + function parse(&$data, $encoding) { // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character - if (strtoupper($encoding) == 'US-ASCII') + if (strtoupper($encoding) === 'US-ASCII') { $this->encoding = 'UTF-8'; } @@ -10255,68 +14359,150 @@ class SimplePie_Parser // Strip BOM: // UTF-32 Big Endian BOM - if (strpos($data, "\x0\x0\xFE\xFF") === 0) + if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") { $data = substr($data, 4); } // UTF-32 Little Endian BOM - elseif (strpos($data, "\xFF\xFE\x0\x0") === 0) + elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") { $data = substr($data, 4); } // UTF-16 Big Endian BOM - elseif (strpos($data, "\xFE\xFF") === 0) + elseif (substr($data, 0, 2) === "\xFE\xFF") { $data = substr($data, 2); } // UTF-16 Little Endian BOM - elseif (strpos($data, "\xFF\xFE") === 0) + elseif (substr($data, 0, 2) === "\xFF\xFE") { $data = substr($data, 2); } // UTF-8 BOM - elseif (strpos($data, "\xEF\xBB\xBF") === 0) + elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") { $data = substr($data, 3); } - // Make sure the XML prolog is sane and has the correct encoding - $data = preg_replace("/^<\?xml[\x20\x9\xD\xA]+version([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"1.0\"|'1.0'|\"1.1\"|'1.1')([\x20\x9\xD\xA]+encoding([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"[A-Za-z][A-Za-z0-9._\-]*\"|'[A-Za-z][A-Za-z0-9._\-]*'))?([\x20\x9\xD\xA]+standalone([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"(yes|no)\"|'(yes|no)'))?([\x20\x9\xD\xA]+)?\?>/", '', $data); - $data = "\n" . $data; - } + if (substr($data, 0, 5) === '')) !== false) + { + $declaration = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5)); + if ($declaration->parse()) + { + $data = substr($data, $pos + 2); + $data = 'version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data; + } + else + { + $this->error_string = 'SimplePie bug! Please report this!'; + return false; + } + } - function parse(&$data) - { $return = true; - // Create the parser - $this->xml = xml_parser_create_ns($this->encoding, $this->separator); - xml_parser_set_option($this->xml, XML_OPTION_SKIP_WHITE, 1); - xml_parser_set_option($this->xml, XML_OPTION_CASE_FOLDING, 0); - xml_set_object($this->xml, $this); - xml_set_character_data_handler($this->xml, 'cdata'); - xml_set_element_handler($this->xml, 'tag_open', 'tag_close'); - - // workound for a bug in PHP/libxml2 as described on http://bugs.simplepie.org/issues/show/101 - $data = str_replace('<', '<', $data); - $data = str_replace('>', '>', $data); - $data = str_replace('&', '&', $data); - $data = str_replace(''', ''', $data); - $data = str_replace('"', '"', $data); - - // Parse! - if (!xml_parse($this->xml, $data, true)) + static $xml_is_sane = null; + if ($xml_is_sane === null) { - $this->data = null; - $this->error_code = xml_get_error_code($this->xml); - $this->error_string = xml_error_string($this->error_code); - $return = false; + $parser_check = xml_parser_create(); + xml_parse_into_struct($parser_check, '&', $values); + xml_parser_free($parser_check); + $xml_is_sane = isset($values[0]['value']); + } + + // Create the parser + if ($xml_is_sane) + { + $xml = xml_parser_create_ns($this->encoding, $this->separator); + xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1); + xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0); + xml_set_object($xml, $this); + xml_set_character_data_handler($xml, 'cdata'); + xml_set_element_handler($xml, 'tag_open', 'tag_close'); + + // Parse! + if (!xml_parse($xml, $data, true)) + { + $this->error_code = xml_get_error_code($xml); + $this->error_string = xml_error_string($this->error_code); + $return = false; + } + $this->current_line = xml_get_current_line_number($xml); + $this->current_column = xml_get_current_column_number($xml); + $this->current_byte = xml_get_current_byte_index($xml); + xml_parser_free($xml); + return $return; + } + else + { + libxml_clear_errors(); + $xml = new XMLReader(); + $xml->xml($data); + while (@$xml->read()) + { + switch ($xml->nodeType) + { + + case constant('XMLReader::END_ELEMENT'): + if ($xml->namespaceURI !== '') + { + $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; + } + else + { + $tagName = $xml->localName; + } + $this->tag_close(null, $tagName); + break; + case constant('XMLReader::ELEMENT'): + $empty = $xml->isEmptyElement; + if ($xml->namespaceURI !== '') + { + $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; + } + else + { + $tagName = $xml->localName; + } + $attributes = array(); + while ($xml->moveToNextAttribute()) + { + if ($xml->namespaceURI !== '') + { + $attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; + } + else + { + $attrName = $xml->localName; + } + $attributes[$attrName] = $xml->value; + } + $this->tag_open(null, $tagName, $attributes); + if ($empty) + { + $this->tag_close(null, $tagName); + } + break; + case constant('XMLReader::TEXT'): + + case constant('XMLReader::CDATA'): + $this->cdata(null, $xml->value); + break; + } + } + if ($error = libxml_get_last_error()) + { + $this->error_code = $error->code; + $this->error_string = $error->message; + $this->current_line = $error->line; + $this->current_column = $error->column; + return false; + } + else + { + return true; + } } - $this->current_line = xml_get_current_line_number($this->xml); - $this->current_column = xml_get_current_column_number($this->xml); - $this->current_byte = xml_get_current_byte_index($this->xml); - xml_parser_free($this->xml); - return $return; } function get_error_code() @@ -10351,27 +14537,6 @@ class SimplePie_Parser function tag_open($parser, $tag, $attributes) { - if ($this->feed === 0) - { - return; - } - elseif ($this->feed == false) - { - if (in_array($tag, array( - SIMPLEPIE_NAMESPACE_ATOM_10 . $this->separator . 'feed', - SIMPLEPIE_NAMESPACE_ATOM_03 . $this->separator . 'feed', - 'rss', - SIMPLEPIE_NAMESPACE_RDF . $this->separator . 'RDF' - ))) - { - $this->feed = 1; - } - } - else - { - $this->feed++; - } - list($this->namespace[], $this->element[]) = $this->split_ns($tag); $attribs = array(); @@ -10404,7 +14569,7 @@ class SimplePie_Parser if ($this->current_xhtml_construct >= 0) { $this->current_xhtml_construct++; - if (end($this->namespace) == SIMPLEPIE_NAMESPACE_XHTML) + if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML) { $this->data['data'] .= '<' . end($this->element); if (isset($attribs[''])) @@ -10422,8 +14587,8 @@ class SimplePie_Parser $this->datas[] =& $this->data; $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][]; $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang)); - if ((end($this->namespace) == SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] == 'xml') - || (end($this->namespace) == SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] == 'xhtml')) + if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml') + || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')) { $this->current_xhtml_construct = 0; } @@ -10436,7 +14601,7 @@ class SimplePie_Parser { $this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding); } - elseif ($this->feed > 1) + else { $this->data['data'] .= $cdata; } @@ -10444,22 +14609,17 @@ class SimplePie_Parser function tag_close($parser, $tag) { - if (!$this->feed) - { - return; - } - if ($this->current_xhtml_construct >= 0) { $this->current_xhtml_construct--; - if (end($this->namespace) == SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'))) + if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'))) { $this->data['data'] .= 'element) . '>'; } } - if ($this->current_xhtml_construct == -1) + if ($this->current_xhtml_construct === -1) { - $this->data =& $this->datas[$this->feed]; + $this->data =& $this->datas[count($this->datas) - 1]; array_pop($this->datas); } @@ -10468,7 +14628,6 @@ class SimplePie_Parser array_pop($this->xml_base); array_pop($this->xml_base_explicit); array_pop($this->xml_lang); - $this->feed--; } function split_ns($string) @@ -10483,7 +14642,19 @@ class SimplePie_Parser { $separator_length = strlen($this->separator); } - $cache[$string] = array(substr($string, 0, $pos), substr($string, $pos + $separator_length)); + $namespace = substr($string, 0, $pos); + $local_name = substr($string, $pos + $separator_length); + if (strtolower($namespace) === SIMPLEPIE_NAMESPACE_ITUNES) + { + $namespace = SIMPLEPIE_NAMESPACE_ITUNES; + } + + // Normalize the Media RSS namespaces + if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG) + { + $namespace = SIMPLEPIE_NAMESPACE_MEDIARSS; + } + $cache[$string] = array($namespace, $local_name); } else { @@ -10495,7 +14666,7 @@ class SimplePie_Parser } /** - * @todo Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shortern a string while preserving HTML tags + * @todo Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shorten a string while preserving HTML tags */ class SimplePie_Sanitize { @@ -10667,7 +14838,7 @@ class SimplePie_Sanitize { if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML) { - if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/(\w+)' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data)) + if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data)) { $type |= SIMPLEPIE_CONSTRUCT_HTML; } @@ -10722,9 +14893,7 @@ class SimplePie_Sanitize { foreach ($this->strip_attributes as $attrib) { - $data = preg_replace('/ '. trim($attrib) .'=("|")(\w|\s|=|-|:|;|\/|\.|\?|&|,|#|!|\(|\)|\'|'|<|>|\+|{|})*("|")/i', '', $data); - $data = preg_replace('/ '. trim($attrib) .'=(\'|')(\w|\s|=|-|:|;|\/|\.|\?|&|,|#|!|\(|\)|"|"|<|>|\+|{|})*(\'|')/i', '', $data); - $data = preg_replace('/ '. trim($attrib) .'=(\w|\s|=|-|:|;|\/|\.|\?|&|,|#|!|\(|\)|\+|{|})*/i', '', $data); + $data = preg_replace('/(<[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*)' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . trim($attrib) . '(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>/', '\1\2\3>', $data); } } @@ -10743,27 +14912,30 @@ class SimplePie_Sanitize { if (isset($img['attribs']['src']['data'])) { - $image_url = $img['attribs']['src']['data']; - $cache = new $this->cache_class($this->cache_location, call_user_func($this->cache_name_function, $image_url), 'spi'); + $image_url = call_user_func($this->cache_name_function, $img['attribs']['src']['data']); + $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $image_url, 'spi'); if ($cache->load()) { - $img['attribs']['src']['data'] = $this->image_handler . rawurlencode($img['attribs']['src']['data']); + $img['attribs']['src']['data'] = $this->image_handler . $image_url; $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data); } else { - $file = new $this->file_class($image_url, $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); + $file = new $this->file_class($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); $headers = $file->headers; - if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300))) + if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) { - if (!$cache->save(array('headers' => $file->headers, 'body' => $file->body))) + if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) { - trigger_error("$cache->name is not writeable", E_USER_WARNING); + $img['attribs']['src']['data'] = $this->image_handler . $image_url; + $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data); + } + else + { + trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); } - $img['attribs']['src']['data'] = $this->image_handler . rawurlencode($img['attribs']['src']['data']); - $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data); } } } @@ -10784,7 +14956,7 @@ class SimplePie_Sanitize $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8'); } - if ($this->output_encoding != 'UTF-8') + if ($this->output_encoding !== 'UTF-8') { $data = SimplePie_Misc::change_encoding($data, 'UTF-8', $this->output_encoding); } @@ -10806,7 +14978,9 @@ class SimplePie_Sanitize if (isset($element['attribs'][$attribute]['data'])) { $element['attribs'][$attribute]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attribute]['data'], $this->base); - $data = str_replace($element['full'], SimplePie_Misc::element_implode($element), $data); + $new_element = SimplePie_Misc::element_implode($element); + $data = str_replace($element['full'], $new_element, $data); + $element['full'] = $new_element; } } } From 54cbb215109303681447f900f2029734cc611fc9 Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Sun, 21 Nov 2010 12:25:23 +0100 Subject: [PATCH 013/110] Fixed a call to replace_invalid_with_pct_encoding (fixed upstream after SimplePie1.2) to continue to display correctly feeds with = --- inc/SimplePie.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/SimplePie.php b/inc/SimplePie.php index 1bbc2c0ec..d35443165 100644 --- a/inc/SimplePie.php +++ b/inc/SimplePie.php @@ -12151,7 +12151,7 @@ class SimplePie_IRI } else { - $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?'); + $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?&='); } $this->valid[__FUNCTION__] = true; return true; From 5e1ee188750eca4ed2f13227ede216598c9669c8 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Sun, 7 Nov 2010 02:59:21 +0800 Subject: [PATCH 014/110] Fix unicode handling. Suggested by: MQ Signed-off-by: Xin LI --- inc/DifferenceEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php index a56fe9f6e..1ff6a9fba 100644 --- a/inc/DifferenceEngine.php +++ b/inc/DifferenceEngine.php @@ -890,7 +890,7 @@ class WordLevelDiff extends MappedDiff { } function _split($lines) { - if (!preg_match_all('/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs', + if (!preg_match_all('/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xsu', implode("\n", $lines), $m)) { return array(array(''), array('')); } From 98214867894eba512bf47cba3439ccba3968f49b Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 22 Nov 2010 21:12:02 +0100 Subject: [PATCH 015/110] Render metadata when needed This changes fundamentally when metadata is rendered. This commit introduces a new cache file for every page that just contains a timestamp and is updated whenever the metadata of that page is rendered. Metadata is rendered when p_get_metadata is called and the last rendering has been before a page, metadata, configuration or renderer update or purge is set like in the xhtml renderer cache. Metadata is no longer automatically rendered when the xhtml renderer cache isn't used but will still be rendered when needed as p_get_metadata is called in the cache. Metadata is also no longer rendered in the indexer script when missing as that is already done by pageinfo() before anything else is done so the indexer script won't be called when there is no metadata file. --- inc/cache.php | 29 +++++----------------------- inc/parserutils.php | 23 +++++++++++++++++++---- lib/exe/indexer.php | 46 --------------------------------------------- 3 files changed, 24 insertions(+), 74 deletions(-) diff --git a/inc/cache.php b/inc/cache.php index 571b314cd..ff78e37ae 100644 --- a/inc/cache.php +++ b/inc/cache.php @@ -197,18 +197,6 @@ class cache_parser extends cache { } class cache_renderer extends cache_parser { - - function useCache($depends=array()) { - $use = parent::useCache($depends); - - // meta data needs to be kept in step with the cache - if (!$use && isset($this->page)) { - p_set_metadata($this->page,array(),true); - } - - return $use; - } - function _useCache() { global $conf; @@ -251,19 +239,12 @@ class cache_renderer extends cache_parser { if (isset($this->page)) { $metafile = metaFN($this->page,'.meta'); - if (@file_exists($metafile)) { - $files[] = $metafile; // ... the page's own metadata - $files[] = DOKU_INC.'inc/parser/metadata.php'; // ... the metadata renderer + $files[] = $metafile; // ... the page's own metadata - $valid = p_get_metadata($this->page, 'date valid'); - if (!empty($valid['age'])) { - $this->depends['age'] = isset($this->depends['age']) ? - min($this->depends['age'],$valid['age']) : $valid['age']; - } - - } else { - $this->depends['purge'] = true; // ... purging cache will generate metadata - return; + $valid = p_get_metadata($this->page, 'date valid'); // for xhtml this will render the metadata if needed + if (!empty($valid['age'])) { + $this->depends['age'] = isset($this->depends['age']) ? + min($this->depends['age'],$valid['age']) : $valid['age']; } } diff --git a/inc/parserutils.php b/inc/parserutils.php index a50e3f4f3..d4f55a6e4 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -221,6 +221,7 @@ function p_get_instructions($text){ * returns the metadata of a page * * @author Esther Brunner + * @author Michael Hamann */ function p_get_metadata($id, $key='', $render=false){ global $ID; @@ -231,10 +232,24 @@ function p_get_metadata($id, $key='', $render=false){ $cache = ($ID == $id); $meta = p_read_metadata($id, $cache); - // metadata has never been rendered before - do it! (but not for non-existent pages) - if ($render && !isset($meta['current']['description']['abstract']) && page_exists($id)){ - $meta = p_render_metadata($id, $meta); - p_save_metadata($id, $meta); + // prevent recursive calls in the cache + static $recursion = false; + if (!$recursion){ + $recursion = true; + + $cachefile = new cache_renderer($id, wikiFN($id), 'metadata'); + + if (page_exists($id) && !$cachefile->useCache()){ + $meta = p_render_metadata($id, $meta); + if (p_save_metadata($id, $meta)) { + // store a timestamp in order to make sure that the cachefile is touched + $cachefile->storeCache(time()); + } else { + msg('Unable to save metadata file. Hint: disk full; file permissions; safe_mode setting.',-1); + } + } + + $recursion = false; } $val = $meta['current']; diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 3fa81715b..bf5bad2e7 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -34,7 +34,6 @@ $tmp = array(); // No event data $evt = new Doku_Event('INDEXER_TASKS_RUN', $tmp); if ($evt->advise_before()) { runIndexer() or - metaUpdate() or runSitemapper() or sendDigest() or runTrimRecentChanges() or @@ -174,51 +173,6 @@ function runIndexer(){ return true; } -/** - * Will render the metadata for the page if not exists yet - * - * This makes sure pages which are created from outside DokuWiki will - * gain their data when viewed for the first time. - */ -function metaUpdate(){ - global $ID; - print "metaUpdate(): started".NL; - - if(!$ID) return false; - $file = metaFN($ID, '.meta'); - echo "meta file: $file".NL; - - // rendering needed? - if (@file_exists($file)) return false; - if (!page_exists($ID)) return false; - - global $conf; - - // gather some additional info from changelog - $info = io_grep($conf['changelog'], - '/^(\d+)\t(\d+\.\d+\.\d+\.\d+)\t'.preg_quote($ID,'/').'\t([^\t]+)\t([^\t\n]+)/', - 0,true); - - $meta = array(); - if(!empty($info)){ - $meta['date']['created'] = $info[0][1]; - foreach($info as $item){ - if($item[4] != '*'){ - $meta['date']['modified'] = $item[1]; - if($item[3]){ - $meta['contributor'][$item[3]] = $item[3]; - } - } - } - } - - $meta = p_render_metadata($ID, $meta); - p_save_metadata($ID, $meta); - - echo "metaUpdate(): finished".NL; - return true; -} - /** * Builds a Google Sitemap of all public pages known to the indexer * From d1d99bb9528b5a7ca62b74e60314288602cbd5a0 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 24 Nov 2010 16:33:47 +0100 Subject: [PATCH 016/110] check for spl_autoload_register() in install.php See http://forum.dokuwiki.org/post/22120 --- install.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.php b/install.php index ef3c848a9..9b852977f 100644 --- a/install.php +++ b/install.php @@ -460,7 +460,8 @@ function check_functions(){ 'glob header ignore_user_abort ini_get mail mkdir '. 'ob_start opendir parse_ini_file readfile realpath '. 'rename rmdir serialize session_start unlink usleep '. - 'preg_replace file_get_contents htmlspecialchars_decode'); + 'preg_replace file_get_contents htmlspecialchars_decode '. + 'spl_autoload_register'); if (!function_exists('mb_substr')) { $funcs[] = 'utf8_encode'; From 4871414204799044c31aa2764c4b4ca020e2331d Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 26 Nov 2010 16:54:51 +0100 Subject: [PATCH 017/110] Fix for $conf['breadcrumbs'] < 0, FS#2107 This fixes an infinite loop in breadcrumbs() and makes the behaviors in all places where breadcrumbs are used consistent so that non-numeric values, values < 0 and 0 are treated the same way. --- doku.php | 2 +- inc/common.php | 3 +++ inc/template.php | 2 +- lib/tpl/default/main.php | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doku.php b/doku.php index 1303f1ade..ccab843ee 100644 --- a/doku.php +++ b/doku.php @@ -69,7 +69,7 @@ if(!$INFO['exists'] && } //prepare breadcrumbs (initialize a static var) -if ($conf['breadcrumbs']) breadcrumbs(); +if ($conf['breadcrumbs'] > 0) breadcrumbs(); // check upstream checkUpdateMessages(); diff --git a/inc/common.php b/inc/common.php index 18f782788..667846804 100644 --- a/inc/common.php +++ b/inc/common.php @@ -268,6 +268,9 @@ function breadcrumbs(){ global $ACT; global $conf; + // Prevent infinite loop later in this function + if (!is_numeric($conf['breadcrumbs']) || $conf['breadcrumbs'] <= 0) return array(); + //first visit? $crumbs = isset($_SESSION[DOKU_COOKIE]['bc']) ? $_SESSION[DOKU_COOKIE]['bc'] : array(); //we only save on show and existing wiki documents diff --git a/inc/template.php b/inc/template.php index e2ea6e386..b89f7abbc 100644 --- a/inc/template.php +++ b/inc/template.php @@ -690,7 +690,7 @@ function tpl_breadcrumbs($sep='»'){ global $conf; //check if enabled - if(!$conf['breadcrumbs']) return false; + if(!is_numeric($conf['breadcrumbs']) || $conf['breadcrumbs'] <= 0) return false; $crumbs = breadcrumbs(); //setup crumb trace diff --git a/lib/tpl/default/main.php b/lib/tpl/default/main.php index 754a6e482..c1b62f12e 100644 --- a/lib/tpl/default/main.php +++ b/lib/tpl/default/main.php @@ -68,7 +68,7 @@ if (!defined('DOKU_INC')) die();
- + 0){?> - 0){?> + '; $shown[$hash] = 1; } + + unset($GLOBALS['MSG']); } /** diff --git a/inc/infoutils.php b/inc/infoutils.php index d3c6f2918..5f406aa3e 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -258,7 +258,7 @@ function check(){ * @see html_msgarea */ function msg($message,$lvl=0,$line='',$file=''){ - global $MSG; + global $MSG, $MSG_shown; $errors[-1] = 'error'; $errors[0] = 'info'; $errors[1] = 'success'; @@ -268,7 +268,7 @@ function msg($message,$lvl=0,$line='',$file=''){ if(!isset($MSG)) $MSG = array(); $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); - if(headers_sent()){ + if(isset($MSG_shown) || headers_sent()){ if(function_exists('html_msgarea')){ html_msgarea(); }else{ From 517a47eca3a26afd3aedfd47eb372596af4029ae Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 10 Jan 2011 22:47:54 +0100 Subject: [PATCH 078/110] Call the indexer for hidden pages This makes sure that the indexer is also called for hidden pages so they aren't missing in the title index and digest subscriptions work for them, too. Hidden pages are already filtered from the search results. --- inc/template.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/inc/template.php b/inc/template.php index 413c3af07..e4c74a714 100644 --- a/inc/template.php +++ b/inc/template.php @@ -988,8 +988,6 @@ function tpl_indexerWebBug(){ global $INFO; if(!$INFO['exists']) return false; - if(isHiddenPage($ID)) return false; //no need to index hidden pages - $p = array(); $p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID). '&'.time(); From ff725173bf45c47b1ed9778524710cce72b1d42d Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 10 Jan 2011 23:41:43 +0100 Subject: [PATCH 079/110] Add define for metadata usage limit in p_get_first_heading This commit introduces a new define P_GET_FIRST_HEADING_METADATA_LIMIT that can be set in preload.php in order to change the limit for how many pages the first heading shall be loaded from metadata in p_get_first_heading. Changing this is probably most interesting for Wikis with a lot of pages where loading the title index costs a significant amount of time and memory. --- inc/parserutils.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/inc/parserutils.php b/inc/parserutils.php index b7359d7ef..6e349e984 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -9,6 +9,13 @@ if(!defined('DOKU_INC')) die('meh.'); +/** + * For how many different pages shall the first heading be loaded from the + * metadata? When this limit is reached the title index is loaded and used for + * all following requests. + */ +if (!defined('P_GET_FIRST_HEADING_METADATA_LIMIT')) define('P_GET_FIRST_HEADING_METADATA_LIMIT', 10); + /** * Returns the parsed Wikitext in XHTML for the given id and revision. * @@ -629,7 +636,7 @@ function & p_get_renderer($mode) { */ function p_get_first_heading($id, $render=true){ // counter how many titles have been requested using p_get_metadata - static $count = 0; + static $count = 1; // the index of all titles, only loaded when many titles are requested static $title_index = null; // cache for titles requested using p_get_metadata @@ -643,7 +650,7 @@ function p_get_first_heading($id, $render=true){ // check if already too many titles have been requested and probably // using the title index is better - if ($count > 10) { + if ($count > P_GET_FIRST_HEADING_METADATA_LIMIT) { if (is_null($title_index)) { $pages = array_map('rtrim', idx_getIndex('page', '')); $titles = array_map('rtrim', idx_getIndex('title', '')); From 9063ec149f164f26e583c635f4fa29dcba23eb90 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 12 Jan 2011 13:09:23 +0100 Subject: [PATCH 080/110] Remove trailing whitespace in buildAttributes output --- inc/common.php | 5 ++++- inc/form.php | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/inc/common.php b/inc/common.php index 6ea6d56d8..b4866bccf 100644 --- a/inc/common.php +++ b/inc/common.php @@ -242,13 +242,16 @@ function buildURLparams($params, $sep='&'){ */ function buildAttributes($params,$skipempty=false){ $url = ''; + $white = false; foreach($params as $key => $val){ if($key{0} == '_') continue; if($val === '' && $skipempty) continue; + if($white) $url .= ' '; $url .= $key.'="'; $url .= htmlspecialchars ($val); - $url .= '" '; + $url .= '"'; + $white = true; } return $url; } diff --git a/inc/form.php b/inc/form.php index e614d2f30..30e16b626 100644 --- a/inc/form.php +++ b/inc/form.php @@ -696,7 +696,7 @@ function form_wikitext($attrs) { */ function form_button($attrs) { $p = (!empty($attrs['_action'])) ? 'name="do['.$attrs['_action'].']" ' : ''; - return ''; + return ''; } /** @@ -714,7 +714,7 @@ function form_field($attrs) { if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"'; if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"'; $s .= '>'.$attrs['_text'].''; - $s .= ' '; + $s .= ' '; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; return $s; @@ -734,7 +734,7 @@ function form_fieldright($attrs) { $s = ''; + $s .= '>'; $s .= ' '.$attrs['_text'].''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; @@ -758,7 +758,7 @@ function form_textfield($attrs) { if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"'; if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"'; $s .= '>'.$attrs['_text'].' '; - $s .= ''; + $s .= ''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; return $s; @@ -781,7 +781,7 @@ function form_passwordfield($attrs) { if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"'; if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"'; $s .= '>'.$attrs['_text'].' '; - $s .= ''; + $s .= ''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; return $s; @@ -807,7 +807,7 @@ function form_filefield($attrs) { $s .= ''; $attrs['value'] = $attrs['value'][0]; } - $s .= ''; + $s .= ''; $s .= ' '.$attrs['_text'].''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; @@ -860,7 +860,7 @@ function form_radiofield($attrs) { $s = ''; + $s .= '>'; $s .= ' '.$attrs['_text'].''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; From 283c7183458261e20d78d545539cdaa727ee1590 Mon Sep 17 00:00:00 2001 From: Usama Akkad Date: Wed, 12 Jan 2011 20:13:38 +0100 Subject: [PATCH 081/110] Arabic language update --- inc/lang/ar/lang.php | 129 ++++++++++--------- lib/plugins/config/lang/ar/lang.php | 9 +- lib/plugins/popularity/lang/ar/lang.php | 5 + lib/plugins/popularity/lang/ar/submitted.txt | 3 + 4 files changed, 82 insertions(+), 64 deletions(-) create mode 100644 lib/plugins/popularity/lang/ar/submitted.txt diff --git a/inc/lang/ar/lang.php b/inc/lang/ar/lang.php index 30095347e..0a2341b97 100644 --- a/inc/lang/ar/lang.php +++ b/inc/lang/ar/lang.php @@ -28,7 +28,7 @@ $lang['btn_revs'] = 'نسخ قديمة'; $lang['btn_recent'] = 'أحدث التغييرات'; $lang['btn_upload'] = 'ارفع'; $lang['btn_cancel'] = 'ألغ'; -$lang['btn_index'] = 'فهرس'; +$lang['btn_index'] = 'خريطة موقع'; $lang['btn_secedit'] = 'حرر'; $lang['btn_login'] = 'لج'; $lang['btn_logout'] = 'اخرج'; @@ -54,21 +54,21 @@ $lang['newpass'] = 'كلمة سر جديدة'; $lang['oldpass'] = 'أكد كلمة السر الحالية'; $lang['passchk'] = 'مرة أخرى'; $lang['remember'] = 'تذكرني'; -$lang['fullname'] = 'الاسم الكامل'; +$lang['fullname'] = 'الاسم الحقيقي'; $lang['email'] = 'البريد الإلكتروني'; $lang['register'] = 'سجّل'; $lang['profile'] = 'الملف الشخصي'; $lang['badlogin'] = 'عذرا، اسم المشترك أو كلمة السر غير صحيحة'; $lang['minoredit'] = 'تعديلات طفيفة'; -$lang['draftdate'] = 'حفظ المسودات تلقائيا مشغل'; -$lang['nosecedit'] = 'غُيرت الصفحة في هذه الأثناء، معلومات الفقرة اصبحت قديمة. حُمُلت كل الصفحة بدلا.'; -$lang['regmissing'] = 'عذرا، يجب ملء جميع الحقول'; +$lang['draftdate'] = 'حفظ المسودات آليا مفعّل'; +$lang['nosecedit'] = 'غُيرت الصفحة في هذه الأثناء، معلومات الجزء اصبحت قديمة. حُمُلت كل الصفحة بدلا.'; +$lang['regmissing'] = 'عذرا، عليك ملء جميع الحقول.'; $lang['reguexists'] = 'عذرا، يوجد مشترك بنفس الاسم.'; $lang['regsuccess'] = 'أنشئ المستخدم و ارسلت كلمة السر بالبريد.'; $lang['regsuccess2'] = 'أنشئ المستخدم.'; -$lang['regmailfail'] = 'حدث خطأ فى إرسال رسالة كلمة اسرر. يرجى مراسلة المدير'; -$lang['regbadmail'] = 'يبدو البريد الإلكتروني المعطى غير صحيح، إن كنت تظن أن هذا خطأ، راسل المدير'; -$lang['regbadpass'] = 'كلمتى المرور غير متطابقتين، حاول مرة أخرى.'; +$lang['regmailfail'] = 'حدث خطأ فى إرسال رسالة كلمة السر. يرجى مراسلة المدير!'; +$lang['regbadmail'] = 'يبدو البريد الإلكتروني المعطى غيرَ صحيح، إن كنت تظن أن هذا خطأ، راسل المدير'; +$lang['regbadpass'] = 'كلمتا المرور غير متطابقتين، حاول مرة أخرى.'; $lang['regpwmail'] = 'كلمة مرورك إلى دوكو ويكي'; $lang['reghere'] = 'ليس لديك حساب بعد؟ احصل على واحد'; $lang['profna'] = 'هذه الويكي لا تدعم تعديل الملف الشخصي'; @@ -81,35 +81,35 @@ $lang['resendpwd'] = 'إرسال كلمة مرور'; $lang['resendpwdmissing'] = 'عذراّ، يجب أن تملأ كل الحقول.'; $lang['resendpwdnouser'] = 'عذراً، لم نجد المستخدم هذا في قاعدة بياناتنا.'; $lang['resendpwdbadauth'] = 'عذراً، رمز التفعيل هذا غير صحيح. نأكد من استخدامك كامل وصلة التأكيد.'; -$lang['resendpwdconfirm'] = 'أرسل رابط التأكيد بواسطة البريد.'; -$lang['resendpwdsuccess'] = 'كلمة السرالجديدة إرسلت عبر البريد.'; -$lang['license'] = 'مالم يشر لخلاف ذلك، فإن المحتوى على هذه الويكي مرخص وفق الرخصة التالية:'; +$lang['resendpwdconfirm'] = 'اُرسل رابط التأكيد بواسطة البريد.'; +$lang['resendpwdsuccess'] = 'كلمة السرالجديدة اُرسلت عبر البريد.'; +$lang['license'] = 'مالم يشر لخلاف ذلك، فإن المحتوى في هذه الويكي مرخص وفق الرخصة التالية:'; $lang['licenseok'] = 'لاحظ: بتحرير هذه الصفحة أنت توافق على ترخيص محتواها تحت الرخصة التالية:'; -$lang['searchmedia'] = 'ابحث في اسماء الملفات:'; +$lang['searchmedia'] = 'ابحث في أسماء الملفات:'; $lang['searchmedia_in'] = 'ابحث في %s'; $lang['txt_upload'] = 'اختر ملفاً للرفع'; $lang['txt_filename'] = 'رفع كـ (اختياري)'; $lang['txt_overwrt'] = 'اكتب على ملف موجود'; -$lang['lockedby'] = 'حالياً مقفل بواسطة'; +$lang['lockedby'] = 'مقفلة حاليا لـ'; $lang['lockexpire'] = 'ينتهي القفل في'; $lang['willexpire'] = 'سينتهي قفل تحرير هذه الصفحه خلال دقيقة.\nلتجنب التعارض استخدم زر المعاينة لتصفير مؤقت القفل.'; -$lang['js']['notsavedyet'] = 'التعديلات غير المحفوظة ستفقد. اكمل فعلا؟'; +$lang['js']['notsavedyet'] = 'التعديلات غير المحفوظة ستفقد.'; $lang['js']['searchmedia'] = 'ابحث عن ملفات'; $lang['js']['keepopen'] = 'أبقي النافذة مفتوحة أثناء الاختيار'; $lang['js']['hidedetails'] = 'أخف التفاصيل'; -$lang['js']['mediatitle'] = 'اعدادات الرابط'; +$lang['js']['mediatitle'] = 'إعدادات الرابط'; $lang['js']['mediadisplay'] = 'نوع الرابط'; $lang['js']['mediaalign'] = 'المحاذاة'; $lang['js']['mediasize'] = 'حجم الصورة'; $lang['js']['mediatarget'] = 'هدف الرابط'; -$lang['js']['mediaclose'] = 'اغلق'; +$lang['js']['mediaclose'] = 'أغلق'; $lang['js']['mediainsert'] = 'أدرج'; -$lang['js']['mediadisplayimg'] = 'اظهر الصورة.'; +$lang['js']['mediadisplayimg'] = 'أظهر الصورة.'; $lang['js']['mediadisplaylnk'] = 'اظهر الرابط فقط.'; $lang['js']['mediasmall'] = 'نسخة مصغرة'; $lang['js']['mediamedium'] = 'نسخة متوسطة'; $lang['js']['medialarge'] = 'نسخة كبيرة'; -$lang['js']['mediaoriginal'] = 'نسخة أصلية'; +$lang['js']['mediaoriginal'] = 'النسخة الأصلية'; $lang['js']['medialnk'] = 'الرابط لصفحة التفاصيل'; $lang['js']['mediadirect'] = 'رابط مباشر للأصل'; $lang['js']['medianolnk'] = 'لا رابط'; @@ -118,70 +118,73 @@ $lang['js']['medialeft'] = 'حاذي الصورة إلى اليسار.'; $lang['js']['mediaright'] = 'حاذي الصورة إلى اليمين.'; $lang['js']['mediacenter'] = 'حاذي الصورة إلى الوسط.'; $lang['js']['medianoalign'] = 'لا تستعمل المحاذاة.'; -$lang['js']['nosmblinks'] = 'الروابط لمجلدات ويندوز المشاركة تعمل فقط مع متصفح مايكروسفت Internet Explorer. ما زال بإمكانك قص و لصق الرابط.'; +$lang['js']['nosmblinks'] = 'الروابط لمجلدات مشاركة وندز تعمل فقط مع متصفح مايكروسفت Internet Explorer. +ما زال بإمكانك قص و لصق الرابط.'; $lang['js']['linkwiz'] = 'مرشد الروابط'; $lang['js']['linkto'] = 'الرابط إلى :'; $lang['js']['del_confirm'] = 'هل حقاً تريد حذف البنود المختارة؟'; $lang['js']['mu_btn'] = 'رفع عدة ملفات في وقت واحد'; $lang['rssfailed'] = 'خطأ ما حدث أثناء جلب ملف التغذية:'; $lang['nothingfound'] = 'لا يوجد شيء'; -$lang['mediaselect'] = 'ملفات الوسائط المتعددة'; -$lang['fileupload'] = 'تحميل ملف وسائط متعددة'; -$lang['uploadsucc'] = 'تم التحميل بنجاح'; -$lang['uploadfail'] = 'فشل التحميل، قد يكون الخطأ فى التراخيص؟'; -$lang['uploadwrong'] = 'التحميل ممنوع، نوع الملف مرفوض!'; -$lang['uploadexist'] = 'الملف موجود أصلاً. لم يحدث شيء'; -$lang['uploadbadcontent'] = 'المحتوى المحمّل لم يتطابق مع نوع الملف %s'; -$lang['uploadspam'] = 'التحميل محجوب بواسطة القائمة السوداء لبرنامج تقفي التطفل'; -$lang['uploadxss'] = 'التحميل محجوب لمنع المحتويات الخبيثة'; -$lang['uploadsize'] = 'الملف الذي تم رفعه كبير جدا . ( الحد الأقصى %s )'; -$lang['deletesucc'] = 'تم حذف الملف "%s"'; -$lang['deletefail'] = 'لا يمكن حذف "%s"، تأكد من تراخيصك'; -$lang['mediainuse'] = 'لم يحذف الملف "%s"، مازال موجوداً'; +$lang['mediaselect'] = 'ملفات الوسائط'; +$lang['fileupload'] = 'تحميل ملف وسائط'; +$lang['uploadsucc'] = 'تم الرفع بنجاح'; +$lang['uploadfail'] = 'فشل الرفع، ربما خطأ تراخيص؟'; +$lang['uploadwrong'] = 'الرفع ممنوع، نوع الملف مرفوض!'; +$lang['uploadexist'] = 'الملف موجود أصلاً. لم يُعمل شيئ.'; +$lang['uploadbadcontent'] = 'المحتوى المرفوع لم يطابق لاحقة ملفات %s.'; +$lang['uploadspam'] = 'الرفع محجوب بواسطة القائمة السوداء لبرنامج تقفي التطفل.'; +$lang['uploadxss'] = 'رُفض الرفع للإشتباه بمحتوى ضار.'; +$lang['uploadsize'] = 'الملف المرفوع كان كبيرا جدا . ( الحد %s )'; +$lang['deletesucc'] = 'حُذف الملف "%s".'; +$lang['deletefail'] = 'تعذر حذف "%s" - تأكد من الصلاحيات.'; +$lang['mediainuse'] = 'لم يحذف الملف "%s" - مازال مستخدما.'; $lang['namespaces'] = 'فضاء التسمية'; $lang['mediafiles'] = 'ملفات موجودة في'; +$lang['accessdenied'] = 'لا يسمح لك برؤية هذه الصفحة.'; $lang['mediausage'] = 'استخدم هذه الصياغة للدلالة على هذا الملف:'; -$lang['mediaview'] = 'عرض الملف الأصلي'; +$lang['mediaview'] = 'اعرض الملف الأصلي'; $lang['mediaroot'] = 'الجذر'; -$lang['mediaupload'] = 'تحميل ملف إلى فضاء التسمية هنا. لإنشاء فضاءات تسمية فرعية، أضفها إلى بداية خانة تحميل باسم وافصل بينها باستخدام الفواصل'; -$lang['mediaextchange'] = 'تم تغيير نوع الملف من .%s إلى .%s!'; +$lang['mediaupload'] = 'تحميل ملف إلى فضاء التسمية هنا. لإنشاء فضاءات تسمية فرعية، أضفها إلى بداية خانة تحميل باسم وافصل بينها باستخدام الفاصلتان الرأسيتان.'; +$lang['mediaextchange'] = 'غُيرت لاحقة الملف من .%s إلى .%s!'; $lang['reference'] = 'مراجع لـ'; $lang['ref_inuse'] = 'لا يمكن حذف الملف، لأنه مستخدم من قبل الصفحات التالية:'; -$lang['ref_hidden'] = 'بعض المراجع لصفاحات لا تملك ترخيص برؤيتها'; -$lang['hits'] = 'زوار'; -$lang['quickhits'] = 'صفحات بهذا الاسم'; +$lang['ref_hidden'] = 'بعض المراجع على صفحات لا تملك صلاحيات قراءتها'; +$lang['hits'] = 'مرة'; +$lang['quickhits'] = 'صفحات مطابقة'; $lang['toc'] = 'جدول المحتويات'; $lang['current'] = 'حالي'; $lang['yours'] = 'نسختك'; -$lang['diff'] = 'مقارنة بالنسخة الحالية'; -$lang['diff2'] = 'مقارنة بين النسخ المختارة'; +$lang['diff'] = 'أظهر الاختلافات مع النسخة الحالية'; +$lang['diff2'] = 'أظهر الاختلافات بين النسخ المحددة'; +$lang['difflink'] = 'رابط إلى هذه المقارنة'; $lang['line'] = 'سطر'; $lang['breadcrumb'] = 'أثر'; $lang['youarehere'] = 'أنت هنا'; $lang['lastmod'] = 'آخر تعديل'; $lang['by'] = 'بواسطة'; -$lang['deleted'] = 'تم حذف'; -$lang['created'] = 'تم إنشاء'; -$lang['restored'] = 'عودة لنسخة قديمة'; +$lang['deleted'] = 'حذفت'; +$lang['created'] = 'اُنشئت'; +$lang['restored'] = 'استعيدت نسخة قديمة'; $lang['external_edit'] = 'تحرير خارجي'; $lang['summary'] = 'ملخص التحرير'; $lang['noflash'] = 'تحتاج إلىملحق فلاش أدوبي لعرض هذا المحتوى.'; $lang['download'] = 'نزل Snippet'; $lang['mail_newpage'] = 'إضافة صفحة:'; $lang['mail_changed'] = 'تعديل صفحة:'; -$lang['mail_subscribe_list'] = 'صفحات غيرت في النظاق:'; -$lang['mail_new_user'] = 'مشترك جديد'; -$lang['mail_upload'] = 'تحميل ملف:'; +$lang['mail_subscribe_list'] = 'صفحات غيرت في النطاق:'; +$lang['mail_new_user'] = 'مشترك جديد:'; +$lang['mail_upload'] = 'رفع ملف:'; $lang['qb_bold'] = 'نص عريض'; $lang['qb_italic'] = 'نص مائل'; $lang['qb_underl'] = 'نص مسطر'; $lang['qb_code'] = 'نص برمجي'; $lang['qb_strike'] = 'نص مشطوب'; -$lang['qb_h1'] = 'عنوان مستوى أول'; -$lang['qb_h2'] = 'عنوان مستوى ثاني'; -$lang['qb_h3'] = 'عنوان مستوى ثالث'; -$lang['qb_h4'] = 'عنوان مستوى رابع'; -$lang['qb_h5'] = 'عنوان مستوى خامس'; +$lang['qb_h1'] = 'عنوان مستوى ١'; +$lang['qb_h2'] = 'عنوان مستوى ٢'; +$lang['qb_h3'] = 'عنوان مستوى ٣'; +$lang['qb_h4'] = 'عنوان مستوى ٤'; +$lang['qb_h5'] = 'عنوان مستوى ٥'; $lang['qb_h'] = 'الترويسة'; $lang['qb_hs'] = 'حدد الترويسة'; $lang['qb_hplus'] = 'ترويسة أعلى'; @@ -192,29 +195,29 @@ $lang['qb_extlink'] = 'رابط خارجي'; $lang['qb_hr'] = 'سطر أفقي'; $lang['qb_ol'] = 'بند فى قائمة مرتبة'; $lang['qb_ul'] = 'بند فى قائمة غير مرتبة'; -$lang['qb_media'] = 'إضافة صور و ملفات أخرى'; -$lang['qb_sig'] = 'أضف توقيعك'; -$lang['qb_smileys'] = 'الابتسامات'; +$lang['qb_media'] = 'أضف صورا و ملفات أخرى'; +$lang['qb_sig'] = 'أدرج التوقيع'; +$lang['qb_smileys'] = 'الإبتسامات'; $lang['qb_chars'] = 'محارف خاصة'; $lang['upperns'] = 'انتقل للنطاق الأب'; -$lang['admin_register'] = 'إضافة مشترك جديد'; +$lang['admin_register'] = 'أضف مستخدما جديدا'; $lang['metaedit'] = 'تحرير البيانات الشمولية '; -$lang['metasaveerr'] = 'فشلت عملية كتابة البيانات الشمولية'; -$lang['metasaveok'] = 'تم حفظ البيانت الشمولية'; -$lang['img_backto'] = 'العودة إلى'; +$lang['metasaveerr'] = 'فشلت كتابة البيانات الشمولية'; +$lang['metasaveok'] = 'حُفظت البيانات الشمولية'; +$lang['img_backto'] = 'عودة إلى'; $lang['img_title'] = 'العنوان'; -$lang['img_caption'] = 'تنويه الصورة'; +$lang['img_caption'] = 'وصف'; $lang['img_date'] = 'التاريخ'; $lang['img_fname'] = 'اسم الملف'; $lang['img_fsize'] = 'الحجم'; $lang['img_artist'] = 'المصور'; $lang['img_copyr'] = 'حقوق النسخ'; -$lang['img_format'] = 'صيغ رسومية'; -$lang['img_camera'] = 'آلة التصوير'; +$lang['img_format'] = 'الهيئة'; +$lang['img_camera'] = 'الكمرا'; $lang['img_keywords'] = 'كلمات مفتاحية'; $lang['subscr_subscribe_success'] = 'اضيف %s لقائمة اشتراك %s'; $lang['subscr_subscribe_error'] = 'خطأ في إضافة %s لقائمة اشتراك %s'; -$lang['subscr_subscribe_noaddress'] = 'ليس هناك عنوان مرتبط بدخولك، لا يمكن اضافتك لقائمة الاشتراك'; +$lang['subscr_subscribe_noaddress'] = 'ليس هناك عنوان مرتبط بولوجك، لا يمكن اضافتك لقائمة الاشتراك'; $lang['subscr_unsubscribe_success'] = 'أزيل %s من قائمة اشتراك %s'; $lang['subscr_unsubscribe_error'] = 'خطأ في إزالة %s من قائمة اشتراك %s'; $lang['subscr_already_subscribed'] = '%s مشترك مسبقا في %s'; @@ -224,7 +227,7 @@ $lang['subscr_m_new_header'] = 'أضف اشتراكا'; $lang['subscr_m_current_header'] = 'الاشتراكات الحالية'; $lang['subscr_m_unsubscribe'] = 'ألغ الاشتراك'; $lang['subscr_m_subscribe'] = 'اشترك'; -$lang['subscr_m_receive'] = 'استقبل'; +$lang['subscr_m_receive'] = 'استقبال'; $lang['subscr_style_every'] = 'بريدا على كل تغيير'; $lang['subscr_style_digest'] = 'بريد ملخص عن تغييرات كل صفحة'; $lang['subscr_style_list'] = 'قائمة بالصفحات المتغيرة منذ آخر بريد'; diff --git a/lib/plugins/config/lang/ar/lang.php b/lib/plugins/config/lang/ar/lang.php index 5d0ff76b9..26cc16e5c 100644 --- a/lib/plugins/config/lang/ar/lang.php +++ b/lib/plugins/config/lang/ar/lang.php @@ -116,6 +116,7 @@ $lang['rss_update'] = 'تحديث تلقيم XML (ثوان)'; $lang['recent_days'] = 'مدة إبقاء أحدث التغييرات (ايام)'; $lang['rss_show_summary'] = 'تلقيم XML يظهر ملخصا في العنوان'; $lang['target____wiki'] = 'النافذة الهدف للروابط الداخلية'; +$lang['target____interwiki'] = 'النافذة الهدف للروابط الممرة interwiki'; $lang['target____extern'] = 'النافذة الهدف للروابط الخارجية'; $lang['target____media'] = 'النافذة الهدف لروابط الوسائط'; $lang['target____windows'] = 'النافذة الهدف لروابط النوافذ'; @@ -124,6 +125,7 @@ $lang['proxy____port'] = 'منفذ الوكيل'; $lang['proxy____user'] = 'اسم مستخدم الوكيل'; $lang['proxy____pass'] = 'كلمة سر الوكيل'; $lang['proxy____ssl'] = 'استخدم ssl للاتصال بالوكيل'; +$lang['proxy____except'] = 'تعبير شرطي لمقابلة العناوين التي ستتجاوز البروكسي.'; $lang['safemodehack'] = 'مكّن hack الوضع الآمن'; $lang['ftp____host'] = 'خادوم FTP ل hack الوضع الآمن'; $lang['ftp____port'] = 'منفذ FTP ل hack الوضع الآمن'; @@ -136,6 +138,7 @@ $lang['typography_o_1'] = 'استبعاد الاقتباس المفرد'; $lang['typography_o_2'] = 'تضمين علامات اقتباس مفردة (قد لا يعمل دائما)'; $lang['userewrite_o_0'] = 'لاشيء'; $lang['userewrite_o_1'] = '.htaccess'; +$lang['userewrite_o_2'] = 'دو'; $lang['deaccent_o_0'] = 'معطل'; $lang['gdlib_o_0'] = 'مكتبة GD غير متوفرة'; $lang['gdlib_o_1'] = 'الاصدار 1.x'; @@ -156,11 +159,15 @@ $lang['compression_o_0'] = 'لا شيء'; $lang['compression_o_gz'] = 'gzip'; $lang['compression_o_bz2'] = 'bz2'; $lang['xsendfile_o_0'] = 'لا تستخدم'; +$lang['xsendfile_o_1'] = 'ترويسة lighttpd مملوكة (قبل الاصدار 1.5)'; +$lang['xsendfile_o_2'] = 'ترويسة X-Sendfile قياسية'; +$lang['xsendfile_o_3'] = 'ترويسة Nginx X-Accel-Redirect مملوكة'; $lang['showuseras_o_loginname'] = 'اسم الدخول'; $lang['showuseras_o_username'] = 'اسم المستخدم الكامل'; $lang['showuseras_o_email'] = 'عنوان بريد المستخدم (مبهم تبعا لاعدادات حارس_البريد)'; $lang['showuseras_o_email_link'] = 'عنوان بريد المستخدم كـ مالتيو: رابط'; $lang['useheading_o_0'] = 'أبدا'; -$lang['useheading_o_navigation'] = 'ال'; +$lang['useheading_o_navigation'] = 'التنقل فقط'; $lang['useheading_o_content'] = 'محتوى الويكي فقط'; $lang['useheading_o_1'] = 'دائما'; +$lang['readdircache'] = 'المدة القصوى لتخزين '; diff --git a/lib/plugins/popularity/lang/ar/lang.php b/lib/plugins/popularity/lang/ar/lang.php index c0e7dc6af..b2581294a 100644 --- a/lib/plugins/popularity/lang/ar/lang.php +++ b/lib/plugins/popularity/lang/ar/lang.php @@ -7,3 +7,8 @@ */ $lang['name'] = 'رد الشعبية (قد يأخذ بعض الوقت ليحمل)'; $lang['submit'] = 'أرسل البيانات'; +$lang['autosubmit'] = 'ارسل البيانات آليا كل شهر'; +$lang['submissionFailed'] = 'تعذر إرسال البيانات بسبب الخطأ التالي:'; +$lang['submitDirectly'] = 'يمكنك إرسال البيانات يدويا بارسال النموذج التالي.'; +$lang['autosubmitError'] = 'فشلت آخر محاولة للإرسال، بسبب الخطأ التالي:'; +$lang['lastSent'] = 'أرسلت البيانات'; diff --git a/lib/plugins/popularity/lang/ar/submitted.txt b/lib/plugins/popularity/lang/ar/submitted.txt new file mode 100644 index 000000000..085e3bd98 --- /dev/null +++ b/lib/plugins/popularity/lang/ar/submitted.txt @@ -0,0 +1,3 @@ +====== رد الشعبية ====== + +أرسلت البيانات بنجاح. \ No newline at end of file From 01032c33d1c2c00e6c2f04f0bdd9b9ac0057ded6 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 9 Jan 2011 12:59:58 +0100 Subject: [PATCH 082/110] Fix FS#2131 - metaFiles returning unrelated files --- inc/pageutils.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/inc/pageutils.php b/inc/pageutils.php index 5d24c12bb..216debd9a 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -316,9 +316,8 @@ function metaFiles($id){ $name = noNS($id); $ns = getNS($id); $dir = ($ns) ? metaFN($ns,'').'/' : metaFN($ns,''); - $files = array(); - $files = glob($dir.$name.'.*'); - return $files; + $files = glob($dir.$name.'.*', GLOB_MARK); + return $files ? preg_grep('/^'.preg_quote($dir.$name, '/').'\.[^.\/]*$/u', $files) : array(); } /** From ba0267b3bcb1b5feeb707e9a92766c4a619409bb Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Wed, 12 Jan 2011 20:46:36 +0100 Subject: [PATCH 083/110] Fix metaFiles for ids that require utf-8 escaping Before this change metaFiles didn't return anything for ids where the part without the namespace needs (utf-8) filename escaping. --- inc/pageutils.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inc/pageutils.php b/inc/pageutils.php index 216debd9a..cd01dcae7 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -311,13 +311,13 @@ function metaFN($id,$ext){ * returns an array of full paths to all metafiles of a given ID * * @author Esther Brunner + * @author Michael Hamann */ function metaFiles($id){ - $name = noNS($id); - $ns = getNS($id); - $dir = ($ns) ? metaFN($ns,'').'/' : metaFN($ns,''); - $files = glob($dir.$name.'.*', GLOB_MARK); - return $files ? preg_grep('/^'.preg_quote($dir.$name, '/').'\.[^.\/]*$/u', $files) : array(); + $basename = metaFN($id, ''); + $files = glob($basename.'.*', GLOB_MARK); + // filter files like foo.bar.meta when $id == 'foo' + return $files ? preg_grep('/^'.preg_quote($basename, '/').'\.[^.\/]*$/u', $files) : array(); } /** From 4481b2a04e9fbc3dd2696f436d5c2d2a725c8386 Mon Sep 17 00:00:00 2001 From: Tobias Sarnowski Date: Tue, 11 Jan 2011 13:12:26 +0100 Subject: [PATCH 084/110] added keep-alive capabilities to the http client The DokuHTTPClient is now able to keep connections alive. This feature is enabled by default. It can be disabled with $client->setKeepAlive(false); and asked with $client->isKeepAlive();. --- inc/HTTPClient.php | 84 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 72 insertions(+), 12 deletions(-) diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 43b00034c..d46200697 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -71,6 +71,7 @@ class DokuHTTPClient extends HTTPClient { * @link http://www.splitbrain.org/go/videodb * @author Andreas Goetz * @author Andreas Gohr + * @author Tobias Sarnowski */ class HTTPClient { //set these if you like @@ -86,6 +87,7 @@ class HTTPClient { var $headers; var $debug; var $start = 0; // for timings + var $keep_alive = true; // keep alive rocks // don't set these, read on error var $error; @@ -108,6 +110,9 @@ class HTTPClient { var $proxy_ssl; //boolean set to true if your proxy needs SSL var $proxy_except; // regexp of URLs to exclude from proxy + // list of kept alive connections + var $connections = array(); + // what we use as boundary on multipart/form-data posts var $boundary = '---DokuWikiHTTPClient--4523452351'; @@ -247,7 +252,11 @@ class HTTPClient { if($uri['port']) $headers['Host'].= ':'.$uri['port']; $headers['User-Agent'] = $this->agent; $headers['Referer'] = $this->referer; - $headers['Connection'] = 'Close'; + if ($this->isKeepAlive()) { + $headers['Connection'] = 'Keep-Alive'; + } else { + $headers['Connection'] = 'Close'; + } if($method == 'POST'){ if(is_array($data)){ if($headers['Content-Type'] == 'multipart/form-data'){ @@ -273,15 +282,29 @@ class HTTPClient { // stop time $start = time(); - // open socket - $socket = @fsockopen($server,$port,$errno, $errstr, $this->timeout); - if (!$socket){ - $this->status = -100; - $this->error = "Could not connect to $server:$port\n$errstr ($errno)"; - return false; + // already connected? + $connectionId = $this->_uniqueConnectionId($server,$port); + $this->_debug('connection pool', $this->connections); + if (isset($this->connections[$connectionId])) { + $this->_debug('reusing connection', $connectionId); + $socket = $this->connections[$connectionId]; + } else { + $this->_debug('opening connection', $connectionId); + // open socket + $socket = @fsockopen($server,$port,$errno, $errstr, $this->timeout); + if (!$socket){ + $this->status = -100; + $this->error = "Could not connect to $server:$port\n$errstr ($errno)"; + return false; + } + //set non blocking + stream_set_blocking($socket,0); + + // keep alive? + if ($this->isKeepAlive()) { + $this->connections[$connectionId] = $socket; + } } - //set non blocking - stream_set_blocking($socket,0); // build request $request = "$method $request_url HTTP/".$this->http.HTTP_NL; @@ -359,6 +382,11 @@ class HTTPClient { // check server status code to follow redirect if($this->status == 301 || $this->status == 302 ){ + // close the connection because we don't handle content retrieval here + // that's the easiest way to clean up the connection + fclose($socket); + unset($this->connections[$connectionId]); + if (empty($this->resp_headers['location'])){ $this->error = 'Redirect but no Location Header found'; return false; @@ -450,9 +478,13 @@ class HTTPClient { } } - // close socket - $status = socket_get_status($socket); - fclose($socket); + if (!$this->isKeepAlive() || + (isset($this->resp_headers['connection']) && $this->resp_headers['connection'] == 'Close')) { + // close socket + $status = socket_get_status($socket); + fclose($socket); + unset($this->connections[$connectionId]); + } // decode gzip if needed if(isset($this->resp_headers['content-encoding']) && @@ -598,6 +630,34 @@ class HTTPClient { return $out; } + /** + * Returns if the keep-alive feature is enabled or not. + * + * @return bool keep-alive enabled + * @author Tobias Sarnowski + */ + function isKeepAlive() { + return $this->keep_alive; + } + + /** + * Set the keep-alive feature status. + * + * @param bool $keep_alive if keep-alive should be enabled or not + * @author Tobias Sarnowski + */ + function setKeepAlive($keep_alive) { + $this->keep_alive = $keep_alive; + } + + /** + * Generates a unique identifier for a connection. + * + * @return string unique identifier + */ + function _uniqueConnectionId($server, $port) { + return "$server:$port"; + } } //Setup VIM: ex: et ts=4 : From 1415e8b5968a264b9a2aa5bac0d77c2a898c8e81 Mon Sep 17 00:00:00 2001 From: Tobias Sarnowski Date: Tue, 11 Jan 2011 13:18:20 +0100 Subject: [PATCH 085/110] keep http connections application wide alive Using a static context for the connection pool allows connection reuse throughout the whole application without additional changes in other places. --- inc/HTTPClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index d46200697..1dbcd6be1 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -111,7 +111,7 @@ class HTTPClient { var $proxy_except; // regexp of URLs to exclude from proxy // list of kept alive connections - var $connections = array(); + static $connections = array(); // what we use as boundary on multipart/form-data posts var $boundary = '---DokuWikiHTTPClient--4523452351'; From a6bacf701037fe4798658f00854ec9c5e6ddf835 Mon Sep 17 00:00:00 2001 From: Tobias Sarnowski Date: Tue, 11 Jan 2011 15:07:46 +0100 Subject: [PATCH 086/110] do not reuse errornous http connections As soon as something goes wrong while querying a http server do not reuse the same connection again, its state is undefined. In addition, check the connection for feof() before reusing it. --- inc/HTTPClient.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 1dbcd6be1..53b344b76 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -285,10 +285,12 @@ class HTTPClient { // already connected? $connectionId = $this->_uniqueConnectionId($server,$port); $this->_debug('connection pool', $this->connections); + $socket = null; if (isset($this->connections[$connectionId])) { $this->_debug('reusing connection', $connectionId); $socket = $this->connections[$connectionId]; - } else { + } + if (is_null($socket) || feof($socket)) { $this->_debug('opening connection', $connectionId); // open socket $socket = @fsockopen($server,$port,$errno, $errstr, $this->timeout); @@ -303,6 +305,8 @@ class HTTPClient { // keep alive? if ($this->isKeepAlive()) { $this->connections[$connectionId] = $socket; + } else { + unset($this->connections[$connectionId]); } } @@ -323,6 +327,7 @@ class HTTPClient { if($ret === false){ $this->status = -100; $this->error = 'Failed writing to socket'; + unset($this->connections[$connectionId]); return false; } $written += $ret; @@ -334,10 +339,12 @@ class HTTPClient { if(time()-$start > $this->timeout){ $this->status = -100; $this->error = sprintf('Timeout while reading headers (%.3fs)',$this->_time() - $this->start); + unset($this->connections[$connectionId]); return false; } if(feof($socket)){ $this->error = 'Premature End of File (socket)'; + unset($this->connections[$connectionId]); return false; } $r_headers .= fgets($socket,1024); @@ -350,6 +357,7 @@ class HTTPClient { if($match[1] > $this->max_bodysize){ $this->error = 'Reported content length exceeds allowed response size'; if ($this->max_bodysize_abort) + unset($this->connections[$connectionId]); return false; } } @@ -357,6 +365,7 @@ class HTTPClient { // get Status if (!preg_match('/^HTTP\/(\d\.\d)\s*(\d+).*?\n/', $r_headers, $m)) { $this->error = 'Server returned bad answer'; + unset($this->connections[$connectionId]); return false; } $this->status = $m[2]; @@ -414,6 +423,7 @@ class HTTPClient { // check if headers are as expected if($this->header_regexp && !preg_match($this->header_regexp,$r_headers)){ $this->error = 'The received headers did not match the given regexp'; + unset($this->connections[$connectionId]); return false; } @@ -425,11 +435,13 @@ class HTTPClient { do { if(feof($socket)){ $this->error = 'Premature End of File (socket)'; + unset($this->connections[$connectionId]); return false; } if(time()-$start > $this->timeout){ $this->status = -100; $this->error = sprintf('Timeout while reading chunk (%.3fs)',$this->_time() - $this->start); + unset($this->connections[$connectionId]); return false; } $byte = fread($socket,1); @@ -447,6 +459,7 @@ class HTTPClient { if($this->max_bodysize && strlen($r_body) > $this->max_bodysize){ $this->error = 'Allowed response size exceeded'; if ($this->max_bodysize_abort) + unset($this->connections[$connectionId]); return false; else break; @@ -458,6 +471,7 @@ class HTTPClient { if(time()-$start > $this->timeout){ $this->status = -100; $this->error = sprintf('Timeout while reading response (%.3fs)',$this->_time() - $this->start); + unset($this->connections[$connectionId]); return false; } $r_body .= fread($socket,4096); @@ -465,6 +479,7 @@ class HTTPClient { if($this->max_bodysize && $r_size > $this->max_bodysize){ $this->error = 'Allowed response size exceeded'; if ($this->max_bodysize_abort) + unset($this->connections[$connectionId]); return false; else break; From b58bcfed1ea9c70e4103c91723a19c845b06f300 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 12 Jan 2011 20:55:16 +0100 Subject: [PATCH 087/110] removed setter/getter to match coding style since we don't use setter/getters for the other options it doesn't make sense to have them for the keep-alive function --- inc/HTTPClient.php | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 53b344b76..7e5e40ee3 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -252,7 +252,7 @@ class HTTPClient { if($uri['port']) $headers['Host'].= ':'.$uri['port']; $headers['User-Agent'] = $this->agent; $headers['Referer'] = $this->referer; - if ($this->isKeepAlive()) { + if ($this->keep_alive) { $headers['Connection'] = 'Keep-Alive'; } else { $headers['Connection'] = 'Close'; @@ -303,7 +303,7 @@ class HTTPClient { stream_set_blocking($socket,0); // keep alive? - if ($this->isKeepAlive()) { + if ($this->keep_alive) { $this->connections[$connectionId] = $socket; } else { unset($this->connections[$connectionId]); @@ -493,7 +493,7 @@ class HTTPClient { } } - if (!$this->isKeepAlive() || + if (!$this->keep_alive || (isset($this->resp_headers['connection']) && $this->resp_headers['connection'] == 'Close')) { // close socket $status = socket_get_status($socket); @@ -645,26 +645,6 @@ class HTTPClient { return $out; } - /** - * Returns if the keep-alive feature is enabled or not. - * - * @return bool keep-alive enabled - * @author Tobias Sarnowski - */ - function isKeepAlive() { - return $this->keep_alive; - } - - /** - * Set the keep-alive feature status. - * - * @param bool $keep_alive if keep-alive should be enabled or not - * @author Tobias Sarnowski - */ - function setKeepAlive($keep_alive) { - $this->keep_alive = $keep_alive; - } - /** * Generates a unique identifier for a connection. * From 299c3423aa580b305c33bbe62c29123815f5419a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 12 Jan 2011 20:56:13 +0100 Subject: [PATCH 088/110] fixed brackets --- inc/HTTPClient.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 7e5e40ee3..7011aa9ed 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -458,11 +458,12 @@ class HTTPClient { if($this->max_bodysize && strlen($r_body) > $this->max_bodysize){ $this->error = 'Allowed response size exceeded'; - if ($this->max_bodysize_abort) + if ($this->max_bodysize_abort){ unset($this->connections[$connectionId]); return false; - else + } else { break; + } } } while ($chunk_size); }else{ @@ -478,11 +479,12 @@ class HTTPClient { $r_size = strlen($r_body); if($this->max_bodysize && $r_size > $this->max_bodysize){ $this->error = 'Allowed response size exceeded'; - if ($this->max_bodysize_abort) + if ($this->max_bodysize_abort) { unset($this->connections[$connectionId]); return false; - else + } else { break; + } } if(isset($this->resp_headers['content-length']) && !isset($this->resp_headers['transfer-encoding']) && From 99fef1646aeb4e3f5f819e991e4079bce08adc75 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Wed, 12 Jan 2011 23:15:52 +0100 Subject: [PATCH 089/110] Hebrew language update --- inc/lang/he/conflict.txt | 6 +- inc/lang/he/denied.txt | 2 +- inc/lang/he/draft.txt | 4 +- inc/lang/he/edit.txt | 2 +- inc/lang/he/editrev.txt | 2 +- inc/lang/he/index.txt | 4 +- inc/lang/he/install.html | 16 +- inc/lang/he/lang.php | 330 +++++++++++++---------- inc/lang/he/mailtext.txt | 20 +- inc/lang/he/password.txt | 8 +- inc/lang/he/pwconfirm.txt | 8 +- inc/lang/he/read.txt | 2 +- inc/lang/he/register.txt | 2 +- inc/lang/he/registermail.txt | 10 +- inc/lang/he/resendpwd.txt | 4 +- inc/lang/he/subscr_digest.txt | 20 ++ inc/lang/he/subscr_single.txt | 22 ++ lib/plugins/acl/lang/he/lang.php | 1 + lib/plugins/config/lang/he/lang.php | 1 + lib/plugins/plugin/lang/he/lang.php | 1 + lib/plugins/popularity/lang/he/lang.php | 1 + lib/plugins/revert/lang/he/lang.php | 1 + lib/plugins/usermanager/lang/he/lang.php | 1 + 23 files changed, 276 insertions(+), 192 deletions(-) create mode 100644 inc/lang/he/subscr_digest.txt create mode 100644 inc/lang/he/subscr_single.txt diff --git a/inc/lang/he/conflict.txt b/inc/lang/he/conflict.txt index d27a78559..c1cccdfcf 100644 --- a/inc/lang/he/conflict.txt +++ b/inc/lang/he/conflict.txt @@ -1,6 +1,6 @@ -====== גירסה עדכנית יותר של הקובץ קיימת ====== +====== קיימת גרסה עדכנית יותר של הקובץ ====== -גירסה עדכנית יותר של המסמך קיימת. דבר זה קורה כאשר משתמש אחר שינה את המסמך בזמן שערכת אותו. +ישנה גרסה עדכנית יותר של המסמך. מצב כזה קורה כאשר משתמש אחר שינה את המסמך בזמן שערכת אותו. -מומלץ לעיין בהבדלים תחת הודעה ולאחר מכן להחליט איזו גירסה כדאי לשמור. לחיצה על הכפתור "שמור" תשמור את הגרסה שערכת. לחיצה על הכפתור "בטל" תשמור את הגרסה הקיימת. +מומלץ לעיין בהבדלים המופיעים להלן ולאחר מכן להחליט איזו גרסה כדאי לשמור. לחיצה על הכפתור "שמירה" תשמור את הגרסה שערכת. לחיצה על הכפתור "ביטול" תשמור את הגרסה הקיימת. diff --git a/inc/lang/he/denied.txt b/inc/lang/he/denied.txt index 34c8417b4..a366fc198 100644 --- a/inc/lang/he/denied.txt +++ b/inc/lang/he/denied.txt @@ -1,3 +1,3 @@ ====== הרשאה נדחתה ====== -אנו מצטערים אך אין לך הרשאות מתאימות כדי להמשיך. אולי שכחת להכנס למערכת? \ No newline at end of file +אנו מצטערים אך אין לך הרשאות מתאימות כדי להמשיך. אולי שכחת להיכנס למערכת? \ No newline at end of file diff --git a/inc/lang/he/draft.txt b/inc/lang/he/draft.txt index 22fc88d9f..b999cc187 100644 --- a/inc/lang/he/draft.txt +++ b/inc/lang/he/draft.txt @@ -1,5 +1,5 @@ -====== נמצא קובץ טיוטא ====== +====== נמצא קובץ טיוטה ====== -העריכה האחרונה שבוצעה לדף זה לא הסתימה כהלכה. DokuWiki שמר באופן אוטומטי טיוטה של העבודה ובאפשרותך להשתמש בה כדי להמשיך את העריכה. ניתן לראות מטה את המידע שנשמר מהפעם הקודמת. +העריכה האחרונה שבוצעה לדף זה לא הושלמה כראוי. DokuWiki שמר באופן אוטומטי טיוטה של העבודה ובאפשרותך להשתמש בה כדי להמשיך את העריכה. ניתן לראות להלן את הנתונים שנשמרו מהפעם הקודמת. באפשרותך לבחור ב//שחזור הטיוטה// של אותה עריכה //מחיקת הטיוטה// או //ביטול// העריכה כליל. \ No newline at end of file diff --git a/inc/lang/he/edit.txt b/inc/lang/he/edit.txt index 4d8151e9d..74b3cefeb 100644 --- a/inc/lang/he/edit.txt +++ b/inc/lang/he/edit.txt @@ -1 +1 @@ -עריכת הדף ולחיצה על הכפתור "שמור" תעדכן את תוכנו. מומלץ לעיין בדף ה[[wiki:syntax|תחביר]] כדי להכיר את כללי תחביר הויקי. נא לערוך את הדף רק אם הדבר נעשה כדי **לשפר** אותו. אם העריכה היא לצורך התנסות מומלץ לבקר ב[[playground:playground|ארגז החול]]. +עריכת הדף ולחיצה על הלחצן "שמירה" תעדכן את תוכנו. מומלץ לעיין בדף ה[[wiki:syntax|תחביר]] כדי להכיר את כללי תחביר הוויקי. נא לערוך את הדף רק אם הדבר נעשה כדי **לשפר** אותו. אם העריכה היא לצורך התנסות מומלץ לבקר ב[[playground:playground|ארגז החול]]. diff --git a/inc/lang/he/editrev.txt b/inc/lang/he/editrev.txt index a6c755cba..e33001fa3 100644 --- a/inc/lang/he/editrev.txt +++ b/inc/lang/he/editrev.txt @@ -1,2 +1,2 @@ -**הדף שנפתח הוא גרסה ישנה של המסמך!** לחיצה על הכפתור "שמור" תשחזר את המסמך לגרסה המוצגת כעת. +**הדף שנפתח הוא גרסה ישנה של המסמך!** לחיצה על הלחצן "שמירה" תשחזר את המסמך לגרסה המוצגת כעת. ---- \ No newline at end of file diff --git a/inc/lang/he/index.txt b/inc/lang/he/index.txt index 12b7a960e..4b0623f84 100644 --- a/inc/lang/he/index.txt +++ b/inc/lang/he/index.txt @@ -1,4 +1,4 @@ -====== אינדקס ====== +====== מפת אתר ====== -זהו קובץ אינדקס הנמצא מעל לכל הדפים המאורגנים ב[[ויקי:דוקיוויקי]]. +זהו קובץ מפת אתר הנמצא מעל לכל הדפים המאורגנים ב[[ויקי:דוקיוויקי]]. diff --git a/inc/lang/he/install.html b/inc/lang/he/install.html index 7831623c9..3832fb5fb 100644 --- a/inc/lang/he/install.html +++ b/inc/lang/he/install.html @@ -1,13 +1,13 @@ -

דף זה מסייע להתקנה וההגדרה הראשוניות של -Dokuwiki. מידע נוסף על מתקין זה זמין בדף +

דף זה מסייע בהליכי ההתקנה וההגדרה הראשוניים של +Dokuwiki. מידע נוסף על תכנית התקנה זו זמין בדף התיעוד שלו.

-

DokuWiki עושה שימוש בקבצים רגילים לשמירת דפי ויקי ומידע נוסף הקשור לדפים אלו (לדוגמה תמונות, רשימות חיפוש, גרסאות קודמות וכו'). -לתפקוד תקין DokuWiki חייב גישה לכתיבה לתיקיות המכילות קבצים אלו. מתקין זה אינו יכול לקבוע הרשאות לתיקיות. -פעולה זו צריכה בד"כ להתבצע ישירות משורת הפקודה או במקרה שנעשה שימוש בשרת מארח דרך FTP או מנשק הניהול של המארח (cPanell לדוגמה).

+

DokuWiki עושה שימוש בקבצים רגילים לשמירת דפי ויקי ומידע נוסף הקשור לדפים אלו (לדוגמה: תמונות, רשימות חיפוש, גרסאות קודמות וכו׳). +לצורך תפקוד תקין DokuWiki חייב גישה לכתיבה לתיקיות המכילות קבצים אלו. תכנית התקנה זו אינה יכולה להגדיר הרשאות לתיקיות. +פעולה זו צריכה בד״כ להתבצע ישירות משורת הפקודה או במקרה שנעשה שימוש בשרת מארח דרך FTP או מנשק הניהול של המארח (cPanell לדוגמה).

-

מתקין זה יגדיר את תצורת ה-ACL ב-DokuWiki שלך +

מתקין זה יגדיר את תצורת ה־ACL ב-DokuWiki שלך , זה בתורו מאפשר גישת מנהל לתפריט הניהול של DokuWiki כדי להתקין הרחבות, לנהל משתמשים, לנהל גישות לדפי ויקי ושינויים בהגדרות התצורה. -אין הוא הכרחי לתפקוד DokuWiki אך הוא יהפוך את Dokuwiki קל יותר לניהול.

+אין הוא הכרחי לתפקוד DokuWiki אך הוא יהפוך את Dokuwiki לפשוט יותר לניהול.

-

על משתמשים מנוסים או כאלו עם דרישות מיוחדות להתקנה להשתמש בקישורים אלו לפרטים בנוגע להוראות התקנה והגדרות תצורה.

+

על משתמשים מנוסים או כאלו עם דרישות מיוחדות להתקנה להשתמש בקישורים אלו לפרטים בנוגע להוראות התקנה ולהגדרות תצורה.

diff --git a/inc/lang/he/lang.php b/inc/lang/he/lang.php index a411764d2..47310d4d1 100644 --- a/inc/lang/he/lang.php +++ b/inc/lang/he/lang.php @@ -10,6 +10,7 @@ * @author Dotan Kamber * @author Moshe Kaplan * @author Yaron Yogev + * @author Yaron Shahrabani */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'rtl'; @@ -18,132 +19,153 @@ $lang['doublequoteclosing'] = '”'; $lang['singlequoteopening'] = '‘'; $lang['singlequoteclosing'] = '’'; $lang['apostrophe'] = '\''; -$lang['btn_edit'] = 'עריכה'; -$lang['btn_source'] = 'הצג את מקור הדף'; -$lang['btn_show'] = 'הצג דף'; +$lang['btn_edit'] = 'עריכת דף זה'; +$lang['btn_source'] = 'הצגת מקור הדף'; +$lang['btn_show'] = 'הצגת דף'; $lang['btn_create'] = 'יצירת דף'; -$lang['btn_search'] = 'חפש'; -$lang['btn_save'] = 'שמור'; +$lang['btn_search'] = 'חיפוש'; +$lang['btn_save'] = 'שמירה'; $lang['btn_preview'] = 'תצוגה מקדימה'; -$lang['btn_top'] = 'חזור למעלה'; -$lang['btn_newer'] = '<< יותר חדש'; -$lang['btn_older'] = 'פחות חדש >>'; +$lang['btn_top'] = 'חזרה למעלה'; +$lang['btn_newer'] = '<< חדש יותר'; +$lang['btn_older'] = 'פחות חדש >>'; $lang['btn_revs'] = 'גרסאות קודמות'; $lang['btn_recent'] = 'שינויים אחרונים'; -$lang['btn_upload'] = 'העלה'; -$lang['btn_cancel'] = 'בטל'; -$lang['btn_index'] = 'אינדקס'; +$lang['btn_upload'] = 'העלאה'; +$lang['btn_cancel'] = 'ביטול'; +$lang['btn_index'] = 'מפת האתר'; $lang['btn_secedit'] = 'עריכה'; $lang['btn_login'] = 'כניסה'; $lang['btn_logout'] = 'יציאה'; -$lang['btn_admin'] = 'מנהל'; -$lang['btn_update'] = 'עדכן'; -$lang['btn_delete'] = 'מחק'; -$lang['btn_back'] = 'חזור'; +$lang['btn_admin'] = 'ניהול'; +$lang['btn_update'] = 'עדכון'; +$lang['btn_delete'] = 'מחיקה'; +$lang['btn_back'] = 'חזרה'; $lang['btn_backlink'] = 'קישורים לכאן'; -$lang['btn_backtomedia'] = 'לחזור לבחירת קובץ מדיה'; -$lang['btn_subscribe'] = 'עקוב אחרי שינוים'; -$lang['btn_unsubscribe'] = 'הפסק לעקוב'; -$lang['btn_subscribens'] = 'הרשמה לשינויים במרחב השם'; -$lang['btn_unsubscribens'] = 'הסרת הרשמה לשינויים במחב השם'; -$lang['btn_profile'] = 'עדכן פרופיל'; +$lang['btn_backtomedia'] = 'חזרה לבחירת קובץ מדיה'; +$lang['btn_subscribe'] = 'מעקב אחרי שינוים'; +$lang['btn_profile'] = 'עדכון הפרופיל'; $lang['btn_reset'] = 'איפוס'; -$lang['btn_resendpwd'] = 'שלח סיסמה חדשה'; +$lang['btn_resendpwd'] = 'שליחת ססמה חדשה'; $lang['btn_draft'] = 'עריכת טיוטה'; $lang['btn_recover'] = 'שחזור טיוטה'; $lang['btn_draftdel'] = 'מחיקת טיוטה'; -$lang['btn_revert'] = 'שחזר'; -$lang['loggedinas'] = 'רשום כ-'; +$lang['btn_revert'] = 'שחזור'; +$lang['loggedinas'] = 'נכנסת בשם'; $lang['user'] = 'שם משתמש'; -$lang['pass'] = 'סיסמה'; -$lang['newpass'] = 'סיסמה חדשה'; -$lang['oldpass'] = 'אשר את הסיסמה הנוכחית'; -$lang['passchk'] = 'שוב'; -$lang['remember'] = 'זכור אותי'; +$lang['pass'] = 'ססמה'; +$lang['newpass'] = 'ססמה חדשה'; +$lang['oldpass'] = 'אישור הססמה הנוכחית'; +$lang['passchk'] = 'פעם נוספת'; +$lang['remember'] = 'שמירת הפרטים שלי'; $lang['fullname'] = 'שם מלא'; -$lang['email'] = 'דוא"ל'; +$lang['email'] = 'דוא״ל'; $lang['register'] = 'הרשמה'; -$lang['profile'] = 'פרופיל'; -$lang['badlogin'] = 'סליחה, שם המשתמש או הסיסמה שגויים'; -$lang['minoredit'] = 'שינוים מינוריים'; -$lang['draftdate'] = 'טיוטה נשמרה ב-'; +$lang['profile'] = 'פרופיל המשתמש'; +$lang['badlogin'] = 'שם המשתמש או הססמה שגויים, עמך הסליחה'; +$lang['minoredit'] = 'שינוים מזעריים'; +$lang['draftdate'] = 'הטיוטה נשמרה אוטומטית ב־'; $lang['nosecedit'] = 'הדף השתנה בינתיים, הקטע שערכת אינו מעודכן - העמוד כולו נטען במקום זאת.'; -$lang['regmissing'] = 'סליחה, עליך למלא את כל השדות'; -$lang['reguexists'] = 'סליחה, משתמש בשם זה כבר נרשם'; -$lang['regsuccess'] = 'הרשמה הצליחה, המשתמש נרשם והודעה נשלחה בדואר'; -$lang['regsuccess2'] = 'הרשמה הצליחה, המשתמש נרשם.'; -$lang['regmailfail'] = 'שליחת הודעת הדואר כשלה, נא ליצור קשר עם מנהל האתר'; -$lang['regbadmail'] = 'כתובת דואר כנראה לא תקפה, אם לא כך היא יש ליצור קשר עם מנהל האתר'; -$lang['regbadpass'] = 'שתי הסיסמות הן לא זהות, נא לנסות שוב'; -$lang['regpwmail'] = 'סיסמת הדוקוויקי שלך'; -$lang['reghere'] = 'עדיין ללא שם-משתמש? ההרשמה כאן'; +$lang['regmissing'] = 'עליך למלא את כל השדות, עמך הסליחה.'; +$lang['reguexists'] = 'משתמש בשם זה כבר נרשם, עמך הסליחה.'; +$lang['regsuccess'] = 'ההרשמה הצליחה, המשתמש נרשם והודעה נשלחה בדוא״ל.'; +$lang['regsuccess2'] = 'ההרשמה הצליחה, המשתמש נוצר.'; +$lang['regmailfail'] = 'שליחת הודעת הדוא״ל כשלה, נא ליצור קשר עם מנהל האתר!'; +$lang['regbadmail'] = 'יתכן כי כתובת הדוא״ל אינה תקפה, אם לא כך הדבר ליצור קשר עם מנהל האתר'; +$lang['regbadpass'] = 'שתי הססמאות אינן זהות זו לזו, נא לנסות שוב.'; +$lang['regpwmail'] = 'ססמת הדוקוויקי שלך'; +$lang['reghere'] = 'עדיין אין לך חשבון? ההרשמה כאן'; $lang['profna'] = 'בוויקי הזה לא ניתן לשנות פרופיל'; -$lang['profnochange'] = 'אין שינוים, פרופיל לא עודכן'; -$lang['profnoempty'] = 'שם וכתובת דוא"ל לא יכולים להיות ריקים'; -$lang['profchanged'] = 'פרופיל עודכן בהצלחה'; -$lang['pwdforget'] = 'שכחת סיסמה? קבל חדשה'; -$lang['resendna'] = 'הוויקי הזה לא תומך בחידוש סיסמה'; -$lang['resendpwd'] = 'שלח סיסמה חדשה עבור'; -$lang['resendpwdmissing'] = 'סליחה, עליך למלא את כל השדות'; -$lang['resendpwdnouser'] = 'סליחה, משתמש בשם זה לא נמצא'; -$lang['resendpwdbadauth'] = 'סליחה, קוד אימות זה אינו תקף. יש לודא כי נעשה שימוש במלוא קישור האימות.'; -$lang['resendpwdconfirm'] = 'קישור אימות נשלח בדוא"ל.'; -$lang['resendpwdsuccess'] = 'סיסמה חדשה נשלחה בדואר'; -$lang['license'] = 'למעט מקרים בהם צוין אחרת, התוכן בוויקי זה זמין לפי הרשיון הבא:'; -$lang['licenseok'] = 'שים לב: עריכת דף זה מהווה הסכמה מצידך להצגת התוכן שהוספת לפי הרשיון הבא:'; -$lang['searchmedia'] = 'חפש שם קובץ:'; -$lang['txt_upload'] = 'בחר קובץ להעלות'; -$lang['txt_filename'] = 'הכנס שם לוויקי (בחירה)'; -$lang['txt_overwrt'] = 'לכתוב במקום קובץ קיים'; +$lang['profnochange'] = 'אין שינויים, הפרופיל לא עודכן'; +$lang['profnoempty'] = 'השם וכתובת הדוא״ל לא יכולים להיות ריקים'; +$lang['profchanged'] = 'הפרופיל עודכן בהצלחה'; +$lang['pwdforget'] = 'שכחת את הססמה שלך? ניתן לקבל חדשה'; +$lang['resendna'] = 'הוויקי הזה אינו תומך בחידוש ססמה'; +$lang['resendpwd'] = 'שליחת ססמה חדשה עבור'; +$lang['resendpwdmissing'] = 'עליך למלא את כל השדות, עמך הסליחה.'; +$lang['resendpwdnouser'] = 'משתמש בשם זה לא נמצא במסד הנתונים, עמך הסליחה.'; +$lang['resendpwdbadauth'] = 'קוד אימות זה אינו תקף. יש לוודא כי נעשה שימוש בקישור האימות המלא, עמך הסליחה.'; +$lang['resendpwdconfirm'] = 'נשלח קישור לאימות נשלח בדוא״ל.'; +$lang['resendpwdsuccess'] = 'נשלחה ססמה חדשה בדוא״ל'; +$lang['license'] = 'למעט מקרים בהם צוין אחרת, התוכן בוויקי זה זמין לפי הרישיון הבא:'; +$lang['licenseok'] = 'נא לשים לב: עריכת דף זה מהווה הסכמה מצדך להצגת התוכן שהוספת בהתאם הרישיון הבא:'; +$lang['searchmedia'] = 'חיפוש שם קובץ:'; +$lang['searchmedia_in'] = 'חיפוש תחת %s'; +$lang['txt_upload'] = 'בחירת קובץ להעלות'; +$lang['txt_filename'] = 'העלאה בשם (נתון לבחירה)'; +$lang['txt_overwrt'] = 'שכתוב על קובץ קיים'; $lang['lockedby'] = 'נעול על ידי'; -$lang['lockexpire'] = 'נעילה פגה'; -$lang['willexpire'] = 'נעילה תחלוף עוד זמן קצר. \nלמניעת התנגשויות יש להשתמש בכפתור הרענון מטה כדי לאתחל את הנעילה שנית'; -$lang['js']['notsavedyet'] = "קיימים שינויים שטרם נשמרו ואשר יאבדו \n האם להמשיך?"; -$lang['rssfailed'] = 'כשל ב-RSS'; -$lang['nothingfound'] = 'לא נמצאו תוצאות'; -$lang['mediaselect'] = 'בחירת קובץ מדיה'; -$lang['fileupload'] = 'העלאת קובץ מדיה'; -$lang['uploadsucc'] = 'העלאת הקובץ בוצעה בהצלחה'; -$lang['uploadfail'] = 'קרתה שגיאה בעת העלאת הקובץ. תיתכן ובעייה זו נוצרה עקב הרשאות שגיות.'; -$lang['uploadwrong'] = 'העלאה לא אושרה. קבצים בסיומת זו אסורים'; -$lang['uploadexist'] = 'הקובץ כבר קיים. פעולה בוטלה'; -$lang['uploadbadcontent'] = 'התוכן שהועלה לא תאם את הסיומת %s של הקובץ.'; -$lang['uploadspam'] = 'ההעלאה נחסמה על ידי הרשימה השחורה של הספאם.'; -$lang['uploadxss'] = 'ההעלאה נחסמה בשל חשד לתוכן זדוני.'; -$lang['uploadsize'] = 'הקובץ שהועלה היה גדול מדי. (מקסימום %s)'; -$lang['deletesucc'] = 'קובץ %s נמחק'; -$lang['deletefail'] = 'לא יכולתי למחוק "%s" -- בדקו הרשאות'; -$lang['mediainuse'] = 'קובץ "%s" לא נמחק - הוא עדיין בשימוש'; -$lang['namespaces'] = 'שמות מתחם'; -$lang['mediafiles'] = 'קבצים זמינים ב-'; -$lang['js']['searchmedia'] = 'חיפוש קבצים'; -$lang['js']['keepopen'] = 'השאר חלון פתוח בבחירה'; -$lang['js']['hidedetails'] = 'הסתר פרטים'; -$lang['js']['nosmblinks'] = ':( קישור למערכת קבצים של חלונות פועל רק בדפדפן אינטרנט אקספלורר. - זה בסדר, אין צורך לעבור. אפשר להעתיק ולהדביק את הקישור'; +$lang['lockexpire'] = 'הנעילה פגה'; +$lang['willexpire'] = 'הנעילה תחלוף עוד זמן קצר. \nלמניעת התנגשויות יש להשתמש בכפתור הרענון מטה כדי לאפס את מד משך הנעילה.'; +$lang['js']['notsavedyet'] = 'שינויים שלא נשמרו ילכו לאיבוד.'; +$lang['js']['searchmedia'] = 'חיפוש אחר קבצים'; +$lang['js']['keepopen'] = 'השארת חלון פתוח על הבחירה'; +$lang['js']['hidedetails'] = 'הסתרת פרטים'; +$lang['js']['mediatitle'] = 'הגדרות הקישור'; +$lang['js']['mediadisplay'] = 'סוג הקישור'; +$lang['js']['mediaalign'] = 'יישור'; +$lang['js']['mediasize'] = 'גודל התמונה'; +$lang['js']['mediatarget'] = 'יעד הקישור'; +$lang['js']['mediaclose'] = 'סגירה'; +$lang['js']['mediainsert'] = 'הוספה'; +$lang['js']['mediadisplayimg'] = 'הצגת התמונה.'; +$lang['js']['mediadisplaylnk'] = 'הצגת הקישור בלבד.'; +$lang['js']['mediasmall'] = 'גרסה קטנה'; +$lang['js']['mediamedium'] = 'גרסה בינונית'; +$lang['js']['medialarge'] = 'גרסה גדולה'; +$lang['js']['mediaoriginal'] = 'הגרסה המקורית'; +$lang['js']['medialnk'] = 'קישור לעמוד הפרטים'; +$lang['js']['mediadirect'] = 'הקישור הישיר למקור'; +$lang['js']['medianolnk'] = 'אין קישור'; +$lang['js']['medianolink'] = 'אין לקשר לתמונה'; +$lang['js']['medialeft'] = 'יישור התמונה לשמאל.'; +$lang['js']['mediaright'] = 'יישור התמונה לימין.'; +$lang['js']['mediacenter'] = 'מרכוז התמונה.'; +$lang['js']['medianoalign'] = 'לא להשתמש ביישור.'; +$lang['js']['nosmblinks'] = 'קישור לכונני שיתוף של Windows עובד רק באמצעות Microsoft Internet Explorer. +עדיין ניתן להעתיק ולהדביק את הקישור.'; $lang['js']['linkwiz'] = 'אשף הקישורים'; -$lang['js']['linkto'] = 'קשר אל:'; +$lang['js']['linkto'] = 'קישור אל:'; $lang['js']['del_confirm'] = 'באמת למחוק?'; -$lang['js']['mu_btn'] = 'העלאת קבצים מרובים'; -$lang['mediausage'] = 'השתמש בתחביר הבא להתיחסות אל קובץ זה:'; -$lang['mediaview'] = 'הצג את הקובץ המקורי'; +$lang['js']['mu_btn'] = 'העלאת מספר קבצים יחד'; +$lang['rssfailed'] = 'אירע כשל בעת קבלת הזנה זו:'; +$lang['nothingfound'] = 'לא נמצאו תוצאות.'; +$lang['mediaselect'] = 'קובצי מדיה'; +$lang['fileupload'] = 'העלאת קובצי מדיה'; +$lang['uploadsucc'] = 'ההעלאה הושלמה בהצלחה'; +$lang['uploadfail'] = 'אירעה שגיאה בעת העלאת הקובץ. היתכן שתקלה זו נוצרה עקב הרשאות שגיות?'; +$lang['uploadwrong'] = 'ההעלאה לא אושרה. קבצים בסיומת זו אסורים!'; +$lang['uploadexist'] = 'הקובץ כבר קיים. הפעולה בוטלה.'; +$lang['uploadbadcontent'] = 'התוכן שהועלה לא תאם את הסיומת %s של הקובץ.'; +$lang['uploadspam'] = 'ההעלאה נחסמה על ידי רשימת חסימת הספאם.'; +$lang['uploadxss'] = 'ההעלאה נחסמה בשל חשד לתוכן זדוני.'; +$lang['uploadsize'] = 'הקובץ שהועלה היה גדול מדי. (%s לכל היותר)'; +$lang['deletesucc'] = 'הקובץ %s נמחק.'; +$lang['deletefail'] = 'לא ניתן למחוק את "%s" -- נא לבדוק את ההרשאות.'; +$lang['mediainuse'] = 'הקובץ "%s" לא נמחק - הוא עדיין בשימוש.'; +$lang['namespaces'] = 'שמות מתחם'; +$lang['mediafiles'] = 'קבצים זמינים תחת'; +$lang['accessdenied'] = 'אין לך הרשאה לצפות בדף זה.'; +$lang['mediausage'] = 'יש להשתמש בתחביר הבא כדי להפנות לקובץ זה:'; +$lang['mediaview'] = 'הצגת הקובץ המקורי'; $lang['mediaroot'] = 'root'; -$lang['mediaupload'] = 'כאן ניתן להעלות קובץ למרחב השמות הנוכחי. ליצירת תתי-מרחבי שמות צרפם ב-"העלה" לתחילת שם הקובץ מופרדים בפסיקים'; -$lang['mediaextchange'] = 'סיומת הקובץ השתנתה מ-.%s ל-.%s!'; -$lang['reference'] = 'קישורים ל'; +$lang['mediaupload'] = 'כאן ניתן להעלות קובץ למרחב השם הנוכחי. ליצירת תת־מרחבי שם יש לצרף אותם לתחילת שם הקובץ, מופרדים בפסיקים, בשם הקובץ תחת "העלאה בתור".'; +$lang['mediaextchange'] = 'סיומת הקובץ השתנתה מ־‎.%s ל־‎.%s!'; +$lang['reference'] = 'הפניות אל'; $lang['ref_inuse'] = 'לא ניתן למחוק קובץ זה, כיוון שהדפים הבאים עדיין משתמשים בו:'; -$lang['ref_hidden'] = 'יש קישורים לדפים ללא הרשאת קריאה'; -$lang['hits'] = 'פגיעות'; -$lang['quickhits'] = 'דפים שנמצאו'; +$lang['ref_hidden'] = 'חלק מההפניות נמצאות בדפים שאין לך הרשאות לקרוא אותם'; +$lang['hits'] = 'ביקורים'; +$lang['quickhits'] = 'שמות דפים שנמצאו'; $lang['toc'] = 'תוכן עניינים'; -$lang['current'] = 'גירסה נוכחית'; +$lang['current'] = 'הגרסה הנוכחית'; $lang['yours'] = 'הגרסה שלך'; -$lang['diff'] = 'הצג שינוים מגרסה זו ועד הנוכחית'; +$lang['diff'] = 'הצגת שינוים מגרסה זו ועד הנוכחית'; $lang['diff2'] = 'הצגת הבדלים בין הגרסאות שנבחרו'; +$lang['difflink'] = 'קישור לתצוגה השוואה זו'; $lang['line'] = 'שורה'; $lang['breadcrumb'] = 'ביקורים אחרונים'; -$lang['youarehere'] = 'אתה נמצא כאן'; -$lang['lastmod'] = 'שונה לאחרונה ב'; +$lang['youarehere'] = 'זהו מיקומך'; +$lang['lastmod'] = 'מועד השינוי האחרון'; $lang['by'] = 'על ידי'; $lang['deleted'] = 'נמחק'; $lang['created'] = 'נוצר'; @@ -151,9 +173,10 @@ $lang['restored'] = 'שוחזר'; $lang['external_edit'] = 'עריכה חיצונית'; $lang['summary'] = 'תקציר העריכה'; $lang['noflash'] = 'תוסף פלאש לדפדפן נדרש כדי להציג תוכן זה.'; -$lang['download'] = 'הורד מקטע'; +$lang['download'] = 'הורדת מקטע'; $lang['mail_newpage'] = 'דף נוסף:'; $lang['mail_changed'] = 'דף שונה:'; +$lang['mail_subscribe_list'] = 'דפים שהשתנו במרחב השם:'; $lang['mail_new_user'] = 'משתמש חדש:'; $lang['mail_upload'] = 'קובץ הועלה:'; $lang['qb_bold'] = 'טקסט מודגש'; @@ -167,7 +190,7 @@ $lang['qb_h3'] = 'כותרת רמה 3'; $lang['qb_h4'] = 'כותרת רמה 4'; $lang['qb_h5'] = 'כותרת רמה 5'; $lang['qb_h'] = 'כותרת'; -$lang['qb_hs'] = 'בחירת כותרת'; +$lang['qb_hs'] = 'כותרת נבחרת'; $lang['qb_hplus'] = 'כותרת ברמה גבוהה יותר'; $lang['qb_hminus'] = 'כותרת ברמה נמוכה יותר'; $lang['qb_hequal'] = 'כותרת באותה רמה'; @@ -175,73 +198,85 @@ $lang['qb_link'] = 'קישור פנימי'; $lang['qb_extlink'] = 'קישור חיצוני'; $lang['qb_hr'] = 'קו אופקי'; $lang['qb_ol'] = 'איבר ברשימה ממוספרת'; -$lang['qb_ul'] = 'אבר ברשימה לא ממוספרת'; -$lang['qb_media'] = 'תמונות או קובץ אחר'; -$lang['qb_sig'] = 'הזנת חתימה'; -$lang['qb_smileys'] = 'פרצופונים'; -$lang['qb_chars'] = 'סימנים מיוחדים'; -$lang['upperns'] = 'עבור למרחב השם שברמה שמעל הנוכחית'; -$lang['admin_register'] = 'להוסיף משתמש חדש'; -$lang['metaedit'] = 'ערוך נתונים'; -$lang['metasaveerr'] = 'כשל בשמירת נתונים'; -$lang['metasaveok'] = 'נתונים נשמרו'; -$lang['img_backto'] = 'הזור ל'; -$lang['img_title'] = 'כותרת'; -$lang['img_caption'] = 'תיאור'; +$lang['qb_ul'] = 'איבר ברשימה לא ממוספרת'; +$lang['qb_media'] = 'תמונות וקבצים אחרים'; +$lang['qb_sig'] = 'הוספת חתימה'; +$lang['qb_smileys'] = 'חייכנים'; +$lang['qb_chars'] = 'תווים מיוחדים'; +$lang['upperns'] = 'מעבר למרחב השם שברמה שמעל הנוכחית'; +$lang['admin_register'] = 'הוספת משתמש חדש'; +$lang['metaedit'] = 'עריכת נתוני העל'; +$lang['metasaveerr'] = 'אירע כשל בשמירת נתוני העל'; +$lang['metasaveok'] = 'נתוני העל נשמרו'; +$lang['img_backto'] = 'חזרה אל'; +$lang['img_title'] = 'שם'; +$lang['img_caption'] = 'כותרת'; $lang['img_date'] = 'תאריך'; $lang['img_fname'] = 'שם הקובץ'; $lang['img_fsize'] = 'גודל'; $lang['img_artist'] = 'צלם'; -$lang['img_copyr'] = 'זכויות'; -$lang['img_format'] = 'פורמט'; +$lang['img_copyr'] = 'זכויות יוצרים'; +$lang['img_format'] = 'מבנה'; $lang['img_camera'] = 'מצלמה'; $lang['img_keywords'] = 'מילות מפתח'; -$lang['subscribe_success'] = '%s נוסף לרשימת המכותבים עבור %s'; -$lang['subscribe_error'] = 'שגיאה בהוספת %s לרשימת המכותבים עבור %s'; -$lang['subscribe_noaddress'] = 'אין כתובת המשויכת לרישום שלך ולכן אין באפשרותך להצטרף לרשימת המכותבים'; -$lang['unsubscribe_success'] = '%s הוסר מרשימת המכותבים עבור %s'; -$lang['unsubscribe_error'] = 'שגיאה בהסרת %s מרשימת המכותבים עבור %s'; -$lang['authmodfailed'] = 'תצורת אימות משתמשים גרועה. נא לדווח למנהל הויקי.'; -$lang['authtempfail'] = 'אימות משתמשים אינו זמין כרגע. אם מצב זה נמשך נא להודיע למנהל הויקי.'; +$lang['subscr_subscribe_success'] = '%s נוסף לרשימת המינויים לדף %s'; +$lang['subscr_subscribe_error'] = 'אירעה שגיאה בהוספת %s לרשימת המינויים לדף %s'; +$lang['subscr_subscribe_noaddress'] = 'אין כתובת המשויכת עם הכניסה שלך, נא ניתן להוסיף אותך לרשימת המינויים'; +$lang['subscr_unsubscribe_success'] = 'המשתמש %s הוסר מרשימת המינויים לדף %s'; +$lang['subscr_unsubscribe_error'] = 'אירעה שגיאה בהסרת %s מרשימת המינויים לדף %s'; +$lang['subscr_already_subscribed'] = 'המשתמש %s כבר מנוי לדף %s'; +$lang['subscr_not_subscribed'] = 'המשתמש %s איננו רשום לדף %s'; +$lang['subscr_m_not_subscribed'] = 'המשתמש שלך אינו רשום, נכון לעכשיו, לדף הנוכחי או למרחב השם.'; +$lang['subscr_m_new_header'] = 'הוספת מינוי'; +$lang['subscr_m_current_header'] = 'המינויים הנוכחיים'; +$lang['subscr_m_unsubscribe'] = 'ביטול המינוי'; +$lang['subscr_m_subscribe'] = 'מינוי'; +$lang['subscr_m_receive'] = 'קבלת'; +$lang['subscr_style_every'] = 'דוא״ל עם כל שינוי'; +$lang['subscr_style_digest'] = 'הודעת דוא״ל המציגה את כל השינויים בכל עמוד (בכל %.2f ימים)'; +$lang['subscr_style_list'] = 'רשימת השינויים בדפים מאז הודעת הדוא״ל האחרונה (בכל %.2f ימים)'; +$lang['authmodfailed'] = 'תצורת אימות המשתמשים אינה תקינה. נא ליידע את מנהל הוויקי.'; +$lang['authtempfail'] = 'אימות משתמשים אינו זמין כרגע. אם מצב זה נמשך נא ליידע את מנהל הוויקי.'; $lang['i_chooselang'] = 'נא לבחור שפה'; -$lang['i_installer'] = 'DokuWiki Installer'; -$lang['i_wikiname'] = 'שם הויקי'; -$lang['i_enableacl'] = 'אפשר ACL (מומלץ)'; -$lang['i_superuser'] = 'משתמש-על'; -$lang['i_problems'] = 'המתקין זיהה מספר בעיות המצוינות מטה. אין באפשרותך להמשיך לפני תיקונן.'; -$lang['i_modified'] = 'משיקולי אבטחה תסריט זה יעבוד אך ורק עם התקנת DokuWiki חדשה שלא עברה כל שינוי. - עליך לחלץ שנית את הקבצים מהחבילה שהורדה או להעזר בדף +$lang['i_installer'] = 'תכנית ההתקנה של DokuWiki'; +$lang['i_wikiname'] = 'שם הוויקי'; +$lang['i_enableacl'] = 'הפעלת ACL (מומלץ)'; +$lang['i_superuser'] = 'משתמש־על'; +$lang['i_problems'] = 'תכנית ההתקנה זיהתה מספר בעיות המפורטות להלן. אין באפשרותך להמשיך לפני תיקונן.'; +$lang['i_modified'] = 'משיקולי אבטחה סקריפט זה יעבוד אך ורק עם התקנת DokuWiki חדשה שלא עברה כל שינוי. + עליך לחלץ שנית את הקבצים מהחבילה שהורדה או להיעזר בדף Dokuwiki installation instructions'; -$lang['i_funcna'] = 'פונקצית ה-PHP %s אינה זמינה. יתכן כי מארח האתר חסם אותה מסיבה כלשהי?'; -$lang['i_phpver'] = 'גרסת ה-PHP שלך %s נמוכה מהדרוש. עליך לשדרג את התקנת ה-PHP'; -$lang['i_permfail'] = '%s אינה ברת כתיבה על ידי DokuWiki. עליך לשנות הרשאות ספריה זו!'; +$lang['i_funcna'] = 'פונקציית ה-PHP‏ %s אינה זמינה. יתכן כי מארח האתר חסם אותה מסיבה כלשהי?'; +$lang['i_phpver'] = 'גרסת ה־PHP שלך %s נמוכה מהדרוש. עליך לשדרג את התקנת ה־PHP שלך.'; +$lang['i_permfail'] = '%s אינה ניתנת לכתיבה על ידי DokuWiki. עליך לשנות הרשאות תיקייה זו!'; $lang['i_confexists'] = '%s כבר קיים'; -$lang['i_writeerr'] = 'אין אפשרות ליצור את %s. נא לבדוק את הרשאות הקובץ/ספריה וליצור את הקובץ ידנית.'; -$lang['i_badhash'] = 'קובץ Dokuwiki.php לא מזוהה או שעבר שינויים (hash=%s)'; -$lang['i_badval'] = '%s - ערך לא חוקי או ריק'; -$lang['i_success'] = 'ההגדרה הסתימה בהצלחה. באפשרותך למחוק עתה את הקובץ install.php ולהמשיך אל DokuWiki החדש שלך.'; -$lang['i_failure'] = 'מספר שגיאות ארעו בעת כתיבת קבצי התצורה. ייתכן כי יהיה צורך לתקנם ידנית לפני שניתן יהיה להשתמש בDokuWiki החדש שלך.'; -$lang['i_policy'] = 'מדיניות ACL תחילית'; +$lang['i_writeerr'] = 'אין אפשרות ליצור את %s. נא לבדוק את הרשאות הקובץ/תיקייה וליצור את הקובץ ידנית.'; +$lang['i_badhash'] = 'הקובץ Dokuwiki.php אינו מזוהה או שעבר שינויים (hash=%s)'; +$lang['i_badval'] = '%s - הערך אינו חוקי או ריק'; +$lang['i_success'] = 'תהליך ההגדרה הסתיים בהצלחה. כעת ניתן למחוק את הקובץ install.php ולהמשיך אל ה־DokuWiki החדש שלך.'; +$lang['i_failure'] = 'מספר שגיאות אירעו בעת כתיבת קובצי התצורה. יתכן כי יהיה צורך לתקנם ידנית לפני שניתן יהיה להשתמש ב־DokuWiki החדש שלך.'; +$lang['i_policy'] = 'מדיניות ACL התחלתית'; $lang['i_pol0'] = 'ויקי פתוח (קריאה, כתיבה והעלאה לכולם)'; $lang['i_pol1'] = ' ויקי ציבורי (קריאה לכולם, כתיבה והעלאה למשתמשים רשומים)'; $lang['i_pol2'] = 'ויקי סגור (קריאה, כתיבה והעלאה למשתמשים רשומים בלבד)'; -$lang['i_retry'] = 'נסיון נוסף'; -$lang['mu_intro'] = 'כאן תוכל להעלות קבצים מרובים. לחץ על כפתור החיפוש להוסיף אותם למחסנית. לחץ על העלאה לסיום.'; -$lang['mu_gridname'] = 'שם קובץ'; +$lang['i_retry'] = 'ניסיון נוסף'; +$lang['i_license'] = 'נא לבחור את הרישיון שיחול על התוכן שבוויקי שלך:'; +$lang['mu_intro'] = 'דרך כאן ניתן להעלות מספר קבצים בבת אחת. יש ללחוץ על לחצן החיפוש להוסיף אותם למחסנית. ניתן ללחוץ על העלאה לסיום.'; +$lang['mu_gridname'] = 'שם הקובץ'; $lang['mu_gridsize'] = 'גודל'; -$lang['mu_gridstat'] = 'סטאטןס'; +$lang['mu_gridstat'] = 'מצב'; $lang['mu_namespace'] = 'מרחב שם'; $lang['mu_browse'] = 'חיפוש'; $lang['mu_toobig'] = 'גדול מדי'; -$lang['mu_ready'] = 'מוכן להעלאה'; -$lang['mu_done'] = 'סיים'; +$lang['mu_ready'] = 'בהמתנה להעלאה'; +$lang['mu_done'] = 'הסתיים'; $lang['mu_fail'] = 'נכשל'; -$lang['mu_authfail'] = 'תקוף נעילת עריכה פג'; +$lang['mu_authfail'] = 'תוקף ההפעלה פג'; $lang['mu_progress'] = '@PCT@% הועלה'; $lang['mu_filetypes'] = 'סוגי קבצים מורשים'; $lang['mu_info'] = 'הקבצים הועלו'; $lang['mu_lasterr'] = 'שגיאה אחרונה:'; -$lang['recent_global'] = 'אתה צופה כעת בשינויים בתוך מרחב השם %s. אתה יכול גם לצפות בשינויים האחרונים של כל הוויקי .'; +$lang['recent_global'] = 'נכון לעכשיו מתנהל על ידיך מעקב אחר מרחב השם %s. כמו כן, באפשרותך לצפות בשינויים האחרונים בוויקי כולו.'; $lang['years'] = 'לפני %d שנים'; $lang['months'] = 'לפני %d חודשים'; $lang['weeks'] = 'לפני %d שבועות'; @@ -249,3 +284,4 @@ $lang['days'] = 'לפני %d ימים'; $lang['hours'] = 'לפני %d שעות'; $lang['minutes'] = 'לפני %d דקות'; $lang['seconds'] = 'לפני %d שניות'; +$lang['wordblock'] = 'השינויים שלך לא נשמרו כיוון שהם מכילים טקסט חסום (ספאם).'; diff --git a/inc/lang/he/mailtext.txt b/inc/lang/he/mailtext.txt index d7990b2b3..222ee1b6d 100644 --- a/inc/lang/he/mailtext.txt +++ b/inc/lang/he/mailtext.txt @@ -1,17 +1,17 @@ -דף בDokuWiki נוסף או שונה. הנה הפרטים: +דף בDokuWiki נוסף או שונה. להלן הפרטים: -Date : @DATE@ -Browser : @BROWSER@ -IP-Address : @IPADDRESS@ -Hostname : @HOSTNAME@ -Old Revision: @OLDPAGE@ -New Revision: @NEWPAGE@ -Edit Summary: @SUMMARY@ -User : @USER@ +תאריך : @DATE@ +דפדפן : @BROWSER@ +כתובת ה־IP‏ : @IPADDRESS@ +שם המארח : @HOSTNAME@ +המהדורה הישנה: @OLDPAGE@ +המהדורה החדשה: @NEWPAGE@ +תקציר העריכה: @SUMMARY@ +משתמש : @USER@ @DIFF@ -- -דף זה נוצר ע"י DokuWiki ב- +דף זה נוצר ע״י ה־DokuWiki הזמין בכתובת @DOKUWIKIURL@ diff --git a/inc/lang/he/password.txt b/inc/lang/he/password.txt index 29742ebda..745c5cb5c 100644 --- a/inc/lang/he/password.txt +++ b/inc/lang/he/password.txt @@ -1,10 +1,10 @@ שלום @FULLNAME@! -הנה נתוני המשתמש שלך עבור @TITLE@ ב- @DOKUWIKIURL@ +הנה נתוני המשתמש שלך עבור @TITLE@ ב־@DOKUWIKIURL@ -כניסה : @LOGIN@ -סיסמה : @PASSWORD@ +שם כניסה : @LOGIN@ +ססמה : @PASSWORD@ -- -מכתב זה נוצר על ידי דוקוויקי ב- +מכתב זה נוצר על ידי ה־DokuWiki הזמין בכתובת @DOKUWIKIURL@ \ No newline at end of file diff --git a/inc/lang/he/pwconfirm.txt b/inc/lang/he/pwconfirm.txt index 255195c7f..7dc46c340 100644 --- a/inc/lang/he/pwconfirm.txt +++ b/inc/lang/he/pwconfirm.txt @@ -1,13 +1,13 @@ שלום @FULLNAME@! -מישהו ביקש סיסמה חדשה עבור הכניסה שלך ל-@TITLE@ ב-@DOKUWIKIURL@ +מישהו ביקש ססמה חדשה עבור שם הכניסה שלך לוויקי @TITLE@ בכתובת @DOKUWIKIURL@ -אם לא ביקשת סיסמה חדשה פשוט התעלם מדוא"ל זה. +אם לא ביקשת ססמה חדשה באפשרותך פשוט להתעלם מהודעת דוא״ל זו. -כדי לאשר שהבקשה באמת נשלחה על ידך נא השתמש בקישור הבא. +כדי לאשר שהבקשה באמת נשלחה על ידך עליך השתמש בקישור הבא. @CONFIRM@ -- -דואר זה נוצר על ידי DokuWiki ב- +הודעת דוא״ל זו נוצרה על ידי ה־DokuWiki הזמין בכתובת @DOKUWIKIURL@ diff --git a/inc/lang/he/read.txt b/inc/lang/he/read.txt index 8e4c177ee..18efc5e03 100644 --- a/inc/lang/he/read.txt +++ b/inc/lang/he/read.txt @@ -1,2 +1,2 @@ -דף זה הוא דף לקריאה בלבד. ניתן לצפות בקוד המקור שלו, אבל לא ניתן לערוך אותו. ניתן לפנות אל מנהל הויקי אם לדעתך נפלה טעות. +דף זה הוא דף לקריאה בלבד. ניתן לצפות בקוד המקור שלו, אך לא ניתן לערוך אותו. ניתן לפנות למנהל הוויקי אם לדעתך נפלה טעות. diff --git a/inc/lang/he/register.txt b/inc/lang/he/register.txt index 7225b02fd..c4dfad752 100644 --- a/inc/lang/he/register.txt +++ b/inc/lang/he/register.txt @@ -1,3 +1,3 @@ ====== הרשמה כמשתמש חדש ====== -יש למלא את כל המידע מטה כדי ליצור חשבון חדש בויקי זה. יש לודא כי מוזנת **כתובת דוא"ל תקפה**- סיסמתך החדשה תשלח לכתובת זו\\ על שם המשתמש להיות [[hdoku>ויקי:שם דף|שם דף]] תקף. +יש למלא את כל המידע להלן כדי ליצור חשבון חדש בוויקי זה. עליך לוודא כי הזנת **כתובת דוא״ל תקפה**- ססמתך החדשה תשלח לכתובת זו. על שם המשתמש להיות [[hdoku>ויקי:שם דף|שם דף]] תקף. diff --git a/inc/lang/he/registermail.txt b/inc/lang/he/registermail.txt index bb64a8158..3edca3fa0 100644 --- a/inc/lang/he/registermail.txt +++ b/inc/lang/he/registermail.txt @@ -1,14 +1,14 @@ -משתמש חדש נרשם. הנה הפרטים: +משתמש חדש נרשם. להלן הפרטים: שם משתמש : @NEWUSER@ שם מלא : @NEWNAME@ -דוא"ל : @NEWEMAIL@ +דוא״ל : @NEWEMAIL@ תאריך : @DATE@ דפדפן : @BROWSER@ -כתובת רשת : @IPADDRESS@ -שם המחשב : @HOSTNAME@ +כתובת IP‏ : @IPADDRESS@ +שם המארח : @HOSTNAME@ -- -דוא"ל זה נוצר על ידי DokuWiki ב- +הודעת דוא״ל זו נוצרה על ידי ה־DokuWiki הזמין בכתובת @DOKUWIKIURL@ diff --git a/inc/lang/he/resendpwd.txt b/inc/lang/he/resendpwd.txt index 47e7749c2..8ca27207b 100644 --- a/inc/lang/he/resendpwd.txt +++ b/inc/lang/he/resendpwd.txt @@ -1,4 +1,4 @@ -====== שליחת סיסמה חדשה ====== +====== שליחת ססמה חדשה ====== -יש להזין את שם המשתמש בטופס מטה ולבקש סיסמה חדשה לחשבון שלך בויקי זה. קישור לאימות ישלח לכתובת הדו"ל איתה נרשמת. +יש להזין את שם המשתמש בטופס מטה ולבקש ססמה חדשה לחשבון שלך בוויקי זה. הקישור לאימות יישלח לכתובת הדוא״ל באמצעותה נרשמת. diff --git a/inc/lang/he/subscr_digest.txt b/inc/lang/he/subscr_digest.txt new file mode 100644 index 000000000..af5220229 --- /dev/null +++ b/inc/lang/he/subscr_digest.txt @@ -0,0 +1,20 @@ +שלום! + +הדף @PAGE@ שבאתר הוויקי @TITLE@ השתנה. +להלן השינויים: + +-------------------------------------------------------- +@DIFF@ +-------------------------------------------------------- + +המהדורה הישנה: @OLDPAGE@ +המהדורה החדשה: @NEWPAGE@ + +כדי לבטל את ההתרעות לשינויי העמוד, יש להיכנס לאתר הוויקי בכתובת +@DOKUWIKIURL@ ואז לבקר באגף +@SUBSCRIBE@ +ולבטל את המינוי לשינויים בדף ו/או במרחב השם. + +-- +הודעת דוא״ל זו נוצרה על ידי ה־DokuWiki שבכתובת +@DOKUWIKIURL@ \ No newline at end of file diff --git a/inc/lang/he/subscr_single.txt b/inc/lang/he/subscr_single.txt new file mode 100644 index 000000000..123b186c8 --- /dev/null +++ b/inc/lang/he/subscr_single.txt @@ -0,0 +1,22 @@ +שלום! + +הדף @PAGE@ באתר הוויקי @TITLE@ השתנה. + +-------------------------------------------------------- +@DIFF@ +-------------------------------------------------------- + +תאריך : @DATE@ +משתמש : @USER@ +תקציר העריכה: @SUMMARY@ +המהדורה הישנה: @OLDPAGE@ +המהדורה החדשה: @NEWPAGE@ + +לביטול התרעות בנוגע לעמוד, יש להיכנס לאתר הוויקי בכתובת +@DOKUWIKIURL@ ואז לבקר בדף +@NEWPAGE@ +ולבטל את המינוי לקבלת שינויים בדף ו/או במרחב השם. + +-- +הודעת דוא״ל זו נוצרה על ידי ה־DokuWiki הזמין בכתובת +@DOKUWIKIURL@ \ No newline at end of file diff --git a/lib/plugins/acl/lang/he/lang.php b/lib/plugins/acl/lang/he/lang.php index ac00730dd..91025f4b8 100644 --- a/lib/plugins/acl/lang/he/lang.php +++ b/lib/plugins/acl/lang/he/lang.php @@ -7,6 +7,7 @@ * @author Dotan Kamber * @author Moshe Kaplan * @author Yaron Yogev + * @author Yaron Shahrabani */ $lang['admin_acl'] = 'ניהול רשימת בקרת גישות'; $lang['acl_group'] = 'קבוצה'; diff --git a/lib/plugins/config/lang/he/lang.php b/lib/plugins/config/lang/he/lang.php index a39d0ab5c..ab4a8928e 100644 --- a/lib/plugins/config/lang/he/lang.php +++ b/lib/plugins/config/lang/he/lang.php @@ -7,6 +7,7 @@ * @author Dotan Kamber * @author Moshe Kaplan * @author Yaron Yogev + * @author Yaron Shahrabani */ $lang['menu'] = 'הגדרות תצורה'; $lang['error'] = 'ההגדרות לא עודכנו בגלל ערך לא תקף, נא לעיין בשינויים ולשלוח שנית. diff --git a/lib/plugins/plugin/lang/he/lang.php b/lib/plugins/plugin/lang/he/lang.php index c6e462193..47253e335 100644 --- a/lib/plugins/plugin/lang/he/lang.php +++ b/lib/plugins/plugin/lang/he/lang.php @@ -7,6 +7,7 @@ * @author Dotan Kamber * @author Moshe Kaplan * @author Yaron Yogev + * @author Yaron Shahrabani */ $lang['menu'] = 'ניהול הרחבות'; $lang['download'] = 'הורדת והתקנת הרחבה חדשה'; diff --git a/lib/plugins/popularity/lang/he/lang.php b/lib/plugins/popularity/lang/he/lang.php index 024f94ae8..f619127cd 100644 --- a/lib/plugins/popularity/lang/he/lang.php +++ b/lib/plugins/popularity/lang/he/lang.php @@ -5,6 +5,7 @@ * @author Dotan Kamber * @author Moshe Kaplan * @author Yaron Yogev + * @author Yaron Shahrabani */ $lang['name'] = 'משוב פופולריות (יתכן זמן טעינה ארוך)'; $lang['submit'] = 'שלח מידע'; diff --git a/lib/plugins/revert/lang/he/lang.php b/lib/plugins/revert/lang/he/lang.php index 585487816..ac3c3412e 100644 --- a/lib/plugins/revert/lang/he/lang.php +++ b/lib/plugins/revert/lang/he/lang.php @@ -5,6 +5,7 @@ * @author Dotan Kamber * @author Moshe Kaplan * @author Yaron Yogev + * @author Yaron Shahrabani */ $lang['menu'] = 'מנהל שחזור'; $lang['filter'] = 'חפש דפים עם ספאם'; diff --git a/lib/plugins/usermanager/lang/he/lang.php b/lib/plugins/usermanager/lang/he/lang.php index b2b55c3b4..601163013 100644 --- a/lib/plugins/usermanager/lang/he/lang.php +++ b/lib/plugins/usermanager/lang/he/lang.php @@ -6,6 +6,7 @@ * @author Dotan Kamber * @author Moshe Kaplan * @author Yaron Yogev + * @author Yaron Shahrabani */ $lang['menu'] = 'מנהל משתמשים'; $lang['noauth'] = '(אימות משתמשים אינו זמין)'; From 11aec52adf81e5d1a752ce9c3d83692014bfc19f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Jan 2011 10:50:13 +0100 Subject: [PATCH 090/110] updated adLDAP library to 3.3.2 [+] New feature: Move the user to a new OU using user_move() function [-] Bug fix: Prevent an 'undefined index' error in recursive_groups() when full PHP E_ALL logging is enabled [-] Bug fix: user_groups() does not return primary group when objectsid is not given (Tracker ID:2931213) [-] Bug fix: Undefined index in function user_info for non-existent users (Tracker ID:2922729) [-] Bug fix: Force user_info to find objectCategory of person as if a sAMAccountName also exists in a group it will return that group. (Tracker ID:3006096) [-] Bug fix: Return false for user_info if the user does not exist [-] Bug fix: user_info, checks for for a "count" value that not exist in $entries array if "memberof" isn't passed in $fields array. (Tracker ID:2993172) [-] Bug fix: In authenticate() if user authentication fails function returns and does not rebind with admin credentials - so the other funcions don't work anymore as $this->_bind === false. (Tracker ID:2987887) [-] Bug fix: When calling $ldap->user_modify('user', array("expires"=>0)) the function fails due to the value being 0. Changed to isset (Tracker ID:3036726) --- inc/adLDAP.php | 120 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 93 insertions(+), 27 deletions(-) diff --git a/inc/adLDAP.php b/inc/adLDAP.php index 94cd8a50d..4c8ee5db3 100644 --- a/inc/adLDAP.php +++ b/inc/adLDAP.php @@ -1,7 +1,7 @@ _bind = @ldap_bind($this->_conn,$username.$this->_account_suffix,$password); - if (!$this->_bind){ return (false); } + $ret = true; + $this->_bind = @ldap_bind($this->_conn, $username . $this->_account_suffix, $password); + if (!$this->_bind){ $ret = false; } // Cnce we've checked their details, kick back into admin mode if we have it - if ($this->_ad_username!=NULL && !$prevent_rebind){ - $this->_bind = @ldap_bind($this->_conn,$this->_ad_username.$this->_account_suffix,$this->_ad_password); + if ($this->_ad_username !== NULL && !$prevent_rebind) { + $this->_bind = @ldap_bind($this->_conn, $this->_ad_username . $this->_account_suffix , $this->_ad_password); if (!$this->_bind){ // This should never happen in theory throw new adLDAPException('Rebind to Active Directory failed. AD said: ' . $this->get_last_error()); } } - return (true); + return $ret; } //***************************************************************************************************************** @@ -758,7 +759,7 @@ class adLDAP { $ret_groups=array(); $groups=$this->group_info($group,array("memberof")); - if (is_array($groups[0]["memberof"])) { + if (isset($groups[0]["memberof"]) && is_array($groups[0]["memberof"])) { $groups=$groups[0]["memberof"]; if ($groups){ @@ -861,7 +862,7 @@ class adLDAP { * @param array $attributes The attributes to set to the user account * @return bool */ - public function user_create($attributes){ + public function user_create($attributes){ // Check for compulsory fields if (!array_key_exists("username",$attributes)){ return ("Missing compulsory field [username]"); } if (!array_key_exists("firstname",$attributes)){ return ("Missing compulsory field [firstname]"); } @@ -963,25 +964,36 @@ class adLDAP { $username = $this->strguid2hex($username); $filter="objectguid=".$username; } - else { - $filter="samaccountname=".$username; + else if (strstr($username, "@")) { + $filter="userPrincipalName=".$username; } + else { + $filter="samaccountname=".$username; + } + $filter = "(&(objectCategory=person)({$filter}))"; if ($fields===NULL){ $fields=array("samaccountname","mail","memberof","department","displayname","telephonenumber","primarygroupid","objectsid"); } + if (!in_array("objectsid",$fields)){ + $fields[] = "objectsid"; + } $sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields); $entries = ldap_get_entries($this->_conn, $sr); - if ($entries[0]['count'] >= 1) { - // AD does not return the primary group in the ldap query, we may need to fudge it - if ($this->_real_primarygroup && isset($entries[0]["primarygroupid"][0]) && isset($entries[0]["objectsid"][0])){ - //$entries[0]["memberof"][]=$this->group_cn($entries[0]["primarygroupid"][0]); - $entries[0]["memberof"][]=$this->get_primary_group($entries[0]["primarygroupid"][0], $entries[0]["objectsid"][0]); - } else { - $entries[0]["memberof"][]="CN=Domain Users,CN=Users,".$this->_base_dn; + if (isset($entries[0])) { + if ($entries[0]['count'] >= 1) { + if (in_array("memberof", $fields)) { + // AD does not return the primary group in the ldap query, we may need to fudge it + if ($this->_real_primarygroup && isset($entries[0]["primarygroupid"][0]) && isset($entries[0]["objectsid"][0])){ + //$entries[0]["memberof"][]=$this->group_cn($entries[0]["primarygroupid"][0]); + $entries[0]["memberof"][]=$this->get_primary_group($entries[0]["primarygroupid"][0], $entries[0]["objectsid"][0]); + } else { + $entries[0]["memberof"][]="CN=Domain Users,CN=Users,".$this->_base_dn; + } + $entries[0]["memberof"]["count"]++; + } } + return $entries; } - - $entries[0]["memberof"]["count"]++; - return ($entries); + return false; } /** @@ -1232,6 +1244,33 @@ class adLDAP { } } + /** + * Move a user account to a different OU + * + * @param string $username The username to move (please be careful here!) + * @param array $container The container or containers to move the user to (please be careful here!). + * accepts containers in 1. parent 2. child order + * @return array + */ + public function user_move($username, $container) { + if (!$this->_bind){ return (false); } + if ($username === null){ return ("Missing compulsory field [username]"); } + if ($container === null){ return ("Missing compulsory field [container]"); } + if (!is_array($container)){ return ("Container must be an array"); } + + $userinfo = $this->user_info($username, array("*")); + $dn = $userinfo[0]['distinguishedname'][0]; + $newrdn = "cn=" . $username; + $container = array_reverse($container); + $newcontainer = "ou=" . implode(",ou=",$container); + $newbasedn = strtolower($newcontainer) . "," . $this->_base_dn; + $result=@ldap_rename($this->_conn,$dn,$newrdn,$newbasedn,true); + if ($result !== true) { + return (false); + } + return (true); + } + //***************************************************************************************************************** // CONTACT FUNCTIONS // * Still work to do in this area, and new functions to write @@ -1567,6 +1606,32 @@ class adLDAP { return ($groups); } + //************************************************************************************************************ + // ORGANIZATIONAL UNIT FUNCTIONS + + /** + * Create an organizational unit + * + * @param array $attributes Default attributes of the ou + * @return bool + */ + public function ou_create($attributes){ + if (!is_array($attributes)){ return ("Attributes must be an array"); } + if (!array_key_exists("ou_name",$attributes)){ return ("Missing compulsory field [ou_name]"); } + if (!array_key_exists("container",$attributes)){ return ("Missing compulsory field [container]"); } + if (!is_array($attributes["container"])){ return ("Container attribute must be an array."); } + $attributes["container"]=array_reverse($attributes["container"]); + + $add=array(); + $add["objectClass"] = "organizationalUnit"; + + $container="OU=".implode(",OU=",$attributes["container"]); + $result=ldap_add($this->_conn,"CN=".$add["cn"].", ".$container.",".$this->_base_dn,$add); + if ($result!=true){ return (false); } + + return (true); + } + //************************************************************************************************************ // EXCHANGE FUNCTIONS @@ -1998,6 +2063,7 @@ class adLDAP { if ($attributes["exchange_usedefaults"]){ $mod["mDBUseDefaults"][0]=$attributes["exchange_usedefaults"]; } if ($attributes["exchange_policyexclude"]){ $mod["msExchPoliciesExcluded"][0]=$attributes["exchange_policyexclude"]; } if ($attributes["exchange_policyinclude"]){ $mod["msExchPoliciesIncluded"][0]=$attributes["exchange_policyinclude"]; } + if ($attributes["exchange_addressbook"]){ $mod["showInAddressBook"][0]=$attributes["exchange_addressbook"]; } // This schema is designed for contacts if ($attributes["exchange_hidefromlists"]){ $mod["msExchHideFromAddressLists"][0]=$attributes["exchange_hidefromlists"]; } From d0b9cae13d5b6d7dc15d57fff452054235ca8662 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Jan 2011 11:19:43 +0100 Subject: [PATCH 091/110] coding style fix --- lib/exe/ajax.php | 422 +++++++++++++++++++++++------------------------ 1 file changed, 210 insertions(+), 212 deletions(-) diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index e514762fd..540399a59 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -8,7 +8,7 @@ //fix for Opera XMLHttpRequests if(!count($_POST) && !empty($HTTP_RAW_POST_DATA)){ - parse_str($HTTP_RAW_POST_DATA, $_POST); + parse_str($HTTP_RAW_POST_DATA, $_POST); } if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); @@ -20,25 +20,25 @@ header('Content-Type: text/html; charset=utf-8'); //call the requested function -if(isset($_POST['call'])) - $call = $_POST['call']; -else if(isset($_GET['call'])) - $call = $_GET['call']; -else - exit; - +if(isset($_POST['call'])){ + $call = $_POST['call']; +}else if(isset($_GET['call'])){ + $call = $_GET['call']; +}else{ + exit; +} $callfn = 'ajax_'.$call; if(function_exists($callfn)){ - $callfn(); + $callfn(); }else{ - $evt = new Doku_Event('AJAX_CALL_UNKNOWN', $call); - if ($evt->advise_before()) { - print "AJAX call '".htmlspecialchars($call)."' unknown!\n"; - exit; - } - $evt->advise_after(); - unset($evt); + $evt = new Doku_Event('AJAX_CALL_UNKNOWN', $call); + if ($evt->advise_before()) { + print "AJAX call '".htmlspecialchars($call)."' unknown!\n"; + exit; + } + $evt->advise_after(); + unset($evt); } /** @@ -47,33 +47,33 @@ if(function_exists($callfn)){ * @author Andreas Gohr */ function ajax_qsearch(){ - global $conf; - global $lang; + global $conf; + global $lang; - $query = $_POST['q']; - if(empty($query)) $query = $_GET['q']; - if(empty($query)) return; + $query = $_POST['q']; + if(empty($query)) $query = $_GET['q']; + if(empty($query)) return; - $data = ft_pageLookup($query, true, useHeading('navigation')); + $data = ft_pageLookup($query, true, useHeading('navigation')); - if(!count($data)) return; + if(!count($data)) return; - print ''.$lang['quickhits'].''; - print '
    '; - foreach($data as $id => $title){ - if (useHeading('navigation')) { - $name = $title; - } else { - $ns = getNS($id); - if($ns){ - $name = shorten(noNS($id), ' ('.$ns.')',30); - }else{ - $name = $id; + print ''.$lang['quickhits'].''; + print '
      '; + foreach($data as $id => $title){ + if (useHeading('navigation')) { + $name = $title; + } else { + $ns = getNS($id); + if($ns){ + $name = shorten(noNS($id), ' ('.$ns.')',30); + }else{ + $name = $id; + } } + echo '
    • ' . html_wikilink(':'.$id,$name) . '
    • '; } - echo '
    • ' . html_wikilink(':'.$id,$name) . '
    • '; - } - print '
    '; + print '
'; } /** @@ -83,36 +83,36 @@ function ajax_qsearch(){ * @author Mike Frysinger */ function ajax_suggestions() { - global $conf; - global $lang; + global $conf; + global $lang; - $query = cleanID($_POST['q']); - if(empty($query)) $query = cleanID($_GET['q']); - if(empty($query)) return; + $query = cleanID($_POST['q']); + if(empty($query)) $query = cleanID($_GET['q']); + if(empty($query)) return; - $data = array(); - $data = ft_pageLookup($query); - if(!count($data)) return; - $data = array_keys($data); + $data = array(); + $data = ft_pageLookup($query); + if(!count($data)) return; + $data = array_keys($data); - // limit results to 15 hits - $data = array_slice($data, 0, 15); - $data = array_map('trim',$data); - $data = array_map('noNS',$data); - $data = array_unique($data); - sort($data); + // limit results to 15 hits + $data = array_slice($data, 0, 15); + $data = array_map('trim',$data); + $data = array_map('noNS',$data); + $data = array_unique($data); + sort($data); - /* now construct a json */ - $suggestions = array( - $query, // the original query - $data, // some suggestions - array(), // no description - array() // no urls - ); - $json = new JSON(); + /* now construct a json */ + $suggestions = array( + $query, // the original query + $data, // some suggestions + array(), // no description + array() // no urls + ); + $json = new JSON(); - header('Content-Type: application/x-suggestions+json'); - print $json->encode($suggestions); + header('Content-Type: application/x-suggestions+json'); + print $json->encode($suggestions); } /** @@ -121,32 +121,32 @@ function ajax_suggestions() { * Andreas Gohr */ function ajax_lock(){ - global $conf; - global $lang; - $id = cleanID($_POST['id']); - if(empty($id)) return; + global $conf; + global $lang; + $id = cleanID($_POST['id']); + if(empty($id)) return; - if(!checklock($id)){ - lock($id); - echo 1; - } - - if($conf['usedraft'] && $_POST['wikitext']){ - $client = $_SERVER['REMOTE_USER']; - if(!$client) $client = clientIP(true); - - $draft = array('id' => $id, - 'prefix' => substr($_POST['prefix'], 0, -1), - 'text' => $_POST['wikitext'], - 'suffix' => $_POST['suffix'], - 'date' => (int) $_POST['date'], - 'client' => $client, - ); - $cname = getCacheName($draft['client'].$id,'.draft'); - if(io_saveFile($cname,serialize($draft))){ - echo $lang['draftdate'].' '.dformat(); + if(!checklock($id)){ + lock($id); + echo 1; + } + + if($conf['usedraft'] && $_POST['wikitext']){ + $client = $_SERVER['REMOTE_USER']; + if(!$client) $client = clientIP(true); + + $draft = array('id' => $id, + 'prefix' => substr($_POST['prefix'], 0, -1), + 'text' => $_POST['wikitext'], + 'suffix' => $_POST['suffix'], + 'date' => (int) $_POST['date'], + 'client' => $client, + ); + $cname = getCacheName($draft['client'].$id,'.draft'); + if(io_saveFile($cname,serialize($draft))){ + echo $lang['draftdate'].' '.dformat(); + } } - } } @@ -156,14 +156,14 @@ function ajax_lock(){ * @author Andreas Gohr */ function ajax_draftdel(){ - $id = cleanID($_REQUEST['id']); - if(empty($id)) return; + $id = cleanID($_REQUEST['id']); + if(empty($id)) return; - $client = $_SERVER['REMOTE_USER']; - if(!$client) $client = clientIP(true); + $client = $_SERVER['REMOTE_USER']; + if(!$client) $client = clientIP(true); - $cname = getCacheName($client.$id,'.draft'); - @unlink($cname); + $cname = getCacheName($client.$id,'.draft'); + @unlink($cname); } /** @@ -172,22 +172,22 @@ function ajax_draftdel(){ * @author Andreas Gohr */ function ajax_medians(){ - global $conf; + global $conf; - // wanted namespace - $ns = cleanID($_POST['ns']); - $dir = utf8_encodeFN(str_replace(':','/',$ns)); + // wanted namespace + $ns = cleanID($_POST['ns']); + $dir = utf8_encodeFN(str_replace(':','/',$ns)); - $lvl = count(explode(':',$ns)); + $lvl = count(explode(':',$ns)); - $data = array(); - search($data,$conf['mediadir'],'search_index',array('nofiles' => true),$dir); - foreach($data as $item){ - $item['level'] = $lvl+1; - echo media_nstree_li($item); - echo media_nstree_item($item); - echo ''; - } + $data = array(); + search($data,$conf['mediadir'],'search_index',array('nofiles' => true),$dir); + foreach($data as $item){ + $item['level'] = $lvl+1; + echo media_nstree_li($item); + echo media_nstree_item($item); + echo ''; + } } /** @@ -196,11 +196,11 @@ function ajax_medians(){ * @author Andreas Gohr */ function ajax_medialist(){ - global $conf; - global $NS; + global $conf; + global $NS; - $NS = $_POST['ns']; - tpl_mediaContent(true); + $NS = $_POST['ns']; + tpl_mediaContent(true); } /** @@ -209,24 +209,24 @@ function ajax_medialist(){ * @author Andreas Gohr */ function ajax_index(){ - global $conf; + global $conf; - // wanted namespace - $ns = cleanID($_POST['idx']); - $dir = utf8_encodeFN(str_replace(':','/',$ns)); + // wanted namespace + $ns = cleanID($_POST['idx']); + $dir = utf8_encodeFN(str_replace(':','/',$ns)); - $lvl = count(explode(':',$ns)); + $lvl = count(explode(':',$ns)); - $data = array(); - search($data,$conf['datadir'],'search_index',array('ns' => $ns),$dir); - foreach($data as $item){ - $item['level'] = $lvl+1; - echo html_li_index($item); - echo '
'; - echo html_list_index($item); - echo '
'; - echo ''; - } + $data = array(); + search($data,$conf['datadir'],'search_index',array('ns' => $ns),$dir); + foreach($data as $item){ + $item['level'] = $lvl+1; + echo html_li_index($item); + echo '
'; + echo html_list_index($item); + echo '
'; + echo ''; + } } /** @@ -235,107 +235,105 @@ function ajax_index(){ * @author Andreas Gohr */ function ajax_linkwiz(){ - global $conf; - global $lang; + global $conf; + global $lang; - $q = ltrim($_POST['q'],':'); - $id = noNS($q); - $ns = getNS($q); + $q = ltrim($_POST['q'],':'); + $id = noNS($q); + $ns = getNS($q); - $ns = cleanID($ns); - $id = cleanID($id); + $ns = cleanID($ns); + $id = cleanID($id); - $nsd = utf8_encodeFN(str_replace(':','/',$ns)); - $idd = utf8_encodeFN(str_replace(':','/',$id)); + $nsd = utf8_encodeFN(str_replace(':','/',$ns)); + $idd = utf8_encodeFN(str_replace(':','/',$id)); - $data = array(); - if($q && !$ns){ + $data = array(); + if($q && !$ns){ - // use index to lookup matching pages - $pages = array(); - $pages = ft_pageLookup($id,true); + // use index to lookup matching pages + $pages = array(); + $pages = ft_pageLookup($id,true); - // result contains matches in pages and namespaces - // we now extract the matching namespaces to show - // them seperately - $dirs = array(); + // result contains matches in pages and namespaces + // we now extract the matching namespaces to show + // them seperately + $dirs = array(); + foreach($pages as $pid => $title){ + if(strpos(noNS($pid),$id) === false){ + // match was in the namespace + $dirs[getNS($pid)] = 1; // assoc array avoids dupes + }else{ + // it is a matching page, add it to the result + $data[] = array( + 'id' => $pid, + 'title' => $title, + 'type' => 'f', + ); + } + unset($pages[$pid]); + } + foreach($dirs as $dir => $junk){ + $data[] = array( + 'id' => $dir, + 'type' => 'd', + ); + } - foreach($pages as $pid => $title){ - if(strpos(noNS($pid),$id) === false){ - // match was in the namespace - $dirs[getNS($pid)] = 1; // assoc array avoids dupes - }else{ - // it is a matching page, add it to the result - $data[] = array( - 'id' => $pid, - 'title' => $title, - 'type' => 'f', - ); - } - unset($pages[$pid]); - } - foreach($dirs as $dir => $junk){ - $data[] = array( - 'id' => $dir, - 'type' => 'd', - ); - } - - }else{ - - $opts = array( - 'depth' => 1, - 'listfiles' => true, - 'listdirs' => true, - 'pagesonly' => true, - 'firsthead' => true, - 'sneakyacl' => $conf['sneaky_index'], - ); - if($id) $opts['filematch'] = '^.*\/'.$id; - if($id) $opts['dirmatch'] = '^.*\/'.$id; - search($data,$conf['datadir'],'search_universal',$opts,$nsd); - - // add back to upper - if($ns){ - array_unshift($data,array( - 'id' => getNS($ns), - 'type' => 'u', - )); - } - } - - // fixme sort results in a useful way ? - - if(!count($data)){ - echo $lang['nothingfound']; - exit; - } - - // output the found data - $even = 1; - foreach($data as $item){ - $even *= -1; //zebra - - if(($item['type'] == 'd' || $item['type'] == 'u') && $item['id']) $item['id'] .= ':'; - $link = wl($item['id']); - - echo '
'; - - - if($item['type'] == 'u'){ - $name = $lang['upperns']; }else{ - $name = htmlspecialchars($item['id']); + + $opts = array( + 'depth' => 1, + 'listfiles' => true, + 'listdirs' => true, + 'pagesonly' => true, + 'firsthead' => true, + 'sneakyacl' => $conf['sneaky_index'], + ); + if($id) $opts['filematch'] = '^.*\/'.$id; + if($id) $opts['dirmatch'] = '^.*\/'.$id; + search($data,$conf['datadir'],'search_universal',$opts,$nsd); + + // add back to upper + if($ns){ + array_unshift($data,array( + 'id' => getNS($ns), + 'type' => 'u', + )); + } } - echo ''.$name.''; + // fixme sort results in a useful way ? - if($item['title']){ - echo ''.htmlspecialchars($item['title']).''; + if(!count($data)){ + echo $lang['nothingfound']; + exit; + } + + // output the found data + $even = 1; + foreach($data as $item){ + $even *= -1; //zebra + + if(($item['type'] == 'd' || $item['type'] == 'u') && $item['id']) $item['id'] .= ':'; + $link = wl($item['id']); + + echo '
'; + + if($item['type'] == 'u'){ + $name = $lang['upperns']; + }else{ + $name = htmlspecialchars($item['id']); + } + + echo ''.$name.''; + + if($item['title']){ + echo ''.htmlspecialchars($item['title']).''; + } + echo '
'; } - echo '
'; - } } From 168cead4e4c7d7c79cc57fa557dd21428243b2f9 Mon Sep 17 00:00:00 2001 From: Christian Wichmann Date: Fri, 14 Jan 2011 11:22:52 +0100 Subject: [PATCH 092/110] German language update --- inc/lang/de/lang.php | 1 + lib/plugins/acl/lang/de/lang.php | 1 + lib/plugins/config/lang/de/lang.php | 2 ++ lib/plugins/plugin/lang/de/lang.php | 1 + lib/plugins/popularity/lang/de/lang.php | 1 + lib/plugins/revert/lang/de/lang.php | 1 + lib/plugins/usermanager/lang/de/lang.php | 1 + 7 files changed, 8 insertions(+) diff --git a/inc/lang/de/lang.php b/inc/lang/de/lang.php index c220b706d..a353b98ed 100644 --- a/inc/lang/de/lang.php +++ b/inc/lang/de/lang.php @@ -18,6 +18,7 @@ * @author Robert Bogenschneider * @author Robert Bogenschneider * @author Niels Lange + * @author Christian Wichmann */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'ltr'; diff --git a/lib/plugins/acl/lang/de/lang.php b/lib/plugins/acl/lang/de/lang.php index 13b3f3f05..3c6bf8cf0 100644 --- a/lib/plugins/acl/lang/de/lang.php +++ b/lib/plugins/acl/lang/de/lang.php @@ -18,6 +18,7 @@ * @author Robert Bogenschneider * @author Robert Bogenschneider * @author Niels Lange + * @author Christian Wichmann */ $lang['admin_acl'] = 'Zugangsverwaltung'; $lang['acl_group'] = 'Gruppe'; diff --git a/lib/plugins/config/lang/de/lang.php b/lib/plugins/config/lang/de/lang.php index a5205c16b..b26df4993 100644 --- a/lib/plugins/config/lang/de/lang.php +++ b/lib/plugins/config/lang/de/lang.php @@ -14,6 +14,7 @@ * @author Robert Bogenschneider * @author Robert Bogenschneider * @author Niels Lange + * @author Christian Wichmann */ $lang['menu'] = 'Konfiguration'; $lang['error'] = 'Die Einstellungen wurden wegen einer fehlerhaften Eingabe nicht gespeichert. @@ -112,6 +113,7 @@ $lang['fetchsize'] = 'Maximale Größe (in Bytes), die fetch.php von $lang['notify'] = 'Änderungsmitteilungen an diese E-Mail-Adresse versenden'; $lang['registernotify'] = 'Information über neu registrierte Nutzer an diese E-Mail-Adresse senden'; $lang['mailfrom'] = 'Absender-E-Mail-Adresse für automatische Mails'; +$lang['mailprefix'] = 'Präfix für E-Mail-Betreff beim automatischen Versand von Benachrichtigungen'; $lang['gzip_output'] = 'Seiten mit gzip komprimiert ausliefern'; $lang['gdlib'] = 'GD Lib Version'; $lang['im_convert'] = 'Pfad zu ImageMagicks Konvertierwerkzeug'; diff --git a/lib/plugins/plugin/lang/de/lang.php b/lib/plugins/plugin/lang/de/lang.php index bbc3506f5..6f785168b 100644 --- a/lib/plugins/plugin/lang/de/lang.php +++ b/lib/plugins/plugin/lang/de/lang.php @@ -15,6 +15,7 @@ * @author Robert Bogenschneider * @author Robert Bogenschneider * @author Niels Lange + * @author Christian Wichmann */ $lang['menu'] = 'Plugins verwalten'; $lang['download'] = 'Neues Plugin herunterladen und installieren'; diff --git a/lib/plugins/popularity/lang/de/lang.php b/lib/plugins/popularity/lang/de/lang.php index b5094520b..4649062f7 100644 --- a/lib/plugins/popularity/lang/de/lang.php +++ b/lib/plugins/popularity/lang/de/lang.php @@ -12,6 +12,7 @@ * @author Robert Bogenschneider * @author Robert Bogenschneider * @author Niels Lange + * @author Christian Wichmann */ $lang['name'] = 'Popularitäts-Feedback (Eventuell längere Ladezeit)'; $lang['submit'] = 'Daten senden'; diff --git a/lib/plugins/revert/lang/de/lang.php b/lib/plugins/revert/lang/de/lang.php index 8918c8b28..0bc8e2ce0 100644 --- a/lib/plugins/revert/lang/de/lang.php +++ b/lib/plugins/revert/lang/de/lang.php @@ -13,6 +13,7 @@ * @author Robert Bogenschneider * @author Robert Bogenschneider * @author Niels Lange + * @author Christian Wichmann */ $lang['menu'] = 'Seiten wieder herstellen'; $lang['filter'] = 'Nach betroffenen Seiten suchen'; diff --git a/lib/plugins/usermanager/lang/de/lang.php b/lib/plugins/usermanager/lang/de/lang.php index 9ae049d3e..090d1d1d9 100644 --- a/lib/plugins/usermanager/lang/de/lang.php +++ b/lib/plugins/usermanager/lang/de/lang.php @@ -14,6 +14,7 @@ * @author Robert Bogenschneider * @author Robert Bogenschneider * @author Niels Lange + * @author Christian Wichmann */ $lang['menu'] = 'Benutzerverwaltung'; $lang['noauth'] = '(Authentifizierungssystem nicht verfügbar)'; From ef7acde6835f3eda384a189e4d6f2f86a3ad9d3c Mon Sep 17 00:00:00 2001 From: Christian Wichmann Date: Fri, 14 Jan 2011 11:23:23 +0100 Subject: [PATCH 093/110] German (informal) language update --- inc/lang/de-informal/lang.php | 72 +++++++++---------- lib/plugins/acl/lang/de-informal/lang.php | 1 + lib/plugins/config/lang/de-informal/lang.php | 2 + lib/plugins/plugin/lang/de-informal/lang.php | 1 + .../popularity/lang/de-informal/lang.php | 1 + .../popularity/lang/de-informal/submitted.txt | 3 + lib/plugins/revert/lang/de-informal/lang.php | 1 + .../usermanager/lang/de-informal/lang.php | 1 + 8 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 lib/plugins/popularity/lang/de-informal/submitted.txt diff --git a/inc/lang/de-informal/lang.php b/inc/lang/de-informal/lang.php index c79f26227..b7c446656 100644 --- a/inc/lang/de-informal/lang.php +++ b/inc/lang/de-informal/lang.php @@ -17,6 +17,7 @@ * @author Juergen Schwarzer * @author Marcel Metz * @author Matthias Schulte + * @author Christian Wichmann */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'ltr'; @@ -107,27 +108,27 @@ $lang['js']['notsavedyet'] = 'Nicht gespeicherte Änderungen gehen verloren! $lang['js']['searchmedia'] = 'Suche nach Dateien'; $lang['js']['keepopen'] = 'Fenster nach Auswahl nicht schließen'; $lang['js']['hidedetails'] = 'Details ausblenden'; -$lang['js']['mediatitle'] = 'Link-Eigenschaften'; -$lang['js']['mediadisplay'] = 'Linktyp'; -$lang['js']['mediaalign'] = 'Ausrichtung'; -$lang['js']['mediasize'] = 'Bildgröße'; -$lang['js']['mediatarget'] = 'Linkziel'; -$lang['js']['mediaclose'] = 'Schließen'; -$lang['js']['mediainsert'] = 'Einfügen'; -$lang['js']['mediadisplayimg'] = 'Bild anzeigen.'; -$lang['js']['mediadisplaylnk'] = 'Nur den Link anzeigen.'; -$lang['js']['mediasmall'] = 'Kleine Version'; -$lang['js']['mediamedium'] = 'Mittelgroße Version'; -$lang['js']['medialarge'] = 'Große Version'; -$lang['js']['mediaoriginal'] = 'Original Version'; -$lang['js']['medialnk'] = 'Link zu der Detailseite'; -$lang['js']['mediadirect'] = 'Direkter Link zum Original'; -$lang['js']['medianolnk'] = 'Kein link'; -$lang['js']['medianolink'] = 'Keine Verlinkung des Bildes'; -$lang['js']['medialeft'] = 'Bild nach links ausrichten.'; -$lang['js']['mediaright'] = 'Bild nach rechts ausrichten.'; -$lang['js']['mediacenter'] = 'Bild in der Mitte ausrichten'; -$lang['js']['medianoalign'] = 'Keine Ausrichtung des Bildes.'; +$lang['js']['mediatitle'] = 'Link-Eigenschaften'; +$lang['js']['mediadisplay'] = 'Linktyp'; +$lang['js']['mediaalign'] = 'Ausrichtung'; +$lang['js']['mediasize'] = 'Bildgröße'; +$lang['js']['mediatarget'] = 'Linkziel'; +$lang['js']['mediaclose'] = 'Schließen'; +$lang['js']['mediainsert'] = 'Einfügen'; +$lang['js']['mediadisplayimg'] = 'Bild anzeigen.'; +$lang['js']['mediadisplaylnk'] = 'Nur den Link anzeigen.'; +$lang['js']['mediasmall'] = 'Kleine Version'; +$lang['js']['mediamedium'] = 'Mittelgroße Version'; +$lang['js']['medialarge'] = 'Große Version'; +$lang['js']['mediaoriginal'] = 'Original Version'; +$lang['js']['medialnk'] = 'Link zu der Detailseite'; +$lang['js']['mediadirect'] = 'Direkter Link zum Original'; +$lang['js']['medianolnk'] = 'Kein link'; +$lang['js']['medianolink'] = 'Keine Verlinkung des Bildes'; +$lang['js']['medialeft'] = 'Bild nach links ausrichten.'; +$lang['js']['mediaright'] = 'Bild nach rechts ausrichten.'; +$lang['js']['mediacenter'] = 'Bild in der Mitte ausrichten'; +$lang['js']['medianoalign'] = 'Keine Ausrichtung des Bildes.'; $lang['js']['nosmblinks'] = 'Das Verlinken von Windows-Freigaben funktioniert nur im Microsoft Internet-Explorer.\nDer Link kann jedoch durch Kopieren und Einfügen verwendet werden.'; $lang['js']['linkwiz'] = 'Link-Assistent'; $lang['js']['linkto'] = 'Link zu:'; @@ -148,7 +149,6 @@ $lang['uploadsize'] = 'Die hochgeladene Datei war zu groß. (max. %s) $lang['deletesucc'] = 'Die Datei "%s" wurde gelöscht.'; $lang['deletefail'] = '"%s" konnte nicht gelöscht werden. Keine Berechtigung?.'; $lang['mediainuse'] = 'Die Datei "%s" wurde nicht gelöscht. Sie wird noch verwendet.'; -$lang['mediainuse'] = 'Die Datei "%s" wurde nicht gelöscht. Sie wird noch verwendet.'; $lang['namespaces'] = 'Namensräume'; $lang['mediafiles'] = 'Vorhandene Dateien in'; $lang['accessdenied'] = 'Du hast keinen Zugriff auf diese Seite'; @@ -225,22 +225,22 @@ $lang['img_copyr'] = 'Copyright'; $lang['img_format'] = 'Format'; $lang['img_camera'] = 'Kamera'; $lang['img_keywords'] = 'Schlagwörter'; -$lang['subscr_subscribe_success'] = 'Die Seite %s wurde zur Abonnementenliste von %s hinzugefügt'; -$lang['subscr_subscribe_error'] = 'Fehler beim Hinzufügen von %s zur Abonnementenliste von %s'; +$lang['subscr_subscribe_success'] = 'Die Seite %s wurde zur Abonnementenliste von %s hinzugefügt'; +$lang['subscr_subscribe_error'] = 'Fehler beim Hinzufügen von %s zur Abonnementenliste von %s'; $lang['subscr_subscribe_noaddress'] = 'In deinem Account ist keine E-Mail-Adresse hinterlegt. Dadurch kann die Seite nicht abonniert werden'; $lang['subscr_unsubscribe_success'] = 'Die Seite %s wurde von der Abonnementenliste von %s entfernt'; -$lang['subscr_unsubscribe_error'] = 'Fehler beim Entfernen von %s von der Abonnementenliste von %s'; -$lang['subscr_already_subscribed'] = '%s ist bereits auf der Abonnementenliste von %s'; -$lang['subscr_not_subscribed'] = '%s ist nicht auf der Abonnementenliste von %s'; -$lang['subscr_m_not_subscribed'] = 'Du hast kein Abonnement von dieser Seite oder dem Namensraum.'; -$lang['subscr_m_new_header'] = 'Abonnementen hinzufügen'; -$lang['subscr_m_current_header'] = 'Aktive Abonnements'; -$lang['subscr_m_unsubscribe'] = 'Abbestellen'; -$lang['subscr_m_subscribe'] = 'Abonnieren'; -$lang['subscr_m_receive'] = 'Erhalten'; -$lang['subscr_style_every'] = 'E-Mail bei jeder Änderung'; -$lang['subscr_style_digest'] = 'E-Mail mit zusammengefasster Übersicht der Seitenänderungen (alle %.2f Tage)'; -$lang['subscr_style_list'] = 'Auflistung aller geänderten Seiten seit der letzten E-Mail (alle %.2f Tage)'; +$lang['subscr_unsubscribe_error'] = 'Fehler beim Entfernen von %s von der Abonnementenliste von %s'; +$lang['subscr_already_subscribed'] = '%s ist bereits auf der Abonnementenliste von %s'; +$lang['subscr_not_subscribed'] = '%s ist nicht auf der Abonnementenliste von %s'; +$lang['subscr_m_not_subscribed'] = 'Du hast kein Abonnement von dieser Seite oder dem Namensraum.'; +$lang['subscr_m_new_header'] = 'Abonnementen hinzufügen'; +$lang['subscr_m_current_header'] = 'Aktive Abonnements'; +$lang['subscr_m_unsubscribe'] = 'Abbestellen'; +$lang['subscr_m_subscribe'] = 'Abonnieren'; +$lang['subscr_m_receive'] = 'Erhalten'; +$lang['subscr_style_every'] = 'E-Mail bei jeder Änderung'; +$lang['subscr_style_digest'] = 'E-Mail mit zusammengefasster Übersicht der Seitenänderungen (alle %.2f Tage)'; +$lang['subscr_style_list'] = 'Auflistung aller geänderten Seiten seit der letzten E-Mail (alle %.2f Tage)'; $lang['authmodfailed'] = 'Benutzerüberprüfung nicht möglich. Bitte wende dich an den Admin.'; $lang['authtempfail'] = 'Benutzerüberprüfung momentan nicht möglich. Falls das Problem andauert, wende dich an den Admin.'; $lang['i_chooselang'] = 'Wähle deine Sprache'; diff --git a/lib/plugins/acl/lang/de-informal/lang.php b/lib/plugins/acl/lang/de-informal/lang.php index fdb6f5a89..e24584a55 100644 --- a/lib/plugins/acl/lang/de-informal/lang.php +++ b/lib/plugins/acl/lang/de-informal/lang.php @@ -6,6 +6,7 @@ * @author Juergen Schwarzer * @author Marcel Metz * @author Matthias Schulte + * @author Christian Wichmann */ $lang['admin_acl'] = 'Zugriffskontrollsystem Management'; $lang['acl_group'] = 'Gruppe'; diff --git a/lib/plugins/config/lang/de-informal/lang.php b/lib/plugins/config/lang/de-informal/lang.php index 01beeeeb9..f6ddaa8e9 100644 --- a/lib/plugins/config/lang/de-informal/lang.php +++ b/lib/plugins/config/lang/de-informal/lang.php @@ -6,6 +6,7 @@ * @author Juergen Schwarzer * @author Marcel Metz * @author Matthias Schulte + * @author Christian Wichmann */ $lang['menu'] = 'Einstellungen'; $lang['error'] = 'Einstellungen wurden nicht aktualisiert auf Grund eines ungültigen Wertes. Bitte überprüfe deine Änderungen und versuche es erneut.
Die/der ungültige(n) Wert(e) werden durch eine rote Umrandung hervorgehoben.'; @@ -102,6 +103,7 @@ $lang['fetchsize'] = 'Maximale Größe (in Bytes), die fetch.php von $lang['notify'] = 'Sende Änderungsbenachrichtigungen an diese E-Mail-Adresse.'; $lang['registernotify'] = 'Sende Information bei neu registrierten Benutzern an diese E-Mail-Adresse.'; $lang['mailfrom'] = 'Absenderadresse für automatisch erzeugte E-Mails'; +$lang['mailprefix'] = 'Präfix für E-Mail-Betreff beim automatischen Versand von Benachrichtigungen'; $lang['gzip_output'] = 'Seiten mit gzip komprimiert ausliefern'; $lang['gdlib'] = 'GD Lib Version'; $lang['im_convert'] = 'Pfad zu ImageMagicks Konvertierwerkzeug'; diff --git a/lib/plugins/plugin/lang/de-informal/lang.php b/lib/plugins/plugin/lang/de-informal/lang.php index 65050b896..3ba729fd6 100644 --- a/lib/plugins/plugin/lang/de-informal/lang.php +++ b/lib/plugins/plugin/lang/de-informal/lang.php @@ -6,6 +6,7 @@ * @author Juergen Schwarzer * @author Marcel Metz * @author Matthias Schulte + * @author Christian Wichmann */ $lang['menu'] = 'Plugins verwalten'; $lang['download'] = 'Herunterladen und installieren einer neuen Erweiterung'; diff --git a/lib/plugins/popularity/lang/de-informal/lang.php b/lib/plugins/popularity/lang/de-informal/lang.php index 61a7db7b1..f884ed690 100644 --- a/lib/plugins/popularity/lang/de-informal/lang.php +++ b/lib/plugins/popularity/lang/de-informal/lang.php @@ -6,6 +6,7 @@ * @author Juergen Schwarzer * @author Marcel Metz * @author Matthias Schulte + * @author Christian Wichmann */ $lang['name'] = 'Popularitätsrückmeldung (kann eine Weile dauern, bis es fertig geladen wurde)'; $lang['submit'] = 'Sende Daten'; diff --git a/lib/plugins/popularity/lang/de-informal/submitted.txt b/lib/plugins/popularity/lang/de-informal/submitted.txt new file mode 100644 index 000000000..e7b45b5b7 --- /dev/null +++ b/lib/plugins/popularity/lang/de-informal/submitted.txt @@ -0,0 +1,3 @@ +====== Popularitäts-Feedback ====== + +Die Daten wurden erfolgreich versandt. \ No newline at end of file diff --git a/lib/plugins/revert/lang/de-informal/lang.php b/lib/plugins/revert/lang/de-informal/lang.php index ac2f35e85..b6709d2fa 100644 --- a/lib/plugins/revert/lang/de-informal/lang.php +++ b/lib/plugins/revert/lang/de-informal/lang.php @@ -6,6 +6,7 @@ * @author Juergen Schwarzer * @author Marcel Metz * @author Matthias Schulte + * @author Christian Wichmann */ $lang['menu'] = 'Zurückstellungsmanager'; $lang['filter'] = 'Durchsuche als Spam markierte Seiten'; diff --git a/lib/plugins/usermanager/lang/de-informal/lang.php b/lib/plugins/usermanager/lang/de-informal/lang.php index e906c0cf8..95b36c60f 100644 --- a/lib/plugins/usermanager/lang/de-informal/lang.php +++ b/lib/plugins/usermanager/lang/de-informal/lang.php @@ -6,6 +6,7 @@ * @author Juergen Schwarzer * @author Marcel Metz * @author Matthias Schulte + * @author Christian Wichmann */ $lang['menu'] = 'Benutzerverwalter'; $lang['noauth'] = '(Benutzeranmeldung ist nicht verfügbar)'; From 5ba8d196ffe346ef6fbd8e6ffc11f0c849537ed3 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Jan 2011 12:20:19 +0100 Subject: [PATCH 094/110] shorten quicksearch namespaces in JavaScript This patch moves the shortening of namespaces in the quicksearch results to JavaScript. This makes it independend from used template and will always try to fill the width of the result pane correctly. Things missing: * Make it work with RTL-languages * Check Browser compatibility (only tested in Chrome so far) --- lib/scripts/ajax.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lib/scripts/ajax.js b/lib/scripts/ajax.js index de009d448..761329f0f 100644 --- a/lib/scripts/ajax.js +++ b/lib/scripts/ajax.js @@ -31,6 +31,47 @@ addInitEvent(function () { outObj.innerHTML = data; outObj.style.display = 'block'; + outObj.style['white-space'] = 'nowrap'; + + // shorten namespaces if too long + var width = outObj.clientWidth; + var links = outObj.getElementsByTagName('a'); + for(var i=0; i 3) && links[i].offsetWidth > max ){ + if(runaway++ > 500) return; // just in case something went wrong + + if(eli){ + // elipsis already inserted + if( (eli - nsL) > (nsR - eli) ){ + // cut left + links[i].innerText = links[i].innerText.substring(0,eli-2)+ + links[i].innerText.substring(eli); + }else{ + // cut right + links[i].innerText = links[i].innerText.substring(0,eli+1)+ + links[i].innerText.substring(eli+2); + } + }else{ + // replace middle with ellipsis + var mid = Math.floor( nsL + ((nsR-nsL)/2) ); + links[i].innerText = links[i].innerText.substring(0,mid)+'…'+ + links[i].innerText.substring(mid+1); + } + eli = links[i].innerText.indexOf('…'); + nsL = links[i].innerText.indexOf('('); + nsR = links[i].innerText.indexOf(')'); + } + } + }; // attach eventhandler to search field From 301971b3769a2d1a440cf58fd84f2c100a1348e3 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Jan 2011 13:59:23 +0100 Subject: [PATCH 095/110] correctly(?) shorten namespaces for RTL langunages in quicksearch --- lib/scripts/ajax.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/scripts/ajax.js b/lib/scripts/ajax.js index 761329f0f..d752edb38 100644 --- a/lib/scripts/ajax.js +++ b/lib/scripts/ajax.js @@ -38,15 +38,23 @@ addInitEvent(function () { var links = outObj.getElementsByTagName('a'); for(var i=0; i 0) continue; var nsL = links[i].innerText.indexOf('('); var nsR = links[i].innerText.indexOf(')'); var eli = 0; var runaway = 0; - while( (nsR - nsL > 3) && links[i].offsetWidth > max ){ + while( (nsR - nsL > 3) && + ( + (!isRTL && links[i].offsetWidth > max) || + (isRTL && links[i].offsetLeft < 0) + ) + ){ if(runaway++ > 500) return; // just in case something went wrong if(eli){ From bced4159c8c5f1b4da2e98b2242c2ec1c09ec74e Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 14 Jan 2011 23:32:29 +0100 Subject: [PATCH 096/110] Deprecate $NS in doku.php $NS is only used in lib/exe/{ajax,mediamanager}.php when no $ID context is present. The two functions which use $NS in inc/template.php are only called through those both endpoints, not through doku.php. In doku.php, $ID is the only correct value, $NS is not kept synchronous with $ID. Use getNS($ID) in functions which are called through doku.php. --- doku.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doku.php b/doku.php index 816acd3da..b0312fb25 100644 --- a/doku.php +++ b/doku.php @@ -30,7 +30,10 @@ $old = error_reporting(E_ALL ^ E_NOTICE); //import variables $QUERY = trim($_REQUEST['id']); $ID = getID(); + +// deprecated 2011-01-14 $NS = getNS($ID); + $REV = $_REQUEST['rev']; $IDX = $_REQUEST['idx']; $DATE = $_REQUEST['date']; From d83e78edb7657053f07161bbace2dba26ee83905 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Jan 2011 09:46:17 +0100 Subject: [PATCH 097/110] added missing change for path length shortener in ajax backend --- lib/exe/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 540399a59..1939a7bcb 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -66,7 +66,7 @@ function ajax_qsearch(){ } else { $ns = getNS($id); if($ns){ - $name = shorten(noNS($id), ' ('.$ns.')',30); + $name = noNS($id).' ('.$ns.')'; }else{ $name = $id; } From a8254dfa8d8e02d4ac011fe915f3dcb4fdf7a361 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Jan 2011 10:29:42 +0100 Subject: [PATCH 098/110] made ajax quicksearch its own object This makes it possible for plugin and template authors to overwrite or extend the quicksearch JavaScript logic. --- lib/scripts/ajax.js | 79 ++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/lib/scripts/ajax.js b/lib/scripts/ajax.js index d752edb38..44dcee999 100644 --- a/lib/scripts/ajax.js +++ b/lib/scripts/ajax.js @@ -5,30 +5,58 @@ * @author Andreas Gohr * @author Adrian Lang */ -addInitEvent(function () { +var ajax_quicksearch = { - var inID = 'qsearch__in'; - var outID = 'qsearch__out'; + inObj: null, + outObj: null, + sackObj: null, + delay: null, - var inObj = document.getElementById(inID); - var outObj = document.getElementById(outID); + init: function(inID, outID) { - // objects found? - if (inObj === null){ return; } - if (outObj === null){ return; } + this.inObj = $(inID); + this.outObj = $(outID); - function clear_results(){ - outObj.style.display = 'none'; - outObj.innerHTML = ''; - } + // objects found? + if (this.inObj === null) return; + if (this.outObj === null) return; - var sack_obj = new sack(DOKU_BASE + 'lib/exe/ajax.php'); - sack_obj.AjaxFailedAlert = ''; - sack_obj.encodeURIString = false; - sack_obj.onCompletion = function () { - var data = sack_obj.response; + // prepare AJAX + this.sackObj = new sack(DOKU_BASE + 'lib/exe/ajax.php'); + this.sackObj.AjaxFailedAlert = ''; + this.sackObj.encodeURIString = false; + this.sackObj.onCompletion = ajax_quicksearch.onCompletion; + + // attach eventhandler to search field + this.delay = new Delay(function () { + ajax_quicksearch.clear_results(); + var value = ajax_quicksearch.inObj.value; + if(value === ''){ return; } + ajax_quicksearch.sackObj.runAJAX('call=qsearch&q=' + encodeURI(value)); + }); + + addEvent(this.inObj, 'keyup', function () { + ajax_quicksearch.clear_results(); + ajax_quicksearch.delay.start(); + }); + + // attach eventhandler to output field + addEvent(this.outObj, 'click', function () { + ajax_quicksearch.outObj.style.display = 'none'; + }); + }, + + clear_results: function(){ + ajax_quicksearch.outObj.style.display = 'none'; + ajax_quicksearch.outObj.innerHTML = ''; + }, + + onCompletion: function() { + var data = this.response; // 'this' is sack context if (data === '') { return; } + var outObj = ajax_quicksearch.outObj; + outObj.innerHTML = data; outObj.style.display = 'block'; outObj.style['white-space'] = 'nowrap'; @@ -79,19 +107,12 @@ addInitEvent(function () { nsR = links[i].innerText.indexOf(')'); } } + } - }; +}; - // attach eventhandler to search field - var delay = new Delay(function () { - clear_results(); - var value = inObj.value; - if(value === ''){ return; } - sack_obj.runAJAX('call=qsearch&q=' + encodeURI(value)); - }); - addEvent(inObj, 'keyup', function () {clear_results(); delay.start(); }); - - // attach eventhandler to output field - addEvent(outObj, 'click', function () {outObj.style.display = 'none'; }); +addInitEvent(function(){ + ajax_quicksearch.init('qsearch__in','qsearch__out'); }); + From 99f04cb741f14f2ccea37163786f1ea4824c2eb0 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Jan 2011 10:39:42 +0100 Subject: [PATCH 099/110] don't use » for non hierarchical breadcrumbs FS#2135 Not sure if this sympol is the best to use. I'm open for different suggestions. Template auhtors still can overwrite the symbol of course. --- inc/template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/template.php b/inc/template.php index e4c74a714..6d25a7171 100644 --- a/inc/template.php +++ b/inc/template.php @@ -685,7 +685,7 @@ function tpl_searchform($ajax=true,$autocomplete=true){ * * @author Andreas Gohr */ -function tpl_breadcrumbs($sep='»'){ +function tpl_breadcrumbs($sep='♦'){ global $lang; global $conf; From ef7df687e4ebf910c7eb86b5a8b2a47b9d121917 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Jan 2011 11:28:59 +0100 Subject: [PATCH 100/110] added unit test for kmd5 password hashing --- _test/cases/inc/auth_password.test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_test/cases/inc/auth_password.test.php b/_test/cases/inc/auth_password.test.php index cb1cd5593..77ee9eed3 100644 --- a/_test/cases/inc/auth_password.test.php +++ b/_test/cases/inc/auth_password.test.php @@ -15,6 +15,7 @@ class auth_password_test extends UnitTestCase { 'crypt' => 'ablvoGr1hvZ5k', 'mysql' => '4a1fa3780bd6fd55', 'my411' => '*e5929347e25f82e19e4ebe92f1dc6b6e7c2dbd29', + 'kmd5' => 'a579299436d7969791189acadd86fcb716', ); @@ -22,7 +23,7 @@ class auth_password_test extends UnitTestCase { foreach($this->passes as $method => $hash){ $info = "testing method $method"; $this->signal('failinfo',$info); - $this->assertEqual(auth_cryptPassword('foo'.$method,$method,'abcdefgh'),$hash); + $this->assertEqual(auth_cryptPassword('foo'.$method,$method,'abcdefgh12345678912345678912345678'),$hash); } } From f91977c212fd1c1645f521f6190e1ec32259f7a2 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Jan 2011 12:24:14 +0100 Subject: [PATCH 101/110] Added support for Wordpress' password hashing FS#2134 --- _test/cases/inc/auth_password.test.php | 7 ++++ inc/auth.php | 47 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/_test/cases/inc/auth_password.test.php b/_test/cases/inc/auth_password.test.php index 77ee9eed3..140c7c23e 100644 --- a/_test/cases/inc/auth_password.test.php +++ b/_test/cases/inc/auth_password.test.php @@ -16,6 +16,8 @@ class auth_password_test extends UnitTestCase { 'mysql' => '4a1fa3780bd6fd55', 'my411' => '*e5929347e25f82e19e4ebe92f1dc6b6e7c2dbd29', 'kmd5' => 'a579299436d7969791189acadd86fcb716', + 'pmd5' => '$P$abcdefgh1RC6Fd32heUzl7EYCG9uGw.', + 'hmd5' => '$H$abcdefgh1ZbJodHxmeXVAhEzTG7IAp.', ); @@ -39,6 +41,11 @@ class auth_password_test extends UnitTestCase { $this->assertTrue(auth_verifyPassword('foo','$1$$n1rTiFE0nRifwV/43bVon/')); } + function test_verifyPassword_fixedpmd5(){ + $this->assertTrue(auth_verifyPassword('test12345','$P$9IQRaTwmfeRo7ud9Fh4E2PdI0S3r.L0')); + $this->assertTrue(auth_verifyPassword('test12345','$H$9IQRaTwmfeRo7ud9Fh4E2PdI0S3r.L0')); + } + } //Setup VIM: ex: et ts=4 : diff --git a/inc/auth.php b/inc/auth.php index 83d1d4159..5cdcec830 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -937,6 +937,8 @@ function act_resendpwd(){ * mysql - MySQL password (old method) * my411 - MySQL 4.1.1 password * kmd5 - Salted MD5 hashing as used by UNB + * pmd5 - Salted multi iteration MD5 as used by Wordpress + * hmd5 - Same as pmd5 but PhpBB3 flavour * * @author Andreas Gohr * @return string The crypted password @@ -1016,6 +1018,45 @@ function auth_cryptPassword($clear,$method='',$salt=null){ $hash1 = strtolower(md5($key . md5($clear))); $hash2 = substr($hash1, 0, 16) . $key . substr($hash1, 16); return $hash2; + case 'hmd5': + $key = 'H'; + // hmd5 is exactly the same as pmd5, but uses an H as identifier + // PhpBB3 uses it that way, so we just fall through here + case 'pmd5': + if(!$key) $key = 'P'; + $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + $iterc = $salt[0]; // pos 0 of salt is iteration count + $iter = strpos($itoa64,$iterc); + $iter = 1 << $iter; + $salt = substr($salt,1,8); + + // iterate + $hash = md5($salt . $clear, true); + do { + $hash = md5($hash . $clear, true); + } while (--$iter); + + // encode + $output = ''; + $count = 16; + $i = 0; + do { + $value = ord($hash[$i++]); + $output .= $itoa64[$value & 0x3f]; + if ($i < $count) + $value |= ord($hash[$i]) << 8; + $output .= $itoa64[($value >> 6) & 0x3f]; + if ($i++ >= $count) + break; + if ($i < $count) + $value |= ord($hash[$i]) << 16; + $output .= $itoa64[($value >> 12) & 0x3f]; + if ($i++ >= $count) + break; + $output .= $itoa64[($value >> 18) & 0x3f]; + } while ($i < $count); + + return '$'.$key.'$'.$iterc.$salt.$output; default: msg("Unsupported crypt method $method",-1); } @@ -1043,6 +1084,12 @@ function auth_verifyPassword($clear,$crypt){ }elseif(preg_match('/^\$apr1\$([^\$]{0,8})\$/',$crypt,$m)){ $method = 'apr1'; $salt = $m[1]; + }elseif(preg_match('/^\$P\$(.{31})$/',$crypt,$m)){ + $method = 'pmd5'; + $salt = $m[1]; + }elseif(preg_match('/^\$H\$(.{31})$/',$crypt,$m)){ + $method = 'hmd5'; + $salt = $m[1]; }elseif(substr($crypt,0,6) == '{SSHA}'){ $method = 'ssha'; $salt = substr(base64_decode(substr($crypt, 6)),20); From 0c94c420c9dc14fc16700de5cca04959ca38e2c1 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Jan 2011 12:25:58 +0100 Subject: [PATCH 102/110] Added hmd5 and pmd5 as passcrypt choices in config manager --- lib/plugins/config/settings/config.metadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php index f5eb1da18..af7e63a61 100644 --- a/lib/plugins/config/settings/config.metadata.php +++ b/lib/plugins/config/settings/config.metadata.php @@ -122,7 +122,7 @@ $meta['_authentication'] = array('fieldset'); $meta['useacl'] = array('onoff'); $meta['autopasswd'] = array('onoff'); $meta['authtype'] = array('authtype'); -$meta['passcrypt'] = array('multichoice','_choices' => array('smd5','md5','apr1','sha1','ssha','crypt','mysql','my411','kmd5')); +$meta['passcrypt'] = array('multichoice','_choices' => array('smd5','md5','apr1','sha1','ssha','crypt','mysql','my411','kmd5','pmd5','hmd5')); $meta['defaultgroup']= array('string'); $meta['superuser'] = array('string'); $meta['manager'] = array('string'); From b2665af72cdba76ca409b7e00e150746f2f83ced Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 27 Dec 2010 22:53:18 +0100 Subject: [PATCH 103/110] Handle renamed authorization variables Sometimes (when using rewriting with the workaround for CGI mode described at http://www.besthostratings.com/articles/http-auth-php-cgi.html) the HTTP_AUTHORIZATION variable is renamed, this change detects this renaming and uses the renamed variable. --- inc/auth.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/inc/auth.php b/inc/auth.php index 5cdcec830..38d1c925d 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -70,6 +70,12 @@ function auth_setup(){ $_REQUEST['http_credentials'] = false; if (!$conf['rememberme']) $_REQUEST['r'] = false; + // handle renamed HTTP_AUTHORIZATION variable (can happen when a fix like + // the one presented at + // http://www.besthostratings.com/articles/http-auth-php-cgi.html is used + // for enabling HTTP authentication with CGI/SuExec) + if(isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) + $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; // streamline HTTP auth credentials (IIS/rewrite -> mod_php) if(isset($_SERVER['HTTP_AUTHORIZATION'])){ list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = From 278a5eb294b2df859c7eb20c6e35e32280a8b613 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 15 Jan 2011 12:18:09 +0100 Subject: [PATCH 104/110] Remove superfluous headers, fix XML-RPC with gzip enabled This removes headers that are sent by PHP/the webserver anyway as they are possibly wrong as e.g. when gzip compression is enabled in inc/init.php (which does happen when the client supports gzip) the content size is smaller than the one that was specified by the content-length header and thus e.g. the Python XML-RPC client fails with an error message because of the size mismatch. Additionally the content encoding is now set to utf-8 in the http headers. --- inc/IXR_Library.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/inc/IXR_Library.php b/inc/IXR_Library.php index c7f83a6d6..c8255e6d9 100644 --- a/inc/IXR_Library.php +++ b/inc/IXR_Library.php @@ -395,13 +395,8 @@ EOD; $this->output($error->getXml()); } function output($xml) { - $xml = ''."\n".$xml; - $length = strlen($xml); - header('Connection: close'); - header('Content-Length: '.$length); - header('Content-Type: text/xml'); - header('Date: '.date('r')); - echo $xml; + header('Content-Type: text/xml; charset=utf-8'); + echo '', "\n", $xml; exit; } function hasMethod($method) { From 876d3278dce690fbf6a38e29a82e8bad24813fe7 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 16 Jan 2011 11:25:46 +0100 Subject: [PATCH 105/110] Revert "tmp: disable notices in doku.php" This reverts commit 58a22bd0570451af9e62b659343dd47a26bacb3f. It was accidentally pushed to the repo. --- doku.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/doku.php b/doku.php index b0312fb25..d7d270d40 100644 --- a/doku.php +++ b/doku.php @@ -26,7 +26,6 @@ if (isset($_SERVER['HTTP_X_DOKUWIKI_DO'])){ // load and initialize the core system require_once(DOKU_INC.'inc/init.php'); -$old = error_reporting(E_ALL ^ E_NOTICE); //import variables $QUERY = trim($_REQUEST['id']); $ID = getID(); @@ -47,7 +46,6 @@ if (isset($_POST['wikitext'])) { $PRE = cleanText(substr($_POST['prefix'], 0, -1)); $SUF = cleanText($_POST['suffix']); $SUM = $_REQUEST['summary']; -error_reporting($old); //sanitize revision $REV = preg_replace('/[^0-9]/','',$REV); From eff795ac6482d5885761f6688ce183c66becd7e1 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 16 Jan 2011 13:30:49 +0100 Subject: [PATCH 106/110] Fix several security issues in the XML-RPC interface For locks and getRevisions there hasn't been any acl check. In many other cases the id hadn't been cleaned before the acl check was done which means that many acl rules that should be applied weren't applied. So e.g. when you have read permissions for the root namespace but not for a subnamespace you could add a leading ":" and the permissions for the root namespace will be used instead of the permissions for the subnamespace. This did not apply to writing pages and reading media files, but writing and deleting media files have been concerned as well as reading both plain and html versions of pages. This only concerns installations where XML-RPC is enabled (default is disabled) and XML-RPC is allowed for all or untrusted users. --- lib/exe/xmlrpc.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index d232930a3..d40e338b2 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -296,6 +296,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * Return a raw wiki page */ function rawPage($id,$rev=''){ + $id = cleanID($id); if(auth_quickaclcheck($id) < AUTH_READ){ return new IXR_Error(1, 'You are not allowed to read this page'); } @@ -351,6 +352,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * Return a wiki page rendered to html */ function htmlPage($id,$rev=''){ + $id = cleanID($id); if(auth_quickaclcheck($id) < AUTH_READ){ return new IXR_Error(1, 'You are not allowed to read this page'); } @@ -488,6 +490,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * Return some basic data about a page */ function pageInfo($id,$rev=''){ + $id = cleanID($id); if(auth_quickaclcheck($id) < AUTH_READ){ return new IXR_Error(1, 'You are not allowed to read this page'); } @@ -601,6 +604,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * Michael Klier */ function putAttachment($id, $file, $params) { + $id = cleanID($id); global $conf; global $lang; @@ -668,6 +672,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * @author Gina Haeussge */ function deleteAttachment($id){ + $id = cleanID($id); $auth = auth_quickaclcheck(getNS($id).':*'); if($auth < AUTH_DELETE) return new IXR_ERROR(1, "You don't have permissions to delete files."); global $conf; @@ -725,6 +730,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * Returns the permissions of a given wiki page */ function aclCheck($id) { + $id = cleanID($id); return auth_quickaclcheck($id); } @@ -734,13 +740,14 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * @author Michael Klier */ function listLinks($id) { + $id = cleanID($id); if(auth_quickaclcheck($id) < AUTH_READ){ return new IXR_Error(1, 'You are not allowed to read this page'); } $links = array(); // resolve page instructions - $ins = p_cached_instructions(wikiFN(cleanID($id))); + $ins = p_cached_instructions(wikiFN($id)); // instantiate new Renderer - needed for interwiki links include(DOKU_INC.'inc/parser/xhtml.php'); @@ -848,6 +855,10 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * @author Michael Klier */ function pageVersions($id, $first) { + $id = cleanID($id); + if(auth_quickaclcheck($id) < AUTH_READ){ + return new IXR_Error(1, 'You are not allowed to read this page'); + } global $conf; $versions = array(); @@ -923,7 +934,8 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $unlockfail = array(); foreach((array) $set['lock'] as $id){ - if(checklock($id)){ + $id = cleanID($id); + if(auth_quickaclcheck($id) < AUTH_EDIT || checklock($id)){ $lockfail[] = $id; }else{ lock($id); @@ -932,10 +944,11 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { } foreach((array) $set['unlock'] as $id){ - if(unlock($id)){ - $unlocked[] = $id; - }else{ + $id = cleanID($id); + if(auth_quickaclcheck($id) < AUTH_EDIT || !unlock($id)){ $unlockfail[] = $id; + }else{ + $unlocked[] = $id; } } From dbd545d51b77a8684d6790ee5283b520884dd79f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 16 Jan 2011 18:46:26 +0100 Subject: [PATCH 107/110] increased msg count --- doku.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doku.php b/doku.php index d7d270d40..6cd0c0e0c 100644 --- a/doku.php +++ b/doku.php @@ -7,7 +7,7 @@ */ // update message version -$updateVersion = 29; +$updateVersion = 30; // xdebug_start_profiling(); From 1b052f5cb72bee256af579602cbbed59492b2759 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 16 Jan 2011 19:29:03 +0100 Subject: [PATCH 108/110] increase indexer version to reforce rebuild for the new title index --- lib/exe/indexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 58b0d0787..eec8c968c 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -12,7 +12,7 @@ session_write_close(); //close session if(!defined('NL')) define('NL',"\n"); // Version tag used to force rebuild on upgrade -define('INDEXER_VERSION', 2); +define('INDEXER_VERSION', 3); // keep running after browser closes connection @ignore_user_abort(true); From 204b27c8e0c1bcfa6810ee45bd12fda3f5d83960 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 16 Jan 2011 22:23:54 +0100 Subject: [PATCH 109/110] Fix getBaseURL for literal IPv6 addresses in URLs (RFC 2732) + test case --- _test/cases/inc/init_getbaseurl.test.php | 25 ++++++++++++++++++++++++ inc/init.php | 13 ++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/_test/cases/inc/init_getbaseurl.test.php b/_test/cases/inc/init_getbaseurl.test.php index d9c76801f..a22172feb 100644 --- a/_test/cases/inc/init_getbaseurl.test.php +++ b/_test/cases/inc/init_getbaseurl.test.php @@ -275,6 +275,31 @@ class init_getBaseURL_test extends UnitTestCase { $this->assertEqual(getBaseURL(true),$correct_result); } } + + /** + * Absolute URL with IPv6 domain name. + * lighttpd, fastcgi + * + * data provided by Michael Hamann + */ + function test12() { + global $conf; + $conf['basedir'] = ''; + $conf['baseurl'] = ''; + $conf['canonical'] = 0; + + $_SERVER['DOCUMENT_ROOT'] = '/srv/http/'; + $_SERVER['HTTP_HOST'] = '[fd00::6592:39ed:a2ed:2c78]'; + $_SERVER['SCRIPT_FILENAME'] = '/srv/http/~michitux/dokuwiki/doku.php'; + $_SERVER['REQUEST_URI'] = '/~michitux/dokuwiki/doku.php?do=debug'; + $_SERVER['SCRIPT_NAME'] = '/~michitux/dokuwiki/doku.php'; + $_SERVER['PATH_INFO'] = null; + $_SERVER['PATH_TRANSLATED'] = null; + $_SERVER['PHP_SELF'] = '/~michitux/dokuwiki/doku.php'; + $_SERVER['SERVER_PORT'] = '80'; + $_SERVER['SERVER_NAME'] = '[fd00'; + $this->assertEqual(getBaseURL(true), 'http://[fd00::6592:39ed:a2ed:2c78]/~michitux/dokuwiki/'); + } } //Setup VIM: ex: et ts=2 : diff --git a/inc/init.php b/inc/init.php index 3b438f15b..6f4ba1ca9 100644 --- a/inc/init.php +++ b/inc/init.php @@ -420,9 +420,13 @@ function getBaseURL($abs=null){ //split hostheader into host and port if(isset($_SERVER['HTTP_HOST'])){ - list($host,$port) = explode(':',$_SERVER['HTTP_HOST']); + $parsed_host = parse_url('http://'.$_SERVER['HTTP_HOST']); + $host = $parsed_host['host']; + $port = $parsed_host['port']; }elseif(isset($_SERVER['SERVER_NAME'])){ - list($host,$port) = explode(':',$_SERVER['SERVER_NAME']); + $parsed_host = parse_url('http://'.$_SERVER['SERVER_NAME']); + $host = $parsed_host['host']; + $port = $parsed_host['port']; }else{ $host = php_uname('n'); $port = ''; @@ -431,6 +435,11 @@ function getBaseURL($abs=null){ if(!$port && isset($_SERVER['SERVER_PORT'])) { $port = $_SERVER['SERVER_PORT']; } + + if(is_null($port)){ + $port = ''; + } + if(!is_ssl()){ $proto = 'http://'; if ($port == '80') { From 820923f1328bcfe6002831570eb65238411c5b70 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 18 Jan 2011 00:04:41 +0100 Subject: [PATCH 110/110] Revert "tmp" for inc/html.php as it breaks the diff output This reverts commit fa7c70ff4d7f9999466436e7d559eb0c81571779. --- inc/html.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/inc/html.php b/inc/html.php index 67b1c10b7..bd87ee7a1 100644 --- a/inc/html.php +++ b/inc/html.php @@ -876,7 +876,7 @@ function html_diff($text='',$intro=true){ // array in rev2. $rev1 = $REV; - if (is_array($_REQUEST['rev2'])){ + if(is_array($_REQUEST['rev2'])){ $rev1 = (int) $_REQUEST['rev2'][0]; $rev2 = (int) $_REQUEST['rev2'][1]; @@ -948,12 +948,8 @@ function html_diff($text='',$intro=true){ '
'.$l_user.' '.$l_sum; } - $_r_rev = $r_rev; - if (!$_r_rev) { - $_r_rev = @filemtime(wikiFN($ID)); - } - if($_r_rev){ - $r_info = getRevisionInfo($ID,$_r_rev,true); + if($r_rev){ + $r_info = getRevisionInfo($ID,$r_rev,true); if($r_info['user']){ $r_user = editorinfo($r_info['user']); if(auth_ismanager()) $r_user .= ' ('.$r_info['ip'].')';