From c277a6bdf6a2286eadaba9b8ad5c638b9d50922b Mon Sep 17 00:00:00 2001 From: Tom N Harris Date: Thu, 21 Oct 2010 13:20:08 -0400 Subject: Deprecate html_attbuild in favor of buildAttributes --- inc/form.php | 4 ++-- inc/html.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'inc') 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){ -- cgit v1.2.3 From dc9bdeadf4b4eeacd7b6c7a51269a4400e4d25d8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 18 Nov 2010 22:42:42 +0100 Subject: 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(-) (limited to 'inc') 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)) { -- cgit v1.2.3 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: Czech language update --- inc/lang/cs/lang.php | 4 ++-- inc/lang/cs/subscr_form.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'inc') 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 -- cgit v1.2.3 From 11d7187b1b2e7bddc70324b865e01e750c5df162 Mon Sep 17 00:00:00 2001 From: YooS C Date: Thu, 18 Nov 2010 22:47:25 +0100 Subject: 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 ++++++++++++ 8 files changed, 125 insertions(+), 17 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 (limited to 'inc') 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 -- cgit v1.2.3 From 7deca91be61f76ac935c147107c82982252a688a Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Wed, 27 Oct 2010 11:46:27 -0400 Subject: White space fixes only - no functional changes --- inc/DifferenceEngine.php | 167 +++++++++++++++++++++-------------------------- 1 file changed, 75 insertions(+), 92 deletions(-) (limited to 'inc') 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 } } -- cgit v1.2.3 From 812bb04e971a47bee7e0da80d93831f1660efafb Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sat, 20 Nov 2010 11:53:38 +0100 Subject: 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(+) (limited to 'inc') 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 : -- cgit v1.2.3 From 4064e2d30906d01e696c5de106fd9ff356980a93 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sat, 20 Nov 2010 13:13:21 +0100 Subject: Handle do=check before ACL checking --- inc/actions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'inc') 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'] -- cgit v1.2.3 From 85dcda20ffd82becbe69a7ca5d99e4b6fd99c9ea Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sat, 20 Nov 2010 13:17:00 +0100 Subject: Send 403 header for permission denied screens when send404 is enabled --- inc/actions.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'inc') 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 -- cgit v1.2.3 From ba6984cf400bde3cbdd7e1f203602cb0d04eb7d2 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 20 Nov 2010 15:35:17 +0100 Subject: Turkish language update --- inc/lang/tr/lang.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'inc') 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'; -- cgit v1.2.3 From 91d55b797acf64322fa396dbfea34a78ea6b970f Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Sun, 21 Nov 2010 12:16:21 +0100 Subject: First step to upgrade to SimplePie 1.2 --- inc/FeedParser.php | 1 + inc/SimplePie.php | 13380 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 8778 insertions(+), 4603 deletions(-) (limited to 'inc') 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; } - if (isset($_GET[$this->javascript])) + // 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')) { - if (function_exists('ob_gzhandler')) + static $xml_is_sane = null; + if ($xml_is_sane === null) { - ob_start('ob_gzhandler'); + $parser_check = xml_parser_create(); + xml_parse_into_struct($parser_check, '&', $values); + xml_parser_free($parser_check); + $xml_is_sane = isset($values[0]['value']); } - 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(''); -} + if (!$xml_is_sane) + { + return false; + } + } -function embed_wmedia(width, height, link) { - document.writeln(''); -} - javascript])) + { + SimplePie_Misc::output_javascript(); exit; } @@ -1383,7 +1544,7 @@ function embed_wmedia(width, height, link) { // Decide whether to enable caching if ($this->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'; + + // There's no point in trying an encoding twice + $encodings = array_unique($encodings); - $parser = new $this->parser_class(); - $parser->pre_process($data, 'UTF-8'); - // If we want the XML, just output that and quit + // 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)) + + // Loop through each possible encoding, till we return something, or run out of possibilities + foreach ($encodings as $encoding) { - unset($data); - $this->data = $parser->get_data(); - if (isset($this->data['child'])) + // Change the encoding to UTF-8 (as we always use UTF-8 internally) + if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8')) { - if (isset($headers)) - { - $this->data['headers'] = $headers; - } - $this->data['build'] = SIMPLEPIE_BUILD; + // Create new parser + $parser = new $this->parser_class(); - // Cache the file if caching is enabled - if ($cache && !$cache->save($this->data)) + // If it's parsed fine + if ($parser->parse($utf8_data, 'UTF-8')) { - trigger_error("$cache->name is not writeable", E_USER_WARNING); + $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; + } } - return true; - } - 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; } } - // 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,12 +2340,12 @@ function embed_wmedia(width, height, link) { } } - function get_link($key = 0, $rel = 'alternate') + function get_category($key = 0) { - $links = $this->get_links($rel); - if (isset($links[$key])) + $categories = $this->get_categories(); + if (isset($categories[$key])) { - return $links[$key]; + return $categories[$key]; } else { @@ -2183,33 +2353,257 @@ function embed_wmedia(width, height, link) { } } - /** - * Added for parity between the parent-level and the item/entry-level. - */ - function get_permalink() + function get_categories() { - return $this->get_link(0); - } + $categories = array(); - function get_links($rel = 'alternate') - { - if (!isset($this->data['links'])) + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) { - $this->data['links'] = array(); - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) + $term = null; + $scheme = null; + $label = null; + if (isset($category['attribs']['']['term'])) { - 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)); - } - } + $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); } - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) + if (isset($category['attribs']['']['scheme'])) { - foreach ($links as $link) + $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); + 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_channel_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_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) + { + foreach ($links as $link) { if (isset($link['attribs']['']['href'])) { @@ -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)) - { - return SimplePie::merge_items($this->multifeed_objects, $start, $end); - } - elseif (!isset($this->data['items'])) + if (!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')) + { + $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')) { - $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]); + } } } } @@ -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); + return md5($this->get_permalink() . $this->get_title()); } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) + else { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + return md5(serialize($this->data)); } - elseif ($return = $this->get_item_tags('', 'guid')) + } + + function get_title() + { + if (!isset($this->data['title'])) { - 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; - } - else - { - return $this->__toString(); - } - } - - function get_title() - { - if ($return = $this->get_item_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_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; - - // 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'])) + if (isset($content['attribs']['']['url'])) { - $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + // 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; + + // 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'])) - { - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['lang'])) + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) { - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], 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']['']['start'])) + if (is_array($captions)) { - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + $captions = array_values(SimplePie_Misc::array_unique($captions)); } - if (isset($caption['attribs']['']['end'])) + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) { - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], 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['data'])) + if (is_array($captions)) { - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $captions = array_values(SimplePie_Misc::array_unique($captions)); } - $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); } - if (is_array($captions)) + else { - $captions = array_values(SimplePie_Misc::array_unique($captions)); + $captions = $captions_parent; } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) + + // CATEGORIES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) { - $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'])) + foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) { - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], 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($caption['data'])) + } + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) + { + foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) { - $caption_text = $this->sanitize($caption['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); } - $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); } - if (is_array($captions)) + if (is_array($categories) && is_array($categories_parent)) { - $captions = array_values(SimplePie_Misc::array_unique($captions)); + $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)); } - } - else - { - $captions = $captions_parent; - } - // CATEGORIES - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) - { - foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) + // COPYRIGHTS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) { - $term = null; - $scheme = null; - $label = null; - if (isset($category['data'])) + $copyright_url = null; + $copyright_label = null; + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) { - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); } - if (isset($category['attribs']['']['scheme'])) + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) { - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - else + $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'])) { - $scheme = 'http://search.yahoo.com/mrss/category_schema'; + $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); } - if (isset($category['attribs']['']['label'])) + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) { - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $categories[] = new $this->feed->category_class($term, $scheme, $label); + $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); } - } - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) - { - foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) + else { - $term = null; - $scheme = null; - $label = null; - if (isset($category['data'])) + $copyrights = $copyrights_parent; + } + + // CREDITS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) { - $term = $this->sanitize($category['data'], 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($category['attribs']['']['scheme'])) + if (is_array($credits)) { - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + $credits = array_values(SimplePie_Misc::array_unique($credits)); } - else + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) { - $scheme = 'http://search.yahoo.com/mrss/category_schema'; + $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($category['attribs']['']['label'])) + if (is_array($credits)) { - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + $credits = array_values(SimplePie_Misc::array_unique($credits)); } - $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)); - } - - // 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'])) + else { - $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + $credits = $credits_parent; } - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) + + // DESCRIPTION + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) { - $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $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'])) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) { - $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) + else { - $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $description = $description_parent; } - $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) + // HASHES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) { - $credit_role = null; - $credit_scheme = null; - $credit_name = null; - if (isset($credit['attribs']['']['role'])) + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) { - $credit_role = $this->sanitize($credit['attribs']['']['role'], 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($credit['attribs']['']['scheme'])) + if (is_array($hashes)) { - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + $hashes = array_values(SimplePie_Misc::array_unique($hashes)); } - else + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) { - $credit_scheme = 'urn:ebu'; + $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($credit['data'])) + if (is_array($hashes)) { - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $hashes = array_values(SimplePie_Misc::array_unique($hashes)); } - $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); } - if (is_array($credits)) + else { - $credits = array_values(SimplePie_Misc::array_unique($credits)); + $hashes = $hashes_parent; } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) + + // KEYWORDS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) { - $credit_role = null; - $credit_scheme = null; - $credit_name = null; - if (isset($credit['attribs']['']['role'])) + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) { - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords[] = trim($word); + } + unset($temp); } - if (isset($credit['attribs']['']['scheme'])) + if (is_array($keywords)) { - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + $keywords = array_values(SimplePie_Misc::array_unique($keywords)); } - else + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) + { + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) { - $credit_scheme = 'urn:ebu'; + $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 (isset($credit['data'])) + if (is_array($keywords)) { - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $keywords = array_values(SimplePie_Misc::array_unique($keywords)); } - $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); } - if (is_array($credits)) + else { - $credits = array_values(SimplePie_Misc::array_unique($credits)); + $keywords = $keywords_parent; } - } - 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; - } - // HASHES - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) + // PLAYER + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) { - $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; + $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); } - if (is_array($hashes)) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) { - $hashes = array_values(SimplePie_Misc::array_unique($hashes)); + $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); } - } - 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'])) + $player = $player_parent; + } + + // RATINGS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) { - $algo = $this->sanitize($hash['attribs']['']['algo'], 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)) { - $algo = 'md5'; + $ratings = array_values(SimplePie_Misc::array_unique($ratings)); } - $hashes[] = $algo.':'.$value; - } - 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'])) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) { - $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - foreach ($temp as $word) + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) { - $keywords[] = trim($word); + $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); } - 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($ratings)) { - $keywords[] = trim($word); + $ratings = array_values(SimplePie_Misc::array_unique($ratings)); } - unset($temp); } - if (is_array($keywords)) + else { - $keywords = array_values(SimplePie_Misc::array_unique($keywords)); + $ratings = $ratings_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; - } - // RATINGS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) + // RESTRICTIONS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) { - $rating_scheme = null; - $rating_value = null; - if (isset($rating['attribs']['']['scheme'])) - { - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) { - $rating_scheme = 'urn:simple'; + $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($rating['data'])) + if (is_array($restrictions)) { - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); } - $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) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) { - $rating_scheme = null; - $rating_value = null; - if (isset($rating['attribs']['']['scheme'])) - { - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) { - $rating_scheme = 'urn:simple'; + $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($rating['data'])) + if (is_array($restrictions)) { - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); } - $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); } - if (is_array($ratings)) + else { - $ratings = array_values(SimplePie_Misc::array_unique($ratings)); + $restrictions = $restrictions_parent; } - } - else - { - $ratings = $ratings_parent; - } - // RESTRICTIONS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) + // THUMBNAILS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) { - $restriction_relationship = null; - $restriction_type = null; - $restriction_value = null; - if (isset($restriction['attribs']['']['relationship'])) + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) { - $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); + $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); } - if (isset($restriction['data'])) + if (is_array($thumbnails)) { - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); } - $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) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) { - $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'])) + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) { - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); } - if (isset($restriction['data'])) + if (is_array($thumbnails)) { - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); } - $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); } - if (is_array($restrictions)) + else { - $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); + $thumbnails = $thumbnails_parent; } - } - else - { - $restrictions = $restrictions_parent; - } - // THUMBNAILS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) - { - $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - if (is_array($thumbnails)) + // TITLES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) { - $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); + $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) { - $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - if (is_array($thumbnails)) + else { - $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); + $title = $title_parent; } - } - 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; + $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,224 +5727,78 @@ class SimplePie_Item } } -class SimplePie_Author +class SimplePie_Source { - var $name; - var $link; - var $email; + var $item; + var $data = array(); - // Constructor, used to input the data - function SimplePie_Author($name = null, $link = null, $email = null) + function SimplePie_Source($item, $data) { - $this->name = $name; - $this->link = $link; - $this->email = $email; + $this->item = $item; + $this->data = $data; } function __toString() { - // There is no $this->data here - return md5(serialize($this)); - } - - function get_name() - { - if ($this->name !== null) - { - return $this->name; - } - else - { - return null; - } - } - - function get_link() - { - if ($this->link !== null) - { - return $this->link; - } - else - { - return null; - } + return md5(serialize($this->data)); } - function get_email() + function get_source_tags($namespace, $tag) { - if ($this->email !== null) + if (isset($this->data['child'][$namespace][$tag])) { - return $this->email; + return $this->data['child'][$namespace][$tag]; } else { return null; } } -} - -class SimplePie_Category -{ - var $term; - var $scheme; - var $label; - - // Constructor, used to input the data - function SimplePie_Category($term = null, $scheme = null, $label = null) - { - $this->term = $term; - $this->scheme = $scheme; - $this->label = $label; - } - function __toString() + function get_base($element = array()) { - // There is no $this->data here - return md5(serialize($this)); + return $this->item->get_base($element); } - function get_term() + function sanitize($data, $type, $base = '') { - if ($this->term !== null) - { - return $this->term; - } - else - { - return null; - } + return $this->item->sanitize($data, $type, $base); } - function get_scheme() + function get_item() { - if ($this->scheme !== null) - { - return $this->scheme; - } - else - { - return null; - } + return $this->item; } - function get_label() + function get_title() { - if ($this->label !== null) - { - return $this->label; - } - else + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) { - return $this->get_term(); + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); } - } -} - -class SimplePie_Enclosure -{ - var $bitrate; - var $captions; - var $categories; - var $channels; - var $copyright; - var $credits; - var $description; - var $duration; - var $expression; - var $framerate; - var $handler; - var $hashes; - var $height; - var $javascript; - var $keywords; - var $lang; - var $length; - var $link; - var $medium; - var $player; - var $ratings; - var $restrictions; - var $samplingrate; - var $thumbnails; - var $title; - var $type; - var $width; - - // Constructor, used to input the data - function SimplePie_Enclosure($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null) - { - $this->bitrate = $bitrate; - $this->captions = $captions; - $this->categories = $categories; - $this->channels = $channels; - $this->copyright = $copyright; - $this->credits = $credits; - $this->description = $description; - $this->duration = $duration; - $this->expression = $expression; - $this->framerate = $framerate; - $this->hashes = $hashes; - $this->height = $height; - $this->javascript = $javascript; - $this->keywords = $keywords; - $this->lang = $lang; - $this->length = $length; - $this->link = $link; - $this->medium = $medium; - $this->player = $player; - $this->ratings = $ratings; - $this->restrictions = $restrictions; - $this->samplingrate = $samplingrate; - $this->thumbnails = $thumbnails; - $this->title = $title; - $this->type = $type; - $this->width = $width; - if (class_exists('idna_convert')) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) { - $idn = new idna_convert; - $parsed = SimplePie_Misc::parse_url($link); - $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); } - $this->handler = $this->get_handler(); // Needs to load last - } - - function __toString() - { - // There is no $this->data here - return md5(serialize($this)); - } - - function get_bitrate() - { - if ($this->bitrate !== null) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) { - return $this->bitrate; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - else + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) { - return null; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - } - - function get_caption($key = 0) - { - $captions = $this->get_captions(); - if (isset($captions[$key])) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { - return $captions[$key]; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - else + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) { - return null; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - } - - function get_captions() - { - if ($this->captions !== null) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) { - return $this->captions; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } else { @@ -5371,46 +5821,54 @@ class SimplePie_Enclosure function get_categories() { - if ($this->categories !== null) - { - return $this->categories; - } - else - { - return null; - } - } + $categories = array(); - function get_channels() - { - if ($this->channels !== null) + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) { - return $this->channels; + $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); } - else + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) { - return 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->item->feed->category_class($term, $scheme, null); } - } - - function get_copyright() - { - if ($this->copyright !== null) + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) { - return $this->copyright; + $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } - else + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) { - return null; + $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } - } - function get_credit($key = 0) - { - $credits = $this->get_credits(); - if (isset($credits[$key])) + if (!empty($categories)) { - return $credits[$key]; + return SimplePie_Misc::array_unique($categories); } else { @@ -5418,11 +5876,12 @@ class SimplePie_Enclosure } } - function get_credits() + function get_author($key = 0) { - if ($this->credits !== null) + $authors = $this->get_authors(); + if (isset($authors[$key])) { - return $this->credits; + return $authors[$key]; } else { @@ -5430,68 +5889,140 @@ class SimplePie_Enclosure } } - function get_description() + function get_authors() { - if ($this->description !== null) - { - return $this->description; - } - else + $authors = array(); + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) { - return null; + $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); + } } - } - - function get_duration($convert = false) - { - if ($this->duration !== null) + if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) { - if ($convert) + $name = null; + $url = null; + $email = null; + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) { - $time = SimplePie_Misc::time_hms($this->duration); - return $time; + $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - else + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) { - return $this->duration; + $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_expression() + function get_contributor($key = 0) { - if ($this->expression !== null) + $contributors = $this->get_contributors(); + if (isset($contributors[$key])) { - return $this->expression; + return $contributors[$key]; } else { - return 'full'; + return null; } } - function get_extension() + function get_contributors() { - if ($this->link !== null) + $contributors = array(); + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) { - $url = SimplePie_Misc::parse_url($this->link); - if ($url['path'] !== '') + $name = null; + $uri = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) { - return pathinfo($url['path'], PATHINFO_EXTENSION); + $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); } } - return null; - } - function get_framerate() - { - if ($this->framerate !== null) + if (!empty($contributors)) { - return $this->framerate; + return SimplePie_Misc::array_unique($contributors); } else { @@ -5499,17 +6030,12 @@ class SimplePie_Enclosure } } - function get_handler() - { - return $this->get_real_type(true); - } - - function get_hash($key = 0) + function get_link($key = 0, $rel = 'alternate') { - $hashes = $this->get_hashes(); - if (isset($hashes[$key])) + $links = $this->get_links($rel); + if (isset($links[$key])) { - return $hashes[$key]; + return $links[$key]; } else { @@ -5517,11 +6043,81 @@ class SimplePie_Enclosure } } - function get_hashes() + /** + * Added for parity between the parent-level and the item/entry-level. + */ + function get_permalink() { - if ($this->hashes !== null) + return $this->get_link(0); + } + + function get_links($rel = 'alternate') + { + if (!isset($this->data['links'])) { - return $this->hashes; + $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 { @@ -5529,60 +6125,43 @@ class SimplePie_Enclosure } } - function get_height() + function get_description() { - if ($this->height !== null) + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) { - return $this->height; + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); } - else + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) { - return null; + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); } - } - - function get_language() - { - if ($this->lang !== null) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) { - return $this->lang; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - else + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) { - return null; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - } - - function get_keyword($key = 0) - { - $keywords = $this->get_keywords(); - if (isset($keywords[$key])) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) { - return $keywords[$key]; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - else + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) { - return null; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - } - - function get_keywords() - { - if ($this->keywords !== null) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) { - return $this->keywords; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - else + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) { - return null; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); } - } - - function get_length() - { - if ($this->length !== null) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) { - return $this->length; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); } else { @@ -5590,35 +6169,27 @@ class SimplePie_Enclosure } } - function get_link() + function get_copyright() { - if ($this->link !== null) + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) { - return urldecode($this->link); + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); } - else + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) { - return null; + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); } - } - - function get_medium() - { - if ($this->medium !== null) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) { - return $this->medium; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - else + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) { - return null; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - } - - function get_player() - { - if ($this->player !== null) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) { - return $this->player; + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } else { @@ -5626,12 +6197,23 @@ class SimplePie_Enclosure } } - function get_rating($key = 0) + function get_language() { - $ratings = $this->get_ratings(); - if (isset($ratings[$key])) + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) { - return $ratings[$key]; + 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 { @@ -5639,11 +6221,15 @@ class SimplePie_Enclosure } } - function get_ratings() + function get_latitude() { - if ($this->ratings !== null) + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) { - return $this->ratings; + 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 { @@ -5651,12 +6237,19 @@ class SimplePie_Enclosure } } - function get_restriction($key = 0) + function get_longitude() { - $restrictions = $this->get_restrictions(); - if (isset($restrictions[$key])) + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) { - return $restrictions[$key]; + 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 { @@ -5664,23 +6257,52 @@ class SimplePie_Enclosure } } - function get_restrictions() + function get_image_url() { - if ($this->restrictions !== null) + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) { - return $this->restrictions; + 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; } } +} - function get_sampling_rate() +class SimplePie_Author +{ + var $name; + var $link; + var $email; + + // Constructor, used to input the data + function SimplePie_Author($name = null, $link = null, $email = null) { - if ($this->samplingrate !== null) + $this->name = $name; + $this->link = $link; + $this->email = $email; + } + + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + function get_name() + { + if ($this->name !== null) { - return $this->samplingrate; + return $this->name; } else { @@ -5688,12 +6310,11 @@ class SimplePie_Enclosure } } - function get_size() + function get_link() { - $length = $this->get_length(); - if ($length !== null) + if ($this->link !== null) { - return round($length/1048576, 2); + return $this->link; } else { @@ -5701,24 +6322,44 @@ class SimplePie_Enclosure } } - function get_thumbnail($key = 0) + function get_email() { - $thumbnails = $this->get_thumbnails(); - if (isset($thumbnails[$key])) + if ($this->email !== null) { - return $thumbnails[$key]; + return $this->email; } else { return null; } } +} - function get_thumbnails() +class SimplePie_Category +{ + var $term; + var $scheme; + var $label; + + // Constructor, used to input the data + function SimplePie_Category($term = null, $scheme = null, $label = null) { - if ($this->thumbnails !== null) + $this->term = $term; + $this->scheme = $scheme; + $this->label = $label; + } + + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + function get_term() + { + if ($this->term !== null) { - return $this->thumbnails; + return $this->term; } else { @@ -5726,11 +6367,11 @@ class SimplePie_Enclosure } } - function get_title() + function get_scheme() { - if ($this->title !== null) + if ($this->scheme !== null) { - return $this->title; + return $this->scheme; } else { @@ -5738,23 +6379,98 @@ class SimplePie_Enclosure } } - function get_type() + function get_label() { - if ($this->type !== null) + if ($this->label !== null) { - return $this->type; + return $this->label; } else { - return null; + return $this->get_term(); } } +} - function get_width() +class SimplePie_Enclosure +{ + var $bitrate; + var $captions; + var $categories; + var $channels; + var $copyright; + var $credits; + var $description; + var $duration; + var $expression; + var $framerate; + var $handler; + var $hashes; + var $height; + var $javascript; + var $keywords; + var $lang; + var $length; + var $link; + var $medium; + var $player; + var $ratings; + var $restrictions; + var $samplingrate; + var $thumbnails; + var $title; + var $type; + var $width; + + // Constructor, used to input the data + function SimplePie_Enclosure($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null) { - if ($this->width !== null) + $this->bitrate = $bitrate; + $this->captions = $captions; + $this->categories = $categories; + $this->channels = $channels; + $this->copyright = $copyright; + $this->credits = $credits; + $this->description = $description; + $this->duration = $duration; + $this->expression = $expression; + $this->framerate = $framerate; + $this->hashes = $hashes; + $this->height = $height; + $this->javascript = $javascript; + $this->keywords = $keywords; + $this->lang = $lang; + $this->length = $length; + $this->link = $link; + $this->medium = $medium; + $this->player = $player; + $this->ratings = $ratings; + $this->restrictions = $restrictions; + $this->samplingrate = $samplingrate; + $this->thumbnails = $thumbnails; + $this->title = $title; + $this->type = $type; + $this->width = $width; + if (class_exists('idna_convert')) { - return $this->width; + $idn = new idna_convert; + $parsed = SimplePie_Misc::parse_url($link); + $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); + } + $this->handler = $this->get_handler(); // Needs to load last + } + + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + function get_bitrate() + { + if ($this->bitrate !== null) + { + return $this->bitrate; } else { @@ -5762,471 +6478,185 @@ class SimplePie_Enclosure } } - function native_embed($options='') + function get_caption($key = 0) { - return $this->embed($options, true); + $captions = $this->get_captions(); + if (isset($captions[$key])) + { + return $captions[$key]; + } + else + { + return null; + } } - /** - * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'. - */ - function embed($options = '', $native = false) + function get_captions() { - // Set up defaults - $audio = ''; - $video = ''; - $alt = ''; - $altclass = ''; - $loop = 'false'; - $width = 'auto'; - $height = 'auto'; - $bgcolor = '#ffffff'; - $mediaplayer = ''; - $widescreen = false; - $handler = $this->get_handler(); - $type = $this->get_real_type(); - - // Process options and reassign values as necessary - if (is_array($options)) + if ($this->captions !== null) { - extract($options); + return $this->captions; } else { - $options = explode(',', $options); - foreach($options as $option) - { - $opt = explode(':', $option, 2); - if (isset($opt[0], $opt[1])) - { - $opt[0] = trim($opt[0]); - $opt[1] = trim($opt[1]); - switch ($opt[0]) - { - case 'audio': - $audio = $opt[1]; - break; + return null; + } + } - case 'video': - $video = $opt[1]; - break; - - case 'alt': - $alt = $opt[1]; - break; - - case 'altclass': - $altclass = $opt[1]; - break; - - case 'loop': - $loop = $opt[1]; - break; - - case 'width': - $width = $opt[1]; - break; - - case 'height': - $height = $opt[1]; - break; - - case 'bgcolor': - $bgcolor = $opt[1]; - break; - - case 'mediaplayer': - $mediaplayer = $opt[1]; - break; - - case 'widescreen': - $widescreen = $opt[1]; - break; - } - } - } + function get_category($key = 0) + { + $categories = $this->get_categories(); + if (isset($categories[$key])) + { + return $categories[$key]; } - - $mime = explode('/', $type, 2); - $mime = $mime[0]; - - // Process values for 'auto' - if ($width == 'auto') + else { - if ($mime == 'video') - { - if ($height == 'auto') - { - $width = 480; - } - elseif ($widescreen) - { - $width = round((intval($height)/9)*16); - } - else - { - $width = round((intval($height)/3)*4); - } - } - else - { - $width = '100%'; - } + return null; } + } - if ($height == 'auto') + function get_categories() + { + if ($this->categories !== null) { - if ($mime == 'audio') - { - $height = 0; - } - elseif ($mime == 'video') - { - if ($width == 'auto') - { - if ($widescreen) - { - $height = 270; - } - else - { - $height = 360; - } - } - elseif ($widescreen) - { - $height = round((intval($width)/16)*9); - } - else - { - $height = round((intval($width)/4)*3); - } - } - else - { - $height = 376; - } + return $this->categories; } - elseif ($mime == 'audio') + else { - $height = 0; + return null; } + } - // Set proper placeholder value - if ($mime == 'audio') + function get_channels() + { + if ($this->channels !== null) { - $placeholder = $audio; + return $this->channels; } - elseif ($mime == 'video') + else { - $placeholder = $video; + return null; } + } - $embed = ''; - - // Make sure the JS library is included - if (!$native) + function get_copyright() + { + if ($this->copyright !== null) { - static $javascript_outputted = null; - if (!$javascript_outputted && $this->javascript) - { - $embed .= ''; - $javascript_outputted = true; - } + return $this->copyright; } - - // Odeo Feed MP3's - if ($handler == 'odeo') + else { - if ($native) - { - $embed .= ''; - } - else - { - $embed .= ''; - } + return null; } + } - // Flash - elseif ($handler == 'flash') + function get_credit($key = 0) + { + $credits = $this->get_credits(); + if (isset($credits[$key])) { - if ($native) - { - $embed .= "get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\">"; - } - else - { - $embed .= ""; - } + return $credits[$key]; + } + else + { + return null; } + } - // Flash Media Player file types. - // Preferred handler for MP3 file types. - elseif ($handler == 'fmedia' || ($handler == 'mp3' && $mediaplayer != '')) + function get_credits() + { + if ($this->credits !== null) { - $height += 20; - if ($native) - { - $embed .= "get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\">"; - } - else - { - $embed .= ""; - } + return $this->credits; + } + else + { + return null; } + } - // 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 == '')) + function get_description() + { + if ($this->description !== null) { - $height += 16; - if ($native) - { - 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 { - $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/\">"; - } - } - else - { - $embed .= ""; - } + return $this->description; + } + else + { + return null; } + } - // Windows Media - elseif ($handler == 'wmedia') + function get_duration($convert = false) + { + if ($this->duration !== null) { - $height += 45; - if ($native) + if ($convert) { - $embed .= "get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\">"; + $time = SimplePie_Misc::time_hms($this->duration); + return $time; } else { - $embed .= ""; + return $this->duration; } } - - // Everything else - else $embed .= '' . $alt . ''; - - return $embed; - } - - 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') + else { - return 'odeo'; + return null; } + } - // 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_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 - - if ($this->get_type() !== null) + function get_expression() + { + if ($this->expression !== null) { - $type = strtolower($this->type); + return $this->expression; } else { - $type = null; + return 'full'; } + } - // If we encounter an unsupported mime-type, check the file extension and guess intelligently. - if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3))) + function get_extension() + { + if ($this->link !== null) { - switch (strtolower($this->get_extension())) + $url = SimplePie_Misc::parse_url($this->link); + if ($url['path'] !== '') { - // Audio mime-types - case 'aac': - case 'adts': - $type = 'audio/acc'; - break; - - case 'aif': - case 'aifc': - case 'aiff': - case 'cdda': - $type = 'audio/aiff'; - break; - - case 'bwf': - $type = 'audio/wav'; - break; - - case 'kar': - case 'mid': - case 'midi': - case 'smf': - $type = 'audio/midi'; - break; - - case 'm4a': - $type = 'audio/x-m4a'; - break; - - case 'mp3': - case 'swa': - $type = 'audio/mp3'; - break; - - case 'wav': - $type = 'audio/wav'; - break; - - case 'wax': - $type = 'audio/x-ms-wax'; - break; - - case 'wma': - $type = 'audio/x-ms-wma'; - break; - - // Video mime-types - case '3gp': - case '3gpp': - $type = 'video/3gpp'; - break; - - case '3g2': - case '3gp2': - $type = 'video/3gpp2'; - break; - - case 'asf': - $type = 'video/x-ms-asf'; - break; - - case 'flv': - $type = 'video/x-flv'; - break; - - case 'm1a': - case 'm1s': - case 'm1v': - case 'm15': - case 'm75': - case 'mp2': - case 'mpa': - case 'mpeg': - case 'mpg': - case 'mpm': - case 'mpv': - $type = 'video/mpeg'; - break; - - case 'm4v': - $type = 'video/x-m4v'; - break; - - case 'mov': - case 'qt': - $type = 'video/quicktime'; - break; - - case 'mp4': - case 'mpg4': - $type = 'video/mp4'; - break; - - case 'sdv': - $type = 'video/sd-video'; - break; - - case 'wm': - $type = 'video/x-ms-wm'; - break; - - case 'wmv': - $type = 'video/x-ms-wmv'; - break; - - case 'wvx': - $type = 'video/x-ms-wvx'; - break; - - // Flash mime-types - case 'spl': - $type = 'application/futuresplash'; - break; - - case 'swf': - $type = 'application/x-shockwave-flash'; - break; + return pathinfo($url['path'], PATHINFO_EXTENSION); } } + return null; + } - if ($find_handler) + function get_framerate() + { + if ($this->framerate !== null) { - if (in_array($type, $types_flash)) - { - return 'flash'; - } - elseif (in_array($type, $types_fmedia)) - { - return 'fmedia'; - } - elseif (in_array($type, $types_quicktime)) - { - return 'quicktime'; - } - elseif (in_array($type, $types_wmedia)) - { - return 'wmedia'; - } - elseif (in_array($type, $types_mp3)) - { - return 'mp3'; - } - else - { - return null; - } + return $this->framerate; } else { - return $type; + return null; } } -} - -class SimplePie_Caption -{ - var $type; - var $lang; - var $startTime; - var $endTime; - var $text; - - // Constructor, used to input the data - function SimplePie_Caption($type = null, $lang = null, $startTime = null, $endTime = null, $text = null) - { - $this->type = $type; - $this->lang = $lang; - $this->startTime = $startTime; - $this->endTime = $endTime; - $this->text = $text; - } - function __toString() + function get_handler() { - // There is no $this->data here - return md5(serialize($this)); + return $this->get_real_type(true); } - function get_endtime() + function get_hash($key = 0) { - if ($this->endTime !== null) + $hashes = $this->get_hashes(); + if (isset($hashes[$key])) { - return $this->endTime; + return $hashes[$key]; } else { @@ -6234,11 +6664,11 @@ class SimplePie_Caption } } - function get_language() + function get_hashes() { - if ($this->language !== null) + if ($this->hashes !== null) { - return $this->language; + return $this->hashes; } else { @@ -6246,11 +6676,11 @@ class SimplePie_Caption } } - function get_starttime() + function get_height() { - if ($this->startTime !== null) + if ($this->height !== null) { - return $this->startTime; + return $this->height; } else { @@ -6258,11 +6688,11 @@ class SimplePie_Caption } } - function get_text() + function get_language() { - if ($this->text !== null) + if ($this->lang !== null) { - return $this->text; + return $this->lang; } else { @@ -6270,44 +6700,48 @@ class SimplePie_Caption } } - function get_type() + function get_keyword($key = 0) { - if ($this->type !== null) + $keywords = $this->get_keywords(); + if (isset($keywords[$key])) { - return $this->type; + return $keywords[$key]; } else { return null; } } -} -class SimplePie_Credit -{ - var $role; - var $scheme; - var $name; - - // Constructor, used to input the data - function SimplePie_Credit($role = null, $scheme = null, $name = null) + function get_keywords() { - $this->role = $role; - $this->scheme = $scheme; - $this->name = $name; + if ($this->keywords !== null) + { + return $this->keywords; + } + else + { + return null; + } } - function __toString() + function get_length() { - // There is no $this->data here - return md5(serialize($this)); + if ($this->length !== null) + { + return $this->length; + } + else + { + return null; + } } - function get_role() + function get_link() { - if ($this->role !== null) + if ($this->link !== null) { - return $this->role; + return urldecode($this->link); } else { @@ -6315,11 +6749,11 @@ class SimplePie_Credit } } - function get_scheme() + function get_medium() { - if ($this->scheme !== null) + if ($this->medium !== null) { - return $this->scheme; + return $this->medium; } else { @@ -6327,42 +6761,24 @@ class SimplePie_Credit } } - function get_name() + function get_player() { - if ($this->name !== null) + if ($this->player !== null) { - return $this->name; + return $this->player; } else { return null; } } -} - -class SimplePie_Copyright -{ - var $url; - var $label; - // Constructor, used to input the data - function SimplePie_Copyright($url = null, $label = null) - { - $this->url = $url; - $this->label = $label; - } - - function __toString() - { - // There is no $this->data here - return md5(serialize($this)); - } - - function get_url() + function get_rating($key = 0) { - if ($this->url !== null) + $ratings = $this->get_ratings(); + if (isset($ratings[$key])) { - return $this->url; + return $ratings[$key]; } else { @@ -6370,42 +6786,48 @@ class SimplePie_Copyright } } - function get_attribution() + function get_ratings() { - if ($this->label !== null) + if ($this->ratings !== null) { - return $this->label; + return $this->ratings; } else { return null; } } -} - -class SimplePie_Rating -{ - var $scheme; - var $value; - // Constructor, used to input the data - function SimplePie_Rating($scheme = null, $value = null) + function get_restriction($key = 0) { - $this->scheme = $scheme; - $this->value = $value; + $restrictions = $this->get_restrictions(); + if (isset($restrictions[$key])) + { + return $restrictions[$key]; + } + else + { + return null; + } } - function __toString() + function get_restrictions() { - // There is no $this->data here - return md5(serialize($this)); + if ($this->restrictions !== null) + { + return $this->restrictions; + } + else + { + return null; + } } - function get_scheme() + function get_sampling_rate() { - if ($this->scheme !== null) + if ($this->samplingrate !== null) { - return $this->scheme; + return $this->samplingrate; } else { @@ -6413,44 +6835,49 @@ class SimplePie_Rating } } - function get_value() + function get_size() { - if ($this->value !== null) + $length = $this->get_length(); + if ($length !== null) { - return $this->value; + return round($length/1048576, 2); } else { return null; } } -} -class SimplePie_Restriction -{ - var $relationship; - var $type; - var $value; - - // Constructor, used to input the data - function SimplePie_Restriction($relationship = null, $type = null, $value = null) + function get_thumbnail($key = 0) { - $this->relationship = $relationship; - $this->type = $type; - $this->value = $value; + $thumbnails = $this->get_thumbnails(); + if (isset($thumbnails[$key])) + { + return $thumbnails[$key]; + } + else + { + return null; + } } - function __toString() + function get_thumbnails() { - // There is no $this->data here - return md5(serialize($this)); + if ($this->thumbnails !== null) + { + return $this->thumbnails; + } + else + { + return null; + } } - function get_relationship() + function get_title() { - if ($this->relationship !== null) + if ($this->title !== null) { - return $this->relationship; + return $this->title; } else { @@ -6470,3352 +6897,6923 @@ class SimplePie_Restriction } } - function get_value() + function get_width() { - if ($this->value !== null) + if ($this->width !== null) { - return $this->value; + return $this->width; } else { return null; } } -} -/** - * @todo Move to properly supporting RFC2616 (HTTP/1.1) - */ -class SimplePie_File -{ - var $url; - var $useragent; - var $success = true; - var $headers = array(); - var $body; - var $status_code; - var $redirects = 0; - var $error; - var $method; + function native_embed($options='') + { + return $this->embed($options, true); + } - function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) + /** + * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'. + */ + function embed($options = '', $native = false) { - if (class_exists('idna_convert')) + // Set up defaults + $audio = ''; + $video = ''; + $alt = ''; + $altclass = ''; + $loop = 'false'; + $width = 'auto'; + $height = 'auto'; + $bgcolor = '#ffffff'; + $mediaplayer = ''; + $widescreen = false; + $handler = $this->get_handler(); + $type = $this->get_real_type(); + + // Process options and reassign values as necessary + if (is_array($options)) { - $idn = new idna_convert; - $parsed = SimplePie_Misc::parse_url($url); - $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); + extract($options); } - $this->url = $url; - $this->useragent = $useragent; - if (preg_match('/^http(s)?:\/\//i', $url)) + else { - if ($useragent === null) - { - $useragent = ini_get('user_agent'); - $this->useragent = $useragent; - } - if (!is_array($headers)) + $options = explode(',', $options); + foreach($options as $option) { - $headers = array(); + $opt = explode(':', $option, 2); + if (isset($opt[0], $opt[1])) + { + $opt[0] = trim($opt[0]); + $opt[1] = trim($opt[1]); + switch ($opt[0]) + { + case 'audio': + $audio = $opt[1]; + break; + + case 'video': + $video = $opt[1]; + break; + + case 'alt': + $alt = $opt[1]; + break; + + case 'altclass': + $altclass = $opt[1]; + break; + + case 'loop': + $loop = $opt[1]; + break; + + case 'width': + $width = $opt[1]; + break; + + case 'height': + $height = $opt[1]; + break; + + case 'bgcolor': + $bgcolor = $opt[1]; + break; + + case 'mediaplayer': + $mediaplayer = $opt[1]; + break; + + case 'widescreen': + $widescreen = $opt[1]; + break; + } + } } - if (!$force_fsockopen && extension_loaded('curl')) + } + + $mime = explode('/', $type, 2); + $mime = $mime[0]; + + // Process values for 'auto' + if ($width === 'auto') + { + if ($mime === 'video') { - $this->method = 'curl'; - $fp = curl_init(); - $headers2 = array(); - foreach ($headers as $key => $value) + if ($height === 'auto') { - $headers2[] = "$key: $value"; + $width = 480; } - if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) + elseif ($widescreen) { - curl_setopt($fp, CURLOPT_ENCODING, ''); + $width = round((intval($height)/9)*16); } - curl_setopt($fp, CURLOPT_URL, $url); - curl_setopt($fp, CURLOPT_HEADER, 1); - curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($fp, CURLOPT_TIMEOUT, $timeout); - curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout); - curl_setopt($fp, CURLOPT_REFERER, $url); - curl_setopt($fp, CURLOPT_USERAGENT, $useragent); - curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); - if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) + else { - curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); - curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); - } - - $this->headers = curl_exec($fp); - if (curl_errno($fp) == 23 || curl_errno($fp) == 61) - { - curl_setopt($fp, CURLOPT_ENCODING, 'none'); - $this->headers = curl_exec($fp); - } - if (curl_errno($fp)) - { - $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); - $this->success = false; - } - else - { - $info = curl_getinfo($fp); - curl_close($fp); - $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); - $this->headers = array_pop($this->headers); - $parser = new SimplePie_HTTP_Parser($this->headers); - if ($parser->parse()) - { - $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) - { - $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); - } - return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); - } - } + $width = round((intval($height)/3)*4); } } else { - $this->method = 'fsockopen'; - $url_parts = parse_url($url); - if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) == 'https') - { - $url_parts['host'] = "ssl://$url_parts[host]"; - $url_parts['port'] = 443; - } - if (!isset($url_parts['port'])) - { - $url_parts['port'] = 80; - } - $fp = fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout); - if (!$fp) - { - $this->error = 'fsockopen error: ' . $errstr; - $this->success = false; - } - else + $width = '100%'; + } + } + + if ($height === 'auto') + { + if ($mime === 'audio') + { + $height = 0; + } + elseif ($mime === 'video') + { + if ($width === 'auto') { - if (function_exists('stream_set_timeout')) - { - stream_set_timeout($fp, $timeout); - } - else - { - socket_set_timeout($fp, $timeout); - } - if (isset($url_parts['path'])) + if ($widescreen) { - if (isset($url_parts['query'])) - { - $get = "$url_parts[path]?$url_parts[query]"; - } - else - { - $get = $url_parts['path']; - } + $height = 270; } else { - $get = '/'; - } - $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')) - { - $out .= "Accept-Encoding: gzip,deflate\r\n"; + $height = 360; } + } + elseif ($widescreen) + { + $height = round((intval($width)/16)*9); + } + else + { + $height = round((intval($width)/4)*3); + } + } + else + { + $height = 376; + } + } + elseif ($mime === 'audio') + { + $height = 0; + } - if (isset($url_parts['user']) && isset($url_parts['pass'])) - { - $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n"; - } - foreach ($headers as $key => $value) - { - $out .= "$key: $value\r\n"; - } - $out .= "Connection: Close\r\n\r\n"; - fwrite($fp, $out); + // Set proper placeholder value + if ($mime === 'audio') + { + $placeholder = $audio; + } + elseif ($mime === 'video') + { + $placeholder = $video; + } - if (function_exists('stream_get_meta_data')) - { - $info = stream_get_meta_data($fp); - } - else - { - $info = socket_get_status($fp); - } + $embed = ''; - $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); - } - } - if (!$info['timed_out']) - { - $parser = new SimplePie_HTTP_Parser($this->headers); - if ($parser->parse()) - { - $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) - { - $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); - } - 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 (substr($this->body, 0, 8) == "\x1f\x8b\x08\x00\x00\x00\x00\x00") - { - $this->body = substr($this->body, 10); - } - $this->body = gzinflate($this->body); - } - } - } - else - { - $this->error = 'fsocket timed out'; - $this->success = false; - } - fclose($fp); - } + // Make sure the JS library is included + if (!$native) + { + static $javascript_outputted = null; + if (!$javascript_outputted && $this->javascript) + { + $embed .= ''; + $javascript_outputted = true; } } - elseif (function_exists('file_get_contents')) + + // Odeo Feed MP3's + if ($handler === 'odeo') { - $this->method = 'file_get_contents'; - if (!$this->body = file_get_contents($url)) + if ($native) { - $this->error = 'file_get_contents could not read the file'; - $this->success = false; + $embed .= ''; + } + else + { + $embed .= ''; } } - else + + // Flash + elseif ($handler === 'flash') { - $this->method = 'fopen'; - if (($fp = fopen($url, 'rb')) === false) + if ($native) { - $this->error = 'failed to open stream: No such file or directory'; - $this->success = false; + $embed .= "get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\">"; + } + else + { + $embed .= ""; + } + } + + // Flash Media Player file types. + // Preferred handler for MP3 file types. + elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) + { + $height += 20; + if ($native) + { + $embed .= "get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\">"; } else { - $this->body = ''; - while (!feof($fp)) + $embed .= ""; + } + } + + // 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 === '')) + { + $height += 16; + if ($native) + { + if ($placeholder !== '') { - $this->body .= fread($fp, 8192); + $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 + { + $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/\">"; } - fclose($fp); + } + else + { + $embed .= ""; } } - } -} -/** - * HTTP Response Parser - * - * @package SimplePie - * @todo Support HTTP Requests - */ -class SimplePie_HTTP_Parser -{ - /** - * HTTP Version - * - * @access public - * @var string - */ - var $http_version = ''; + // Windows Media + elseif ($handler === 'wmedia') + { + $height += 45; + if ($native) + { + $embed .= "get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\">"; + } + else + { + $embed .= ""; + } + } - /** - * Status code - * - * @access public - * @var string - */ - var $status_code = ''; + // Everything else + else $embed .= '' . $alt . ''; - /** - * Reason phrase - * - * @access public - * @var string - */ - var $reason = ''; - - /** - * Key/value pairs of the headers - * - * @access public - * @var array - */ - var $headers = array(); - - /** - * Body of the response - * - * @access public - * @var string - */ - var $body = ''; - - /** - * Current state of the state machine - * - * @access private - * @var string - */ - var $state = 'start'; - - /** - * 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 - * - * @access private - * @var int - */ - var $position = 0; - - /** - * Name of the hedaer currently being parsed - * - * @access private - * @var string - */ - var $name = ''; - - /** - * Value of the hedaer currently being parsed - * - * @access private - * @var string - */ - var $value = ''; - - /** - * Create an instance of the class with the input data - * - * @access public - * @param string $data Input data - */ - function SimplePie_HTTP_Parser($data) - { - $this->data = $data; - $this->data_length = strlen($this->data); + return $embed; } - /** - * Parse the input data - * - * @access public - * @return bool true on success, false on failure - */ - function parse() + function get_real_type($find_handler = false) { - while ($this->state && $this->state != 'emit' && $this->has_data()) - { - $state = $this->state; - $this->$state(); - } - $this->data = ''; - if ($this->state == 'emit') - { - return true; - } - else + // If it's Odeo, let's get it out of the way. + if (substr(strtolower($this->get_link()), 0, 15) === 'http://odeo.com') { - $this->http_version = ''; - $this->status_code = ''; - $this->headers = array(); - $this->body = ''; - return false; + return 'odeo'; } - } - - /** - * 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); - } - - /** - * See if the next character is LWS - * - * @access private - * @return bool true if the next character is LWS, false if not - */ - 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))); - } - /** - * 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'; - } + // Mime-types by handler. + $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash + $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 - /** - * Parse an HTTP-version string - * - * @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 ($this->get_type() !== null) { - $this->position += strlen($match[0]); - $this->http_version = $match[1]; - return true; + $type = strtolower($this->type); } else { - return false; + $type = null; } - } - /** - * Parse LWS, replacing consecutive characters with a single space - * - * @access private - */ - function linear_whitespace() - { - do + // If we encounter an unsupported mime-type, check the file extension and guess intelligently. + if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3))) { - if (substr($this->data, $this->position, 2) == "\r\n") - { - $this->position += 2; - } - elseif (strspn($this->data, "\r\n", $this->position, 1)) + switch (strtolower($this->get_extension())) { - $this->position++; - } - $this->position += strspn($this->data, "\x09\x20", $this->position); - } while ($this->is_linear_whitespace()); - $this->value .= "\x20"; - } + // Audio mime-types + case 'aac': + case 'adts': + $type = 'audio/acc'; + break; - /** - * Parse an HTTP-version string within a response - * - * @access private - */ - function http_version_response() - { - if ($this->http_version() && $this->data[$this->position] == "\x20") - { - $this->state = 'status_code'; - $this->position++; - } - else - { - $this->state = false; - } - } + case 'aif': + case 'aifc': + case 'aiff': + case 'cdda': + $type = 'audio/aiff'; + break; - /** - * 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; - } - } + case 'bwf': + $type = 'audio/wav'; + break; - /** - * 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'; - } - } + case 'kar': + case 'mid': + case 'midi': + case 'smf': + $type = 'audio/midi'; + break; - /** - * Parse a header name - * - * @access private - */ - function name() - { - $len = strcspn($this->data, ':', $this->position); - $this->name = substr($this->data, $this->position, $len); - $this->position += $len; + case 'm4a': + $type = 'audio/x-m4a'; + break; - if ($this->has_data() && $this->data[$this->position] == ':') - { - $this->state = 'value_next'; - $this->position++; - } - else - { - $this->state = false; - } - } + case 'mp3': + case 'swa': + $type = 'audio/mp3'; + break; - /** - * See what state to move the state machine to while within non-quoted header values - * - * @access private - */ - function value_next() - { - 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; + case 'wav': + $type = 'audio/wav'; + break; + + case 'wax': + $type = 'audio/x-ms-wax'; + break; + + case 'wma': + $type = 'audio/x-ms-wma'; + break; + + // Video mime-types + case '3gp': + case '3gpp': + $type = 'video/3gpp'; + break; + + case '3g2': + case '3gp2': + $type = 'video/3gpp2'; + break; + + case 'asf': + $type = 'video/x-ms-asf'; + break; + + case 'flv': + $type = 'video/x-flv'; + break; + + case 'm1a': + case 'm1s': + case 'm1v': + case 'm15': + case 'm75': + case 'mp2': + case 'mpa': + case 'mpeg': + case 'mpg': + case 'mpm': + case 'mpv': + $type = 'video/mpeg'; + break; + + case 'm4v': + $type = 'video/x-m4v'; + break; + + case 'mov': + case 'qt': + $type = 'video/quicktime'; + break; + + case 'mp4': + case 'mpg4': + $type = 'video/mp4'; + break; + + case 'sdv': + $type = 'video/sd-video'; + break; + + case 'wm': + $type = 'video/x-ms-wm'; + break; + + case 'wmv': + $type = 'video/x-ms-wmv'; + break; + + case 'wvx': + $type = 'video/x-ms-wvx'; + break; + + // Flash mime-types + case 'spl': + $type = 'application/futuresplash'; + break; + + case 'swf': + $type = 'application/x-shockwave-flash'; + break; + } } - elseif (strspn($this->data, "\r\n", $this->position, 1)) + + if ($find_handler) { - $this->state = 'end_crlf'; - $this->position++; + if (in_array($type, $types_flash)) + { + return 'flash'; + } + elseif (in_array($type, $types_fmedia)) + { + return 'fmedia'; + } + elseif (in_array($type, $types_quicktime)) + { + return 'quicktime'; + } + elseif (in_array($type, $types_wmedia)) + { + return 'wmedia'; + } + elseif (in_array($type, $types_mp3)) + { + return 'mp3'; + } + else + { + return null; + } } else { - $this->state = 'value_no_quote'; + return $type; } } +} - /** - * Parse a header value while outside quotes - * - * @access private - */ - function value_no_quote() +class SimplePie_Caption +{ + var $type; + var $lang; + var $startTime; + var $endTime; + var $text; + + // Constructor, used to input the data + function SimplePie_Caption($type = null, $lang = null, $startTime = null, $endTime = null, $text = null) { - $len = strcspn($this->data, "\x09\x20\r\n\"", $this->position); - $this->value .= substr($this->data, $this->position, $len); - $this->state = 'value_next'; - $this->position += $len; + $this->type = $type; + $this->lang = $lang; + $this->startTime = $startTime; + $this->endTime = $endTime; + $this->text = $text; } - /** - * Parse LWS outside quotes - * - * @access private - */ - function value_linear_whitespace() + function __toString() { - $this->linear_whitespace(); - $this->state = 'value_next'; + // There is no $this->data here + return md5(serialize($this)); } - /** - * See what state to move the state machine to while within quoted header values - * - * @access private - */ - function value_quote_next() + function get_endtime() { - if ($this->is_linear_whitespace()) + if ($this->endTime !== null) { - $this->state = 'value_linear_whitespace_quote'; + return $this->endTime; } else { - switch ($this->data[$this->position]) - { - case '"': - $this->state = 'value_next'; - $this->position++; - break; - - case '\\': - $this->state = 'value_quote_char'; - $this->position++; - break; - - default: - $this->state = 'value_quote'; - break; - } + return null; } } - /** - * Parse a header value while within quotes - * - * @access private - */ - function value_quote() - { - $len = strcspn($this->data, "\x09\x20\r\n\"\\", $this->position); - $this->value .= substr($this->data, $this->position, $len); - $this->position += $len; - $this->state = 'value_quote_next'; - } - - /** - * Parse an escaped character within quotes - * - * @access private - */ - function value_quote_char() + function get_language() { - $this->value .= $this->data[$this->position]; - $this->state = 'value_quote_next'; - $this->position++; + if ($this->lang !== null) + { + return $this->lang; + } + else + { + return null; + } } - /** - * Parse LWS within quotes - * - * @access private - */ - function value_linear_whitespace_quote() + function get_starttime() { - $this->linear_whitespace(); - $this->state = 'value_quote_next'; + if ($this->startTime !== null) + { + return $this->startTime; + } + else + { + return null; + } } - /** - * Parse a CRLF, and see whether we have a further header, or whether we are followed by the body - * - * @access private - */ - function end_crlf() + function get_text() { - $this->name = strtolower($this->name); - $this->value = trim($this->value, "\x20"); - if (isset($this->headers[$this->name])) + if ($this->text !== null) { - $this->headers[$this->name] .= ', ' . $this->value; + return $this->text; } else { - $this->headers[$this->name] = $this->value; + return null; } + } - if (substr($this->data, $this->position, 2) == "\r\n") - { - $this->body = substr($this->data, $this->position + 2); - $this->state = 'emit'; - } - elseif (strspn($this->data, "\r\n", $this->position, 1)) + function get_type() + { + if ($this->type !== null) { - $this->body = substr($this->data, $this->position + 1); - $this->state = 'emit'; + return $this->type; } else { - $this->name = ''; - $this->value = ''; - $this->state = 'name'; + return null; } } } -class SimplePie_Cache +class SimplePie_Credit { - var $location; - var $filename; - var $extension; + var $role; + var $scheme; var $name; - function SimplePie_Cache($location, $filename, $extension) + // Constructor, used to input the data + function SimplePie_Credit($role = null, $scheme = null, $name = null) { - $this->location = $location; - $this->filename = rawurlencode($filename); - $this->extension = rawurlencode($extension); - $this->name = "$location/$this->filename.$this->extension"; + $this->role = $role; + $this->scheme = $scheme; + $this->name = $name; } - function save($data) + function __toString() { - if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location)) + // There is no $this->data here + return md5(serialize($this)); + } + + function get_role() + { + if ($this->role !== null) { - if (function_exists('file_put_contents')) - { - return (bool) file_put_contents($this->name, serialize($data)); - } - else - { - $fp = fopen($this->name, 'wb'); - if ($fp) - { - fwrite($fp, serialize($data)); - fclose($fp); - return true; - } - } + return $this->role; } - return false; - } - - function load() - { - if (file_exists($this->name) && is_readable($this->name)) + else { - 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 null; } - return false; } - function mtime() + function get_scheme() { - if (file_exists($this->name)) + if ($this->scheme !== null) { - return filemtime($this->name); + return $this->scheme; } - return false; - } - - function touch() - { - if (file_exists($this->name)) + else { - return touch($this->name); + return null; } - return false; } - function unlink() + function get_name() { - if (file_exists($this->name)) + if ($this->name !== null) { - return unlink($this->name); + return $this->name; + } + else + { + return null; } - return false; } } -class SimplePie_Misc +class SimplePie_Copyright { - function time_hms($seconds) + var $url; + var $label; + + // Constructor, used to input the data + function SimplePie_Copyright($url = null, $label = null) { - $time = ''; + $this->url = $url; + $this->label = $label; + } - $hours = floor($seconds / 3600); - $remainder = $seconds % 3600; - if ($hours > 0) - { - $time .= $hours.':'; - } + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } - $minutes = floor($remainder / 60); - $seconds = $remainder % 60; - if ($minutes < 10 && $hours > 0) + function get_url() + { + if ($this->url !== null) { - $minutes = '0' . $minutes; + return $this->url; } - if ($seconds < 10) + else { - $seconds = '0' . $seconds; + return null; } - - $time .= $minutes.':'; - $time .= $seconds; - - return $time; } - function absolutize_url($relative, $base) + function get_attribution() { - if ($relative !== '') + if ($this->label !== null) { - $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']); + return $this->label; } else { - $return = $base; + return null; } - $return = SimplePie_Misc::normalize_url($return); - return $return; } +} - function remove_dot_segments($input) +class SimplePie_Rating +{ + var $scheme; + var $value; + + // Constructor, used to input the data + function SimplePie_Rating($scheme = null, $value = null) { - $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; + $this->scheme = $scheme; + $this->value = $value; } - function get_element($realname, $string) + function __toString() { - $return = array(); - $name = preg_quote($realname, '/'); - if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) - { - for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) - { - $return[$i]['tag'] = $realname; - $return[$i]['full'] = $matches[$i][0][0]; - $return[$i]['offset'] = $matches[$i][0][1]; - if (strlen($matches[$i][3][0]) <= 2) - { - $return[$i]['self_closing'] = true; - } - else - { - $return[$i]['self_closing'] = false; - $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)) - { - for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) - { - if (count($attribs[$j]) == 2) - { - $attribs[$j][2] = $attribs[$j][1]; - } - $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8'); - } - } - } - } - return $return; + // There is no $this->data here + return md5(serialize($this)); } - function element_implode($element) + function get_scheme() { - $full = "<$element[tag]"; - foreach ($element['attribs'] as $key => $value) - { - $key = strtolower($key); - $full .= " $key=\"" . htmlspecialchars($value['data']) . '"'; - } - if ($element['self_closing']) + if ($this->scheme !== null) { - $full .= ' />'; + return $this->scheme; } else { - $full .= ">$element[content]"; + return null; } - return $full; } - function error($message, $level, $file, $line) + function get_value() { - switch ($level) + if ($this->value !== null) { - 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; - } - error_log("$note: $message in $file on line $line", 0); - return $message; - } - - /** - * If a file has been cached, retrieve and display it. - * - * This is most useful for caching images (get_favicon(), etc.), - * however it works for all cached files. This WILL NOT display ANY - * file/image/page/whatever, but rather only display what has already - * been cached by SimplePie. - * - * @access public - * @see SimplePie::get_favicon() - * @param str $identifier_url URL that is used to identify the content. - * This may or may not be the actual URL of the live content. - * @param str $cache_location Location of SimplePie's cache. Defaults - * to './cache'. - * @param str $cache_extension The file extension that the file was - * cached with. Defaults to 'spc'. - * @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'. - */ - 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); - - if ($file = $cache->load()) - { - header('Content-type:' . $file['headers']['content-type']); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days - echo $file['body']; - exit; - } - - die('Cached file for ' . $identifier_url . ' cannot be found.'); - } - - function fix_protocol($url, $http = 1) - { - $url = SimplePie_Misc::normalize_url($url); - $parsed = SimplePie_Misc::parse_url($url); - 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); - } - - if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) - { - return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http); - } - - if ($http == 2 && $parsed['scheme'] !== '') - { - return "feed:$url"; - } - elseif ($http == 3 && strtolower($parsed['scheme']) == 'http') - { - return substr_replace($url, 'podcast', 0, 4); - } - elseif ($http == 4 && strtolower($parsed['scheme']) == 'http') - { - return substr_replace($url, 'itpc', 0, 4); + return $this->value; } else { - return $url; + return null; } } +} - 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' => ''); - } - } +class SimplePie_Restriction +{ + var $relationship; + var $type; + var $value; - function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '') + // Constructor, used to input the data + function SimplePie_Restriction($relationship = null, $type = null, $value = null) { - $return = ''; - if ($scheme !== '') - { - $return .= "$scheme:"; - } - if ($authority !== '') - { - $return .= "//$authority"; - } - if ($path !== '') - { - $return .= $path; - } - if ($query !== '') - { - $return .= "?$query"; - } - if ($fragment !== '') - { - $return .= "#$fragment"; - } - return $return; + $this->relationship = $relationship; + $this->type = $type; + $this->value = $value; } - function normalize_url($url) + function __toString() { - $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']); + // There is no $this->data here + return md5(serialize($this)); } - function percent_encoding_normalization($match) + function get_relationship() { - $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 ($this->relationship !== null) { - return chr($integer); + return $this->relationship; } else { - return strtoupper($match[0]); + return null; } } - /** - * Remove bad UTF-8 bytes - * - * PCRE Pattern to locate bad bytes in a UTF-8 string comes from W3C - * FAQ: Multilingual Forms (modified to include full ASCII range) - * - * @author Geoffrey Sneddon - * @see http://www.w3.org/International/questions/qa-forms-utf-8 - * @param string $str String to remove bad UTF-8 bytes from - * @return string UTF-8 string - */ - function utf8_bad_replace($str) + function get_type() { - if (function_exists('iconv')) - { - $out = iconv('UTF-8', 'UTF-8//IGNORE', $str); - if($out !== false) return $out; - } - if (function_exists('mb_convert_encoding')) - { - return mb_convert_encoding($str, 'UTF-8', 'UTF-8'); - } - 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]); - } - elseif ($str !== '') + if ($this->type !== null) { - return "\xEF\xBF\xBD"; + return $this->type; } else { - return ''; + return null; } } - function change_encoding($data, $input, $output) + function get_value() { - $input = SimplePie_Misc::encoding($input); - $output = SimplePie_Misc::encoding($output); - - if (function_exists('iconv') && ($return = @iconv($input, "$output//IGNORE", $data))) - { - return $return; - } - elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data))) - { - return $return; - } - elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($data, $output, $input))) - { - return $return; - } - elseif ($input == 'ISO-8859-1' && $output == 'UTF-8') + if ($this->value !== null) { - return utf8_encode($data); + return $this->value; } - elseif ($input == 'UTF-8' && $output == 'ISO-8859-1') + else { - return utf8_decode($data); + return null; } - return $data; } +} + +/** + * @todo Move to properly supporting RFC2616 (HTTP/1.1) + */ +class SimplePie_File +{ + var $url; + var $useragent; + var $success = true; + var $headers = array(); + var $body; + var $status_code; + var $redirects = 0; + var $error; + var $method = SIMPLEPIE_FILE_SOURCE_NONE; - function encoding($encoding) + function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) { - // Character sets are case-insensitive (though we'll return them in the form given in their registration) - switch (strtoupper($encoding)) + if (class_exists('idna_convert')) { - 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'; + $idn = new idna_convert; + $parsed = SimplePie_Misc::parse_url($url); + $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); + } + $this->url = $url; + $this->useragent = $useragent; + if (preg_match('/^http(s)?:\/\//i', $url)) + { + if ($useragent === null) + { + $useragent = ini_get('user_agent'); + $this->useragent = $useragent; + } + if (!is_array($headers)) + { + $headers = array(); + } + if (!$force_fsockopen && function_exists('curl_exec')) + { + $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL; + $fp = curl_init(); + $headers2 = array(); + foreach ($headers as $key => $value) + { + $headers2[] = "$key: $value"; + } + if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) + { + curl_setopt($fp, CURLOPT_ENCODING, ''); + } + curl_setopt($fp, CURLOPT_URL, $url); + curl_setopt($fp, CURLOPT_HEADER, 1); + curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($fp, CURLOPT_TIMEOUT, $timeout); + curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout); + curl_setopt($fp, CURLOPT_REFERER, $url); + curl_setopt($fp, CURLOPT_USERAGENT, $useragent); + curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); + if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) + { + curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); + } - case 'ISO_646.BASIC:1983': - case 'REF': - case 'CSISO646BASIC1983': - return 'ISO_646.basic:1983'; + $this->headers = curl_exec($fp); + if (curl_errno($fp) === 23 || curl_errno($fp) === 61) + { + curl_setopt($fp, CURLOPT_ENCODING, 'none'); + $this->headers = curl_exec($fp); + } + if (curl_errno($fp)) + { + $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); + $this->success = false; + } + else + { + $info = curl_getinfo($fp); + curl_close($fp); + $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); + $this->headers = array_pop($this->headers); + $parser = new SimplePie_HTTP_Parser($this->headers); + if ($parser->parse()) + { + $this->headers = $parser->headers; + $this->body = $parser->body; + $this->status_code = $parser->status_code; + 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++; + $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); + return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); + } + } + } + } + else + { + $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') + { + $url_parts['host'] = "ssl://$url_parts[host]"; + $url_parts['port'] = 443; + } + if (!isset($url_parts['port'])) + { + $url_parts['port'] = 80; + } + $fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout); + if (!$fp) + { + $this->error = 'fsockopen error: ' . $errstr; + $this->success = false; + } + else + { + stream_set_timeout($fp, $timeout); + if (isset($url_parts['path'])) + { + if (isset($url_parts['query'])) + { + $get = "$url_parts[path]?$url_parts[query]"; + } + else + { + $get = $url_parts['path']; + } + } + else + { + $get = '/'; + } + $out = "GET $get HTTP/1.0\r\n"; + $out .= "Host: $url_parts[host]\r\n"; + $out .= "User-Agent: $useragent\r\n"; + if (extension_loaded('zlib')) + { + $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n"; + } + + if (isset($url_parts['user']) && isset($url_parts['pass'])) + { + $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n"; + } + foreach ($headers as $key => $value) + { + $out .= "$key: $value\r\n"; + } + $out .= "Connection: Close\r\n\r\n"; + fwrite($fp, $out); + + $info = stream_get_meta_data($fp); + + $this->headers = ''; + while (!$info['eof'] && !$info['timed_out']) + { + $this->headers .= fread($fp, 1160); + $info = stream_get_meta_data($fp); + } + if (!$info['timed_out']) + { + $parser = new SimplePie_HTTP_Parser($this->headers); + if ($parser->parse()) + { + $this->headers = $parser->headers; + $this->body = $parser->body; + $this->status_code = $parser->status_code; + 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++; + $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'])) + { + // Hey, we act dumb elsewhere, so let's do that here too + switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) + { + 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; + } + } + } + } + else + { + $this->error = 'fsocket timed out'; + $this->success = false; + } + fclose($fp); + } + } + } + else + { + $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; + } + } + } +} + +/** + * HTTP Response Parser + * + * @package SimplePie + */ +class SimplePie_HTTP_Parser +{ + /** + * HTTP Version + * + * @access public + * @var float + */ + var $http_version = 0.0; + + /** + * Status code + * + * @access public + * @var int + */ + var $status_code = 0; + + /** + * Reason phrase + * + * @access public + * @var string + */ + var $reason = ''; + + /** + * Key/value pairs of the headers + * + * @access public + * @var array + */ + var $headers = array(); + + /** + * Body of the response + * + * @access public + * @var string + */ + var $body = ''; + + /** + * Current state of the state machine + * + * @access private + * @var string + */ + var $state = 'http_version'; + + /** + * 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; + + /** + * Name of the hedaer currently being parsed + * + * @access private + * @var string + */ + var $name = ''; + + /** + * Value of the hedaer currently being parsed + * + * @access private + * @var string + */ + var $value = ''; + + /** + * Create an instance of the class with the input data + * + * @access public + * @param string $data Input data + */ + function SimplePie_HTTP_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' || $this->state === 'body') + { + return true; + } + else + { + $this->http_version = ''; + $this->status_code = ''; + $this->reason = ''; + $this->headers = array(); + $this->body = ''; + 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); + } + + /** + * See if the next character is LWS + * + * @access private + * @return bool true if the next character is LWS, false if not + */ + function is_linear_whitespace() + { + 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"))); + } + + /** + * Parse the HTTP version + * + * @access private + */ + function http_version() + { + if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/') + { + $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 + { + $this->state = false; + } + } + + /** + * Parse the status code + * + * @access private + */ + function status() + { + if ($len = strspn($this->data, '0123456789', $this->position)) + { + $this->status_code = (int) substr($this->data, $this->position, $len); + $this->position += $len; + $this->state = 'reason'; + } + else + { + $this->state = false; + } + } + + /** + * Parse the reason phrase + * + * @access private + */ + function reason() + { + $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->position++; + $this->state = 'body'; + } + else + { + $this->state = 'name'; + } + } + + /** + * Parse a header name + * + * @access private + */ + function name() + { + $len = strcspn($this->data, "\x0A:", $this->position); + if (isset($this->data[$this->position + $len])) + { + 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 + { + $this->state = false; + } + } + + /** + * Parse LWS, replacing consecutive LWS characters with a single space + * + * @access private + */ + 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->linear_whitespace(); + } + else + { + 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; + } + } + } + + /** + * Parse a header value while outside quotes + * + * @access private + */ + function value_char() + { + $len = strcspn($this->data, "\x09\x20\x0A\"", $this->position); + $this->value .= substr($this->data, $this->position, $len); + $this->position += $len; + $this->state = 'value'; + } + + /** + * See what state to move to while within quoted header values + * + * @access private + */ + function quote() + { + if ($this->is_linear_whitespace()) + { + $this->linear_whitespace(); + } + else + { + switch ($this->data[$this->position]) + { + case '"': + $this->position++; + $this->state = 'value'; + break; + + case "\x0A": + $this->position++; + $this->state = 'new_line'; + break; + + case '\\': + $this->position++; + $this->state = 'quote_escaped'; + break; + + default: + $this->state = 'quote_char'; + break; + } + } + } + + /** + * Parse a header value while within quotes + * + * @access private + */ + function quote_char() + { + $len = strcspn($this->data, "\x09\x20\x0A\"\\", $this->position); + $this->value .= substr($this->data, $this->position, $len); + $this->position += $len; + $this->state = 'value'; + } + + /** + * Parse an escaped character within quotes + * + * @access private + */ + function quote_escaped() + { + $this->value .= $this->data[$this->position]; + $this->position++; + $this->state = 'quote'; + } + + /** + * Parse the body + * + * @access private + */ + function body() + { + $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); + } + + /** + * Set the compressed string and related properties + * + * @access public + */ + function SimplePie_gzdecode($data) + { + $this->compressed_data = $data; + $this->compressed_size = strlen($data); + } + + /** + * Decode the GZIP stream + * + * @access public + */ + function parse() + { + if ($this->compressed_size >= $this->min_compressed_size) + { + // 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 + { + 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_File($location, $filename, $extension) + { + $this->location = $location; + $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, $data); + } + else + { + $fp = fopen($this->name, 'wb'); + if ($fp) + { + fwrite($fp, $data); + fclose($fp); + return true; + } + } + } + return false; + } + + function load() + { + if (file_exists($this->name) && is_readable($this->name)) + { + return unserialize(file_get_contents($this->name)); + } + return false; + } + + function mtime() + { + if (file_exists($this->name)) + { + return filemtime($this->name); + } + return false; + } + + function touch() + { + if (file_exists($this->name)) + { + return touch($this->name); + } + return false; + } + + function unlink() + { + if (file_exists($this->name)) + { + return unlink($this->name); + } + return false; + } +} + +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) + { + $time = ''; + + $hours = floor($seconds / 3600); + $remainder = $seconds % 3600; + if ($hours > 0) + { + $time .= $hours.':'; + } + + $minutes = floor($remainder / 60); + $seconds = $remainder % 60; + if ($minutes < 10 && $hours > 0) + { + $minutes = '0' . $minutes; + } + if ($seconds < 10) + { + $seconds = '0' . $seconds; + } + + $time .= $minutes.':'; + $time .= $seconds; + + return $time; + } + + function absolutize_url($relative, $base) + { + $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 === '..') + { + // 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; + } + + function get_element($realname, $string) + { + $return = array(); + $name = preg_quote($realname, '/'); + if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) + { + for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) + { + $return[$i]['tag'] = $realname; + $return[$i]['full'] = $matches[$i][0][0]; + $return[$i]['offset'] = $matches[$i][0][1]; + if (strlen($matches[$i][3][0]) <= 2) + { + $return[$i]['self_closing'] = true; + } + else + { + $return[$i]['self_closing'] = false; + $return[$i]['content'] = $matches[$i][4][0]; + } + $return[$i]['attribs'] = array(); + 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) + { + $attribs[$j][2] = $attribs[$j][1]; + } + $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8'); + } + } + } + } + return $return; + } + + function element_implode($element) + { + $full = "<$element[tag]"; + foreach ($element['attribs'] as $key => $value) + { + $key = strtolower($key); + $full .= " $key=\"" . htmlspecialchars($value['data']) . '"'; + } + if ($element['self_closing']) + { + $full .= ' />'; + } + else + { + $full .= ">$element[content]"; + } + return $full; + } + + function error($message, $level, $file, $line) + { + if ((ini_get('error_reporting') & $level) > 0) + { + 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); + } + } + + return $message; + } + + /** + * If a file has been cached, retrieve and display it. + * + * This is most useful for caching images (get_favicon(), etc.), + * however it works for all cached files. This WILL NOT display ANY + * file/image/page/whatever, but rather only display what has already + * been cached by SimplePie. + * + * @access public + * @see SimplePie::get_favicon() + * @param str $identifier_url URL that is used to identify the content. + * This may or may not be the actual URL of the live content. + * @param str $cache_location Location of SimplePie's cache. Defaults + * to './cache'. + * @param str $cache_extension The file extension that the file was + * cached with. Defaults to 'spc'. + * @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 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 = call_user_func(array($cache_class, 'create'), $cache_location, $identifier_url, $cache_extension); + + if ($file = $cache->load()) + { + 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; + } + + die('Cached file for ' . $identifier_url . ' cannot be found.'); + } + + function fix_protocol($url, $http = 1) + { + $url = SimplePie_Misc::normalize_url($url); + $parsed = SimplePie_Misc::parse_url($url); + 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); + } + + if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) + { + return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http); + } + + if ($http === 2 && $parsed['scheme'] !== '') + { + return "feed:$url"; + } + elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') + { + return substr_replace($url, 'podcast', 0, 4); + } + elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') + { + return substr_replace($url, 'itpc', 0, 4); + } + else + { + return $url; + } + } + + function parse_url($url) + { + $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 = '') + { + $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) + { + $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) + { + return chr($integer); + } + else + { + return strtoupper($match[0]); + } + } + + /** + * Remove bad UTF-8 bytes + * + * PCRE Pattern to locate bad bytes in a UTF-8 string comes from W3C + * FAQ: Multilingual Forms (modified to include full ASCII range) + * + * @author Geoffrey Sneddon + * @see http://www.w3.org/International/questions/qa-forms-utf-8 + * @param string $str String to remove bad UTF-8 bytes from + * @return string UTF-8 string + */ + function utf8_bad_replace($str) + { + if (function_exists('iconv') && ($return = @iconv('UTF-8', 'UTF-8//IGNORE', $str))) + { + return $return; + } + elseif (function_exists('mb_convert_encoding') && ($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)) + { + return implode("\xEF\xBF\xBD", $matches[0]); + } + elseif ($str !== '') + { + return "\xEF\xBF\xBD"; + } + else + { + return ''; + } + } + + /** + * 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); + + // 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; + } + // If we can't do anything, just fail + else + { + return false; + } + } + + function encoding($charset) + { + // Normalization from UTS #22 + switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) + { + case 'adobestandardencoding': + case 'csadobestandardencoding': + return 'Adobe-Standard-Encoding'; + + case 'adobesymbolencoding': + case 'cshppsmath': + return 'Adobe-Symbol-Encoding'; + + case 'ami1251': + case 'amiga1251': + return 'Amiga-1251'; + + case 'ansix31101983': + case 'csat5001983': + case 'csiso99naplps': + case 'isoir99': + case 'naplps': + return 'ANSI_X3.110-1983'; + + 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 '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 'INVARIANT': - case 'CSINVARIANT': - return 'INVARIANT'; + case 'ccsid1149': + case 'cp1149': + case 'ebcdicis871euro': + case 'ibm1149': + return 'IBM01149'; - case 'ISO_646.IRV:1983': - case 'ISO-IR-2': - case 'IRV': - case 'CSISO2INTLREFVERSION': - return 'ISO_646.irv:1983'; + case 'cp37': + case 'csibm37': + case 'ebcdiccpca': + case 'ebcdiccpnl': + case 'ebcdiccpus': + case 'ebcdiccpwt': + case 'ibm37': + return 'IBM037'; - case 'NATS-SEFI': - case 'ISO-IR-8-1': - case 'CSNATSSEFI': - return 'NATS-SEFI'; + case 'cp38': + case 'csibm38': + case 'ebcdicint': + case 'ibm38': + return 'IBM038'; - case 'NATS-SEFI-ADD': - case 'ISO-IR-8-2': - case 'CSNATSSEFIADD': - return 'NATS-SEFI-ADD'; + case 'cp273': + case 'csibm273': + case 'ibm273': + return 'IBM273'; - case 'NATS-DANO': - case 'ISO-IR-9-1': - case 'CSNATSDANO': - return 'NATS-DANO'; + case 'cp274': + case 'csibm274': + case 'ebcdicbe': + case 'ibm274': + return 'IBM274'; - case 'NATS-DANO-ADD': - case 'ISO-IR-9-2': - case 'CSNATSDANOADD': - return 'NATS-DANO-ADD'; + case 'cp275': + case 'csibm275': + case 'ebcdicbr': + case 'ibm275': + return 'IBM275'; - 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 'csibm277': + case 'ebcdiccpdk': + case 'ebcdiccpno': + case 'ibm277': + return 'IBM277'; - 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 'cp278': + case 'csibm278': + case 'ebcdiccpfi': + case 'ebcdiccpse': + case 'ibm278': + return 'IBM278'; - case 'ISO-2022-KR': - case 'CSISO2022KR': - return 'ISO-2022-KR'; + case 'cp280': + case 'csibm280': + case 'ebcdiccpit': + case 'ibm280': + return 'IBM280'; - case 'EUC-KR': - case 'CSEUCKR': - return 'EUC-KR'; + case 'cp281': + case 'csibm281': + case 'ebcdicjpe': + case 'ibm281': + return 'IBM281'; - case 'ISO-2022-JP': - case 'CSISO2022JP': - return 'ISO-2022-JP'; + case 'cp284': + case 'csibm284': + case 'ebcdiccpes': + case 'ibm284': + return 'IBM284'; - case 'ISO-2022-JP-2': - case 'CSISO2022JP2': - return 'ISO-2022-JP-2'; + case 'cp285': + case 'csibm285': + case 'ebcdiccpgb': + case 'ibm285': + return 'IBM285'; - 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 'cp290': + case 'csibm290': + case 'ebcdicjpkana': + case 'ibm290': + return 'IBM290'; - case 'JIS_C6220-1969-RO': - case 'ISO-IR-14': - case 'JP': - case 'ISO646-JP': - case 'CSISO14JISC6220RO': - return 'JIS_C6220-1969-ro'; + case 'cp297': + case 'csibm297': + case 'ebcdiccpfr': + case 'ibm297': + return 'IBM297'; - case 'PT': - case 'ISO-IR-16': - case 'ISO646-PT': - case 'CSISO16PORTUGUESE': - return 'PT'; + case 'cp420': + case 'csibm420': + case 'ebcdiccpar1': + case 'ibm420': + return 'IBM420'; - case 'GREEK7-OLD': - case 'ISO-IR-18': - case 'CSISO18GREEK7OLD': - return 'greek7-old'; + case 'cp423': + case 'csibm423': + case 'ebcdiccpgr': + case 'ibm423': + return 'IBM423'; - case 'LATIN-GREEK': - case 'ISO-IR-19': - case 'CSISO19LATINGREEK': - return 'latin-greek'; + case 'cp424': + case 'csibm424': + case 'ebcdiccphe': + case 'ibm424': + return 'IBM424'; - case 'NF_Z_62-010_(1973)': - case 'ISO-IR-25': - case 'ISO646-FR1': - case 'CSISO25FRENCH': - return 'NF_Z_62-010_(1973)'; + case '437': + case 'cp437': + case 'cspc8codepage437': + case 'ibm437': + return 'IBM437'; - case 'LATIN-GREEK-1': - case 'ISO-IR-27': - case 'CSISO27LATINGREEK1': - return 'Latin-greek-1'; + case 'cp500': + case 'csibm500': + case 'ebcdiccpbe': + case 'ebcdiccpch': + case 'ibm500': + return 'IBM500'; - case 'ISO_5427': - case 'ISO-IR-37': - case 'CSISO5427CYRILLIC': - return 'ISO_5427'; + case 'cp775': + case 'cspc775baltic': + case 'ibm775': + return 'IBM775'; - case 'JIS_C6226-1978': - case 'ISO-IR-42': - case 'CSISO42JISC62261978': - return 'JIS_C6226-1978'; + case '850': + case 'cp850': + case 'cspc850multilingual': + case 'ibm850': + return 'IBM850'; - case 'BS_VIEWDATA': - case 'ISO-IR-47': - case 'CSISO47BSVIEWDATA': - return 'BS_viewdata'; + case '851': + case 'cp851': + case 'csibm851': + case 'ibm851': + return 'IBM851'; - case 'INIS': - case 'ISO-IR-49': - case 'CSISO49INIS': - return 'INIS'; + case '852': + case 'cp852': + case 'cspcp852': + case 'ibm852': + return 'IBM852'; - case 'INIS-8': - case 'ISO-IR-50': - case 'CSISO50INIS8': - return 'INIS-8'; + case '855': + case 'cp855': + case 'csibm855': + case 'ibm855': + return 'IBM855'; - case 'INIS-CYRILLIC': - case 'ISO-IR-51': - case 'CSISO51INISCYRILLIC': - return 'INIS-cyrillic'; + case '857': + case 'cp857': + case 'csibm857': + case 'ibm857': + return 'IBM857'; - case 'ISO_5427:1981': - case 'ISO-IR-54': - case 'ISO5427CYRILLIC1981': - return 'ISO_5427:1981'; + case '860': + case 'cp860': + case 'csibm860': + case 'ibm860': + return 'IBM860'; - case 'ISO_5428:1980': - case 'ISO-IR-55': - case 'CSISO5428GREEK': - return 'ISO_5428:1980'; + case '861': + case 'cp861': + case 'cpis': + case 'csibm861': + case 'ibm861': + return 'IBM861'; - case 'GB_1988-80': - case 'ISO-IR-57': - case 'CN': - case 'ISO646-CN': - case 'CSISO57GB1988': - return 'GB_1988-80'; + case '862': + case 'cp862': + case 'cspc862latinhebrew': + case 'ibm862': + return 'IBM862'; - 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 '863': + case 'cp863': + case 'csibm863': + case 'ibm863': + return 'IBM863'; - case 'VIDEOTEX-SUPPL': - case 'ISO-IR-70': - case 'CSISO70VIDEOTEXSUPP1': - return 'videotex-suppl'; + case 'cp864': + case 'csibm864': + case 'ibm864': + return 'IBM864'; - case 'PT2': - case 'ISO-IR-84': - case 'ISO646-PT2': - case 'CSISO84PORTUGUESE2': - return 'PT2'; + case '865': + case 'cp865': + case 'csibm865': + case 'ibm865': + return 'IBM865'; - case 'ES2': - case 'ISO-IR-85': - case 'ISO646-ES2': - case 'CSISO85SPANISH2': - return 'ES2'; + case '866': + case 'cp866': + case 'csibm866': + case 'ibm866': + return 'IBM866'; - case 'MSZ_7795.3': - case 'ISO-IR-86': - case 'ISO646-HU': - case 'HU': - case 'CSISO86HUNGARIAN': - return 'MSZ_7795.3'; + case 'cp868': + case 'cpar': + case 'csibm868': + case 'ibm868': + return 'IBM868'; - case 'JIS_C6226-1983': - case 'ISO-IR-87': - case 'X0208': - case 'JIS_X0208-1983': - case 'CSISO87JISX0208': - return 'JIS_C6226-1983'; + case '869': + case 'cp869': + case 'cpgr': + case 'csibm869': + case 'ibm869': + return 'IBM869'; - case 'GREEK7': - case 'ISO-IR-88': - case 'CSISO88GREEK7': - return 'greek7'; + case 'cp870': + case 'csibm870': + case 'ebcdiccproece': + case 'ebcdiccpyu': + case 'ibm870': + return 'IBM870'; - case 'ASMO_449': - case 'ISO_9036': - case 'ARABIC7': - case 'ISO-IR-89': - case 'CSISO89ASMO449': - return 'ASMO_449'; + case 'cp871': + case 'csibm871': + case 'ebcdiccpis': + case 'ibm871': + return 'IBM871'; - case 'ISO-IR-90': - case 'CSISO90': - return 'iso-ir-90'; + case 'cp880': + case 'csibm880': + case 'ebcdiccyrillic': + case 'ibm880': + return 'IBM880'; - case 'JIS_C6229-1984-A': - case 'ISO-IR-91': - case 'JP-OCR-A': - case 'CSISO91JISC62291984A': - return 'JIS_C6229-1984-a'; + case 'cp891': + case 'csibm891': + case 'ibm891': + return 'IBM891'; - 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 'cp903': + case 'csibm903': + case 'ibm903': + return 'IBM903'; - case 'JIS_C6229-1984-B-ADD': - case 'ISO-IR-93': - case 'JP-OCR-B-ADD': - case 'CSISO93JIS62291984BADD': - return 'JIS_C6229-1984-b-add'; + case '904': + case 'cp904': + case 'csibbm904': + case 'ibm904': + return 'IBM904'; - case 'JIS_C6229-1984-HAND': - case 'ISO-IR-94': - case 'JP-OCR-HAND': - case 'CSISO94JIS62291984HAND': - return 'JIS_C6229-1984-hand'; + case 'cp905': + case 'csibm905': + case 'ebcdiccptr': + case 'ibm905': + return 'IBM905'; - case 'JIS_C6229-1984-HAND-ADD': - case 'ISO-IR-95': - case 'JP-OCR-HAND-ADD': - case 'CSISO95JIS62291984HANDADD': - return 'JIS_C6229-1984-hand-add'; + case 'cp918': + case 'csibm918': + case 'ebcdiccpar2': + case 'ibm918': + return 'IBM918'; - case 'JIS_C6229-1984-KANA': - case 'ISO-IR-96': - case 'CSISO96JISC62291984KANA': - return 'JIS_C6229-1984-kana'; + case 'cp1026': + case 'csibm1026': + case 'ibm1026': + return 'IBM1026'; - case 'ISO_2033-1983': - case 'ISO-IR-98': - case 'E13B': - case 'CSISO2033': - return 'ISO_2033-1983'; + case 'ibm1047': + return 'IBM1047'; - case 'ANSI_X3.110-1983': - case 'ISO-IR-99': - case 'CSA_T500-1983': - case 'NAPLPS': - case 'CSISO99NAPLPS': - return 'ANSI_X3.110-1983'; + case 'csiso143iecp271': + case 'iecp271': + case 'isoir143': + return 'IEC_P27-1'; - case 'T.61-7BIT': - case 'ISO-IR-102': - case 'CSISO102T617BIT': - return 'T.61-7bit'; + case 'csiso49inis': + case 'inis': + case 'isoir49': + return 'INIS'; - case 'T.61-8BIT': - case 'T.61': - case 'ISO-IR-103': - case 'CSISO103T618BIT': - return 'T.61-8bit'; + case 'csiso50inis8': + case 'inis8': + case 'isoir50': + return 'INIS-8'; - case 'ECMA-CYRILLIC': - case 'ISO-IR-111': - case 'KOI8-E': - case 'CSISO111ECMACYRILLIC': - return 'ECMA-cyrillic'; + case 'csiso51iniscyrillic': + case 'iniscyrillic': + case 'isoir51': + return 'INIS-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 'csinvariant': + case 'invariant': + return 'INVARIANT'; - 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 'iso2022cn': + return 'ISO-2022-CN'; - case 'CSA_Z243.4-1985-GR': - case 'ISO-IR-123': - case 'CSISO123CSAZ24341985GR': - return 'CSA_Z243.4-1985-gr'; + 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 'ISO_8859-6-E': - case 'CSISO88596E': - case 'ISO-8859-6-E': + case 'csiso88596e': + case 'iso88596e': return 'ISO-8859-6-E'; - case 'ISO_8859-6-I': - case 'CSISO88596I': - case 'ISO-8859-6-I': + case 'csiso88596i': + case 'iso88596i': return 'ISO-8859-6-I'; - case 'T.101-G2': - case 'ISO-IR-128': - case 'CSISO128T101G2': - return 'T.101-G2'; + 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 'ISO_8859-8-E': - case 'CSISO88598E': - case 'ISO-8859-8-E': + case 'csiso88598e': + case 'iso88598e': return 'ISO-8859-8-E'; - case 'ISO_8859-8-I': - case 'CSISO88598I': - case 'ISO-8859-8-I': + case 'csiso88598i': + case 'iso88598i': return 'ISO-8859-8-I'; - case 'CSN_369103': - case 'ISO-IR-139': - case 'CSISO139CSN369103': - return 'CSN_369103'; + case 'cswindows31latin5': + case 'iso88599windowslatin5': + return 'ISO-8859-9-Windows-Latin-5'; - case 'JUS_I.B1.002': - case 'ISO-IR-141': - case 'ISO646-YU': - case 'JS': - case 'YU': - case 'CSISO141JUSIB1002': - return 'JUS_I.B1.002'; + case 'csisolatin6': + case 'iso885910': + case 'iso8859101992': + case 'isoir157': + case 'l6': + case 'latin6': + return 'ISO-8859-10'; - case 'IEC_P27-1': - case 'ISO-IR-143': - case 'CSISO143IECP271': - return 'IEC_P27-1'; + case 'iso885913': + return 'ISO-8859-13'; - case 'JUS_I.B1.003-SERB': - case 'ISO-IR-146': - case 'SERBIAN': - case 'CSISO146SERBIAN': - return 'JUS_I.B1.003-serb'; + case 'iso885914': + case 'iso8859141998': + case 'isoceltic': + case 'isoir199': + case 'l8': + case 'latin8': + return 'ISO-8859-14'; - case 'JUS_I.B1.003-MAC': - case 'MACEDONIAN': - case 'ISO-IR-147': - case 'CSISO147MACEDONIAN': - return 'JUS_I.B1.003-mac'; + case 'iso885915': + case 'latin9': + return 'ISO-8859-15'; - case 'GREEK-CCITT': - case 'ISO-IR-150': - case 'CSISO150': - case 'CSISO150GREEKCCITT': - return 'greek-ccitt'; + case 'iso885916': + case 'iso8859162001': + case 'isoir226': + case 'l10': + case 'latin10': + return 'ISO-8859-16'; - case 'NC_NC00-10:81': - case 'CUBA': - case 'ISO-IR-151': - case 'ISO646-CU': - case 'CSISO151CUBA': - return 'NC_NC00-10:81'; + 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 'ISO_6937-2-25': - case 'ISO-IR-152': - case 'CSISO6937ADD': + case 'csiso6937add': + case 'iso6937225': + case 'isoir152': 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 'csisotextcomm': + case 'iso69372add': + case 'isoir142': + return 'ISO_6937-2-add'; - case 'ISO_8859-SUPP': - case 'ISO-IR-154': - case 'LATIN1-2-5': - case 'CSISO8859SUPP': + case 'csiso8859supp': + case 'iso8859supp': + case 'isoir154': + case 'latin125': return 'ISO_8859-supp'; - case 'ISO_10367-BOX': - case 'ISO-IR-155': - case 'CSISO10367BOX': + case 'csiso10367box': + case 'iso10367box': + case 'isoir155': return 'ISO_10367-box'; - case 'LATIN-LAP': - case 'LAP': - case 'ISO-IR-158': - case 'CSISO158LAP': - return 'latin-lap'; + 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 'JIS_X0212-1990': - case 'X0212': - case 'ISO-IR-159': - case 'CSISO159JISX02121990': + case 'csiso159jisx2121990': + case 'isoir159': + case 'jisx2121990': + case 'x212': return 'JIS_X0212-1990'; - case 'DS_2089': - case 'DS2089': - case 'ISO646-DK': - case 'DK': - case 'CSISO646DANISH': - return 'DS_2089'; + case 'csiso141jusib1002': + case 'iso646yu': + case 'isoir141': + case 'js': + case 'jusib1002': + case 'yu': + return 'JUS_I.B1.002'; - case 'US-DK': - case 'CSUSDK': - return 'us-dk'; + case 'csiso147macedonian': + case 'isoir147': + case 'jusib1003mac': + case 'macedonian': + return 'JUS_I.B1.003-mac'; - case 'DK-US': - case 'CSDKUS': - return 'dk-us'; + 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 'KSC5636': - case 'ISO646-KR': - case 'CSKSC5636': + case 'csksc5636': + case 'iso646kr': + case 'ksc5636': return 'KSC5636'; - case 'UNICODE-1-1-UTF-7': - case 'CSUNICODE11UTF7': - return 'UNICODE-1-1-UTF-7'; + case 'cskz1048': + case 'kz1048': + case 'rk1048': + case 'strk10482002': + return 'KZ-1048'; - case 'ISO-2022-CN': - return 'ISO-2022-CN'; + case 'csiso19latingreek': + case 'isoir19': + case 'latingreek': + return 'latin-greek'; - case 'ISO-2022-CN-EXT': - return 'ISO-2022-CN-EXT'; + case 'csiso27latingreek1': + case 'isoir27': + case 'latingreek1': + return 'Latin-greek-1'; - case 'UTF-8': - return 'UTF-8'; + case 'csiso158lap': + case 'isoir158': + case 'lap': + case 'latinlap': + return 'latin-lap'; - case 'ISO-8859-13': - return 'ISO-8859-13'; + case 'csmacintosh': + case 'mac': + case 'macintosh': + return 'macintosh'; - 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 '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 'ISO-8859-15': - case 'ISO_8859-15': - case 'LATIN-9': - return 'ISO-8859-15'; + case 'csiso151cuba': + case 'cuba': + case 'iso646cu': + case 'isoir151': + case 'ncnc1081': + return 'NC_NC00-10:81'; - 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 'csiso69french': + case 'fr': + case 'iso646fr': + case 'isoir69': + case 'nfz62010': + return 'NF_Z_62-010'; - case 'GBK': - case 'CP936': - case 'MS936': - case 'WINDOWS-936': - return 'GBK'; + case 'csiso25french': + case 'iso646fr1': + case 'isoir25': + case 'nfz620101973': + return 'NF_Z_62-010_(1973)'; - case 'GB18030': - return 'GB18030'; + case 'csiso60danishnorwegian': + case 'csiso60norwegian1': + case 'iso646no': + case 'isoir60': + case 'no': + case 'ns45511': + return 'NS_4551-1'; - case 'OSD_EBCDIC_DF04_15': - return 'OSD_EBCDIC_DF04_15'; + case 'csiso61norwegian2': + case 'iso646no2': + case 'isoir61': + case 'no2': + case 'ns45512': + return 'NS_4551-2'; - case 'OSD_EBCDIC_DF03_IRV': + case 'osdebcdicdf3irv': return 'OSD_EBCDIC_DF03_IRV'; - case 'OSD_EBCDIC_DF04_1': + case 'osdebcdicdf41': 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 'osdebcdicdf415': + return 'OSD_EBCDIC_DF04_15'; - case 'ISO-10646-UCS-BASIC': - case 'CSUNICODEASCII': - return 'ISO-10646-UCS-Basic'; + case 'cspc8danishnorwegian': + case 'pc8danishnorwegian': + return 'PC8-Danish-Norwegian'; - case 'ISO-10646-UNICODE-LATIN1': - case 'CSUNICODELATIN1': - case 'ISO-10646': - return 'ISO-10646-Unicode-Latin1'; + case 'cspc8turkish': + case 'pc8turkish': + return 'PC8-Turkish'; - case 'ISO-10646-J-1': - return 'ISO-10646-J-1'; + case 'csiso16portuguese': + case 'iso646pt': + case 'isoir16': + case 'pt': + return 'PT'; - case 'ISO-UNICODE-IBM-1261': - case 'CSUNICODEIBM1261': - return 'ISO-Unicode-IBM-1261'; + case 'csiso84portuguese2': + case 'iso646pt2': + case 'isoir84': + case 'pt2': + return 'PT2'; - case 'ISO-UNICODE-IBM-1268': - case 'CSUNICODEIBM1268': - return 'ISO-Unicode-IBM-1268'; + case 'cp154': + case 'csptcp154': + case 'cyrillicasian': + case 'pt154': + case 'ptcp154': + return 'PTCP154'; - case 'ISO-UNICODE-IBM-1276': - case 'CSUNICODEIBM1276': - return 'ISO-Unicode-IBM-1276'; + case 'scsu': + return 'SCSU'; - case 'ISO-UNICODE-IBM-1264': - case 'CSUNICODEIBM1264': - return 'ISO-Unicode-IBM-1264'; + case 'csiso10swedish': + case 'fi': + case 'iso646fi': + case 'iso646se': + case 'isoir10': + case 'se': + case 'sen850200b': + return 'SEN_850200_B'; - case 'ISO-UNICODE-IBM-1265': - case 'CSUNICODEIBM1265': - return 'ISO-Unicode-IBM-1265'; + case 'csiso11swedishfornames': + case 'iso646se2': + case 'isoir11': + case 'se2': + case 'sen850200c': + return 'SEN_850200_C'; - case 'UNICODE-1-1': - case 'CSUNICODE11': - return 'UNICODE-1-1'; + case 'csshiftjis': + case 'mskanji': + case 'shiftjis': + return 'Shift_JIS'; - case 'SCSU': - return 'SCSU'; + case 'csiso102t617bit': + case 'isoir102': + case 't617bit': + return 'T.61-7bit'; - case 'UTF-7': - return 'UTF-7'; + case 'csiso103t618bit': + case 'isoir103': + case 't61': + case 't618bit': + return 'T.61-8bit'; - case 'UTF-16BE': - return 'UTF-16BE'; + case 'csiso128t101g2': + case 'isoir128': + case 't101g2': + return 'T.101-G2'; - case 'UTF-16LE': - return 'UTF-16LE'; + case 'cstscii': + case 'tscii': + return 'TSCII'; - case 'UTF-16': - return 'UTF-16'; + case 'csunicode11': + case 'unicode11': + return 'UNICODE-1-1'; - case 'CESU-8': - case 'CSCESU-8': - return 'CESU-8'; + case 'csunicode11utf7': + case 'unicode11utf7': + return 'UNICODE-1-1-UTF-7'; - case 'UTF-32': - return 'UTF-32'; + case 'csunknown8bit': + case 'unknown8bit': + return 'UNKNOWN-8BIT'; - case 'UTF-32BE': - return 'UTF-32BE'; + 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 'UTF-32LE': - return 'UTF-32LE'; + case 'csusdk': + case 'usdk': + return 'us-dk'; - case 'BOCU-1': - case 'CSBOCU-1': - return 'BOCU-1'; + case 'utf7': + return 'UTF-7'; - case 'ISO-8859-1-WINDOWS-3.0-LATIN-1': - case 'CSWINDOWS30LATIN1': - return 'ISO-8859-1-Windows-3.0-Latin-1'; + case 'utf8': + return 'UTF-8'; - case 'ISO-8859-1-WINDOWS-3.1-LATIN-1': - case 'CSWINDOWS31LATIN1': - return 'ISO-8859-1-Windows-3.1-Latin-1'; + case 'utf16': + return 'UTF-16'; - case 'ISO-8859-2-WINDOWS-LATIN-2': - case 'CSWINDOWS31LATIN2': - return 'ISO-8859-2-Windows-Latin-2'; + case 'utf16be': + return 'UTF-16BE'; - case 'ISO-8859-9-WINDOWS-LATIN-5': - case 'CSWINDOWS31LATIN5': - return 'ISO-8859-9-Windows-Latin-5'; + case 'utf16le': + return 'UTF-16LE'; - case 'HP-ROMAN8': - case 'ROMAN8': - case 'R8': - case 'CSHPROMAN8': - return 'hp-roman8'; + case 'utf32': + return 'UTF-32'; - case 'ADOBE-STANDARD-ENCODING': - case 'CSADOBESTANDARDENCODING': - return 'Adobe-Standard-Encoding'; + case 'utf32be': + return 'UTF-32BE'; - case 'VENTURA-US': - case 'CSVENTURAUS': - return 'Ventura-US'; + case 'utf32le': + return 'UTF-32LE'; - case 'VENTURA-INTERNATIONAL': - case 'CSVENTURAINTERNATIONAL': + case 'csventurainternational': + case 'venturainternational': 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 'csventuramath': + case 'venturamath': + return 'Ventura-Math'; - case 'IBM862': - case 'CP862': - case '862': - case 'CSPC862LATINHEBREW': - return 'IBM862'; + case 'csventuraus': + case 'venturaus': + return 'Ventura-US'; - case 'PC8-TURKISH': - case 'CSPC8TURKISH': - return 'PC8-Turkish'; + case 'csiso70videotexsupp1': + case 'isoir70': + case 'videotexsuppl': + return 'videotex-suppl'; - case 'IBM-SYMBOLS': - case 'CSIBMSYMBOLS': - return 'IBM-Symbols'; + case 'csviqr': + case 'viqr': + return 'VIQR'; - case 'IBM-THAI': - case 'CSIBMTHAI': - return 'IBM-Thai'; + case 'csviscii': + case 'viscii': + return 'VISCII'; - case 'HP-LEGAL': - case 'CSHPLEGAL': - return 'HP-Legal'; + case 'cswindows31j': + case 'windows31j': + return 'Windows-31J'; - case 'HP-PI-FONT': - case 'CSHPPIFONT': - return 'HP-Pi-font'; + 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 'HP-MATH8': - case 'CSHPMATH8': - return 'HP-Math8'; + case 'windows1251': + return 'windows-1251'; - case 'ADOBE-SYMBOL-ENCODING': - case 'CSHPPSMATH': - return 'Adobe-Symbol-Encoding'; + case 'cp819': + case 'csisolatin1': + case 'ibm819': + case 'iso88591': + case 'iso885911987': + case 'isoir100': + case 'l1': + case 'latin1': + case 'windows1252': + return 'windows-1252'; - case 'HP-DESKTOP': - case 'CSHPDESKTOP': - return 'HP-DeskTop'; + case 'windows1253': + return 'windows-1253'; - case 'VENTURA-MATH': - case 'CSVENTURAMATH': - return 'Ventura-Math'; + case 'csisolatin5': + case 'iso88599': + case 'iso885991989': + case 'isoir148': + case 'l5': + case 'latin5': + case 'windows1254': + return 'windows-1254'; - case 'MICROSOFT-PUBLISHING': - case 'CSMICROSOFTPUBLISHING': - return 'Microsoft-Publishing'; + case 'windows1255': + return 'windows-1255'; - case 'WINDOWS-31J': - case 'CSWINDOWS31J': - return 'Windows-31J'; + case 'windows1256': + return 'windows-1256'; - case 'GB2312': - case 'CSGB2312': - return 'GB2312'; + case 'windows1257': + return 'windows-1257'; - case 'BIG5': - case 'CSBIG5': - return 'Big5'; + case 'windows1258': + return 'windows-1258'; - case 'MACINTOSH': - case 'MAC': - case 'CSMACINTOSH': - return 'macintosh'; + default: + return $charset; + } + } - case 'IBM037': - case 'CP037': - case 'EBCDIC-CP-US': - case 'EBCDIC-CP-CA': - case 'EBCDIC-CP-WT': - case 'EBCDIC-CP-NL': - case 'CSIBM037': - return 'IBM037'; + function get_curl_version() + { + if (is_array($curl = curl_version())) + { + $curl = $curl['version']; + } + elseif (substr($curl, 0, 5) === 'curl/') + { + $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5)); + } + elseif (substr($curl, 0, 8) === 'libcurl/') + { + $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8)); + } + else + { + $curl = 0; + } + return $curl; + } - case 'IBM038': - case 'EBCDIC-INT': - case 'CP038': - case 'CSIBM038': - return 'IBM038'; + function is_subclass_of($class1, $class2) + { + if (func_num_args() !== 2) + { + trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING); + } + elseif (version_compare(PHP_VERSION, '5.0.3', '>=') || is_object($class1)) + { + return is_subclass_of($class1, $class2); + } + elseif (is_string($class1) && is_string($class2)) + { + if (class_exists($class1)) + { + if (class_exists($class2)) + { + $class2 = strtolower($class2); + while ($class1 = strtolower(get_parent_class($class1))) + { + if ($class1 === $class2) + { + return true; + } + } + } + } + else + { + trigger_error('Unknown class passed as parameter', E_USER_WARNNG); + } + } + return false; + } - case 'IBM273': - case 'CP273': - case 'CSIBM273': - return 'IBM273'; + /** + * Strip HTML comments + * + * @access public + * @param string $data Data to strip comments from + * @return string Comment stripped string + */ + function strip_comments($data) + { + $output = ''; + while (($start = strpos($data, '', $start)) !== false) + { + $data = substr_replace($data, '', 0, $end + 3); + } + else + { + $data = ''; + } + } + return $output . $data; + } - case 'IBM274': - case 'EBCDIC-BE': - case 'CP274': - case 'CSIBM274': - return 'IBM274'; + function parse_date($dt) + { + $parser = SimplePie_Parse_Date::get(); + return $parser->parse($dt); + } - case 'IBM275': - case 'EBCDIC-BR': - case 'CP275': - case 'CSIBM275': - return 'IBM275'; + /** + * Decode HTML entities + * + * @static + * @access public + * @param string $data Input data + * @return string Output data + */ + function entities_decode($data) + { + $decoder = new SimplePie_Decode_HTML_Entities($data); + return $decoder->parse(); + } - case 'IBM277': - case 'EBCDIC-CP-DK': - case 'EBCDIC-CP-NO': - case 'CSIBM277': - return 'IBM277'; + /** + * Remove RFC822 comments + * + * @access public + * @param string $data Data to strip comments from + * @return string Comment stripped string + */ + function uncomment_rfc822($string) + { + $string = (string) $string; + $position = 0; + $length = strlen($string); + $depth = 0; - case 'IBM278': - case 'CP278': - case 'EBCDIC-CP-FI': - case 'EBCDIC-CP-SE': - case 'CSIBM278': - return 'IBM278'; + $output = ''; - case 'IBM280': - case 'CP280': - case 'EBCDIC-CP-IT': - case 'CSIBM280': - return 'IBM280'; + 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 'IBM281': - case 'EBCDIC-JP-E': - case 'CP281': - case 'CSIBM281': - return 'IBM281'; + case ')': + $depth--; + break; + } + $position++; + } + else + { + break; + } + } + } + else + { + $output .= '('; + } + } + $output .= substr($string, $position); - case 'IBM284': - case 'CP284': - case 'EBCDIC-CP-ES': - case 'CSIBM284': - return 'IBM284'; + return $output; + } - case 'IBM285': - case 'CP285': - case 'EBCDIC-CP-GB': - case 'CSIBM285': - return 'IBM285'; + function parse_mime($mime) + { + if (($pos = strpos($mime, ';')) === false) + { + return trim($mime); + } + else + { + return trim(substr($mime, 0, $pos)); + } + } - case 'IBM290': - case 'CP290': - case 'EBCDIC-JP-KANA': - case 'CSIBM290': - return 'IBM290'; + function htmlspecialchars_decode($string, $quote_style) + { + if (function_exists('htmlspecialchars_decode')) + { + return htmlspecialchars_decode($string, $quote_style); + } + else + { + return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style))); + } + } - case 'IBM297': - case 'CP297': - case 'EBCDIC-CP-FR': - case 'CSIBM297': - return 'IBM297'; + function atom_03_construct_type($attribs) + { + if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64')) + { + $mode = SIMPLEPIE_CONSTRUCT_BASE64; + } + else + { + $mode = SIMPLEPIE_CONSTRUCT_NONE; + } + if (isset($attribs['']['type'])) + { + switch (strtolower(trim($attribs['']['type']))) + { + case 'text': + case 'text/plain': + return SIMPLEPIE_CONSTRUCT_TEXT | $mode; - case 'IBM420': - case 'CP420': - case 'EBCDIC-CP-AR1': - case 'CSIBM420': - return 'IBM420'; + case 'html': + case 'text/html': + return SIMPLEPIE_CONSTRUCT_HTML | $mode; - case 'IBM423': - case 'CP423': - case 'EBCDIC-CP-GR': - case 'CSIBM423': - return 'IBM423'; + case 'xhtml': + case 'application/xhtml+xml': + return SIMPLEPIE_CONSTRUCT_XHTML | $mode; - case 'IBM424': - case 'CP424': - case 'EBCDIC-CP-HE': - case 'CSIBM424': - return 'IBM424'; + default: + return SIMPLEPIE_CONSTRUCT_NONE | $mode; + } + } + else + { + return SIMPLEPIE_CONSTRUCT_TEXT | $mode; + } + } - case 'IBM437': - case 'CP437': - case '437': - case 'CSPC8CODEPAGE437': - return 'IBM437'; + function atom_10_construct_type($attribs) + { + if (isset($attribs['']['type'])) + { + switch (strtolower(trim($attribs['']['type']))) + { + case 'text': + return SIMPLEPIE_CONSTRUCT_TEXT; - case 'IBM500': - case 'CP500': - case 'EBCDIC-CP-BE': - case 'EBCDIC-CP-CH': - case 'CSIBM500': - return 'IBM500'; + case 'html': + return SIMPLEPIE_CONSTRUCT_HTML; - case 'IBM851': - case 'CP851': - case '851': - case 'CSIBM851': - return 'IBM851'; + case 'xhtml': + return SIMPLEPIE_CONSTRUCT_XHTML; - case 'IBM852': - case 'CP852': - case '852': - case 'CSPCP852': - return 'IBM852'; + default: + return SIMPLEPIE_CONSTRUCT_NONE; + } + } + return SIMPLEPIE_CONSTRUCT_TEXT; + } - case 'IBM855': - case 'CP855': - case '855': - case 'CSIBM855': - return 'IBM855'; + function atom_10_content_construct_type($attribs) + { + if (isset($attribs['']['type'])) + { + $type = strtolower(trim($attribs['']['type'])); + switch ($type) + { + case 'text': + return SIMPLEPIE_CONSTRUCT_TEXT; - case 'IBM857': - case 'CP857': - case '857': - case 'CSIBM857': - return 'IBM857'; + case 'html': + return SIMPLEPIE_CONSTRUCT_HTML; - case 'IBM860': - case 'CP860': - case '860': - case 'CSIBM860': - return 'IBM860'; + case 'xhtml': + return SIMPLEPIE_CONSTRUCT_XHTML; + } + if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/') + { + return SIMPLEPIE_CONSTRUCT_NONE; + } + else + { + return SIMPLEPIE_CONSTRUCT_BASE64; + } + } + else + { + return SIMPLEPIE_CONSTRUCT_TEXT; + } + } - case 'IBM861': - case 'CP861': - case '861': - case 'CP-IS': - case 'CSIBM861': - return 'IBM861'; + function is_isegment_nz_nc($string) + { + return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string); + } - case 'IBM863': - case 'CP863': - case '863': - case 'CSIBM863': - return 'IBM863'; + function space_seperated_tokens($string) + { + $space_characters = "\x20\x09\x0A\x0B\x0C\x0D"; + $string_length = strlen($string); - case 'IBM864': - case 'CP864': - case 'CSIBM864': - return 'IBM864'; + $position = strspn($string, $space_characters); + $tokens = array(); - case 'IBM865': - case 'CP865': - case '865': - case 'CSIBM865': - return 'IBM865'; + while ($position < $string_length) + { + $len = strcspn($string, $space_characters, $position); + $tokens[] = substr($string, $position, $len); + $position += $len; + $position += strspn($string, $space_characters, $position); + } - case 'IBM868': - case 'CP868': - case 'CP-AR': - case 'CSIBM868': - return 'IBM868'; + return $tokens; + } - case 'IBM869': - case 'CP869': - case '869': - case 'CP-GR': - case 'CSIBM869': - return 'IBM869'; + function array_unique($array) + { + if (version_compare(PHP_VERSION, '5.2', '>=')) + { + return array_unique($array); + } + else + { + $array = (array) $array; + $new_array = array(); + $new_array_strings = array(); + foreach ($array as $key => $value) + { + if (is_object($value)) + { + if (method_exists($value, '__toString')) + { + $cmp = $value->__toString(); + } + else + { + trigger_error('Object of class ' . get_class($value) . ' could not be converted to string', E_USER_ERROR); + } + } + elseif (is_array($value)) + { + $cmp = (string) reset($value); + } + else + { + $cmp = (string) $value; + } + if (!in_array($cmp, $new_array_strings)) + { + $new_array[$key] = $value; + $new_array_strings[] = $cmp; + } + } + return $new_array; + } + } - case 'IBM870': - case 'CP870': - case 'EBCDIC-CP-ROECE': - case 'EBCDIC-CP-YU': - case 'CSIBM870': - return 'IBM870'; + /** + * Converts a unicode codepoint to a UTF-8 character + * + * @static + * @access public + * @param int $codepoint Unicode codepoint + * @return string UTF-8 character + */ + function codepoint_to_utf8($codepoint) + { + $codepoint = (int) $codepoint; + if ($codepoint < 0) + { + return false; + } + else if ($codepoint <= 0x7f) + { + return chr($codepoint); + } + else if ($codepoint <= 0x7ff) + { + return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); + } + else if ($codepoint <= 0xffff) + { + return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); + } + else if ($codepoint <= 0x10ffff) + { + 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 "\xEF\xBF\xBD"; + } + } - case 'IBM871': - case 'CP871': - case 'EBCDIC-CP-IS': - case 'CSIBM871': - return 'IBM871'; + /** + * Re-implementation of PHP 5's stripos() + * + * Returns the numeric position of the first occurrence of needle in the + * haystack string. + * + * @static + * @access string + * @param object $haystack + * @param string $needle Note that the needle may be a string of one or more + * characters. If needle is not a string, it is converted to an integer + * and applied as the ordinal value of a character. + * @param int $offset The optional offset parameter allows you to specify which + * character in haystack to start searching. The position returned is still + * 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; + } - case 'IBM880': - case 'CP880': - case 'EBCDIC-CYRILLIC': - case 'CSIBM880': - return 'IBM880'; + return strpos(strtolower($haystack), $needle, $offset); + } + } - case 'IBM891': - case 'CP891': - case 'CSIBM891': - return 'IBM891'; + /** + * 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); - case 'IBM903': - case 'CP903': - case 'CSIBM903': - return 'IBM903'; + foreach ($str as $section) + { + if (strpos($section, '=') !== false) + { + list($name, $value) = explode('=', $section, 2); + $return[urldecode($name)][] = urldecode($value); + } + else + { + $return[urldecode($section)][] = null; + } + } - case 'IBM904': - case 'CP904': - case '904': - case 'CSIBBM904': - return 'IBM904'; + return $return; + } - case 'IBM905': - case 'CP905': - case 'EBCDIC-CP-TR': - case 'CSIBM905': - return 'IBM905'; + /** + * 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; + } - case 'IBM918': - case 'CP918': - case 'EBCDIC-CP-AR2': - case 'CSIBM918': - return 'IBM918'; + 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(''); +} - case 'IBM1026': - case 'CP1026': - case 'CSIBM1026': - return 'IBM1026'; +function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { + if (placeholder != '') { + document.writeln(''); + } + else { + document.writeln(''); + } +} - case 'EBCDIC-AT-DE': - case 'CSIBMEBCDICATDE': - return 'EBCDIC-AT-DE'; +function embed_flash(bgcolor, width, height, link, loop, type) { + document.writeln(''); +} - case 'EBCDIC-AT-DE-A': - case 'CSEBCDICATDEA': - return 'EBCDIC-AT-DE-A'; +function embed_flv(width, height, link, placeholder, loop, player) { + document.writeln(''); +} - case 'EBCDIC-CA-FR': - case 'CSEBCDICCAFR': - return 'EBCDIC-CA-FR'; +function embed_wmedia(width, height, link) { + document.writeln(''); +} + data = $data; + } - case 'EBCDIC-FR': - case 'CSEBCDICFR': - return 'EBCDIC-FR'; + /** + * Parse the input data + * + * @access public + * @return string Output data + */ + function parse() + { + while (($this->position = strpos($this->data, '&', $this->position)) !== false) + { + $this->consume(); + $this->entity(); + $this->consumed = ''; + } + return $this->data; + } - case 'EBCDIC-IT': - case 'CSEBCDICIT': - return 'EBCDIC-IT'; + /** + * Consume the next byte + * + * @access private + * @return mixed The next byte, or false, if there is no more data + */ + function consume() + { + if (isset($this->data[$this->position])) + { + $this->consumed .= $this->data[$this->position]; + return $this->data[$this->position++]; + } + else + { + return false; + } + } - case 'EBCDIC-PT': - case 'CSEBCDICPT': - return 'EBCDIC-PT'; + /** + * Consume a range of characters + * + * @access private + * @param string $chars Characters to consume + * @return mixed A series of characters that match the range, or false + */ + function consume_range($chars) + { + if ($len = strspn($this->data, $chars, $this->position)) + { + $data = substr($this->data, $this->position, $len); + $this->consumed .= $data; + $this->position += $len; + return $data; + } + else + { + return false; + } + } - case 'EBCDIC-ES': - case 'CSEBCDICES': - return 'EBCDIC-ES'; + /** + * Unconsume one byte + * + * @access private + */ + function unconsume() + { + $this->consumed = substr($this->consumed, 0, -1); + $this->position--; + } - case 'EBCDIC-ES-A': - case 'CSEBCDICESA': - return 'EBCDIC-ES-A'; + /** + * Decode an entity + * + * @access private + */ + function entity() + { + switch ($this->consume()) + { + case "\x09": + case "\x0A": + case "\x0B": + case "\x0B": + case "\x0C": + case "\x20": + case "\x3C": + case "\x26": + case false: + break; - case 'EBCDIC-ES-S': - case 'CSEBCDICESS': - return 'EBCDIC-ES-S'; + case "\x23": + switch ($this->consume()) + { + case "\x78": + case "\x58": + $range = '0123456789ABCDEFabcdef'; + $hex = true; + break; - case 'EBCDIC-UK': - case 'CSEBCDICUK': - return 'EBCDIC-UK'; + default: + $range = '0123456789'; + $hex = false; + $this->unconsume(); + break; + } - case 'EBCDIC-US': - case 'CSEBCDICUS': - return 'EBCDIC-US'; + if ($codepoint = $this->consume_range($range)) + { + static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"); - case 'UNKNOWN-8BIT': - case 'CSUNKNOWN8BIT': - return 'UNKNOWN-8BIT'; + if ($hex) + { + $codepoint = hexdec($codepoint); + } + else + { + $codepoint = intval($codepoint); + } - case 'MNEMONIC': - case 'CSMNEMONIC': - return 'MNEMONIC'; + if (isset($windows_1252_specials[$codepoint])) + { + $replacement = $windows_1252_specials[$codepoint]; + } + else + { + $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); + } - case 'MNEM': - case 'CSMNEM': - return 'MNEM'; + if (!in_array($this->consume(), array(';', false), true)) + { + $this->unconsume(); + } - case 'VISCII': - case 'CSVISCII': - return 'VISCII'; + $consumed_length = strlen($this->consumed); + $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length); + $this->position += strlen($replacement) - $consumed_length; + } + break; - case 'VIQR': - case 'CSVIQR': - return 'VIQR'; + 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"); - case 'KOI8-R': - case 'CSKOI8R': - return 'KOI8-R'; + for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) + { + $consumed = substr($this->consumed, 1); + if (isset($entities[$consumed])) + { + $match = $consumed; + } + } - case 'HZ-GB-2312': - return 'HZ-GB-2312'; + if ($match !== null) + { + $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); + $this->position += strlen($entities[$match]) - strlen($consumed) - 1; + } + break; + } + } +} - case 'IBM866': - case 'CP866': - case '866': - case 'CSIBM866': - return 'IBM866'; +/** + * IRI parser/serialiser + * + * @package SimplePie + */ +class SimplePie_IRI +{ + /** + * Scheme + * + * @access private + * @var string + */ + var $scheme; - case 'IBM775': - case 'CP775': - case 'CSPC775BALTIC': - return 'IBM775'; + /** + * User Information + * + * @access private + * @var string + */ + var $userinfo; - case 'KOI8-U': - return 'KOI8-U'; + /** + * Host + * + * @access private + * @var string + */ + var $host; - case 'IBM00858': - case 'CCSID00858': - case 'CP00858': - case 'PC-MULTILINGUAL-850+EURO': - return 'IBM00858'; + /** + * Port + * + * @access private + * @var string + */ + var $port; - case 'IBM00924': - case 'CCSID00924': - case 'CP00924': - case 'EBCDIC-LATIN9--EURO': - return 'IBM00924'; + /** + * Path + * + * @access private + * @var string + */ + var $path; - case 'IBM01140': - case 'CCSID01140': - case 'CP01140': - case 'EBCDIC-US-37+EURO': - return 'IBM01140'; + /** + * Query + * + * @access private + * @var string + */ + var $query; - case 'IBM01141': - case 'CCSID01141': - case 'CP01141': - case 'EBCDIC-DE-273+EURO': - return 'IBM01141'; + /** + * Fragment + * + * @access private + * @var string + */ + var $fragment; - case 'IBM01142': - case 'CCSID01142': - case 'CP01142': - case 'EBCDIC-DK-277+EURO': - case 'EBCDIC-NO-277+EURO': - return 'IBM01142'; + /** + * Whether the object represents a valid IRI + * + * @access private + * @var array + */ + var $valid = array(); - case 'IBM01143': - case 'CCSID01143': - case 'CP01143': - case 'EBCDIC-FI-278+EURO': - case 'EBCDIC-SE-278+EURO': - return 'IBM01143'; + /** + * Return the entire IRI when you try and read the object as a string + * + * @access public + * @return string + */ + function __toString() + { + return $this->get_iri(); + } - case 'IBM01144': - case 'CCSID01144': - case 'CP01144': - case 'EBCDIC-IT-280+EURO': - return 'IBM01144'; + /** + * 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']); + } + } - case 'IBM01145': - case 'CCSID01145': - case 'CP01145': - case 'EBCDIC-ES-284+EURO': - return 'IBM01145'; + /** + * 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; + } - case 'IBM01146': - case 'CCSID01146': - case 'CP01146': - case 'EBCDIC-GB-285+EURO': - return 'IBM01146'; + /** + * 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]); + } - case 'IBM01147': - case 'CCSID01147': - case 'CP01147': - case 'EBCDIC-FR-297+EURO': - return 'IBM01147'; + /** + * 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; + } - case 'IBM01148': - case 'CCSID01148': - case 'CP01148': - case 'EBCDIC-INTERNATIONAL-500+EURO': - return 'IBM01148'; + /** + * 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); + } - case 'IBM01149': - case 'CCSID01149': - case 'CP01149': - case 'EBCDIC-IS-871+EURO': - return 'IBM01149'; + // Store position and string length (to avoid constantly recalculating this) + $position = 0; + $strlen = strlen($string); - case 'BIG5-HKSCS': - return 'Big5-HKSCS'; + // 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))); - case 'IBM1047': - case 'IBM-1047': - return 'IBM1047'; + // 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++; + } - case 'PTCP154': - case 'CSPTCP154': - case 'PT154': - case 'CP154': - case 'CYRILLIC-ASIAN': - return 'PTCP154'; + // 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; + } - case 'AMIGA-1251': - case 'AMI1251': - case 'AMIGA1251': - case 'AMI-1251': - return 'Amiga-1251'; + /** + * Check if the object represents a valid IRI + * + * @access public + * @return bool + */ + function is_valid() + { + return array_sum($this->valid) === count($this->valid); + } - case 'KOI7-SWITCHED': - return 'KOI7-switched'; + /** + * 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 'BRF': - case 'CSBRF': - return 'BRF'; + 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; + } - case 'TSCII': - case 'CSTSCII': - return 'TSCII'; + /** + * 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; + } - case 'WINDOWS-1250': - return 'windows-1250'; + if (($port_start = strpos($authority, ':')) !== false) + { + $port = substr($authority, $port_start + 1); + $authority = substr($authority, 0, $port_start); + } + else + { + $port = null; + } - case 'WINDOWS-1251': - return 'windows-1251'; + return $this->set_userinfo($userinfo) && $this->set_host($authority) && $this->set_port($port); + } - case 'WINDOWS-1252': - return 'windows-1252'; + /** + * 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; + } - case 'WINDOWS-1253': - return 'windows-1253'; + /** + * 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; + } + } - case 'WINDOWS-1254': - return 'windows-1254'; + /** + * 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; + } + } - case 'WINDOWS-1255': - return 'windows-1255'; + /** + * 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; + } + } - case 'WINDOWS-1256': - return 'windows-1256'; + /** + * 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; + } - case 'WINDOWS-1257': - return 'windows-1257'; + /** + * 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; + } - case 'WINDOWS-1258': - return 'windows-1258'; + /** + * 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; + } - default: - return (string) $encoding; + if ($iri !== '') + { + return $iri; + } + else + { + return null; } } - function get_curl_version() + /** + * Get the scheme + * + * @access public + * @return string + */ + function get_scheme() { - if (is_array($curl = curl_version())) + return $this->scheme; + } + + /** + * Get the complete authority + * + * @access public + * @return string + */ + function get_authority() + { + $authority = ''; + if ($this->userinfo !== null) { - $curl = $curl['version']; + $authority .= $this->userinfo . '@'; } - elseif (substr($curl, 0, 5) == 'curl/') + if ($this->host !== null) { - $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5)); + $authority .= $this->host; } - elseif (substr($curl, 0, 8) == 'libcurl/') + if ($this->port !== null) { - $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8)); + $authority .= ':' . $this->port; + } + + if ($authority !== '') + { + return $authority; } else { - $curl = 0; + return null; } - return $curl; } - function is_subclass_of($class1, $class2) + /** + * Get the user information + * + * @access public + * @return string + */ + function get_userinfo() + { + return $this->userinfo; + } + + /** + * Get the host + * + * @access public + * @return string + */ + function get_host() { - if (func_num_args() != 2) + 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) { - trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING); + list($addr, $nm) = explode('/', $ip); } - elseif (version_compare(PHP_VERSION, '5.0.3', '>=') || is_object($class1)) + else { - return is_subclass_of($class1, $class2); + $addr = $ip; } - elseif (is_string($class1) && is_string($class2)) + 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) { - if (class_exists($class1)) + 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 === '') { - if (class_exists($class2)) + $c2 = -1; + } + else + { + $pos = 0; + if (($pos = substr_count($ip2, ':')) > 0) { - $class2 = strtolower($class2); - while ($class1 = strtolower(get_parent_class($class1))) - { - if ($class1 == $class2) - { - return true; - } - } + $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 { - trigger_error('Unknown class passed as parameter', E_USER_WARNING); + $fill = str_repeat(':0:', 6 - $c2 - $c1); + $uip = str_replace('::', $fill, $uip); + $uip = str_replace('::', ':', $uip); } } - return false; + return $uip; } /** - * Strip HTML comments + * 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 - * @param string $data Data to strip comments from - * @return string Comment stripped string + * @static + * @param string $ip a valid IPv6-address (hex format) + * @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format) */ - function strip_comments($data) + function SplitV64($ip) { - $output = ''; - while (($start = strpos($data, '', $start)) !== false) - { - $data = substr_replace($data, '', 0, $end + 3); - } - else - { - $data = ''; - } + $pos = strrpos($ip, ':'); + $ip[$pos] = '_'; + $ipPart = explode('_', $ip); + return $ipPart; + } + else + { + return array($ip, ''); } - return $output . $data; } - function parse_date($dt, $rfc822_tz = true) + /** + * 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) { - static $cache = array(); - if (!isset($cache[$dt][$rfc822_tz])) + $ipPart = SimplePie_Net_IPv6::SplitV64($ip); + $count = 0; + if (!empty($ipPart[0])) { - $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)) + $ipv6 = explode(':', $ipPart[0]); + for ($i = 0; $i < count($ipv6); $i++) { - // Fill all matches - for ($i = count($match); $i <= 28; $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))) { - $match[$i] = ''; + $count++; } - - // Set blank vars - $year = 1970; - $month = 1; - $day = 1; - $hour = 0; - $minute = 0; - $second = 0; - $timezone = false; - - // RFC 822 - if ($match[1] !== '') + } + if ($count === 8) + { + return true; + } + elseif ($count === 6 && !empty($ipPart[1])) + { + $ipv4 = explode('.', $ipPart[1]); + $count = 0; + foreach ($ipv4 as $ipv4_part) { - if (strlen($match[4]) == 2) - { - $year = ($match[4] < 70) ? "20$match[4]" : "19$match[4]"; - } - else + if ($ipv4_part >= 0 && $ipv4_part <= 255 && preg_match('/^\d{1,3}$/', $ipv4_part)) { - $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; + $count++; } - $day = $match[2]; } - // ISO 8601 - else + if ($count === 4) { - // 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"; - } + return true; } - // 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])); + } + else + { + return false; + } - if ($timezone > 74) - { - $timezone--; - } + } + else + { + return false; + } + } +} - if ($timezone <= 76) - { - $timezone = -($timezone - 64); - } - else - { - $timezone -= 76; - } +/** + * Date Parser + * + * @package SimplePie + */ +class SimplePie_Parse_Date +{ + /** + * Input data + * + * @access protected + * @var string + */ + var $date; - $timezone *= 3600; - } - } - // Code - else - { - switch (strtoupper($match[28])) - { - case 'UT': - case 'UTC': - case 'GMT': - $timezone = 0; - break; + /** + * 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, + ); - case 'EST': - $timezone = -18000; - break; + /** + * 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, + ); - case 'CST': - $timezone = -21600; - break; + /** + * 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, + ); - case 'MST': - $timezone = -25200; - break; + /** + * Cached PCRE for SimplePie_Parse_Date::$day + * + * @access protected + * @var string + */ + var $day_pcre; - case 'PST': - $timezone = -28800; - break; + /** + * Cached PCRE for SimplePie_Parse_Date::$month + * + * @access protected + * @var string + */ + var $month_pcre; - case 'EDT': - $timezone = -14400; - break; + /** + * Array of user-added callback methods + * + * @access private + * @var array + */ + var $built_in = array(); - case 'CDT': - $timezone = -18000; - break; + /** + * Array of user-added callback methods + * + * @access private + * @var array + */ + var $user = array(); - case 'MDT': - $timezone = -21600; - break; + /** + * 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), '|') . ')'; - 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); + static $cache; + if (!isset($cache[get_class($this)])) + { + $all_methods = get_class_methods($this); - if ($match[23] == '-') - { - $timezone = -$timezone; - } - } - } - } - if ($timezone === false) - { - $cache[$dt][$rfc822_tz] = mktime($hour, $minute, $second, $month, $day, $year); - } - else + foreach ($all_methods as $method) + { + if (strtolower(substr($method, 0, 5)) === 'date_') { - $cache[$dt][$rfc822_tz] = gmmktime($hour, $minute, $second, $month, $day, $year) - $timezone; + $cache[get_class($this)][] = $method; } } - elseif (($time = strtotime($dt)) > 0) - { - $cache[$dt][$rfc822_tz] = $time; - } - else - { - $cache[$dt][$rfc822_tz] = false; - } } - return $cache[$dt][$rfc822_tz]; + + foreach ($cache[get_class($this)] as $method) + { + $this->built_in[] = $method; + } } /** - * Decode HTML entities + * Get the object * - * @static * @access public - * @param string $data Input data - * @return string Output data */ - function entities_decode($data) + function get() { - $decoder = new SimplePie_Decode_HTML_Entities($data); - return $decoder->parse(); + static $object; + if (!$object) + { + $object = new SimplePie_Parse_Date; + } + return $object; } /** - * Remove RFC822 comments + * Parse a date * - * @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 + * @final * @access public - * @param string $data Data to strip comments from - * @return string Comment stripped string + * @param string $date Date to parse + * @return int Timestamp corresponding to date string, or false on failure */ - function uncomment_rfc822($data) - { - if ((version_compare(PHP_VERSION, '4.4.6', '>=') && version_compare(PHP_VERSION, '5', '<')) || version_compare(PHP_VERSION, '5.2.2', '>=')) - { - return $data; - } - else - { - return preg_replace('/((?:(?:\\\\"|[^("])*(?:"(?:[^"\\\\\r]|\\\\.)*"\s*)?)*)((?user as $method) { - return trim($mime); + if (($returned = call_user_func($method, $date)) !== false) + { + return $returned; + } } - else + + foreach ($this->built_in as $method) { - return trim(substr($mime, 0, $pos)); + if (($returned = call_user_func(array(&$this, $method), $date)) !== false) + { + return $returned; + } } + + return false; } - function htmlspecialchars_decode($string, $quote_style) + /** + * Add a callback method to parse a date + * + * @final + * @access public + * @param callback $callback + */ + function add_callback($callback) { - if (function_exists('htmlspecialchars_decode')) + if (is_callable($callback)) { - return htmlspecialchars_decode($string, $quote_style); + $this->user[] = $callback; } else { - return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style))); + trigger_error('User-supplied function must be a valid callback', E_USER_WARNING); } } - function atom_03_construct_type($attribs) + /** + * 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) { - if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) == 'base64')) - { - $mode = SIMPLEPIE_CONSTRUCT_BASE64; - } - else + static $pcre; + if (!$pcre) { - $mode = SIMPLEPIE_CONSTRUCT_NONE; + $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 (isset($attribs['']['type'])) + if (preg_match($pcre, $date, $match)) { - switch (strtolower(trim($attribs['']['type']))) - { - case 'text': - case 'text/plain': - return SIMPLEPIE_CONSTRUCT_TEXT | $mode; + /* + 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 + */ - case 'html': - case 'text/html': - return SIMPLEPIE_CONSTRUCT_HTML | $mode; + // Fill in empty matches + for ($i = count($match); $i <= 3; $i++) + { + $match[$i] = '1'; + } - case 'xhtml': - case 'application/xhtml+xml': - return SIMPLEPIE_CONSTRUCT_XHTML | $mode; + for ($i = count($match); $i <= 7; $i++) + { + $match[$i] = '0'; + } - default: - return SIMPLEPIE_CONSTRUCT_NONE | $mode; + // 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 SIMPLEPIE_CONSTRUCT_TEXT | $mode; + return false; } } - function atom_10_construct_type($attribs) + /** + * Remove RFC822 comments + * + * @access protected + * @param string $data Data to strip comments from + * @return string Comment stripped string + */ + function remove_rfc2822_comments($string) { - if (isset($attribs['']['type'])) - { - switch (strtolower(trim($attribs['']['type']))) - { - case 'text': - return SIMPLEPIE_CONSTRUCT_TEXT; + $string = (string) $string; + $position = 0; + $length = strlen($string); + $depth = 0; - case 'html': - return SIMPLEPIE_CONSTRUCT_HTML; + $output = ''; - case 'xhtml': - return SIMPLEPIE_CONSTRUCT_XHTML; + 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; - default: - return SIMPLEPIE_CONSTRUCT_NONE; + case ')': + $depth--; + break; + } + $position++; + } + else + { + break; + } + } + } + else + { + $output .= '('; } } - return SIMPLEPIE_CONSTRUCT_TEXT; + $output .= substr($string, $position); + + return $output; } - function atom_10_content_construct_type($attribs) + /** + * Parse RFC2822's date format + * + * @access protected + * @return int Timestamp + */ + function date_rfc2822($date) { - if (isset($attribs['']['type'])) + static $pcre; + if (!$pcre) { - $type = strtolower(trim($attribs['']['type'])); - switch ($type) - { - case 'text': - return SIMPLEPIE_CONSTRUCT_TEXT; + $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 + */ - case 'html': - return SIMPLEPIE_CONSTRUCT_HTML; + // Find the month number + $month = $this->month[strtolower($match[3])]; - case 'xhtml': - return SIMPLEPIE_CONSTRUCT_XHTML; + // Numeric timezone + if ($match[8] !== '') + { + $timezone = $match[9] * 3600; + $timezone += $match[10] * 60; + if ($match[8] === '-') + { + $timezone = 0 - $timezone; + } } - if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) == 'text/') + // Character timezone + elseif (isset($this->timezone[strtoupper($match[11])])) { - return SIMPLEPIE_CONSTRUCT_NONE; + $timezone = $this->timezone[strtoupper($match[11])]; } + // Assume everything else to be -0000 else { - return SIMPLEPIE_CONSTRUCT_BASE64; + $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 SIMPLEPIE_CONSTRUCT_TEXT; + return false; } } - function is_isegment_nz_nc($string) + /** + * Parse RFC850's date format + * + * @access protected + * @return int Timestamp + */ + function date_rfc850($date) { - return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string); - } + 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 + */ - function space_seperated_tokens($string) - { - $space_characters = "\x20\x09\x0A\x0B\x0C\x0D"; - $string_length = strlen($string); + // Month + $month = $this->month[strtolower($match[3])]; - $position = strspn($string, $space_characters); - $tokens = array(); + // Character timezone + if (isset($this->timezone[strtoupper($match[8])])) + { + $timezone = $this->timezone[strtoupper($match[8])]; + } + // Assume everything else to be -0000 + else + { + $timezone = 0; + } - while ($position < $string_length) + // 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 { - $len = strcspn($string, $space_characters, $position); - $tokens[] = substr($string, $position, $len); - $position += $len; - $position += strspn($string, $space_characters, $position); + return false; } + } - return $tokens; + /** + * 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; + } } - function array_unique($array) + /** + * Parse dates using strtotime() + * + * @access protected + * @return int Timestamp + */ + function date_strtotime($date) { - if (version_compare(PHP_VERSION, '5.2', '>=')) + $strtotime = strtotime($date); + if ($strtotime === -1 || $strtotime === false) { - return array_unique($array); + return false; } else { - $array = (array) $array; - $new_array = array(); - $new_array_strings = array(); - foreach ($array as $key => $value) + 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')) { - if (is_object($value)) - { - if (method_exists($value, '__toString')) - { - $cmp = $value->__toString(); - } - else - { - trigger_error('Object of class ' . get_class($value) . ' could not be converted to string', E_USER_ERROR); - } - } - elseif (is_array($value)) + 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()) { - $cmp = (string) reset($value); + return $return; } else { - $cmp = (string) $value; - } - if (!in_array($cmp, $new_array_strings)) - { - $new_array[$key] = $value; - $new_array_strings[] = $cmp; + return $official; } } - return $new_array; + elseif ($official === 'text/html') + { + return $this->feed_or_html(); + } + else + { + return $official; + } + } + else + { + return $this->unknown(); } } /** - * Converts a unicode codepoint to a UTF-8 character + * Sniff text or binary * - * @static - * @access public - * @param int $codepoint Unicode codepoint - * @return string UTF-8 character + * @access private + * @return string Actual Content-Type */ - function codepoint_to_utf8($codepoint) + function text_or_binary() { - static $cache = array(); - $codepoint = (int) $codepoint; - if (isset($cache[$codepoint])) + 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 $cache[$codepoint]; + return 'text/plain'; } - elseif ($codepoint < 0) + elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body)) { - return $cache[$codepoint] = false; + return 'application/octect-stream'; } - else if ($codepoint <= 0x7f) + else { - return $cache[$codepoint] = chr($codepoint); + return 'text/plain'; } - else if ($codepoint <= 0x7ff) + } + + /** + * 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)) === '> 6)) . chr(0x80 | ($codepoint & 0x3f)); + return 'text/html'; } - else if ($codepoint <= 0xffff) + elseif (substr($this->file->body, 0, 5) === '%PDF-') { - return $cache[$codepoint] = chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); + return 'application/pdf'; } - else if ($codepoint <= 0x10ffff) + 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 $cache[$codepoint] = chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); + return 'image/bmp'; } else { - // U+FFFD REPLACEMENT CHARACTER - return $cache[$codepoint] = "\xEF\xBF\xBD"; + return $this->text_or_binary(); } } /** - * Re-implementation of PHP 4.2.0's is_a() + * Sniff images * - * @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); - } - } + * @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; + } + } /** - * Re-implementation of PHP 5's stripos() - * - * Returns the numeric position of the first occurrence of needle in the - * haystack string. + * Sniff HTML * - * @static - * @access string - * @param object $haystack - * @param string $needle Note that the needle may be a string of one or more - * characters. If needle is not a string, it is converted to an integer - * and applied as the ordinal value of a character. - * @param int $offset The optional offset parameter allows you to specify which - * character in haystack to start searching. The position returned is still - * relative to the beginning of haystack. - * @return bool If needle is not found, stripos() will return boolean false. + * @access private + * @return string Actual Content-Type */ - 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); - } - } + 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'; + } } /** - * Decode HTML Entities - * - * This implements HTML5 as of revision 967 (2007-06-28) + * Parses the XML Declaration * * @package SimplePie */ -class SimplePie_Decode_HTML_Entities +class SimplePie_XML_Declaration_Parser { /** - * Data to be parsed + * 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 $data = ''; + var $state = 'before_version_name'; /** - * Currently consumed bytes + * Input data * * @access private * @var string */ - var $consumed = ''; + var $data = ''; /** - * Position of the current byte being parsed + * 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; /** @@ -9824,169 +13822,250 @@ class SimplePie_Decode_HTML_Entities * @access public * @param string $data Input data */ - function SimplePie_Decode_HTML_Entities($data) + function SimplePie_XML_Declaration_Parser($data) { $this->data = $data; + $this->data_length = strlen($this->data); } /** * Parse the input data * * @access public - * @return string Output data + * @return bool true on success, false on failure */ function parse() { - while (($this->position = strpos($this->data, '&', $this->position)) !== false) + 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->consume(); - $this->entity(); - $this->consumed = ''; + $this->position++; + $this->skip_whitespace(); + $this->state = 'encoding_value'; + } + else + { + $this->state = false; } - return $this->data; } - /** - * Consume the next byte - * - * @access private - * @return mixed The next byte, or false, if there is no more data - */ - function consume() + function encoding_value() { - if (isset($this->data[$this->position])) + if ($this->encoding = $this->get_value()) { - $this->consumed .= $this->data[$this->position]; - return $this->data[$this->position++]; + $this->skip_whitespace(); + if ($this->has_data()) + { + $this->state = 'standalone_name'; + } + else + { + $this->state = 'emit'; + } } else { - $this->consumed = false; - return false; + $this->state = false; } } - /** - * Consume a range of characters - * - * @access private - * @param string $chars Characters to consume - * @return mixed A series of characters that match the range, or false - */ - function consume_range($chars) + function standalone_name() { - if ($len = strspn($this->data, $chars, $this->position)) + if (substr($this->data, $this->position, 10) === 'standalone') { - $data = substr($this->data, $this->position, $len); - $this->consumed .= $data; - $this->position += $len; - return $data; + $this->position += 10; + $this->skip_whitespace(); + $this->state = 'standalone_equals'; } else { - $this->consumed = false; - return false; + $this->state = false; } } - /** - * Unconsume one byte - * - * @access private - */ - function unconsume() + function standalone_equals() { - $this->consumed = substr($this->consumed, 0, -1); - $this->position--; + if (substr($this->data, $this->position, 1) === '=') + { + $this->position++; + $this->skip_whitespace(); + $this->state = 'standalone_value'; + } + else + { + $this->state = false; + } } - /** - * Decode an entity - * - * @access private - */ - function entity() + function standalone_value() { - switch ($this->consume()) + if ($standalone = $this->get_value()) { - case "\x09": - case "\x0A": - case "\x0B": - case "\x0B": - case "\x0C": - case "\x20": - case "\x3C": - case "\x26": - case false: - break; - - case "\x23": - switch ($this->consume()) - { - case "\x78": - case "\x58": - $range = '0123456789ABCDEFabcdef'; - $hex = true; - break; - - default: - $range = '0123456789'; - $hex = false; - $this->unconsume(); - break; - } - - if ($codepoint = $this->consume_range($range)) - { - static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"); - - if ($hex) - { - $codepoint = hexdec($codepoint); - } - else - { - $codepoint = intval($codepoint); - } - - if (isset($windows_1252_specials[$codepoint])) - { - $replacement = $windows_1252_specials[$codepoint]; - } - else - { - $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); - } - - if ($this->consume() != ';') - { - $this->unconsume(); - } - - $consumed_length = strlen($this->consumed); - $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length); - $this->position += strlen($replacement) - $consumed_length; - } - break; + switch ($standalone) + { + case 'yes': + $this->standalone = true; + break; - 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"); + case 'no': + $this->standalone = false; + break; - for ($i = 0, $match = null; $i < 9 && $this->consume(); $i++) - { - $consumed = substr($this->consumed, 1); - if (isset($entities[$consumed])) - { - $match = $consumed; - } - } + default: + $this->state = false; + return; + } - if ($match !== null) - { - $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); - $this->position += strlen($entities[$match]) - strlen($consumed) - 1; - } - break; + $this->skip_whitespace(); + if ($this->has_data()) + { + $this->state = false; + } + else + { + $this->state = 'emit'; + } + } + else + { + $this->state = false; } } } @@ -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) { - return true; + $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; + } } - return false; - } - - function get_base() - { - if (isset($this->file->headers['content-location'])) + elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL) { - $this->http_base = SimplePie_Misc::absolutize_url(trim($this->file->headers['content-location']), $this->file->url); + return true; } else { - $this->http_base = $this->file->url; + return false; } + } + + function get_base() + { + $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; + 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']); + } + // 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)) - { - $this->data = null; - $this->error_code = xml_get_error_code($this->xml); - $this->error_string = xml_error_string($this->error_code); - $return = false; - } - $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; + 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; + } + } } 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))) + { + $img['attribs']['src']['data'] = $this->image_handler . $image_url; + $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data); + } + else { - trigger_error("$cache->name is not writeable", E_USER_WARNING); + 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; } } } -- cgit v1.2.3 From 54cbb215109303681447f900f2029734cc611fc9 Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Sun, 21 Nov 2010 12:25:23 +0100 Subject: 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(-) (limited to 'inc') 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; -- cgit v1.2.3 From 5e1ee188750eca4ed2f13227ede216598c9669c8 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Sun, 7 Nov 2010 02:59:21 +0800 Subject: Fix unicode handling. Suggested by: MQ Signed-off-by: Xin LI --- inc/DifferenceEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') 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('')); } -- cgit v1.2.3 From 98214867894eba512bf47cba3439ccba3968f49b Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 22 Nov 2010 21:12:02 +0100 Subject: 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 | 31 ++++++------------------------- inc/parserutils.php | 23 +++++++++++++++++++---- 2 files changed, 25 insertions(+), 29 deletions(-) (limited to 'inc') 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 - - $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; + $files[] = $metafile; // ... the page's own metadata + + $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']; -- cgit v1.2.3 From 4871414204799044c31aa2764c4b4ca020e2331d Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 26 Nov 2010 16:54:51 +0100 Subject: 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. --- inc/common.php | 3 +++ inc/template.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'inc') 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 -- cgit v1.2.3 From e3776c06c37cc197709dac60892604dfea894ac2 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 29 Nov 2010 01:34:36 +0100 Subject: Remove enc=utf-8 in VIM modeline as it is not allowed in VIM 7.3 As of VIM 7.3 it is no longer possible to specify the encoding in the modeline. This gives an error message whenever such a file is opened, thus this commit removes the enc setting from the modeline. --- inc/DifferenceEngine.php | 2 +- inc/HTTPClient.php | 2 +- inc/actions.php | 2 +- inc/auth.php | 2 +- inc/auth/ad.class.php | 2 +- inc/auth/basic.class.php | 2 +- inc/auth/ldap.class.php | 2 +- inc/auth/mysql.class.php | 2 +- inc/auth/pgsql.class.php | 2 +- inc/auth/plain.class.php | 2 +- inc/common.php | 2 +- inc/confutils.php | 2 +- inc/feedcreator.class.php | 2 +- inc/fulltext.php | 2 +- inc/indexer.php | 2 +- inc/lang/en/lang.php | 2 +- inc/lang/et/lang.php | 2 +- inc/lang/km/lang.php | 2 +- inc/lang/ku/lang.php | 2 +- inc/lang/mg/lang.php | 2 +- inc/lang/vi/lang.php | 2 +- inc/parser/handler.php | 2 +- inc/parser/lexer.php | 2 +- inc/parser/metadata.php | 2 +- inc/parser/parser.php | 2 +- inc/parser/renderer.php | 2 +- inc/parser/xhtml.php | 2 +- inc/parser/xhtmlsummary.php | 2 +- inc/search.php | 2 +- inc/template.php | 2 +- inc/toolbar.php | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) (limited to 'inc') diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php index 1ff6a9fba..08e09c65f 100644 --- a/inc/DifferenceEngine.php +++ b/inc/DifferenceEngine.php @@ -1158,4 +1158,4 @@ class InlineDiffFormatter extends DiffFormatter { } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index e68679bde..b23616ef1 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -600,4 +600,4 @@ class HTTPClient { } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/actions.php b/inc/actions.php index fb2ae452f..d98382a3b 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -743,4 +743,4 @@ function subscription_handle_post(&$params) { $params = compact('target', 'style', 'data', 'action'); } -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/auth.php b/inc/auth.php index a2844a732..6bc4f8673 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -1117,4 +1117,4 @@ function auth_getCookie(){ return array($user,$sticky,$pass); } -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/auth/ad.class.php b/inc/auth/ad.class.php index 90fe0266b..41e9d854b 100644 --- a/inc/auth/ad.class.php +++ b/inc/auth/ad.class.php @@ -296,4 +296,4 @@ class auth_ad extends auth_basic { } } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/auth/basic.class.php b/inc/auth/basic.class.php index fa38970ae..c7e7031bf 100644 --- a/inc/auth/basic.class.php +++ b/inc/auth/basic.class.php @@ -400,4 +400,4 @@ class auth_basic { } } -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/auth/ldap.class.php b/inc/auth/ldap.class.php index 7f1eec187..420043238 100644 --- a/inc/auth/ldap.class.php +++ b/inc/auth/ldap.class.php @@ -457,4 +457,4 @@ class auth_ldap extends auth_basic { } } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/auth/mysql.class.php b/inc/auth/mysql.class.php index ca607ced5..dbdfe5fda 100644 --- a/inc/auth/mysql.class.php +++ b/inc/auth/mysql.class.php @@ -936,4 +936,4 @@ class auth_mysql extends auth_basic { } } -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/auth/pgsql.class.php b/inc/auth/pgsql.class.php index 8e68e865e..cf8bf7600 100644 --- a/inc/auth/pgsql.class.php +++ b/inc/auth/pgsql.class.php @@ -407,4 +407,4 @@ class auth_pgsql extends auth_mysql { } -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/auth/plain.class.php b/inc/auth/plain.class.php index ec9e52beb..3941190e9 100644 --- a/inc/auth/plain.class.php +++ b/inc/auth/plain.class.php @@ -325,4 +325,4 @@ class auth_plain extends auth_basic { } } -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/common.php b/inc/common.php index 667846804..b6048825b 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1541,4 +1541,4 @@ function valid_input_set($param, $valid_values, $array, $exc = '') { } } -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/confutils.php b/inc/confutils.php index 4306dab8f..26ed4f087 100644 --- a/inc/confutils.php +++ b/inc/confutils.php @@ -324,4 +324,4 @@ function conf_decodeString($str) { return $str; } } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/feedcreator.class.php b/inc/feedcreator.class.php index 8141d867c..435add6ac 100644 --- a/inc/feedcreator.class.php +++ b/inc/feedcreator.class.php @@ -1577,4 +1577,4 @@ class DokuWikiFeedCreator extends UniversalFeedCreator{ -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/fulltext.php b/inc/fulltext.php index 7ace3a724..59a9c1d96 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -756,4 +756,4 @@ function ft_termParser($term, &$stopwords, $consider_asian = true, $phrase_mode return $parsed; } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/indexer.php b/inc/indexer.php index f5330040a..5a361ddc5 100644 --- a/inc/indexer.php +++ b/inc/indexer.php @@ -701,4 +701,4 @@ function idx_tokenizer($string,&$stopwords,$wc=false){ return $words; } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 5c890246c..9ccbe14e0 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -316,4 +316,4 @@ $lang['seconds'] = '%d seconds ago'; $lang['wordblock'] = 'Your change was not saved because it contains blocked text (spam).'; -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/lang/et/lang.php b/inc/lang/et/lang.php index ef540bb3d..ee765b5b5 100644 --- a/inc/lang/et/lang.php +++ b/inc/lang/et/lang.php @@ -211,4 +211,4 @@ $lang['js']['del_confirm']= 'Kas kustutame selle kirje?'; #$lang['unsubscribe_success'] = ''; #$lang['unsubscribe_error'] = ''; -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/lang/km/lang.php b/inc/lang/km/lang.php index 19847674d..3519a484e 100644 --- a/inc/lang/km/lang.php +++ b/inc/lang/km/lang.php @@ -227,4 +227,4 @@ $lang['i_pol2'] = 'វីគីបិទជិត'; $lang['i_retry'] = 'ម្តងទៀត'; -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/lang/ku/lang.php b/inc/lang/ku/lang.php index cb8dd0865..0ff2ca4ca 100644 --- a/inc/lang/ku/lang.php +++ b/inc/lang/ku/lang.php @@ -160,4 +160,4 @@ $lang['subscribe_noaddress']= 'There is no address associated with your login, y $lang['unsubscribe_success']= 'Removed %s from subscription list for %s'; $lang['unsubscribe_error'] = 'Error removing %s from subscription list for %s'; -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/lang/mg/lang.php b/inc/lang/mg/lang.php index 2ecbcdcff..3727cfe9a 100644 --- a/inc/lang/mg/lang.php +++ b/inc/lang/mg/lang.php @@ -132,4 +132,4 @@ $lang['acl_perm8'] = 'Mandefa rakitra'; $lang['acl_perm16'] = 'Mamafa'; $lang['acl_new'] = 'Ampio andalana vaovao'; -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/lang/vi/lang.php b/inc/lang/vi/lang.php index 168fe3595..750433910 100644 --- a/inc/lang/vi/lang.php +++ b/inc/lang/vi/lang.php @@ -103,4 +103,4 @@ $lang['qb_sig'] = 'Đặt chữ ký'; $lang['js']['del_confirm']= 'Xoá mục này?'; -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/parser/handler.php b/inc/parser/handler.php index a96e6b9db..4d0b56b44 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -1707,4 +1707,4 @@ class Doku_Handler_Block { } } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/parser/lexer.php b/inc/parser/lexer.php index 211945d8f..b5bcb9612 100644 --- a/inc/parser/lexer.php +++ b/inc/parser/lexer.php @@ -597,4 +597,4 @@ function Doku_Lexer_Escape($str) { return preg_replace($chars, $escaped, $str); } -//Setup VIM: ex: et ts=4 sw=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 sw=4 : diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index f635ea1d5..263745593 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -479,4 +479,4 @@ class Doku_Renderer_metadata extends Doku_Renderer { } } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/parser/parser.php b/inc/parser/parser.php index 20f0e6ca3..2e6b7791a 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -957,4 +957,4 @@ class Doku_Parser_Mode_emaillink extends Doku_Parser_Mode { } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index a178b2457..7002fd0cb 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -319,4 +319,4 @@ class Doku_Renderer extends DokuWiki_Plugin { } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 37900b2c3..b0d93f93e 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -1205,4 +1205,4 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/parser/xhtmlsummary.php b/inc/parser/xhtmlsummary.php index b187fef01..95f86cbef 100644 --- a/inc/parser/xhtmlsummary.php +++ b/inc/parser/xhtmlsummary.php @@ -87,4 +87,4 @@ class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml { } -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : diff --git a/inc/search.php b/inc/search.php index a6787c5d2..db0b008f0 100644 --- a/inc/search.php +++ b/inc/search.php @@ -624,4 +624,4 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ return $return; } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/template.php b/inc/template.php index b89f7abbc..d171ab075 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1372,5 +1372,5 @@ function tpl_getFavicon() { } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : diff --git a/inc/toolbar.php b/inc/toolbar.php index 8bcf6f030..58d80043c 100644 --- a/inc/toolbar.php +++ b/inc/toolbar.php @@ -252,4 +252,4 @@ function toolbar_signature(){ return $sig; } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : -- cgit v1.2.3 From 609c41e4b585232192abba662698288798157297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 29 Nov 2010 20:59:50 +0200 Subject: Use $USERINFO in mail_setup, as $INFO['userinfo'] is not yet available. 20:51:05 what is the difference between $INFO['userinfo'] and $USERINFO? 20:52:17 none really 20:52:33 yet one works ($USERINFO) and the other doesn't in my setup 20:52:59 $INFO isn't available everywhere 20:53:27 or might not have been set yet (if you're fetching an early action hook) 20:53:27 yeah, mail headers setup failed for me --- inc/mail.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'inc') diff --git a/inc/mail.php b/inc/mail.php index fb163585a..604a0999a 100644 --- a/inc/mail.php +++ b/inc/mail.php @@ -37,12 +37,12 @@ if (!defined('PREG_PATTERN_VALID_EMAIL')) define('PREG_PATTERN_VALID_EMAIL', '[' */ function mail_setup(){ global $conf; - global $INFO; + global $USERINFO; $replace = array(); - if(!empty($INFO['userinfo']['mail'])){ - $replace['@MAIL@'] = $INFO['userinfo']['mail']; + if(!empty($USERINFO['mail'])){ + $replace['@MAIL@'] = $USERINFO['mail']; }else{ $replace['@MAIL@'] = 'noreply@'.parse_url(DOKU_URL,PHP_URL_HOST); } @@ -53,8 +53,8 @@ function mail_setup(){ $replace['@USER@'] = 'noreply'; } - if(!empty($INFO['userinfo']['name'])){ - $replace['@NAME@'] = $INFO['userinfo']['name']; + if(!empty($USERINFO['name'])){ + $replace['@NAME@'] = $USERINFO['name']; }else{ $replace['@NAME@'] = ''; } -- cgit v1.2.3 From 359fab8b2f7d0847ef0cf9b669e6c8ffb0687525 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 30 Nov 2010 18:34:10 +0100 Subject: Revert "Fix for $conf['breadcrumbs'] < 0, FS#2107", new fix This reverts commit 4871414204799044c31aa2764c4b4ca020e2331d. Additionally there is a new fix for FS#2107 that doesn't introduce a lot of checks but instead ensures that the configuration option can't be set to negative values when the configuration manager is used. --- inc/common.php | 3 --- inc/template.php | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'inc') diff --git a/inc/common.php b/inc/common.php index b6048825b..a1c4580a6 100644 --- a/inc/common.php +++ b/inc/common.php @@ -268,9 +268,6 @@ 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 d171ab075..53ae9abce 100644 --- a/inc/template.php +++ b/inc/template.php @@ -690,7 +690,7 @@ function tpl_breadcrumbs($sep='»'){ global $conf; //check if enabled - if(!is_numeric($conf['breadcrumbs']) || $conf['breadcrumbs'] <= 0) return false; + if(!$conf['breadcrumbs']) return false; $crumbs = breadcrumbs(); //setup crumb trace -- cgit v1.2.3 From 2b7b5b9221b5aca30667e8f28ecd0818fbb5cd93 Mon Sep 17 00:00:00 2001 From: Matthias Schulte Date: Tue, 30 Nov 2010 20:05:11 +0100 Subject: DE: typo fixed --- inc/lang/de/lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/lang/de/lang.php b/inc/lang/de/lang.php index dfd9a8eab..ecc190c36 100644 --- a/inc/lang/de/lang.php +++ b/inc/lang/de/lang.php @@ -54,7 +54,7 @@ $lang['btn_profile'] = 'Benutzerprofil'; $lang['btn_reset'] = 'Zurücksetzen'; $lang['btn_resendpwd'] = 'Sende neues Passwort'; $lang['btn_draft'] = 'Entwurf bearbeiten'; -$lang['btn_recover'] = 'Entwurf wieder herstellen'; +$lang['btn_recover'] = 'Entwurf wiederherstellen'; $lang['btn_draftdel'] = 'Entwurf löschen'; $lang['btn_revert'] = 'Wiederherstellen'; $lang['loggedinas'] = 'Angemeldet als'; -- cgit v1.2.3 From 68ee030431d00b9924366a1af38805ff0263c529 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 2 Dec 2010 18:45:03 +0100 Subject: renamed variable initialization in HTTPClient --- inc/HTTPClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index b23616ef1..43b00034c 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -92,7 +92,7 @@ class HTTPClient { var $redirect_count; // read these after a successful request - var $resp_status; + var $status; var $resp_body; var $resp_headers; -- cgit v1.2.3 From 5048c277bbf430c50bf87cd17ef1e5e21fcb095a Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Mon, 6 Dec 2010 19:47:43 +0000 Subject: fixed newlines nesting error (introduced by 7deca91b) --- inc/DifferenceEngine.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'inc') diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php index 08e09c65f..dd096a55a 100644 --- a/inc/DifferenceEngine.php +++ b/inc/DifferenceEngine.php @@ -1019,9 +1019,9 @@ class TableDiffFormatter extends DiffFormatter { global $lang; $l1 = $lang['line'].' '.$xbeg; $l2 = $lang['line'].' '.$ybeg; - $r = ''.$l1.':\n'. - ' '.$l2.":\n'. - '\n"; + $r = ''.$l1.":\n". + ' '.$l2.":\n". + "\n"; return $r; } -- cgit v1.2.3 From 9fa736b0317d46fdfb2025895fa0288fd736ca08 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 7 Dec 2010 16:09:01 +0100 Subject: Make baseonly work in allowedModes This makes it possible to have modes that do accept headers (baseonly) in the parser. Related test cases are still running through but I'm not 100% sure I did not break something here. So it should be tested a bit more. This patch will allow plugins to wrap multiple sections, however it also makes it possible to easily break XHTML validity, because headers also open and close sections, so plugin authors need to be aware! In case you wonder: this patch is not about allowing formatting inside headers. --- inc/parser/parser.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'inc') diff --git a/inc/parser/parser.php b/inc/parser/parser.php index 2e6b7791a..b93760f3a 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -90,7 +90,6 @@ class Doku_Parser { if ( $mode == 'base' ) { continue; } - $this->modes[$mode]->preConnect(); foreach ( array_keys($this->modes) as $cm ) { @@ -218,11 +217,11 @@ class Doku_Parser_Mode_footnote extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_header extends Doku_Parser_Mode { - function preConnect() { + function connectTo($mode) { //we're not picky about the closing ones, two are enough $this->Lexer->addSpecialPattern( '[ \t]*={2,}[^\n]+={2,}[ \t]*(?=\n)', - 'base', + $mode, 'header' ); } -- cgit v1.2.3 From 3733161e2de6b5a7092884f4e39ce8c846ae8f8c Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 8 Dec 2010 08:51:32 +0100 Subject: Add missing variable declaration --- inc/html.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index 9d3c92707..1e02ac9ce 100644 --- a/inc/html.php +++ b/inc/html.php @@ -888,6 +888,9 @@ function html_diff($text='',$intro=true){ $rev2 = (int) $_REQUEST['rev2']; } + $r_minor = ''; + $l_minor = ''; + if($text){ // compare text to the most current revision $l_rev = ''; $l_text = rawWiki($ID,''); -- cgit v1.2.3 From fa7c70ff4d7f9999466436e7d559eb0c81571779 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 8 Dec 2010 17:17:40 +0100 Subject: tmp --- inc/HTTPClient.php | 17 +++++++++-------- inc/auth.php | 5 +++-- inc/auth/ad.class.php | 2 +- inc/html.php | 10 +++++++--- 4 files changed, 20 insertions(+), 14 deletions(-) (limited to 'inc') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 43b00034c..a9afef9f9 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -222,7 +222,7 @@ class HTTPClient { $path = $uri['path']; if(empty($path)) $path = '/'; if(!empty($uri['query'])) $path .= '?'.$uri['query']; - $port = $uri['port']; + if(isset($uri['port']) && !empty($uri['port'])) $port = $uri['port']; if(isset($uri['user'])) $this->user = $uri['user']; if(isset($uri['pass'])) $this->pass = $uri['pass']; @@ -235,7 +235,7 @@ class HTTPClient { }else{ $request_url = $path; $server = $server; - if (empty($port)) $port = ($uri['scheme'] == 'https') ? 443 : 80; + if (!isset($port)) $port = ($uri['scheme'] == 'https') ? 443 : 80; } // add SSL stream prefix if needed - needs SSL support in PHP @@ -506,12 +506,13 @@ class HTTPClient { */ function _parseHeaders($string){ $headers = array(); - $lines = explode("\n",$string); - foreach($lines as $line){ - list($key,$val) = explode(':',$line,2); - $key = strtolower(trim($key)); - $val = trim($val); - if(empty($val)) continue; + if (!preg_match_all('/^\s*([\w-]+)\s*:\s*([\S \t]+)\s*$/m', $string, + $matches, PREG_SET_ORDER)) { + return $headers; + } + foreach($matches as $match){ + list(, $key, $val) = $match; + $key = strtolower($key); if(isset($headers[$key])){ if(is_array($headers[$key])){ $headers[$key][] = $val; diff --git a/inc/auth.php b/inc/auth.php index 6bc4f8673..f2de4424e 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -194,10 +194,11 @@ function auth_login($user,$pass,$sticky=false,$silent=false){ }else{ // read cookie information list($user,$sticky,$pass) = auth_getCookie(); - // get session info - $session = $_SESSION[DOKU_COOKIE]['auth']; if($user && $pass){ // we got a cookie - see if we can trust it + + // get session info + $session = $_SESSION[DOKU_COOKIE]['auth']; if(isset($session) && $auth->useSessionCache($user) && ($session['time'] >= time()-$conf['auth_security_timeout']) && diff --git a/inc/auth/ad.class.php b/inc/auth/ad.class.php index 41e9d854b..5478d64b9 100644 --- a/inc/auth/ad.class.php +++ b/inc/auth/ad.class.php @@ -126,7 +126,7 @@ class auth_ad extends auth_basic { * at least these fields: * * name string full name of the user - * mail string email addres of the user + * mail string email address of the user * grps array list of groups the user is in * * This LDAP specific function returns the following diff --git a/inc/html.php b/inc/html.php index 1e02ac9ce..98ee8a496 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,8 +948,12 @@ function html_diff($text='',$intro=true){ '
'.$l_user.' '.$l_sum; } - if($r_rev){ - $r_info = getRevisionInfo($ID,$r_rev,true); + $_r_rev = $r_rev; + if (!$_r_rev) { + $_r_rev = @filemtime(wikiFN($ID)); + } + 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'].')'; -- cgit v1.2.3 From 5b72404c10cb148753118be9ff987ab339b2db06 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 8 Dec 2010 23:12:25 +0100 Subject: fixed indent --- inc/io.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/io.php b/inc/io.php index 1d69dabc9..559f3febc 100644 --- a/inc/io.php +++ b/inc/io.php @@ -486,7 +486,7 @@ function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=20 preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)) { $name = basename($match[1]); - } + } } -- cgit v1.2.3 From d6dc956f8c13064c5e638d5ba817123f66261cfe Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 8 Dec 2010 23:41:59 +0100 Subject: added auth_isMember() This function abstracts checking a given user and her groups against a given member list (as used in the superuser and manager options). It is also used in auth_isManager() and auth_isAdmin(), unlike the previous function, this one skips the nameencode step as it should be unnessary here (all input is given decoded). The test cases where extended by some non-ID user and group names. People with non-plain auth backends should check that their administrator and manager setups still work as expected --- inc/auth.php | 106 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 52 insertions(+), 54 deletions(-) (limited to 'inc') diff --git a/inc/auth.php b/inc/auth.php index 6bc4f8673..c455fac0c 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -371,63 +371,15 @@ function auth_ismanager($user=null,$groups=null,$adminonly=false){ $user = $_SERVER['REMOTE_USER']; } } - $user = trim($auth->cleanUser($user)); - if($user === '') return false; - if(is_null($groups)) $groups = (array) $USERINFO['grps']; - $groups = array_map(array($auth,'cleanGroup'),$groups); - $user = auth_nameencode($user); - - // check username against superuser and manager - $superusers = explode(',', $conf['superuser']); - $superusers = array_unique($superusers); - $superusers = array_map('trim', $superusers); - $superusers = array_filter($superusers); - // prepare an array containing only true values for array_map call - $alltrue = array_fill(0, count($superusers), true); - $superusers = array_map('auth_nameencode', $superusers, $alltrue); - - // case insensitive? - if(!$auth->isCaseSensitive()){ - $superusers = array_map('utf8_strtolower',$superusers); - $user = utf8_strtolower($user); + if(is_null($groups)){ + $groups = (array) $USERINFO['grps']; } - // check user match - if(in_array($user, $superusers)) return true; - + // check superuser match + if(auth_isMember($conf['superuser'],$user, $groups)) return true; + if($adminonly) return false; // check managers - if(!$adminonly){ - $managers = explode(',', $conf['manager']); - $managers = array_unique($managers); - $managers = array_map('trim', $managers); - $managers = array_filter($managers); - // prepare an array containing only true values for array_map call - $alltrue = array_fill(0, count($managers), true); - $managers = array_map('auth_nameencode', $managers, $alltrue); - if(!$auth->isCaseSensitive()) $managers = array_map('utf8_strtolower',$managers); - if(in_array($user, $managers)) return true; - } - - // check user's groups against superuser and manager - if (!empty($groups)) { - - //prepend groups with @ and nameencode - $cnt = count($groups); - for($i=0; $i<$cnt; $i++){ - $groups[$i] = '@'.auth_nameencode($groups[$i]); - if(!$auth->isCaseSensitive()){ - $groups[$i] = utf8_strtolower($groups[$i]); - } - } - - // check groups against superuser and manager - foreach($superusers as $supu) - if(in_array($supu, $groups)) return true; - if(!$adminonly){ - foreach($managers as $mana) - if(in_array($mana, $groups)) return true; - } - } + if(auth_isMember($conf['manager'],$user, $groups)) return true; return false; } @@ -446,6 +398,52 @@ function auth_isadmin($user=null,$groups=null){ return auth_ismanager($user,$groups,true); } + +/** + * Match a user and his groups against a comma separated list of + * users and groups to determine membership status + * + * Note: all input should NOT be nameencoded. + * + * @param $memberlist string commaseparated list of allowed users and groups + * @param $user string user to match against + * @param $groups array groups the user is member of + * @returns bool true for membership acknowledged + */ +function auth_isMember($memberlist,$user,array $groups){ + global $auth; + if (!$auth) return false; + + // clean user and groups + if($auth->isCaseSensitive()){ + $user = utf8_strtolower($user); + $groups = array_map('utf8_strtolower',$groups); + } + $user = $auth->cleanUser($user); + $groups = array_map(array($auth,'cleanGroup'),$groups); + + // extract the memberlist + $members = explode(',',$memberlist); + $members = array_map('trim',$members); + $members = array_unique($members); + $members = array_filter($members); + + // compare cleaned values + foreach($members as $member){ + if($auth->isCaseSensitive()) $member = utf8_strtolower($member); + if($member[0] == '@'){ + $member = $auth->cleanGroup(substr($member,1)); + if(in_array($member, $groups)) return true; + }else{ + $member = $auth->cleanUser($member); + if($member == $user) return true; + } + } + + // still here? not a member! + return false; +} + /** * Convinience function for auth_aclcheck() * -- cgit v1.2.3 From 204d9c533d983cce1a75f12ef218a92b01961d46 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 8 Dec 2010 23:55:54 +0100 Subject: surpress warning in mail setup when hostname can't be determined --- inc/mail.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/mail.php b/inc/mail.php index 604a0999a..e1f327cfe 100644 --- a/inc/mail.php +++ b/inc/mail.php @@ -44,7 +44,9 @@ function mail_setup(){ if(!empty($USERINFO['mail'])){ $replace['@MAIL@'] = $USERINFO['mail']; }else{ - $replace['@MAIL@'] = 'noreply@'.parse_url(DOKU_URL,PHP_URL_HOST); + $host = @parse_url(DOKU_URL,PHP_URL_HOST); + if(!$host) $host = 'example.com'; + $replace['@MAIL@'] = 'noreply@'.$host; } if(!empty($_SERVER['REMOTE_USER'])){ -- cgit v1.2.3 From 3e304b55d99607a2d4586c7a4f0219736d995478 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 11 Dec 2010 00:08:51 +0100 Subject: preg_quote namespaces in auth_aclcheck Like ids namespaces are now preg_quoted in the acl check (and therefore the escaping of "*" has been removed). When plugins call the ACL check function with strange ids the regex fails otherwise (in the case of the include plugin errors like "Warning: preg_grep() [function.preg-grep]: Compilation failed: missing terminating ] for character class at offset 47" have been reported by two users). I've run the acl tests after this change and everything passes so this shouldn't break anything but please test this especially with protected wikis as this change modifies the code that handles namespace permissions. Furthermore permissions for a namespace foobar are no longer applied to namespaces with names like foo.ar, I hope nobody has used that "feature". When you are using per-user namespaces, user registration is open and either write or read protection for these namespaces is important to you this is a security fix for you: When someone wants to get access to the namespace of a user "foo.bar" he can register as "fooxbar" (where "x" is an arbitrary character) and will have access to the user namespace of the user "foo.bar" as when a page in "foo.bar" is checked it will match the rule for "fooxbar". --- inc/auth.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'inc') diff --git a/inc/auth.php b/inc/auth.php index c455fac0c..fd2a9c66d 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -534,13 +534,13 @@ function auth_aclcheck($id,$user,$groups){ //still here? do the namespace checks if($ns){ - $path = $ns.':\*'; + $path = $ns.':*'; }else{ - $path = '\*'; //root document + $path = '*'; //root document } do{ - $matches = preg_grep('/^'.$path.'\s+('.$regexp.')\s+/'.$ci,$AUTH_ACL); + $matches = preg_grep('/^'.preg_quote($path,'/').'\s+('.$regexp.')\s+/'.$ci,$AUTH_ACL); if(count($matches)){ foreach($matches as $match){ $match = preg_replace('/#.*$/','',$match); //ignore comments @@ -557,9 +557,9 @@ function auth_aclcheck($id,$user,$groups){ //get next higher namespace $ns = getNS($ns); - if($path != '\*'){ - $path = $ns.':\*'; - if($path == ':\*') $path = '\*'; + if($path != '*'){ + $path = $ns.':*'; + if($path == ':*') $path = '*'; }else{ //we did this already //looks like there is something wrong with the ACL -- cgit v1.2.3 From 03f008cd4edafbcb75d5f3b99bd3271caabed988 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 12 Dec 2010 19:48:29 +0100 Subject: Copy changes from ajax_lock to act_draftsave --- inc/actions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/actions.php b/inc/actions.php index d98382a3b..a4461d1ab 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -292,9 +292,10 @@ function act_draftsave($act){ global $conf; if($conf['usedraft'] && $_POST['wikitext']){ $draft = array('id' => $ID, - 'prefix' => $_POST['prefix'], + 'prefix' => substr($_POST['prefix'], 0, -1), 'text' => $_POST['wikitext'], 'suffix' => $_POST['suffix'], + 'date' => (int) $_POST['date'], 'date' => $_POST['date'], 'client' => $INFO['client'], ); -- cgit v1.2.3 From ec5906e60bfe61520ec062e6a89096988c218690 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 13 Dec 2010 15:52:57 +0100 Subject: Delete superfluous assignment created by the last commit --- inc/actions.php | 1 - 1 file changed, 1 deletion(-) (limited to 'inc') diff --git a/inc/actions.php b/inc/actions.php index a4461d1ab..0297f6e56 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -296,7 +296,6 @@ function act_draftsave($act){ 'text' => $_POST['wikitext'], 'suffix' => $_POST['suffix'], 'date' => (int) $_POST['date'], - 'date' => $_POST['date'], 'client' => $INFO['client'], ); $cname = getCacheName($draft['client'].$ID,'.draft'); -- cgit v1.2.3 From 35594613ea01a868e958663dc211bce021df23f4 Mon Sep 17 00:00:00 2001 From: Kazutaka Miyasaka Date: Tue, 14 Dec 2010 01:52:20 +0900 Subject: Fixed Asian search term handling in ft_snippet_re_preprocess() --- inc/fulltext.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'inc') diff --git a/inc/fulltext.php b/inc/fulltext.php index 59a9c1d96..457ad1baf 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -396,6 +396,11 @@ function ft_snippet($id,$highlight){ * Wraps a search term in regex boundary checks. */ function ft_snippet_re_preprocess($term) { + // do not process asian terms where word boundaries are not explicit + if(preg_match('/'.IDX_ASIAN.'/u',$term)){ + return $term; + } + if(substr($term,0,2) == '\\*'){ $term = substr($term,2); }else{ -- cgit v1.2.3 From 6ac2077a96f206f26714699c001c72f914bf7970 Mon Sep 17 00:00:00 2001 From: Kazutaka Miyasaka Date: Tue, 14 Dec 2010 01:38:54 +0900 Subject: Removed unnecessary regexp excecution in ft_termParser() --- inc/fulltext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/fulltext.php b/inc/fulltext.php index 457ad1baf..be3938cac 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -739,7 +739,7 @@ function ft_termParser($term, &$stopwords, $consider_asian = true, $phrase_mode // successive asian characters need to be searched as a phrase $words = preg_split('/('.IDX_ASIAN.'+)/u', $term, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); foreach ($words as $word) { - if (preg_match('/'.IDX_ASIAN.'/u', $word)) $phrase_mode = true; + $phrase_mode = $phrase_mode ? true : preg_match('/'.IDX_ASIAN.'/u', $word); $parsed .= ft_termParser($word, $stopwords, false, $phrase_mode); } } else { -- cgit v1.2.3 From 5627186c2f8b450460892f0247dbbb5f8d4369b4 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 18 Dec 2010 10:07:04 +0100 Subject: more robust hostname detection as discussed in http://www.freelists.org/post/dokuwiki/git-changes-20101209,7 --- inc/init.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'inc') diff --git a/inc/init.php b/inc/init.php index ed4409729..3b438f15b 100644 --- a/inc/init.php +++ b/inc/init.php @@ -419,12 +419,16 @@ function getBaseURL($abs=null){ if($conf['baseurl']) return rtrim($conf['baseurl'],'/').$dir; //split hostheader into host and port - $addr = explode(':',$_SERVER['HTTP_HOST']); - $host = $addr[0]; - $port = ''; - if (isset($addr[1])) { - $port = $addr[1]; - } elseif (isset($_SERVER['SERVER_PORT'])) { + if(isset($_SERVER['HTTP_HOST'])){ + list($host,$port) = explode(':',$_SERVER['HTTP_HOST']); + }elseif(isset($_SERVER['SERVER_NAME'])){ + list($host,$port) = explode(':',$_SERVER['SERVER_NAME']); + }else{ + $host = php_uname('n'); + $port = ''; + } + + if(!$port && isset($_SERVER['SERVER_PORT'])) { $port = $_SERVER['SERVER_PORT']; } if(!is_ssl()){ -- cgit v1.2.3 From 15e86bd352576ba668e9b899f721b35d72900af4 Mon Sep 17 00:00:00 2001 From: Tanguy Ortolo Date: Sun, 12 Dec 2010 23:21:28 +0100 Subject: Correct the phpdoc license tag of TarLib.class.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The author of MaxgTar (original name of this file) wrote an incorrect phpdoc license tag mentionning the “GPL” without a version number. Contacted to clarify the licensing situation of this file, he explained that he wanted to use the LGPL-2.1: > I am the author of MaxgTar and I must say I am more than slightly > surprised to hear about it. > […] > I have no doubt that my intention was to use the GNU Lesser General > Public License, version 2.1. --- inc/TarLib.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/TarLib.class.php b/inc/TarLib.class.php index 7a7acdbdb..12418c48d 100644 --- a/inc/TarLib.class.php +++ b/inc/TarLib.class.php @@ -7,7 +7,7 @@ * * Modified for Dokuwiki * - * @license GPL + * @license LGPL-2.1 * @link http://docs.maxg.info * @author Bouchon (Maxg) * @author Christopher Smith -- cgit v1.2.3 From 02700828f76adcfc63a9dafe75ffa941cdb9831b Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 18 Dec 2010 10:33:31 +0100 Subject: Update EmailValidator to r10 and allow local email addresses FS#2118 --- inc/EmailAddressValidator.php | 42 +++++++++++++++++++++++++++++++++++------- inc/mail.php | 1 + 2 files changed, 36 insertions(+), 7 deletions(-) (limited to 'inc') diff --git a/inc/EmailAddressValidator.php b/inc/EmailAddressValidator.php index 2ce2093e2..31b34cc58 100644 --- a/inc/EmailAddressValidator.php +++ b/inc/EmailAddressValidator.php @@ -5,21 +5,38 @@ * @author Dave Child * @link http://code.google.com/p/php-email-address-validation/ * @license http://www.opensource.org/licenses/bsd-license.php + * @version SVN r10 + Issue 15 fix */ class EmailAddressValidator { + /** + * Set true to allow addresses like me@localhost + */ + public $allowLocalAddresses = false; /** * Check email address validity * @param strEmailAddress Email address to be checked * @return True if email is valid, false if not */ - function check_email_address($strEmailAddress) { + public function check_email_address($strEmailAddress) { + + // If magic quotes is "on", email addresses with quote marks will + // fail validation because of added escape characters. Uncommenting + // the next three lines will allow for this issue. + //if (get_magic_quotes_gpc()) { + // $strEmailAddress = stripslashes($strEmailAddress); + //} // Control characters are not allowed if (preg_match('/[\x00-\x1F\x7F-\xFF]/', $strEmailAddress)) { return false; } + // Check email length - min 3 (a@a), max 256 + if (!$this->check_text_length($strEmailAddress, 3, 256)) { + return false; + } + // Split it into sections using last instance of "@" $intAtSymbol = strrpos($strEmailAddress, '@'); if ($intAtSymbol === false) { @@ -31,10 +48,15 @@ class EmailAddressValidator { // Count the "@" symbols. Only one is allowed, except where // contained in quote marks in the local part. Quickest way to - // check this is to remove anything in quotes. - $arrTempAddress[0] = preg_replace('/"[^"]+"/' + // check this is to remove anything in quotes. We also remove + // characters escaped with backslash, and the backslash + // character. + $arrTempAddress[0] = preg_replace('/\./' ,'' ,$arrEmailAddress[0]); + $arrTempAddress[0] = preg_replace('/"[^"]+"/' + ,'' + ,$arrTempAddress[0]); $arrTempAddress[1] = $arrEmailAddress[1]; $strTempAddress = $arrTempAddress[0] . $arrTempAddress[1]; // Then check - should be no "@" symbols. @@ -63,7 +85,7 @@ class EmailAddressValidator { * @param strLocalPortion Text to be checked * @return True if local portion is valid, false if not */ - function check_local_portion($strLocalPortion) { + protected function check_local_portion($strLocalPortion) { // Local portion can only be from 1 to 64 characters, inclusive. // Please note that servers are encouraged to accept longer local // parts than 64 characters. @@ -94,7 +116,7 @@ class EmailAddressValidator { * @param strDomainPortion Text to be checked * @return True if domain portion is valid, false if not */ - function check_domain_portion($strDomainPortion) { + protected function check_domain_portion($strDomainPortion) { // Total domain can only be from 1 to 255 characters, inclusive if (!$this->check_text_length($strDomainPortion, 1, 255)) { return false; @@ -109,7 +131,7 @@ class EmailAddressValidator { return true; } else { $arrDomainPortion = explode('.', $strDomainPortion); - if (sizeof($arrDomainPortion) < 2) { + if (!$this->allowLocalAddresses && sizeof($arrDomainPortion) < 2) { return false; // Not enough parts to domain } for ($i = 0, $max = sizeof($arrDomainPortion); $i < $max; $i++) { @@ -121,6 +143,11 @@ class EmailAddressValidator { .'([A-Za-z0-9]+))$/', $arrDomainPortion[$i])) { return false; } + if ($i == $max - 1) { // TLD cannot be only numbers + if (strlen(preg_replace('/[0-9]/', '', $arrDomainPortion[$i])) <= 0) { + return false; + } + } } } return true; @@ -133,7 +160,7 @@ class EmailAddressValidator { * @param intMaximum Maximum acceptable length * @return True if string is within bounds (inclusive), false if not */ - function check_text_length($strText, $intMinimum, $intMaximum) { + protected function check_text_length($strText, $intMinimum, $intMaximum) { // Minimum and maximum are both inclusive $intTextLength = strlen($strText); if (($intTextLength < $intMinimum) || ($intTextLength > $intMaximum)) { @@ -142,5 +169,6 @@ class EmailAddressValidator { return true; } } + } diff --git a/inc/mail.php b/inc/mail.php index e1f327cfe..aa9d195d1 100644 --- a/inc/mail.php +++ b/inc/mail.php @@ -227,6 +227,7 @@ function mail_encode_address($string,$header='',$names=true){ */ function mail_isvalid($email){ $validator = new EmailAddressValidator; + $validator->allowLocalAddresses = true; return $validator->check_email_address($email); } -- cgit v1.2.3 From 4f56ecbf9229ff893b58cf34012a9646a06f91c0 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 21 Dec 2010 13:20:10 +0100 Subject: Fix handling of case in auth_isMember; add and fix test cases --- inc/auth.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc') diff --git a/inc/auth.php b/inc/auth.php index fd2a9c66d..b3c20e6b9 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -415,7 +415,7 @@ function auth_isMember($memberlist,$user,array $groups){ if (!$auth) return false; // clean user and groups - if($auth->isCaseSensitive()){ + if(!$auth->isCaseSensitive()){ $user = utf8_strtolower($user); $groups = array_map('utf8_strtolower',$groups); } @@ -430,7 +430,7 @@ function auth_isMember($memberlist,$user,array $groups){ // compare cleaned values foreach($members as $member){ - if($auth->isCaseSensitive()) $member = utf8_strtolower($member); + if(!$auth->isCaseSensitive()) $member = utf8_strtolower($member); if($member[0] == '@'){ $member = $auth->cleanGroup(substr($member,1)); if(in_array($member, $groups)) return true; -- cgit v1.2.3 From f2cfd2ce9ab3c204e78cd3e6589f8bb8d0079621 Mon Sep 17 00:00:00 2001 From: Gregor Skumavc Date: Tue, 21 Dec 2010 21:10:33 +0100 Subject: Slovak language update --- inc/lang/sl/admin.txt | 3 + inc/lang/sl/adminplugins.txt | 1 + inc/lang/sl/draft.txt | 5 ++ inc/lang/sl/lang.php | 130 ++++++++++++++++++++++++++++++++++++++++-- inc/lang/sl/subscr_digest.txt | 20 +++++++ inc/lang/sl/subscr_form.txt | 3 + inc/lang/sl/subscr_list.txt | 17 ++++++ inc/lang/sl/updateprofile.txt | 3 + inc/lang/sl/uploadmail.txt | 13 +++++ 9 files changed, 190 insertions(+), 5 deletions(-) create mode 100644 inc/lang/sl/admin.txt create mode 100644 inc/lang/sl/adminplugins.txt create mode 100644 inc/lang/sl/draft.txt create mode 100644 inc/lang/sl/subscr_digest.txt create mode 100644 inc/lang/sl/subscr_form.txt create mode 100644 inc/lang/sl/subscr_list.txt create mode 100644 inc/lang/sl/updateprofile.txt create mode 100644 inc/lang/sl/uploadmail.txt (limited to 'inc') diff --git a/inc/lang/sl/admin.txt b/inc/lang/sl/admin.txt new file mode 100644 index 000000000..fc78273ac --- /dev/null +++ b/inc/lang/sl/admin.txt @@ -0,0 +1,3 @@ +===== Administracija ===== + +Spodaj lahko vidite seznam administrativnih opravil v DokuWikiju. \ No newline at end of file diff --git a/inc/lang/sl/adminplugins.txt b/inc/lang/sl/adminplugins.txt new file mode 100644 index 000000000..9438b4759 --- /dev/null +++ b/inc/lang/sl/adminplugins.txt @@ -0,0 +1 @@ +===== Dodatni vtičniki ===== \ No newline at end of file diff --git a/inc/lang/sl/draft.txt b/inc/lang/sl/draft.txt new file mode 100644 index 000000000..9fea86fd1 --- /dev/null +++ b/inc/lang/sl/draft.txt @@ -0,0 +1,5 @@ +=====Najden je bil osnutek strani===== + +Vaša zadnja seja na tej strani ni bila pravilno zaključena. DokuWiki je samodejno shranil osnutek med vašim delom, katerega sedaj lahko nadaljujete. Spodaj lahko vidite podatke, ki so bili samodejno shranjeni v vaši zadnji seji. + +Prosimo, odločite se ali boste //obnovili// vašo sejo, //izbrisali// samodejno shranjen osnutek alo //prekinili// proces urejanja. \ No newline at end of file diff --git a/inc/lang/sl/lang.php b/inc/lang/sl/lang.php index 9d94bab49..8014d8a70 100644 --- a/inc/lang/sl/lang.php +++ b/inc/lang/sl/lang.php @@ -6,8 +6,10 @@ * @author Jaka Kranjc * @author Boštjan Seničar * @author Dejan Levec + * @author Gregor Skumavc (grega.skumavc@gmail.com) */ $lang['encoding'] = 'utf-8'; +$lang['direction'] = 'ltr'; $lang['doublequoteopening'] = '„'; $lang['doublequoteclosing'] = '“'; $lang['singlequoteopening'] = '‚'; @@ -35,12 +37,16 @@ $lang['btn_admin'] = 'Administrator'; $lang['btn_update'] = 'Posodobi'; $lang['btn_delete'] = 'Izbriši'; $lang['btn_back'] = 'Nazaj'; +$lang['btn_backlink'] = 'Navzkrižne povezave'; +$lang['btn_backtomedia'] = 'Nazaj na izbiro medijskih datotek'; +$lang['btn_subscribe'] = 'Uredi naročnine'; $lang['btn_profile'] = 'Posodobi profil'; $lang['btn_reset'] = 'Ponastavi'; $lang['btn_resendpwd'] = 'Pošlji novo geslo'; $lang['btn_draft'] = 'Uredi osnutek'; $lang['btn_recover'] = 'Obnovi osnutek'; $lang['btn_draftdel'] = 'Izbriši osnutek'; +$lang['btn_revert'] = 'Povrni'; $lang['loggedinas'] = 'Prijavljen kot'; $lang['user'] = 'Uporabniško ime'; $lang['pass'] = 'Geslo'; @@ -55,6 +61,7 @@ $lang['profile'] = 'Profil uporabnika'; $lang['badlogin'] = 'Oprostite, uporabniško ime ali geslo ni pravo.'; $lang['minoredit'] = 'Manjše spremembe'; $lang['draftdate'] = 'Samodejno shranjevanje osnutka vključeno'; +$lang['nosecedit'] = 'Stran se je medtem spremenila, informacije odseka so bile stare, naložila se je celotna stran.'; $lang['regmissing'] = 'Oprostite, zapolniti morate vsa polja.'; $lang['reguexists'] = 'Oprostite, uporabnik s tem imenom že obstaja.'; $lang['regsuccess'] = 'Uporabnik je bil ustvarjen. Geslo je bilo poslano na vaš elektronski naslov.'; @@ -64,21 +71,60 @@ $lang['regbadmail'] = 'Podan elektronski naslov izgleda neveljaven - $lang['regbadpass'] = 'Gesli nista enaki.'; $lang['regpwmail'] = 'Vaše geslo za DokuWiki'; $lang['reghere'] = 'Nimate še računa? Priskrbite si ga'; +$lang['profna'] = 'Ta wiki ne podpira sprememb profila'; $lang['profnochange'] = 'Brez sprememb, ničesar za storiti.'; +$lang['profnoempty'] = 'Prazno polje "e-pošta" ali "ime" ni dovoljeno.'; $lang['profchanged'] = 'Uporabniški profil uspešno posodobljen'; $lang['pwdforget'] = 'Pozabili geslo? Pridobite novega'; +$lang['resendna'] = 'Ta wiki ne podpira ponovnega pošiljanja gesel.'; $lang['resendpwd'] = 'Pošlji novo geslo za'; $lang['resendpwdmissing'] = 'Se opravičujemo, vendar morate izpolniti vsa polja.'; $lang['resendpwdnouser'] = 'Se opravičujemo, vendar tega uporabniškega imena ni v bazi.'; +$lang['resendpwdbadauth'] = 'Oprostite, ta avtorizacijska koda ni prava. Prepričajte se, da ste uporabili celotno povezavo za potrditev.'; $lang['resendpwdconfirm'] = 'Potrditvena povezava je bila poslana na vaš elektronski naslov'; $lang['resendpwdsuccess'] = 'Vaše novo geslo je bilo poslano na vaš elektronski naslov'; +$lang['license'] = 'Če ni drugače navedeno, je vsebina tega wikija licencirana z naslednjo licenco:'; +$lang['licenseok'] = 'Pomembno: Z urejanjem te strani se strinjate s tem, da se vsebina zaščiti z naslednjo licenco:'; +$lang['searchmedia'] = 'Išči datoteko:'; +$lang['searchmedia_in'] = 'Išči v %s'; $lang['txt_upload'] = 'Izberite datoteko za pošiljanje'; $lang['txt_filename'] = 'Vnesite wikiname (neobvezno)'; $lang['txt_overwrt'] = 'Prepiši obstoječo datoteko'; $lang['lockedby'] = 'Trenutno zaklenjeno od'; $lang['lockexpire'] = 'Zaklep preteče'; $lang['willexpire'] = 'Vaš zaklep za urejevanje bo pretekel čez eno minuto.\nDa se izognete konfliktom, uporabite predogled, da se merilnik časa za zaklep ponastavi.'; -$lang['js']['notsavedyet'] = "Obstajajo neshranjene spremembe, ki bodo izgubljene.\nRes želite nadaljevati?"; +$lang['js']['notsavedyet'] = 'Obstajajo neshranjene spremembe, ki bodo izgubljene. +Res želite nadaljevati?'; +$lang['js']['searchmedia'] = 'Išči datoteke'; +$lang['js']['keepopen'] = 'Od izbiri obdrži okno odprto'; +$lang['js']['hidedetails'] = 'Skrij podrobnosti'; +$lang['js']['mediatitle'] = 'Nastavitve povezave'; +$lang['js']['mediadisplay'] = 'Vrsta povezave'; +$lang['js']['mediaalign'] = 'Poravnava'; +$lang['js']['mediasize'] = 'Velikost slike'; +$lang['js']['mediatarget'] = 'Mesto povezave'; +$lang['js']['mediaclose'] = 'Zapri'; +$lang['js']['mediainsert'] = 'Vstavi'; +$lang['js']['mediadisplayimg'] = 'Pokaži sliko.'; +$lang['js']['mediadisplaylnk'] = 'Pokaži le povezavo.'; +$lang['js']['mediasmall'] = 'Manjša različica'; +$lang['js']['mediamedium'] = 'Srednja različica'; +$lang['js']['medialarge'] = 'Velika različica'; +$lang['js']['mediaoriginal'] = 'Originalna različica'; +$lang['js']['medialnk'] = 'Povezava na detajle strani'; +$lang['js']['mediadirect'] = 'Direktna povezava na original'; +$lang['js']['medianolnk'] = 'Brez povezave'; +$lang['js']['medianolink'] = 'Ne poveži na sliko'; +$lang['js']['medialeft'] = 'Poravnaj sliko na levi'; +$lang['js']['mediaright'] = 'Poravnaj sliko na desni'; +$lang['js']['mediacenter'] = 'Poravnaj sliko na sredino'; +$lang['js']['medianoalign'] = 'Ne uporabi poravnave'; +$lang['js']['nosmblinks'] = 'Povezovanje do Windows deljenih datotek deluje samo v Microsoft Internet Explorer-ju. +Še vedno pa lahko ročno kopirate povezavo.'; +$lang['js']['linkwiz'] = 'Čarovnik za povezave'; +$lang['js']['linkto'] = 'Poveži na:'; +$lang['js']['del_confirm'] = 'Resnično brišem izbrano(e) sliko(e)?'; +$lang['js']['mu_btn'] = 'Prenesite več dokumentov naenkrat.'; $lang['rssfailed'] = 'Prišlo je do napake pri prenašanju tega dovoda: '; $lang['nothingfound'] = 'Nič ni bilo najdeno.'; $lang['mediaselect'] = 'Mediafile Izbira'; @@ -87,23 +133,32 @@ $lang['uploadsucc'] = 'Pošiljanje uspelo'; $lang['uploadfail'] = 'Pošiljanje je spodletelo. Mogoče nimate dovoljenj?'; $lang['uploadwrong'] = 'Pošiljanje zavrnjeno. Ta datotečna končnica je prepovedana'; $lang['uploadexist'] = 'Dokument že obstaja. Brez sprememb.'; +$lang['uploadbadcontent'] = 'Naložena datoteka se ne ujema z/s %s končnico datoteke.'; +$lang['uploadspam'] = 'Nalaganje je bilo ustavljeno zaradi "črne liste" neželenih datotek.'; $lang['uploadxss'] = 'Prenos je bil zaustavljen zaradi možne zlonamerne vsebine.'; $lang['uploadsize'] = 'Prenesen dokument je prevelik. (max. %s)'; $lang['deletesucc'] = 'Datoteka "%s" je bila izbrisana.'; +$lang['deletefail'] = '"%s" ni bilo možno izbrisati - preverite nastavitve CHMOD'; $lang['mediainuse'] = 'Dokument "%s" ni bil izbrisan - je še vedno v uporabi.'; $lang['namespaces'] = 'Imenski prostori'; $lang['mediafiles'] = 'Datoteke ki so na voljo v'; -$lang['js']['hidedetails'] = 'Skrij podrobnosti'; -$lang['js']['nosmblinks'] = 'Povezovanje do Windows deljenih datotek deluje samo v Microsoft Internet Explorer-ju. -Še vedno pa lahko ročno kopirate povezavo.'; -$lang['js']['mu_btn'] = 'Prenesite več dokumentov naenkrat.'; +$lang['accessdenied'] = 'Nimate dovoljenja za ogled te strani.'; +$lang['mediausage'] = 'Uporabite naslednjo kodo za navajanje te datoteke:'; $lang['mediaview'] = 'Poglej originalno datoteko'; +$lang['mediaroot'] = 'korenska mapa'; +$lang['mediaupload'] = 'Naložite datoteko v trenutno mapo. Za ustvarjanje novih podmap, jih pripnite pred "Naloži kot" ime in jih ločite z navpičnico.'; +$lang['mediaextchange'] = 'Končnica datoteke se je spremenila iz .%s v .%s!'; +$lang['reference'] = 'Reference za'; +$lang['ref_inuse'] = 'Te datoteke ni možno izbrisati, ker jo še vedno uporablja(jo) stran(i):'; +$lang['ref_hidden'] = 'Nekaj referenc je na straneh, do katerih nimate dostopa.'; $lang['hits'] = 'Zadetkov'; $lang['quickhits'] = 'Ujemanja v imenih strani'; $lang['toc'] = 'Kazalo'; $lang['current'] = 'trenutna'; $lang['yours'] = 'Vaša različica'; $lang['diff'] = 'prikaži razlike s trenutno različico'; +$lang['diff2'] = 'Pokaži razlike med izbranimi revizijami'; +$lang['difflink'] = 'Naredi povezavo na to primerjavo'; $lang['line'] = 'Vrstica'; $lang['breadcrumb'] = 'Sled'; $lang['youarehere'] = 'Tukaj ste'; @@ -112,10 +167,13 @@ $lang['by'] = 'od'; $lang['deleted'] = 'odstranjena'; $lang['created'] = 'ustvarjena'; $lang['restored'] = 'stara različica povrnjena'; +$lang['external_edit'] = 'urejanje v zunanjem urejevalniku'; $lang['summary'] = 'Povzetek urejanja'; $lang['noflash'] = 'Za prikaz vsebine potrebujete Adobe Flash Plugin'; +$lang['download'] = 'Naloži izrezek'; $lang['mail_newpage'] = '[DokuWiki] stran dodana:'; $lang['mail_changed'] = '[DokuWiki] stran spremenjena:'; +$lang['mail_subscribe_list'] = 'strani s spremenjenim imenom:'; $lang['mail_new_user'] = 'nov uporabnik.'; $lang['mail_upload'] = 'naložena datoteka:'; $lang['qb_bold'] = 'Krepki tisk'; @@ -128,6 +186,11 @@ $lang['qb_h2'] = 'Naslov drugee stopnje'; $lang['qb_h3'] = 'Naslov tretje stopnje'; $lang['qb_h4'] = 'Naslov četrte stopnje'; $lang['qb_h5'] = 'Naslov pete stopnje'; +$lang['qb_h'] = 'Naslov'; +$lang['qb_hs'] = 'Izberi naslov'; +$lang['qb_hplus'] = 'Naslov na višjem nivoju'; +$lang['qb_hminus'] = 'Naslov na nižjem nivoju'; +$lang['qb_hequal'] = 'Naslov na istem nivoju'; $lang['qb_link'] = 'Notranja povezava'; $lang['qb_extlink'] = 'Zunanja povezava'; $lang['qb_hr'] = 'Vodoravna črta'; @@ -137,6 +200,7 @@ $lang['qb_media'] = 'Dodaj slike in druge datoteke'; $lang['qb_sig'] = 'Vstavi podpis'; $lang['qb_smileys'] = 'Smeški'; $lang['qb_chars'] = 'Posebni znaki'; +$lang['upperns'] = 'skoči na starševski članek'; $lang['admin_register'] = 'Dodaj novega uporabnika'; $lang['metaedit'] = 'Popravi metapodatke'; $lang['metasaveerr'] = 'Zapisovanje metapodatkov ni uspelo'; @@ -148,15 +212,71 @@ $lang['img_date'] = 'Datum'; $lang['img_fname'] = 'Ime datoteke'; $lang['img_fsize'] = 'Velikost'; $lang['img_artist'] = 'Fotograf'; +$lang['img_copyr'] = 'Avtorska zaščita'; $lang['img_format'] = 'Velikost'; $lang['img_camera'] = 'Fotoaparat'; $lang['img_keywords'] = 'Ključne besede'; +$lang['subscr_subscribe_success'] = 'Dodan %s na seznam naročnin za %s'; +$lang['subscr_subscribe_error'] = 'Napaka pri dodajanju %s na seznam naročnin za %s'; +$lang['subscr_subscribe_noaddress'] = 'Z vašo prijavo ni povezan noben e-naslov, zato vas ne moremo dodati na seznam naročnikov'; +$lang['subscr_unsubscribe_success'] = 'Odstranjeno %s s seznama naročnin za %s'; +$lang['subscr_unsubscribe_error'] = 'Napaka pri odstranjevanju %s s seznama naročnin za %s'; +$lang['subscr_already_subscribed'] = '%s je že naročen na %s'; +$lang['subscr_not_subscribed'] = '%s ni naročen na %s'; +$lang['subscr_m_not_subscribed'] = 'Niste naročeni na trenutno stran ali članek.'; +$lang['subscr_m_new_header'] = 'Naroči se na spremembe'; +$lang['subscr_m_current_header'] = 'Trenutne naročnine'; +$lang['subscr_m_unsubscribe'] = 'Odjavi se'; +$lang['subscr_m_subscribe'] = 'Naroči se'; +$lang['subscr_m_receive'] = 'Prejmi'; +$lang['subscr_style_every'] = 'e-pošto ob vsaki spremembi'; +$lang['subscr_style_digest'] = 'strnjeno e-pošti sprememb za vsako stran (vsake %.2f dni)'; +$lang['subscr_style_list'] = 'seznam spremenjenih strani od zadnje pošte (vsake %.2f dni)'; +$lang['authmodfailed'] = 'Slaba nastavitev potrditve. Prosimo obvestite administratorja wikija.'; +$lang['authtempfail'] = 'Potrditev uporabnika je trenutno nedostopna. Če se ta napaka ponavlja, prosimo obvestite administratorja wikija.'; $lang['i_chooselang'] = 'Izberite jezik'; $lang['i_installer'] = 'DokuWiki namestitev'; $lang['i_wikiname'] = 'Wiki ime'; $lang['i_enableacl'] = 'Omogoči ACL (priporočeno)'; $lang['i_superuser'] = 'Naduporabnik'; +$lang['i_problems'] = 'Installer je naletel na težave, ki so opisane spodaj. Ne morete nadaljevati, dokler jih ne odpravite.'; +$lang['i_modified'] = 'Iz varnostnih razlogov bo ta skrip deloval le v novi in nespremenjeneni namestitvi DokuWikija. Potrebno je ali ponovno razširiti datoteke iz naloženega paketa, ali preberete popolna Dokuwiki navodila za namestitev.'; +$lang['i_funcna'] = 'PHP funkcija %s ni na voljo. Morda jo je vaš ponudnik onemogočil?'; +$lang['i_phpver'] = 'Verzija vašega PHP-ja %s je nižja od potrebne %s. Potrebno je posodobiti PHP inštalacijo.'; +$lang['i_permfail'] = '%s ni zapisljiva. Potrebno je nastaviti CHMOD nastavitve dostopa do direktorija.'; $lang['i_confexists'] = '%s že obstaja'; +$lang['i_writeerr'] = 'Ni mogoče ustvariti %s. Preveriti morate CHMOD nastavitve dostopa direktorija ali datoteke in ustvariti datoteko ročno.'; +$lang['i_badhash'] = 'nepoznana ali spremenjena dokuwiki.php (hash=%s)'; +$lang['i_badval'] = '%s - neveljavna ali prazna vrednost'; +$lang['i_success'] = 'Konfiguracija se je zaključila uspešno. Datoteko install.php lahko sedaj izbrišete. Nadaljujte v vaš novi DokuWiki.'; +$lang['i_failure'] = 'Med zapisovanjem nastavitvenih datotek je prišlo do nekaj napak. Preden lahko uporabite vaš novi DokuWiki, jih boste morali ročno popraviti.'; +$lang['i_policy'] = 'Namesti ACL'; +$lang['i_pol0'] = 'Odprt Wiki (branje, zapis, nalaganje datotek je javno za vse)'; +$lang['i_pol1'] = 'Javni Wiki (branje za vse, zapis in nalaganje datotek za prijavljene uporabnike)'; +$lang['i_pol2'] = 'Zaprt Wiki (berejo in urejajo lahko le prijavljeni uporabniki)'; +$lang['i_retry'] = 'Ponovni poskus'; +$lang['i_license'] = 'Prosimo, izberite licenco, pod katero bo objsavljena vsebina:'; +$lang['mu_intro'] = 'Tukaj lahko naložite več datotek hkrati. Kliknite gumb "Brskaj", da jih dodate v vrsto. Kliknite "Naloži", ko ste končali'; +$lang['mu_gridname'] = 'Ime datoteke'; $lang['mu_gridsize'] = 'Velikost'; +$lang['mu_gridstat'] = 'Status'; +$lang['mu_namespace'] = 'Ime'; +$lang['mu_browse'] = 'Brskaj'; +$lang['mu_toobig'] = 'prevelika datoteka'; +$lang['mu_ready'] = 'pripravljena na nalaganje'; $lang['mu_done'] = 'končano'; +$lang['mu_fail'] = 'ni uspelo'; +$lang['mu_authfail'] = 'seja je potekla'; +$lang['mu_progress'] = '@PCT@% naloženo'; $lang['mu_filetypes'] = 'Dovoljeni tipi datotek'; +$lang['mu_info'] = 'datoteke naložene'; +$lang['mu_lasterr'] = 'Zadnja napaka:'; +$lang['recent_global'] = 'Trenutno gledate spremembe znotraj imenskega prostora %s. Lahko si ogledate tudi spremembe, narejene v celotnem wikiju.'; +$lang['years'] = '%d let nazaj'; +$lang['months'] = '%d mesecev nazaj'; +$lang['weeks'] = '%d tednov nazaj'; +$lang['days'] = '%d dni nazaj'; +$lang['hours'] = '%d ur nazaj'; +$lang['minutes'] = '%d minut nazaj'; +$lang['seconds'] = '%d sekund nazaj'; +$lang['wordblock'] = 'Vaša sprememba ni bila shranjena, ker vsebuje neželeno besedilo (spam).'; diff --git a/inc/lang/sl/subscr_digest.txt b/inc/lang/sl/subscr_digest.txt new file mode 100644 index 000000000..983cab233 --- /dev/null +++ b/inc/lang/sl/subscr_digest.txt @@ -0,0 +1,20 @@ +Pozdravljeni! + +Stran @PAGE@ v wikiju @TITLE@ je bila spremenjena. +Tu so spremembe: + +------------------------------------------------ +@DIFF@ +------------------------------------------------ + +Stara revizija: @OLDPAGE@ +Nova revizija: @NEWPAGE@ + +Za odjavo pošiljanja sprememb se prijavite v wiki na naslovu +@DOKUWIKIURL@, nato obiščite +@SUBSCRIBE@ +in se odjavite od sprememb strani in/ali imenskega prostora. + +-- +To sporočilo je generiral DokuWiki na naslovu +@DUKOWIKIURL@ \ No newline at end of file diff --git a/inc/lang/sl/subscr_form.txt b/inc/lang/sl/subscr_form.txt new file mode 100644 index 000000000..46be8c954 --- /dev/null +++ b/inc/lang/sl/subscr_form.txt @@ -0,0 +1,3 @@ +===== Urejanje naročnin ==== + +Ta stran vam omogoča urejanje vaših naročnin za trenutno stran in imenski prostor. \ No newline at end of file diff --git a/inc/lang/sl/subscr_list.txt b/inc/lang/sl/subscr_list.txt new file mode 100644 index 000000000..f4cfbc268 --- /dev/null +++ b/inc/lang/sl/subscr_list.txt @@ -0,0 +1,17 @@ +Pozdravljeni! + +Strani v imenskem prostoru @PAGE@ wikija @TITLE@ so se spremenile. +Tu so spremenjene strani: + +------------------------------------------------ +@DIFF@ +------------------------------------------------ + +Za odjavo pošiljanja sprememb se prijavite v wiki na naslovu +@DOKUWIKIURL@, nato obiščite +@SUBSCRIBE@ +in se odjavite od sprememb strani in/ali imenskega prostora. + +-- +To sporočilo je generiral DokuWiki na naslovu +@DUKOWIKIURL@ \ No newline at end of file diff --git a/inc/lang/sl/updateprofile.txt b/inc/lang/sl/updateprofile.txt new file mode 100644 index 000000000..45aa7d92f --- /dev/null +++ b/inc/lang/sl/updateprofile.txt @@ -0,0 +1,3 @@ +===== Posodobite svoj profil računa ===== + +Posodobite le tista polja, ki jih želite spremeniti. Svojega uporabiškega imena ne morete spreminjati. \ No newline at end of file diff --git a/inc/lang/sl/uploadmail.txt b/inc/lang/sl/uploadmail.txt new file mode 100644 index 000000000..6006bd379 --- /dev/null +++ b/inc/lang/sl/uploadmail.txt @@ -0,0 +1,13 @@ +Datoteka je bila naložena v vaš DokuWiki. Tu so podatki: + +Datoteka: @MEDIA@ +Datum: @DATE@ +Brskalnik: @BROWSER@ +IP naslov: @IPADDRESS@ +Ponudnik: @HOSTNAME@ +Velikost: @SIZE@ +MIME tip: @MIME@ +Uporabnik: @USER@ + +-- +Sporočilo je generiral DokuWiki na naslovu @DOKUWIKIURL@ \ No newline at end of file -- cgit v1.2.3 From a8e721331b457d168309bfdfa062d0889997abd6 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 22 Dec 2010 14:19:52 +0100 Subject: store the creator's login name in metadata FS#1397 --- inc/changelog.php | 5 ++++- inc/parser/metadata.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/changelog.php b/inc/changelog.php index cc7612bfd..15cd46d77 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -84,7 +84,10 @@ function addLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', $extr $meta = array(); if (!$INFO['exists'] && empty($oldmeta['persistent']['date']['created'])){ // newly created $meta['date']['created'] = $created; - if ($user) $meta['creator'] = $INFO['userinfo']['name']; + if ($user){ + $meta['creator'] = $INFO['userinfo']['name']; + $meta['user'] = $user; + } } elseif (!$INFO['exists'] && !empty($oldmeta['persistent']['date']['created'])) { // re-created / restored $meta['date']['created'] = $oldmeta['persistent']['date']['created']; $meta['date']['modified'] = $created; // use the files ctime here diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 263745593..5617a0c86 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -45,6 +45,9 @@ class Doku_Renderer_metadata extends Doku_Renderer { if(!$this->persistent['date']['created']){ $this->persistent['date']['created'] = filectime(wikiFN($ID)); } + if(!isset($this->persistent['user'])){ + $this->persistent['user'] = ''; + } if(!isset($this->persistent['creator'])){ $this->persistent['creator'] = ''; } -- cgit v1.2.3 From 682a7e10474024fe1dc045e30d2fafa4279d7059 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 22 Dec 2010 14:51:55 +0100 Subject: skip empty image title from abstract --- inc/parser/metadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 5617a0c86..fc2c8cbc5 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -464,7 +464,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { } else if (is_string($title)){ return $title; } else if (is_array($title)){ - return '['.$title['title'].']'; + if($title['title']) return '['.$title['title'].']'; } } -- cgit v1.2.3 From 69ba640bb6c63d2132ca401588053dfc507dbb1b Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 27 Dec 2010 22:51:06 +0100 Subject: Save metadata only when really changed This avoids disk writes when not needed and possibly also xhtml rendering when the metadata needs to be rendered but xhtml doesn't (unless the metadata file is changed). --- inc/parserutils.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/parserutils.php b/inc/parserutils.php index d4f55a6e4..fbdc2e3a9 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -240,8 +240,10 @@ function p_get_metadata($id, $key='', $render=false){ $cachefile = new cache_renderer($id, wikiFN($id), 'metadata'); if (page_exists($id) && !$cachefile->useCache()){ + $old_meta = $meta; $meta = p_render_metadata($id, $meta); - if (p_save_metadata($id, $meta)) { + // only update the file when the metadata has been changed + if ($meta == $old_meta || p_save_metadata($id, $meta)) { // store a timestamp in order to make sure that the cachefile is touched $cachefile->storeCache(time()); } else { -- cgit v1.2.3 From e6cecb0872ef457f44529edbc736aba3dc3ac258 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 26 Dec 2010 23:03:16 +0100 Subject: Language files can now be customized in the conf/ directory As suggested by Robin Getz locale .txt files can now be duplicated and changed in the conf/lang/ directory and conf/plugin_lang/$plugin/ directory for plugins. --- inc/pageutils.php | 9 ++++++--- inc/plugin.php | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'inc') diff --git a/inc/pageutils.php b/inc/pageutils.php index 42a485bdf..5d24c12bb 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -344,10 +344,13 @@ function mediaFN($id){ */ function localeFN($id){ global $conf; - $file = DOKU_INC.'inc/lang/'.$conf['lang'].'/'.$id.'.txt'; + $file = DOKU_CONF.'/lang/'.$conf['lang'].'/'.$id.'.txt'; if(!@file_exists($file)){ - //fall back to english - $file = DOKU_INC.'inc/lang/en/'.$id.'.txt'; + $file = DOKU_INC.'inc/lang/'.$conf['lang'].'/'.$id.'.txt'; + if(!@file_exists($file)){ + //fall back to english + $file = DOKU_INC.'inc/lang/en/'.$id.'.txt'; + } } return $file; } diff --git a/inc/plugin.php b/inc/plugin.php index aff07c1e5..628ae39b0 100644 --- a/inc/plugin.php +++ b/inc/plugin.php @@ -88,10 +88,13 @@ class DokuWiki_Plugin { function localFN($id) { global $conf; $plugin = $this->getPluginName(); - $file = DOKU_PLUGIN.$plugin.'/lang/'.$conf['lang'].'/'.$id.'.txt'; - if(!@file_exists($file)){ - //fall back to english - $file = DOKU_PLUGIN.$plugin.'/lang/en/'.$id.'.txt'; + $file = DOKU_CONF.'/plugin_lang/'.$plugin.'/'.$conf['lang'].'/'.$id.'.txt'; + if (!@file_exists($file)){ + $file = DOKU_PLUGIN.$plugin.'/lang/'.$conf['lang'].'/'.$id.'.txt'; + if(!@file_exists($file)){ + //fall back to english + $file = DOKU_PLUGIN.$plugin.'/lang/en/'.$id.'.txt'; + } } return $file; } -- cgit v1.2.3 From 5526795c71a703486ddd19bf986e6a0cf7309945 Mon Sep 17 00:00:00 2001 From: Guy Brand Date: Fri, 31 Dec 2010 15:46:43 +0100 Subject: Allow a prefix for subject of sent mails (Close FS#2021) --- inc/common.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'inc') diff --git a/inc/common.php b/inc/common.php index a1c4580a6..6ea6d56d8 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1128,12 +1128,15 @@ function notify($id,$who,$rev='',$summary='',$minor=false,$replace=array()){ $diff = rawWiki($id); } $text = str_replace('@DIFF@',$diff,$text); - if(utf8_strlen($conf['title']) < 20) { - $subject = '['.$conf['title'].'] '.$subject; + if(empty($conf['mailprefix'])) { + if(utf8_strlen($conf['title']) < 20) { + $subject = '['.$conf['title'].'] '.$subject; + }else{ + $subject = '['.utf8_substr($conf['title'], 0, 20).'...] '.$subject; + } }else{ - $subject = '['.utf8_substr($conf['title'], 0, 20).'...] '.$subject; + $subject = '['.$conf['mailprefix'].'] '.$subject; } - mail_send($to,$subject,$text,$conf['mailfrom'],'',$bcc); } -- cgit v1.2.3 From e013f48d37f8cdd20b7c81cd4dfb24b695354050 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 2 Jan 2011 19:27:46 +0000 Subject: adjusted tpl_youarehere to use tpl_pagelink (and fixed bugs with missing first headings) --- inc/template.php | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'inc') diff --git a/inc/template.php b/inc/template.php index 53ae9abce..373e60fde 100644 --- a/inc/template.php +++ b/inc/template.php @@ -748,39 +748,27 @@ function tpl_youarehere($sep=' » '){ echo ''.$lang['youarehere'].': '; // always print the startpage - $title = useHeading('navigation') ? p_get_first_heading($conf['start']) : $conf['start']; - if(!$title) $title = $conf['start']; - tpl_link(wl($conf['start']),hsc($title),'title="'.$conf['start'].'"'); + tpl_pagelink(':'.$conf['start']); // print intermediate namespace links $part = ''; for($i=0; $i<$count - 1; $i++){ $part .= $parts[$i].':'; $page = $part; - resolve_pageid('',$page,$exists); if ($page == $conf['start']) continue; // Skip startpage // output echo $sep; - if($exists){ - $title = useHeading('navigation') ? p_get_first_heading($page) : $parts[$i]; - tpl_link(wl($page),hsc($title),'title="'.$page.'"'); - }else{ - tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); - } + tpl_pagelink($page); } // print current page, skipping start page, skipping for namespace index + resolve_pageid('',$page,$exists); if(isset($page) && $page==$part.$parts[$i]) return; $page = $part.$parts[$i]; if($page == $conf['start']) return; echo $sep; - if(page_exists($page)){ - $title = useHeading('navigation') ? p_get_first_heading($page) : $parts[$i]; - tpl_link(wl($page),hsc($title),'title="'.$page.'"'); - }else{ - tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); - } + tpl_pagelink($page); return true; } -- cgit v1.2.3 From ddcde0004fc886990df5b7029e93bb345d7e09b4 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 2 Jan 2011 20:45:16 +0000 Subject: added space between license text and link --- inc/html.php | 4 ++-- inc/template.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index 9d3c92707..4e3744fd1 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1214,9 +1214,9 @@ function html_edit(){ if($wr && $conf['license']){ $form->addElement(form_makeOpenTag('div', array('class'=>'license'))); $out = $lang['licenseok']; - $out .= ''; + $out .= '>'.$license[$conf['license']]['name'].''; $form->addElement($out); $form->addElement(form_makeCloseTag('div')); } diff --git a/inc/template.php b/inc/template.php index 373e60fde..413c3af07 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1236,7 +1236,7 @@ function tpl_license($img='badge',$imgonly=false,$return=false){ } if(!$imgonly) { $out .= $lang['license']; - $out .= ''; } -- cgit v1.2.3 From 4c36bf829933f31b2adfa813cd61b9b895e31469 Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Mon, 3 Jan 2011 14:46:03 +0100 Subject: Change sitemap filename to sitemap.xml(.gz). Closes FS#2127 --- inc/actions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc') diff --git a/inc/actions.php b/inc/actions.php index 0297f6e56..016af4aea 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -626,6 +626,7 @@ function act_sitemap($act) { if (is_readable($sitemap)) { // Send headers header('Content-Type: '.$mime); + header('Content-Disposition: attachment; filename='.basename($sitemap)); http_conditionalRequest(filemtime($sitemap)); -- cgit v1.2.3 From be96545ccf297b7b2a7bf10b2d0f35d636e8adf6 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Mon, 3 Jan 2011 15:46:10 +0000 Subject: removed obsolete references to 'JSnocheck' class --- inc/parser/xhtml.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index b0d93f93e..9405d9420 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -734,9 +734,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $name = $this->_getLinkTitle($name, '', $isImage); if ( !$isImage ) { - $link['class']='mail JSnocheck'; + $link['class']='mail'; } else { - $link['class']='media JSnocheck'; + $link['class']='media'; } $address = $this->_xmlEntities($address); -- cgit v1.2.3 From 3e47436aa32c2639098515b6b46dbf36094118de Mon Sep 17 00:00:00 2001 From: lupo49 Date: Tue, 4 Jan 2011 20:02:25 +0100 Subject: updated russian translation (core) --- inc/lang/ru/conflict.txt | 2 +- inc/lang/ru/draft.txt | 2 +- inc/lang/ru/edit.txt | 2 +- inc/lang/ru/editrev.txt | 2 +- inc/lang/ru/install.html | 4 ++-- inc/lang/ru/lang.php | 42 ++++++++++++++++++++---------------------- inc/lang/ru/norev.txt | 2 +- inc/lang/ru/password.txt | 7 ++++--- inc/lang/ru/preview.txt | 2 +- inc/lang/ru/pwconfirm.txt | 2 +- inc/lang/ru/revisions.txt | 2 +- inc/lang/ru/searchpage.txt | 2 +- inc/lang/ru/showrev.txt | 2 +- inc/lang/ru/subscr_digest.txt | 2 +- inc/lang/ru/subscr_list.txt | 7 ++++--- inc/lang/ru/subscr_single.txt | 10 ++++++---- 16 files changed, 47 insertions(+), 45 deletions(-) (limited to 'inc') diff --git a/inc/lang/ru/conflict.txt b/inc/lang/ru/conflict.txt index f1ac60bd4..6c5e33dce 100644 --- a/inc/lang/ru/conflict.txt +++ b/inc/lang/ru/conflict.txt @@ -2,4 +2,4 @@ Существует более новая версия документа, который вы редактировали. Такое случается, когда другой пользователь изменил документ, пока вы делали то же самое. -Внимательно изучите различия, приведенные ниже и решите, какую версию оставить. Если вы выберете ''Сохранить'', то ваша версия будет сохранена. Нажав ''Отменить',' вы оставите текущую версию. +Внимательно изучите различия, приведенные ниже, и решите, какую версию оставить. Если вы выберете «Сохранить», то ваша версия будет сохранена. Нажав «Отменить», вы оставите текущую версию. diff --git a/inc/lang/ru/draft.txt b/inc/lang/ru/draft.txt index bbd2e5913..cb35f72b6 100644 --- a/inc/lang/ru/draft.txt +++ b/inc/lang/ru/draft.txt @@ -1,6 +1,6 @@ ====== Найден черновик ====== -Последний раз редактирование этой страницы не было корректно завершено. Во время вашей работы был автоматически сохранён черновик, который вы теперь можете восстановить и продолжить прерванную правку. Ниже вы видите автоматически сохраненную версию. +Последний раз редактирование этой страницы не было корректно завершено. Во время вашей работы был автоматически сохранён черновик, который вы теперь можете восстановить и продолжить прерванную правку. Ниже вы видите автоматически сохранённую версию. Пожалуйста, решите, хотите ли вы //восстановить// потерянную версию, //удалить// черновик, или //отменить// редактирование. diff --git a/inc/lang/ru/edit.txt b/inc/lang/ru/edit.txt index 6398e8e83..aac399d7c 100644 --- a/inc/lang/ru/edit.txt +++ b/inc/lang/ru/edit.txt @@ -1,2 +1,2 @@ -Отредактируйте страницу и нажмите ''Сохранить''. Прочтите [[wiki:syntax]] для ознакомления с синтаксисом вики. Пожалуйста, редактируйте только в том случае, если планируете **улучшить** содержимое. Если вы просто хотите потестировать что-либо, воспользуйтесь специальной страницей: [[playground:playground]]. +Отредактируйте страницу и нажмите «Сохранить». Прочтите [[wiki:syntax|справочную страницу]] для ознакомления с синтаксисом вики. Пожалуйста, редактируйте только в том случае, если планируете **улучшить** содержимое. Если вы просто хотите потестировать что-либо, воспользуйтесь специальной страницей: [[playground:playground]]. diff --git a/inc/lang/ru/editrev.txt b/inc/lang/ru/editrev.txt index db843ec1c..97b799a70 100644 --- a/inc/lang/ru/editrev.txt +++ b/inc/lang/ru/editrev.txt @@ -1,2 +1,2 @@ -**Вы загрузили старую ревизию документа!** Сохранив её, вы создадите новую текущую версию с этим содержимым. +**Вы загрузили старую ревизию документа.** Сохранив её, вы создадите новую текущую версию с этим содержимым. ---- diff --git a/inc/lang/ru/install.html b/inc/lang/ru/install.html index da0c5e239..b830b06c0 100644 --- a/inc/lang/ru/install.html +++ b/inc/lang/ru/install.html @@ -1,6 +1,6 @@ -

Эта страница предназначена помочь в первоначальной установке и конфигурации «ДокуВики». Дополнительная информация о программе установки доступна на её странице документации.

+

Эта страница предназначена помочь в первоначальной установке и конфигурации «ДокуВики». Дополнительная информация о программе установки доступна на её странице документации.

-

«ДокуВики» использует обычные файлы для хранения страниц и дополнительной информации (например, изображений, поискового индекса, предыдущих версий страницы, и т. д.). Для успешной работы «ДокуВики» необходим доступ на запись к директориям с этими файлами. Данная программа установки не может самостоятельно изменять системные права доступа к директориям. Обычно это делается напрямую из командной строки (shell), или, если вы используете удалённый хостинг, через FTP или панель управления вашего хостинга (например, cPanel).

+

«ДокуВики» использует обычные файлы для хранения страниц и дополнительной информации (например, изображений, поискового индекса, предыдущих версий страницы, и т. д.). Для успешной работы «ДокуВики» необходим доступ на запись к директориям с этими файлами. Данная программа установки не может самостоятельно изменять системные права доступа к директориям. Обычно это делается напрямую из командной строки (shell), или, если вы используете удалённый хостинг, через FTP или панель управления своего хостинга (например, cPanel).

Программа установки включит использование списков контроля доступа (ACL) в вашей «ДокуВики». Это позволит администратору, после авторизации в «ДокуВики», использовать специальное меню для установки плагинов, управления пользователями и доступом к страницам вики, а также для настройки конфигурационных параметров. Списки контроля доступа не обязательны для работы «ДокуВики», однако они позволяют упростить управление вашей «ДокуВики».

diff --git a/inc/lang/ru/lang.php b/inc/lang/ru/lang.php index 88692ae93..2968d72bd 100644 --- a/inc/lang/ru/lang.php +++ b/inc/lang/ru/lang.php @@ -76,7 +76,7 @@ $lang['regmissing'] = 'Извините, вам следует зап $lang['reguexists'] = 'Извините, пользователь с таким логином уже существует.'; $lang['regsuccess'] = 'Пользователь создан, пароль выслан на адрес электронной почты.'; $lang['regsuccess2'] = 'Пользователь создан.'; -$lang['regmailfail'] = 'Похоже, проблема с отправкой пароля по почте. Пожалуйста, сообщите администратору.'; +$lang['regmailfail'] = 'Похоже есть проблема с отправкой пароля по почте. Пожалуйста, сообщите об этом администратору.'; $lang['regbadmail'] = 'Данный вами адрес электронной почты выглядит неправильным. Если вы считаете это ошибкой, сообщите администратору.'; $lang['regbadpass'] = 'Два введённых пароля не идентичны. Пожалуйста, попробуйте ещё раз.'; $lang['regpwmail'] = 'Ваш пароль для системы «ДокуВики»'; @@ -94,7 +94,7 @@ $lang['resendpwdbadauth'] = 'Извините, неверный код ав $lang['resendpwdconfirm'] = 'Ссылка для подтверждения пароля была выслана по электронной почте. '; $lang['resendpwdsuccess'] = 'Ваш новый пароль был выслан по электронной почте.'; $lang['license'] = 'За исключением случаев, когда указано иное, содержимое этой вики предоставляется на условиях следующей лицензии:'; -$lang['licenseok'] = 'Примечание: редактируя эту страницу, вы соглашаетесь на использование вашего вклада на условиях следующей лицензии:'; +$lang['licenseok'] = 'Примечание: редактируя эту страницу, вы соглашаетесь на использование своего вклада на условиях следующей лицензии:'; $lang['searchmedia'] = 'Поиск по имени файла:'; $lang['searchmedia_in'] = 'Поиск в %s'; $lang['txt_upload'] = 'Выберите файл для загрузки'; @@ -103,8 +103,7 @@ $lang['txt_overwrt'] = 'Перезаписать существующ $lang['lockedby'] = 'В данный момент заблокирован'; $lang['lockexpire'] = 'Блокировка истекает в'; $lang['willexpire'] = 'Ваша блокировка редактирования этой страницы истекает в течение минуты.\nЧтобы избежать конфликтов и сбросить таймер блокировки, нажмите кнопку просмотра.'; -$lang['js']['notsavedyet'] = 'Несохранённые изменения будут потеряны. -Вы действительно хотите продолжить?'; +$lang['js']['notsavedyet'] = 'Несохранённые изменения будут потеряны. Вы действительно хотите продолжить?'; $lang['js']['searchmedia'] = 'Поиск файлов'; $lang['js']['keepopen'] = 'Не закрывать окно после выбора'; $lang['js']['hidedetails'] = 'Скрыть детали'; @@ -112,7 +111,7 @@ $lang['js']['mediatitle'] = 'Настройки ссылок'; $lang['js']['mediadisplay'] = 'Тип ссылки'; $lang['js']['mediaalign'] = 'Выравнивание'; $lang['js']['mediasize'] = 'Размер изображения'; -$lang['js']['mediatarget'] = 'target ссылки'; +$lang['js']['mediatarget'] = 'Значение target ссылки'; $lang['js']['mediaclose'] = 'Закрыть'; $lang['js']['mediainsert'] = 'Вставить'; $lang['js']['mediadisplayimg'] = 'Показывать изображение.'; @@ -129,8 +128,7 @@ $lang['js']['medialeft'] = 'Выровнять изображение по $lang['js']['mediaright'] = 'Выровнять изображение по правому краю.'; $lang['js']['mediacenter'] = 'Выровнять изображение по центру.'; $lang['js']['medianoalign'] = 'Не выравнивать.'; -$lang['js']['nosmblinks'] = 'Ссылка на сетевые каталоги Windows работает только из Интернет Эксплорера -Но вы можете скопировать ссылку.'; +$lang['js']['nosmblinks'] = 'Ссылка на сетевые каталоги Windows работает только из Интернет Эксплорера. Но вы можете скопировать ссылку.'; $lang['js']['linkwiz'] = 'Мастер ссылок'; $lang['js']['linkto'] = 'Ссылка на:'; $lang['js']['del_confirm'] = 'Вы на самом деле желаете удалить выбранное?'; @@ -149,18 +147,18 @@ $lang['uploadxss'] = 'Загрузка заблокирована п $lang['uploadsize'] = 'Загруженный файл был слишком большой. (макс. %s)'; $lang['deletesucc'] = 'Файл "%s" был удалён.'; $lang['deletefail'] = 'Невозможно удалить файл "%s". Проверьте права доступа к файлу.'; -$lang['mediainuse'] = 'Файл "%s" не был удалён - файл всё ещё используется.'; +$lang['mediainuse'] = 'Файл "%s" не был удалён — файл всё ещё используется.'; $lang['namespaces'] = 'Пространства имён'; $lang['mediafiles'] = 'Доступные файлы'; $lang['accessdenied'] = 'Вы не можете просмотреть эту страницу.'; $lang['mediausage'] = 'Для ссылки на этот файл используйте следующий синтаксис:'; $lang['mediaview'] = 'Посмотреть исходный файл'; $lang['mediaroot'] = 'корень'; -$lang['mediaupload'] = 'Здесь можно загрузить файл в текущий каталог («пространство имен»). Чтобы создать подкаталоги, добавьте их к началу имени файла («Загрузить как»). Имена подкаталогов разделяются двоеточиями. '; +$lang['mediaupload'] = 'Здесь можно загрузить файл в текущий каталог («пространство имён»). Чтобы создать подкаталоги, добавьте их к началу имени файла («Загрузить как»). Имена подкаталогов разделяются двоеточиями. '; $lang['mediaextchange'] = 'Расширение изменилось: с .%s на .%s!'; $lang['reference'] = 'Ссылки для'; -$lang['ref_inuse'] = 'Этот файл не может быть удалён, так как он используется следующими страницами:'; -$lang['ref_hidden'] = 'Некоторые ссылки находятся на страницах, на чтение которых у вас нет прав'; +$lang['ref_inuse'] = 'Этот файл не может быть удалён, так как он используется на следующих страницах:'; +$lang['ref_hidden'] = 'Некоторые ссылки находятся на страницах, на чтение которых у вас нет прав доступа'; $lang['hits'] = 'соответствий'; $lang['quickhits'] = 'Соответствия в названиях страниц'; $lang['toc'] = 'Содержание'; @@ -183,7 +181,7 @@ $lang['noflash'] = 'Для просмотра этого соде $lang['download'] = 'Скачать код'; $lang['mail_newpage'] = 'страница добавлена:'; $lang['mail_changed'] = 'страница изменена:'; -$lang['mail_subscribe_list'] = 'изменились страницы в пространстве имен:'; +$lang['mail_subscribe_list'] = 'изменились страницы в пространстве имён:'; $lang['mail_new_user'] = 'новый пользователь:'; $lang['mail_upload'] = 'файл закачан:'; $lang['qb_bold'] = 'Полужирный'; @@ -210,7 +208,7 @@ $lang['qb_media'] = 'Добавить изображения или $lang['qb_sig'] = 'Вставить подпись'; $lang['qb_smileys'] = 'Смайлики'; $lang['qb_chars'] = 'Специальные символы'; -$lang['upperns'] = 'Перейти в родительское пространство имен'; +$lang['upperns'] = 'Перейти в родительское пространство имён'; $lang['admin_register'] = 'Добавить пользователя'; $lang['metaedit'] = 'Править метаданные'; $lang['metasaveerr'] = 'Ошибка записи метаданных'; @@ -233,7 +231,7 @@ $lang['subscr_unsubscribe_success'] = 'Удалён %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_not_subscribed'] = 'Вы не подписаны на текущую страницу или пространство имён.'; $lang['subscr_m_new_header'] = 'Добавить подписку'; $lang['subscr_m_current_header'] = 'Текущие подписки'; $lang['subscr_m_unsubscribe'] = 'Отменить подписку'; @@ -242,8 +240,8 @@ $lang['subscr_m_receive'] = 'Получить'; $lang['subscr_style_every'] = 'уведомлять о каждом изменении'; $lang['subscr_style_digest'] = 'сводка изменений по каждой странице'; $lang['subscr_style_list'] = 'перечислять изменившиеся страницы с прошлого уведомления'; -$lang['authmodfailed'] = 'Неправильная конфигурация аутентификации пользователя. Пожалуйста, сообщите об этом вашему администратору вики.'; -$lang['authtempfail'] = 'Аутентификация пользователей временно недоступна. Если проблема продолжается какое-то время, пожалуйста, сообщите об этом вашему администратору вики.'; +$lang['authmodfailed'] = 'Неправильная конфигурация аутентификации пользователя. Пожалуйста, сообщите об этом своему администратору вики.'; +$lang['authtempfail'] = 'Аутентификация пользователей временно недоступна. Если проблема продолжается какое-то время, пожалуйста, сообщите об этом своему администратору вики.'; $lang['i_chooselang'] = 'Выберите свой язык/Choose your language'; $lang['i_installer'] = 'Установка «ДокуВики»'; $lang['i_wikiname'] = 'Название вики'; @@ -258,18 +256,18 @@ $lang['i_phpver'] = 'Ваша версия PHP (%s) н $lang['i_permfail'] = '%s недоступна для записи «ДокуВики». Вам необходимо исправить системные права доступа для этой директории!'; $lang['i_confexists'] = '%s уже существует'; $lang['i_writeerr'] = 'Не удалось создать %s. Вам необходимо проверить системные права доступа к файлу/директориям и создать файл вручную. '; -$lang['i_badhash'] = 'dokuwiki.php не распознана или изменена (хэш=%s)'; +$lang['i_badhash'] = 'dokuwiki.php не распознан или изменён (хэш=%s)'; $lang['i_badval'] = '%s — недопустимое или пустое значение'; $lang['i_success'] = 'Конфигурация прошла успешно. Теперь вы можете удалить файл install.php. Переходите к - вашей новой «ДокуВики».'; -$lang['i_failure'] = 'При записи в файлы конфигурации были обнаружены ошибки. Возможно, вам придется исправить их вручную, прежде чем вы сможете использовать вашу новую «ДокуВики».'; + своей новой «ДокуВики».'; +$lang['i_failure'] = 'При записи в файлы конфигурации были обнаружены ошибки. Возможно, вам придётся исправить их вручную, прежде чем вы сможете использовать свою новую «ДокуВики».'; $lang['i_policy'] = 'Исходная политика прав доступа'; $lang['i_pol0'] = 'Открытая вики (чтение, запись, закачка файлов для всех)'; $lang['i_pol1'] = 'Общедоступная вики (чтение для всех, запись и загрузка файлов для зарегистрированных пользователей)'; $lang['i_pol2'] = 'Закрытая вики (чтение, запись и загрузка файлов только для зарегистрированных пользователей)'; $lang['i_retry'] = 'Повторить попытку'; -$lang['i_license'] = 'Пожалуйста, выберите тип лицензии для вашей вики:'; -$lang['mu_intro'] = 'Здесь вы можете загрузить несколько файлов сразу. Кликните на «обзор», чтобы добавить их в список. Нажмите «загрузить» когда будете готовы.'; +$lang['i_license'] = 'Пожалуйста, выберите тип лицензии для своей вики:'; +$lang['mu_intro'] = 'Здесь вы можете загрузить несколько файлов сразу. Кликните на «обзор», чтобы добавить их в список. Нажмите «загрузить», когда будете готовы.'; $lang['mu_gridname'] = 'Имя файла'; $lang['mu_gridsize'] = 'Размер'; $lang['mu_gridstat'] = 'Статус'; @@ -284,7 +282,7 @@ $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 недель назад'; diff --git a/inc/lang/ru/norev.txt b/inc/lang/ru/norev.txt index db36a0ddd..388d6149d 100644 --- a/inc/lang/ru/norev.txt +++ b/inc/lang/ru/norev.txt @@ -1,4 +1,4 @@ ====== Такой версии не существует ====== -Указанная версия страницы не существует. Нажмите на кнопку ''История страницы'', чтобы получить список доступных предыдущих версий этого документа. +Указанная версия страницы не существует. Нажмите на кнопку «История страницы», чтобы получить список доступных предыдущих версий этого документа. diff --git a/inc/lang/ru/password.txt b/inc/lang/ru/password.txt index af6a7d14d..91117ca56 100644 --- a/inc/lang/ru/password.txt +++ b/inc/lang/ru/password.txt @@ -1,9 +1,10 @@ -Здравствуйте, @FULLNAME@! +Здравствуйте, @FULLNAME@. Ваши данные для @TITLE@ (@DOKUWIKIURL@) -Имя пользователя : @LOGIN@ -Пароль : @PASSWORD@ +Имя пользователя: @LOGIN@ + +Пароль: @PASSWORD@ -- Это письмо было сгенерировано «ДокуВики» по адресу diff --git a/inc/lang/ru/preview.txt b/inc/lang/ru/preview.txt index 2bc383eb2..401827607 100644 --- a/inc/lang/ru/preview.txt +++ b/inc/lang/ru/preview.txt @@ -1,4 +1,4 @@ ====== Просмотр ====== -Здесь показано, как ваш текст будет выглядеть. Внимание: текст ещё **не сохранён!** +Здесь показано, как ваш текст будет выглядеть. Внимание: текст ещё **не сохранён.** diff --git a/inc/lang/ru/pwconfirm.txt b/inc/lang/ru/pwconfirm.txt index 3e2331269..9c27af752 100644 --- a/inc/lang/ru/pwconfirm.txt +++ b/inc/lang/ru/pwconfirm.txt @@ -1,4 +1,4 @@ -Здравствуйте, @FULLNAME@! +Здравствуйте, @FULLNAME@. Кто-то запросил новый пароль для входа в @TITLE@ по адресу @DOKUWIKIURL@ diff --git a/inc/lang/ru/revisions.txt b/inc/lang/ru/revisions.txt index 06022323f..55072cd8a 100644 --- a/inc/lang/ru/revisions.txt +++ b/inc/lang/ru/revisions.txt @@ -1,3 +1,3 @@ ====== История страницы ====== -Перед вами — история правок текущего документа. Чтобы вернуться к одной из предыдущих версий, выберите нужную, нажмите ''Править страницу'' и сохраните. +Перед вами — история правок текущего документа. Чтобы вернуться к одной из предыдущих версий, выберите нужную, нажмите «Править страницу» и сохраните. diff --git a/inc/lang/ru/searchpage.txt b/inc/lang/ru/searchpage.txt index 608220495..04feb21cd 100644 --- a/inc/lang/ru/searchpage.txt +++ b/inc/lang/ru/searchpage.txt @@ -1,5 +1,5 @@ ====== Поиск ====== -Перед вами результаты поиска. Если вы не нашли то, что искали, вы можете создать новую страницу с именем, совпадающим с запросом. Чтобы сделать это, просто нажмите на кнопку ''Создать страницу''. +Перед вами результаты поиска. Если вы не нашли то, что искали, вы можете создать новую страницу с именем, совпадающим с запросом. Чтобы сделать это, просто нажмите на кнопку «Создать страницу». ===== Результаты ===== \ No newline at end of file diff --git a/inc/lang/ru/showrev.txt b/inc/lang/ru/showrev.txt index b3f3852eb..596815870 100644 --- a/inc/lang/ru/showrev.txt +++ b/inc/lang/ru/showrev.txt @@ -1,2 +1,2 @@ -**Это старая версия документа!** +**Это старая версия документа.** ---- diff --git a/inc/lang/ru/subscr_digest.txt b/inc/lang/ru/subscr_digest.txt index 3d1d35d30..41774a4e9 100644 --- a/inc/lang/ru/subscr_digest.txt +++ b/inc/lang/ru/subscr_digest.txt @@ -1,4 +1,4 @@ -Привет! +Привет. Страница @PAGE@ в вики @TITLE@ изменилась. Список изменений: diff --git a/inc/lang/ru/subscr_list.txt b/inc/lang/ru/subscr_list.txt index 9d0eb10e0..df5c2aa54 100644 --- a/inc/lang/ru/subscr_list.txt +++ b/inc/lang/ru/subscr_list.txt @@ -1,6 +1,7 @@ -Привет! -Страницы в пространстве имен @PAGE@ в вики @TITLE@ были изменены. +Привет. + +Страницы в пространстве имён @PAGE@ в вики @TITLE@ были изменены. Список изменившихся страниц: -------------------------------------------------------- @@ -10,7 +11,7 @@ Чтобы отписаться от уведомлений об изменениях, войдите в вики @DOKUWIKIURL@ в раздел @SUBSCRIBE@ -и отмените подписку на страницу и/или пространство имен. +и отмените подписку на страницу и/или пространство имён. -- Это письмо создано «ДокуВики» с сайта diff --git a/inc/lang/ru/subscr_single.txt b/inc/lang/ru/subscr_single.txt index ed8ead4cd..0e67d8f59 100644 --- a/inc/lang/ru/subscr_single.txt +++ b/inc/lang/ru/subscr_single.txt @@ -1,4 +1,5 @@ -Привет! +Привет. + Страница @PAGE@ в вики @TITLE@ изменилась. Список изменений: @@ -7,8 +8,9 @@ @DIFF@ -------------------------------------------------------- -Дата : @DATE@ -Автор : @USER@ +Дата: @DATE@ +Автор: @USER@ + Примечание: @SUMMARY@ Старая версия: @OLDPAGE@ Новая версия: @NEWPAGE@ @@ -16,7 +18,7 @@ Чтобы отписаться от уведомлений об изменениях, войдите в вики @DOKUWIKIURL@ в раздел @SUBSCRIBE@ -и отмените подписку на страницу и/или пространство имен. +и отмените подписку на страницу и/или пространство имён. -- Это письмо создано «ДокуВики» с сайта -- cgit v1.2.3 From 26fe3366027908989841108483f7cc6d2b52f824 Mon Sep 17 00:00:00 2001 From: lupo49 Date: Tue, 4 Jan 2011 20:58:35 +0100 Subject: de / de-informal: update for mail subscriptions --- inc/lang/de-informal/lang.php | 2 +- inc/lang/de-informal/subscr_digest.txt | 6 +++--- inc/lang/de-informal/subscr_single.txt | 12 ++++++------ inc/lang/de/lang.php | 2 +- inc/lang/de/subscr_digest.txt | 4 ++-- inc/lang/de/subscr_single.txt | 12 ++++++------ 6 files changed, 19 insertions(+), 19 deletions(-) (limited to 'inc') diff --git a/inc/lang/de-informal/lang.php b/inc/lang/de-informal/lang.php index 948a1ee51..c79f26227 100644 --- a/inc/lang/de-informal/lang.php +++ b/inc/lang/de-informal/lang.php @@ -49,7 +49,7 @@ $lang['btn_delete'] = 'Löschen'; $lang['btn_back'] = 'Zurück'; $lang['btn_backlink'] = 'Links hierher'; $lang['btn_backtomedia'] = 'Zurück zur Dateiauswahl'; -$lang['btn_subscribe'] = 'Änderungen abonnieren'; +$lang['btn_subscribe'] = 'Aboverwaltung'; $lang['btn_profile'] = 'Benutzerprofil'; $lang['btn_reset'] = 'Zurücksetzen'; $lang['btn_resendpwd'] = 'Sende neues Passwort'; diff --git a/inc/lang/de-informal/subscr_digest.txt b/inc/lang/de-informal/subscr_digest.txt index 9e943626c..f8cab210f 100644 --- a/inc/lang/de-informal/subscr_digest.txt +++ b/inc/lang/de-informal/subscr_digest.txt @@ -1,7 +1,7 @@ Hallo! Die Seite @PAGE@ im @TITLE@ Wiki wurde bearbeitet. -Das sind die nderungen: +Üersicht der Änderungen: -------------------------------------------------------- @DIFF@ @@ -10,10 +10,10 @@ Das sind die Alte Revision: @OLDPAGE@ Neue Revision: @NEWPAGE@ -Um das Abonnement fr diese Seite aufzulsen, melde dich im Wiki an +Um das Abonnement für diese Seite aufzulösen, melde dich im Wiki an @DOKUWIKIURL@, besuchen dann @SUBSCRIBE@ -und klicke auf den Link 'nderungen abbestellen'. +und klicke auf den Link 'Aboverwaltung'. -- Diese Mail kommt vom DokuWiki auf diff --git a/inc/lang/de-informal/subscr_single.txt b/inc/lang/de-informal/subscr_single.txt index 3a295be76..3c557bc17 100644 --- a/inc/lang/de-informal/subscr_single.txt +++ b/inc/lang/de-informal/subscr_single.txt @@ -1,22 +1,22 @@ Hallo! Die Seite @PAGE@ im @TITLE@ Wiki wurde bearbeitet. -Das sind die Änderungen: +Übersicht der Änderungen: -------------------------------------------------------- @DIFF@ -------------------------------------------------------- -Datum : @DATE@ -Benutzer : @USER@ -Übersicht: @SUMMARY@ +Datum: @DATE@ +Benutzer: @USER@ +Zusammenfassung: @SUMMARY@ Alte Revision: @OLDPAGE@ Neue Revision: @NEWPAGE@ Um das Abonnement für diese Seite aufzulösen, melde dich im Wiki an -@DOKUWIKIURL@, besuchen dann +@DOKUWIKIURL@, besuche dann @NEWPAGE@ -und klicke auf den Link 'Änderungen abbestellen'. +und klicke auf den Link 'Aboverwaltung'. -- Diese Mail kommt vom DokuWiki auf diff --git a/inc/lang/de/lang.php b/inc/lang/de/lang.php index ecc190c36..fef9d556c 100644 --- a/inc/lang/de/lang.php +++ b/inc/lang/de/lang.php @@ -49,7 +49,7 @@ $lang['btn_delete'] = 'Löschen'; $lang['btn_back'] = 'Zurück'; $lang['btn_backlink'] = 'Links hierher'; $lang['btn_backtomedia'] = 'Zurück zur Dateiauswahl'; -$lang['btn_subscribe'] = 'Änderungen abonnieren'; +$lang['btn_subscribe'] = 'Aboverwaltung'; $lang['btn_profile'] = 'Benutzerprofil'; $lang['btn_reset'] = 'Zurücksetzen'; $lang['btn_resendpwd'] = 'Sende neues Passwort'; diff --git a/inc/lang/de/subscr_digest.txt b/inc/lang/de/subscr_digest.txt index c8bf770ee..7cc79bba2 100644 --- a/inc/lang/de/subscr_digest.txt +++ b/inc/lang/de/subscr_digest.txt @@ -1,7 +1,7 @@ Hallo! Die Seite @PAGE@ im @TITLE@ Wiki wurde bearbeitet. -Das sind die Änderungen: +Übersicht der Änderungen: -------------------------------------------------------- @DIFF@ @@ -13,7 +13,7 @@ Neue Revision: @NEWPAGE@ Um das Abonnement für diese Seite aufzulösen, melden Sie sich im Wiki an @DOKUWIKIURL@, besuchen dann @SUBSCRIBE@ -und klicken auf den Link 'Änderungen abbestellen'. +und klicken auf den Link 'Aboverwaltung'. -- Diese Mail kommt vom DokuWiki auf diff --git a/inc/lang/de/subscr_single.txt b/inc/lang/de/subscr_single.txt index fb149e927..f3e1cd393 100644 --- a/inc/lang/de/subscr_single.txt +++ b/inc/lang/de/subscr_single.txt @@ -1,22 +1,22 @@ Hallo! Die Seite @PAGE@ im @TITLE@ Wiki wurde bearbeitet. -Das sind die Änderungen: +Übersicht der Änderungen: -------------------------------------------------------- @DIFF@ -------------------------------------------------------- -Datum : @DATE@ -Benutzer : @USER@ -Übersicht: @SUMMARY@ +Datum: @DATE@ +Benutzer: @USER@ +Zusammenfassung: @SUMMARY@ Alte Revision: @OLDPAGE@ Neue Revision: @NEWPAGE@ -Um das Abonnement für diese Seite aufzulösen, melde Sie sich im Wiki an +Um das Abonnement für diese Seite aufzulösen, melden Sie sich im Wiki an @DOKUWIKIURL@, besuchen dann @NEWPAGE@ -und klicken auf die Taste 'Änderungen abbestellen'. +und klicken auf die Taste 'Aboverwaltung'. -- Diese Mail kommt vom DokuWiki auf -- cgit v1.2.3 From 178c8be8577764b678fc145787fb5a5fe5bd5bf7 Mon Sep 17 00:00:00 2001 From: Massimiliano Vassalli Date: Sun, 9 Jan 2011 11:01:51 +0100 Subject: Latin language update - better use of Latin terminology for DokuWiki - ACL is not translated as AAA (Aditus Administrationis Aditus) but with ICA (Index Custodiae Aditus), which is a more literal translation - minor corrections of grammar and logic - The word "namespace" is more literally translated "spatium nominis", but according to other translations (like the Italian one), I preferred to use "genus". --- inc/lang/la/conflict.txt | 6 ++--- inc/lang/la/editrev.txt | 2 +- inc/lang/la/index.txt | 2 +- inc/lang/la/install.html | 8 +++++++ inc/lang/la/lang.php | 51 ++++++++++++++++++++++--------------------- inc/lang/la/norev.txt | 4 ++-- inc/lang/la/showrev.txt | 2 +- inc/lang/la/subscr_digest.txt | 2 +- inc/lang/la/subscr_form.txt | 2 +- inc/lang/la/subscr_list.txt | 2 +- inc/lang/la/subscr_single.txt | 2 +- 11 files changed, 46 insertions(+), 37 deletions(-) create mode 100644 inc/lang/la/install.html (limited to 'inc') diff --git a/inc/lang/la/conflict.txt b/inc/lang/la/conflict.txt index 3d1f66ab6..aebc38b25 100644 --- a/inc/lang/la/conflict.txt +++ b/inc/lang/la/conflict.txt @@ -1,5 +1,5 @@ -====== Recentior uersio est ====== +====== Recentior forma est ====== -Recentior uersio est: nam dum hanc paginam recensibas, aliquis paginam mutauit. +Recentior forma est: nam dum hanc paginam recensibas, aliquis paginam mutauit. -Discrimina uides et uersionem seruandam eligis. Alia uersio delebitur. \ No newline at end of file +Discrimina uides et formam seruandam eligis. Alia forma delebitur. \ No newline at end of file diff --git a/inc/lang/la/editrev.txt b/inc/lang/la/editrev.txt index bac047d31..6a4d082cc 100644 --- a/inc/lang/la/editrev.txt +++ b/inc/lang/la/editrev.txt @@ -1,2 +1,2 @@ -**Vetus uersio a te restituta est** Si hanc uersionem seruabis, nouam creabis. +**Vetus forma a te restituta est** Si hanc formam seruabis, nouam creabis. ---- \ No newline at end of file diff --git a/inc/lang/la/index.txt b/inc/lang/la/index.txt index eb6f06f79..cd65dbb59 100644 --- a/inc/lang/la/index.txt +++ b/inc/lang/la/index.txt @@ -1,3 +1,3 @@ ====== Forma Situs ====== -Haec forma situs ordinata a(b) [[doku>namespaces|namespaces]]. \ No newline at end of file +Haec forma situs ordinata [[doku>namespaces|generatim]]. \ No newline at end of file diff --git a/inc/lang/la/install.html b/inc/lang/la/install.html new file mode 100644 index 000000000..c06f3ac2c --- /dev/null +++ b/inc/lang/la/install.html @@ -0,0 +1,8 @@ +

Haec pagina te adiuuat in Dokuuiki conformando. Maiores res in +hac pagina sunt.

+ +

DokuWiki documenta ut omnes paginas uicis et omnia (ut imagines, indices, ueteres formas) quae ad easdem pertinent colligat. Vt bene operet DokuWiki omnes facultates scrini habere debes. Hoc instrumentum facultates eligere non potest, his facultatibus locatori spati interretis quaeras uel FTP intrumento uel aliis rebus (ut cPanel) uteraris.

+ +

Hoc intrumentum optiones primae DokuWiki ICA, quos rectori situs inire et indicem, ut addenda optiones uicis et alia administrare possit uidere licet. Hoc instrumentum non necessarium DokuWiki ut feliciter operet, sed melius administrare adiuuat.

+ +

Periti uel qui certa quaesita habet paginas rationis conformandum uicem et optionum conformationis uidere possunt.

\ No newline at end of file diff --git a/inc/lang/la/lang.php b/inc/lang/la/lang.php index 49ae67c31..ec80ac4d1 100644 --- a/inc/lang/la/lang.php +++ b/inc/lang/la/lang.php @@ -8,6 +8,7 @@ * lines starting with @author * * @url http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/languages/messages/MessagesLa.php?view=co + * @author Massimiliano Vassalli */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'ltr'; @@ -19,9 +20,9 @@ $lang['apostrophe'] = '´'; $lang['btn_edit'] = 'Recensere hanc paginam'; $lang['btn_source'] = 'Fontem uidere'; $lang['btn_show'] = 'Ostendere paginam'; -$lang['btn_create'] = 'Facere paginam'; +$lang['btn_create'] = 'Creare paginam'; $lang['btn_search'] = 'Quaerere'; -$lang['btn_save'] = 'Seruare paginam'; +$lang['btn_save'] = 'Seruare'; $lang['btn_preview'] = 'Praeuidere'; $lang['btn_top'] = 'I ad summa'; $lang['btn_newer'] = '<< recentiores'; @@ -39,7 +40,7 @@ $lang['btn_update'] = 'Nouare'; $lang['btn_delete'] = 'Delere'; $lang['btn_back'] = 'Redire'; $lang['btn_backlink'] = 'Nexus ad paginam'; -$lang['btn_backtomedia'] = 'Ad medias redire'; +$lang['btn_backtomedia'] = 'Ad media redire'; $lang['btn_subscribe'] = 'Custodire'; $lang['btn_profile'] = 'Tabellam nouare'; $lang['btn_reset'] = 'Abrogare'; @@ -55,14 +56,14 @@ $lang['newpass'] = 'Tessera noua'; $lang['oldpass'] = 'Tessera uetus:'; $lang['passchk'] = 'Tesseram tuam adfirmare'; $lang['remember'] = 'Tesseram meam sodalitatis memento'; -$lang['fullname'] = 'Nomen tuum uerum:'; +$lang['fullname'] = 'Nomen tuom uerum:'; $lang['email'] = 'Cursus interretialis:'; $lang['register'] = 'Te adscribere'; $lang['profile'] = 'Tabella Sodalis'; -$lang['badlogin'] = 'Error in ineundo est.'; -$lang['minoredit'] = 'Haec est recensio minor'; +$lang['badlogin'] = 'Error in ineundo est, rectum nomen uel tessera cedo.'; +$lang['minoredit'] = 'Recensio minor'; $lang['draftdate'] = 'Propositum seruatur die:'; -$lang['nosecedit'] = 'Pagina interea mutatur, pars rerum exiit.'; +$lang['nosecedit'] = 'Pagina interea mutatur, pars rerum exiit, in loco eius tota pagina reclamata est.'; $lang['regmissing'] = 'Omnes campi complendi sunt.'; $lang['reguexists'] = 'Nomen Sodalis ab aliquo iam elegitur.'; $lang['regsuccess'] = 'Adscriptio feliciter perficitur et tessera cursu interretiali mittitur'; @@ -92,17 +93,17 @@ $lang['txt_upload'] = 'Eligere documenta oneranda:'; $lang['txt_filename'] = 'Onerare (optio):'; $lang['txt_overwrt'] = 'Documento ueteri imponere:'; $lang['lockedby'] = 'Nunc hoc intercludit'; -$lang['lockexpire'] = 'Hoc aperiuit'; +$lang['lockexpire'] = 'Hoc apertum'; $lang['willexpire'] = 'Interclusio paginae recensendae uno minuto finita est.\nUt errores uites, \'praeuisio\' preme ut interclusionem ripristines.'; $lang['js']['notsavedyet'] = 'Res non seruatae amissurae sunt.'; $lang['js']['searchmedia'] = 'Quaere inter documenta'; $lang['js']['keepopen'] = 'Fenestram apertam tene'; $lang['js']['hidedetails'] = 'Singulas res abscondere'; -$lang['js']['mediatitle'] = 'Optiones connectendi'; -$lang['js']['mediadisplay'] = 'Exemplar connectendi'; +$lang['js']['mediatitle'] = 'Optiones nexorum'; +$lang['js']['mediadisplay'] = 'Genus nexi'; $lang['js']['mediaalign'] = 'Collocatio'; $lang['js']['mediasize'] = 'Amplitudo imaginis'; -$lang['js']['mediatarget'] = 'Signum connectere'; +$lang['js']['mediatarget'] = 'Cui nexum est'; $lang['js']['mediaclose'] = 'Claudere'; $lang['js']['mediainsert'] = 'Insere'; $lang['js']['mediadisplayimg'] = 'Imaginem ostendere'; @@ -122,7 +123,7 @@ $lang['js']['medianoalign'] = 'Collocationem remouere'; $lang['js']['nosmblinks'] = 'Windows nexa solum cum Microsoft Internet Explorer ostendi possunt. Adhuc transcribere nexum potes.'; $lang['js']['linkwiz'] = 'Connectendi ductor'; -$lang['js']['linkto'] = 'Nexum:'; +$lang['js']['linkto'] = 'Nexum ad:'; $lang['js']['del_confirm'] = 'Delere electas res uin?'; $lang['js']['mu_btn'] = 'Plura documenta uno tempore onerare'; $lang['rssfailed'] = 'Error in restituendo '; @@ -140,13 +141,13 @@ $lang['uploadsize'] = 'Documentum onerandum ponderosius est. (Maxime $lang['deletesucc'] = 'Documentum "%s" deletum est.'; $lang['deletefail'] = '"%s" non deletur: uide facultates.'; $lang['mediainuse'] = 'documentum "%s" non deletur, nam aliquis hoc utitur.'; -$lang['namespaces'] = 'Spatium nominis'; +$lang['namespaces'] = 'Genus'; $lang['mediafiles'] = 'Documentum liberum in:'; $lang['accessdenied'] = 'Non uidere documentum potes.'; $lang['mediausage'] = 'Hac forma uteris ut documentum referas:'; $lang['mediaview'] = 'Vide documentum primigenium'; $lang['mediaroot'] = 'scrinium'; -$lang['mediaupload'] = 'Spatium nominis hic oneras. Si nouom spatium nominis creare uis, ante "Onerare ut" nomen documenti diuisum a duabus punctis ponas.'; +$lang['mediaupload'] = 'Hic genus oneras. Si nouom genus creare uis, ante "Onerare ut" nomen documenti diuisum a duabus punctis ponas.'; $lang['mediaextchange'] = 'Genus documenti mutatum a(b) ".%s" ad ".%s"!'; $lang['reference'] = 'Referre:'; $lang['ref_inuse'] = 'Documentum non deleri potest, nam in his paginis apertum est:'; @@ -170,10 +171,10 @@ $lang['restored'] = 'Recensio uetus restituta'; $lang['external_edit'] = 'Externe recensere'; $lang['summary'] = 'Indicem recensere'; $lang['noflash'] = 'Adobe Flash Plugin necessarium est.'; -$lang['download'] = 'Snippet cape'; +$lang['download'] = 'Snippet capere'; $lang['mail_newpage'] = 'Pagina addita:'; $lang['mail_changed'] = 'Pagina mutata:'; -$lang['mail_subscribe_list'] = 'Pagina in spatio nominis mutata:'; +$lang['mail_subscribe_list'] = 'Paginae in genere mutatae:'; $lang['mail_new_user'] = 'Nouos Sodalis:'; $lang['mail_upload'] = 'Documentum oneratum:'; $lang['qb_bold'] = 'Litterae pingues'; @@ -198,9 +199,9 @@ $lang['qb_ol'] = 'Index ordinatus rerum'; $lang['qb_ul'] = 'Index non ordinatus rerum'; $lang['qb_media'] = 'Imagines et documenta addere'; $lang['qb_sig'] = 'Subscriptio tua cum indicatione temporis'; -$lang['qb_smileys'] = 'Facies'; +$lang['qb_smileys'] = 'Pupuli'; $lang['qb_chars'] = 'Signa singularia'; -$lang['upperns'] = 'I ad anterius spatium nominis'; +$lang['upperns'] = 'I ad anterius genus'; $lang['admin_register'] = 'Nouom Sodalem creare'; $lang['metaedit'] = 'Res codicis mutare'; $lang['metasaveerr'] = 'Res codicis non scribitur.'; @@ -223,7 +224,7 @@ $lang['subscr_unsubscribe_success'] = 'A subscriptione %s deletur quod %s'; $lang['subscr_unsubscribe_error'] = 'Error delendi %s a subscriptione quod %s'; $lang['subscr_already_subscribed'] = '%s iam subscriptus\a est in %s'; $lang['subscr_not_subscribed'] = '%s non subscriptus\a est in %n'; -$lang['subscr_m_not_subscribed'] = 'Non hanc paginam uel spatium nominis subscribere potes.'; +$lang['subscr_m_not_subscribed'] = 'Non hanc paginam uel genus subscribere potes.'; $lang['subscr_m_new_header'] = 'Subscriptionem addere'; $lang['subscr_m_current_header'] = 'haec subscriptio:'; $lang['subscr_m_unsubscribe'] = 'Delere'; @@ -237,12 +238,12 @@ $lang['authtempfail'] = 'Confirmare non potes. Rectorem conuenis.'; $lang['i_chooselang'] = 'Linguam eligere'; $lang['i_installer'] = 'Docuuicis creator'; $lang['i_wikiname'] = 'Nomen Vicis'; -$lang['i_enableacl'] = 'AAA aptum facias (consulatum est)'; +$lang['i_enableacl'] = 'ICA aptum facias (consulatum est)'; $lang['i_superuser'] = 'Magister\stra'; $lang['i_problems'] = 'Creator hos errores habes. Continuare potes postquam omnia soluentur.'; -$lang['i_modified'] = 'Hoc scriptum solum cum noua uersione Dokuuicis est. Hoc rursum capere in pagina, in qua haec machina capta est, potes aut i ad Dokuuicis installation instructions'; +$lang['i_modified'] = 'Hoc scriptum solum cum noua forma Dokuuicis est. Hoc rursum capere in pagina, in qua haec machina capta est, potes aut i ad Dokuuicis installation instructions'; $lang['i_funcna'] = 'PHP functio %s inepta est.'; -$lang['i_phpver'] = 'Versio tua PHP %s minor quam illa necessaria %s.'; +$lang['i_phpver'] = 'Forma tua PHP %s minor quam illa necessaria %s.'; $lang['i_permfail'] = '%s non a uice scribitur. Facultates inspicere.'; $lang['i_confexists'] = '%s iam est.'; $lang['i_writeerr'] = '%s non creari potest. Manu illum creas.'; @@ -250,7 +251,7 @@ $lang['i_badhash'] = 'Ignotum uel mutatum dokuwiki.php (%s Date: Sun, 9 Jan 2011 11:31:39 +0100 Subject: German language update --- inc/lang/de/lang.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc') diff --git a/inc/lang/de/lang.php b/inc/lang/de/lang.php index fef9d556c..c220b706d 100644 --- a/inc/lang/de/lang.php +++ b/inc/lang/de/lang.php @@ -17,6 +17,7 @@ * @author Blitzi94@gmx.de * @author Robert Bogenschneider * @author Robert Bogenschneider + * @author Niels Lange */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'ltr'; -- cgit v1.2.3 From d6a4a040ca66d247bb4c3fc3e67c4ee683c920b2 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 10 Jan 2011 19:22:37 +0100 Subject: Use md5 of the id in the subscription lockdir. FS#2112 Filenames can't contain ":" on windows and the lock directory contained the unescaped page id. The lock function tries in an endless loop to create the lock directory when it fails and the directory doesn't exist. Just escaping the directory name won't work as then the filename length limit will be quickly hit when using deep namespace structures with utf8 names. Thus using the md5sum seems to be the best solution. Perhaps the lock function could also be changed to create a file with that name that contains the id so the id can be retrieved for debugging purposes. --- inc/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/subscription.php b/inc/subscription.php index 08d4cb241..1b5476553 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -46,7 +46,7 @@ function subscription_filename($id) { */ function subscription_lock_filename ($id){ global $conf; - return $conf['lockdir'].'/_subscr_' . $id . '.lock'; + return $conf['lockdir'].'/_subscr_' . md5($id) . '.lock'; } function subscription_lock($id) { -- cgit v1.2.3 From 4a81940267e4278153d3726b605286fd963084ec Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 10 Jan 2011 20:39:44 +0100 Subject: Activate the render parameter of p_get_metadata p_get_metadata has a $render parameter that has been disabled by the restructuring of metadata rendering. This change reactivates it so rendering metadata can be prevented. This is e.g. used in the search and in some plugins like indexmenu that use p_get_first_heading. The default of the parameter has been changed to true as otherwise the new caching structure won't work as almost all calls to p_get_metadata don't set the $render parameter. The indexer call to p_get_first_heading has been changed to set $render to true as in the indexer only one page will be rendered and the title in the index should really be the current one. This does not fix the problem that rendering pages with lots of links or displaying the index can cause the parsing/rendering of a lot of pages. --- inc/indexer.php | 2 +- inc/parserutils.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'inc') diff --git a/inc/indexer.php b/inc/indexer.php index 5a361ddc5..943c2a8c4 100644 --- a/inc/indexer.php +++ b/inc/indexer.php @@ -305,7 +305,7 @@ function idx_addPage($page){ } unset($page_idx); // free memory - idx_saveIndexLine('title', '', $pid, p_get_first_heading($page, false)); + idx_saveIndexLine('title', '', $pid, p_get_first_heading($page, true)); $pagewords = array(); // get word usage in page diff --git a/inc/parserutils.php b/inc/parserutils.php index fbdc2e3a9..9224dae10 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -220,10 +220,15 @@ function p_get_instructions($text){ /** * returns the metadata of a page * + * @param string $id The id of the page the metadata should be returned from + * @param string $key The key of the metdata value that shall be read (by default everything) - separate hierarchies by " " like "date created" + * @param boolean $render If the page should be rendererd when the cache can't be used - default true + * @return mixed The requested metadata fields + * * @author Esther Brunner * @author Michael Hamann */ -function p_get_metadata($id, $key='', $render=false){ +function p_get_metadata($id, $key='', $render=true){ global $ID; // cache the current page @@ -234,7 +239,7 @@ function p_get_metadata($id, $key='', $render=false){ // prevent recursive calls in the cache static $recursion = false; - if (!$recursion){ + if (!$recursion && $render){ $recursion = true; $cachefile = new cache_renderer($id, wikiFN($id), 'metadata'); -- cgit v1.2.3 From bf0c93c21103a02f9efe4c427b9fefd6c5732666 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 10 Jan 2011 21:19:11 +0100 Subject: Use title index for more than 11 p_first_heading calls This change makes p_get_first_heading load the title index when more than 11 requests that caused a call to p_get_metadata have already been done. This means that small pages and the breadcrums won't trigger the loading of the title index but for larger pages or the sitemap the title index will be used. This is necessary because every call to p_get_metadata can trigger the parsing and rendering of a whole page and there can be many calls when useheading is activated and e.g. the index/sitemap page is displayed. Additionally this adds a small title cache that caches titles requested from p_get_metadata. Further tests should be done how this affects memory usage and how often the index loading is triggered in order to see if that parameter should be adjusted. --- inc/parserutils.php | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/parserutils.php b/inc/parserutils.php index 9224dae10..b7359d7ef 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -625,9 +625,41 @@ function & p_get_renderer($mode) { * headings ... and so on. * * @author Andreas Gohr + * @author Michael Hamann */ function p_get_first_heading($id, $render=true){ - return p_get_metadata($id,'title',$render); + // counter how many titles have been requested using p_get_metadata + static $count = 0; + // the index of all titles, only loaded when many titles are requested + static $title_index = null; + // cache for titles requested using p_get_metadata + static $title_cache = array(); + + $id = cleanID($id); + + // check if this title has already been requested + if (isset($title_cache[$id])) + return $title_cache[$id]; + + // check if already too many titles have been requested and probably + // using the title index is better + if ($count > 10) { + if (is_null($title_index)) { + $pages = array_map('rtrim', idx_getIndex('page', '')); + $titles = array_map('rtrim', idx_getIndex('title', '')); + // check for corrupt title index #FS2076 + if(count($pages) != count($titles)){ + $titles = array_fill(0,count($pages),''); + @unlink($conf['indexdir'].'/title.idx'); // will be rebuilt in inc/init.php + } + $title_index = array_combine($pages, $titles); + } + return $title_index[$id]; + } + + ++$count; + $title_cache[$id] = p_get_metadata($id,'title',$render); + return $title_cache[$id]; } /** -- cgit v1.2.3 From cc58224cff540373081dcde9c64d00efbf0fbddc Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 10 Jan 2011 21:54:58 +0100 Subject: Fix msg() calls when messages have already been printed This commit fixes two bugs that occurred when msg() was called after html_msgarea() had already been called. - the $MSG array is now cleared when it has been printed (otherwise $MSG has been printed again when another msg() call was done) - headers_sent() didn't work for me, it always reported false although html_msgarea() had already been called which might be explainable with output buffering. This makes msg() now depend on the first call of html_msgarea() or headers_sent() in order to not to break msg() in ajax requests etc. --- inc/html.php | 7 ++++++- inc/infoutils.php | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index 4e3744fd1..b6c5cc7ba 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1034,7 +1034,10 @@ function html_conflict($text,$summary){ * @author Andreas Gohr */ function html_msgarea(){ - global $MSG; + global $MSG, $MSG_shown; + // store if the global $MSG has already been shown and thus HTML output has been started + $MSG_shown = true; + if(!isset($MSG)) return; $shown = array(); @@ -1046,6 +1049,8 @@ function html_msgarea(){ print '
'; $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{ -- cgit v1.2.3 From 517a47eca3a26afd3aedfd47eb372596af4029ae Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 10 Jan 2011 22:47:54 +0100 Subject: 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(-) (limited to 'inc') 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(); -- cgit v1.2.3 From ff725173bf45c47b1ed9778524710cce72b1d42d Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 10 Jan 2011 23:41:43 +0100 Subject: 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(-) (limited to 'inc') 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', '')); -- cgit v1.2.3 From 9063ec149f164f26e583c635f4fa29dcba23eb90 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 12 Jan 2011 13:09:23 +0100 Subject: Remove trailing whitespace in buildAttributes output --- inc/common.php | 5 ++++- inc/form.php | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'inc') 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 .= '
'; -- cgit v1.2.3 From 283c7183458261e20d78d545539cdaa727ee1590 Mon Sep 17 00:00:00 2001 From: Usama Akkad Date: Wed, 12 Jan 2011 20:13:38 +0100 Subject: Arabic language update --- inc/lang/ar/lang.php | 129 ++++++++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 63 deletions(-) (limited to 'inc') 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'] = 'قائمة بالصفحات المتغيرة منذ آخر بريد'; -- cgit v1.2.3 From 01032c33d1c2c00e6c2f04f0bdd9b9ac0057ded6 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 9 Jan 2011 12:59:58 +0100 Subject: Fix FS#2131 - metaFiles returning unrelated files --- inc/pageutils.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'inc') 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(); } /** -- cgit v1.2.3 From ba0267b3bcb1b5feeb707e9a92766c4a619409bb Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Wed, 12 Jan 2011 20:46:36 +0100 Subject: 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(-) (limited to 'inc') 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(); } /** -- cgit v1.2.3 From 4481b2a04e9fbc3dd2696f436d5c2d2a725c8386 Mon Sep 17 00:00:00 2001 From: Tobias Sarnowski Date: Tue, 11 Jan 2011 13:12:26 +0100 Subject: 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(-) (limited to 'inc') 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 : -- cgit v1.2.3 From 1415e8b5968a264b9a2aa5bac0d77c2a898c8e81 Mon Sep 17 00:00:00 2001 From: Tobias Sarnowski Date: Tue, 11 Jan 2011 13:18:20 +0100 Subject: 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(-) (limited to 'inc') 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'; -- cgit v1.2.3 From a6bacf701037fe4798658f00854ec9c5e6ddf835 Mon Sep 17 00:00:00 2001 From: Tobias Sarnowski Date: Tue, 11 Jan 2011 15:07:46 +0100 Subject: 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(-) (limited to 'inc') 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; -- cgit v1.2.3 From b58bcfed1ea9c70e4103c91723a19c845b06f300 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 12 Jan 2011 20:55:16 +0100 Subject: 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(-) (limited to 'inc') 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. * -- cgit v1.2.3 From 299c3423aa580b305c33bbe62c29123815f5419a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 12 Jan 2011 20:56:13 +0100 Subject: fixed brackets --- inc/HTTPClient.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'inc') 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']) && -- cgit v1.2.3 From 99fef1646aeb4e3f5f819e991e4079bce08adc75 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Wed, 12 Jan 2011 23:15:52 +0100 Subject: 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 | 328 +++++++++++++++++++++++------------------- 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 +++ 17 files changed, 269 insertions(+), 191 deletions(-) create mode 100644 inc/lang/he/subscr_digest.txt create mode 100644 inc/lang/he/subscr_single.txt (limited to 'inc') 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['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']['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['uploadspam'] = 'ההעלאה נחסמה על ידי רשימת חסימת הספאם.'; $lang['uploadxss'] = 'ההעלאה נחסמה בשל חשד לתוכן זדוני.'; -$lang['uploadsize'] = 'הקובץ שהועלה היה גדול מדי. (מקסימום %s)'; -$lang['deletesucc'] = 'קובץ %s נמחק'; -$lang['deletefail'] = 'לא יכולתי למחוק "%s" -- בדקו הרשאות'; -$lang['mediainuse'] = 'קובץ "%s" לא נמחק - הוא עדיין בשימוש'; +$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['js']['linkwiz'] = 'אשף הקישורים'; -$lang['js']['linkto'] = 'קשר אל:'; -$lang['js']['del_confirm'] = 'באמת למחוק?'; -$lang['js']['mu_btn'] = 'העלאת קבצים מרובים'; -$lang['mediausage'] = 'השתמש בתחביר הבא להתיחסות אל קובץ זה:'; -$lang['mediaview'] = 'הצג את הקובץ המקורי'; +$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 -- cgit v1.2.3 From 11aec52adf81e5d1a752ce9c3d83692014bfc19f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Jan 2011 10:50:13 +0100 Subject: 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 | 118 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 92 insertions(+), 26 deletions(-) (limited to 'inc') 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 if (strstr($username, "@")) { + $filter="userPrincipalName=".$username; + } else { - $filter="samaccountname=".$username; + $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"]; } -- cgit v1.2.3 From 168cead4e4c7d7c79cc57fa557dd21428243b2f9 Mon Sep 17 00:00:00 2001 From: Christian Wichmann Date: Fri, 14 Jan 2011 11:22:52 +0100 Subject: German language update --- inc/lang/de/lang.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc') 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'; -- cgit v1.2.3 From ef7acde6835f3eda384a189e4d6f2f86a3ad9d3c Mon Sep 17 00:00:00 2001 From: Christian Wichmann Date: Fri, 14 Jan 2011 11:23:23 +0100 Subject: German (informal) language update --- inc/lang/de-informal/lang.php | 72 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'inc') 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'; -- cgit v1.2.3 From 99f04cb741f14f2ccea37163786f1ea4824c2eb0 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Jan 2011 10:39:42 +0100 Subject: 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(-) (limited to 'inc') 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; -- cgit v1.2.3 From f91977c212fd1c1645f521f6190e1ec32259f7a2 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Jan 2011 12:24:14 +0100 Subject: Added support for Wordpress' password hashing FS#2134 --- inc/auth.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'inc') 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); -- cgit v1.2.3 From b2665af72cdba76ca409b7e00e150746f2f83ced Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 27 Dec 2010 22:53:18 +0100 Subject: 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(+) (limited to 'inc') 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']) = -- cgit v1.2.3 From 278a5eb294b2df859c7eb20c6e35e32280a8b613 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 15 Jan 2011 12:18:09 +0100 Subject: 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(-) (limited to 'inc') 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) { -- cgit v1.2.3 From 204b27c8e0c1bcfa6810ee45bd12fda3f5d83960 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 16 Jan 2011 22:23:54 +0100 Subject: Fix getBaseURL for literal IPv6 addresses in URLs (RFC 2732) + test case --- inc/init.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'inc') 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') { -- cgit v1.2.3 From 820923f1328bcfe6002831570eb65238411c5b70 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 18 Jan 2011 00:04:41 +0100 Subject: 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(-) (limited to 'inc') 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'].')'; -- cgit v1.2.3