From 50b00028bd207f461d6ed02f7868eccb5c6b8fe1 Mon Sep 17 00:00:00 2001 From: donncha Date: Wed, 19 Mar 2008 12:35:25 +0000 Subject: Add and delete WP 2.5 files. *DON'T SVN UPDATE!* git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1214 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-admin/async-upload.php | 32 + wp-admin/css/colors-classic.css | 701 +++ wp-admin/css/colors-fresh.css | 681 +++ wp-admin/css/dashboard.css | 283 + wp-admin/css/global.css | 126 + wp-admin/css/ie.css | 58 + wp-admin/css/login.css | 74 + wp-admin/css/media.css | 238 + wp-admin/css/theme-editor.css | 44 + wp-admin/css/upload-rtl.css | 12 - wp-admin/css/upload.css | 204 - wp-admin/edit-attachment-rows.php | 138 + wp-admin/edit-tag-form.php | 41 + wp-admin/edit-tags.php | 202 + wp-admin/images/align-center.png | Bin 0 -> 571 bytes wp-admin/images/align-left.png | Bin 0 -> 587 bytes wp-admin/images/align-none.png | Bin 0 -> 453 bytes wp-admin/images/align-right.png | Bin 0 -> 556 bytes wp-admin/images/box-bg-left.gif | Bin 37 -> 0 bytes wp-admin/images/box-bg-right.gif | Bin 151 -> 0 bytes wp-admin/images/box-bg.gif | Bin 111 -> 0 bytes wp-admin/images/box-butt-left.gif | Bin 169 -> 0 bytes wp-admin/images/box-butt-right.gif | Bin 960 -> 0 bytes wp-admin/images/box-butt.gif | Bin 347 -> 0 bytes wp-admin/images/box-head-left.gif | Bin 334 -> 0 bytes wp-admin/images/box-head-right.gif | Bin 3609 -> 0 bytes wp-admin/images/box-head.gif | Bin 879 -> 0 bytes wp-admin/images/bubble_bg.gif | Bin 0 -> 206 bytes wp-admin/images/comment-grey-bubble.png | Bin 0 -> 158 bytes wp-admin/images/comment-pill.gif | Bin 0 -> 72 bytes wp-admin/images/comment-stalk-classic.gif | Bin 0 -> 1100 bytes wp-admin/images/comment-stalk-fresh.gif | Bin 0 -> 1067 bytes wp-admin/images/date-button.gif | Bin 0 -> 111 bytes wp-admin/images/heading-bg.gif | Bin 37 -> 0 bytes wp-admin/images/login-bkg-bottom.gif | Bin 704 -> 0 bytes wp-admin/images/login-bkg-tile.gif | Bin 19279 -> 0 bytes wp-admin/images/logo-login.gif | Bin 0 -> 3184 bytes wp-admin/images/media-button-gallery.gif | Bin 0 -> 72 bytes wp-admin/images/media-button-image.gif | Bin 0 -> 69 bytes wp-admin/images/media-button-music.gif | Bin 0 -> 188 bytes wp-admin/images/media-button-other.gif | Bin 0 -> 141 bytes wp-admin/images/media-button-video.gif | Bin 0 -> 68 bytes wp-admin/images/media-buttons.gif | Bin 0 -> 723 bytes wp-admin/images/notice.gif | Bin 156 -> 0 bytes wp-admin/images/tail.gif | Bin 0 -> 98 bytes wp-admin/images/toggle-arrow.gif | Bin 0 -> 71 bytes wp-admin/images/toggle.gif | Bin 216 -> 0 bytes wp-admin/images/xit.gif | Bin 0 -> 181 bytes wp-admin/includes/class-ftp-pure.php | 175 + wp-admin/includes/class-ftp-sockets.php | 236 + wp-admin/includes/class-ftp.php | 842 +++ wp-admin/includes/class-pclzip.php | 5748 ++++++++++++++++++++ wp-admin/includes/class-wp-filesystem-direct.php | 336 ++ wp-admin/includes/class-wp-filesystem-ftpext.php | 480 ++ .../includes/class-wp-filesystem-ftpsockets.php | 426 ++ wp-admin/includes/dashboard.php | 538 ++ wp-admin/includes/export.php | 255 + wp-admin/includes/media.php | 1225 +++++ wp-admin/includes/widgets.php | 269 + wp-admin/js/comment.js | 12 + wp-admin/js/common.js | 12 + wp-admin/js/dbx-admin-key.js | 47 - wp-admin/js/editor.js | 153 + wp-admin/js/forms.js | 31 + wp-admin/js/link-cat.js | 10 - wp-admin/js/link.js | 48 + wp-admin/js/media-upload.js | 12 + wp-admin/js/page.js | 16 + wp-admin/js/password-strength-meter.js | 162 + wp-admin/js/post.js | 157 + wp-admin/js/postbox.js | 14 + wp-admin/js/slug.js | 48 + wp-admin/js/tags.js | 21 + wp-admin/js/widgets.js | 136 + wp-admin/media-upload.php | 41 + wp-admin/media.php | 87 + wp-admin/update.php | 127 + wp-admin/wpmu-blogs.php.rej | 1224 +++++ wp-content/themes/default/attachment.php | 67 - wp-content/themes/default/image.php | 63 + wp-includes/class-phpass.php | 256 + wp-includes/images/audio.png | Bin 0 -> 574 bytes wp-includes/images/crystal/archive.png | Bin 0 -> 3066 bytes wp-includes/images/crystal/audio.png | Bin 0 -> 2647 bytes wp-includes/images/crystal/code.png | Bin 0 -> 2133 bytes wp-includes/images/crystal/default.png | Bin 0 -> 638 bytes wp-includes/images/crystal/document.png | Bin 0 -> 2305 bytes wp-includes/images/crystal/interactive.png | Bin 0 -> 2808 bytes wp-includes/images/crystal/license.txt | 9 + wp-includes/images/crystal/spreadsheet.png | Bin 0 -> 2725 bytes wp-includes/images/crystal/text.png | Bin 0 -> 999 bytes wp-includes/images/crystal/video.png | Bin 0 -> 2372 bytes wp-includes/images/css.png | Bin 0 -> 533 bytes wp-includes/images/default.png | Bin 0 -> 479 bytes wp-includes/images/doc.png | Bin 0 -> 1535 bytes wp-includes/images/exe.png | Bin 0 -> 194 bytes wp-includes/images/html.png | Bin 0 -> 537 bytes wp-includes/images/js.png | Bin 0 -> 517 bytes wp-includes/images/pdf.png | Bin 0 -> 1424 bytes wp-includes/images/swf.png | Bin 0 -> 1542 bytes wp-includes/images/tar.png | Bin 0 -> 1280 bytes wp-includes/images/text.png | Bin 0 -> 1559 bytes wp-includes/images/video.png | Bin 0 -> 596 bytes wp-includes/images/zip.png | Bin 0 -> 1270 bytes wp-includes/js/dbx.js | 6 - wp-includes/js/fat.js | 90 - wp-includes/js/jquery/jquery.color.js | 128 + wp-includes/js/jquery/jquery.dimensions.min.js | 12 + wp-includes/js/jquery/jquery.schedule.js | 36 + wp-includes/js/jquery/suggest.js | 310 ++ wp-includes/js/jquery/ui.tabs.js | 529 ++ wp-includes/js/list-manipulation.js | 295 - wp-includes/js/swfupload/handlers.js | 227 + .../js/swfupload/plugins/swfupload.cookies.js | 50 + .../swfupload/plugins/swfupload.documentready.js | 102 + .../plugins/swfupload.graceful_degradation.js | 63 + .../js/swfupload/plugins/swfupload.queue.js | 58 + wp-includes/js/swfupload/swfupload.js | 1051 ++++ wp-includes/js/swfupload/swfupload_f9.swf | Bin 0 -> 9109 bytes wp-includes/js/thickbox/loadingAnimation.gif | Bin 0 -> 5886 bytes wp-includes/js/thickbox/tb-close.png | Bin 0 -> 506 bytes wp-includes/js/thickbox/thickbox.css | 159 + wp-includes/js/thickbox/thickbox.js | 320 ++ wp-includes/js/tinymce/langs/en.js | 41 - wp-includes/js/tinymce/langs/wp-langs.php | 400 ++ .../tinymce/plugins/autosave/editor_plugin_src.js | 30 - .../js/tinymce/plugins/autosave/langs/en.js | 5 - .../tinymce/plugins/directionality/images/ltr.gif | Bin 155 -> 0 bytes .../tinymce/plugins/directionality/images/rtl.gif | Bin 153 -> 0 bytes .../js/tinymce/plugins/directionality/langs/en.js | 6 - .../js/tinymce/plugins/fullscreen/editor_plugin.js | 1 + .../js/tinymce/plugins/fullscreen/fullscreen.htm | 111 + .../plugins/inlinepopups/css/inlinepopup.css | 69 - .../tinymce/plugins/inlinepopups/images/spacer.gif | Bin 43 -> 0 bytes .../plugins/inlinepopups/images/window_close.gif | Bin 110 -> 0 bytes .../inlinepopups/images/window_maximize.gif | Bin 111 -> 0 bytes .../inlinepopups/images/window_minimize.gif | Bin 112 -> 0 bytes .../plugins/inlinepopups/images/window_resize.gif | Bin 74 -> 0 bytes .../plugins/inlinepopups/jscripts/mcwindows.js | 453 -- .../inlinepopups/skins/clearlooks2/img/alert.gif | Bin 0 -> 818 bytes .../inlinepopups/skins/clearlooks2/img/button.gif | Bin 0 -> 280 bytes .../inlinepopups/skins/clearlooks2/img/buttons.gif | Bin 0 -> 989 bytes .../inlinepopups/skins/clearlooks2/img/confirm.gif | Bin 0 -> 915 bytes .../inlinepopups/skins/clearlooks2/img/corners.gif | Bin 0 -> 911 bytes .../inlinepopups/skins/clearlooks2/img/drag.gif | Bin 0 -> 57 bytes .../skins/clearlooks2/img/horizontal.gif | Bin 0 -> 769 bytes .../skins/clearlooks2/img/vertical.gif | Bin 0 -> 92 bytes .../inlinepopups/skins/clearlooks2/window.css | 125 + .../js/tinymce/plugins/inlinepopups/template.htm | 387 ++ .../js/tinymce/plugins/media/css/content.css | 6 + wp-includes/js/tinymce/plugins/media/css/media.css | 68 + .../js/tinymce/plugins/media/editor_plugin.js | 1 + wp-includes/js/tinymce/plugins/media/img/flash.gif | Bin 0 -> 241 bytes .../js/tinymce/plugins/media/img/flv_player.swf | Bin 0 -> 11668 bytes .../js/tinymce/plugins/media/img/quicktime.gif | Bin 0 -> 303 bytes .../js/tinymce/plugins/media/img/realmedia.gif | Bin 0 -> 439 bytes .../js/tinymce/plugins/media/img/shockwave.gif | Bin 0 -> 387 bytes wp-includes/js/tinymce/plugins/media/img/trans.gif | Bin 0 -> 43 bytes .../js/tinymce/plugins/media/img/windowsmedia.gif | Bin 0 -> 415 bytes wp-includes/js/tinymce/plugins/media/js/embed.js | 73 + wp-includes/js/tinymce/plugins/media/js/media.js | 621 +++ wp-includes/js/tinymce/plugins/media/media.htm | 824 +++ .../js/tinymce/plugins/paste/images/pastetext.gif | Bin 294 -> 0 bytes .../js/tinymce/plugins/paste/images/pasteword.gif | Bin 299 -> 0 bytes .../js/tinymce/plugins/paste/images/selectall.gif | Bin 205 -> 0 bytes .../js/tinymce/plugins/paste/js/pastetext.js | 42 + .../js/tinymce/plugins/paste/js/pasteword.js | 56 + .../js/tinymce/plugins/paste/jscripts/pastetext.js | 38 - .../js/tinymce/plugins/paste/jscripts/pasteword.js | 52 - wp-includes/js/tinymce/plugins/paste/langs/en.js | 10 - wp-includes/js/tinymce/plugins/safari/blank.htm | 1 + .../js/tinymce/plugins/safari/editor_plugin.js | 1 + .../plugins/spellchecker/classes/GoogleSpell.php | 158 + .../spellchecker/classes/HttpClient.class.php | 339 -- .../plugins/spellchecker/classes/PSpell.php | 81 + .../plugins/spellchecker/classes/PSpellShell.php | 112 + .../plugins/spellchecker/classes/SpellChecker.php | 61 + .../spellchecker/classes/TinyGoogleSpell.class.php | 126 - .../spellchecker/classes/TinyPspell.class.php | 64 - .../spellchecker/classes/TinyPspellShell.class.php | 121 - .../plugins/spellchecker/classes/utils/JSON.php | 595 ++ .../plugins/spellchecker/classes/utils/Logger.php | 268 + .../plugins/spellchecker/css/spellchecker.css | 35 - .../plugins/spellchecker/images/spellchecker.gif | Bin 591 -> 0 bytes .../tinymce/plugins/spellchecker/images/wline.gif | Bin 46 -> 0 bytes .../js/tinymce/plugins/spellchecker/img/wline.gif | Bin 0 -> 46 bytes .../plugins/spellchecker/includes/general.php | 98 + .../js/tinymce/plugins/spellchecker/langs/en.js | 15 - .../js/tinymce/plugins/spellchecker/rpc.php | 75 + .../js/tinymce/plugins/spellchecker/tinyspell.php | 164 - .../js/tinymce/plugins/wordpress/css/content.css | 15 + .../js/tinymce/plugins/wordpress/images/help.gif | Bin 295 -> 0 bytes .../js/tinymce/plugins/wordpress/images/more.gif | Bin 108 -> 0 bytes .../tinymce/plugins/wordpress/images/more_bug.gif | Bin 146 -> 0 bytes .../js/tinymce/plugins/wordpress/images/page.gif | Bin 108 -> 0 bytes .../tinymce/plugins/wordpress/images/page_bug.gif | Bin 180 -> 0 bytes .../tinymce/plugins/wordpress/images/toolbars.gif | Bin 260 -> 0 bytes .../js/tinymce/plugins/wordpress/img/help.gif | Bin 0 -> 295 bytes .../js/tinymce/plugins/wordpress/img/more.gif | Bin 0 -> 108 bytes .../js/tinymce/plugins/wordpress/img/more_bug.gif | Bin 0 -> 146 bytes .../js/tinymce/plugins/wordpress/img/page.gif | Bin 0 -> 108 bytes .../js/tinymce/plugins/wordpress/img/page_bug.gif | Bin 0 -> 180 bytes .../js/tinymce/plugins/wordpress/img/toolbars.gif | Bin 0 -> 260 bytes .../js/tinymce/plugins/wordpress/img/trans.gif | Bin 0 -> 43 bytes .../js/tinymce/plugins/wordpress/langs/en.js | 37 - .../js/tinymce/plugins/wordpress/wordpress.css | 81 - .../js/tinymce/plugins/wphelp/editor_plugin.js | 57 - .../js/tinymce/plugins/wphelp/images/help.gif | Bin 295 -> 0 bytes wp-includes/js/tinymce/plugins/wphelp/langs/en.js | 5 - .../js/tinymce/themes/advanced/css/colorpicker.css | 53 - .../tinymce/themes/advanced/css/editor_content.css | 58 - .../tinymce/themes/advanced/css/editor_popup.css | 358 -- .../js/tinymce/themes/advanced/css/editor_ui.css | 97 - .../js/tinymce/themes/advanced/images/anchor.gif | Bin 171 -> 0 bytes .../themes/advanced/images/anchor_symbol.gif | Bin 70 -> 0 bytes .../tinymce/themes/advanced/images/backcolor.gif | Bin 359 -> 0 bytes .../js/tinymce/themes/advanced/images/bold.gif | Bin 76 -> 0 bytes .../tinymce/themes/advanced/images/bold_de_se.gif | Bin 73 -> 0 bytes .../js/tinymce/themes/advanced/images/bold_es.gif | Bin 80 -> 0 bytes .../js/tinymce/themes/advanced/images/bold_fr.gif | Bin 78 -> 0 bytes .../js/tinymce/themes/advanced/images/bold_ru.gif | Bin 77 -> 0 bytes .../js/tinymce/themes/advanced/images/bold_tw.gif | Bin 207 -> 0 bytes .../js/tinymce/themes/advanced/images/browse.gif | Bin 113 -> 0 bytes .../js/tinymce/themes/advanced/images/bullist.gif | Bin 108 -> 0 bytes .../tinymce/themes/advanced/images/button_menu.gif | Bin 57 -> 0 bytes .../js/tinymce/themes/advanced/images/buttons.gif | Bin 5662 -> 0 bytes .../themes/advanced/images/cancel_button_bg.gif | Bin 677 -> 0 bytes .../js/tinymce/themes/advanced/images/center.gif | Bin 70 -> 0 bytes .../js/tinymce/themes/advanced/images/charmap.gif | Bin 245 -> 0 bytes .../js/tinymce/themes/advanced/images/cleanup.gif | Bin 256 -> 0 bytes .../js/tinymce/themes/advanced/images/close.gif | Bin 102 -> 0 bytes .../js/tinymce/themes/advanced/images/code.gif | Bin 110 -> 0 bytes .../js/tinymce/themes/advanced/images/color.gif | Bin 125 -> 0 bytes .../js/tinymce/themes/advanced/images/colors.jpg | Bin 3189 -> 0 bytes .../js/tinymce/themes/advanced/images/copy.gif | Bin 263 -> 0 bytes .../js/tinymce/themes/advanced/images/custom_1.gif | Bin 76 -> 0 bytes .../js/tinymce/themes/advanced/images/cut.gif | Bin 187 -> 0 bytes .../tinymce/themes/advanced/images/forecolor.gif | Bin 342 -> 0 bytes .../js/tinymce/themes/advanced/images/full.gif | Bin 71 -> 0 bytes .../js/tinymce/themes/advanced/images/help.gif | Bin 295 -> 0 bytes .../js/tinymce/themes/advanced/images/hr.gif | Bin 63 -> 0 bytes .../js/tinymce/themes/advanced/images/image.gif | Bin 194 -> 0 bytes .../js/tinymce/themes/advanced/images/indent.gif | Bin 112 -> 0 bytes .../themes/advanced/images/insert_button_bg.gif | Bin 703 -> 0 bytes .../js/tinymce/themes/advanced/images/italic.gif | Bin 79 -> 0 bytes .../themes/advanced/images/italic_de_se.gif | Bin 75 -> 0 bytes .../tinymce/themes/advanced/images/italic_es.gif | Bin 74 -> 0 bytes .../tinymce/themes/advanced/images/italic_ru.gif | Bin 78 -> 0 bytes .../tinymce/themes/advanced/images/italic_tw.gif | Bin 274 -> 0 bytes .../themes/advanced/images/justifycenter.gif | Bin 70 -> 0 bytes .../tinymce/themes/advanced/images/justifyfull.gif | Bin 71 -> 0 bytes .../tinymce/themes/advanced/images/justifyleft.gif | Bin 71 -> 0 bytes .../themes/advanced/images/justifyright.gif | Bin 70 -> 0 bytes .../js/tinymce/themes/advanced/images/left.gif | Bin 71 -> 0 bytes .../js/tinymce/themes/advanced/images/link.gif | Bin 175 -> 0 bytes .../tinymce/themes/advanced/images/menu_check.gif | Bin 51 -> 0 bytes .../tinymce/themes/advanced/images/newdocument.gif | Bin 170 -> 0 bytes .../js/tinymce/themes/advanced/images/numlist.gif | Bin 111 -> 0 bytes .../js/tinymce/themes/advanced/images/opacity.png | Bin 147 -> 0 bytes .../js/tinymce/themes/advanced/images/outdent.gif | Bin 110 -> 0 bytes .../js/tinymce/themes/advanced/images/paste.gif | Bin 286 -> 0 bytes .../js/tinymce/themes/advanced/images/redo.gif | Bin 169 -> 0 bytes .../themes/advanced/images/removeformat.gif | Bin 168 -> 0 bytes .../js/tinymce/themes/advanced/images/right.gif | Bin 70 -> 0 bytes .../tinymce/themes/advanced/images/separator.gif | Bin 57 -> 0 bytes .../js/tinymce/themes/advanced/images/spacer.gif | Bin 43 -> 0 bytes .../themes/advanced/images/statusbar_resize.gif | Bin 79 -> 0 bytes .../themes/advanced/images/strikethrough.gif | Bin 83 -> 0 bytes .../js/tinymce/themes/advanced/images/sub.gif | Bin 148 -> 0 bytes .../js/tinymce/themes/advanced/images/sup.gif | Bin 147 -> 0 bytes .../js/tinymce/themes/advanced/images/table.gif | Bin 287 -> 0 bytes .../themes/advanced/images/table_delete_col.gif | Bin 163 -> 0 bytes .../themes/advanced/images/table_delete_row.gif | Bin 171 -> 0 bytes .../advanced/images/table_insert_col_after.gif | Bin 165 -> 0 bytes .../advanced/images/table_insert_col_before.gif | Bin 165 -> 0 bytes .../advanced/images/table_insert_row_after.gif | Bin 163 -> 0 bytes .../advanced/images/table_insert_row_before.gif | Bin 159 -> 0 bytes .../tinymce/themes/advanced/images/underline.gif | Bin 88 -> 0 bytes .../themes/advanced/images/underline_es.gif | Bin 79 -> 0 bytes .../themes/advanced/images/underline_fr.gif | Bin 79 -> 0 bytes .../themes/advanced/images/underline_ru.gif | Bin 77 -> 0 bytes .../themes/advanced/images/underline_tw.gif | Bin 245 -> 0 bytes .../js/tinymce/themes/advanced/images/undo.gif | Bin 175 -> 0 bytes .../js/tinymce/themes/advanced/images/unlink.gif | Bin 190 -> 0 bytes .../tinymce/themes/advanced/images/visualaid.gif | Bin 206 -> 0 bytes .../tinymce/themes/advanced/images/xp/tab_bg.gif | Bin 694 -> 0 bytes .../tinymce/themes/advanced/images/xp/tab_end.gif | Bin 169 -> 0 bytes .../themes/advanced/images/xp/tab_sel_bg.gif | Bin 428 -> 0 bytes .../themes/advanced/images/xp/tab_sel_end.gif | Bin 101 -> 0 bytes .../tinymce/themes/advanced/images/xp/tabs_bg.gif | Bin 48 -> 0 bytes .../js/tinymce/themes/advanced/img/colorpicker.jpg | Bin 0 -> 3189 bytes wp-includes/js/tinymce/themes/advanced/img/fm.gif | Bin 0 -> 1805 bytes .../js/tinymce/themes/advanced/img/gotmoxie.png | Bin 0 -> 983 bytes .../js/tinymce/themes/advanced/img/icons.gif | Bin 0 -> 11532 bytes .../js/tinymce/themes/advanced/img/sflogo.png | Bin 0 -> 469 bytes wp-includes/js/tinymce/themes/advanced/js/about.js | 72 + .../js/tinymce/themes/advanced/js/anchor.js | 33 + .../js/tinymce/themes/advanced/js/charmap.js | 325 ++ .../js/tinymce/themes/advanced/js/color_picker.js | 245 + wp-includes/js/tinymce/themes/advanced/js/image.js | 254 + wp-includes/js/tinymce/themes/advanced/js/link.js | 126 + .../js/tinymce/themes/advanced/js/source_editor.js | 62 + .../js/tinymce/themes/advanced/jscripts/about.js | 75 - .../js/tinymce/themes/advanced/jscripts/anchor.js | 74 - .../js/tinymce/themes/advanced/jscripts/charmap.js | 326 -- .../themes/advanced/jscripts/color_picker.js | 240 - .../js/tinymce/themes/advanced/jscripts/image.js | 81 - .../js/tinymce/themes/advanced/jscripts/link.js | 82 - .../themes/advanced/jscripts/source_editor.js | 59 - wp-includes/js/tinymce/themes/advanced/langs/en.js | 93 - .../themes/advanced/skins/default/content.css | 25 + .../themes/advanced/skins/default/dialog.css | 114 + .../themes/advanced/skins/default/img/buttons.png | Bin 0 -> 3274 bytes .../themes/advanced/skins/default/img/items.gif | Bin 0 -> 70 bytes .../advanced/skins/default/img/menu_arrow.gif | Bin 0 -> 68 bytes .../advanced/skins/default/img/menu_check.gif | Bin 0 -> 70 bytes .../themes/advanced/skins/default/img/progress.gif | Bin 0 -> 1787 bytes .../themes/advanced/skins/default/img/tabs.gif | Bin 0 -> 1326 bytes .../tinymce/themes/advanced/skins/default/ui.css | 210 + .../tinymce/themes/advanced/skins/o2k7/content.css | 25 + .../tinymce/themes/advanced/skins/o2k7/dialog.css | 113 + .../themes/advanced/skins/o2k7/img/button_bg.png | Bin 0 -> 5859 bytes .../advanced/skins/o2k7/img/button_bg_black.png | Bin 0 -> 3736 bytes .../advanced/skins/o2k7/img/button_bg_silver.png | Bin 0 -> 5358 bytes .../js/tinymce/themes/advanced/skins/o2k7/ui.css | 211 + .../themes/advanced/skins/o2k7/ui_black.css | 8 + .../themes/advanced/skins/o2k7/ui_silver.css | 5 + .../themes/advanced/skins/wp_theme/content.css | 19 + .../themes/advanced/skins/wp_theme/dialog.css | 119 + .../themes/advanced/skins/wp_theme/img/butt2.png | Bin 0 -> 545 bytes .../advanced/skins/wp_theme/img/button_bg.png | Bin 0 -> 5859 bytes .../advanced/skins/wp_theme/img/down_arrow.gif | Bin 0 -> 60 bytes .../advanced/skins/wp_theme/img/fade-butt.png | Bin 0 -> 785 bytes .../advanced/skins/wp_theme/img/separator.gif | Bin 0 -> 57 bytes .../themes/advanced/skins/wp_theme/img/tabs.gif | Bin 0 -> 1326 bytes .../tinymce/themes/advanced/skins/wp_theme/ui.css | 370 ++ wp-includes/js/tinymce/tiny_mce_ext.js | 29 + wp-includes/js/tinymce/wordpress.css | 29 + wp-includes/js/wp-ajax-response.js | 57 + wp-includes/js/wp-lists.js | 369 ++ wp-includes/media.php | 404 ++ wp-includes/shortcodes.php | 133 + 342 files changed, 26359 insertions(+), 4075 deletions(-) create mode 100644 wp-admin/async-upload.php create mode 100644 wp-admin/css/colors-classic.css create mode 100644 wp-admin/css/colors-fresh.css create mode 100644 wp-admin/css/dashboard.css create mode 100644 wp-admin/css/global.css create mode 100644 wp-admin/css/ie.css create mode 100644 wp-admin/css/login.css create mode 100644 wp-admin/css/media.css create mode 100644 wp-admin/css/theme-editor.css delete mode 100644 wp-admin/css/upload-rtl.css delete mode 100644 wp-admin/css/upload.css create mode 100644 wp-admin/edit-attachment-rows.php create mode 100644 wp-admin/edit-tag-form.php create mode 100644 wp-admin/edit-tags.php create mode 100644 wp-admin/images/align-center.png create mode 100644 wp-admin/images/align-left.png create mode 100644 wp-admin/images/align-none.png create mode 100644 wp-admin/images/align-right.png delete mode 100644 wp-admin/images/box-bg-left.gif delete mode 100644 wp-admin/images/box-bg-right.gif delete mode 100644 wp-admin/images/box-bg.gif delete mode 100644 wp-admin/images/box-butt-left.gif delete mode 100644 wp-admin/images/box-butt-right.gif delete mode 100644 wp-admin/images/box-butt.gif delete mode 100644 wp-admin/images/box-head-left.gif delete mode 100644 wp-admin/images/box-head-right.gif delete mode 100644 wp-admin/images/box-head.gif create mode 100644 wp-admin/images/bubble_bg.gif create mode 100644 wp-admin/images/comment-grey-bubble.png create mode 100644 wp-admin/images/comment-pill.gif create mode 100644 wp-admin/images/comment-stalk-classic.gif create mode 100644 wp-admin/images/comment-stalk-fresh.gif create mode 100644 wp-admin/images/date-button.gif delete mode 100644 wp-admin/images/heading-bg.gif delete mode 100644 wp-admin/images/login-bkg-bottom.gif delete mode 100644 wp-admin/images/login-bkg-tile.gif create mode 100644 wp-admin/images/logo-login.gif create mode 100644 wp-admin/images/media-button-gallery.gif create mode 100644 wp-admin/images/media-button-image.gif create mode 100644 wp-admin/images/media-button-music.gif create mode 100644 wp-admin/images/media-button-other.gif create mode 100644 wp-admin/images/media-button-video.gif create mode 100644 wp-admin/images/media-buttons.gif delete mode 100644 wp-admin/images/notice.gif create mode 100644 wp-admin/images/tail.gif create mode 100644 wp-admin/images/toggle-arrow.gif delete mode 100644 wp-admin/images/toggle.gif create mode 100644 wp-admin/images/xit.gif create mode 100644 wp-admin/includes/class-ftp-pure.php create mode 100644 wp-admin/includes/class-ftp-sockets.php create mode 100644 wp-admin/includes/class-ftp.php create mode 100644 wp-admin/includes/class-pclzip.php create mode 100644 wp-admin/includes/class-wp-filesystem-direct.php create mode 100644 wp-admin/includes/class-wp-filesystem-ftpext.php create mode 100644 wp-admin/includes/class-wp-filesystem-ftpsockets.php create mode 100644 wp-admin/includes/dashboard.php create mode 100644 wp-admin/includes/export.php create mode 100644 wp-admin/includes/media.php create mode 100644 wp-admin/includes/widgets.php create mode 100644 wp-admin/js/comment.js create mode 100644 wp-admin/js/common.js delete mode 100644 wp-admin/js/dbx-admin-key.js create mode 100644 wp-admin/js/editor.js create mode 100644 wp-admin/js/forms.js delete mode 100644 wp-admin/js/link-cat.js create mode 100644 wp-admin/js/link.js create mode 100644 wp-admin/js/media-upload.js create mode 100644 wp-admin/js/page.js create mode 100644 wp-admin/js/password-strength-meter.js create mode 100644 wp-admin/js/post.js create mode 100644 wp-admin/js/postbox.js create mode 100644 wp-admin/js/slug.js create mode 100644 wp-admin/js/tags.js create mode 100644 wp-admin/js/widgets.js create mode 100644 wp-admin/media-upload.php create mode 100644 wp-admin/media.php create mode 100644 wp-admin/update.php create mode 100644 wp-admin/wpmu-blogs.php.rej delete mode 100644 wp-content/themes/default/attachment.php create mode 100644 wp-content/themes/default/image.php create mode 100644 wp-includes/class-phpass.php create mode 100644 wp-includes/images/audio.png create mode 100644 wp-includes/images/crystal/archive.png create mode 100644 wp-includes/images/crystal/audio.png create mode 100644 wp-includes/images/crystal/code.png create mode 100644 wp-includes/images/crystal/default.png create mode 100644 wp-includes/images/crystal/document.png create mode 100644 wp-includes/images/crystal/interactive.png create mode 100644 wp-includes/images/crystal/license.txt create mode 100644 wp-includes/images/crystal/spreadsheet.png create mode 100644 wp-includes/images/crystal/text.png create mode 100644 wp-includes/images/crystal/video.png create mode 100644 wp-includes/images/css.png create mode 100644 wp-includes/images/default.png create mode 100644 wp-includes/images/doc.png create mode 100644 wp-includes/images/exe.png create mode 100644 wp-includes/images/html.png create mode 100644 wp-includes/images/js.png create mode 100644 wp-includes/images/pdf.png create mode 100644 wp-includes/images/swf.png create mode 100644 wp-includes/images/tar.png create mode 100644 wp-includes/images/text.png create mode 100644 wp-includes/images/video.png create mode 100644 wp-includes/images/zip.png delete mode 100644 wp-includes/js/dbx.js delete mode 100644 wp-includes/js/fat.js create mode 100644 wp-includes/js/jquery/jquery.color.js create mode 100644 wp-includes/js/jquery/jquery.dimensions.min.js create mode 100644 wp-includes/js/jquery/jquery.schedule.js create mode 100644 wp-includes/js/jquery/suggest.js create mode 100644 wp-includes/js/jquery/ui.tabs.js delete mode 100644 wp-includes/js/list-manipulation.js create mode 100644 wp-includes/js/swfupload/handlers.js create mode 100644 wp-includes/js/swfupload/plugins/swfupload.cookies.js create mode 100644 wp-includes/js/swfupload/plugins/swfupload.documentready.js create mode 100644 wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js create mode 100644 wp-includes/js/swfupload/plugins/swfupload.queue.js create mode 100644 wp-includes/js/swfupload/swfupload.js create mode 100644 wp-includes/js/swfupload/swfupload_f9.swf create mode 100644 wp-includes/js/thickbox/loadingAnimation.gif create mode 100644 wp-includes/js/thickbox/tb-close.png create mode 100644 wp-includes/js/thickbox/thickbox.css create mode 100644 wp-includes/js/thickbox/thickbox.js delete mode 100644 wp-includes/js/tinymce/langs/en.js create mode 100644 wp-includes/js/tinymce/langs/wp-langs.php delete mode 100644 wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js delete mode 100644 wp-includes/js/tinymce/plugins/autosave/langs/en.js delete mode 100644 wp-includes/js/tinymce/plugins/directionality/images/ltr.gif delete mode 100644 wp-includes/js/tinymce/plugins/directionality/images/rtl.gif delete mode 100644 wp-includes/js/tinymce/plugins/directionality/langs/en.js create mode 100644 wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm delete mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css delete mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/images/spacer.gif delete mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/images/window_close.gif delete mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/images/window_maximize.gif delete mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/images/window_minimize.gif delete mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/images/window_resize.gif delete mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/button.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/drag.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/template.htm create mode 100644 wp-includes/js/tinymce/plugins/media/css/content.css create mode 100644 wp-includes/js/tinymce/plugins/media/css/media.css create mode 100644 wp-includes/js/tinymce/plugins/media/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/media/img/flash.gif create mode 100644 wp-includes/js/tinymce/plugins/media/img/flv_player.swf create mode 100644 wp-includes/js/tinymce/plugins/media/img/quicktime.gif create mode 100644 wp-includes/js/tinymce/plugins/media/img/realmedia.gif create mode 100644 wp-includes/js/tinymce/plugins/media/img/shockwave.gif create mode 100644 wp-includes/js/tinymce/plugins/media/img/trans.gif create mode 100644 wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif create mode 100644 wp-includes/js/tinymce/plugins/media/js/embed.js create mode 100644 wp-includes/js/tinymce/plugins/media/js/media.js create mode 100644 wp-includes/js/tinymce/plugins/media/media.htm delete mode 100644 wp-includes/js/tinymce/plugins/paste/images/pastetext.gif delete mode 100644 wp-includes/js/tinymce/plugins/paste/images/pasteword.gif delete mode 100644 wp-includes/js/tinymce/plugins/paste/images/selectall.gif create mode 100644 wp-includes/js/tinymce/plugins/paste/js/pastetext.js create mode 100644 wp-includes/js/tinymce/plugins/paste/js/pasteword.js delete mode 100644 wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js delete mode 100644 wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js delete mode 100644 wp-includes/js/tinymce/plugins/paste/langs/en.js create mode 100644 wp-includes/js/tinymce/plugins/safari/blank.htm create mode 100644 wp-includes/js/tinymce/plugins/safari/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php delete mode 100755 wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php create mode 100644 wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php create mode 100644 wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php create mode 100644 wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php delete mode 100755 wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php delete mode 100755 wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php delete mode 100755 wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php create mode 100644 wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php create mode 100644 wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php delete mode 100755 wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css delete mode 100755 wp-includes/js/tinymce/plugins/spellchecker/images/spellchecker.gif delete mode 100755 wp-includes/js/tinymce/plugins/spellchecker/images/wline.gif create mode 100644 wp-includes/js/tinymce/plugins/spellchecker/img/wline.gif create mode 100644 wp-includes/js/tinymce/plugins/spellchecker/includes/general.php delete mode 100755 wp-includes/js/tinymce/plugins/spellchecker/langs/en.js create mode 100644 wp-includes/js/tinymce/plugins/spellchecker/rpc.php delete mode 100755 wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php create mode 100644 wp-includes/js/tinymce/plugins/wordpress/css/content.css delete mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/help.gif delete mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/more.gif delete mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/more_bug.gif delete mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/page.gif delete mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif delete mode 100755 wp-includes/js/tinymce/plugins/wordpress/images/toolbars.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/img/help.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/img/more.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/img/page.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/img/trans.gif delete mode 100644 wp-includes/js/tinymce/plugins/wordpress/langs/en.js delete mode 100644 wp-includes/js/tinymce/plugins/wordpress/wordpress.css delete mode 100644 wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js delete mode 100644 wp-includes/js/tinymce/plugins/wphelp/images/help.gif delete mode 100644 wp-includes/js/tinymce/plugins/wphelp/langs/en.js delete mode 100644 wp-includes/js/tinymce/themes/advanced/css/colorpicker.css delete mode 100644 wp-includes/js/tinymce/themes/advanced/css/editor_content.css delete mode 100644 wp-includes/js/tinymce/themes/advanced/css/editor_popup.css delete mode 100644 wp-includes/js/tinymce/themes/advanced/css/editor_ui.css delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/anchor.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/anchor_symbol.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/backcolor.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/bold.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/bold_de_se.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/bold_es.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/bold_fr.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/bold_ru.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/bold_tw.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/browse.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/bullist.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/button_menu.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/buttons.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/cancel_button_bg.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/center.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/charmap.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/cleanup.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/close.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/code.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/color.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/colors.jpg delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/copy.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/custom_1.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/cut.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/forecolor.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/full.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/help.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/hr.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/image.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/indent.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/insert_button_bg.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/italic.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/italic_de_se.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/italic_es.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/italic_ru.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/italic_tw.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/justifycenter.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/justifyfull.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/justifyleft.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/justifyright.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/left.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/link.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/menu_check.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/newdocument.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/numlist.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/opacity.png delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/outdent.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/paste.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/redo.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/removeformat.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/right.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/separator.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/spacer.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/statusbar_resize.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/strikethrough.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/sub.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/sup.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/table.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_delete_col.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_delete_row.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_insert_col_after.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_insert_col_before.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_insert_row_after.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_insert_row_before.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/underline.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/underline_es.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/underline_fr.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/underline_ru.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/underline_tw.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/undo.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/unlink.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/visualaid.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/xp/tab_bg.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/xp/tab_end.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_bg.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_end.gif delete mode 100644 wp-includes/js/tinymce/themes/advanced/images/xp/tabs_bg.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/img/colorpicker.jpg create mode 100644 wp-includes/js/tinymce/themes/advanced/img/fm.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/img/gotmoxie.png create mode 100644 wp-includes/js/tinymce/themes/advanced/img/icons.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/img/sflogo.png create mode 100644 wp-includes/js/tinymce/themes/advanced/js/about.js create mode 100644 wp-includes/js/tinymce/themes/advanced/js/anchor.js create mode 100644 wp-includes/js/tinymce/themes/advanced/js/charmap.js create mode 100644 wp-includes/js/tinymce/themes/advanced/js/color_picker.js create mode 100644 wp-includes/js/tinymce/themes/advanced/js/image.js create mode 100644 wp-includes/js/tinymce/themes/advanced/js/link.js create mode 100644 wp-includes/js/tinymce/themes/advanced/js/source_editor.js delete mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/about.js delete mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js delete mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js delete mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js delete mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/image.js delete mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/link.js delete mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js delete mode 100644 wp-includes/js/tinymce/themes/advanced/langs/en.js create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/default/content.css create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/default/dialog.css create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/default/img/buttons.png create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/default/img/items.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_arrow.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_check.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/default/img/progress.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/default/img/tabs.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/default/ui.css create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/o2k7/content.css create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/o2k7/dialog.css create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg.png create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg_black.png create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg_silver.png create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui.css create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_black.css create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_silver.css create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/butt2.png create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/button_bg.png create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/down_arrow.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/fade-butt.png create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/separator.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/tabs.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css create mode 100644 wp-includes/js/tinymce/tiny_mce_ext.js create mode 100644 wp-includes/js/tinymce/wordpress.css create mode 100644 wp-includes/js/wp-ajax-response.js create mode 100644 wp-includes/js/wp-lists.js create mode 100644 wp-includes/media.php create mode 100644 wp-includes/shortcodes.php diff --git a/wp-admin/async-upload.php b/wp-admin/async-upload.php new file mode 100644 index 0000000..c6350aa --- /dev/null +++ b/wp-admin/async-upload.php @@ -0,0 +1,32 @@ +'.wp_specialchars($id->get_error_message()).''; + exit; +} + +$type = $_REQUEST['type']; +echo apply_filters("async_upload_{$type}", $id); + +?> diff --git a/wp-admin/css/colors-classic.css b/wp-admin/css/colors-classic.css new file mode 100644 index 0000000..4251f15 --- /dev/null +++ b/wp-admin/css/colors-classic.css @@ -0,0 +1,701 @@ +a.page-numbers:hover { + border-color: #999; +} + +body { + background-color: #fff; + color: #333; +} + +body > #upload-menu { + border-bottom-style: #fff; +} + +div#current-widgets, #postcustomstuff table, #your-profile fieldset, a.page-numbers, #rightnow, div.dashboard-widget, .widefat { + border-color: #ccc; +} + +div.dashboard-widget-error { + background-color: #c43; +} + +div.dashboard-widget-notice { + background-color: #F0F6FB; +} + +div.dashboard-widget-submit, ul.widget-control-list div.widget-control-actions { + border-top-color: #ccc; +} + +input.disabled, textarea.disabled { + background-color: #ccc; +} + +li.widget-list-control-item h4.widget-title a:hover, .submit a, #user_info a, #dashmenu a:hover, #footer a, #upload-menu li a.upload-tab-link, li.widget-list-control-item h4.widget-title a, +#dragHelper li.widget-list-control-item h4.widget-title a, +#draghelper li.widget-list-control-item h4.widget-title a:visited, .login #backtoblog a:hover { + color: #fff; +} + +ul#category-tabs li.ui-tabs-selected, li.widget-list-control-item, div.nav, .tablenav, .submitbox, h3.dashboard-widget-title, h3.dashboard-widget-title span, h3.dashboard-widget-title small, ul.view-switch li.current, .form-table tr, #poststuff h3, .login form { + background-color: #cfebf7; +} + +div.ui-tabs-panel { + border-color: #cfebf7; +} + +select { + background-color: #fff; + border-color: #ddd; +} + +strong .post-com-count span { + background-color: #2583ad; +} + +.button-secondary, #quicktags, #login form .submit input { + background-color: #83b4d5 !important; +} + +ul#widget-list li.widget-list-item h4.widget-title { + background-color: #f0f0f0; + color: #000; +} + +ul.widget-control-list .sorthelper { + background-color: #ccf3fa; +} + +.ac_match, .subsubsub a.current, h2 { + color: #000; +} + +.ac_over { + background-color: #f0f0b8; +} + +.ac_results { + background-color: #fff; + border-color: #808080; +} + +.ac_results li { + color: #101010; +} + +.alternate { + background-color: #f9f9f9; +} + +.available-theme a.screenshot { + background-color: #f1f1f1; + border-color: #ccc; +} + +.bar { + background-color: #e8e8e8; + border-right-color: #99d; +} + +.describe { + border-top-color: #d0d0d0; +} + +.error, #login #login_error { + background-color: #ffebe8; + border-color: #c00; +} + +.error a { + color: #c00; +} + +.form-invalid { + background-color: #ffebe8 !important; +} + +.form-invalid input { + border-color: #c00 !important; +} + +.form-table input, .form-table textarea { + border-color: #c6d9e9; +} + +.form-table td, .form-table th { + border-bottom-color: #fff; +} + +.highlight { + background-color: #cfebf7; + color: #d54e21; +} + +.howto, .nonessential, #sidemenu, #edit-slug-box, .form-input-tip, #dashboard_primary span.rss-date, .subsubsub, #dashboard_secondary div.dashboard-widget-content ul li a cite { + color: #999; +} + +#dashmenu a { + color: #88b4d7; +} + +.media-item { + border-bottom-color: #d0d0d0; +} + +.media-upload-form label.form-help, td.help { + color: #9a9a9a; +} + +.page-numbers { + background-color: #fff; + border-color: #fff; +} + +.page-numbers.current { + background-color: #328ab2; + border-color: #328ab2; + color: #fff; +} + +.post-com-count { + background-image: url(../images/bubble_bg.gif); + color: #fff; +} + +.post-com-count span { + background-color: #bbb; + color: #fff; +} + +.post-com-count:hover span { + background-color: #d54e21; +} + +.quicktags, .search { + background-color: #ccc; + color: #000; +} + +.side-info h5, .bordertitle { + border-bottom-color: #dadada; +} + +.side-info ul { + color: #666; +} + +.submit input, .button, .button-secondary, #login form .submit input, div.dashboard-widget-submit input { + background-color: #e5e5e5; + color: #246; + border-color: #a3a3a3; +} + +.tablenav .button-secondary { + border-color: #5396c5; +} + +.submit input:hover, .button:hover { + border-color: #535353; +} + +.submit input:hover, .button:hover, .button-secondary:hover, #wphead #viewsite a:hover, #adminmenu a:hover, #sidemenu a:hover, #submenu a.current, #submenu a:hover, .submitbox #previewview a:hover, #the-comment-list .comment a:hover, #rightnow a:hover, a:hover, .subsubsub a:hover, .subsubsub a.current:hover, #login form .submit input:hover, div.dashboard-widget-submit input:hover { + color: #d54e21; +} + +.button-secondary:hover, #login form .submit input:hover { + border-color: #328ab2; +} + +.submitbox #autosave .error, ul.view-switch li.current a { + color: #333; +} + +.submitbox #previewview { + background-color: #5488af; +} + +.submitbox #previewview a, #rightnow .rbutton { + background-color: #ebebeb; + color: #264761; +} + +.submitbox .submit { + background-color: #464646; + color: #ccc; +} + +.submitbox .submitdelete { + border-bottom-color: #999; +} + +.submitbox .submitdelete:hover { + color: #fff; + background-color: #f00; + border-bottom-color: #f00; +} + +.tablenav .dots { + background-color: #cfebf7; + border-color: #cfebf7; +} + +.tablenav .next, .tablenav .prev{ + background-color: #cfebf7; + border-bottom-color: #cfebf7; + border-color: #cfebf7; + color: #2583ad; +} + +.tablenav .next:hover, .tablenav .prev:hover { + border-bottom-color: #d54e21; + border-color: #cfebf7; + color: #d54e21; +} + +.updated, .login #login_error, .login .message { + background-color: #ffffe0; + border-color: #e6db55; +} + +.updated a { + border-bottom-color: #2583ad; +} + +.widefat td, .widefat th, div#available-widgets-filter, ul#widget-list li.widget-list-item, .commentlist li { + border-bottom-color: #ccc; +} + +.widefat thead, .thead { + background-color: #464646; + color: #d7d7d7; +} + +.widget-control-save, .widget-control-remove { + background-color: #83b4d5; + color: #246; +} + +.wrap h2 { + border-bottom-color: #dadada; + color: #5a5a5a; +} + +#poststuff #edButtonPreview, #poststuff #edButtonHTML, #the-comment-list p.comment-author strong a, a { + color: #2e7ca0; +} + +#adminmenu a { + color: #cfebf6; +} + +#submenu a { + color: #2782af +} +/* Because we don't want visited on these links */ +#adminmenu a.current, #sidemenu a.current { + background-color: #fff; + border-color: #c6d9e9; + border-bottom-color: #fff; + color: #d54e21; + font-weight: bold; +} + +#adminmenu li a #awaiting-mod { + background-image: url(../images/comment-stalk-classic.gif); +} + +#adminmenu li a #awaiting-mod span { + background-color: #d54e21; + color: #fff; +} + +#rightnow .reallynow { + background-color: #114973; + color: #fff; +} + + +#adminmenu li a:hover #awaiting-mod span { + background-color: #07273E; +} + +#adminmenu, div#media-upload-header { + background-color: #14568a; + border-bottom-color: #c6d9e9; +} + +#currenttheme img { + border-color: #666; +} + +#current-widgets .drop-widget-here { + background-color: #ffc; +} + +#dashboard_secondary div.dashboard-widget-content ul li a { + background-color: #f9f9f9; +} + +input.readonly { + background-color: #ddd; +} + +#dashmenu a.current { + background-color: #14568a; + color: #cfebf6; +} + +#dragHelper h4.widget-title, li.widget-list-control-item h4, #dragHelper li.widget-list-control-item h4 { + background-color: #2683ae; + color: #fff; +} + +#ed_toolbar input { + background: url( ../images/fade-butt.png ) #fff repeat-x 0 -2px; +} + +#editable-post-name { + background-color: #fffbcc; +} + +#edit-slug-box strong, .login #nav a { + color: #777; +} + +#edit-slug-buttons a.save { + background-color: #ebebeb; +} + +#footer { + background: url(../images/logo-ghost.png) #464646 no-repeat 20px 10px; + color: #999; +} + +#media-items { + border-color: #c0c0c0; +} + +#pass-strength-result { + background-color: #e3e3e3; + border-color: #000; +} + +#pass-strength-result.bad { + background-color: #ffeff7; + border-color: #c69; +} + +#pass-strength-result.good { + background-color: #effff4; + border-color: #66cc87; +} + +#pass-strength-result.short { + background-color: #e3e3e3; +} + +#pass-strength-result.strong { + background-color: #59ef86; + border-color: #319f52; +} + +#plugins .active, .checkbox, .side-info, #your-profile #rich_editing { + background-color: #fff; +} + +#plugins .togl { + border-right-color: #ccc; +} + +#plugins tr, #the-comment-list .unapproved { + background-color: #f0f0f0; +} + +#poststuff #editor-toolbar .active { + background-color: #83b4d5; + color: #333; +} + +#poststuff .closed .togbox { + background-color: #2583ad; + background-image: url(../images/toggle-arrow.gif); +} + +#poststuff .postbox, #titlediv, #poststuff .postarea, #poststuff .stuffbox { + border-color: #ebebeb; + border-right-color: #ccc; + border-bottom-color: #ccc; +} + +#poststuff .togbox { + background-color: #b2b2b2; + background-image: url(../images/toggle-arrow.gif); +} + +#quicktags #ed_link { + color: #00f; +} + +#rightnow .youhave { + background-color: #f0f6fb; +} + +#rightnow a { + color: #448abd; +} + +#sidemenu a { + background-color: #14568a; + border-bottom-color: #c6d9e9; + border-top-color: #14568a; + color: #cfebf6; +} + +#tagchecklist span a { + background: url(../images/xit.gif) no-repeat; +} + +#tagchecklist span a:hover { + background: url(../images/xit.gif) no-repeat -10px 0; +} + +#the-comment-list .comment a { + border-bottom-color: #ababab; + color: #666; +} + +#update-nag a:link, .plugin-update a:link { + color: #036; +} + +#update-nag, .plugin-update { + background-color: #fffeeb; + border-bottom-color: #ccc; + border-top-color: #ccc; + color: #cfebf6; +} + +#upload-files a.file-link { + background-color: #d1e2ef; +} + +#upload-file-view a img { + border-bottom-color: #69c; +} + +#upload-menu li #current-tab-nav, #upload-file { + background-color: #f9fcfe; +} + +#upload-menu li span a.page-numbers { + color: #00019b; +} + +#upload-menu li.current { + border-right-color: #448abd; + color: #000; +} + +#upload-menu li.current a.upload-tab-link, #upload-menu li a:hover { + background-color: #f9fcfe; + color: #000; +} + +#upload-menu, #upload-menu li { + border-top-color: #247fab; +} + +#user_info, .login #backtoblog a { + color: #ccc; +} + +#wphead { + background-color: #14568a; +} + +#wphead, body.login { + border-top-color: #07273e; +} + +#wphead #viewsite a { + background-color: #94acc1; + color: white; + border-color: #94acc1; +} + +#wphead #viewsite a:hover { + color: #246; +} + +#wphead h1, #dashmenu a.current:hover { + color: #cfebf6; +} + +div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover, .delete:hover { + color: #f00; +} + +#media-upload a.delete { + color: #888; +} + + +/* TinyMCE */ +.wp_themeSkin *, +.wp_themeSkin a:hover, +.wp_themeSkin a:link, +.wp_themeSkin a:visited, +.wp_themeSkin a:active { + color: #000; +} + +/* Containers */ +.wp_themeSkin table { + background: #83B4D5; +} + +.wp_themeSkin iframe { + background: #fff; +} + +/* Layout */ +.wp_themeSkin .mceStatusbar { + color:#000; + background-color: #eaf3fa; +} + +/* Button */ +.wp_themeSkin .mceButton { + background-color: #e9e8e8; + border-color: #83B4D5; +} + +.wp_themeSkin a.mceButtonEnabled:hover, +.wp_themeSkin a.mceButtonActive, +.wp_themeSkin a.mceButtonSelected { + background-color: #d6d8da; + border-color: #7789ba !important; +} + +.wp_themeSkin .mceButtonDisabled { + border-color: #83B4D5 !important; +} + +/* ListBox */ +.wp_themeSkin .mceListBox .mceText, +.wp_themeSkin .mceListBox .mceOpen { + border-color: #83B4D5; + background-color: #e9e8e8; +} + +.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen, +.wp_themeSkin .mceListBoxHover .mceOpen, +.wp_themeSkin .mceListBoxSelected .mceOpen, +.wp_themeSkin .mceListBoxSelected .mceText { + border-color: #7789ba !important; + background-color: #d6d8da; +} + +.wp_themeSkin table.mceListBoxEnabled:hover .mceText, +.wp_themeSkin .mceListBoxHover .mceText { + border-color: #7789ba !important; +} + +.wp_themeSkin select.mceListBox { + border-color: #b3c7e1; + background-color: #fff; +} + +/* SplitButton */ +.wp_themeSkin .mceSplitButton a.mceAction, +.wp_themeSkin .mceSplitButton a.mceOpen { + background-color: #e9e8e8; + border-color: #83B4D5; +} + +.wp_themeSkin .mceSplitButton a.mceOpen:hover, +.wp_themeSkin .mceSplitButtonSelected a.mceOpen, +.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction, +.wp_themeSkin .mceSplitButton a.mceAction:hover { + background-color: #d6d8da; + border-color: #7789ba !important; +} + +.wp_themeSkin .mceSplitButtonActive { + background-color: #d6d8da; +} + +/* ColorSplitButton */ +.wp_themeSkin div.mceColorSplitMenu table { + background-color: #ebeaeb; + border-color: #808080; +} + +.wp_themeSkin .mceColorSplitMenu a { + border-color: #808080; +} + +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors { + border-color: #fff; +} + +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover { + border-color: #0A246A; + background-color: #B6BDD2; +} + +.wp_themeSkin a.mceMoreColors:hover { + border-color: #0A246A; +} + +/* Menu */ +.wp_themeSkin .mceMenu { + border-color: #ddd; +} + +.wp_themeSkin .mceMenu table { + background-color: #ebeaeb; +} + +.wp_themeSkin .mceMenu .mceText { + color: #000; +} + +.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover, +.wp_themeSkin .mceMenu .mceMenuItemActive { + background-color: #83B4D5; +} +.wp_themeSkin td.mceMenuItemSeparator { + background-color: #aaa; +} +.wp_themeSkin .mceMenuItemTitle a { + background-color: #ccc; + border-bottom-color: #aaa; +} +.wp_themeSkin .mceMenuItemTitle span.mceText { + color: #000; +} +.wp_themeSkin .mceMenuItemDisabled .mceText { + color: #888; +} + +/* pop-up */ +.clearlooks2 .mceTop .mceLeft, .clearlooks2 .mceTop .mceRight { + background-color: #cee1ef; + border-color: #c6d9e9; +} + +.clearlooks2 .mceFocus .mceTop .mceLeft, .clearlooks2 .mceFocus .mceTop .mceRight { + background-color: #5488AF; + border-color: #464646; +} + +#editorcontainer { + border-color: #ccc; +} + +#poststuff #titlewrap { + border-color: #ccc; +} diff --git a/wp-admin/css/colors-fresh.css b/wp-admin/css/colors-fresh.css new file mode 100644 index 0000000..823ba46 --- /dev/null +++ b/wp-admin/css/colors-fresh.css @@ -0,0 +1,681 @@ +a.page-numbers:hover { + border-color: #999; +} + +body { + background-color: #fff; + color: #333; +} + +body > #upload-menu { + border-bottom-style: #fff; +} + +div#current-widgets, #postcustomstuff table, #your-profile fieldset, a.page-numbers, #rightnow, div.dashboard-widget, .widefat { + border-color: #ccc; +} + +div.dashboard-widget-error { + background-color: #c43; +} + +div.dashboard-widget-notice { + background-color: #cfe1ef; +} + +div.dashboard-widget-submit, ul.widget-control-list div.widget-control-actions { + border-top-color: #ccc; +} + +div.ui-tabs-panel { + border-color: #cee1ef; +} + +input.disabled, textarea.disabled { + background-color: #ccc; +} + +li.widget-list-control-item h4.widget-title a:hover, .submit a, #user_info a, #dashmenu a:hover, #footer a, #upload-menu li a.upload-tab-link, li.widget-list-control-item h4.widget-title a, +#dragHelper li.widget-list-control-item h4.widget-title a, +#draghelper li.widget-list-control-item h4.widget-title a:visited, .login #backtoblog a:hover { + color: #fff; +} + +li.widget-list-control-item, div.nav, .tablenav, .submitbox, h3.dashboard-widget-title, h3.dashboard-widget-title span, h3.dashboard-widget-title small, ul.view-switch li.current, .form-table tr, #poststuff h3, .login form { + background-color: #eaf3fa; +} + +select { + background-color: #fff; + border-color: #ddd; +} + +strong .post-com-count span { + background-color: #2583ad; +} + +ul#category-tabs li.ui-tabs-selected, .button-secondary, #quicktags, #login form .submit input { + background-color: #cee1ef !important; +} + +ul#widget-list li.widget-list-item h4.widget-title { + background-color: #f0f0f0; + color: #000; +} + +ul.widget-control-list .sorthelper { + background-color: #ccf3fa; +} + +.ac_match, .subsubsub a.current, h2 { + color: #000; +} + +.ac_over { + background-color: #f0f0b8; +} + +.ac_results { + background-color: #fff; + border-color: #808080; +} + +.ac_results li { + color: #101010; +} + +.alternate { + background-color: #f9f9f9; +} + +.available-theme a.screenshot { + background-color: #f1f1f1; + border-color: #ccc; +} + +.bar { + background-color: #e8e8e8; + border-right-color: #99d; +} + +.describe { + border-top-color: #d0d0d0; +} + +.error, #login #login_error { + background-color: #ffebe8; + border-color: #c00; +} + +.error a { + color: #c00; +} + +.form-invalid { + background-color: #ffebe8 !important; +} + +.form-invalid input { + border-color: #c00 !important; +} + +.form-table input, .form-table textarea { + border-color: #c6d9e9; +} + +.form-table td, .form-table th { + border-bottom-color: #fff; +} + +.highlight { + background-color: #e4f2fd; + color: #d54e21; +} + +.howto, .nonessential, #dashmenu a, #sidemenu, #edit-slug-box, .form-input-tip, #dashboard_primary span.rss-date, .subsubsub, #dashboard_secondary div.dashboard-widget-content ul li a cite { + color: #999; +} + +.media-item { + border-bottom-color: #d0d0d0; +} + +.media-upload-form label.form-help, td.help { + color: #9a9a9a; +} + +.page-numbers { + background-color: #fff; + border-color: #fff; +} + +.page-numbers.current { + background-color: #328ab2; + border-color: #328ab2; + color: #fff; +} + +.post-com-count { + background-image: url(../images/bubble_bg.gif); + color: #fff; +} + +.post-com-count span { + background-color: #bbb; + color: #fff; +} + +.post-com-count:hover span { + background-color: #d54e21; +} + +.quicktags, .search { + background-color: #ccc; + color: #000; +} + +.side-info h5, .bordertitle { + border-bottom-color: #dadada; +} + +.side-info ul { + color: #666; +} + +.submit input, .button, .button-secondary, #login form .submit input, div.dashboard-widget-submit input { + background-color: #e5e5e5; + color: #246; + border-color: #a3a3a3; +} + +.submit input:hover, .button:hover { + border-color: #535353; +} + +.submit input:hover, .button:hover, .button-secondary:hover, #wphead #viewsite a:hover, #adminmenu a:hover, #sidemenu a:hover, #submenu a.current, #submenu a:hover, .submitbox #previewview a:hover, #the-comment-list .comment a:hover, #rightnow a:hover, a:hover, .subsubsub a:hover, .subsubsub a.current:hover, #login form .submit input:hover, div.dashboard-widget-submit input:hover { + color: #d54e21; +} + +.button-secondary:hover, #login form .submit input:hover { + border-color: #328ab2; +} + +.submitbox #autosave .error, ul.view-switch li.current a { + color: #333; +} + +.submitbox #previewview { + background-color: #2683ae; +} + +.submitbox #previewview a, #rightnow .rbutton { + background-color: #ebebeb; + color: #264761; +} + +.submitbox .submit { + background-color: #464646; + color: #ccc; +} + +.submitbox .submitdelete { + border-bottom-color: #999; +} + +.submitbox .submitdelete:hover { + color: #fff; + background-color: #f00; + border-bottom-color: #f00; +} + +.tablenav .dots { + background-color: #e4f2fd; + border-color: #e4f2fd; +} + +.tablenav .next, .tablenav .prev{ + background-color: #e4f2fd; + border-bottom-color: #2583ad; + border-color: #e4f2fd; + color: #2583ad; +} + +.tablenav .next:hover, .tablenav .prev:hover { + border-bottom-color: #d54e21; + border-color: #e4f2fd; + color: #d54e21; +} + +.updated, .login #login_error, .login .message { + background-color: #ffffe0; + border-color: #e6db55; +} + +.updated a { + border-bottom-color: #2583ad; +} + +.widefat td, .widefat th, div#available-widgets-filter, ul#widget-list li.widget-list-item, .commentlist li { + border-bottom-color: #ccc; +} + +.widefat thead, .thead { + background-color: #464646; + color: #d7d7d7; +} + +.widget-control-save, .widget-control-remove { + background-color: #cee1ef; + color: #246; +} + +.wrap h2 { + border-bottom-color: #dadada; + color: #666; +} + +#adminmenu a, #submenu a, #poststuff #edButtonPreview, #poststuff #edButtonHTML, #the-comment-list p.comment-author strong a, a { + color: #2583ad; +} + +/* Because we don't want visited on these links */ +#adminmenu a.current, #sidemenu a.current { + background-color: #fff; + border-color: #c6d9e9; + border-bottom-color: #fff; + color: #d54e21; +} + +#adminmenu li a #awaiting-mod { + background-image: url(../images/comment-stalk-fresh.gif); +} + +#adminmenu li a #awaiting-mod span, #rightnow .reallynow { + background-color: #d54e21; + color: #fff; +} + +#adminmenu li a:hover #awaiting-mod span { + background-color: #264761; +} + +#adminmenu, div#media-upload-header { + background-color: #e4f2fd; + border-bottom-color: #c6d9e9; +} + +#currenttheme img { + border-color: #666; +} + +#current-widgets .drop-widget-here { + background-color: #ffc; +} + +#dashboard_secondary div.dashboard-widget-content ul li a { + background-color: #f9f9f9; +} + +input.readonly { + background-color: #ddd; +} + +#dashmenu a.current { + background-color: #e4f2fd; + color: #555; +} + +#dragHelper h4.widget-title, li.widget-list-control-item h4, #dragHelper li.widget-list-control-item h4 { + background-color: #2683ae; + color: #fff; +} + +#ed_toolbar input { + background: url( ../images/fade-butt.png ) #fff repeat-x 0 -2px; +} + +#editable-post-name { + background-color: #fffbcc; +} + +#edit-slug-box strong, .login #nav a { + color: #777; +} + +#edit-slug-buttons a.save { + background-color: #ebebeb; +} + +#footer { + background: url(../images/logo-ghost.png) #464646 no-repeat 20px 10px; + color: #999; +} + +#media-items { + border-color: #c0c0c0; +} + +#pass-strength-result { + background-color: #e3e3e3; + border-color: #000; +} + +#pass-strength-result.bad { + background-color: #ffeff7; + border-color: #c69; +} + +#pass-strength-result.good { + background-color: #effff4; + border-color: #66cc87; +} + +#pass-strength-result.short { + background-color: #e3e3e3; +} + +#pass-strength-result.strong { + background-color: #59ef86; + border-color: #319f52; +} + +#plugins .active, .checkbox, .side-info, #your-profile #rich_editing { + background-color: #fff; +} + +#plugins .togl { + border-right-color: #ccc; +} + +#plugins tr, #the-comment-list .unapproved { + background-color: #f0f0f0; +} + +#poststuff #editor-toolbar .active { + background-color: #cee1ef; + color: #333; +} + +#poststuff .closed .togbox { + background-color: #2583ad; + background-image: url(../images/toggle-arrow.gif); +} + +#poststuff .postbox, #titlediv, #poststuff .postarea, #poststuff .stuffbox { + border-color: #ebebeb; + border-right-color: #ccc; + border-bottom-color: #ccc; +} + +#poststuff .togbox { + background-color: #b2b2b2; + background-image: url(../images/toggle-arrow.gif); +} + +#quicktags #ed_link { + color: #00f; +} + +#rightnow .youhave { + background-color: #f0f6fb; +} + +#rightnow a { + color: #448abd; +} + +#sidemenu a { + background-color: #e4f2fd; + border-bottom-color: #c6d9e9; + border-top-color: #e4f2fd; +} + +#tagchecklist span a { + background: url(../images/xit.gif) no-repeat; +} + +#tagchecklist span a:hover { + background: url(../images/xit.gif) no-repeat -10px 0; +} + +#the-comment-list .comment a { + border-bottom-color: #ababab; + color: #666; +} + +#update-nag a:link, .plugin-update a:link { + color: #036; +} + +#update-nag, .plugin-update { + background-color: #fffeeb; + border-bottom-color: #ccc; + border-top-color: #ccc; + color: #555; +} + +#upload-files a.file-link { + background-color: #d1e2ef; +} + +#upload-file-view a img { + border-bottom-color: #69c; +} + +#upload-menu li #current-tab-nav, #upload-file { + background-color: #f9fcfe; +} + +#upload-menu li span a.page-numbers { + color: #00019b; +} + +#upload-menu li.current { + border-right-color: #448abd; + color: #000; +} + +#upload-menu li.current a.upload-tab-link, #upload-menu li a:hover { + background-color: #f9fcfe; + color: #000; +} + +#upload-menu, #upload-menu li { + border-top-color: #247fab; +} + +#user_info, .login #backtoblog a, .curtime { + color: #ccc; +} + +#wphead { + background-color: #e4f2fd; +} + +#wphead, body.login { + border-top-color: #464646; +} + +#wphead #viewsite a { + background-color: #c6d9e9; + color: #246; + border-color: #94acc1; +} + +#wphead #viewsite a:hover { + border-color: #246; +} + +#wphead h1, #dashmenu a.current:hover, #login form input { + color: #555; +} + +div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover, .delete:hover { + color: #f00; +} + +#media-upload a.delete { + color: #888; +} + +/* TinyMCE */ +.wp_themeSkin *, +.wp_themeSkin a:hover, +.wp_themeSkin a:link, +.wp_themeSkin a:visited, +.wp_themeSkin a:active { + color: #000; +} + +/* Containers */ +.wp_themeSkin table { + background: #cee1ef; +} + +.wp_themeSkin iframe { + background: #fff; +} + +/* Layout */ +.wp_themeSkin .mceStatusbar { + color:#000; + background-color: #eaf3fa; +} + +/* Button */ +.wp_themeSkin .mceButton { + background-color: #e9e8e8; + border-color: #abc0fb; +} + +.wp_themeSkin a.mceButtonEnabled:hover, +.wp_themeSkin a.mceButtonActive, +.wp_themeSkin a.mceButtonSelected { + background-color: #d6d8da; + border-color: #7789ba !important; +} + +.wp_themeSkin .mceButtonDisabled { + border-color: #bdd !important; +} + +/* ListBox */ +.wp_themeSkin .mceListBox .mceText, +.wp_themeSkin .mceListBox .mceOpen { + border-color: #abc0fb; + background-color: #e9e8e8; +} + +.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen, +.wp_themeSkin .mceListBoxHover .mceOpen, +.wp_themeSkin .mceListBoxSelected .mceOpen, +.wp_themeSkin .mceListBoxSelected .mceText { + border-color: #7789ba !important; + background-color: #d6d8da; +} + +.wp_themeSkin table.mceListBoxEnabled:hover .mceText, +.wp_themeSkin .mceListBoxHover .mceText { + border-color: #7789ba !important; +} + +.wp_themeSkin select.mceListBox { + border-color: #b3c7e1; + background-color: #fff; +} + +/* SplitButton */ +.wp_themeSkin .mceSplitButton a.mceAction, +.wp_themeSkin .mceSplitButton a.mceOpen { + background-color: #e9e8e8; + border-color: #abc0fb; +} + +.wp_themeSkin .mceSplitButton a.mceOpen:hover, +.wp_themeSkin .mceSplitButtonSelected a.mceOpen, +.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction, +.wp_themeSkin .mceSplitButton a.mceAction:hover { + background-color: #d6d8da; + border-color: #7789ba !important; +} + +.wp_themeSkin .mceSplitButtonActive { + background-color: #d6d8da; +} + +/* ColorSplitButton */ +.wp_themeSkin div.mceColorSplitMenu table { + background-color: #ebeaeb; + border-color: #808080; +} + +.wp_themeSkin .mceColorSplitMenu a { + border-color: #808080; +} + +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors { + border-color: #fff; +} + +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover { + border-color: #0A246A; + background-color: #B6BDD2; +} + +.wp_themeSkin a.mceMoreColors:hover { + border-color: #0A246A; +} + +/* Menu */ +.wp_themeSkin .mceMenu { + border-color: #ddd; +} + +.wp_themeSkin .mceMenu table { + background-color: #ebeaeb; +} + +.wp_themeSkin .mceMenu .mceText { + color: #000; +} + +.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover, +.wp_themeSkin .mceMenu .mceMenuItemActive { + background-color: #CEE1EF; +} +.wp_themeSkin td.mceMenuItemSeparator { + background-color: #aaa; +} +.wp_themeSkin .mceMenuItemTitle a { + background-color: #ccc; + border-bottom-color: #aaa; +} +.wp_themeSkin .mceMenuItemTitle span.mceText { + color: #000; +} +.wp_themeSkin .mceMenuItemDisabled .mceText { + color: #888; +} + +/* pop-up */ +.clearlooks2 .mceTop .mceLeft, .clearlooks2 .mceTop .mceRight { + background-color: #cee1ef; + border-color: #c6d9e9; +} + +.clearlooks2 .mceFocus .mceTop .mceLeft, .clearlooks2 .mceFocus .mceTop .mceRight { + background-color: #2683ae; + border-color: #464646; +} + +#editorcontainer { + border-color: #ccc; +} + +#poststuff #titlewrap { + border-color: #ccc; +} + +.curtime { + color: #666; +} \ No newline at end of file diff --git a/wp-admin/css/dashboard.css b/wp-admin/css/dashboard.css new file mode 100644 index 0000000..003e8e3 --- /dev/null +++ b/wp-admin/css/dashboard.css @@ -0,0 +1,283 @@ +/* Right Now */ + +#rightnow { + border-width: 1px; + border-style: solid; + padding: 2px; + margin-top: 10px; + margin-right: 7px; +} + +#rightnow .reallynow { + padding: 6px; + font-size: 15px; + line-height: 2; + margin: 0; +} + +#rightnow .rbutton { + font-weight: normal; + padding: 6px; + border-bottom: none; + -moz-border-radius: 2px; + -khtml-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px; + text-decoration: none; +} + +#rightnow .reallynow span { + display: block; + text-align: left; + float: left; + padding: 0 6px; +} + +#rightnow .reallynow a { + display: block; + text-align: right; + float: right; + padding: 0 6px; + font-size: 14px; + margin: 1px 6px 0 0; +} + +#rightnow .youhave { + font-size: 14px; + padding: 10px; +} + +#rightnow h3, #rightnow p { + padding: 0 10px; +} + +#rightnow a { + font-weight: bold; +} + +/* Widgets */ + +div#dashboard-widgets-wrap { + margin-top: -20px; + margin-right: -13px; /* 20 (div.dashboard-widget margin-right) - 7 (#rightnow margin-right) */ +} + +div#dashboard-widgets { + width: 100%; + padding-right: 7px; /* (#rightnow margin-right) */ +} + +div.dashboard-widget-holder { + margin-top: 20px; + width: 50%; + float: left; +} + +div.dashboard-widget-holder.third { + width: 33.3%; +} + +div.dashboard-widget-holder.fourth { + width: 25%; +} + +div.dashboard-widget-holder.full { + width: 100%; +} + +div.dashboard-widget-holder.double div.dashboard-widget { + height: 52em; + padding-bottom: 28px /* lame */ +} + +div.dashboard-widget { + position: relative; + margin-right: 20px; + border-width: 1px; + border-style: solid; + padding: 2px; + height: 27em; + overflow: auto; + font-size: 11px; +} + +h3.dashboard-widget-title { + margin: 0; + padding: 0 7px; + font-size: 14px; + line-height: 2; +} + +h3.dashboard-widget-title span { + display: block; + text-align: left; + float: left; +} + +h3.dashboard-widget-title small { + display: block; + text-align: right; + float: right; + font-size: 75%; + line-height: 2.67; /* math: it works, bitches */ +} + +h3.dashboard-widget-title img.rss-icon { + vertical-align: middle; + margin: .5em 0; +} + +div.dashboard-widget-notice { + padding: 0 14px; + font-size: 1.2em; + line-height: 2; +} + +div.dashboard-widget-error { + padding: 0 20px; + font-size: 1.2em; + line-height: 2; +} + +div.dashboard-widget-content { + padding: 10px 15px; +} + +div.dashboard-widget-submit { + border-top: 1px solid #ccc; + padding: 1em 0 0 0; + margin: 10px 0 0 0; +} +div.dashboard-widget-submit input { + font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + padding: 4px 6px; + border: none; + font-size: 13px; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + cursor: pointer; + text-decoration: none; +} + +div.dashboard-widget-content ul, div.dashboard-widget-content ol, div.dashboard-widget-content dl { + margin: 0; + text-indent: 0; + padding-left: 15px; +} +div.dashboard-widget-content li { + margin: .5em 0 1em; +} + +div.dashboard-widget-content blockquote { + margin: -1em 0; +} + +div#dashboard_recent_comments p { + font-size: 14px; +} + +div.dashboard-widget-content p.comment-meta { + font-size: 11px !important; +} + +#dashboard_secondary div.dashboard-widget { + height: auto; +} + +#dashboard_secondary div.dashboard-widget-content ul { + list-style: none; + padding: 0; +} + +#dashboard_secondary div.dashboard-widget-content ul li { + display: block; + width: 19.95%; + padding-bottom: 10px; + margin: 0; + float: left; + font-size: 95%; +} + +#dashboard_secondary div.dashboard-widget-content { + margin: 10px 5px; + padding: 0; +} + +#dashboard_secondary div.dashboard-widget-content ul li .post { + display:block; + font-family:Georgia,"Times New Roman",Times,serif; + font-size:18px; + line-height: 1.2em; + height:90px; + overflow:hidden; +} + +#dashboard_secondary div.dashboard-widget-content ul li a { + display: block; + height:100%; + overflow:hidden; + margin: 5px 10px; + text-decoration: none; + padding: .5em; + border-right: 1px solid #dadada; + border-bottom: 1px solid #dadada; +} + +#dashboard_secondary div.dashboard-widget-content ul li a cite { + display: block; + font-family: "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; +} + +#dashboard-widgets .widget_rss ul { + list-style: none; + padding: 0; +} + +#dashboard-widgets .widget_rss ul li { + clear: both; +} + +#dashboard-widgets .widget_rss ul li span.rss-date { + float: left; + margin: 0; +} + +#dashboard-widgets .widget_rss ul li a { + float: left; + margin: 0 .5em .2em 0; + font-weight: bold; +} + +#dashboard-widgets .widget_rss ul li div { + clear: both; + line-height: 1.5em; +} + +#dashboard_primary a.rsswidget, #dashboard_plugins h5 { + font-size: 14px; +} + +#dashboard_primary span.rss-date { + font-size: 14px; +} + +#dashboard_plugins h4 { + font-size: 1em; + margin: 0 0 .1em; +} + +#dashboard_plugins h5 { + margin: 0; + display: inline; + line-height: 1.4em; +} + +#dashboard_plugins p { + margin: 0 0 1em; + line-height: 1.5em; +} + +.widget-loading { +} diff --git a/wp-admin/css/global.css b/wp-admin/css/global.css new file mode 100644 index 0000000..5bd9e2f --- /dev/null +++ b/wp-admin/css/global.css @@ -0,0 +1,126 @@ +/* styles for use by people extending the WordPress interface */ + + +body { + margin: 0; + padding: 0; +} + +body, td { + font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; +} + +form, label input { margin: 0; padding: 0; } + +img { border: 0; } + +label { cursor: pointer; } + +li, dd { margin-bottom: 6px; } + +p, li, dl, dd, dt { line-height: 140%; } + +textarea, input, select { + font: 13px Verdana, Arial, Helvetica, sans-serif; + margin: 1px; + padding: 3px; +} + +.alignleft { float: left; } + +.alignright { float: right; } + + +.clear { clear: both; height: 2px; } + +.hidden { display: none; } + +.subsubsub { + list-style: none; + margin: 15px 0 10px 0; + padding: 0; + white-space: nowrap; + font-size: 12px; +} + +.subsubsub a { line-height: 200%; padding: 3px; text-decoration: none; } + +.subsubsub a.current { font-weight: bold; background: none; border: none;} + +.subsubsub li { display: inline; margin: 0; padding: 0; } + +.widefat { + border-width: 1px; + border-style: solid; + border-collapse: collapse; + width: 100%; + clear: both; +} + +.widefat a { + text-decoration: none; +} + +.widefat td, .widefat th { + border-bottom-width: 1px; + border-bottom-style: solid; + border-bottom-color: #ccc; + font-size: 12px; + padding: 10px 10px 20px; + vertical-align: text-top; +} + +.widefat th { + padding-bottom: 8px; + padding-top: 10px; + text-align: left; +} + +.widefat .check-column { + text-align: center; + vertical-align: text-top; + width: 3%; +} + +.wrap, .updated, .error { + margin: 0; + margin-left: 15px; + margin-right: 15px; + padding: 0; + max-width: 980px; +} + +.updated, .error { + border-width: 1px; + border-style: solid; + padding: 0 15px; + max-width: 950px; + margin-bottom: 1em; +} + +.wrap .updated, .wrap .error { + margin: auto 0 0; +} + +.updated a, .error a { + text-decoration: underline; +} + +.updated a { + text-decoration: none; + padding-bottom: 2px; +} + +.wrap h2 { + border-bottom-width: 1px; + border-bottom-style: solid; + clear: both; + font: 24px Georgia, "Times New Roman", Times, serif; + margin: 5px 0 0 -4px; + padding: 0; + padding-bottom: 7px; +} + +#timestampdiv { + display: none; +} \ No newline at end of file diff --git a/wp-admin/css/ie.css b/wp-admin/css/ie.css new file mode 100644 index 0000000..dd7deaa --- /dev/null +++ b/wp-admin/css/ie.css @@ -0,0 +1,58 @@ +/* Fixes for IE bugs */ + +#poststuff .postbox h3 { + padding-left: 23px; +} + +#submenu li a.current { + background:none; + border:none; +} + +* html body.minwidth { + _width: expression(document.documentElement.clientWidth < 810 ? "808px" : "99.9%"); +} + +* html #wpbody { + _width: expression(document.documentElement.clientWidth > 982 ? "980px" : "99.9%"); +} + +* html #poststuff .postarea, * html #poststuff #titlediv { + width: 95%; + margin-left: 3%; +} + +.submitbox { + margin-top: 10px; +} + +* html div.widget-liquid-left-holder, * html div.widget-liquid-right { + display: block; + position: relative; +} + +#wpwrap, #wpcontent, #post, #wrap, #postdivrich, #postdiv, #poststuff, #titlediv, #post-body, #editorcontainer, .tablenav, .widget-control-list { + display: block; + zoom: 100%; +} + +* html #editorcontainer { + padding: 0; +} + +* html #editorcontainer #content { + position: relative; + overflow: auto; + padding: 6px; + margin: auto; + width: 98%; +} + +form#template div { + width: 100%; +} + +#ed_toolbar input { + overflow: visible; + padding: 1px 5px; +} diff --git a/wp-admin/css/login.css b/wp-admin/css/login.css new file mode 100644 index 0000000..92f10bc --- /dev/null +++ b/wp-admin/css/login.css @@ -0,0 +1,74 @@ +* { margin: 0; padding: 0; } + +body { + border-top-width: 30px; + border-top-style: solid; + font: 12px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; +} + +form { + margin-left: 8px; + padding: 16px 16px 40px 16px; + font-weight: bold; + -moz-border-radius: 5px; + -khtml-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; +} + +form .forgetmenot { font-weight: normal; float: left; margin-bottom: 0;} + +#login form .submit input { + font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + padding: 3px 5px; + border: none; + font-size: 13px; + border-width: 1px; + border-style: solid; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + cursor: default; + text-decoration: none; + margin-top: -6px; +} + +form .submit { float: right; } + +form p { margin-bottom: 24px; } + +h1 a { + background: url(../images/logo-login.gif) no-repeat; + width: 292px; + height: 66px; + text-indent: -9999px; + overflow: hidden; + padding-bottom: 15px; + display: block; +} + +#backtoblog a { + position: absolute; + top: 7px; + left: 15px; + text-decoration: none; +} + +#login { width: 292px; margin: 7em auto; } + +#login_error, .message { + margin: 0 0 16px 8px; + border-width: 1px; + border-style: solid; + padding: 12px; +} + +#nav { margin: 0 0 0 8px; padding: 16px; } + +#user_pass, #user_login, #user_email { + font-size: 20px; + width: 97%; + padding: 3px; + margin-right: 6px; +} \ No newline at end of file diff --git a/wp-admin/css/media.css b/wp-admin/css/media.css new file mode 100644 index 0000000..a5b354e --- /dev/null +++ b/wp-admin/css/media.css @@ -0,0 +1,238 @@ +div#media-upload-header { + margin: 0; + padding: 0 5px; + font-weight: bold; + position: relative; + border-bottom-width: 1px; + border-bottom-style: solid; + height: 2.5em; +} + +ul#sidemenu { + font-weight: normal; + margin: 0 5px; + position: absolute; + left: 0px; + bottom: -1px; +} + +div#media-upload-error { + margin: 1em; + font-weight: bold; +} + +form { + margin: 1em; +} + +#search-filter { + text-align: right; +} + +.media-upload-form label, .media-upload-form legend { + display:block; + font-weight: bold; + margin-bottom: 0.5em; + margin: 0 0 0.5em 0; +} + +th { position: relative; } + +.media-upload-form label.form-help, td.help { + font-style: italic; + font-weight: normal; +} + +.media-upload-form p.help { + margin: 0; + padding: 0; +} + +.media-upload-form fieldset { + width: 100%; + border: none; + text-align: justify; + margin: 0 0 1em 0; + padding: 0; +} + +/* specific to the image upload form */ +.align .field label { + display: inline; + padding: 0 0 0 28px; + margin: 0 1em 0 0; +} +.image-align-none-label { + background: url(../images/align-none.png) no-repeat center left; +} + +.image-align-left-label { + background: url(../images/align-left.png) no-repeat center left; +} + +.image-align-center-label { + background: url(../images/align-center.png) no-repeat center left; +} + +.image-align-right-label { + background: url(../images/align-right.png) no-repeat center left; +} + +#flash-upload-ui, .insert-gallery { + display: none; +} + +tr.image-size label { + display: inline; + margin: 0 1em 0 0; +} +.pinkynail { + max-width: 40px; + max-height: 40px; +} + +.filename { + display: none; +} +button.dismiss { + position: absolute; + top: 5px; + right: 5px; + z-index: 4; +} +.file-error { + margin: 0 0 5px 50px; + font-weight: bold; +} + +.progress { + position: absolute; + top: 0px; + left: 0px; + width: 623px; + height: 36px; +} +.bar { + width: 0px; + height: 100%; + border-right-width: 3px; + border-right-style: solid; +} +.media-item .thumbnail { + max-width: 128px; + max-height: 128px; +} +.media-item .pinkynail { + position: absolute; + top: 2px; + left: 2px; + height: 32px; + max-width: 40px; +} + +tbody.media-item-info tr { + background-color: transparent; +} +tbody.media-item-info th, tbody.media-item-info td { + border: none; + margin: 0; +} + +.form-table tbody.media-item-info { + border: 8px solid #fff; +} + +.describe.startopen, .describe.startclosed { + display: none; +} +abbr.required { + text-decoration: none; + border: none; +} +.describe label { + display: inline; +} +.describe td { + vertical-align: middle; +} +.describe td.A1 { + width: 132px; +} +.describe input[type="text"], .describe textarea { + width: 460px; +} +.describe-toggle-on, .describe-toggle-off { + display: block; + line-height: 36px; + z-index: 2; + position: absolute; + top: 0px; + right: 20px; +} +.describe-toggle-off { + display: none; +} +.clickmask { + background: transparent; + position: absolute; + top: 0px; + left: 0px; + cursor: pointer; + border: none; + z-index: 3; + height: 36px; +} + +.hidden { + height: 0px; + width: 0px; + overflow: hidden; + border: none; +} + +/* Specific to Uploader */ + +#media-upload .media-upload-form p { + margin: 0 1em 1em 0; +} +#media-upload p.help { + font-style: italic; + font-weight: normal; +} +#media-upload tr.image-size td.field { + text-align: center; +} +#media-upload #media-items { + border-width: 1px; + border-style: solid; + border-bottom: none; + width: 623px; +} + +#media-upload .media-item { + border-bottom-width: 1px; + border-bottom-style: solid; + width: 623px; + position: relative; + min-height: 36px; +} +#media-upload .filename { + display: block; + line-height: 36px; + margin-left: 50px; + z-index: 2; +} +#media-upload .describe { + border-top-width: 1px; + border-top-style: solid; + padding: 5px; + width: 100%; + clear: both; +} +#media-upload .describe th.label { + padding-top: .5em; + text-align: left; +} +#media-upload tr.align td.field { + text-align: center; +} \ No newline at end of file diff --git a/wp-admin/css/theme-editor.css b/wp-admin/css/theme-editor.css new file mode 100644 index 0000000..eaaa946 --- /dev/null +++ b/wp-admin/css/theme-editor.css @@ -0,0 +1,44 @@ +#template textarea { + font-family: 'Courier New', Courier, monospace; + font-size: 12px; + width: 97%; +} + +#template p { + width: 97%; +} + +#templateside { + float: right; + width: 190px; + margin-top:-3.4em; +} + +#templateside h3, #postcustomstuff p.submit { + margin: 0; +} + +#templateside ol, #templateside ul { + list-style: none; + margin: .5em; + padding: 0; +} + +#templateside ol li, #templateside ul li { + margin: 1px 0px; +} + +#themeselector { + padding-right: 5px; + float: right; + position: relative; + bottom: 25px; +} + +.nonessential { + font-size: small; +} + +.highlight { + padding: 1px; +} \ No newline at end of file diff --git a/wp-admin/css/upload-rtl.css b/wp-admin/css/upload-rtl.css deleted file mode 100644 index dc13a4b..0000000 --- a/wp-admin/css/upload-rtl.css +++ /dev/null @@ -1,12 +0,0 @@ -html { - direction: ltr; - } -#uploadoptions, table { - direction: rtl; - } -td { - padding: 1px 6px 0; - } -.submit { - text-align: left; - } \ No newline at end of file diff --git a/wp-admin/css/upload.css b/wp-admin/css/upload.css deleted file mode 100644 index 009986c..0000000 --- a/wp-admin/css/upload.css +++ /dev/null @@ -1,204 +0,0 @@ -body { background: #f9fcfe; } - -.upload-file-data { display: none; } - -#upload-menu { - border-top: 2em solid #247fab; - margin: 0; - padding: 0; - height: 0; - list-style: none; - width: 100%; -} - -body > #upload-menu { border-bottom: 7px solid #fff; } - -#upload-menu li { - margin: 0; - position: relative; - top: -2em; - padding-bottom: 5px; - border: none; - border-top: 3px solid #247fab; -} - -#upload-menu li a.upload-tab-link { - margin-left: 0.75em; - padding: 5px 5px 0; - display: block; - float: left; - height: 100%; - text-decoration: none; - border-bottom: none; - color: #fff; -} - -#upload-menu li.current { - border-right: 2px solid #448abd; - color: #000; -} - -#upload-menu li.current a.upload-tab-link, #upload-menu li a:hover { - background: #f9fcfe; - color: #000; -} - -#upload-menu li #current-tab-nav { - background: #f9fcfe; - float: left; - padding: 5px 5px 0 0; - margin-left: -5px; -} - -#upload-menu li span .page-numbers { - padding: 0; - border: none; -} - -#upload-menu li span a.page-numbers { color: #00019b; } -#upload-menu li span a.page-numbers:hover { text-decoration: underline; } - -#upload-content { - position: relative; - clear: both; - margin: 0; - padding: 0; - border: none; - width: 100%; - height: 100%; - background: none; -} - -#upload-file { - margin: 0 auto; - top: 0; - left: 0; - width: 95%; - height: 100%; - background: #f9fcfe; -} - -#upload-file th { - width: 8em; -} - -form#upload-file input, form#upload-file textarea, div#upload-content.upload table { width: 100%; } - -form#upload-file .submit input { width: auto; } - -#upload-file-view { padding: 0 0 0 75px; } - -#file-title { - margin: 0 0 .2em 75px; - padding: 0; - display: block; - font-family: Georgia, "Times New Roman", Times, serif; - font-size: 16px; -} - -h2 { - margin: 0 .2em 0 0; - padding: 0; - display: inline; - border: none; - color: #000; - font-size: 1.4em; - line-height: 1.4em; -} - -.wrap h2 { - margin: .4em 0 .5em; - display: block; - border-bottom: .5em solid #e5f3ff; - color: #333; - font: normal 32px/5px serif; - clear: both; -} - -* html .wrap h2 { - margin-top: 1em; -} - -.back { - display: block; - position: absolute; - left: 14px; - top: 10px; -} - -#upload-files { - list-style-type: none; - margin: 0; - padding: 15px 0 0; -} - -#upload-files li { margin: 0 0 15px 15px; } - -#upload-files a, #upload-file-view a, a.file-link { - border: none; - text-decoration: none; -} - -#upload-file-view a img { padding-bottom: .2em; border-bottom: 1px solid #6699CC; } - -#upload-files a.file-link { - display: block; - width: 130px; - height: 128px; - background-color: rgb(209, 226, 239); - text-align: center; - overflow: hidden; -} - -#upload-files a.text { - padding-top: 40px; - height: 88px; - font-size: 16px; -} - -#upload-files a.file-link.image { - font-size: 2px; - letter-spacing: 0; -} - -#upload-files a.file-link img { vertical-align: middle; } - -#the-attachment-links textarea { - font-size: 10px; - overflow: hidden; -} - -form table { float: none; padding: 0 15px; } - -table { - float: left; - margin: 0; - padding: 0; -} - -th { text-align: right; vertical-align: text-top; } - -tr, td, th { - margin-top: 0; - padding-top: 0; -} - -#uploadoptions th { - width: 80px; -} - -#uploadoptions p { - margin: 0; - padding: 0; -} - -#uploadoptions td { - padding-left: 1em; - line-height: 140%; -} - -#uploadoptions table { - width: 300px; -} - -input.readonly { background-color: #ddd; } diff --git a/wp-admin/edit-attachment-rows.php b/wp-admin/edit-attachment-rows.php new file mode 100644 index 0000000..8eb9066 --- /dev/null +++ b/wp-admin/edit-attachment-rows.php @@ -0,0 +1,138 @@ + + + + + + + + + + + + + +\n\t\n"; // Hack! +$class = ( $i_post > 15 || 'alternate' == $class) ? '' : 'alternate'; +global $current_user; +$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); +?> + post_status ); ?>' valign="top"> + +$column_display_name) { + + switch($column_name) { + + case 'cb': + ?> + + + + + + + + post_date && 'date' == $column_name ) { + $t_time = $h_time = __('Unpublished'); + } else { + $t_time = get_the_time(__('Y/m/d g:i:s A')); + $m_time = $post->post_date; + $time = get_post_time( 'G', true ); + if ( ( abs($t_diff = time() - $time) ) < 86400 ) { + if ( $t_diff < 0 ) + $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); + else + $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); + } else { + $h_time = mysql2date(__('Y/m/d'), $m_time); + } + } + ?> + + post_parent) ) { + $title = get_the_title($post->post_parent); + if ( empty($title) ) + $title = __('(no title)'); + } else { + $title = ''; + } + ?> + + + + + + + + + + + + + + + +
diff --git a/wp-admin/edit-tag-form.php b/wp-admin/edit-tag-form.php new file mode 100644 index 0000000..c3a6665 --- /dev/null +++ b/wp-admin/edit-tag-form.php @@ -0,0 +1,41 @@ +'; + $action = 'editedtag'; + $nonce_action = 'update-tag_' . $tag_ID; + do_action('edit_tag_form_pre', $tag); +} else { + $heading = __('Add Tag'); + $submit_text = __('Add Tag'); + $form = '
'; + $action = 'addtag'; + $nonce_action = 'add-tag'; + do_action('add_tag_form_pre', $tag); +} +?> + +
+

+
+ + + + + + + + + + + + + +
+

+

+

+ + +
diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php new file mode 100644 index 0000000..fe6b89f --- /dev/null +++ b/wp-admin/edit-tags.php @@ -0,0 +1,202 @@ + + + +

+ + +
+ +
+ +

add new)'), '#addtag') ?>

+ +

+ + +

+ + +

+ +
+ +
+ + add_query_arg( 'pagenum', '%#%' ), + 'format' => '', + 'total' => ceil(wp_count_terms('post_tag') / $tagsperpage), + 'current' => $pagenum +)); + +if ( $page_links ) + echo "
$page_links
"; +?> + +
+ + +
+ +
+
+ +
+ + + + + + + + + + + + +
+
+ +
+ +
+ +$page_links
"; +?> +
+
+ + + + + +
+ + + + + diff --git a/wp-admin/images/align-center.png b/wp-admin/images/align-center.png new file mode 100644 index 0000000..a412226 Binary files /dev/null and b/wp-admin/images/align-center.png differ diff --git a/wp-admin/images/align-left.png b/wp-admin/images/align-left.png new file mode 100644 index 0000000..2e433fc Binary files /dev/null and b/wp-admin/images/align-left.png differ diff --git a/wp-admin/images/align-none.png b/wp-admin/images/align-none.png new file mode 100644 index 0000000..5fb9af2 Binary files /dev/null and b/wp-admin/images/align-none.png differ diff --git a/wp-admin/images/align-right.png b/wp-admin/images/align-right.png new file mode 100644 index 0000000..9b92578 Binary files /dev/null and b/wp-admin/images/align-right.png differ diff --git a/wp-admin/images/box-bg-left.gif b/wp-admin/images/box-bg-left.gif deleted file mode 100644 index c3c7e35..0000000 Binary files a/wp-admin/images/box-bg-left.gif and /dev/null differ diff --git a/wp-admin/images/box-bg-right.gif b/wp-admin/images/box-bg-right.gif deleted file mode 100644 index 12a0d1a..0000000 Binary files a/wp-admin/images/box-bg-right.gif and /dev/null differ diff --git a/wp-admin/images/box-bg.gif b/wp-admin/images/box-bg.gif deleted file mode 100644 index 2eb7f58..0000000 Binary files a/wp-admin/images/box-bg.gif and /dev/null differ diff --git a/wp-admin/images/box-butt-left.gif b/wp-admin/images/box-butt-left.gif deleted file mode 100644 index 590c2ef..0000000 Binary files a/wp-admin/images/box-butt-left.gif and /dev/null differ diff --git a/wp-admin/images/box-butt-right.gif b/wp-admin/images/box-butt-right.gif deleted file mode 100644 index 487ebb3..0000000 Binary files a/wp-admin/images/box-butt-right.gif and /dev/null differ diff --git a/wp-admin/images/box-butt.gif b/wp-admin/images/box-butt.gif deleted file mode 100644 index 514a165..0000000 Binary files a/wp-admin/images/box-butt.gif and /dev/null differ diff --git a/wp-admin/images/box-head-left.gif b/wp-admin/images/box-head-left.gif deleted file mode 100644 index b03e075..0000000 Binary files a/wp-admin/images/box-head-left.gif and /dev/null differ diff --git a/wp-admin/images/box-head-right.gif b/wp-admin/images/box-head-right.gif deleted file mode 100644 index 897b03a..0000000 Binary files a/wp-admin/images/box-head-right.gif and /dev/null differ diff --git a/wp-admin/images/box-head.gif b/wp-admin/images/box-head.gif deleted file mode 100644 index 5c09a9a..0000000 Binary files a/wp-admin/images/box-head.gif and /dev/null differ diff --git a/wp-admin/images/bubble_bg.gif b/wp-admin/images/bubble_bg.gif new file mode 100644 index 0000000..c6f395a Binary files /dev/null and b/wp-admin/images/bubble_bg.gif differ diff --git a/wp-admin/images/comment-grey-bubble.png b/wp-admin/images/comment-grey-bubble.png new file mode 100644 index 0000000..6f1e765 Binary files /dev/null and b/wp-admin/images/comment-grey-bubble.png differ diff --git a/wp-admin/images/comment-pill.gif b/wp-admin/images/comment-pill.gif new file mode 100644 index 0000000..2fabf99 Binary files /dev/null and b/wp-admin/images/comment-pill.gif differ diff --git a/wp-admin/images/comment-stalk-classic.gif b/wp-admin/images/comment-stalk-classic.gif new file mode 100644 index 0000000..3cf83a5 Binary files /dev/null and b/wp-admin/images/comment-stalk-classic.gif differ diff --git a/wp-admin/images/comment-stalk-fresh.gif b/wp-admin/images/comment-stalk-fresh.gif new file mode 100644 index 0000000..9048949 Binary files /dev/null and b/wp-admin/images/comment-stalk-fresh.gif differ diff --git a/wp-admin/images/date-button.gif b/wp-admin/images/date-button.gif new file mode 100644 index 0000000..7ee32cb Binary files /dev/null and b/wp-admin/images/date-button.gif differ diff --git a/wp-admin/images/heading-bg.gif b/wp-admin/images/heading-bg.gif deleted file mode 100644 index bea18ca..0000000 Binary files a/wp-admin/images/heading-bg.gif and /dev/null differ diff --git a/wp-admin/images/login-bkg-bottom.gif b/wp-admin/images/login-bkg-bottom.gif deleted file mode 100644 index a78656e..0000000 Binary files a/wp-admin/images/login-bkg-bottom.gif and /dev/null differ diff --git a/wp-admin/images/login-bkg-tile.gif b/wp-admin/images/login-bkg-tile.gif deleted file mode 100644 index 1015a9e..0000000 Binary files a/wp-admin/images/login-bkg-tile.gif and /dev/null differ diff --git a/wp-admin/images/logo-login.gif b/wp-admin/images/logo-login.gif new file mode 100644 index 0000000..276faf1 Binary files /dev/null and b/wp-admin/images/logo-login.gif differ diff --git a/wp-admin/images/media-button-gallery.gif b/wp-admin/images/media-button-gallery.gif new file mode 100644 index 0000000..1191778 Binary files /dev/null and b/wp-admin/images/media-button-gallery.gif differ diff --git a/wp-admin/images/media-button-image.gif b/wp-admin/images/media-button-image.gif new file mode 100644 index 0000000..11278c8 Binary files /dev/null and b/wp-admin/images/media-button-image.gif differ diff --git a/wp-admin/images/media-button-music.gif b/wp-admin/images/media-button-music.gif new file mode 100644 index 0000000..f85cd43 Binary files /dev/null and b/wp-admin/images/media-button-music.gif differ diff --git a/wp-admin/images/media-button-other.gif b/wp-admin/images/media-button-other.gif new file mode 100644 index 0000000..f3f2f8a Binary files /dev/null and b/wp-admin/images/media-button-other.gif differ diff --git a/wp-admin/images/media-button-video.gif b/wp-admin/images/media-button-video.gif new file mode 100644 index 0000000..ceb2734 Binary files /dev/null and b/wp-admin/images/media-button-video.gif differ diff --git a/wp-admin/images/media-buttons.gif b/wp-admin/images/media-buttons.gif new file mode 100644 index 0000000..2266040 Binary files /dev/null and b/wp-admin/images/media-buttons.gif differ diff --git a/wp-admin/images/notice.gif b/wp-admin/images/notice.gif deleted file mode 100644 index ba6eab0..0000000 Binary files a/wp-admin/images/notice.gif and /dev/null differ diff --git a/wp-admin/images/tail.gif b/wp-admin/images/tail.gif new file mode 100644 index 0000000..3f8e7d5 Binary files /dev/null and b/wp-admin/images/tail.gif differ diff --git a/wp-admin/images/toggle-arrow.gif b/wp-admin/images/toggle-arrow.gif new file mode 100644 index 0000000..86cb448 Binary files /dev/null and b/wp-admin/images/toggle-arrow.gif differ diff --git a/wp-admin/images/toggle.gif b/wp-admin/images/toggle.gif deleted file mode 100644 index 72e8b44..0000000 Binary files a/wp-admin/images/toggle.gif and /dev/null differ diff --git a/wp-admin/images/xit.gif b/wp-admin/images/xit.gif new file mode 100644 index 0000000..6f1cc4f Binary files /dev/null and b/wp-admin/images/xit.gif differ diff --git a/wp-admin/includes/class-ftp-pure.php b/wp-admin/includes/class-ftp-pure.php new file mode 100644 index 0000000..5ef92bf --- /dev/null +++ b/wp-admin/includes/class-ftp-pure.php @@ -0,0 +1,175 @@ +__construct($verb, $le); + } + + function __construct($verb=FALSE, $le=FALSE) { + parent::__construct(false, $verb, $le); + } + +// +// +// + + function _settimeout($sock) { + if(!@stream_set_timeout($sock, $this->_timeout)) { + $this->PushError('_settimeout','socket set send timeout'); + $this->_quit(); + return FALSE; + } + return TRUE; + } + + function _connect($host, $port) { + $this->SendMSG("Creating socket"); + $sock = @fsockopen($host, $port, $errno, $errstr, $this->_timeout); + if (!$sock) { + $this->PushError('_connect','socket connect failed', $errstr." (".$errno.")"); + return FALSE; + } + $this->_connected=true; + return $sock; + } + + function _readmsg($fnction="_readmsg"){ + if(!$this->_connected) { + $this->PushError($fnction, 'Connect first'); + return FALSE; + } + $result=true; + $this->_message=""; + $this->_code=0; + $go=true; + do { + $tmp=@fgets($this->_ftp_control_sock, 512); + if($tmp===false) { + $go=$result=false; + $this->PushError($fnction,'Read failed'); + } else { + $this->_message.=$tmp; + if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go=false; + } + } while($go); + if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF; + $this->_code=(int)$regs[1]; + return $result; + } + + function _exec($cmd, $fnction="_exec") { + if(!$this->_ready) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + if($this->LocalEcho) echo "PUT > ",$cmd,CRLF; + $status=@fputs($this->_ftp_control_sock, $cmd.CRLF); + if($status===false) { + $this->PushError($fnction,'socket write failed'); + return FALSE; + } + $this->_lastaction=time(); + if(!$this->_readmsg($fnction)) return FALSE; + return TRUE; + } + + function _data_prepare($mode=FTP_ASCII) { + if(!$this->_settype($mode)) return FALSE; + if($this->_passive) { + if(!$this->_exec("PASV", "pasv")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ip_port = explode(",", ereg_replace("^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*".CRLF."$", "\\1", $this->_message)); + $this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3]; + $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]); + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout); + if(!$this->_ftp_data_sock) { + $this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")"); + $this->_data_close(); + return FALSE; + } + else $this->_ftp_data_sock; + } else { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + return TRUE; + } + + function _data_read($mode=FTP_ASCII, $fp=NULL) { + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + while (!feof($this->_ftp_data_sock)) { + $block=fread($this->_ftp_data_sock, $this->_ftp_buff_size); + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); + if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block)); + else $out.=$block; + } + return $out; + } + + function _data_write($mode=FTP_ASCII, $fp=NULL) { + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + if(is_resource($fp)) { + while(!feof($fp)) { + $block=fread($fp, $this->_ftp_buff_size); + if(!$this->_data_write_block($mode, $block)) return false; + } + } elseif(!$this->_data_write_block($mode, $fp)) return false; + return TRUE; + } + + function _data_write_block($mode, $block) { + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); + do { + if(($t=@fwrite($this->_ftp_data_sock, $block))===FALSE) { + $this->PushError("_data_write","Can't write to socket"); + return FALSE; + } + $block=substr($block, $t); + } while(!empty($block)); + return true; + } + + function _data_close() { + @fclose($this->_ftp_data_sock); + $this->SendMSG("Disconnected data from remote host"); + return TRUE; + } + + function _quit($force=FALSE) { + if($this->_connected or $force) { + @fclose($this->_ftp_control_sock); + $this->_connected=false; + $this->SendMSG("Socket closed"); + } + } +} +?> diff --git a/wp-admin/includes/class-ftp-sockets.php b/wp-admin/includes/class-ftp-sockets.php new file mode 100644 index 0000000..99b4050 --- /dev/null +++ b/wp-admin/includes/class-ftp-sockets.php @@ -0,0 +1,236 @@ +__construct($verb, $le); + } + + function __construct($verb=FALSE, $le=FALSE) { + parent::__construct(true, $verb, $le); + } + +// +// +// + + function _settimeout($sock) { + if(!@socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) { + $this->PushError('_connect','socket set receive timeout',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + if(!@socket_set_option($sock, SOL_SOCKET , SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) { + $this->PushError('_connect','socket set send timeout',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + return true; + } + + function _connect($host, $port) { + $this->SendMSG("Creating socket"); + if(!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) { + $this->PushError('_connect','socket create failed',socket_strerror(socket_last_error($sock))); + return FALSE; + } + if(!$this->_settimeout($sock)) return FALSE; + $this->SendMSG("Connecting to \"".$host.":".$port."\""); + if (!($res = @socket_connect($sock, $host, $port))) { + $this->PushError('_connect','socket connect failed',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + $this->_connected=true; + return $sock; + } + + function _readmsg($fnction="_readmsg"){ + if(!$this->_connected) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + $result=true; + $this->_message=""; + $this->_code=0; + $go=true; + do { + $tmp=@socket_read($this->_ftp_control_sock, 4096, PHP_BINARY_READ); + if($tmp===false) { + $go=$result=false; + $this->PushError($fnction,'Read failed', socket_strerror(socket_last_error($this->_ftp_control_sock))); + } else { + $this->_message.=$tmp; + $go = !preg_match("/^([0-9]{3})(-.+\\1)? [^".CRLF."]+".CRLF."$/Us", $this->_message, $regs); + } + } while($go); + if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF; + $this->_code=(int)$regs[1]; + return $result; + } + + function _exec($cmd, $fnction="_exec") { + if(!$this->_ready) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + if($this->LocalEcho) echo "PUT > ",$cmd,CRLF; + $status=@socket_write($this->_ftp_control_sock, $cmd.CRLF); + if($status===false) { + $this->PushError($fnction,'socket write failed', socket_strerror(socket_last_error($this->stream))); + return FALSE; + } + $this->_lastaction=time(); + if(!$this->_readmsg($fnction)) return FALSE; + return TRUE; + } + + function _data_prepare($mode=FTP_ASCII) { + if(!$this->_settype($mode)) return FALSE; + $this->SendMSG("Creating data socket"); + $this->_ftp_data_sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + if ($this->_ftp_data_sock < 0) { + $this->PushError('_data_prepare','socket create failed',socket_strerror(socket_last_error($this->_ftp_data_sock))); + return FALSE; + } + if(!$this->_settimeout($this->_ftp_data_sock)) { + $this->_data_close(); + return FALSE; + } + if($this->_passive) { + if(!$this->_exec("PASV", "pasv")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ip_port = explode(",", ereg_replace("^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*".CRLF."$", "\\1", $this->_message)); + $this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3]; + $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]); + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + if(!@socket_connect($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) { + $this->PushError("_data_prepare","socket_connect", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + else $this->_ftp_temp_sock=$this->_ftp_data_sock; + } else { + if(!@socket_getsockname($this->_ftp_control_sock, $addr, $port)) { + $this->PushError("_data_prepare","can't get control socket information", socket_strerror(socket_last_error($this->_ftp_control_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_bind($this->_ftp_data_sock,$addr)){ + $this->PushError("_data_prepare","can't bind data socket", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_listen($this->_ftp_data_sock)) { + $this->PushError("_data_prepare","can't listen data socket", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_getsockname($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) { + $this->PushError("_data_prepare","can't get data socket information", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!$this->_exec('PORT '.str_replace('.',',',$this->_datahost.'.'.($this->_dataport>>8).'.'.($this->_dataport&0x00FF)), "_port")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + } + return TRUE; + } + + function _data_read($mode=FTP_ASCII, $fp=NULL) { + $NewLine=$this->_eol_code[$this->OS_local]; + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock); + if($this->_ftp_temp_sock===FALSE) { + $this->PushError("_data_read","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return FALSE; + } + } + + while(($block=@socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ))!==false) { + if($block==="") break; + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); + if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block)); + else $out.=$block; + } + return $out; + } + + function _data_write($mode=FTP_ASCII, $fp=NULL) { + $NewLine=$this->_eol_code[$this->OS_local]; + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock); + if($this->_ftp_temp_sock===FALSE) { + $this->PushError("_data_write","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return false; + } + } + if(is_resource($fp)) { + while(!feof($fp)) { + $block=fread($fp, $this->_ftp_buff_size); + if(!$this->_data_write_block($mode, $block)) return false; + } + } elseif(!$this->_data_write_block($mode, $fp)) return false; + return true; + } + + function _data_write_block($mode, $block) { + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); + do { + if(($t=@socket_write($this->_ftp_temp_sock, $block))===FALSE) { + $this->PushError("_data_write","socket_write", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return FALSE; + } + $block=substr($block, $t); + } while(!empty($block)); + return true; + } + + function _data_close() { + @socket_close($this->_ftp_temp_sock); + @socket_close($this->_ftp_data_sock); + $this->SendMSG("Disconnected data from remote host"); + return TRUE; + } + + function _quit() { + if($this->_connected) { + @socket_close($this->_ftp_control_sock); + $this->_connected=false; + $this->SendMSG("Socket closed"); + } + } +} +?> diff --git a/wp-admin/includes/class-ftp.php b/wp-admin/includes/class-ftp.php new file mode 100644 index 0000000..bc2720a --- /dev/null +++ b/wp-admin/includes/class-ftp.php @@ -0,0 +1,842 @@ +__construct($port_mode); + } + + function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) { + $this->LocalEcho=$le; + $this->Verbose=$verb; + $this->_lastaction=NULL; + $this->_error_array=array(); + $this->_eol_code=array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n"); + $this->AuthorizedTransferMode=array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY); + $this->OS_FullName=array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS'); + $this->AutoAsciiExt=array("ASP","BAT","C","CPP","CSS","CSV","JS","H","HTM","HTML","SHTML","INI","LOG","PHP3","PHTML","PL","PERL","SH","SQL","TXT"); + $this->_port_available=($port_mode==TRUE); + $this->SendMSG("Staring FTP client class".($this->_port_available?"":" without PORT mode support")); + $this->_connected=FALSE; + $this->_ready=FALSE; + $this->_can_restore=FALSE; + $this->_code=0; + $this->_message=""; + $this->_ftp_buff_size=4096; + $this->_curtype=NULL; + $this->SetUmask(0022); + $this->SetType(FTP_AUTOASCII); + $this->SetTimeout(30); + $this->Passive(!$this->_port_available); + $this->_login="anonymous"; + $this->_password="anon@ftp.com"; + $this->_features=array(); + $this->OS_local=FTP_OS_Unix; + $this->OS_remote=FTP_OS_Unix; + $this->features=array(); + if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows; + elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac; + } + +// +// +// + + function parselisting($line) { + $is_windows = ($this->OS_remote == FTP_OS_Windows); + if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|) +(.+)/",$line,$lucifer)) { + $b = array(); + if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix + $b['isdir'] = ($lucifer[7]==""); + if ( $b['isdir'] ) + $b['type'] = 'd'; + else + $b['type'] = 'f'; + $b['size'] = $lucifer[7]; + $b['month'] = $lucifer[1]; + $b['day'] = $lucifer[2]; + $b['year'] = $lucifer[3]; + $b['hour'] = $lucifer[4]; + $b['minute'] = $lucifer[5]; + $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]); + $b['am/pm'] = $lucifer[6]; + $b['name'] = $lucifer[8]; + } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) { + //echo $line."\n"; + $lcount=count($lucifer); + if ($lcount<8) return ''; + $b = array(); + $b['isdir'] = $lucifer[0]{0} === "d"; + $b['islink'] = $lucifer[0]{0} === "l"; + if ( $b['isdir'] ) + $b['type'] = 'd'; + elseif ( $b['islink'] ) + $b['type'] = 'l'; + else + $b['type'] = 'f'; + $b['perms'] = $lucifer[0]; + $b['number'] = $lucifer[1]; + $b['owner'] = $lucifer[2]; + $b['group'] = $lucifer[3]; + $b['size'] = $lucifer[4]; + if ($lcount==8) { + sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']); + sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']); + $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']); + $b['name'] = $lucifer[7]; + } else { + $b['month'] = $lucifer[5]; + $b['day'] = $lucifer[6]; + if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) { + $b['year'] = date("Y"); + $b['hour'] = $l2[1]; + $b['minute'] = $l2[2]; + } else { + $b['year'] = $lucifer[7]; + $b['hour'] = 0; + $b['minute'] = 0; + } + $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute'])); + $b['name'] = $lucifer[8]; + } + } + + return $b; + } + + function SendMSG($message = "", $crlf=true) { + if ($this->Verbose) { + echo $message.($crlf?CRLF:""); + flush(); + } + return TRUE; + } + + function SetType($mode=FTP_AUTOASCII) { + if(!in_array($mode, $this->AuthorizedTransferMode)) { + $this->SendMSG("Wrong type"); + return FALSE; + } + $this->_type=$mode; + $this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) ); + return TRUE; + } + + function _settype($mode=FTP_ASCII) { + if($this->_ready) { + if($mode==FTP_BINARY) { + if($this->_curtype!=FTP_BINARY) { + if(!$this->_exec("TYPE I", "SetType")) return FALSE; + $this->_curtype=FTP_BINARY; + } + } elseif($this->_curtype!=FTP_ASCII) { + if(!$this->_exec("TYPE A", "SetType")) return FALSE; + $this->_curtype=FTP_ASCII; + } + } else return FALSE; + return TRUE; + } + + function Passive($pasv=NULL) { + if(is_null($pasv)) $this->_passive=!$this->_passive; + else $this->_passive=$pasv; + if(!$this->_port_available and !$this->_passive) { + $this->SendMSG("Only passive connections available!"); + $this->_passive=TRUE; + return FALSE; + } + $this->SendMSG("Passive mode ".($this->_passive?"on":"off")); + return TRUE; + } + + function SetServer($host, $port=21, $reconnect=true) { + if(!is_long($port)) { + $this->verbose=true; + $this->SendMSG("Incorrect port syntax"); + return FALSE; + } else { + $ip=@gethostbyname($host); + $dns=@gethostbyaddr($host); + if(!$ip) $ip=$host; + if(!$dns) $dns=$host; + if(ip2long($ip) === -1) { + $this->SendMSG("Wrong host name/address \"".$host."\""); + return FALSE; + } + $this->_host=$ip; + $this->_fullhost=$dns; + $this->_port=$port; + $this->_dataport=$port-1; + } + $this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\""); + if($reconnect){ + if($this->_connected) { + $this->SendMSG("Reconnecting"); + if(!$this->quit(FTP_FORCE)) return FALSE; + if(!$this->connect()) return FALSE; + } + } + return TRUE; + } + + function SetUmask($umask=0022) { + $this->_umask=$umask; + umask($this->_umask); + $this->SendMSG("UMASK 0".decoct($this->_umask)); + return TRUE; + } + + function SetTimeout($timeout=30) { + $this->_timeout=$timeout; + $this->SendMSG("Timeout ".$this->_timeout); + if($this->_connected) + if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE; + return TRUE; + } + + function connect($server=NULL) { + if(!empty($server)) { + if(!$this->SetServer($server)) return false; + } + if($this->_ready) return true; + $this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]); + if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) { + $this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\""); + return FALSE; + } + $this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting."); + do { + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + $this->_lastaction=time(); + } while($this->_code<200); + $this->_ready=true; + $syst=$this->systype(); + if(!$syst) $this->SendMSG("Can't detect remote OS"); + else { + if(preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote=FTP_OS_Windows; + elseif(preg_match("/os/i", $syst[0])) $this->OS_remote=FTP_OS_Mac; + elseif(preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote=FTP_OS_Unix; + else $this->OS_remote=FTP_OS_Mac; + $this->SendMSG("Remote OS: ".$this->OS_FullName[$this->OS_remote]); + } + if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled"); + else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features))); + return TRUE; + } + + function quit($force=false) { + if($this->_ready) { + if(!$this->_exec("QUIT") and !$force) return FALSE; + if(!$this->_checkCode() and !$force) return FALSE; + $this->_ready=false; + $this->SendMSG("Session finished"); + } + $this->_quit(); + return TRUE; + } + + function login($user=NULL, $pass=NULL) { + if(!is_null($user)) $this->_login=$user; + else $this->_login="anonymous"; + if(!is_null($pass)) $this->_password=$pass; + else $this->_password="anon@anon.com"; + if(!$this->_exec("USER ".$this->_login, "login")) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($this->_code!=230) { + if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } + $this->SendMSG("Authentication succeeded"); + if(empty($this->_features)) { + if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled"); + else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features))); + } + return TRUE; + } + + function pwd() { + if(!$this->_exec("PWD", "pwd")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return ereg_replace("^[0-9]{3} \"(.+)\" .+".CRLF, "\\1", $this->_message); + } + + function cdup() { + if(!$this->_exec("CDUP", "cdup")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return true; + } + + function chdir($pathname) { + if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function rmdir($pathname) { + if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function mkdir($pathname) { + if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function rename($from, $to) { + if(!$this->_exec("RNFR ".$from, "rename")) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($this->_code==350) { + if(!$this->_exec("RNTO ".$to, "rename")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } else return FALSE; + return TRUE; + } + + function filesize($pathname) { + if(!isset($this->_features["SIZE"])) { + $this->PushError("filesize", "not supported by server"); + return FALSE; + } + if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message); + } + + function abort() { + if(!$this->_exec("ABOR", "abort")) return FALSE; + if(!$this->_checkCode()) { + if($this->_code!=426) return FALSE; + if(!$this->_readmsg("abort")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } + return true; + } + + function mdtm($pathname) { + if(!isset($this->_features["MDTM"])) { + $this->PushError("mdtm", "not supported by server"); + return FALSE; + } + if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $mdtm = ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message); + $date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d"); + $timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]); + return $timestamp; + } + + function systype() { + if(!$this->_exec("SYST", "systype")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $DATA = explode(" ", $this->_message); + return array($DATA[1], $DATA[3]); + } + + function delete($pathname) { + if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function site($command, $fnction="site") { + if(!$this->_exec("SITE ".$command, $fnction)) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function chmod($pathname, $mode) { + if(!$this->site( sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE; + return TRUE; + } + + function restore($from) { + if(!isset($this->_features["REST"])) { + $this->PushError("restore", "not supported by server"); + return FALSE; + } + if($this->_curtype!=FTP_BINARY) { + $this->PushError("restore", "can't restore in ASCII mode"); + return FALSE; + } + if(!$this->_exec("REST ".$from, "resore")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function features() { + if(!$this->_exec("FEAT", "features")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $f=preg_split("/[".CRLF."]+/", preg_replace("/[0-9]{3}[ -].*[".CRLF."]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY); + $this->_features=array(); + foreach($f as $k=>$v) { + $v=explode(" ", trim($v)); + $this->_features[array_shift($v)]=$v;; + } + return true; + } + + function rawlist($pathname="", $arg="") { + return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist"); + } + + function nlist($pathname="") { + return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist"); + } + + function is_exists($pathname) { + return $this->file_exists($pathname); + } + + function file_exists($pathname) { + $exists=true; + if(!$this->_exec("RNFR ".$pathname, "rename")) $exists=FALSE; + else { + if(!$this->_checkCode()) $exists=FALSE; + $this->abort(); + } + if($exists) $this->SendMSG("Remote file ".$pathname." exists"); + else $this->SendMSG("Remote file ".$pathname." does not exist"); + return $exists; + } + + function fget($fp, $remotefile,$rest=0) { + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("RETR ".$remotefile, "get")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $out=$this->_data_read($mode, $fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $out; + } + + function get($remotefile, $localfile=NULL, $rest=0) { + if(is_null($localfile)) $localfile=$remotefile; + if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten"); + $fp = @fopen($localfile, "w"); + if (!$fp) { + $this->PushError("get","can't open local file", "Cannot create \"".$localfile."\""); + return FALSE; + } + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + fclose($fp); + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("RETR ".$remotefile, "get")) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + $out=$this->_data_read($mode, $fp); + fclose($fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $out; + } + + function fput($remotefile, $fp) { + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("STOR ".$remotefile, "put")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ret=$this->_data_write($mode, $fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $ret; + } + + function put($localfile, $remotefile=NULL, $rest=0) { + if(is_null($remotefile)) $remotefile=$localfile; + if (!file_exists($localfile)) { + $this->PushError("put","can't open local file", "No such file or directory \"".$localfile."\""); + return FALSE; + } + $fp = @fopen($localfile, "r"); + + if (!$fp) { + $this->PushError("put","can't open local file", "Cannot read file \"".$localfile."\""); + return FALSE; + } + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($localfile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + fclose($fp); + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("STOR ".$remotefile, "put")) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + $ret=$this->_data_write($mode, $fp); + fclose($fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $ret; + } + + function mput($local=".", $remote=NULL, $continious=false) { + $local=realpath($local); + if(!@file_exists($local)) { + $this->PushError("mput","can't open local folder", "Cannot stat folder \"".$local."\""); + return FALSE; + } + if(!is_dir($local)) return $this->put($local, $remote); + if(empty($remote)) $remote="."; + elseif(!$this->file_exists($remote) and !$this->mkdir($remote)) return FALSE; + if($handle = opendir($local)) { + $list=array(); + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != "..") $list[]=$file; + } + closedir($handle); + } else { + $this->PushError("mput","can't open local folder", "Cannot read folder \"".$local."\""); + return FALSE; + } + if(empty($list)) return TRUE; + $ret=true; + foreach($list as $el) { + if(is_dir($local."/".$el)) $t=$this->mput($local."/".$el, $remote."/".$el); + else $t=$this->put($local."/".$el, $remote."/".$el); + if(!$t) { + $ret=FALSE; + if(!$continious) break; + } + } + return $ret; + + } + + function mget($remote, $local=".", $continious=false) { + $list=$this->rawlist($remote, "-lA"); + if($list===false) { + $this->PushError("mget","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return FALSE; + } + if(empty($list)) return true; + if(!@file_exists($local)) { + if(!@mkdir($local)) { + $this->PushError("mget","can't create local folder", "Cannot create folder \"".$local."\""); + return FALSE; + } + } + foreach($list as $k=>$v) { + $list[$k]=$this->parselisting($v); + if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); + } + $ret=true; + foreach($list as $el) { + if($el["type"]=="d") { + if(!$this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) { + $this->PushError("mget", "can't copy folder", "Can't copy remote folder \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } else { + if(!$this->get($remote."/".$el["name"], $local."/".$el["name"])) { + $this->PushError("mget", "can't copy file", "Can't copy remote file \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } + @chmod($local."/".$el["name"], $el["perms"]); + $t=strtotime($el["date"]); + if($t!==-1 and $t!==false) @touch($local."/".$el["name"], $t); + } + return $ret; + } + + function mdel($remote, $continious=false) { + $list=$this->rawlist($remote, "-la"); + if($list===false) { + $this->PushError("mdel","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return false; + } + + foreach($list as $k=>$v) { + $list[$k]=$this->parselisting($v); + if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); + } + $ret=true; + + foreach($list as $el) { + if ( empty($el) ) + continue; + + if($el["type"]=="d") { + if(!$this->mdel($remote."/".$el["name"], $continious)) { + $ret=false; + if(!$continious) break; + } + } else { + if (!$this->delete($remote."/".$el["name"])) { + $this->PushError("mdel", "can't delete file", "Can't delete remote file \"".$remote."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } + } + + if(!$this->rmdir($remote)) { + $this->PushError("mdel", "can't delete folder", "Can't delete remote folder \"".$remote."/".$el["name"]."\""); + $ret=false; + } + return $ret; + } + + function mmkdir($dir, $mode = 0777) { + if(empty($dir)) return FALSE; + if($this->is_exists($dir) or $dir == "/" ) return TRUE; + if(!$this->mmkdir(dirname($dir), $mode)) return false; + $r=$this->mkdir($dir, $mode); + $this->chmod($dir,$mode); + return $r; + } + + function glob($pattern, $handle=NULL) { + $path=$output=null; + if(PHP_OS=='WIN32') $slash='\\'; + else $slash='/'; + $lastpos=strrpos($pattern,$slash); + if(!($lastpos===false)) { + $path=substr($pattern,0,-$lastpos-1); + $pattern=substr($pattern,$lastpos); + } else $path=getcwd(); + if(is_array($handle) and !empty($handle)) { + while($dir=each($handle)) { + if($this->glob_pattern_match($pattern,$dir)) + $output[]=$dir; + } + } else { + $handle=@opendir($path); + if($handle===false) return false; + while($dir=readdir($handle)) { + if($this->glob_pattern_match($pattern,$dir)) + $output[]=$dir; + } + closedir($handle); + } + if(is_array($output)) return $output; + return false; + } + + function glob_pattern_match($pattern,$string) { + $out=null; + $chunks=explode(';',$pattern); + foreach($chunks as $pattern) { + $escape=array('$','^','.','{','}','(',')','[',']','|'); + while(strpos($pattern,'**')!==false) + $pattern=str_replace('**','*',$pattern); + foreach($escape as $probe) + $pattern=str_replace($probe,"\\$probe",$pattern); + $pattern=str_replace('?*','*', + str_replace('*?','*', + str_replace('*',".*", + str_replace('?','.{1,1}',$pattern)))); + $out[]=$pattern; + } + if(count($out)==1) return($this->glob_regexp("^$out[0]$",$string)); + else { + foreach($out as $tester) + if($this->my_regexp("^$tester$",$string)) return true; + } + return false; + } + + function glob_regexp($pattern,$probe) { + $sensitive=(PHP_OS!='WIN32'); + return ($sensitive? + ereg($pattern,$probe): + eregi($pattern,$probe) + ); + } + + function dirlist($remote) { + $list=$this->rawlist($remote, "-la"); + if($list===false) { + $this->PushError("dirlist","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return false; + } + + $dirlist = array(); + foreach($list as $k=>$v) { + $entry=$this->parselisting($v); + if ( empty($entry) ) + continue; + + if($entry["name"]=="." or $entry["name"]=="..") + continue; + + $dirlist[$entry['name']] = $entry; + } + + return $dirlist; + } +// +// +// + function _checkCode() { + return ($this->_code<400 and $this->_code>0); + } + + function _list($arg="", $cmd="LIST", $fnction="_list") { + if(!$this->_data_prepare()) return false; + if(!$this->_exec($cmd.$arg, $fnction)) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $out=""; + if($this->_code<200) { + $out=$this->_data_read(); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($out === FALSE ) return FALSE; + $out=preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY); +// $this->SendMSG(implode($this->_eol_code[$this->OS_local], $out)); + } + return $out; + } + +// +// +// +// Gnre une erreur pour traitement externe la classe + function PushError($fctname,$msg,$desc=false){ + $error=array(); + $error['time']=time(); + $error['fctname']=$fctname; + $error['msg']=$msg; + $error['desc']=$desc; + if($desc) $tmp=' ('.$desc.')'; else $tmp=''; + $this->SendMSG($fctname.': '.$msg.$tmp); + return(array_push($this->_error_array,$error)); + } + +// Rcupre une erreur externe + function PopError(){ + if(count($this->_error_array)) return(array_pop($this->_error_array)); + else return(false); + } +} + +$mod_sockets=TRUE; +if (!extension_loaded('sockets')) { + $prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : ''; + if(!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE; +} +require_once "class-ftp-".($mod_sockets?"sockets":"pure").".php"; +?> diff --git a/wp-admin/includes/class-pclzip.php b/wp-admin/includes/class-pclzip.php new file mode 100644 index 0000000..d387f00 --- /dev/null +++ b/wp-admin/includes/class-pclzip.php @@ -0,0 +1,5748 @@ +zipname = $p_zipname; + $this->zip_fd = 0; + $this->magic_quotes_status = -1; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1); + return; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // create($p_filelist, $p_add_dir="", $p_remove_dir="") + // create($p_filelist, $p_option, $p_option_value, ...) + // Description : + // This method supports two different synopsis. The first one is historical. + // This method creates a Zip Archive. The Zip file is created in the + // filesystem. The files and directories indicated in $p_filelist + // are added in the archive. See the parameters description for the + // supported format of $p_filelist. + // When a directory is in the list, the directory and its content is added + // in the archive. + // In this synopsis, the function takes an optional variable list of + // options. See bellow the supported options. + // Parameters : + // $p_filelist : An array containing file or directory names, or + // a string containing one filename or one directory name, or + // a string containing a list of filenames and/or directory + // names separated by spaces. + // $p_add_dir : A path to add before the real path of the archived file, + // in order to have it memorized in the archive. + // $p_remove_dir : A path to remove from the real path of the file to archive, + // in order to have a shorter path memorized in the archive. + // When $p_add_dir and $p_remove_dir are set, $p_remove_dir + // is removed first, before $p_add_dir is added. + // Options : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_COMMENT : + // PCLZIP_CB_PRE_ADD : + // PCLZIP_CB_POST_ADD : + // Return Values : + // 0 on failure, + // The list of the added files, with a status of the add action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function create($p_filelist) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ..."); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Set default values + $v_options = array(); + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove from the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_ADD => 'optional', + PCLZIP_CB_POST_ADD => 'optional', + PCLZIP_OPT_NO_COMPRESSION => 'optional', + PCLZIP_OPT_COMMENT => 'optional' + //, PCLZIP_OPT_CRYPT => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; + } + else if ($v_size > 2) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Invalid number / type of arguments"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Init + $v_string_list = array(); + $v_att_list = array(); + $v_filedescr_list = array(); + $p_result_list = array(); + + // ----- Look if the $p_filelist is really an array + if (is_array($p_filelist)) { + + // ----- Look if the first element is also an array + // This will mean that this is a file description entry + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { + $v_att_list = $p_filelist; + } + + // ----- The list is a list of string names + else { + $v_string_list = $p_filelist; + } + } + + // ----- Look if the $p_filelist is a string + else if (is_string($p_filelist)) { + // ----- Create a list from the string + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); + } + + // ----- Invalid variable type for $p_filelist + else { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Reformat the string list + if (sizeof($v_string_list) != 0) { + foreach ($v_string_list as $v_string) { + if ($v_string != '') { + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Ignore an empty filename"); + } + } + } + + // ----- For each file in the list check the attributes + $v_supported_attributes + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' + ); + foreach ($v_att_list as $v_entry) { + $v_result = $this->privFileDescrParseAtt($v_entry, + $v_filedescr_list[], + $v_options, + $v_supported_attributes); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Expand the filelist (expand directories) + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Call the create fct + $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list); + return $p_result_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // add($p_filelist, $p_add_dir="", $p_remove_dir="") + // add($p_filelist, $p_option, $p_option_value, ...) + // Description : + // This method supports two synopsis. The first one is historical. + // This methods add the list of files in an existing archive. + // If a file with the same name already exists, it is added at the end of the + // archive, the first one is still present. + // If the archive does not exist, it is created. + // Parameters : + // $p_filelist : An array containing file or directory names, or + // a string containing one filename or one directory name, or + // a string containing a list of filenames and/or directory + // names separated by spaces. + // $p_add_dir : A path to add before the real path of the archived file, + // in order to have it memorized in the archive. + // $p_remove_dir : A path to remove from the real path of the file to archive, + // in order to have a shorter path memorized in the archive. + // When $p_add_dir and $p_remove_dir are set, $p_remove_dir + // is removed first, before $p_add_dir is added. + // Options : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_COMMENT : + // PCLZIP_OPT_ADD_COMMENT : + // PCLZIP_OPT_PREPEND_COMMENT : + // PCLZIP_CB_PRE_ADD : + // PCLZIP_CB_POST_ADD : + // Return Values : + // 0 on failure, + // The list of the added files, with a status of the add action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function add($p_filelist) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ..."); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Set default values + $v_options = array(); + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove form the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_ADD => 'optional', + PCLZIP_CB_POST_ADD => 'optional', + PCLZIP_OPT_NO_COMPRESSION => 'optional', + PCLZIP_OPT_COMMENT => 'optional', + PCLZIP_OPT_ADD_COMMENT => 'optional', + PCLZIP_OPT_PREPEND_COMMENT => 'optional' + //, PCLZIP_OPT_CRYPT => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Init + $v_string_list = array(); + $v_att_list = array(); + $v_filedescr_list = array(); + $p_result_list = array(); + + // ----- Look if the $p_filelist is really an array + if (is_array($p_filelist)) { + + // ----- Look if the first element is also an array + // This will mean that this is a file description entry + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { + $v_att_list = $p_filelist; + } + + // ----- The list is a list of string names + else { + $v_string_list = $p_filelist; + } + } + + // ----- Look if the $p_filelist is a string + else if (is_string($p_filelist)) { + // ----- Create a list from the string + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); + } + + // ----- Invalid variable type for $p_filelist + else { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Reformat the string list + if (sizeof($v_string_list) != 0) { + foreach ($v_string_list as $v_string) { + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; + } + } + + // ----- For each file in the list check the attributes + $v_supported_attributes + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' + ); + foreach ($v_att_list as $v_entry) { + $v_result = $this->privFileDescrParseAtt($v_entry, + $v_filedescr_list[], + $v_options, + $v_supported_attributes); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Expand the filelist (expand directories) + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Call the create fct + $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list); + return $p_result_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : listContent() + // Description : + // This public method, gives the list of the files and directories, with their + // properties. + // The properties of each entries in the list are (used also in other functions) : + // filename : Name of the file. For a create or add action it is the filename + // given by the user. For an extract function it is the filename + // of the extracted file. + // stored_filename : Name of the file / directory stored in the archive. + // size : Size of the stored file. + // compressed_size : Size of the file's data compressed in the archive + // (without the headers overhead) + // mtime : Last known modification date of the file (UNIX timestamp) + // comment : Comment associated with the file + // folder : true | false + // index : index of the file in the archive + // status : status of the action (depending of the action) : + // Values are : + // ok : OK ! + // filtered : the file / dir is not extracted (filtered by user) + // already_a_directory : the file can not be extracted because a + // directory with the same name already exists + // write_protected : the file can not be extracted because a file + // with the same name already exists and is + // write protected + // newer_exist : the file was not extracted because a newer file exists + // path_creation_fail : the file is not extracted because the folder + // does not exists and can not be created + // write_error : the file was not extracted because there was a + // error while writing the file + // read_error : the file was not extracted because there was a error + // while reading the file + // invalid_header : the file was not extracted because of an archive + // format error (bad file header) + // Note that each time a method can continue operating when there + // is an action error on a file, the error is only logged in the file status. + // Return Values : + // 0 on an unrecoverable failure, + // The list of the files in the archive. + // -------------------------------------------------------------------------------- + function listContent() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', ""); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Call the extracting fct + $p_list = array(); + if (($v_result = $this->privList($p_list)) != 1) + { + unset($p_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // extract($p_path="./", $p_remove_path="") + // extract([$p_option, $p_option_value, ...]) + // Description : + // This method supports two synopsis. The first one is historical. + // This method extract all the files / directories from the archive to the + // folder indicated in $p_path. + // If you want to ignore the 'root' part of path of the memorized files + // you can indicate this in the optional $p_remove_path parameter. + // By default, if a newer file with the same name already exists, the + // file is not extracted. + // + // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions + // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append + // at the end of the path value of PCLZIP_OPT_PATH. + // Parameters : + // $p_path : Path where the files and directories are to be extracted + // $p_remove_path : First part ('root' part) of the memorized path + // (if any similar) to remove while extracting. + // Options : + // PCLZIP_OPT_PATH : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_CB_PRE_EXTRACT : + // PCLZIP_CB_POST_EXTRACT : + // Return Values : + // 0 or a negative value on failure, + // The list of the extracted files, with a status of the action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function extract() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", ""); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Set default values + $v_options = array(); +// $v_path = "./"; + $v_path = ''; + $v_remove_path = ""; + $v_remove_all_path = false; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Default values for option + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + + // ----- Look for arguments + if ($v_size > 0) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_PATH => 'optional', + PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_EXTRACT => 'optional', + PCLZIP_CB_POST_EXTRACT => 'optional', + PCLZIP_OPT_SET_CHMOD => 'optional', + PCLZIP_OPT_BY_NAME => 'optional', + PCLZIP_OPT_BY_EREG => 'optional', + PCLZIP_OPT_BY_PREG => 'optional', + PCLZIP_OPT_BY_INDEX => 'optional', + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', + PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', + PCLZIP_OPT_REPLACE_NEWER => 'optional' + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Set the arguments + if (isset($v_options[PCLZIP_OPT_PATH])) { + $v_path = $v_options[PCLZIP_OPT_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { + // ----- Check for '/' in last path char + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { + $v_path .= '/'; + } + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_remove_path = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'"); + + // ----- Call the extracting fct + $p_list = array(); + $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, + $v_remove_all_path, $v_options); + if ($v_result < 1) { + unset($p_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + + // -------------------------------------------------------------------------------- + // Function : + // extractByIndex($p_index, $p_path="./", $p_remove_path="") + // extractByIndex($p_index, [$p_option, $p_option_value, ...]) + // Description : + // This method supports two synopsis. The first one is historical. + // This method is doing a partial extract of the archive. + // The extracted files or folders are identified by their index in the + // archive (from 0 to n). + // Note that if the index identify a folder, only the folder entry is + // extracted, not all the files included in the archive. + // Parameters : + // $p_index : A single index (integer) or a string of indexes of files to + // extract. The form of the string is "0,4-6,8-12" with only numbers + // and '-' for range or ',' to separate ranges. No spaces or ';' + // are allowed. + // $p_path : Path where the files and directories are to be extracted + // $p_remove_path : First part ('root' part) of the memorized path + // (if any similar) to remove while extracting. + // Options : + // PCLZIP_OPT_PATH : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and + // not as files. + // The resulting content is in a new field 'content' in the file + // structure. + // This option must be used alone (any other options are ignored). + // PCLZIP_CB_PRE_EXTRACT : + // PCLZIP_CB_POST_EXTRACT : + // Return Values : + // 0 on failure, + // The list of the extracted files, with a status of the action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + //function extractByIndex($p_index, options...) + function extractByIndex($p_index) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ..."); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Set default values + $v_options = array(); +// $v_path = "./"; + $v_path = ''; + $v_remove_path = ""; + $v_remove_all_path = false; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Default values for option + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove form the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_PATH => 'optional', + PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_EXTRACT => 'optional', + PCLZIP_CB_POST_EXTRACT => 'optional', + PCLZIP_OPT_SET_CHMOD => 'optional', + PCLZIP_OPT_REPLACE_NEWER => 'optional' + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Set the arguments + if (isset($v_options[PCLZIP_OPT_PATH])) { + $v_path = $v_options[PCLZIP_OPT_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { + // ----- Check for '/' in last path char + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { + $v_path .= '/'; + } + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; + } + if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set."); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set."); + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_remove_path = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'"); + + // ----- Trick + // Here I want to reuse extractByRule(), so I need to parse the $p_index + // with privParseOptions() + $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); + $v_options_trick = array(); + $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, + array (PCLZIP_OPT_BY_INDEX => 'optional' )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; + + // ----- Call the extracting fct + if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // delete([$p_option, $p_option_value, ...]) + // Description : + // This method removes files from the archive. + // If no parameters are given, then all the archive is emptied. + // Parameters : + // None or optional arguments. + // Options : + // PCLZIP_OPT_BY_INDEX : + // PCLZIP_OPT_BY_NAME : + // PCLZIP_OPT_BY_EREG : + // PCLZIP_OPT_BY_PREG : + // Return Values : + // 0 on failure, + // The list of the files which are still present in the archive. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function delete() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", ""); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Set default values + $v_options = array(); + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Look for arguments + if ($v_size > 0) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_BY_NAME => 'optional', + PCLZIP_OPT_BY_EREG => 'optional', + PCLZIP_OPT_BY_PREG => 'optional', + PCLZIP_OPT_BY_INDEX => 'optional' )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Call the delete fct + $v_list = array(); + if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { + $this->privSwapBackMagicQuotes(); + unset($v_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list); + return $v_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : deleteByIndex() + // Description : + // ***** Deprecated ***** + // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered. + // -------------------------------------------------------------------------------- + function deleteByIndex($p_index) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'"); + + $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : properties() + // Description : + // This method gives the properties of the archive. + // The properties are : + // nb : Number of files in the archive + // comment : Comment associated with the archive file + // status : not_exist, ok + // Parameters : + // None + // Return Values : + // 0 on failure, + // An array with the archive properties. + // -------------------------------------------------------------------------------- + function properties() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", ""); + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Default properties + $v_prop = array(); + $v_prop['comment'] = ''; + $v_prop['nb'] = 0; + $v_prop['status'] = 'not_exist'; + + // ----- Look if file exists + if (@is_file($this->zipname)) + { + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) + { + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0); + return 0; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Set the user attributes + $v_prop['comment'] = $v_central_dir['comment']; + $v_prop['nb'] = $v_central_dir['entries']; + $v_prop['status'] = 'ok'; + } + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop); + return $v_prop; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : duplicate() + // Description : + // This method creates an archive by copying the content of an other one. If + // the archive already exist, it is replaced by the new one without any warning. + // Parameters : + // $p_archive : The filename of a valid archive, or + // a valid PclZip object. + // Return Values : + // 1 on success. + // 0 or a negative value on error (error code). + // -------------------------------------------------------------------------------- + function duplicate($p_archive) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", ""); + $v_result = 1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Look if the $p_archive is a PclZip object + if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'"); + + // ----- Duplicate the archive + $v_result = $this->privDuplicate($p_archive->zipname); + } + + // ----- Look if the $p_archive is a string (so a filename) + else if (is_string($p_archive)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'"); + + // ----- Check that $p_archive is a valid zip file + // TBC : Should also check the archive format + if (!is_file($p_archive)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); + $v_result = PCLZIP_ERR_MISSING_FILE; + } + else { + // ----- Duplicate the archive + $v_result = $this->privDuplicate($p_archive); + } + } + + // ----- Invalid variable + else + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); + $v_result = PCLZIP_ERR_INVALID_PARAMETER; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : merge() + // Description : + // This method merge the $p_archive_to_add archive at the end of the current + // one ($this). + // If the archive ($this) does not exist, the merge becomes a duplicate. + // If the $p_archive_to_add archive does not exist, the merge is a success. + // Parameters : + // $p_archive_to_add : It can be directly the filename of a valid zip archive, + // or a PclZip object archive. + // Return Values : + // 1 on success, + // 0 or negative values on error (see below). + // -------------------------------------------------------------------------------- + function merge($p_archive_to_add) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", ""); + $v_result = 1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Look if the $p_archive_to_add is a PclZip object + if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object"); + + // ----- Merge the archive + $v_result = $this->privMerge($p_archive_to_add); + } + + // ----- Look if the $p_archive_to_add is a string (so a filename) + else if (is_string($p_archive_to_add)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename"); + + // ----- Create a temporary archive + $v_object_archive = new PclZip($p_archive_to_add); + + // ----- Merge the archive + $v_result = $this->privMerge($v_object_archive); + } + + // ----- Invalid variable + else + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); + $v_result = PCLZIP_ERR_INVALID_PARAMETER; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + + + // -------------------------------------------------------------------------------- + // Function : errorCode() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorCode() + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + return(PclErrorCode()); + } + else { + return($this->error_code); + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : errorName() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorName($p_with_code=false) + { + $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', + PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', + PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', + PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', + PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', + PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', + PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', + PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', + PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', + PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', + PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', + PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', + PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', + PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', + PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', + PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', + PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', + PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', + PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' + ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' + ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' + ); + + if (isset($v_name[$this->error_code])) { + $v_value = $v_name[$this->error_code]; + } + else { + $v_value = 'NoName'; + } + + if ($p_with_code) { + return($v_value.' ('.$this->error_code.')'); + } + else { + return($v_value); + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : errorInfo() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorInfo($p_full=false) + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + return(PclErrorString()); + } + else { + if ($p_full) { + return($this->errorName(true)." : ".$this->error_string); + } + else { + return($this->error_string." [code ".$this->error_code."]"); + } + } + } + // -------------------------------------------------------------------------------- + + +// -------------------------------------------------------------------------------- +// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS ***** +// ***** ***** +// ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY ***** +// -------------------------------------------------------------------------------- + + + + // -------------------------------------------------------------------------------- + // Function : privCheckFormat() + // Description : + // This method check that the archive exists and is a valid zip archive. + // Several level of check exists. (futur) + // Parameters : + // $p_level : Level of check. Default 0. + // 0 : Check the first bytes (magic codes) (default value)) + // 1 : 0 + Check the central directory (futur) + // 2 : 1 + Check each file header (futur) + // Return Values : + // true on success, + // false on error, the error code is set. + // -------------------------------------------------------------------------------- + function privCheckFormat($p_level=0) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", ""); + $v_result = true; + + // ----- Reset the file system cache + clearstatcache(); + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Look if the file exits + if (!is_file($this->zipname)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo()); + return(false); + } + + // ----- Check that the file is readeable + if (!is_readable($this->zipname)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo()); + return(false); + } + + // ----- Check the magic code + // TBC + + // ----- Check the central header + // TBC + + // ----- Check each file header + // TBC + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privParseOptions() + // Description : + // This internal methods reads the variable list of arguments ($p_options_list, + // $p_size) and generate an array with the options and values ($v_result_list). + // $v_requested_options contains the options that can be present and those that + // must be present. + // $v_requested_options is an array, with the option value as key, and 'optional', + // or 'mandatory' as value. + // Parameters : + // See above. + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", ""); + $v_result=1; + + // ----- Read the options + $i=0; + while ($i<$p_size) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'"); + + // ----- Check if the option is supported + if (!isset($v_requested_options[$p_options_list[$i]])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for next option + switch ($p_options_list[$i]) { + // ----- Look for options that request a path value + case PCLZIP_OPT_PATH : + case PCLZIP_OPT_REMOVE_PATH : + case PCLZIP_OPT_ADD_PATH : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if ( is_string($p_options_list[$i+1]) + && ($p_options_list[$i+1] != '')) { + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." set with an empty value is ignored."); + } + break; + + // ----- Look for options that request an array of string for value + case PCLZIP_OPT_BY_NAME : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; + } + else if (is_array($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that request an EREG or PREG expression + case PCLZIP_OPT_BY_EREG : + case PCLZIP_OPT_BY_PREG : + //case PCLZIP_OPT_CRYPT : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that takes a string + case PCLZIP_OPT_COMMENT : + case PCLZIP_OPT_ADD_COMMENT : + case PCLZIP_OPT_PREPEND_COMMENT : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, + "Missing parameter value for option '" + .PclZipUtilOptionText($p_options_list[$i]) + ."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, + "Wrong parameter value for option '" + .PclZipUtilOptionText($p_options_list[$i]) + ."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that request an array of index + case PCLZIP_OPT_BY_INDEX : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_work_list = array(); + if (is_string($p_options_list[$i+1])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'"); + + // ----- Remove spaces + $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); + + // ----- Parse items + $v_work_list = explode(",", $p_options_list[$i+1]); + } + else if (is_integer($p_options_list[$i+1])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'"); + $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; + } + else if (is_array($p_options_list[$i+1])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array"); + $v_work_list = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Reduce the index list + // each index item in the list must be a couple with a start and + // an end value : [0,3], [5-5], [8-10], ... + // ----- Check the format of each item + $v_sort_flag=false; + $v_sort_value=0; + for ($j=0; $j= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that request a call-back + case PCLZIP_CB_PRE_EXTRACT : + case PCLZIP_CB_POST_EXTRACT : + case PCLZIP_CB_PRE_ADD : + case PCLZIP_CB_POST_ADD : + /* for futur use + case PCLZIP_CB_PRE_DELETE : + case PCLZIP_CB_POST_DELETE : + case PCLZIP_CB_PRE_LIST : + case PCLZIP_CB_POST_LIST : + */ + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_function_name = $p_options_list[$i+1]; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'"); + + // ----- Check that the value is a valid existing function + if (!function_exists($v_function_name)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Set the attribute + $v_result_list[$p_options_list[$i]] = $v_function_name; + $i++; + break; + + default : + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Unknown parameter '" + .$p_options_list[$i]."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Next options + $i++; + } + + // ----- Look for mandatory options + if ($v_requested_options !== false) { + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { + // ----- Look for mandatory option + if ($v_requested_options[$key] == 'mandatory') { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")"); + // ----- Look if present + if (!isset($v_result_list[$key])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privFileDescrParseAtt() + // Description : + // Parameters : + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrParseAtt", ""); + $v_result=1; + + // ----- For each file in the list check the attributes + foreach ($p_file_list as $v_key => $v_value) { + + // ----- Check if the option is supported + if (!isset($v_requested_options[$v_key])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for attribute + switch ($v_key) { + case PCLZIP_ATT_FILE_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); + + if ($p_filedescr['filename'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + break; + + case PCLZIP_ATT_FILE_NEW_SHORT_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); + + if ($p_filedescr['new_short_name'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + break; + + case PCLZIP_ATT_FILE_NEW_FULL_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); + + if ($p_filedescr['new_full_name'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + break; + + default : + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Unknown parameter '".$v_key."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for mandatory options + if ($v_requested_options !== false) { + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { + // ----- Look for mandatory option + if ($v_requested_options[$key] == 'mandatory') { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")"); + // ----- Look if present + if (!isset($p_file_list[$key])) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + } + } + + // end foreach + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privFileDescrExpand() + // Description : + // Parameters : + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privFileDescrExpand(&$p_filedescr_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrExpand", ""); + $v_result=1; + + // ----- Create a result list + $v_result_list = array(); + + // ----- Look each entry + for ($i=0; $iprivCalculateStoredFilename($v_descr, $p_options); + + // ----- Add the descriptor in result list + $v_result_list[sizeof($v_result_list)] = $v_descr; + + // ----- Look for folder + if ($v_descr['type'] == 'folder') { + // ----- List of items in folder + $v_dirlist_descr = array(); + $v_dirlist_nb = 0; + if ($v_folder_handler = @opendir($v_descr['filename'])) { + while (($v_item_handler = @readdir($v_folder_handler)) !== false) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for '".$v_item_handler."' in the directory"); + + // ----- Skip '.' and '..' + if (($v_item_handler == '.') || ($v_item_handler == '..')) { + continue; + } + + // ----- Compose the full filename + $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; + + // ----- Look for different stored filename + // Because the name of the folder was changed, the name of the + // files/sub-folders also change + if ($v_descr['stored_filename'] != $v_descr['filename']) { + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; + } + + $v_dirlist_nb++; + } + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to open dir '".$v_descr['filename']."' in read mode. Skipped."); + // TBC : unable to open folder in read mode + } + + // ----- Expand each element of the list + if ($v_dirlist_nb != 0) { + // ----- Expand + if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Concat the resulting list + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Merging result list (size '".sizeof($v_result_list)."') with dirlist (size '".sizeof($v_dirlist_descr)."')"); + $v_result_list = array_merge($v_result_list, $v_dirlist_descr); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "merged result list is size '".sizeof($v_result_list)."'"); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Nothing in this folder to expand."); + } + + // ----- Free local array + unset($v_dirlist_descr); + } + } + + // ----- Get the result list + $p_filedescr_list = $v_result_list; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCreate() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privCreate($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list"); + $v_result=1; + $v_list_detail = array(); + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the file in write mode + if (($v_result = $this->privOpenFd('wb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Add the list of files + $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options); + + // ----- Close + $this->privCloseFd(); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAdd() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privAdd($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list"); + $v_result=1; + $v_list_detail = array(); + + // ----- Look if the archive exists or is empty + if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it."); + + // ----- Do a create + $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Open the temporary file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) + { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = $v_central_dir['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Swap the file descriptor + // Here is a trick : I swap the temporary fd with the zip fd, in order to use + // the following methods on the temporary fil and not the real archive + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Add the files + $v_header_list = array(); + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) + { + fclose($v_zip_temp_fd); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset"); + + // ----- Copy the block of file headers from the old archive + $v_size = $v_central_dir['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($v_zip_temp_fd, $v_read_size); + @fwrite($this->zip_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Create the Central Dir files header + for ($i=0, $v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + fclose($v_zip_temp_fd); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + $v_count++; + } + + // ----- Transform the header to a 'usable' info + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + // ----- Zip file comment + $v_comment = $v_central_dir['comment']; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) { + $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; + } + if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($this->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) + { + // ----- Reset the file list + unset($v_header_list); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Swap back the file descriptor + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Close + $this->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privOpenFd() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privOpenFd($p_mode) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode); + $v_result=1; + + // ----- Look if already open + if ($this->zip_fd != 0) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode'); + if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCloseFd() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privCloseFd() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", ""); + $v_result=1; + + if ($this->zip_fd != 0) + @fclose($this->zip_fd); + $this->zip_fd = 0; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddList() + // Description : + // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is + // different from the real path of the file. This is usefull if you want to have PclTar + // running in any directory, and memorize relative path from an other directory. + // Parameters : + // $p_list : An array containing the file or directory names to add in the tar + // $p_result_list : list of added files with their properties (specially the status field) + // $p_add_dir : Path to add in the filename path archived + // $p_remove_dir : Path to remove in the filename path archived + // Return Values : + // -------------------------------------------------------------------------------- +// function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) + function privAddList($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list"); + $v_result=1; + + // ----- Add the files + $v_header_list = array(); + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($this->zip_fd); + + // ----- Create the Central Dir files header + for ($i=0,$v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + $v_count++; + } + + // ----- Transform the header to a 'usable' info + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + // ----- Zip file comment + $v_comment = ''; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($this->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) + { + // ----- Reset the file list + unset($v_header_list); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddFileList() + // Description : + // Parameters : + // $p_filedescr_list : An array containing the file description + // or directory names to add in the zip + // $p_result_list : list of added files with their properties (specially the status field) + // Return Values : + // -------------------------------------------------------------------------------- + function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "filedescr_list"); + $v_result=1; + $v_header = array(); + + // ----- Recuperate the current number of elt in list + $v_nb = sizeof($p_result_list); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have ".$v_nb." elements"); + + // ----- Loop on the files + for ($j=0; ($jprivAddFile($p_filedescr_list[$j], $v_header, + $p_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the file infos + $p_result_list[$v_nb++] = $v_header; + } + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have ".$v_nb." elements"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddFile() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privAddFile($p_filedescr, &$p_header, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='".$p_filedescr['filename']."'"); + $v_result=1; + + // ----- Working variable + $p_filename = $p_filedescr['filename']; + + // TBC : Already done in the fileAtt check ... ? + if ($p_filename == "") { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for a stored different filename + if (isset($p_filedescr['stored_filename'])) { + $v_stored_filename = $p_filedescr['stored_filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is NOT the same "'.$v_stored_filename.'"'); + } + else { + $v_stored_filename = $p_filedescr['stored_filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is the same'); + } + + // ----- Set the file properties + clearstatcache(); + $p_header['version'] = 20; + $p_header['version_extracted'] = 10; + $p_header['flag'] = 0; + $p_header['compression'] = 0; + $p_header['mtime'] = filemtime($p_filename); + $p_header['crc'] = 0; + $p_header['compressed_size'] = 0; + $p_header['size'] = filesize($p_filename); + $p_header['filename_len'] = strlen($p_filename); + $p_header['extra_len'] = 0; + $p_header['comment_len'] = 0; + $p_header['disk'] = 0; + $p_header['internal'] = 0; +// $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); + $p_header['external'] = (is_file($p_filename)?0x00000000:0x00000010); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'"); + $p_header['offset'] = 0; + $p_header['filename'] = $p_filename; + $p_header['stored_filename'] = $v_stored_filename; + $p_header['extra'] = ''; + $p_header['comment'] = ''; + $p_header['status'] = 'ok'; + $p_header['index'] = -1; + + // ----- Look for pre-add callback + if (isset($p_options[PCLZIP_CB_PRE_ADD])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_header, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);'); + if ($v_result == 0) { + // ----- Change the file status + $p_header['status'] = "skipped"; + $v_result = 1; + } + + // ----- Update the informations + // Only some fields can be modified + if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { + $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'"); + } + } + + // ----- Look for empty stored filename + if ($p_header['stored_filename'] == "") { + $p_header['status'] = "filtered"; + } + + // ----- Check the path length + if (strlen($p_header['stored_filename']) > 0xFF) { + $p_header['status'] = 'filename_too_long'; + } + + // ----- Look if no error, or file not skipped + if ($p_header['status'] == 'ok') { + + // ----- Look for a file + if (is_file($p_filename)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file"); + // ----- Open the source file + if (($v_file = @fopen($p_filename, "rb")) == 0) { + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed"); + // ----- Read the file content + $v_content_compressed = @fread($v_file, $p_header['size']); + + // ----- Calculate the CRC + $p_header['crc'] = @crc32($v_content_compressed); + + // ----- Set header parameters + $p_header['compressed_size'] = $p_header['size']; + $p_header['compression'] = 0; + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed"); + // ----- Read the file content + $v_content = @fread($v_file, $p_header['size']); + + // ----- Calculate the CRC + $p_header['crc'] = @crc32($v_content); + + // ----- Compress the file + $v_content_compressed = @gzdeflate($v_content); + + // ----- Set header parameters + $p_header['compressed_size'] = strlen($v_content_compressed); + $p_header['compression'] = 8; + } + + // ----- Look for encryption + /* + if ((isset($p_options[PCLZIP_OPT_CRYPT])) + && ($p_options[PCLZIP_OPT_CRYPT] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File need to be crypted ...."); + + // Should be a random header + $v_header = 'xxxxxxxxxxxx'; + $v_content_compressed = PclZipUtilZipEncrypt($v_content_compressed, + $p_header['compressed_size'], + $v_header, + $p_header['crc'], + "test"); + + $p_header['compressed_size'] += 12; + $p_header['flag'] = 1; + + // ----- Add the header to the data + $v_content_compressed = $v_header.$v_content_compressed; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size after header : ".strlen($v_content_compressed).""); + } + */ + + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { + @fclose($v_file); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Write the compressed (or not) content + @fwrite($this->zip_fd, + $v_content_compressed, $p_header['compressed_size']); + + // ----- Close the file + @fclose($v_file); + } + + // ----- Look for a directory + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a folder"); + // ----- Look for directory last '/' + if (@substr($p_header['stored_filename'], -1) != '/') { + $p_header['stored_filename'] .= '/'; + } + + // ----- Set the file properties + $p_header['size'] = 0; + //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked + $p_header['external'] = 0x00000010; // Value for a folder : to be checked + + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + } + + // ----- Look for post-add callback + if (isset($p_options[PCLZIP_CB_POST_ADD])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_header, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);'); + if ($v_result == 0) { + // ----- Ignored + $v_result = 1; + } + + // ----- Update the informations + // Nothing can be modified + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCalculateStoredFilename() + // Description : + // Based on file descriptor properties and global options, this method + // calculate the filename that will be stored in the archive. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privCalculateStoredFilename(&$p_filedescr, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCalculateStoredFilename", "filename='".$p_filedescr['filename']."'"); + $v_result=1; + + // ----- Working variables + $p_filename = $p_filedescr['filename']; + if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { + $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; + } + else { + $p_add_dir = ''; + } + if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { + $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; + } + else { + $p_remove_dir = ''; + } + if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + else { + $p_remove_all_dir = 0; + } + + // ----- Look for full name change + if (isset($p_filedescr['new_full_name'])) { + $v_stored_filename = $p_filedescr['new_full_name']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing full name of '".$p_filename."' for '".$v_stored_filename."'"); + } + + // ----- Look for path and/or short name change + else { + + // ----- Look for short name change + if (isset($p_filedescr['new_short_name'])) { + $v_path_info = pathinfo($p_filename); + $v_dir = ''; + if ($v_path_info['dirname'] != '') { + $v_dir = $v_path_info['dirname'].'/'; + } + $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing short name of '".$p_filename."' for '".$v_stored_filename."'"); + } + else { + // ----- Calculate the stored filename + $v_stored_filename = $p_filename; + } + + // ----- Look for all path to remove + if ($p_remove_all_dir) { + $v_stored_filename = basename($p_filename); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove all path selected change '".$p_filename."' for '".$v_stored_filename."'"); + } + // ----- Look for partial path remove + else if ($p_remove_dir != "") { + if (substr($p_remove_dir, -1) != '/') + $p_remove_dir .= "/"; + + if ( (substr($p_filename, 0, 2) == "./") + || (substr($p_remove_dir, 0, 2) == "./")) { + + if ( (substr($p_filename, 0, 2) == "./") + && (substr($p_remove_dir, 0, 2) != "./")) { + $p_remove_dir = "./".$p_remove_dir; + } + if ( (substr($p_filename, 0, 2) != "./") + && (substr($p_remove_dir, 0, 2) == "./")) { + $p_remove_dir = substr($p_remove_dir, 2); + } + } + + $v_compare = PclZipUtilPathInclusion($p_remove_dir, + $v_stored_filename); + if ($v_compare > 0) { + if ($v_compare == 2) { + $v_stored_filename = ""; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder"); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$v_stored_filename'"); + $v_stored_filename = substr($v_stored_filename, + strlen($p_remove_dir)); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Result is '$v_stored_filename'"); + } + } + } + // ----- Look for path to add + if ($p_add_dir != "") { + if (substr($p_add_dir, -1) == "/") + $v_stored_filename = $p_add_dir.$v_stored_filename; + else + $v_stored_filename = $p_add_dir."/".$v_stored_filename; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'"); + } + } + + // ----- Filename (reduce the path of stored name) + $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); + $p_filedescr['stored_filename'] = $v_stored_filename; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Stored filename will be '".$p_filedescr['stored_filename']."', strlen ".strlen($p_filedescr['stored_filename'])); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"'); + $v_result=1; + + // ----- Store the offset position of the file + $p_header['offset'] = ftell($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']); + + // ----- Transform UNIX mtime to DOS format mdate/mtime + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + $v_date = getdate($p_header['mtime']); + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; + + // ----- Packed data + $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, + $p_header['version_extracted'], $p_header['flag'], + $p_header['compression'], $v_mtime, $v_mdate, + $p_header['crc'], $p_header['compressed_size'], + $p_header['size'], + strlen($p_header['stored_filename']), + $p_header['extra_len']); + + // ----- Write the first 148 bytes of the header in the archive + fputs($this->zip_fd, $v_binary_data, 30); + + // ----- Write the variable fields + if (strlen($p_header['stored_filename']) != 0) + { + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); + } + if ($p_header['extra_len'] != 0) + { + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteCentralFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteCentralFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"'); + $v_result=1; + + // TBC + //for(reset($p_header); $key = key($p_header); next($p_header)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]); + //} + + // ----- Transform UNIX mtime to DOS format mdate/mtime + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + $v_date = getdate($p_header['mtime']); + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; + + // ----- Packed data + $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, + $p_header['version'], $p_header['version_extracted'], + $p_header['flag'], $p_header['compression'], + $v_mtime, $v_mdate, $p_header['crc'], + $p_header['compressed_size'], $p_header['size'], + strlen($p_header['stored_filename']), + $p_header['extra_len'], $p_header['comment_len'], + $p_header['disk'], $p_header['internal'], + $p_header['external'], $p_header['offset']); + + // ----- Write the 42 bytes of the header in the zip file + fputs($this->zip_fd, $v_binary_data, 46); + + // ----- Write the variable fields + if (strlen($p_header['stored_filename']) != 0) + { + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); + } + if ($p_header['extra_len'] != 0) + { + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); + } + if ($p_header['comment_len'] != 0) + { + fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteCentralHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"'); + $v_result=1; + + // ----- Packed data + $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, + $p_nb_entries, $p_size, + $p_offset, strlen($p_comment)); + + // ----- Write the 22 bytes of the header in the zip file + fputs($this->zip_fd, $v_binary_data, 22); + + // ----- Write the variable fields + if (strlen($p_comment) != 0) + { + fputs($this->zip_fd, $p_comment, strlen($p_comment)); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privList() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privList(&$p_list) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list"); + $v_result=1; + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) + { + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of Central Dir + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_central_dir['offset'])) + { + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + + // ----- Read each entry + for ($i=0; $i<$v_central_dir['entries']; $i++) + { + // ----- Read the file header + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + $v_header['index'] = $i; + + // ----- Get the only interesting attributes + $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); + unset($v_header); + } + + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privConvertHeader2FileInfo() + // Description : + // This function takes the file informations from the central directory + // entries and extract the interesting parameters that will be given back. + // The resulting file infos are set in the array $p_info + // $p_info['filename'] : Filename with full path. Given by user (add), + // extracted in the filesystem (extract). + // $p_info['stored_filename'] : Stored filename in the archive. + // $p_info['size'] = Size of the file. + // $p_info['compressed_size'] = Compressed size of the file. + // $p_info['mtime'] = Last modification date of the file. + // $p_info['comment'] = Comment associated with the file. + // $p_info['folder'] = true/false : indicates if the entry is a folder or not. + // $p_info['status'] = status of the action on the file. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privConvertHeader2FileInfo($p_header, &$p_info) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'"); + $v_result=1; + + // ----- Get the interesting attributes + $p_info['filename'] = $p_header['filename']; + $p_info['stored_filename'] = $p_header['stored_filename']; + $p_info['size'] = $p_header['size']; + $p_info['compressed_size'] = $p_header['compressed_size']; + $p_info['mtime'] = $p_header['mtime']; + $p_info['comment'] = $p_header['comment']; + $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); + $p_info['index'] = $p_header['index']; + $p_info['status'] = $p_header['status']; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractByRule() + // Description : + // Extract a file or directory depending of rules (by index, by name, ...) + // Parameters : + // $p_file_list : An array where will be placed the properties of each + // extracted file + // $p_path : Path to add while writing the extracted files + // $p_remove_path : Path to remove (from the file memorized path) while writing the + // extracted files. If the path does not match the file path, + // the file is extracted with its memorized path. + // $p_remove_path does not apply to 'list' mode. + // $p_path and $p_remove_path are commulative. + // Return Values : + // 1 on success,0 or less on error (see error code list) + // -------------------------------------------------------------------------------- + function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'"); + $v_result=1; + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Check the path + if ( ($p_path == "") + || ( (substr($p_path, 0, 1) != "/") + && (substr($p_path, 0, 3) != "../") + && (substr($p_path,1,2)!=":/"))) + $p_path = "./".$p_path; + + // ----- Reduce the path last (and duplicated) '/' + if (($p_path != "./") && ($p_path != "/")) + { + // ----- Look for the path end '/' + while (substr($p_path, -1) == "/") + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'"); + $p_path = substr($p_path, 0, strlen($p_path)-1); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]"); + } + } + + // ----- Look for path to remove format (should end by /) + if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) + { + $p_remove_path .= '/'; + } + $p_remove_path_size = strlen($p_remove_path); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result = $this->privOpenFd('rb')) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Start at beginning of Central Dir + $v_pos_entry = $v_central_dir['offset']; + + // ----- Read each entry + $j_start = 0; + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'"); + + // ----- Read next Central dir entry + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_pos_entry)) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Read the file header + $v_header = array(); + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the index + $v_header['index'] = $i; + + // ----- Store the file position + $v_pos_entry = ftell($this->zip_fd); + + // ----- Look for the specific extract rules + $v_extract = false; + + // ----- Look for extract by name rule + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'"); + + // ----- Look if the filename is in the list + for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) + && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path"); + $v_extract = true; + } + } + // ----- Look for a filename + elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one."); + $v_extract = true; + } + } + } + + // ----- Look for extract by ereg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); + + if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_extract = true; + } + } + + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'"); + + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_extract = true; + } + } + + // ----- Look for extract by index rule + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'"); + + // ----- Look if the index is in the list + for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range"); + $v_extract = true; + } + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop"); + $j_start = $j+1; + } + + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop"); + break; + } + } + } + + // ----- Look for no rule, which means extract all the archive + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)"); + $v_extract = true; + } + + // ----- Check compression method + if ( ($v_extract) + && ( ($v_header['compression'] != 8) + && ($v_header['compression'] != 0))) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported compression method (".$v_header['compression'].")"); + $v_header['status'] = 'unsupported_compression'; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, + "Filename '".$v_header['stored_filename']."' is " + ."compressed by an unsupported compression " + ."method (".$v_header['compression'].") "); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Check encrypted files + if (($v_extract) && (($v_header['flag'] & 1) == 1)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported file encryption"); + $v_header['status'] = 'unsupported_encryption'; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, + "Unsupported encryption for " + ." filename '".$v_header['stored_filename'] + ."'"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Look for real extraction + if (($v_extract) && ($v_header['status'] != 'ok')) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "No need for extract"); + $v_result = $this->privConvertHeader2FileInfo($v_header, + $p_file_list[$v_nb_extracted++]); + if ($v_result != 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + $v_extract = false; + } + + // ----- Look for real extraction + if ($v_extract) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'"); + + // ----- Go to the file position + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_header['offset'])) + { + // ----- Close the zip file + $this->privCloseFd(); + + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Look for extraction as string + if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { + + // ----- Extracting the file + $v_result1 = $this->privExtractFileAsString($v_header, $v_string); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Set the file content + $p_file_list[$v_nb_extracted]['content'] = $v_string; + + // ----- Next extracted file + $v_nb_extracted++; + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + // ----- Look for extraction in standard output + elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) + && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { + // ----- Extracting the file in standard output + $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + // ----- Look for normal extraction + else { + // ----- Extracting the file + $v_result1 = $this->privExtractFile($v_header, + $p_path, $p_remove_path, + $p_remove_all_path, + $p_options); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + } + } + + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFile() + // Description : + // Parameters : + // Return Values : + // + // 1 : ... ? + // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback + // -------------------------------------------------------------------------------- + function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'"); + $v_result=1; + + // ----- Read the file header + if (($v_result = $this->privReadFileHeader($v_header)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + // ----- Look for all path to remove + if ($p_remove_all_path == true) { + // ----- Look for folder entry that not need to be extracted + if (($p_entry['external']&0x00000010)==0x00000010) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The entry is a folder : need to be filtered"); + + $p_entry['status'] = "filtered"; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "All path is removed"); + // ----- Get the basename of the path + $p_entry['filename'] = basename($p_entry['filename']); + } + + // ----- Look for path to remove + else if ($p_remove_path != "") + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look for some path to remove"); + if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'"); + + // ----- Change the file status + $p_entry['status'] = "filtered"; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + $p_remove_path_size = strlen($p_remove_path); + if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'"); + + // ----- Remove the path + $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'"); + } + } + + // ----- Add the path + if ($p_path != '') { + $p_entry['filename'] = $p_path."/".$p_entry['filename']; + } + + // ----- Check a base_dir_restriction + if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Check the extract directory restriction"); + $v_inclusion + = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], + $p_entry['filename']); + if ($v_inclusion == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_EXTRACT_DIR_RESTRICTION is selected, file is outside restriction"); + + PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, + "Filename '".$p_entry['filename']."' is " + ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Look for pre-extract callback + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); + if ($v_result == 0) { + // ----- Change the file status + $p_entry['status'] = "skipped"; + $v_result = 1; + } + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + // ----- This status is internal and will be changed in 'skipped' + $p_entry['status'] = "aborted"; + $v_result = PCLZIP_ERR_USER_ABORTED; + } + + // ----- Update the informations + // Only some fields can be modified + $p_entry['filename'] = $v_local_header['filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'"); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'"); + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Look for specific actions while the file exist + if (file_exists($p_entry['filename'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists"); + + // ----- Look if file is a directory + if (is_dir($p_entry['filename'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory"); + + // ----- Change the file status + $p_entry['status'] = "already_a_directory"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, + "Filename '".$p_entry['filename']."' is " + ."already used by an existing directory"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + // ----- Look if file is write protected + else if (!is_writeable($p_entry['filename'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected"); + + // ----- Change the file status + $p_entry['status'] = "write_protected"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, + "Filename '".$p_entry['filename']."' exists " + ."and is write protected"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Look if the extracted file is older + else if (filemtime($p_entry['filename']) > $p_entry['mtime']) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")"); + // ----- Change the file status + if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) + && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_REPLACE_NEWER is selected, file will be replaced"); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be replaced"); + $p_entry['status'] = "newer_exist"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, + "Newer version of '".$p_entry['filename']."' exists " + ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is older than the extrated one - will be replaced by the extracted one (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")"); + } + } + + // ----- Check the directory availability and create it if necessary + else { + if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) + $v_dir_to_check = $p_entry['filename']; + else if (!strstr($p_entry['filename'], "/")) + $v_dir_to_check = ""; + else + $v_dir_to_check = dirname($p_entry['filename']); + + if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'"); + + // ----- Change the file status + $p_entry['status'] = "path_creation_fail"; + + // ----- Return + ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + //return $v_result; + $v_result = 1; + } + } + } + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) + { + // ----- Look for not compressed file + if ($p_entry['compression'] == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); + + // ----- Opening destination file + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode"); + + // ----- Change the file status + $p_entry['status'] = "write_error"; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read '".$p_entry['size']."' bytes"); + + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks + $v_size = $p_entry['compressed_size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes"); + $v_buffer = @fread($this->zip_fd, $v_read_size); + /* Try to speed up the code + $v_binary_data = pack('a'.$v_read_size, $v_buffer); + @fwrite($v_dest_file, $v_binary_data, $v_read_size); + */ + @fwrite($v_dest_file, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Closing the destination file + fclose($v_dest_file); + + // ----- Change the file mtime + touch($p_entry['filename'], $p_entry['mtime']); + + + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (Compression method ".$p_entry['compression'].")"); + // ----- TBC + // Need to be finished + if (($p_entry['flag'] & 1) == 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File is encrypted"); + /* + // ----- Read the encryption header + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read 12 encryption header bytes"); + $v_encryption_header = @fread($this->zip_fd, 12); + + // ----- Read the encrypted & compressed file in a buffer + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".($p_entry['compressed_size']-12)."' compressed & encrypted bytes"); + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']-12); + + // ----- Decrypt the buffer + $this->privDecrypt($v_encryption_header, $v_buffer, + $p_entry['compressed_size']-12, $p_entry['crc']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Buffer is '".$v_buffer."'"); + */ + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".$p_entry['compressed_size']."' compressed bytes"); + // ----- Read the compressed file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + } + + // ----- Decompress the file + $v_file_content = @gzinflate($v_buffer); + unset($v_buffer); + if ($v_file_content === FALSE) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to inflate compressed file"); + + // ----- Change the file status + // TBC + $p_entry['status'] = "error"; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Opening destination file + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode"); + + // ----- Change the file status + $p_entry['status'] = "write_error"; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Write the uncompressed data + @fwrite($v_dest_file, $v_file_content, $p_entry['size']); + unset($v_file_content); + + // ----- Closing the destination file + @fclose($v_dest_file); + + // ----- Change the file mtime + @touch($p_entry['filename'], $p_entry['mtime']); + } + + // ----- Look for chmod option + if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'"); + + // ----- Change the mode of the file + @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); + } + } + + // ----- Change abort status + if ($p_entry['status'] == "aborted") { + $p_entry['status'] = "skipped"; + } + + // ----- Look for post-extract callback + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + $v_result = PCLZIP_ERR_USER_ABORTED; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFileInOutput() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privExtractFileInOutput(&$p_entry, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileInOutput', ""); + $v_result=1; + + // ----- Read the file header + if (($v_result = $this->privReadFileHeader($v_header)) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + // ----- Look for pre-extract callback + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); + if ($v_result == 0) { + // ----- Change the file status + $p_entry['status'] = "skipped"; + $v_result = 1; + } + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + // ----- This status is internal and will be changed in 'skipped' + $p_entry['status'] = "aborted"; + $v_result = PCLZIP_ERR_USER_ABORTED; + } + + // ----- Update the informations + // Only some fields can be modified + $p_entry['filename'] = $v_local_header['filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'"); + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'"); + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) { + // ----- Look for not compressed file + if ($p_entry['compressed_size'] == $p_entry['size']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes"); + + // ----- Read the file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Send the file to the output + echo $v_buffer; + unset($v_buffer); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes"); + + // ----- Read the compressed file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Decompress the file + $v_file_content = gzinflate($v_buffer); + unset($v_buffer); + + // ----- Send the file to the output + echo $v_file_content; + unset($v_file_content); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); + } + } + + // ----- Change abort status + if ($p_entry['status'] == "aborted") { + $p_entry['status'] = "skipped"; + } + + // ----- Look for post-extract callback + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + $v_result = PCLZIP_ERR_USER_ABORTED; + } + } + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFileAsString() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privExtractFileAsString(&$p_entry, &$p_string) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'"); + $v_result=1; + + // ----- Read the file header + $v_header = array(); + if (($v_result = $this->privReadFileHeader($v_header)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'"); + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) + { + // ----- Look for not compressed file +// if ($p_entry['compressed_size'] == $p_entry['size']) + if ($p_entry['compression'] == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes"); + + // ----- Reading the file + $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (compression method '".$p_entry['compression']."')"); + + // ----- Reading the file + $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Decompress the file + if (($p_string = @gzinflate($v_data)) === FALSE) { + // TBC + } + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); + } + else { + // TBC : error : can not extract a folder in a string + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", ""); + $v_result=1; + + // ----- Read the 4 bytes signature + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + + // ----- Check signature + if ($v_data['id'] != 0x04034b50) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header"); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read the first 42 bytes of the header + $v_binary_data = fread($this->zip_fd, 26); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 26) + { + $p_header['filename'] = ""; + $p_header['status'] = "invalid_header"; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Extract the values + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'"); + $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); + + // ----- Get filename + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']); + $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\''); + + // ----- Get extra_fields + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']); + if ($v_data['extra_len'] != 0) { + $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); + } + else { + $p_header['extra'] = ''; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\''); + + // ----- Extract properties + $p_header['version_extracted'] = $v_data['version']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : ('.$p_header['version_extracted'].') \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\''); + $p_header['compression'] = $v_data['compression']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.$p_header['compression'].'\''); + $p_header['size'] = $v_data['size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\''); + $p_header['compressed_size'] = $v_data['compressed_size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\''); + $p_header['crc'] = $v_data['crc']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\''); + $p_header['flag'] = $v_data['flag']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\''); + $p_header['filename_len'] = $v_data['filename_len']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename_len : \''.$p_header['filename_len'].'\''); + + // ----- Recuperate date in UNIX format + $p_header['mdate'] = $v_data['mdate']; + $p_header['mtime'] = $v_data['mtime']; + if ($p_header['mdate'] && $p_header['mtime']) + { + // ----- Extract time + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; + $v_seconde = ($p_header['mtime'] & 0x001F)*2; + + // ----- Extract date + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; + $v_day = $p_header['mdate'] & 0x001F; + + // ----- Get UNIX date format + $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + else + { + $p_header['mtime'] = time(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + + // TBC + //for(reset($v_data); $key = key($v_data); next($v_data)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]); + //} + + // ----- Set the stored filename + $p_header['stored_filename'] = $p_header['filename']; + + // ----- Set the status field + $p_header['status'] = "ok"; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadCentralFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadCentralFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", ""); + $v_result=1; + + // ----- Read the 4 bytes signature + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + + // ----- Check signature + if ($v_data['id'] != 0x02014b50) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature"); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read the first 42 bytes of the header + $v_binary_data = fread($this->zip_fd, 42); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 42) + { + $p_header['filename'] = ""; + $p_header['status'] = "invalid_header"; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Extract the values + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'"); + $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data); + + // ----- Get filename + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']); + if ($p_header['filename_len'] != 0) + $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); + else + $p_header['filename'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\''); + + // ----- Get extra + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']); + if ($p_header['extra_len'] != 0) + $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); + else + $p_header['extra'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\''); + + // ----- Get comment + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']); + if ($p_header['comment_len'] != 0) + $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); + else + $p_header['comment'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\''); + + // ----- Extract properties + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\''); + + // ----- Recuperate date in UNIX format + if ($p_header['mdate'] && $p_header['mtime']) + { + // ----- Extract time + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; + $v_seconde = ($p_header['mtime'] & 0x001F)*2; + + // ----- Extract date + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; + $v_day = $p_header['mdate'] & 0x001F; + + // ----- Get UNIX date format + $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + else + { + $p_header['mtime'] = time(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + + // ----- Set the stored filename + $p_header['stored_filename'] = $p_header['filename']; + + // ----- Set default status to ok + $p_header['status'] = 'ok'; + + // ----- Look if it is a directory + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')'); + if (substr($p_header['filename'], -1) == '/') { + //$p_header['external'] = 0x41FF0010; + $p_header['external'] = 0x00000010; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.sprintf("Ox%04X", $p_header['external']).'\''); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCheckFileHeaders() + // Description : + // Parameters : + // Return Values : + // 1 on success, + // 0 on error; + // -------------------------------------------------------------------------------- + function privCheckFileHeaders(&$p_local_header, &$p_central_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFileHeaders", ""); + $v_result=1; + + // ----- Check the static values + // TBC + if ($p_local_header['filename'] != $p_central_header['filename']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename" : TBC To Be Completed'); + } + if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "version_extracted" : TBC To Be Completed'); + } + if ($p_local_header['flag'] != $p_central_header['flag']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "flag" : TBC To Be Completed'); + } + if ($p_local_header['compression'] != $p_central_header['compression']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "compression" : TBC To Be Completed'); + } + if ($p_local_header['mtime'] != $p_central_header['mtime']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "mtime" : TBC To Be Completed'); + } + if ($p_local_header['filename_len'] != $p_central_header['filename_len']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename_len" : TBC To Be Completed'); + } + + // ----- Look for flag bit 3 + if (($p_local_header['flag'] & 8) == 8) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Purpose bit flag bit 3 set !'); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'File size, compression size and crc found in central header'); + $p_local_header['size'] = $p_central_header['size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_local_header['size'].'\''); + $p_local_header['compressed_size'] = $p_central_header['compressed_size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_local_header['compressed_size'].'\''); + $p_local_header['crc'] = $p_central_header['crc']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_local_header['crc']).'\''); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadEndCentralDir() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadEndCentralDir(&$p_central_dir) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", ""); + $v_result=1; + + // ----- Go to the end of the zip file + $v_size = filesize($this->zipname); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size"); + @fseek($this->zip_fd, $v_size); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\''); + if (@ftell($this->zip_fd) != $v_size) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- First try : look if this is an archive with no commentaries (most of the time) + // in this case the end of central dir is at 22 bytes of the file end + $v_found = 0; + if ($v_size > 26) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment'); + @fseek($this->zip_fd, $v_size-22); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\''); + if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read for bytes + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = @unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + + // ----- Check signature + if ($v_data['id'] == 0x06054b50) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position."); + $v_found = 1; + } + + $v_pos = ftell($this->zip_fd); + } + + // ----- Go back to the maximum possible size of the Central Dir End Record + if (!$v_found) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir'); + $v_maximum_size = 65557; // 0xFFFF + 22; + if ($v_maximum_size > $v_size) + $v_maximum_size = $v_size; + @fseek($this->zip_fd, $v_size-$v_maximum_size); + if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\''); + + // ----- Read byte per byte in order to find the signature + $v_pos = ftell($this->zip_fd); + $v_bytes = 0x00000000; + while ($v_pos < $v_size) + { + // ----- Read a byte + $v_byte = @fread($this->zip_fd, 1); + + // ----- Add the byte + $v_bytes = ($v_bytes << 8) | Ord($v_byte); + + // ----- Compare the bytes + if ($v_bytes == 0x504b0506) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\''); + $v_pos++; + break; + } + + $v_pos++; + } + + // ----- Look if not found end of central dir + if ($v_pos == $v_size) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature"); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Read the first 18 bytes of the header + $v_binary_data = fread($this->zip_fd, 18); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 18) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Extract the values + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'"); + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'"); + $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); + + // ----- Check the global size + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']); + if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The central dir is not at the end of the archive. Some trailing bytes exists after the archive."); + + // ----- Removed in release 2.2 see readme file + // The check of the file size is a little too strict. + // Some bugs where found when a zip is encrypted/decrypted with 'crypt'. + // While decrypted, zip has training 0 bytes + if (0) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, + 'The central dir is not at the end of the archive.' + .' Some trailing bytes exists after the archive.'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Get comment + if ($v_data['comment_size'] != 0) + $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); + else + $p_central_dir['comment'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\''); + + $p_central_dir['entries'] = $v_data['entries']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\''); + $p_central_dir['disk_entries'] = $v_data['disk_entries']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\''); + $p_central_dir['offset'] = $v_data['offset']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\''); + $p_central_dir['size'] = $v_data['size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\''); + $p_central_dir['disk'] = $v_data['disk']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\''); + $p_central_dir['disk_start'] = $v_data['disk_start']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\''); + + // TBC + //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]); + //} + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDeleteByRule() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDeleteByRule(&$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", ""); + $v_result=1; + $v_list_detail = array(); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + + // ----- Scan all the files + // ----- Start at beginning of Central Dir + $v_pos_entry = $v_central_dir['offset']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_pos_entry)) + { + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Read each entry + $v_header_list = array(); + $j_start = 0; + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')"); + + // ----- Read the file header + $v_header_list[$v_nb_extracted] = array(); + if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'"); + + // ----- Store the index + $v_header_list[$v_nb_extracted]['index'] = $i; + + // ----- Look for the specific extract rules + $v_found = false; + + // ----- Look for extract by name rule + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'"); + + // ----- Look if the filename is in the list + for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) + && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path"); + $v_found = true; + } + elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ + && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory"); + $v_found = true; + } + } + // ----- Look for a filename + elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one."); + $v_found = true; + } + } + } + + // ----- Look for extract by ereg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); + + if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_found = true; + } + } + + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'"); + + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_found = true; + } + } + + // ----- Look for extract by index rule + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'"); + + // ----- Look if the index is in the list + for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range"); + $v_found = true; + } + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop"); + $j_start = $j+1; + } + + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop"); + break; + } + } + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "No argument mean remove all file"); + $v_found = true; + } + + // ----- Look for deletion + if ($v_found) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted"); + unset($v_header_list[$v_nb_extracted]); + } + else + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted"); + $v_nb_extracted++; + } + } + + // ----- Look if something need to be deleted + if ($v_nb_extracted > 0) { + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Creates a temporary zip archive + $v_temp_zip = new PclZip($v_zip_temp_name); + + // ----- Open the temporary zip file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode"); + if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { + $this->privCloseFd(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look which file need to be kept + for ($i=0; $izip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Read the file header + $v_local_header = array(); + if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Check that local file header is same as central file header + if ($this->privCheckFileHeaders($v_local_header, + $v_header_list[$i]) != 1) { + // TBC + } + unset($v_local_header); + + // ----- Write the file header + if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'"); + + // ----- Read/write the data block + if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($v_temp_zip->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset"); + + // ----- Re-Create the Central Dir files header + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory"); + for ($i=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Transform the header to a 'usable' info + $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer"); + + // ----- Zip file comment + $v_comment = ''; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { + // ----- Reset the file list + unset($v_header_list); + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Close + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Destroy the temporary archive + unset($v_temp_zip); + } + + // ----- Remove every files : reset the file + else if ($v_central_dir['entries'] != 0) { + $this->privCloseFd(); + + if (($v_result = $this->privOpenFd('wb')) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + $this->privCloseFd(); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDirCheck() + // Description : + // Check if a directory exists, if not it creates it and all the parents directory + // which may be useful. + // Parameters : + // $p_dir : Directory path to check. + // Return Values : + // 1 : OK + // -1 : Unable to create directory + // -------------------------------------------------------------------------------- + function privDirCheck($p_dir, $p_is_dir=false) + { + $v_result = 1; + + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'"); + + // ----- Remove the final '/' + if (($p_is_dir) && (substr($p_dir, -1)=='/')) + { + $p_dir = substr($p_dir, 0, strlen($p_dir)-1); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'"); + + // ----- Check the directory availability + if ((is_dir($p_dir)) || ($p_dir == "")) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory"); + return 1; + } + + // ----- Extract parent directory + $p_parent_dir = dirname($p_dir); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'"); + + // ----- Just a check + if ($p_parent_dir != $p_dir) + { + // ----- Look for parent directory + if ($p_parent_dir != "") + { + if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + } + + // ----- Create the directory + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'"); + if (!@mkdir($p_dir, 0777)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created"); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privMerge() + // Description : + // If $p_archive_to_add does not exist, the function exit with a success result. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privMerge(&$p_archive_to_add) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'"); + $v_result=1; + + // ----- Look if the archive_to_add exists + if (!is_file($p_archive_to_add->zipname)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge."); + + // ----- Nothing to merge, so merge is a success + $v_result = 1; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look if the archive exists + if (!is_file($this->zipname)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add."); + + // ----- Do a duplicate + $v_result = $this->privDuplicate($p_archive_to_add->zipname); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'"); + + // ----- Open the archive_to_add file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode"); + if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) + { + $this->privCloseFd(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir_to_add = array(); + if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'"); + @rewind($p_archive_to_add->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'"); + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Open the temporary file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = $v_central_dir['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Copy the files from the archive_to_add into the temporary file + $v_size = $v_central_dir_to_add['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($v_zip_temp_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset"); + + // ----- Copy the block of file headers from the old archive + $v_size = $v_central_dir['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Copy the block of file headers from the archive_to_add + $v_size = $v_central_dir_to_add['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Merge the file comments + $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; + + // ----- Calculate the size of the (new) central header + $v_size = @ftell($v_zip_temp_fd)-$v_offset; + + // ----- Swap the file descriptor + // Here is a trick : I swap the temporary fd with the zip fd, in order to use + // the following methods on the temporary fil and not the real archive fd + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + @fclose($v_zip_temp_fd); + $this->zip_fd = null; + + // ----- Reset the file list + unset($v_header_list); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Swap back the file descriptor + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Close + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDuplicate() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDuplicate($p_archive_filename) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'"); + $v_result=1; + + // ----- Look if the $p_archive_filename exists + if (!is_file($p_archive_filename)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate."); + + // ----- Nothing to duplicate, so duplicate is a success. + $v_result = 1; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('wb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Open the temporary file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) + { + $this->privCloseFd(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = filesize($p_archive_filename); + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes"); + $v_buffer = fread($v_zip_temp_fd, $v_read_size); + @fwrite($this->zip_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Close + $this->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privErrorLog() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privErrorLog($p_error_code=0, $p_error_string='') + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + PclError($p_error_code, $p_error_string); + } + else { + $this->error_code = $p_error_code; + $this->error_string = $p_error_string; + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privErrorReset() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privErrorReset() + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + PclErrorReset(); + } + else { + $this->error_code = 0; + $this->error_string = ''; + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDecrypt() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDecrypt($p_encryption_header, &$p_buffer, $p_size, $p_crc) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDecrypt', "size=".$p_size.""); + $v_result=1; + + // ----- To Be Modified ;-) + $v_pwd = "test"; + + $p_buffer = PclZipUtilZipDecrypt($p_buffer, $p_size, $p_encryption_header, + $p_crc, $v_pwd); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDisableMagicQuotes() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDisableMagicQuotes() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDisableMagicQuotes', ""); + $v_result=1; + + // ----- Look if function exists + if ( (!function_exists("get_magic_quotes_runtime")) + || (!function_exists("set_magic_quotes_runtime"))) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look if already done + if ($this->magic_quotes_status != -1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote already disabled"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Get and memorize the magic_quote value + $this->magic_quotes_status = @get_magic_quotes_runtime(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Current magic_quotes_runtime status is '".($this->magic_quotes_status==0?'disable':'enable')."'"); + + // ----- Disable magic_quotes + if ($this->magic_quotes_status == 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Disable magic_quotes"); + @set_magic_quotes_runtime(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privSwapBackMagicQuotes() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privSwapBackMagicQuotes() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', ""); + $v_result=1; + + // ----- Look if function exists + if ( (!function_exists("get_magic_quotes_runtime")) + || (!function_exists("set_magic_quotes_runtime"))) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look if something to do + if ($this->magic_quotes_status != -1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Swap back magic_quotes + if ($this->magic_quotes_status == 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes"); + @set_magic_quotes_runtime($this->magic_quotes_status); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + } + // End of class + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilPathReduction() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function PclZipUtilPathReduction($p_dir) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'"); + $v_result = ""; + + // ----- Look for not empty path + if ($p_dir != "") { + // ----- Explode path by directory names + $v_list = explode("/", $p_dir); + + // ----- Study directories from last to first + $v_skip = 0; + for ($i=sizeof($v_list)-1; $i>=0; $i--) { + // ----- Look for current path + if ($v_list[$i] == ".") { + // ----- Ignore this directory + // Should be the first $i=0, but no check is done + } + else if ($v_list[$i] == "..") { + $v_skip++; + } + else if ($v_list[$i] == "") { + // ----- First '/' i.e. root slash + if ($i == 0) { + $v_result = "/".$v_result; + if ($v_skip > 0) { + // ----- It is an invalid path, so the path is not modified + // TBC + $v_result = $p_dir; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid path is unchanged"); + $v_skip = 0; + } + } + // ----- Last '/' i.e. indicates a directory + else if ($i == (sizeof($v_list)-1)) { + $v_result = $v_list[$i]; + } + // ----- Double '/' inside the path + else { + // ----- Ignore only the double '//' in path, + // but not the first and last '/' + } + } + else { + // ----- Look for item to skip + if ($v_skip > 0) { + $v_skip--; + } + else { + $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); + } + } + } + + // ----- Look for skip + if ($v_skip > 0) { + while ($v_skip > 0) { + $v_result = '../'.$v_result; + $v_skip--; + } + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilPathInclusion() + // Description : + // This function indicates if the path $p_path is under the $p_dir tree. Or, + // said in an other way, if the file or sub-dir $p_path is inside the dir + // $p_dir. + // The function indicates also if the path is exactly the same as the dir. + // This function supports path with duplicated '/' like '//', but does not + // support '.' or '..' statements. + // Parameters : + // Return Values : + // 0 if $p_path is not inside directory $p_dir + // 1 if $p_path is inside directory $p_dir + // 2 if $p_path is exactly the same as $p_dir + // -------------------------------------------------------------------------------- + function PclZipUtilPathInclusion($p_dir, $p_path) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'"); + $v_result = 1; + + // ----- Look for path beginning by ./ + if ( ($p_dir == '.') + || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { + $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_dir '".$p_dir."'"); + } + if ( ($p_path == '.') + || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { + $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_path '".$p_path."'"); + } + + // ----- Explode dir and path by directory separator + $v_list_dir = explode("/", $p_dir); + $v_list_dir_size = sizeof($v_list_dir); + $v_list_path = explode("/", $p_path); + $v_list_path_size = sizeof($v_list_path); + + // ----- Study directories paths + $i = 0; + $j = 0; + while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'"); + + // ----- Look for empty dir (path reduction) + if ($v_list_dir[$i] == '') { + $i++; + continue; + } + if ($v_list_path[$j] == '') { + $j++; + continue; + } + + // ----- Compare the items + if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different"); + $v_result = 0; + } + + // ----- Next items + $i++; + $j++; + } + + // ----- Look if everything seems to be the same + if ($v_result) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break"); + // ----- Skip all the empty items + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'"); + + if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { + // ----- There are exactly the same + $v_result = 2; + } + else if ($i < $v_list_dir_size) { + // ----- The path is shorter than the dir + $v_result = 0; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilCopyBlock() + // Description : + // Parameters : + // $p_mode : read/write compression mode + // 0 : src & dest normal + // 1 : src gzip, dest normal + // 2 : src normal, dest gzip + // 3 : src & dest gzip + // Return Values : + // -------------------------------------------------------------------------------- + function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode"); + $v_result = 1; + + if ($p_mode==0) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src))); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest))); + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($p_src, $v_read_size); + @fwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src))); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest))); + } + else if ($p_mode==1) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @gzread($p_src, $v_read_size); + @fwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + else if ($p_mode==2) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($p_src, $v_read_size); + @gzwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + else if ($p_mode==3) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @gzread($p_src, $v_read_size); + @gzwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilRename() + // Description : + // This function tries to do a simple rename() function. If it fails, it + // tries to copy the $p_src file in a new $p_dest file and then unlink the + // first one. + // Parameters : + // $p_src : Old filename + // $p_dest : New filename + // Return Values : + // 1 on success, 0 on failure. + // -------------------------------------------------------------------------------- + function PclZipUtilRename($p_src, $p_dest) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest"); + $v_result = 1; + + // ----- Try to rename the files + if (!@rename($p_src, $p_dest)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink"); + + // ----- Try to copy & unlink the src + if (!@copy($p_src, $p_dest)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file"); + $v_result = 0; + } + else if (!@unlink($p_src)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename"); + $v_result = 0; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilOptionText() + // Description : + // Translate option value in text. Mainly for debug purpose. + // Parameters : + // $p_option : the option value. + // Return Values : + // The option text value. + // -------------------------------------------------------------------------------- + function PclZipUtilOptionText($p_option) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'"); + + $v_list = get_defined_constants(); + for (reset($v_list); $v_key = key($v_list); next($v_list)) { + $v_prefix = substr($v_key, 0, 10); + if (( ($v_prefix == 'PCLZIP_OPT') + || ($v_prefix == 'PCLZIP_CB_') + || ($v_prefix == 'PCLZIP_ATT')) + && ($v_list[$v_key] == $p_option)) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key); + return $v_key; + } + } + + $v_result = 'Unknown'; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilTranslateWinPath() + // Description : + // Translate windows path by replacing '\' by '/' and optionally removing + // drive letter. + // Parameters : + // $p_path : path to translate. + // $p_remove_disk_letter : true | false + // Return Values : + // The path translated. + // -------------------------------------------------------------------------------- + function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) + { + if (stristr(php_uname(), 'windows')) { + // ----- Look for potential disk letter + if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { + $p_path = substr($p_path, $v_position+1); + } + // ----- Change potential windows directory separator + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { + $p_path = strtr($p_path, '\\', '/'); + } + } + return $p_path; + } + // -------------------------------------------------------------------------------- + + +?> diff --git a/wp-admin/includes/class-wp-filesystem-direct.php b/wp-admin/includes/class-wp-filesystem-direct.php new file mode 100644 index 0000000..d698b20 --- /dev/null +++ b/wp-admin/includes/class-wp-filesystem-direct.php @@ -0,0 +1,336 @@ +errors = new WP_Error(); + $this->permission = umask(); + } + function connect(){ + return; + } + function setDefaultPermissions($perm){ + $this->permission = $perm; + } + function find_base_dir($base = '.', $echo = false){ + return str_replace('\\','/',ABSPATH); + } + function get_base_dir($base = '.', $echo = false){ + return find_base_dir($base, $echo); + } + function get_contents($file){ + return @file_get_contents($file); + } + function get_contents_array($file){ + return @file($file); + } + function put_contents($file,$contents,$mode=false,$type=''){ + $fp=@fopen($file,'w'.$type); + if (!$fp) + return false; + @fwrite($fp,$contents); + @fclose($fp); + $this->chmod($file,$mode); + return true; + } + function cwd(){ + return @getcwd(); + } + function chgrp($file,$group,$recursive=false){ + if( ! $this->exists($file) ) + return false; + if( ! $recursive ) + return @chgrp($file,$group); + if( ! $this->is_dir($file) ) + return @chgrp($file,$group); + //Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach($filelist as $filename){ + $this->chgrp($file.'/'.$filename,$group,$recursive); + } + return true; + } + function chmod($file,$mode=false,$recursive=false){ + if( ! $mode ) + $mode = $this->permission; + if( ! $this->exists($file) ) + return false; + if( ! $recursive ) + return @chmod($file,$mode); + if( ! $this->is_dir($file) ) + return @chmod($file,$mode); + //Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach($filelist as $filename){ + $this->chmod($file.'/'.$filename,$mode,$recursive); + } + return true; + } + function chown($file,$owner,$recursive=false){ + if( ! $this->exists($file) ) + return false; + if( ! $recursive ) + return @chown($file,$owner); + if( ! $this->is_dir($file) ) + return @chown($file,$owner); + //Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach($filelist as $filename){ + $this->chown($file.'/'.$filename,$owner,$recursive); + } + return true; + } + function owner($file){ + $owneruid=@fileowner($file); + if( ! $owneruid ) + return false; + if( !function_exists('posix_getpwuid') ) + return $owneruid; + $ownerarray=posix_getpwuid($owneruid); + return $ownerarray['name']; + } + function getchmod($file){ + return @fileperms($file); + } + function gethchmod($file){ + //From the PHP.net page for ...? + $perms = $this->getchmod($file); + if (($perms & 0xC000) == 0xC000) { + // Socket + $info = 's'; + } elseif (($perms & 0xA000) == 0xA000) { + // Symbolic Link + $info = 'l'; + } elseif (($perms & 0x8000) == 0x8000) { + // Regular + $info = '-'; + } elseif (($perms & 0x6000) == 0x6000) { + // Block special + $info = 'b'; + } elseif (($perms & 0x4000) == 0x4000) { + // Directory + $info = 'd'; + } elseif (($perms & 0x2000) == 0x2000) { + // Character special + $info = 'c'; + } elseif (($perms & 0x1000) == 0x1000) { + // FIFO pipe + $info = 'p'; + } else { + // Unknown + $info = 'u'; + } + + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); + + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); + + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); + return $info; + } + function getnumchmodfromh($mode) { + $realmode = ""; + $legal = array("","w","r","x","-"); + $attarray = preg_split("//",$mode); + for($i=0;$i'0','r'=>'4','w'=>'2','x'=>'1'); + $mode = strtr($mode,$trans); + $newmode = ''; + $newmode .= $mode[0]+$mode[1]+$mode[2]; + $newmode .= $mode[3]+$mode[4]+$mode[5]; + $newmode .= $mode[6]+$mode[7]+$mode[8]; + return $newmode; + } + function group($file){ + $gid=@filegroup($file); + if( ! $gid ) + return false; + if( !function_exists('posix_getgrgid') ) + return $gid; + $grouparray=posix_getgrgid($gid); + return $grouparray['name']; + } + + function copy($source,$destination,$overwrite=false){ + if( $overwrite && $this->exists($destination) ) + return false; + return copy($source,$destination); + } + + function move($source,$destination,$overwrite=false){ + //Possible to use rename() + if( $this->copy($source,$destination,$overwrite) && $this->exists($destination) ){ + $this->delete($source); + return true; + } else { + return false; + } + } + + function delete($file,$recursive=false){ + $file = str_replace('\\','/',$file); //for win32, occasional problems deleteing files otherwise + + if( $this->is_file($file) ) + return @unlink($file); + + if( !$recursive && $this->is_dir($file) ) + return @rmdir($file); + + $filelist = $this->dirlist($file); + if( ! $filelist ) + return true; //No files exist, Say we've deleted them + + $retval = true; + foreach($filelist as $filename=>$fileinfo){ + if( ! $this->delete($file.'/'.$filename,$recursive) ) + $retval = false; + } + if( ! @rmdir($file) ) + return false; + return $retval; + } + + function exists($file){ + return @file_exists($file); + } + + function is_file($file){ + return @is_file($file); + } + + function is_dir($path){ + return @is_dir($path); + } + + function is_readable($file){ + return @is_readable($file); + } + + function is_writable($file){ + return @is_writable($file); + } + + function atime($file){ + return @fileatime($file); + } + + function mtime($file){ + return @filemtime($file); + } + function size($file){ + return @filesize($file); + } + + function touch($file,$time=0,$atime=0){ + if($time==0) + $time = time(); + if($atime==0) + $atime = time(); + return @touch($file,$time,$atime); + } + + function mkdir($path,$chmod=false,$chown=false,$chgrp=false){ + if( ! $chmod) + $chmod = $this->permission; + + if( !@mkdir($path,$chmod) ) + return false; + if( $chown ) + $this->chown($path,$chown); + if( $chgrp ) + $this->chgrp($path,$chgrp); + return true; + } + + function rmdir($path,$recursive=false){ + if( ! $recursive ) + return @rmdir($path); + //recursive: + $filelist = $this->dirlist($path); + foreach($filelist as $filename=>$det){ + if ( '/' == substr($filename,-1,1) ) + $this->rmdir($path.'/'.$filename,$recursive); + @rmdir($filename); + } + return @rmdir($path); + } + + function dirlist($path,$incdot=false,$recursive=false){ + if( $this->is_file($path) ){ + $limitFile = basename($path); + $path = dirname($path); + } else { + $limitFile = false; + } + if( ! $this->is_dir($path) ) + return false; + + $ret = array(); + $dir = dir($path); + while (false !== ($entry = $dir->read())) { + $struc = array(); + $struc['name'] = $entry; + + if( '.' == $struc['name'][0] && !$incdot) + continue; + if( $limitFile && $struc['name'] != $limitFile) + continue; + + $struc['perms'] = $this->gethchmod($path.'/'.$entry); + $struc['permsn'] = $this->getnumchmodfromh($struc['perms']); + $struc['number'] = false; + $struc['owner'] = $this->owner($path.'/'.$entry); + $struc['group'] = $this->group($path.'/'.$entry); + $struc['size'] = $this->size($path.'/'.$entry); + $struc['lastmodunix']= $this->mtime($path.'/'.$entry); + $struc['lastmod'] = date('M j',$struc['lastmodunix']); + $struc['time'] = date('h:i:s',$struc['lastmodunix']); + $struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f'; + if ('d' == $struc['type'] ){ + $struc['files'] = array(); + + if( $incdot ){ + //We're including the doted starts + if( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder + if ($recursive) + $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); + } + } else { //No dots + if ($recursive) + $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); + } + } + //File + $ret[$struc['name']] = $struc; + } + $dir->close(); + unset($dir); + return $ret; + } + + function __destruct(){ + return; + } +} +?> diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php new file mode 100644 index 0000000..a8a3585 --- /dev/null +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -0,0 +1,480 @@ +FTP_ASCII, + 'css'=>FTP_ASCII, + 'txt'=>FTP_ASCII, + 'js'=>FTP_ASCII, + 'html'=>FTP_ASCII, + 'htm'=>FTP_ASCII, + 'xml'=>FTP_ASCII, + + 'jpg'=>FTP_BINARY, + 'png'=>FTP_BINARY, + 'gif'=>FTP_BINARY, + 'bmp'=>FTP_BINARY + ); + + function WP_Filesystem_FTPext($opt='') { + $this->errors = new WP_Error(); + + //Check if possible to use ftp functions. + if ( ! extension_loaded('ftp') ) { + $this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available')); + return false; + } + + // Set defaults: + if ( empty($opt['port']) ) + $this->options['port'] = 21; + else + $this->options['port'] = $opt['port']; + + if ( empty($opt['hostname']) ) + $this->errors->add('empty_hostname', __('FTP hostname is required')); + else + $this->options['hostname'] = $opt['hostname']; + + if ( isset($opt['base']) && ! empty($opt['base']) ) + $this->wp_base = $opt['base']; + + // Check if the options provided are OK. + if ( empty ($opt['username']) ) + $this->errors->add('empty_username', __('FTP username is required')); + else + $this->options['username'] = $opt['username']; + + if ( empty ($opt['password']) ) + $this->errors->add('empty_password', __('FTP password is required')); + else + $this->options['password'] = $opt['password']; + + $this->options['ssl'] = ( !empty($opt['ssl']) ); + } + + function connect(){ + if ( $this->options['ssl'] && function_exists('ftp_ssl_connect') ) { + $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'],$this->timeout); + } else { + $this->link = @ftp_connect($this->options['hostname'], $this->options['port'],$this->timeout); + } + + if ( ! $this->link ) { + $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); + return false; + } + + if ( ! @ftp_login($this->link,$this->options['username'], $this->options['password']) ) { + $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username'])); + return false; + } + + return true; + } + + function setDefaultPermissions($perm){ + $this->permission = $perm; + } + + function find_base_dir($base = '.',$echo = false){ + $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. + if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter + if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) + $abspath = $mat[1]; + } + + if( empty( $base ) || '.' == $base ) $base = $this->cwd(); + if( empty( $base ) ) $base = '/'; + if( '/' != substr($base, -1) ) $base .= '/'; + + if($echo) echo __('Changing to ') . $base .'
'; + if( false === $this->chdir($base) ) + return false; + + if( $this->exists($base . 'wp-settings.php') ){ + if($echo) echo __('Found ') . $base . 'wp-settings.php
'; + $this->wp_base = $base; + return $this->wp_base; + } + + if( strpos($abspath, $base) > 0) + $arrPath = split('/',substr($abspath,strpos($abspath, $base))); + else + $arrPath = split('/',$abspath); + + for($i = 0; $i <= count($arrPath); $i++) + if( $arrPath[ $i ] == '' ) unset( $arrPath[ $i ] ); + + foreach($arrPath as $key=>$folder){ + if( $this->is_dir($base . $folder) ){ + if($echo) echo __('Found ') . $folder . ' ' . __('Changing to') . ' ' . $base . $folder . '/
'; + return $this->find_base_dir($base . $folder . '/',$echo); + } + } + + if( $base == '/' ) + return false; + //If we get this far, somethings gone wrong, change to / and restart the process. + return $this->find_base_dir('/',$echo); + } + function get_base_dir($base = '.', $echo=false){ + if( empty($this->wp_base) ) + $this->wp_base = $this->find_base_dir($base,$echo); + return $this->wp_base; + } + function get_contents($file,$type='',$resumepos=0){ + if( empty($type) ){ + $extension = substr(strrchr($file, "."), 1); + $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; + } + $temp = tmpfile(); + if( ! @ftp_fget($this->link,$temp,$file,$type,$resumepos) ) + return false; + fseek($temp, 0); //Skip back to the start of the file being written to + $contents = ''; + while (!feof($temp)) { + $contents .= fread($temp, 8192); + } + fclose($temp); + return $contents; + } + function get_contents_array($file){ + return explode("\n",$this->get_contents($file)); + } + function put_contents($file,$contents,$type=''){ + if( empty($type) ){ + $extension = substr(strrchr($filename, "."), 1); + $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; + } + $temp = tmpfile(); + fwrite($temp,$contents); + fseek($temp, 0); //Skip back to the start of the file being written to + $ret = @ftp_fput($this->link,$file,$temp,$type); + fclose($temp); + return $ret; + } + function cwd(){ + return ftp_pwd($this->link); + } + function chdir($dir){ + return @ftp_chdir($dir); + } + function chgrp($file,$group,$recursive=false){ + return false; + } + function chmod($file,$mode=false,$recursive=false){ + if( ! $mode ) + $mode = $this->permission; + if( ! $mode ) + return false; + if ( ! $this->exists($file) ) + return false; + if ( ! $recursive || ! $this->is_dir($file) ){ + if (!function_exists('ftp_chmod')) + return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); + return @ftp_chmod($this->link,$mode,$file); + } + //Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach($filelist as $filename){ + $this->chmod($file.'/'.$filename,$mode,$recursive); + } + return true; + } + function chown($file,$owner,$recursive=false){ + return false; + } + function owner($file){ + $dir = $this->dirlist($file); + return $dir[$file]['owner']; + } + function getchmod($file){ + $dir = $this->dirlist($file); + return $dir[$file]['permsn']; + } + function gethchmod($file){ + //From the PHP.net page for ...? + $perms = $this->getchmod($file); + if (($perms & 0xC000) == 0xC000) { + // Socket + $info = 's'; + } elseif (($perms & 0xA000) == 0xA000) { + // Symbolic Link + $info = 'l'; + } elseif (($perms & 0x8000) == 0x8000) { + // Regular + $info = '-'; + } elseif (($perms & 0x6000) == 0x6000) { + // Block special + $info = 'b'; + } elseif (($perms & 0x4000) == 0x4000) { + // Directory + $info = 'd'; + } elseif (($perms & 0x2000) == 0x2000) { + // Character special + $info = 'c'; + } elseif (($perms & 0x1000) == 0x1000) { + // FIFO pipe + $info = 'p'; + } else { + // Unknown + $info = 'u'; + } + + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); + + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); + + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); + return $info; + } + function getnumchmodfromh($mode) { + $realmode = ""; + $legal = array("","w","r","x","-"); + $attarray = preg_split("//",$mode); + for($i=0;$i'0','r'=>'4','w'=>'2','x'=>'1'); + $mode = strtr($mode,$trans); + $newmode = ''; + $newmode .= $mode[0]+$mode[1]+$mode[2]; + $newmode .= $mode[3]+$mode[4]+$mode[5]; + $newmode .= $mode[6]+$mode[7]+$mode[8]; + return $newmode; + } + function group($file){ + $dir = $this->dirlist($file); + return $dir[$file]['group']; + } + function copy($source,$destination,$overwrite=false){ + if( ! $overwrite && $this->exists($destination) ) + return false; + $content = $this->get_contents($source); + if( false === $content) + return false; + return $this->put_contents($destination,$content); + } + function move($source,$destination,$overwrite=false){ + return ftp_rename($this->link,$source,$destination); + } + + function delete($file,$recursive=false) { + if ( $this->is_file($file) ) + return @ftp_delete($this->link,$file); + if ( !$recursive ) + return @ftp_rmdir($this->link,$file); + $filelist = $this->dirlist($file); + foreach ((array) $filelist as $filename => $fileinfo) { + $this->delete($file.'/'.$filename,$recursive); + } + return @ftp_rmdir($this->link,$file); + } + + function exists($file){ + $list = ftp_rawlist($this->link,$file,false); + if( ! $list ) + return false; + return count($list) == 1 ? true : false; + } + function is_file($file){ + return $this->is_dir($file) ? false : true; + } + function is_dir($path){ + $cwd = $this->cwd(); + @ftp_chdir($this->link, $path); + if ( $this->cwd() != $cwd ) { + @ftp_chdir($this->link, $cwd); + return true; + } + return false; + } + function is_readable($file){ + //Get dir list, Check if the file is writable by the current user?? + return true; + } + function is_writable($file){ + //Get dir list, Check if the file is writable by the current user?? + return true; + } + function atime($file){ + return false; + } + function mtime($file){ + return ftp_mdtm($this->link, $file); + } + function size($file){ + return ftp_size($this->link, $file); + } + function touch($file,$time=0,$atime=0){ + return false; + } + function mkdir($path,$chmod=false,$chown=false,$chgrp=false){ + if( !@ftp_mkdir($this->link, $path) ) + return false; + if( $chmod ) + $this->chmod($path, $chmod); + if( $chown ) + $this->chown($path, $chown); + if( $chgrp ) + $this->chgrp($path, $chgrp); + return true; + } + function rmdir($path,$recursive=false){ + if( ! $recursive ) + return @ftp_rmdir($this->link, $path); + + //TODO: Recursive Directory delete, Have to delete files from the folder first. + //$dir = $this->dirlist($path); + //foreach($dir as $file) + + } + + function parselisting($line) { + $is_windows = ($this->OS_remote == FTP_OS_Windows); + if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|) +(.+)/",$line,$lucifer)) { + $b = array(); + if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix + $b['isdir'] = ($lucifer[7]==""); + if ( $b['isdir'] ) + $b['type'] = 'd'; + else + $b['type'] = 'f'; + $b['size'] = $lucifer[7]; + $b['month'] = $lucifer[1]; + $b['day'] = $lucifer[2]; + $b['year'] = $lucifer[3]; + $b['hour'] = $lucifer[4]; + $b['minute'] = $lucifer[5]; + $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]); + $b['am/pm'] = $lucifer[6]; + $b['name'] = $lucifer[8]; + } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) { + //echo $line."\n"; + $lcount=count($lucifer); + if ($lcount<8) return ''; + $b = array(); + $b['isdir'] = $lucifer[0]{0} === "d"; + $b['islink'] = $lucifer[0]{0} === "l"; + if ( $b['isdir'] ) + $b['type'] = 'd'; + elseif ( $b['islink'] ) + $b['type'] = 'l'; + else + $b['type'] = 'f'; + $b['perms'] = $lucifer[0]; + $b['number'] = $lucifer[1]; + $b['owner'] = $lucifer[2]; + $b['group'] = $lucifer[3]; + $b['size'] = $lucifer[4]; + if ($lcount==8) { + sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']); + sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']); + $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']); + $b['name'] = $lucifer[7]; + } else { + $b['month'] = $lucifer[5]; + $b['day'] = $lucifer[6]; + if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) { + $b['year'] = date("Y"); + $b['hour'] = $l2[1]; + $b['minute'] = $l2[2]; + } else { + $b['year'] = $lucifer[7]; + $b['hour'] = 0; + $b['minute'] = 0; + } + $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute'])); + $b['name'] = $lucifer[8]; + } + } + + return $b; + } + + function dirlist($path='.',$incdot=false,$recursive=false){ + if( $this->is_file($path) ){ + $limitFile = basename($path); + $path = dirname($path) . '/'; + } else { + $limitFile = false; + } + //if( ! $this->is_dir($path) ) + // return false; + $list = ftp_rawlist($this->link , '-a ' . $path, false); + if ( $list === false ) + return false; + + $dirlist = array(); + foreach ( $list as $k => $v ) { + $entry = $this->parselisting($v); + if ( empty($entry) ) + continue; + + if ( $entry["name"]=="." or $entry["name"]==".." ) + continue; + + $dirlist[$entry['name']] = $entry; + } + + if ( ! $dirlist ) + return false; + if ( empty($dirlist) ) + return array(); + + $ret = array(); + foreach ( $dirlist as $struc ) { + + if ( 'd' == $struc['type'] ) { + $struc['files'] = array(); + + if ( $incdot ){ + //We're including the doted starts + if( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder + if ($recursive) + $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); + } + } else { //No dots + if ($recursive) + $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); + } + } + //File + $ret[$struc['name']] = $struc; + } + return $ret; + } + + function __destruct(){ + if( $this->link ) + ftp_close($this->link); + } +} + +?> diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php new file mode 100644 index 0000000..15ab390 --- /dev/null +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -0,0 +1,426 @@ +FTP_ASCII, + 'css'=>FTP_ASCII, + 'txt'=>FTP_ASCII, + 'js'=>FTP_ASCII, + 'html'=>FTP_ASCII, + 'htm'=>FTP_ASCII, + 'xml'=>FTP_ASCII, + + 'jpg'=>FTP_BINARY, + 'png'=>FTP_BINARY, + 'gif'=>FTP_BINARY, + 'bmp'=>FTP_BINARY + ); + + function WP_Filesystem_ftpsockets($opt='') { + $this->errors = new WP_Error(); + + //Check if possible to use ftp functions. + if( ! @include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) + return false; + $this->ftp = new ftp(); + + //Set defaults: + if ( empty($opt['port']) ) + $this->options['port'] = 21; + else + $this->options['port'] = $opt['port']; + + if ( empty($opt['hostname']) ) + $this->errors->add('empty_hostname', __('FTP hostname is required')); + else + $this->options['hostname'] = $opt['hostname']; + + if ( isset($opt['base']) && ! empty($opt['base']) ) + $this->wp_base = $opt['base']; + + // Check if the options provided are OK. + if ( empty ($opt['username']) ) + $this->errors->add('empty_username', __('FTP username is required')); + else + $this->options['username'] = $opt['username']; + + if ( empty ($opt['password']) ) + $this->errors->add('empty_password', __('FTP password is required')); + else + $this->options['password'] = $opt['password']; + } + + function connect() { + if ( ! $this->ftp ) + return false; + + //$this->ftp->Verbose = true; + + if ( ! $this->ftp->SetServer($this->options['hostname'], $this->options['port']) ) { + $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); + return false; + } + if ( ! $this->ftp->connect() ) { + $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); + return false; + } + + if ( ! $this->ftp->login($this->options['username'], $this->options['password']) ) { + $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username'])); + return false; + } + + $this->ftp->SetType(FTP_AUTOASCII); + $this->ftp->Passive(true); + return true; + } + + function setDefaultPermissions($perm) { + $this->permission = $perm; + } + + function find_base_dir($base = '.',$echo = false) { + $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. + if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter + if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) + $abspath = $mat[1]; + } + + if( empty( $base ) || '.' == $base ) $base = $this->cwd(); + if( empty( $base ) ) $base = '/'; + if( '/' != substr($base, -1) ) $base .= '/'; + + if($echo) echo __('Changing to ') . $base .'
'; + if( false === $this->chdir($base) ) + return false; + + if( $this->exists($base . 'wp-settings.php') ){ + if($echo) echo __('Found ') . $base . 'wp-settings.php
'; + $this->wp_base = $base; + return $this->wp_base; + } + + if( strpos($abspath, $base) > 0) + $arrPath = split('/',substr($abspath,strpos($abspath, $base))); + else + $arrPath = split('/',$abspath); + + for($i = 0; $i <= count($arrPath); $i++) + if( $arrPath[ $i ] == '' ) unset( $arrPath[ $i ] ); + + foreach($arrPath as $key=>$folder){ + if( $this->is_dir($base . $folder) ){ + if($echo) echo __('Found ') . $folder . ' ' . __('Changing to') . ' ' . $base . $folder . '/
'; + return $this->find_base_dir($base . $folder . '/',$echo); + } + } + + if( $base == '/' ) + return false; + //If we get this far, somethings gone wrong, change to / and restart the process. + return $this->find_base_dir('/',$echo); + } + + function get_base_dir($base = '.', $echo = false){ + if( empty($this->wp_base) ) + $this->wp_base = $this->find_base_dir($base, $echo); + return $this->wp_base; + } + + function get_contents($file,$type='',$resumepos=0){ + if( ! $this->exists($file) ) + return false; + + if( empty($type) ){ + $extension = substr(strrchr($file, "."), 1); + $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_AUTOASCII; + } + $this->ftp->SetType($type); + $temp = tmpfile(); + if ( ! $this->ftp->fget($temp, $file) ) { + fclose($temp); + return ''; //Blank document, File does exist, Its just blank. + } + fseek($temp, 0); //Skip back to the start of the file being written to + $contents = ''; + while ( !feof($temp) ) + $contents .= fread($temp, 8192); + fclose($temp); + return $contents; + } + + function get_contents_array($file){ + return explode("\n",$this->get_contents($file)); + } + + function put_contents($file,$contents,$type=''){ + if( empty($type) ){ + $extension = substr(strrchr($file, "."), 1); + $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; + } + $this->ftp->SetType($type); + + $temp = tmpfile(); + fwrite($temp,$contents); + fseek($temp, 0); //Skip back to the start of the file being written to + $ret = $this->ftp->fput($file, $temp); + fclose($temp); + return $ret; + } + + function cwd(){ + return $this->ftp->pwd(); + } + + function chdir($file){ + return $this->ftp->chdir($file); + } + + function chgrp($file,$group,$recursive=false){ + return false; + } + + function chmod($file,$mode=false,$recursive=false){ + if( ! $mode ) + $mode = $this->permission; + if( ! $mode ) + return false; + //if( ! $this->exists($file) ) + // return false; + if( ! $recursive || ! $this->is_dir($file) ){ + return $this->ftp->chmod($file,$mode); + } + //Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach($filelist as $filename){ + $this->chmod($file.'/'.$filename,$mode,$recursive); + } + return true; + } + + function chown($file,$owner,$recursive=false){ + return false; + } + + function owner($file){ + $dir = $this->dirlist($file); + return $dir[$file]['owner']; + } + + function getchmod($file){ + $dir = $this->dirlist($file); + return $dir[$file]['permsn']; + } + + function gethchmod($file){ + //From the PHP.net page for ...? + $perms = $this->getchmod($file); + if (($perms & 0xC000) == 0xC000) { + // Socket + $info = 's'; + } elseif (($perms & 0xA000) == 0xA000) { + // Symbolic Link + $info = 'l'; + } elseif (($perms & 0x8000) == 0x8000) { + // Regular + $info = '-'; + } elseif (($perms & 0x6000) == 0x6000) { + // Block special + $info = 'b'; + } elseif (($perms & 0x4000) == 0x4000) { + // Directory + $info = 'd'; + } elseif (($perms & 0x2000) == 0x2000) { + // Character special + $info = 'c'; + } elseif (($perms & 0x1000) == 0x1000) { + // FIFO pipe + $info = 'p'; + } else { + // Unknown + $info = 'u'; + } + + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); + + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); + + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); + return $info; + } + + function getnumchmodfromh($mode) { + $realmode = ""; + $legal = array("","w","r","x","-"); + $attarray = preg_split("//",$mode); + for($i=0;$i'0','r'=>'4','w'=>'2','x'=>'1'); + $mode = strtr($mode,$trans); + $newmode = ''; + $newmode .= $mode[0]+$mode[1]+$mode[2]; + $newmode .= $mode[3]+$mode[4]+$mode[5]; + $newmode .= $mode[6]+$mode[7]+$mode[8]; + return $newmode; + } + + function group($file){ + $dir = $this->dirlist($file); + return $dir[$file]['group']; + } + + function copy($source,$destination,$overwrite=false){ + if( ! $overwrite && $this->exists($destination) ) + return false; + + $content = $this->get_contents($source); + if ( false === $content ) + return false; + + return $this->put_contents($destination,$content); + } + + function move($source,$destination,$overwrite=false){ + return $this->ftp->rename($source,$destination); + } + + function delete($file,$recursive=false) { + if ( $this->is_file($file) ) + return $this->ftp->delete($file); + if ( !$recursive ) + return $this->ftp->rmdir($file); + + return $this->ftp->mdel($file); + } + + function exists($file){ + return $this->ftp->is_exists($file); + } + + function is_file($file){ + return $this->is_dir($file) ? false : true; + } + + function is_dir($path){ + $cwd = $this->cwd(); + if ( $this->chdir($path) ) { + $this->chdir($cwd); + return true; + } + return false; + } + + function is_readable($file){ + //Get dir list, Check if the file is writable by the current user?? + return true; + } + + function is_writable($file){ + //Get dir list, Check if the file is writable by the current user?? + return true; + } + + function atime($file){ + return false; + } + + function mtime($file){ + return $this->ftp->mdtm($file); + } + + function size($file){ + return $this->ftp->filesize($file); + } + + function touch($file,$time=0,$atime=0){ + return false; + } + + function mkdir($path,$chmod=false,$chown=false,$chgrp=false){ + if( ! $this->ftp->mkdir($path) ) + return false; + if( $chmod ) + $this->chmod($path, $chmod); + if( $chown ) + $this->chown($path, $chown); + if( $chgrp ) + $this->chgrp($path, $chgrp); + return true; + } + + function rmdir($path,$recursive=false){ + if( ! $recursive ) + return $this->ftp->rmdir($path); + + return $this->ftp->mdel($path); + } + + function dirlist($path='.',$incdot=false,$recursive=false){ + if( $this->is_file($path) ){ + $limitFile = basename($path); + $path = dirname($path) . '/'; + } else { + $limitFile = false; + } + //if( ! $this->is_dir($path) ) + // return false; + $list = $this->ftp->dirlist($path); + if( ! $list ) + return false; + if( empty($list) ) + return array(); + + $ret = array(); + foreach ( $list as $struc ) { + + if ( 'd' == $struc['type'] ) { + $struc['files'] = array(); + + if ( $incdot ){ + //We're including the doted starts + if( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder + if ($recursive) + $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); + } + } else { //No dots + if ($recursive) + $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); + } + } + //File + $ret[$struc['name']] = $struc; + } + return $ret; + } + + function __destruct(){ + $this->ftp->quit(); + } +} +?> diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php new file mode 100644 index 0000000..c675c4d --- /dev/null +++ b/wp-admin/includes/dashboard.php @@ -0,0 +1,538 @@ + 'WordPress Dashboard', + 'id' => 'wp_dashboard', + 'before_widget' => "\t
\n\n\t\t
\n\n", + 'after_widget' => "\t\t
\n\n\t
\n\n", + 'before_title' => "\t\t\t

", + 'after_title' => "

\n\n" + ) ); + + + /* Register Widgets and Controls */ + + // Recent Comments Widget + if ( current_user_can( 'moderate_comments' ) && $mod_comments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'") ) { + $notice = sprintf( __ngettext( '%d comment awaiting moderation', '%d comments awaiting moderation', $mod_comments ), $mod_comments ); + $notice = "$notice"; + } else { + $notice = ''; + } + wp_register_sidebar_widget( 'dashboard_recent_comments', __( 'Recent Comments' ), 'wp_dashboard_recent_comments', + array( 'all_link' => 'edit-comments.php', 'notice' => $notice, 'width' => 'half' ) + ); + + // Incoming Links Widget + if ( !isset( $widget_options['dashboard_incoming_links'] ) ) { + $update = true; + $widget_options['dashboard_incoming_links'] = array( + 'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), + 'url' => apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&ie=utf-8&num=10&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), + 'items' => 5, + 'show_date' => 0 + ); + } + wp_register_sidebar_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_empty', + array( 'all_link' => $widget_options['dashboard_incoming_links']['link'], 'feed_link' => $widget_options['dashboard_incoming_links']['url'], 'width' => 'half' ), + 'wp_dashboard_cached_rss_widget', 'wp_dashboard_incoming_links_output' + ); + wp_register_widget_control( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_rss_control', array(), + array( 'widget_id' => 'dashboard_incoming_links', 'form_inputs' => array( 'title' => false, 'show_summary' => false, 'show_author' => false ) ) + ); + + + // WP Plugins Widget + wp_register_sidebar_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_empty', + array( 'all_link' => 'http://wordpress.org/extend/plugins/', 'feed_link' => 'http://wordpress.org/extend/plugins/rss/topics/', 'width' => 'half' ), + 'wp_dashboard_cached_rss_widget', 'wp_dashboard_plugins_output', + array( 'http://wordpress.org/extend/plugins/rss/browse/popular/', 'http://wordpress.org/extend/plugins/rss/browse/new/', 'http://wordpress.org/extend/plugins/rss/browse/updated/' ) + ); + + // Primary feed (Dev Blog) Widget + if ( !isset( $widget_options['dashboard_primary'] ) ) { + $update = true; + $widget_options['dashboard_primary'] = array( + 'link' => apply_filters( 'dashboard_primary_link', 'http://wordpress.org/development/' ), + 'url' => apply_filters( 'dashboard_primary_feed', 'http://wordpress.org/development/feed/' ), + 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Development Blog' ) ), + 'items' => 2, + 'show_summary' => 1, + 'show_author' => 0, + 'show_date' => 1 + ); + } + wp_register_sidebar_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_empty', + array( 'all_link' => $widget_options['dashboard_primary']['link'], 'feed_link' => $widget_options['dashboard_primary']['url'], 'width' => 'half', 'class' => 'widget_rss' ), + 'wp_dashboard_cached_rss_widget', 'wp_dashboard_rss_output' + ); + wp_register_widget_control( 'dashboard_primary', __( 'Primary Feed' ), 'wp_dashboard_rss_control', array(), + array( 'widget_id' => 'dashboard_primary' ) + ); + + + // Secondary Feed (Planet) Widget + if ( !isset( $widget_options['dashboard_secondary'] ) ) { + $update = true; + $widget_options['dashboard_secondary'] = array( + 'link' => apply_filters( 'dashboard_secondary_link', 'http://planet.wordpress.org/' ), + 'url' => apply_filters( 'dashboard_secondary_feed', 'http://planet.wordpress.org/feed/' ), + 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), + 'items' => 15 + ); + } + wp_register_sidebar_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_empty', + array( 'all_link' => $widget_options['dashboard_secondary']['link'], 'feed_link' => $widget_options['dashboard_secondary']['url'], 'width' => 'full' ), + 'wp_dashboard_cached_rss_widget', 'wp_dashboard_secondary_output' + ); + wp_register_widget_control( 'dashboard_secondary', __( 'Secondary Feed' ), 'wp_dashboard_rss_control', array(), + array( 'widget_id' => 'dashboard_secondary', 'form_inputs' => array( 'show_summary' => false, 'show_author' => false, 'show_date' => false ) ) + ); + + + /* Dashboard Widget Template + wp_register_sidebar_widget( $widget_id (unique slug) , $widget_title, $output_callback, + array( + 'all_link' => full url for "See All" link, + 'feed_link' => full url for "RSS" link, + 'width' => 'fourth', 'third', 'half', 'full' (defaults to 'half'), + 'height' => 'single', 'double' (defaults to 'single'), + ), + $wp_dashboard_empty_callback (only needed if using 'wp_dashboard_empty' as your $output_callback), + $arg, $arg, $arg... (further args passed to callbacks) + ); + + // optional: if you want users to be able to edit the settings of your widget, you need to register a widget_control + wp_register_widget_control( $widget_id, $widget_control_title, $control_output_callback, + array(), // leave an empty array here: oddity in widget code + array( + 'widget_id' => $widget_id, // Yes - again. This is required: oddity in widget code + 'arg' => an arg to pass to the $control_output_callback, + 'another' => another arg to pass to the $control_output_callback, + ... + ) + ); + */ + + // Hook to register new widgets + do_action( 'wp_dashboard_setup' ); + + // Hard code the sidebar's widgets and order + $dashboard_widgets = array(); + $dashboard_widgets[] = 'dashboard_recent_comments'; + $dashboard_widgets[] = 'dashboard_incoming_links'; + $dashboard_widgets[] = 'dashboard_primary'; + if ( current_user_can( 'activate_plugins' ) ) + $dashboard_widgets[] = 'dashboard_plugins'; + $dashboard_widgets[] = 'dashboard_secondary'; + + // Filter widget order + $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', $dashboard_widgets ); + + $wp_dashboard_sidebars = array( 'wp_dashboard' => $dashboard_widgets, 'array_version' => 3.5 ); + + add_filter( 'dynamic_sidebar_params', 'wp_dashboard_dynamic_sidebar_params' ); + + if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) { + ob_start(); // hack - but the same hack wp-admin/widgets.php uses + wp_dashbaord_trigger_widget_control( $_POST['widget_id'] ); + ob_end_clean(); + wp_redirect( remove_query_arg( 'edit' ) ); + exit; + } + + if ( $update ) + update_option( 'dashboard_widget_options', $widget_options ); +} + +// Echoes out the dashboard +function wp_dashboard() { + echo "
\n\n"; + + // We're already filtering dynamic_sidebar_params obove + add_filter( 'option_sidebars_widgets', 'wp_dashboard_sidebars_widgets' ); // here there be hackery + dynamic_sidebar( 'wp_dashboard' ); + remove_filter( 'option_sidebars_widgets', 'wp_dashboard_sidebars_widgets' ); + + echo "
\n
\n\n\n"; +} + +// Makes sidebar_widgets option reflect the dashboard settings +function wp_dashboard_sidebars_widgets() { // hackery + return $GLOBALS['wp_dashboard_sidebars']; +} + +// Modifies sidbar params on the fly to set up ids, class names, titles for each widget (called once per widget) +// Switches widget to edit mode if $_GET['edit'] +function wp_dashboard_dynamic_sidebar_params( $params ) { + global $wp_registered_widgets, $wp_registered_widget_controls; + + $sidebar_defaults = array('widget_id' => 0, 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => ''); + extract( $sidebar_defaults, EXTR_PREFIX_ALL, 'sidebar' ); + extract( $params[0], EXTR_PREFIX_ALL, 'sidebar' ); + + if ( !isset($wp_registered_widgets[$sidebar_widget_id]) || !is_array($wp_registered_widgets[$sidebar_widget_id]) ) { + return $params; + } + $widget_defaults = array('id' => '', 'width' => '', 'height' => '', 'class' => '', 'feed_link' => '', 'all_link' => '', 'notice' => false, 'error' => false); + extract( $widget_defaults, EXTR_PREFIX_ALL, 'widget' ); + extract( $wp_registered_widgets[$sidebar_widget_id], EXTR_PREFIX_ALL, 'widget' ); + + $the_classes = array(); + if ( in_array($widget_width, array( 'third', 'fourth', 'full' ) ) ) + $the_classes[] = $widget_width; + + if ( 'double' == $widget_height ) + $the_classes[] = 'double'; + + if ( $widget_class ) + $the_classes[] = $widget_class; + + // Add classes to the widget holder + if ( $the_classes ) + $sidebar_before_widget = str_replace( "
' . __( 'See All' ) . ''; + + $content_class = 'dashboard-widget-content'; + if ( current_user_can( 'edit_dashboard' ) && isset($wp_registered_widget_controls[$widget_id]) && is_callable($wp_registered_widget_controls[$widget_id]['callback']) ) { + // Switch this widget to edit mode + if ( isset($_GET['edit']) && $_GET['edit'] == $widget_id ) { + $content_class .= ' dashboard-widget-control'; + $wp_registered_widgets[$widget_id]['callback'] = 'wp_dashboard_empty'; + $sidebar_widget_name = $wp_registered_widget_controls[$widget_id]['name']; + $params[1] = 'wp_dashbaord_trigger_widget_control'; + $sidebar_before_widget .= '
'; + $sidebar_after_widget = "
$sidebar_after_widget"; + $links[] = '' . __( 'Cancel' ) . ''; + } else { + $links[] = '' . __( 'Edit' ) . ''; + } + } + + if ( $widget_feed_link ) + $links[] = '' . __( 'rss icon' ) . ' ' . __( 'RSS' ) . ''; + + $links = apply_filters( "wp_dashboard_widget_links_$widget_id", $links ); + + // Add links to widget's title bar + if ( $links ) { + $sidebar_before_title .= ''; + $sidebar_after_title = '' . join( ' | ', $links ) . "
$sidebar_after_title"; + } + + // Could have put this in widget-content. Doesn't really matter + if ( $widget_notice ) + $sidebar_after_title .= "\t\t\t
$widget_notice
\n\n"; + + if ( $widget_error ) + $sidebar_after_title .= "\t\t\t
$widget_error
\n\n"; + + $sidebar_after_title .= "\t\t\t
\n\n"; + + $sidebar_after_widget .= "\t\t\t
\n\n"; + + foreach( array_keys( $params[0] ) as $key ) + $$key = ${'sidebar_' . $key}; + + $params[0] = compact( array_keys( $params[0] ) ); + + return $params; +} + + +/* Dashboard Widgets */ + +function wp_dashboard_recent_comments( $sidebar_args ) { + global $comment; + extract( $sidebar_args, EXTR_SKIP ); + + echo $before_widget; + + echo $before_title; + echo $widget_name; + echo $after_title; + + $lambda = create_function( '', 'return 5;' ); + add_filter( 'option_posts_per_rss', $lambda ); // hack - comments query doesn't accept per_page parameter + $comments_query = new WP_Query('feed=rss2&withcomments=1'); + remove_filter( 'option_posts_per_rss', $lambda ); + + $is_first = true; + + if ( $comments_query->have_comments() ) { + while ( $comments_query->have_comments() ) { $comments_query->the_comment(); + + $comment_post_url = get_permalink( $comment->comment_post_ID ); + $comment_post_title = get_the_title( $comment->comment_post_ID ); + $comment_post_link = "$comment_post_title"; + $comment_link = '#'; + $comment_meta = sprintf( __( 'From %1$s on %2$s %3$s' ), get_comment_author(), $comment_post_link, $comment_link ); + + if ( $is_first ) : $is_first = false; +?> +

+

+ +
    + + +
  • + + +
+ +items) && 1 < count($rss->items) ) {// Technorati returns a 1-item feed when it has no results + + echo "
    \n"; + + $rss->items = array_slice($rss->items, 0, $items); + foreach ( $rss->items as $item ) { + $publisher = ''; + $site_link = ''; + $link = ''; + $content = ''; + $date = ''; + $link = clean_url( strip_tags( $item['link'] ) ); + + if ( isset( $item['author_uri'] ) ) + $site_link = clean_url( strip_tags( $item['author_uri'] ) ); + + if ( !$publisher = wp_specialchars( strip_tags( isset($item['dc']['publisher']) ? $item['dc']['publisher'] : $item['author_name'] ) ) ) + $publisher = __( 'Somebody' ); + if ( $site_link ) + $publisher = "$publisher"; + else + $publisher = "$publisher"; + + if ( isset($item['description']) ) + $content = $item['description']; + elseif ( isset($item['summary']) ) + $content = $item['summary']; + elseif ( isset($item['atom_content']) ) + $content = $item['atom_content']; + else + $content = __( 'something' ); + $content = wp_html_excerpt($content, 50) . ' ...'; + if ( $link ) + $text = _c( '%1$s linked here saying, "%3$s"|feed_display' ); + else + $text = _c( '%1$s linked here saying, "%3$s"|feed_display' ); + + if ( $show_date ) { + if ( $show_author || $show_summary ) + $text .= _c( ' on %4$s|feed_display' ); + $date = wp_specialchars( strip_tags( isset($item['pubdate']) ? $item['pubdate'] : $item['published'] ) ); + $date = strtotime( $date ); + $date = gmdate( get_option( 'date_format' ), $date ); + } + + echo "\t
  • " . sprintf( _c( "$text|feed_display" ), $publisher, $link, $content, $date ) . "
  • \n"; + } + + echo "
\n"; + + } else { + echo '

' . __('This dashboard widget queries Google Blog Search so that when another blog links to your site it will show up here. They have found no incoming links found… yet. It’s okay — there is no rush.') . "

\n"; + } +} + +// $sidebar_args are handled by wp_dashboard_empty() +function wp_dashboard_rss_output( $widget_id ) { + $widgets = get_option( 'dashboard_widget_options' ); + wp_widget_rss_output( $widgets[$widget_id] ); +} + +// $sidebar_args are handled by wp_dashboard_empty() +function wp_dashboard_secondary_output() { + $widgets = get_option( 'dashboard_widget_options' ); + @extract( @$widgets['dashboard_secondary'], EXTR_SKIP ); + $rss = @fetch_rss( $url ); + if ( !isset($rss->items) || 0 == count($rss->items) ) + return false; + + echo "
    \n"; + + $rss->items = array_slice($rss->items, 0, $items); + foreach ($rss->items as $item ) { + $title = wp_specialchars($item['title']); + $author = preg_replace( '|(.+?):.+|s', '$1', $item['title'] ); + $post = preg_replace( '|.+?:(.+)|s', '$1', $item['title'] ); + $link = clean_url($item['link']); + + echo "\t
  • $post$author
  • \n"; + } + + echo "
\n
\n"; +} + +// $sidebar_args are handled by wp_dashboard_empty() +function wp_dashboard_plugins_output() { + $popular = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/popular/' ); + $new = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/new/' ); + $updated = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/updated/' ); + + foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins'), 'updated' => __('Recently Updated') ) as $feed => $label ) { + if ( !isset($$feed->items) || 0 == count($$feed->items) ) + continue; + + $$feed->items = array_slice($$feed->items, 0, 5); + $item_key = array_rand($$feed->items); + + // Eliminate some common badly formed plugin descriptions + while ( ( null !== $item_key = array_rand($$feed->items) ) && false !== strpos( $$feed->items[$item_key]['description'], 'Plugin Name:' ) ) + unset($$feed->items[$item_key]); + + if ( !isset($$feed->items[$item_key]) ) + continue; + + $item = $$feed->items[$item_key]; + + // current bbPress feed item titles are: user on "topic title" + if ( preg_match( '/"(.*)"/s', $item['title'], $matches ) ) + $title = $matches[1]; + else // but let's make it forward compatible if things change + $title = $item['title']; + $title = wp_specialchars( $title ); + + $description = wp_specialchars( strip_tags(html_entity_decode($item['description'], ENT_QUOTES)) ); + + list($link, $frag) = explode( '#', $item['link'] ); + + $link = clean_url($link); + $dlink = rtrim($link, '/') . '/download/'; + + echo "

$label

\n"; + echo "
$title
 (" . __( 'Download' ) . ")\n"; + echo "

$description

\n"; + } +} + +// Checks to see if all of the feed url in $check_urls are cached. +// If $check_urls is empty, look for the rss feed url found in the dashboard widget optios of $widget_id. +// If cached, call $callback, a function that echoes out output for this widget. +// If not cache, echo a "Loading..." stub which is later replaced by AJAX call (see top of /wp-admin/index.php) +function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) { + $loading = '

' . __( 'Loading…' ) . '

'; + + if ( empty($check_urls) ) { + $widgets = get_option( 'dashboard_widget_options' ); + if ( empty($widgets[$widget_id]['url']) ) { + echo $loading; + return false; + } + $check_urls = array( $widgets[$widget_id]['url'] ); + } + + + require_once( ABSPATH . WPINC . '/rss.php' ); + init(); // initialize rss constants + + $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); + + foreach ( $check_urls as $check_url ) { + $status = $cache->check_cache( $check_url ); + if ( 'HIT' !== $status ) { + echo $loading; + return false; + } + } + + if ( $callback && is_callable( $callback ) ) { + $args = array_slice( func_get_args(), 2 ); + array_unshift( $args, $widget_id ); + call_user_func_array( $callback, $args ); + } + + return true; +} + +// Empty widget used for JS/AJAX created output. +// Callback inserts content between before_widget and after_widget. Used when widget is in edit mode. Can also be used for custom widgets. +function wp_dashboard_empty( $sidebar_args, $callback = false ) { + extract( $sidebar_args, EXTR_SKIP ); + + echo $before_widget; + + echo $before_title; + echo $widget_name; + echo $after_title; + + // When in edit mode, the callback passed to this function is the widget_control callback + if ( $callback && is_callable( $callback ) ) { + $args = array_slice( func_get_args(), 2 ); + array_unshift( $args, $widget_id ); + call_user_func_array( $callback, $args ); + } + + echo $after_widget; +} + +/* Dashboard Widgets Controls. Ssee also wp_dashboard_empty() */ + +// Calls widget_control callback +function wp_dashbaord_trigger_widget_control( $widget_control_id = false ) { + global $wp_registered_widget_controls; + if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_registered_widget_controls[$widget_control_id]) && is_callable($wp_registered_widget_controls[$widget_control_id]['callback']) ) + call_user_func_array( $wp_registered_widget_controls[$widget_control_id]['callback'], $wp_registered_widget_controls[$widget_control_id]['params'] ); +} + +// Sets up $args to be used as input to wp_widget_rss_form(), handles POST data from RSS-type widgets +function wp_dashboard_rss_control( $args ) { + extract( $args ); + if ( !$widget_id ) + return false; + + if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) + $widget_options = array(); + + if ( !isset($widget_options[$widget_id]) ) + $widget_options[$widget_id] = array(); + + $number = 1; // Hack to use wp_widget_rss_form() + $widget_options[$widget_id]['number'] = $number; + + if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) { + $_POST['widget-rss'][$number] = stripslashes_deep( $_POST['widget-rss'][$number] ); + $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); + // title is optional. If black, fill it if possible + if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { + require_once(ABSPATH . WPINC . '/rss.php'); + $rss = fetch_rss($widget_options[$widget_id]['url']); + $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->channel['title'])); + } + update_option( 'dashboard_widget_options', $widget_options ); + } + + wp_widget_rss_form( $widget_options[$widget_id], $form_inputs ); +} + +?> diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php new file mode 100644 index 0000000..a712177 --- /dev/null +++ b/wp-admin/includes/export.php @@ -0,0 +1,255 @@ +get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); + +$categories = (array) get_categories('get=all'); +$tags = (array) get_tags('get=all'); + +function wxr_missing_parents($categories) { + if ( !is_array($categories) || empty($categories) ) + return array(); + + foreach ( $categories as $category ) + $parents[$category->term_id] = $category->parent; + + $parents = array_unique(array_diff($parents, array_keys($parents))); + + if ( $zero = array_search('0', $parents) ) + unset($parents[$zero]); + + return $parents; +} + +while ( $parents = wxr_missing_parents($categories) ) { + $found_parents = get_categories("include=" . join(', ', $parents)); + if ( is_array($found_parents) && count($found_parents) ) + $categories = array_merge($categories, $found_parents); + else + break; +} + +// Put them in order to be inserted with no child going before its parent +$pass = 0; +$passes = 1000 + count($categories); +while ( ( $cat = array_shift($categories) ) && ++$pass < $passes ) { + if ( $cat->parent == 0 || isset($cats[$cat->parent]) ) { + $cats[$cat->term_id] = $cat; + } else { + $categories[] = $cat; + } +} +unset($categories); + +function wxr_cdata($str) { + if ( seems_utf8($str) == false ) + $str = utf8_encode($str); + + // $str = ent2ncr(wp_specialchars($str)); + + $str = ""; + + return $str; +} + +function wxr_site_url() { + global $current_site; + + // mu: the base url + if ( isset($current_site->domain) ) { + return 'http://'.$current_site->domain.$current_site->path; + } + // wp: the blog url + else { + return get_bloginfo_rss('url'); + } +} + +function wxr_cat_name($c) { + if ( empty($c->name) ) + return; + + echo '' . wxr_cdata($c->name) . ''; +} + +function wxr_category_description($c) { + if ( empty($c->description) ) + return; + + echo '' . wxr_cdata($c->description) . ''; +} + +function wxr_tag_name($t) { + if ( empty($t->name) ) + return; + + echo '' . wxr_cdata($t->name) . ''; +} + +function wxr_tag_description($t) { + if ( empty($t->description) ) + return; + + echo '' . wxr_cdata($t->description) . ''; +} + +function wxr_post_taxonomy() { + $categories = get_the_category(); + $tags = get_the_tags(); + $the_list = ''; + $filter = 'rss'; + + if ( !empty($categories) ) foreach ( (array) $categories as $category ) { + $cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); + // for backwards compatibility + $the_list .= "\n\t\t\n"; + // forwards compatibility: use a unique identifier for each cat to avoid clashes + // http://trac.wordpress.org/ticket/5447 + $the_list .= "\n\t\tslug}\">\n"; + } + + if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { + $tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); + $the_list .= "\n\t\t\n"; + // forwards compatibility as above + $the_list .= "\n\t\tslug}\">\n"; + } + + echo $the_list; +} + +echo '\n"; + +?> + + + + + + + + + + + + + + + + + + + + + <?php bloginfo_rss('name'); ?> + + + + http://wordpress.org/?v= + + + + + + slug; ?>parent ? $cats[$c->parent]->name : ''; ?> + + + slug; ?> + + + in_the_loop = true; // Fake being in the loop. + // fetch 20 posts at a time rather than loading the entire table into memory + while ( $next_posts = array_splice($post_ids, 0, 20) ) { + $where = "WHERE ID IN (".join(',', $next_posts).")"; + $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); + foreach ($posts as $post) { + setup_postdata($post); ?> + +<?php echo apply_filters('the_title_rss', $post->post_title); ?> + + + + + + + +post_content); ?>]]> +ID; ?> +post_date; ?> +post_date_gmt; ?> +comment_status; ?> +ping_status; ?> +post_name; ?> +post_status; ?> +post_parent; ?> +menu_order; ?> +post_type; ?> +post_password; ?> +post_type == 'attachment') { ?> +ID); ?> + +get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID"); +if ( $postmeta ) { +?> + + +meta_key; ?> +meta_value; ?> + + + +get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID"); +if ( $comments ) { foreach ( $comments as $c ) { ?> + +comment_ID; ?> +comment_author); ?> +comment_author_email; ?> +comment_author_url; ?> +comment_author_IP; ?> +comment_date; ?> +comment_date_gmt; ?> +comment_content; ?> +comment_approved; ?> +comment_type; ?> +comment_parent; ?> +user_id; ?> + + + + + + + \ No newline at end of file diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php new file mode 100644 index 0000000..b43c2da --- /dev/null +++ b/wp-admin/includes/media.php @@ -0,0 +1,1225 @@ + __('Choose File'), // handler action suffix => tab text + 'gallery' => __('Gallery'), + 'library' => __('Media Library'), + ); + + return apply_filters('media_upload_tabs', $_default_tabs); +} + +function update_gallery_tab($tabs) { + global $wpdb; + if ( !isset($_REQUEST['post_id']) ) { + unset($tabs['gallery']); + return $tabs; + } + if ( intval($_REQUEST['post_id']) ) + $attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id']))); + + $tabs['gallery'] = sprintf(__('Gallery (%s)'), "$attachments"); + + return $tabs; +} +add_filter('media_upload_tabs', 'update_gallery_tab'); + +function the_media_upload_tabs() { + $tabs = media_upload_tabs(); + + if ( !empty($tabs) ) { + echo "
    \n"; + if ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) ) + $current = $_GET['tab']; + else { + $keys = array_keys($tabs); + $current = array_shift($keys); + } + foreach ( $tabs as $callback => $text ) { + $class = ''; + if ( $current == $callback ) + $class = " class='current'"; + $href = add_query_arg(array('tab'=>$callback, 's'=>false, 'paged'=>false, 'post_mime_type'=>false, 'm'=>false)); + $link = "$text"; + echo "\t
  • $link
  • \n"; + } + echo "
\n"; + } +} + +function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') { + + $html = get_image_tag($id, $alt, $title, $align, $rel, $size); + + $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : ''; + + if ( $url ) + $html = "$html"; + + $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url ); + + return $html; +} + +function media_send_to_editor($html) { + ?> + + false); + $file = wp_handle_upload($_FILES[$file_id], $overrides); + + if ( isset($file['error']) ) + return new wp_error( 'upload_error', $file['error'] ); + + $url = $file['url']; + $type = $file['type']; + $file = $file['file']; + $title = preg_replace('/\.[^.]+$/', '', basename($file)); + $content = ''; + + // use image exif/iptc data for title and caption defaults if possible + if ( $image_meta = @wp_read_image_metadata($file) ) { + if ( trim($image_meta['title']) ) + $title = $image_meta['title']; + if ( trim($image_meta['caption']) ) + $content = $image_meta['caption']; + } + + // Construct the attachment array + $attachment = array_merge( array( + 'post_mime_type' => $type, + 'guid' => $url, + 'post_parent' => $post_id, + 'post_title' => $title, + 'post_content' => $content, + ), $post_data ); + + // Save the data + $id = wp_insert_attachment($attachment, $file, $post_parent); + if ( !is_wp_error($id) ) { + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); + } + + return $id; + +} + + +// wrap iframe content (produced by $content_func) in a doctype, html head/body etc +// any additional function args will be passed to content_func +function wp_iframe($content_func /* ... */) { +?> + + > + + +<?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — WordPress + + + + +> + + + +$image_title + $video_title + $audio_title + $media_title + +EOF; + printf($context, $out); +} +add_action( 'media_buttons', 'media_buttons' ); + +function media_buttons_head() { +$siteurl = get_option('siteurl'); +echo "\n"; +} + +add_action( 'admin_print_scripts', 'media_buttons_head' ); + +function media_admin_css() { + wp_admin_css('css/media'); +} + +add_action('media_upload_media', 'media_upload_handler'); + +function media_upload_form_handler() { + check_admin_referer('media-form'); + + // Insert media button was clicked + if ( !empty($_FILES) ) { + // Upload File button was clicked + + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { + $post = $_post = get_post($attachment_id, ARRAY_A); + if ( isset($attachment['post_content']) ) + $post['post_content'] = $attachment['post_content']; + if ( isset($attachment['post_title']) ) + $post['post_title'] = $attachment['post_title']; + if ( isset($attachment['post_excerpt']) ) + $post['post_excerpt'] = $attachment['post_excerpt']; + + $post = apply_filters('attachment_fields_to_save', $post, $attachment); + + if ( isset($post['errors']) ) { + $errors[$attachment_id] = $post['errors']; + unset($post['errors']); + } + + if ( $post != $_post ) + wp_update_post($post); + + foreach ( get_attachment_taxonomies($post) as $t ) + if ( isset($attachment[$t]) ) + wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false); + } + + if ( isset($_POST['insert-gallery']) ) + return media_send_to_editor('[gallery]'); + + if ( isset($_POST['send']) ) { + $keys = array_keys($_POST['send']); + $send_id = (int) array_shift($keys); + $attachment = $_POST['attachments'][$send_id]; + $html = $attachment['post_title']; + if ( !empty($attachment['url']) ) + $html = "$html"; + $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); + return media_send_to_editor($html); + } + + return $errors; +} + +function media_upload_image() { + if ( !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $src = $_POST['insertonly']['src']; + if ( !strpos($src, '://') ) + $src = "http://$src"; + $alt = attribute_escape($_POST['insertonly']['alt']); + if ( isset($_POST['insertonly']['align']) ) { + $align = attribute_escape($_POST['insertonly']['align']); + $class = " class='align$align'"; + } + $html = "$alt"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + return wp_iframe( 'media_upload_type_form', 'image', $errors, $id ); +} + +function media_upload_audio() { + if ( !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $href = $_POST['insertonly']['href']; + if ( !strpos($href, '://') ) + $href = "http://$href"; + $title = attribute_escape($_POST['insertonly']['title']); + $html = "$title"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id ); +} + +function media_upload_video() { + if ( !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $href = $_POST['insertonly']['href']; + if ( !strpos($href, '://') ) + $href = "http://$href"; + $title = attribute_escape($_POST['insertonly']['title']); + $html = "$title"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + return wp_iframe( 'media_upload_type_form', 'video', $errors, $id ); +} + +function media_upload_file() { + if ( !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $href = $_POST['insertonly']['href']; + if ( !strpos($href, '://') ) + $href = "http://$href"; + $title = attribute_escape($_POST['insertonly']['title']); + $html = "$title"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + return wp_iframe( 'media_upload_type_form', 'file', $errors, $id ); +} + +function media_upload_gallery() { + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + return wp_iframe( 'media_upload_gallery_form', $errors ); +} + +function media_upload_library() { + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + return wp_iframe( 'media_upload_library_form', $errors ); +} + +function get_attachment_taxonomies($attachment) { + if ( is_int( $attachment ) ) + $attachment = get_post($attachment); + else if ( is_array($attachment) ) + $attachment = (object) $attachment; + + if ( ! is_object($attachment) ) + return array(); + + $filename = basename($attachment->guid); + + $objects = array('attachment'); + + if ( false !== strpos($filename, '.') ) + $objects[] = 'attachment:' . substr($filename, strrpos($filename, '.') + 1); + if ( !empty($attachment->post_mime_type) ) { + $objects[] = 'attachment:' . $attachment->post_mime_type; + if ( false !== strpos($attachment->post_mime_type, '/') ) + foreach ( explode('/', $attachment->post_mime_type) as $token ) + if ( !empty($token) ) + $objects[] = "attachment:$token"; + } + + $taxonomies = array(); + foreach ( $objects as $object ) + if ( $taxes = get_object_taxonomies($object) ) + $taxonomies = array_merge($taxonomies, $taxes); + + return array_unique($taxonomies); +} + +function image_attachment_fields_to_edit($form_fields, $post) { + if ( substr($post->post_mime_type, 0, 5) == 'image' ) { + $form_fields['post_title']['required'] = true; + $form_fields['post_excerpt']['label'] = __('Description'); + $form_fields['post_excerpt']['helps'][] = __('Alternate text, e.g. "The Mona Lisa"'); + + $form_fields['post_content']['label'] = __('Long Description'); + + $thumb = wp_get_attachment_thumb_url($post->ID); + + $form_fields['align'] = array( + 'label' => __('Alignment'), + 'input' => 'html', + 'html' => " + + + + + + + + \n", + ); + $form_fields['image-size'] = array( + 'label' => __('Size'), + 'input' => 'html', + 'html' => " + " . ( $thumb ? " + + " : '' ) . " + + + ", + ); + } + return $form_fields; +} + +add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2); + +function media_single_attachment_fields_to_edit( $form_fields, $post ) { + unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']); + return $form_fields; +} + +function image_attachment_fields_to_save($post, $attachment) { + if ( substr($post['post_mime_type'], 0, 5) == 'image' ) { + if ( strlen(trim($post['post_title'])) == 0 ) { + $post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid'])); + $post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.'); + } + } + + return $post; +} + +add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2); + +function image_media_send_to_editor($html, $attachment_id, $attachment) { + $post =& get_post($attachment_id); + if ( substr($post->post_mime_type, 0, 5) == 'image' ) { + $url = $attachment['url']; + + if ( isset($attachment['align']) ) + $align = $attachment['align']; + else + $align = 'none'; + + if ( !empty($attachment['image-size']) ) + $size = $attachment['image-size']; + else + $size = 'medium'; + + return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size); + } + + return $html; +} + +add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3); + +function get_attachment_fields_to_edit($post, $errors = null) { + if ( is_int($post) ) + $post =& get_post($post); + if ( is_array($post) ) + $post = (object) $post; + + $edit_post = sanitize_post($post, 'edit'); + $file = wp_get_attachment_url($post->ID); + $link = get_attachment_link($post->ID); + + $form_fields = array( + 'post_title' => array( + 'label' => __('Title'), + 'value' => $edit_post->post_title, + ), + 'post_excerpt' => array( + 'label' => __('Description'), + 'value' => $edit_post->post_excerpt, + ), + 'post_content' => array( + 'label' => __('Long description'), + 'value' => $edit_post->post_content, + 'input' => 'textarea', + ), + 'url' => array( + 'label' => __('Link URL'), + 'input' => 'html', + 'html' => " +
+ + + + \n", + 'helps' => __('Enter a link URL or click above for presets.'), + ), + ); + + foreach ( get_attachment_taxonomies($post) as $taxonomy ) { + $t = (array) get_taxonomy($taxonomy); + if ( empty($t['label']) ) + $t['label'] = $taxonomy; + if ( empty($t['args']) ) + $t['args'] = array(); + + $terms = get_object_term_cache($post->ID, $taxonomy); + if ( empty($terms) ) + $terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); + + $values = array(); + + foreach ( $terms as $term ) + $values[] = $term->name; + $t['value'] = join(', ', $values); + + $form_fields[$taxonomy] = $t; + } + + // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default + // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) + $form_fields = array_merge_recursive($form_fields, (array) $errors); + + $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post); + + return $form_fields; +} + +function get_media_items( $post_id, $errors ) { + if ( $post_id && $post = get_post($post_id) ) { + if ( $post->post_type == 'attachment' ) + $attachments = array($post->ID => $post); + else + $attachments = get_children("post_parent=$post_id&post_type=attachment&orderby=menu_order ASC, ID&order=DESC"); + } else { + if ( is_array($GLOBALS['wp_the_query']->posts) ) + foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) + $attachments[$attachment->ID] = $attachment; + } + + if ( empty($attachments) ) + return ''; + + foreach ( $attachments as $id => $attachment ) + if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) ) + $output .= "\n
$item
\n
"; + + return $output; +} + +function get_media_item( $attachment_id, $args = null ) { + $default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true ); + $args = wp_parse_args( $args, $default_args ); + extract( $args, EXTR_SKIP ); + + global $post_mime_types; + if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) ) + $thumb_url = $thumb_url[0]; + else + return false; + + $title_label = __('Title'); + $description_label = __('Description'); + $tags_label = __('Tags'); + + $toggle_on = __('Show'); + $toggle_off = __('Hide'); + + $post = get_post($attachment_id); + + $filename = basename($post->guid); + $title = attribute_escape($post->post_title); + $description = attribute_escape($post->post_content); + if ( $_tags = get_the_tags($attachment_id) ) { + foreach ( $_tags as $tag ) + $tags[] = $tag->name; + $tags = attribute_escape(join(', ', $tags)); + } + + if ( isset($post_mime_types) ) { + $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type)); + $type = array_shift($keys); + $type = ""; + } + + $form_fields = get_attachment_fields_to_edit($post, $errors); + + if ( $toggle ) { + $class = empty($errors) ? 'startclosed' : 'startopen'; + $toggle_links = " + $toggle_on + $toggle_off"; + } else { + $class = 'form-table'; + $toggle_links = ''; + } + + $item = " + $type + $toggle_links +
$filename
+ + + + + + + + + + + \n"; + + $defaults = array( + 'input' => 'text', + 'required' => false, + 'value' => '', + 'extra_rows' => array(), + ); + + $delete_href = wp_nonce_url("post.php?action=delete-post&post=$attachment_id", 'delete-post_' . $attachment_id); + if ( $send ) + $send = "'; + if ( $delete ) + $delete = "" . __('Delete') . ""; + if ( ( $send || $delete ) && !isset($form_fields['buttons']) ) + $form_fields['buttons'] = array('tr' => "\t\t\n"); + + $hidden_fields = array(); + + foreach ( $form_fields as $id => $field ) { + if ( $id{0} == '_' ) + continue; + + if ( !empty($field['tr']) ) { + $item .= $field['tr']; + continue; + } + + $field = array_merge($defaults, $field); + $name = "attachments[$attachment_id][$id]"; + + if ( $field['input'] == 'hidden' ) { + $hidden_fields[$name] = $field['value']; + continue; + } + + $required = $field['required'] ? '*' : ''; + $class = $id; + $class .= $field['required'] ? ' form-required' : ''; + + $item .= "\t\t\n\t\t\t\n\t\t\t\n\t\t\n"; + + $extra_rows = array(); + + if ( !empty($field['errors']) ) + foreach ( array_unique((array) $field['errors']) as $error ) + $extra_rows['error'][] = $error; + + if ( !empty($field['extra_rows']) ) + foreach ( $field['extra_rows'] as $class => $rows ) + foreach ( (array) $rows as $html ) + $extra_rows[$class][] = $html; + + foreach ( $extra_rows as $class => $rows ) + foreach ( $rows as $html ) + $item .= "\t\t\n"; + } + + if ( !empty($form_fields['_final']) ) + $item .= "\t\t\n"; + $item .= "\t
$filename
$post->post_mime_type
" . mysql2date($post->post_date, get_option('time_format')) . "
" . apply_filters('media_meta', '', $post) . "
$send $delete
"; + if ( !empty($field[$field['input']]) ) + $item .= $field[$field['input']]; + elseif ( $field['input'] == 'textarea' ) { + $item .= ""; + } else { + $item .= ""; + } + if ( !empty($field['helps']) ) + $item .= "

" . join( "

\n

", array_unique((array) $field['helps']) ) . '

'; + $item .= "
$html
{$form_fields['_final']}
\n"; + + foreach ( $hidden_fields as $name => $value ) + $item .= "\t\n"; + + return $item; +} + +function media_upload_header() { + ?> + +
+ +
+ + +
+ + get_error_message(); ?> + +
+ + + +
+

+

+
+ +
+

+ +

+ +
+
+ + +
+ + +

+ + + + +
+ +
+ + + + +
+

+

+
+ +
+
+ +
+
+ + + + + + + + + +
+ +
+ + + + + +
+ + +
+ + + + + +
+ + +
+ +

+

    + $reals ) + foreach ( $reals as $real ) + $num_posts[$_type] += $_num_posts[$real]; +$class = empty($_GET['post_mime_type']) ? ' class="current"' : ''; +$type_links[] = "
  • ".__('All Types').""; +foreach ( $post_mime_types as $mime_type => $label ) { + $class = ''; + + if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) ) + continue; + + if ( wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) + $class = ' class="current"'; + + $type_links[] = "
  • $mime_type, 'paged'=>false)) . "'$class>" . sprintf($label[2], "{$num_posts[$mime_type]}") . ''; +} +echo implode(' |
  • ', $type_links) . ''; +unset($type_links); +?> +
+

+ +
+ + add_query_arg( 'paged', '%#%' ), + 'format' => '', + 'total' => ceil($wp_query->found_posts / 10), + 'current' => $_GET['paged'] +)); + +if ( $page_links ) + echo "
$page_links
"; +?> + +
+posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; + +$arc_result = $wpdb->get_results( $arc_query ); + +$month_count = count($arc_result); + +if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> + + + + + +
+ +
+
+
+ +
+ + + + + + +
+ +
+ + +
+ + + + + * + + + + + + + * + + + + ' . __('Alternate text, e.g. "The Mona Lisa"') . ' + + + + + + + + + + + + + + + + + + + + +'; +} + +function type_form_audio() { + return ' + + + + + + + + + + + + + + +
+ + * +
+ + * +
' . __('Link text, e.g. "Still Alive by Jonathan Coulton"') . '
+ +
+'; +} + +function type_form_video() { + return ' + + + + + + + + + + + + + + +
+ + * +
+ + * +
' . __('Link text, e.g. "Lucy on YouTube"') . '
+ +
+'; +} + +function type_form_file() { + return ' + + + + + + + + + + + + + + +
+ + * +
+ + * +
' . __('Link text, e.g. "Ransom Demands (PDF)"') . '
+ +
+'; +} + +add_filter('async_upload_image', 'get_media_item', 10, 2); +add_filter('async_upload_audio', 'get_media_item', 10, 2); +add_filter('async_upload_video', 'get_media_item', 10, 2); +add_filter('async_upload_file', 'get_media_item', 10, 2); + +add_action('media_upload_image', 'media_upload_image'); +add_action('media_upload_audio', 'media_upload_audio'); +add_action('media_upload_video', 'media_upload_video'); +add_action('media_upload_file', 'media_upload_file'); +add_action('admin_head_media_upload_type_form', 'media_admin_css'); + +add_filter('media_upload_gallery', 'media_upload_gallery'); +add_action('admin_head_media_upload_gallery_form', 'media_admin_css'); + +add_filter('media_upload_library', 'media_upload_library'); +add_action('admin_head_media_upload_library_form', 'media_admin_css'); + + +// Any 'attachment' taxonomy will be included in the description input form for the multi uploader +// Example: +/* +register_taxonomy( + 'image_people', + 'attachment:image', + array( + 'label' => __('People'), + 'template' => __('People: %l'), + 'helps' => __('Left to right, top to bottom.'), + 'sort' => true, + 'args' => array( + 'orderby' => 'term_order' + ) + ) +); +*/ +/* +register_taxonomy('movie_director', 'attachment:video', array('label'=>__('Directors'), 'template'=>__('Directed by %l.'))); +register_taxonomy('movie_producer', 'attachment:video', array('label'=>__('Producers'), 'template'=>__('Produced by %l.'))); +register_taxonomy('movie_screenwriter', 'attachment:video', array('label'=>__('Screenwriter'), 'template'=>__('Screenplay by %l.'))); +register_taxonomy('movie_actor', 'attachment:video', array('label'=>__('Cast'), 'template'=>array(__('Cast: %l.'))); +register_taxonomy('movie_crew', 'attachment:video', array('label'=>__('Crew'), 'template'=>array(__('Crew: %l.'))); +*/ + +?> diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php new file mode 100644 index 0000000..4523b24 --- /dev/null +++ b/wp-admin/includes/widgets.php @@ -0,0 +1,269 @@ + + +
    + $widget ) : + if ( in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget + continue; + + if ( $search_terms ) { + $hit = false; + // Simple case-insensitive search. Boolean OR. + $search_text = preg_replace( '/[^\w]/', '', $widget['name'] ); + if ( isset($widget['description']) ) + $search_text .= preg_replace( '/[^\w]/', '', $widget['description'] ); + + foreach ( $search_terms as $search_term ) { + if ( stristr( $search_text, $search_term ) ) { + $hit = true; + break; + } + } + if ( !$hit ) + continue; + } + + $sidebar = is_active_widget( $widget['callback'], $widget['id'] ); + + if ( ( 'unused' == $show && $sidebar ) || ( 'used' == $show && !$sidebar ) ) + continue; + + ob_start(); + $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' ) ) ); + $sidebar_args = call_user_func_array( 'wp_widget_control', $args ); + $widget_control_template = ob_get_contents(); + ob_end_clean(); + + $is_multi = false !== strpos( $widget_control_template, '%i%' ); + if ( !$sidebar || $is_multi ) { + if ( $is_multi ) + $already_shown[] = $widget['callback']; // it's a multi-widget. We only need to show it in the list once. + $action = 'add'; + $add_url = wp_nonce_url( add_query_arg( array( + 'sidebar' => $sidebar, + 'add' => $widget['id'], + 'key' => false, + 'edit' => false + ) ), "add-widget_$widget[id]" ); + } else { + $action = 'edit'; + $edit_url = clean_url( add_query_arg( array( + 'sidebar' => $sidebar, + 'edit' => $widget['id'], + 'key' => array_search( $widget['id'], $sidebars_widgets[$sidebar] ), + ) ) ); + + $widget_control_template = ''; + } + + $widget_control_template = $sidebar_args['before_widget'] . $widget_control_template . $sidebar_args['after_widget']; + + $no_widgets_shown = false; + + ?> + +
  • +

    + + + + + + + + + + + + + +

    + + +
      + + + +
    + + + + +
    + +
    + +
    + +
  • + + + +
  • + + + +
+ + +
    + + "; ?> + +
+ +\n"; + $params[0]['after_widget'] = ""; + $params[0]['before_title'] = "%BEG_OF_TITLE%"; + $params[0]['after_title'] = "%END_OF_TITLE%"; + if ( is_callable( $wp_registered_widgets[$widget_id]['callback'] ) ) { + $wp_registered_widgets[$widget_id]['_callback'] = $wp_registered_widgets[$widget_id]['callback']; + $wp_registered_widgets[$widget_id]['callback'] = 'wp_widget_control'; + } + return $params; +} + +/* + * Meta widget used to display the control form for a widget. Called from dynamic_sidebar() + */ +function wp_widget_control( $sidebar_args ) { + global $wp_registered_widgets, $wp_registered_widget_controls, $sidebars_widgets, $edit_widget; + $widget_id = $sidebar_args['widget_id']; + $sidebar_id = isset($sidebar_args['id']) ? $sidebar_args['id'] : false; + + $control = $wp_registered_widget_controls[$widget_id]; + $widget = $wp_registered_widgets[$widget_id]; + + $key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : 'no-key'; // position of widget in sidebar + + $edit = $edit_widget > 0 && $key && $edit_widget == $key; // (bool) are we currently editing this widget + + $id_format = $widget['id']; + // We aren't showing a widget control, we're outputing a template for a mult-widget control + if ( 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) { + // number == -1 implies a template where id numbers are replaced by a generic '%i%' + $control['params'][0]['number'] = -1; + // if given, id_base means widget id's should be constructed like {$id_base}-{$id_number} + if ( isset($control['id_base']) ) + $id_format = $control['id_base'] . '-%i%'; + } + + $widget_title = ''; + // We grab the normal widget output to find the widget's title + if ( is_callable( $widget['_callback'] ) ) { + ob_start(); + $args = func_get_args(); + call_user_func_array( $widget['_callback'], $args ); + $widget_title = ob_get_clean(); + $widget_title = wp_widget_control_ob_filter( $widget_title ); + } + $wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback']; + unset($wp_registered_widgets[$widget_id]['_callback']); + + if ( $widget_title ) + $widget_title = sprintf( _c('%1$s: %2$s|widget_admin_title' ), $sidebar_args['widget_name'], $widget_title ); + else + $widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) ); + + + if ( empty($sidebar_args['_display']) || 'template' != $sidebar_args['_display'] ) + echo $sidebar_args['before_widget']; +?> +

+ + + + + + + + + + + +

+ +
> + + ' . __('There are no options for this widget.') . '

'; + ?> + + + + +
+ + + + + + + + "> +
+
+
+ diff --git a/wp-admin/js/comment.js b/wp-admin/js/comment.js new file mode 100644 index 0000000..bde9b97 --- /dev/null +++ b/wp-admin/js/comment.js @@ -0,0 +1,12 @@ +addLoadEvent( function() { + add_postbox_toggles('comment'); + + jQuery('.edit-timestamp').click(function () { + if (jQuery('#timestampdiv').is(":hidden")) { + jQuery('#timestampdiv').slideDown("normal"); + } else { + jQuery('#timestampdiv').hide(); + } + return false; + }); +}); \ No newline at end of file diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js new file mode 100644 index 0000000..9f05e55 --- /dev/null +++ b/wp-admin/js/common.js @@ -0,0 +1,12 @@ +addLoadEvent( function() { + // pulse + jQuery('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300); + + // Reveal + jQuery('.wp-no-js-hidden').removeClass( 'wp-no-js-hidden' ); + + // Basic form validation + if ( ( 'undefined' != typeof wpAjax ) && jQuery.isFunction( wpAjax.validateForm ) ) { + jQuery('form').submit( function() { return wpAjax.validateForm( jQuery(this) ); } ); + } +}); diff --git a/wp-admin/js/dbx-admin-key.js b/wp-admin/js/dbx-admin-key.js deleted file mode 100644 index 3b3f7af..0000000 --- a/wp-admin/js/dbx-admin-key.js +++ /dev/null @@ -1,47 +0,0 @@ -addLoadEvent( function() {var manager = new dbxManager( dbxL10n.manager );} ); - -addLoadEvent( function() -{ - //create new docking boxes group - var meta = new dbxGroup( - 'grabit', // container ID [/-_a-zA-Z0-9/] - 'vertical', // orientation ['vertical'|'horizontal'] - '10', // drag threshold ['n' pixels] - 'no', // restrict drag movement to container axis ['yes'|'no'] - '10', // animate re-ordering [frames per transition, or '0' for no effect] - 'yes', // include open/close toggle buttons ['yes'|'no'] - 'closed', // default state ['open'|'closed'] - dbxL10n.open, // word for "open", as in "open this box" - dbxL10n.close, // word for "close", as in "close this box" - dbxL10n.moveMouse, // sentence for "move this box" by mouse - dbxL10n.toggleMouse, // pattern-match sentence for "(open|close) this box" by mouse - dbxL10n.moveKey, // sentence for "move this box" by keyboard - dbxL10n.toggleKey, // pattern-match sentence-fragment for "(open|close) this box" by keyboard - '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts - ); - - // Boxes are closed by default. Open the Category box if the cookie isn't already set. - var catdiv = document.getElementById('categorydiv'); - if ( catdiv ) { - var button = catdiv.getElementsByTagName('A')[0]; - if ( dbx.cookiestate == null && /dbx\-toggle\-closed/.test(button.className) ) - meta.toggleBoxState(button, true); - } - - var advanced = new dbxGroup( - 'advancedstuff', - 'vertical', - '10', - 'yes', // restrict drag movement to container axis ['yes'|'no'] - '10', - 'yes', - 'closed', - dbxL10n.open, - dbxL10n.close, - dbxL10n.moveMouse, - dbxL10n.toggleMouse, - dbxL10n.moveKey, - dbxL10n.toggleKey, - '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts - ); -}); diff --git a/wp-admin/js/editor.js b/wp-admin/js/editor.js new file mode 100644 index 0000000..a5500ec --- /dev/null +++ b/wp-admin/js/editor.js @@ -0,0 +1,153 @@ +wpEditorInit = function() { + // Activate tinyMCE if it's the user's default editor + if ( ( 'undefined' == typeof wpTinyMCEConfig ) || 'tinymce' == wpTinyMCEConfig.defaultEditor ) { + document.getElementById('editorcontainer').style.padding = '0px'; + tinyMCE.execCommand("mceAddControl", false, "content"); + } else { + var H; + if ( H = tinymce.util.Cookie.getHash("TinyMCE_content_size") ) + document.getElementById('content').style.height = H.ch - 30 + 'px'; + } +}; + +switchEditors = { + + saveCallback : function(el, content, body) { + + document.getElementById(el).style.color = '#fff'; + if ( tinyMCE.activeEditor.isHidden() ) + content = document.getElementById(el).value; + else + content = this.pre_wpautop(content); + + return content; + }, + + pre_wpautop : function(content) { + // We have a TON of cleanup to do. + + // Remove anonymous, empty paragraphs. + content = content.replace(new RegExp('

(\\s| |
)*

', 'mg'), ''); + + // Mark

if it has any attributes. + content = content.replace(new RegExp('(]+>.*?)

', 'mg'), '$1'); + + // Get it ready for wpautop. + content = content.replace(new RegExp('\\s*

', 'mgi'), ''); + content = content.replace(new RegExp('\\s*

\\s*', 'mgi'), '\n\n'); + content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n'); + content = content.replace(new RegExp('\\s*
\\s*', 'gi'), '\n'); + + // Fix some block element newline issues + var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre'; + content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); + content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); + content = content.replace(new RegExp('
  • ', 'g'), '\t
  • '); + + if ( content.indexOf(']*)>\\s*', 'g'), ""); // no pee inside object/embed + content = content.replace(new RegExp('\\s*\\s*', 'g'), ''); + } + + // Unmark special paragraph closing tags + content = content.replace(new RegExp('', 'g'), '

    \n'); + content = content.replace(new RegExp('\\s*(]+>.*

    )', 'mg'), '\n$1'); + + // Trim trailing whitespace + content = content.replace(new RegExp('\\s*$', ''), ''); + + // Hope. + return content; + }, + + go : function(id) { + var ed = tinyMCE.get(id); + var qt = document.getElementById('quicktags'); + var H = document.getElementById('edButtonHTML'); + var P = document.getElementById('edButtonPreview'); + var ta = document.getElementById(id); + var ec = document.getElementById('editorcontainer'); + + if ( ! ed || ed.isHidden() ) { + ta.style.color = '#fff'; + + this.edToggle(P, H); + edCloseAllTags(); // :-( + + qt.style.display = 'none'; + ec.style.padding = '0px'; + ta.style.padding = '0px'; + + ta.value = this.wpautop(ta.value); + + if ( ed ) ed.show(); + else tinyMCE.execCommand("mceAddControl", false, id); + + this.wpSetDefaultEditor('tinymce'); + } else { + this.edToggle(H, P); + ta.style.height = ed.getContentAreaContainer().offsetHeight + 6 + 'px'; + + ed.hide(); + qt.style.display = 'block'; + + if ( tinymce.isIE6 ) { + ta.style.width = '98%'; + ec.style.padding = '0px'; + ta.style.padding = '6px'; + } else { + ta.style.width = '100%'; + ec.style.padding = '6px'; + } + + ta.style.color = ''; + this.wpSetDefaultEditor('html'); + } + }, + + edToggle : function(A, B) { + A.className = 'active'; + B.className = ''; + + B.onclick = A.onclick; + A.onclick = null; + }, + + wpSetDefaultEditor : function(editor) { + try { + editor = escape( editor.toString() ); + } catch(err) { + editor = 'tinymce'; + } + + var userID = document.getElementById('user-id'); + var date = new Date(); + date.setTime(date.getTime()+(10*365*24*60*60*1000)); + document.cookie = "wordpress_editor_" + userID.value + "=" + editor + "; expires=" + date.toGMTString(); + }, + + wpautop : function(pee) { + var blocklist = 'table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]'; + + pee = pee + "\n\n"; + pee = pee.replace(new RegExp('
    \\s*
    ', 'gi'), "\n\n"); + pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1"); + pee = pee.replace(new RegExp('()', 'gi'), "$1\n\n"); + pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n"); + pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n"); + pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "

    $1

    \n"); + pee = pee.replace(new RegExp('

    \\s*?

    ', 'gi'), ''); + pee = pee.replace(new RegExp('

    \\s*(]*>)\\s*

    ', 'gi'), "$1"); + pee = pee.replace(new RegExp("

    (", 'gi'), "$1"); + pee = pee.replace(new RegExp('

    ]*)>', 'gi'), "

    "); + pee = pee.replace(new RegExp('

    ', 'gi'), '

    '); + pee = pee.replace(new RegExp('

    \\s*(]*>)', 'gi'), "$1"); + pee = pee.replace(new RegExp('(]*>)\\s*

    ', 'gi'), "$1"); + pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "
    \n"); + pee = pee.replace(new RegExp('(]*>)\\s*
    ', 'gi'), "$1"); + pee = pee.replace(new RegExp('
    (\\s*)', 'gi'), '$1'); + pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 '); + //pee = pee.replace(new RegExp('()(.*?)!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '' "); // Hmm... + return pee; + } +} diff --git a/wp-admin/js/forms.js b/wp-admin/js/forms.js new file mode 100644 index 0000000..21a62f4 --- /dev/null +++ b/wp-admin/js/forms.js @@ -0,0 +1,31 @@ +function checkAll(form) { + for (i = 0, n = form.elements.length; i < n; i++) { + if(form.elements[i].type == "checkbox" && !(form.elements[i].hasAttribute('onclick'))) { + if(form.elements[i].checked == true) + form.elements[i].checked = false; + else + form.elements[i].checked = true; + } + } +} + +function getNumChecked(form) { + var num = 0; + for (i = 0, n = form.elements.length; i < n; i++) { + if (form.elements[i].type == "checkbox") { + if (form.elements[i].checked == true) + num++; + } + } + return num; +} + +function checkAllUsers(role) { + var checkboxs = document.getElementsByTagName('input'); + for(var i = 0, inp; inp = checkboxs[i]; i++) + if(inp.type.toLowerCase() == 'checkbox' && inp.className == role) + if(inp.checked == false) + inp.checked = true; + else + inp.checked = false; +} \ No newline at end of file diff --git a/wp-admin/js/link-cat.js b/wp-admin/js/link-cat.js deleted file mode 100644 index a0775ce..0000000 --- a/wp-admin/js/link-cat.js +++ /dev/null @@ -1,10 +0,0 @@ -addLoadEvent(function(){linkcatList=new listMan('linkcategorychecklist');linkcatList.ajaxRespEl='jaxcat';linkcatList.topAdder=1;linkcatList.alt=0;linkcatList.showLink=0;}); -addLoadEvent(newLinkCatAddIn); -function newLinkCatAddIn() { - var jaxcat = $('jaxcat'); - if ( !jaxcat ) - return false; - Element.update(jaxcat,'' + linkcatL10n.how + ''); - $('newcat').onkeypress = function(e) { return killSubmit("linkcatList.ajaxAdder('link-category','jaxcat');", e); }; - $('catadd').onclick = function() { linkcatList.ajaxAdder('link-category', 'jaxcat'); }; -} diff --git a/wp-admin/js/link.js b/wp-admin/js/link.js new file mode 100644 index 0000000..9f5a28d --- /dev/null +++ b/wp-admin/js/link.js @@ -0,0 +1,48 @@ +addLoadEvent( function() { + jQuery('#link_name').focus(); + // postboxes + add_postbox_toggles('link'); + + // category tabs + var categoryTabs = jQuery('#category-tabs').tabs(); + + // Ajax Cat + var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } ); + jQuery('#category-add-sumbit').click( function() { newCat.focus(); } ); + var noSyncChecks = false; // prophylactic. necessary? + var syncChecks = function() { + if ( noSyncChecks ) + return; + noSyncChecks = true; + var th = jQuery(this); + var c = th.is(':checked'); + var id = th.val().toString(); + jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); + noSyncChecks = false; + }; + var catAddAfter = function( r, s ) { + jQuery(s.what + ' response_data', r).each( function() { + var t = jQuery(jQuery(this).text()); + t.find( 'label' ).each( function() { + var th = jQuery(this); + var val = th.find('input').val(); + var id = th.find('input')[0].id + jQuery('#' + id).change( syncChecks ); + var name = jQuery.trim( th.text() ); + var o = jQuery( '' ).text( name ); + } ); + } ); + }; + jQuery('#categorychecklist').wpList( { + alt: '', + what: 'link-category', + response: 'category-ajax-response', + addAfter: catAddAfter + } ); + jQuery('#category-add-toggle').click( function() { + jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' ); + categoryTabs.tabsClick( 1 ); + return false; + } ); + jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change(); +}); diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js new file mode 100644 index 0000000..b8c615d --- /dev/null +++ b/wp-admin/js/media-upload.js @@ -0,0 +1,12 @@ +// send html to the post editor +function send_to_editor(h) { + var win = window.opener ? window.opener : window.dialogArguments; + if ( !win ) + win = top; + tinyMCE = win.tinyMCE; + if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.getInstanceById('content') ) && !ed.isHidden() ) { + tinyMCE.selectedInstance.getWin().focus(); + tinyMCE.execCommand('mceInsertContent', false, h); + } else + win.edInsertContent(win.edCanvas, h); +} \ No newline at end of file diff --git a/wp-admin/js/page.js b/wp-admin/js/page.js new file mode 100644 index 0000000..02fd708 --- /dev/null +++ b/wp-admin/js/page.js @@ -0,0 +1,16 @@ +addLoadEvent( function() { + add_postbox_toggles('page'); + make_slugedit_clickable(); + + // hide advanced slug field + jQuery('#pageslugdiv').hide(); + + jQuery('.edit-timestamp').click(function () { + if (jQuery('#timestampdiv').is(":hidden")) { + jQuery('#timestampdiv').slideDown("normal"); + } else { + jQuery('#timestampdiv').hide(); + } + return false; + }); +}); \ No newline at end of file diff --git a/wp-admin/js/password-strength-meter.js b/wp-admin/js/password-strength-meter.js new file mode 100644 index 0000000..eba43fc --- /dev/null +++ b/wp-admin/js/password-strength-meter.js @@ -0,0 +1,162 @@ +// Password strength meter +// This jQuery plugin is written by firas kassem [2007.04.05] +// Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com +// for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/ + +var shortPass = 'Too short' +var badPass = 'Bad' +var goodPass = 'Good' +var strongPass = 'Strong' + + + +function passwordStrength(password,username) +{ + score = 0 + + //password < 4 + if (password.length < 4 ) { return shortPass } + + //password == username + if (password.toLowerCase()==username.toLowerCase()) return badPass + + //password length + score += password.length * 4 + score += ( checkRepetition(1,password).length - password.length ) * 1 + score += ( checkRepetition(2,password).length - password.length ) * 1 + score += ( checkRepetition(3,password).length - password.length ) * 1 + score += ( checkRepetition(4,password).length - password.length ) * 1 + + //password has 3 numbers + if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) score += 5 + + //password has 2 sybols + if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5 + + //password has Upper and Lower chars + if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) score += 10 + + //password has number and chars + if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) score += 15 + // + //password has number and symbol + if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) score += 15 + + //password has char and symbol + if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) score += 15 + + //password is just a nubers or chars + if (password.match(/^\w+$/) || password.match(/^\d+$/) ) score -= 10 + + //verifing 0 < score < 100 + if ( score < 0 ) score = 0 + if ( score > 100 ) score = 100 + + if (score < 34 ) return badPass + if (score < 68 ) return goodPass + return strongPass +} + + +// checkRepetition(1,'aaaaaaabcbc') = 'abcbc' +// checkRepetition(2,'aaaaaaabcbc') = 'aabc' +// checkRepetition(2,'aaaaaaabcdbcd') = 'aabcd' + +function checkRepetition(pLen,str) { + res = "" + for ( i=0; i 100 ) score = 100 + + if (score < 34 ) return badPass + if (score < 68 ) return goodPass + return strongPass +} + + +// checkRepetition(1,'aaaaaaabcbc') = 'abcbc' +// checkRepetition(2,'aaaaaaabcbc') = 'aabc' +// checkRepetition(2,'aaaaaaabcdbcd') = 'aabcd' + +function checkRepetition(pLen,str) { + res = "" + for ( i=0; iX ' + val + ' '; + jQuery( '#tagchecklist' ).append( txt ); + jQuery( '#tag-check-' + key ).click( new_tag_remove_tag ); + shown = true; + } + }); + if ( shown ) + jQuery( '#tagchecklist' ).prepend( ''+postL10n.tagsUsed+'
    ' ); +} + +function tag_flush_to_text() { + var newtags = jQuery('#tags-input').val() + ',' + jQuery('#newtag').val(); + // massage + newtags = newtags.replace( /\s+,+\s*/g, ',' ).replace( /,+/g, ',' ).replace( /,+\s+,+/g, ',' ).replace( /,+\s*$/g, '' ).replace( /^\s*,+/g, '' ); + jQuery('#tags-input').val( newtags ); + tag_update_quickclicks(); + jQuery('#newtag').val(''); + jQuery('#newtag').focus(); + return false; +} + +function tag_save_on_publish() { + if ( jQuery('#newtag').val() != postL10n.addTag ) + tag_flush_to_text(); +} + +function tag_press_key( e ) { + if ( 13 == e.keyCode ) { + tag_flush_to_text(); + return false; + } +} + +addLoadEvent( function() { + // postboxes + add_postbox_toggles('post'); + + // If no tags on the page, skip the tag and category stuff. + if ( !jQuery('#tags-input').size() ) { + return; + } + + // Editable slugs + make_slugedit_clickable(); + + // hide advanced slug field + jQuery('#slugdiv').hide(); + + jQuery('#tags-input').hide(); + tag_update_quickclicks(); + // add the quickadd form + jQuery('#jaxtag').prepend(''+postL10n.separate+''); + jQuery('#tagadd').click( tag_flush_to_text ); + jQuery('#newtag').focus(function() { + if ( this.value == postL10n.addTag ) + jQuery(this).val( '' ).removeClass( 'form-input-tip' ); + }); + jQuery('#newtag').blur(function() { + if ( this.value == '' ) + jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); + }); + + // auto-save tags on post save/publish + jQuery('#publish').click( tag_save_on_publish ); + jQuery('#save-post').click( tag_save_on_publish ); + + // auto-suggest stuff + jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2 } ); + jQuery('#newtag').keypress( tag_press_key ); + + // category tabs + var categoryTabs =jQuery('#category-tabs').tabs(); + + // Ajax Cat + var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } ); + jQuery('#category-add-sumbit').click( function() { newCat.focus(); } ); + var newCatParent = false; + var newCatParentOption = false; + var noSyncChecks = false; // prophylactic. necessary? + var syncChecks = function() { + if ( noSyncChecks ) + return; + noSyncChecks = true; + var th = jQuery(this); + var c = th.is(':checked'); + var id = th.val().toString(); + jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); + noSyncChecks = false; + }; + var catAddAfter = function( r, s ) { + if ( !newCatParent ) newCatParent = jQuery('#newcat_parent'); + if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' ); + jQuery(s.what + ' response_data', r).each( function() { + var t = jQuery(jQuery(this).text()); + t.find( 'label' ).each( function() { + var th = jQuery(this); + var val = th.find('input').val(); + var id = th.find('input')[0].id + jQuery('#' + id).change( syncChecks ); + if ( newCatParent.find( 'option[value=' + val + ']' ).size() ) + return; + var name = jQuery.trim( th.text() ); + var o = jQuery( '' ).text( name ); + newCatParent.prepend( o ); + } ); + newCatParentOption.attr( 'selected', true ); + } ); + }; + jQuery('#categorychecklist').wpList( { + alt: '', + response: 'category-ajax-response', + addAfter: catAddAfter + } ); + jQuery('#category-add-toggle').click( function() { + jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' ); + categoryTabs.tabsClick( 1 ); + jQuery('#newcat').focus(); + return false; + } ); + jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change(); + + jQuery('.edit-timestamp').click(function () { + if (jQuery('#timestampdiv').is(":hidden")) { + jQuery('#timestampdiv').slideDown("normal"); + } else { + jQuery('#timestampdiv').hide(); + } + return false; + }); +}); diff --git a/wp-admin/js/postbox.js b/wp-admin/js/postbox.js new file mode 100644 index 0000000..a512f4b --- /dev/null +++ b/wp-admin/js/postbox.js @@ -0,0 +1,14 @@ +function add_postbox_toggles(page) { + jQuery('.postbox h3').prepend('+ '); + jQuery('.postbox h3').click( function() { jQuery(jQuery(this).parent().get(0)).toggleClass('closed'); save_postboxes_state(page); } ); +} + +function save_postboxes_state(page) { + var closed = jQuery('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','); + jQuery.post(postboxL10n.requestFile, { + action: 'closed-postboxes', + closed: closed, + closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(), + page: page + }); +} diff --git a/wp-admin/js/slug.js b/wp-admin/js/slug.js new file mode 100644 index 0000000..f26a5f2 --- /dev/null +++ b/wp-admin/js/slug.js @@ -0,0 +1,48 @@ +function edit_permalink(post_id) { + var i, c = 0; + var e = jQuery('#editable-post-name'); + var revert_e = e.html(); + var real_slug = jQuery('#post_name'); + var revert_slug = real_slug.html(); + var b = jQuery('#edit-slug-buttons'); + var revert_b = b.html(); + var full = jQuery('#editable-post-name-full').html(); + + b.html(''+slugL10n.save+' '+slugL10n.cancel+''); + b.children('.save').click(function() { + var new_slug = e.children('input').val(); + jQuery.post(slugL10n.requestFile, { + action: 'sample-permalink', + post_id: post_id, + new_slug: new_slug, + new_title: jQuery('#title').val(), + samplepermalinknonce: jQuery('#samplepermalinknonce').val()}, function(data) { + jQuery('#edit-slug-box').html(data); + b.html(revert_b); + real_slug.attr('value', new_slug); + make_slugedit_clickable(); + }); + return false; + }); + jQuery('#edit-slug-buttons .cancel').click(function() { + e.html(revert_e); + b.html(revert_b); + real_slug.attr('value', revert_slug); + return false; + }); + for(i=0; i < full.length; ++i) { + if ('%' == full.charAt(i)) c++; + } + slug_value = (c > full.length/4)? '' : full; + e.html('').children('input').keypress(function(e){ + var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; + // on enter, just save the new slug, don't save the post + if (13 == key) {b.children('.save').click();return false;} + if (27 == key) {b.children('.cancel').click();return false;} + real_slug.attr('value', this.value)}).focus(); +} + +function make_slugedit_clickable() { + jQuery('#editable-post-name').click(function() {jQuery('#edit-slug-buttons').children('.edit-slug').click()}); +} + diff --git a/wp-admin/js/tags.js b/wp-admin/js/tags.js new file mode 100644 index 0000000..37182df --- /dev/null +++ b/wp-admin/js/tags.js @@ -0,0 +1,21 @@ +jQuery(function($) { + var options = false + + var addAfter = function( r, settings ) { + var name = $("" + $('name', r).text() + "").html(); + var id = $('tag', r).attr('id'); + options[options.length] = new Option(name, id); + } + + var delAfter = function( r, settings ) { + var id = $('tag', r).attr('id'); + for ( var o = 0; o < options.length; o++ ) + if ( id == options[o].value ) + options[o] = null; + } + + if ( options ) + $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } ); + else + $('#the-list').wpList(); +}); diff --git a/wp-admin/js/widgets.js b/wp-admin/js/widgets.js new file mode 100644 index 0000000..6bf7f2c --- /dev/null +++ b/wp-admin/js/widgets.js @@ -0,0 +1,136 @@ +jQuery(function($) { + $('.noscript-action').remove(); + + var increment = 1; + + // Open or close widget control form + var toggleWidget = function( li, disableFields ) { + var width = li.find('input.widget-width').val(); + + // it seems IE chokes on these animations because of the positioning/floating + var widgetAnim = $.browser.msie ? function() { + var t = $(this); + if ( t.is(':visible') ) { + if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"]' ).attr( 'disabled', 'disabled' ); } + li.css( 'marginLeft', 0 ); + t.siblings('h4').children('a').text( widgetsL10n.edit ); + } else { + t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open + if ( width > 250 ) + li.css( 'marginLeft', ( width - 250 ) * -1 ); + t.siblings('h4').children('a').text( widgetsL10n.cancel ); + } + t.toggle(); + } : function() { + var t = $(this); + + if ( t.is(':visible') ) { + if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"]' ).attr( 'disabled', 'disabled' ); } + if ( width > 250 ) + li.animate( { marginLeft: 0 } ); + t.siblings('h4').children('a').text( widgetsL10n.edit ); + } else { + t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open + if ( width > 250 ) + li.animate( { marginLeft: ( width - 250 ) * -1 } ); + t.siblings('h4').children('a').text( widgetsL10n.cancel ); + } + t.animate( { height: 'toggle' } ); + }; + + return li.children('div.widget-control').each( widgetAnim ).end(); + }; + + // onclick for edit/cancel links + var editClick = function() { + var q = wpAjax.unserialize( this.href ); + // if link is in available widgets list, make sure it points to the current sidebar + if ( ( q.sidebar && q.sidebar == $('#sidebar').val() ) || q.add ) { + var w = q.edit || q.add; + toggleWidget( $('#current-sidebar .widget-control-list input[@name^="widget-id"][@value=' + w + ']').parents('li:first'), false ).blur(); + return false; + } else if ( q.sidebar ) { // otherwise, redirect to correct page + return true; + } + + // If link is in current widgets list, just open the form + toggleWidget( $(this).parents('li:first'), true ).blur(); + return false; + }; + + // onclick for add links + var addClick = function() { + var oldLi = $(this).parents('li:first').find('ul.widget-control-info li'); + var newLi = oldLi.clone(); + + if ( newLi.html().match( /%i%/ ) ) { + // supplid form is a template, replace %i% by unique id + var i = $('#generated-time').val() + increment.toString(); + increment++; + newLi.html( newLi.html().replace( /%i%/g, i ) ); + } else { + $(this).text( widgetsL10n.edit ).unbind().click( editClick ); + // save form content in textarea so we don't have any conflicting HTML ids + oldLi.html( '' ); + } + + // add event handlers + addWidgetControls( newLi ); + + // add widget to sidebar sortable + widgetSortable.append( newLi ).SortableAddItem( newLi[0] ); + + // increment widget counter + var n = parseInt( $('#widget-count').text(), 10 ) + 1; + $('#widget-count').text( n.toString() ) + + return false; + }; + + // add event handlers to all links found in context + var addWidgetControls = function( context ) { + if ( !context ) + context = document; + + $('a.widget-control-edit', context).click( editClick ); + + // onclick for save links + $('a.widget-control-save', context).click( function() { + toggleWidget( $(this).parents('li:first'), false ).blur() + return false; + } ); + + // onclick for remove links + $('a.widget-control-remove', context).click( function() { + var w = $(this).parents('li:first').find('input[@name^="widget-id"]').val(); + $(this).parents('li:first').remove(); + var t = $('#widget-list ul#widget-control-info-' + w + ' textarea'); + t.parent().html( t.text() ).parents('li.widget-list-item:first').children( 'h4' ).children('a.widget-action') + .show().text( widgetsL10n.add ).unbind().click( addClick ); + var n = parseInt( $('#widget-count').text(), 10 ) - 1; + $('#widget-count').text( n.toString() ) + return false; + } ); + } + + addWidgetControls(); + + $('a.widget-control-add').click( addClick ); + + var widgetSortable; + var widgetSortableInit = function() { + try { // a hack to make sortables work in jQuery 1.2+ and IE7 + $('#current-sidebar .widget-control-list').SortableDestroy(); + } catch(e) {} + widgetSortable = $('#current-sidebar .widget-control-list').Sortable( { + accept: 'widget-sortable', + helperclass: 'sorthelper', + handle: 'h4.widget-title', + onStop: widgetSortableInit + } ); + } + + // initialize sortable + widgetSortableInit(); + +}); diff --git a/wp-admin/media-upload.php b/wp-admin/media-upload.php new file mode 100644 index 0000000..e756166 --- /dev/null +++ b/wp-admin/media-upload.php @@ -0,0 +1,41 @@ + diff --git a/wp-admin/media.php b/wp-admin/media.php new file mode 100644 index 0000000..bd64104 --- /dev/null +++ b/wp-admin/media.php @@ -0,0 +1,87 @@ +

    $message

  • \n"; + +?> + +
    + +

    + +
    +
    +
    + false, 'send' => false, 'delete' => false, 'errors' => $errors ) ); ?> +
    +
    + +

    + + + + +

    + + +
    + + diff --git a/wp-admin/update.php b/wp-admin/update.php new file mode 100644 index 0000000..b047384 --- /dev/null +++ b/wp-admin/update.php @@ -0,0 +1,127 @@ +'.__('You do not have sufficient permissions to update plugins for this blog.').'

    '); + +function request_filesystem_credentials($form_post, $type = '', $error = false) { + if ( empty($type) ) + $type = get_filesystem_method(); + + if ( 'direct' == $type ) + return array(); + + if ( ! $error && !empty($_POST['password']) && !empty($_POST['username']) && !empty($_POST['hostname']) ) { + $credentials = array('hostname' => $_POST['hostname'], 'username' => $_POST['username'], + 'password' => $_POST['password'], 'ssl' => $_POST['ssl']); + $stored_credentials = $credentials; + unset($stored_credentials['password']); + update_option('ftp_credentials', $stored_credentials); + return $credentials; + } + $hostname = ''; + $username = ''; + $password = ''; + $ssl = ''; + if ( $credentials = get_option('ftp_credentials') ) + extract($credentials, EXTR_OVERWRITE); + if( $error ){ + echo '

    ' . __('Error: There was an error connecting to the server, Please verify the settings are correct.') . '

    '; + } +?> + +
    +

    +

    + + + + + + + + + + + + + + + + + +
    + +
    +

    + +

    +
    + +get_error_data() ) + $message = $message->get_error_message() . ': ' . $message->get_error_data(); + else + $message = $message->get_error_message(); + } + echo "

    $message

    "; +} + +function do_plugin_upgrade($plugin) { + global $wp_filesystem; + + $url = wp_nonce_url("update.php?action=upgrade-plugin&plugin=$plugin", "upgrade-plugin_$plugin"); + if ( false === ($credentials = request_filesystem_credentials($url)) ) + return; + + if( ! WP_Filesystem($credentials) ){ + request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again + return; + } + + echo '
    '; + echo '

    ' . __('Upgrade Plugin') . '

    '; + if ( $wp_filesystem->errors->get_error_code() ) { + foreach ( $wp_filesystem->errors->get_error_messages() as $message ) + show_message($message); + echo '
    '; + return; + } + + $result = wp_update_plugin($plugin, 'show_message'); + + if ( is_wp_error($result) ) + show_message($result); + else + echo __('Plugin upgraded successfully'); + echo ''; +} + +if ( isset($_GET['action']) ) { + if ( isset($_GET['plugin']) ) + $plugin = trim($_GET['plugin']); + + if ( 'upgrade-plugin' == $_GET['action'] ) { + check_admin_referer('upgrade-plugin_' . $plugin); + $title = __('Upgrade Plugin'); + $parent_file = 'plugins.php'; + require_once('admin-header.php'); + do_plugin_upgrade($plugin); + include('admin-footer.php'); + } +} + +?> diff --git a/wp-admin/wpmu-blogs.php.rej b/wp-admin/wpmu-blogs.php.rej new file mode 100644 index 0000000..c3aebfd --- /dev/null +++ b/wp-admin/wpmu-blogs.php.rej @@ -0,0 +1,1224 @@ +*************** +*** 1,570 **** + You do not have permission to access this page.

    ') ); + } +- if (isset($_GET['updated'])) { +- ?>

    '; +- switch( $_GET[ 'action' ] ) { +- case "editblog": +- $id = intval( $_GET[ 'id' ] ); +- $options_table_name = "$wpmuBaseTablePrefix{$id}_options"; +- $options = $wpdb->get_results( "SELECT * FROM {$options_table_name} WHERE option_name NOT LIKE 'rss%' AND option_name NOT LIKE '%user_roles'", ARRAY_A ); +- $details = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '{$id}'", ARRAY_A ); +- $editblog_roles = get_blog_option( $id, "$wpmuBaseTablePrefix{$id}_user_roles" ); + +- print "

    " . __('Edit Blog') . "

    "; +- print "{$details[ 'domain' ]}"; +- ?> +-
    +- +- +- +- +- +- +- '; +- } +- } +- if( $out != '' ) { +- print "

    " . __('Blog Themes') . "

    "; +- print '
    +-
    +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- + +-
    http://
    >    +- >    +-
    >    +- >    +-
    >    +- >    +-
    >    +- >    +-
    >    +- >    +-
    +-
    +-
    +-
    />
    +-

    +- +-

    +-
    +-
    +- $theme ) { +- $theme_key = wp_specialchars( $theme[ 'Stylesheet' ] ); +- if( isset( $allowed_themes[ $theme_key ] ) == false ) { +- if( isset( $blog_allowed_themes[ $theme_key ] ) == true ) { +- $checked = 'checked '; +- } else { +- $checked = ''; +- } +- +- $out .= ' +-
    '.$key.'
    '; +- print ''; +- print $out; +- print "
    ' . __('Theme') . '' . __('Enable') . '
    "; +- } +- $blogusers = get_users_of_blog( $id ); +- print '

    ' . __('Blog Users') . '

    '; +- if( is_array( $blogusers ) ) { +- print ''; +- print ""; +- reset( $blogusers ); +- while( list( $key, $val ) = each( $blogusers ) ) +- { +- $t = @unserialize( $val->meta_value ); +- if( is_array( $t ) ) { +- reset( $t ); +- $existing_role = key( $t ); +- } +- print ""; +- if( $val->user_id != $current_user->data->ID ) { +- ?> +- '; +- } else { +- print ""; +- } +- print '"; +- } +- print "
    ' . __('Current Users') . '
    " . __('User') . "" . __('Role') . "" . __('Password') . "" . __('Remove') . "
    " . $val->user_login . "" . __ ('N/A') . "" . __ ('N/A') . "" . __('N/A') . "' . __('Edit') . "
    "; +- } +- print "

    " . __('Add a new user') . "

    "; +- ?> +-

    Click them to select and hit Update Options to add the user.') ?>

    +- +- +- +- +- +- +- +-
    +-
    +-
    +-

    +-
    +-

    +- +-

    +- +- +- +- blogs." +- WHERE site_id = '".$wpdb->siteid."' "; +- if( $_GET[ 's' ] != '' ) { + $query = "SELECT blog_id, {$wpdb->blogs}.domain, {$wpdb->blogs}.path, registered, last_updated +- FROM $wpdb->blogs, $wpdb->site +- WHERE site_id = '$wpdb->siteid' +- AND {$wpdb->blogs}.site_id = {$wpdb->site}.id +- AND ( {$wpdb->blogs}.domain LIKE '%". trim( $_GET[ 's' ] )."%' OR {$wpdb->blogs}.path LIKE '%". trim( $_GET[ 's' ] )."%' )"; +- } elseif( $_GET[ 'blog_id' ] != '' ) { + $query = "SELECT * +- FROM $wpdb->blogs +- WHERE site_id = '$wpdb->siteid' +- AND blog_id = '".intval($_GET[ 'blog_id' ])."'"; +- } elseif( $_GET[ 'ip_address' ] != '' ) { +- $query = "SELECT * +- FROM $wpdb->blogs, wp_registration_log +- WHERE site_id = '$wpdb->siteid' +- AND {$wpdb->blogs}.blog_id = wp_registration_log.blog_id +- AND wp_registration_log.IP LIKE ('%".$_GET[ 'ip_address' ]."%')"; + } +- if( isset( $_GET[ 'sortby' ] ) == false ) { +- $_GET[ 'sortby' ] = 'id'; + } +- if( $_GET[ 'sortby' ] == 'registered' ) { + $query .= ' ORDER BY registered '; +- } elseif( $_GET[ 'sortby' ] == 'id' ) { + $query .= ' ORDER BY ' . $wpdb->blogs . '.blog_id '; +- } elseif( $_GET[ 'sortby' ] == 'lastupdated' ) { + $query .= ' ORDER BY last_updated '; +- } elseif( $_GET[ 'sortby' ] == 'blogname' ) { + $query .= ' ORDER BY domain '; + } +- if( $_GET[ 'order' ] == 'DESC' ) { +- $query .= "DESC"; +- } else { +- $query .= "ASC"; + } + +- if ( $_GET[ 'ip_address' ] == '' ) +- $query .= " LIMIT " . intval( $start ) . ", " . intval( $num ); +- $blog_list = $wpdb->get_results( $query, ARRAY_A ); +- if( count( $blog_list ) < $num ) { +- $next = false; + } else { +- $next = true; + } +- ?> +- + +-

    +- +-
    +-
    +- +- +-  
    +-  
    +-
    +- +-
    +- +-
    +-
    +- +- ' . __('Previous Blogs') . ''; +- } else { +- $blog_navigation .= '' . __('Previous Blogs') . ''; +- } +- if ( $next ) { +- $blog_navigation .= ' || ' . __('Next Blogs') . ''; +- } else { +- $blog_navigation .= ' || ' . __('Next Blogs'); +- } +- echo $blog_navigation; +- ?> +-
    +-
    +-
    + +-
    + +- 'display name' +- $posts_columns = array( +- 'id' => __('ID'), +- 'blogname' => __('Blog Name'), +- 'lastupdated' => __('Last Updated'), +- 'registered' => __('Registered'), +- 'users' => __('Users'), +- 'plugins' => __('Actions') +- ); +- $posts_columns = apply_filters('manage_posts_columns', $posts_columns); + +- // you can not edit these at the moment +- $posts_columns['control_view'] = ''; +- $posts_columns['control_edit'] = ''; +- $posts_columns['control_backend'] = ''; +- $posts_columns['control_deactivate'] = ''; +- $posts_columns['control_archive'] = ''; +- $posts_columns['control_spam'] = ''; +- $posts_columns['control_delete'] = ''; + +- $sortby_url = "s=" . $_GET[ 's' ] . "&ip_address=" . $_GET[ 'ip_address' ]; +- ?> + +-
    +- +- +- + +- $column_display_name) { ?> +- +- + +- +- "#fee", "spam" => "#faa", "deleted" => "#f55" ); +- foreach ($blog_list as $blog) { +- $class = ('alternate' == $class) ? '' : 'alternate'; +- reset( $status_list ); +- $bgcolour = ""; +- while( list( $status, $col ) = each( $status_list ) ) { +- if( get_blog_status( $blog[ 'blog_id' ], $status ) == 1 ) { +- $bgcolour = "style='background: $col'"; +- } +- } +- print ""; +- if( constant( "VHOST" ) == 'yes' ) { +- $blogname = str_replace( '.' . $current_site->domain, '', $blog[ 'domain' ] ); +- } else { +- $blogname = $blog[ 'path' ]; +- } + +- foreach($posts_columns as $column_name=>$column_display_name) { + +- switch($column_name) { +- +- case 'id': +- ?> +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- + +- +- +- +- +- +- +- +- +- +- +- + +- +- +- +- +- +- +- +- +- +- +-
    start=">
    ' name='allblogs[]' value=''> +- 10 ) +- $blogusers = array_slice( $blogusers, 0, 10 ); +- while( list( $key, $val ) = each( $blogusers ) ) +- print '' . $val->user_login . ' ('.$val->user_email.')
    '; +- } +- ?>
    " . __('Edit') . ""; ?>" . __('Backend') . ""; ?>">">">">">">">
    +- +- +-
    +- +-

      +-
    • +-
    • +- +-
    +- '> +- '>

    +- +-
    +-
    +- +- +-
    +-
    +- +-
    +-

    +-
    +- +- +- domain . $current_site->path ?> +- +- +- +-
    .domain;?>
    +- +-
    +-
    +- + +- +- +--- 1,651 ---- + You do not have permission to access this page.

    ') ); + } + ++ $id = intval( $_GET['id'] ); ++ ++ if ( $_GET['updated'] == 'true' ) { ++ ?> ++

    ++ ++

    ++ get_results( "SELECT * FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name NOT LIKE 'rss%' AND option_name NOT LIKE '%user_roles'", ARRAY_A ); ++ $details = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '{$id}'", ARRAY_A ); ++ $editblog_roles = get_blog_option( $id, "{$wpmuBaseTablePrefix}{$id}_user_roles" ); + ?> ++
    ++

    ++ '> ++
    ++ ++ ++ ++ ++ ++ ++ ++ ++ '; ++ } ++ } ++ ++ if( $out != '' ) { ++ echo "

    " . __('Blog Themes') . "

    "; ++ echo '
    ++
    ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ $val ) { ++ if( $val['option_name'] == 'default_role' ) { ++ $editblog_default_role = $val['option_value']; ++ } ++ $disabled = ''; ++ if ( is_serialized($val['option_value']) ) { ++ if ( is_serialized_string($val['option_value']) ) { ++ $val['option_value'] = wp_specialchars(maybe_unserialize($val['option_value']), 'single'); ++ } else { ++ $val['option_value'] = "SERIALIZED DATA"; ++ $disabled = ' disabled="disabled"'; ++ } ++ } ++ if ( stristr($val['option_value'], "\r") || stristr($val['option_value'], "\n") || stristr($val['option_value'], "\r\n") ) { ++ ?> ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    http://
    ++ /> ++ /> ++
    ++ /> ++ /> ++
    ++ /> ++ /> ++
    ++ /> ++ /> ++
    ++ /> ++ /> ++


    />
    ++

    ++

    ++
    ++
    ++ $theme ) { ++ $theme_key = wp_specialchars( $theme['Stylesheet'] ); ++ if( isset($allowed_themes[$theme_key] ) == false ) { ++ $checked = ( isset($blog_allowed_themes[ $theme_key ]) ) ? 'checked="checked"' : ''; ++ $out .= '
    '.$key.'
    '; ++ echo ''; ++ echo $out; ++ echo "
    ' . __('Theme') . '' . __('Enable') . '
    "; ++ } ++ ++ // Blog users ++ $blogusers = get_users_of_blog( $id ); ++ echo '

    ' . __('Blog Users') . '

    '; ++ if( is_array( $blogusers ) ) { ++ echo ''; ++ echo ""; ++ reset($blogusers); ++ foreach ( (array) $blogusers as $key => $val ) { ++ $t = @unserialize( $val->meta_value ); ++ if( is_array( $t ) ) { ++ reset( $t ); ++ $existing_role = key( $t ); ++ } ++ echo ""; ++ if( $val->user_id != $current_user->data->ID ) { ++ ?> ++ ++ ++ '; ++ } else { ++ echo ""; ++ } ++ echo '"; ++ } ++ echo "
    ' . __('Current Users') . '
    " . __('User') . "" . __('Role') . "" . __('Password') . "" . __('Remove') . "
    " . $val->user_login . " ++ ++ ++ ++ " . __ ('N/A') . "" . __ ('N/A') . "" . __('N/A') . "' . __('Edit') . "
    "; ++ } ++ ++ // New blog user ++ echo "

    " . __('Add a new user') . "

    "; ++ ?> ++

    Click them to select and hit Update Options to add the user.') ?>

    ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++ ++
    ++
    ++ ++
    ++ ++

    ++
    ++ ++

    ++

    ++ ++ ++ ++ ++ + blogs} WHERE site_id = '{$wpdb->siteid}' "; ++ ++ if( !empty($_GET['s']) ) { ++ $s = trim($_GET['s']); + $query = "SELECT blog_id, {$wpdb->blogs}.domain, {$wpdb->blogs}.path, registered, last_updated ++ FROM {$wpdb->blogs}, {$wpdb->site} ++ WHERE site_id = '{$wpdb->siteid}' ++ AND {$wpdb->blogs}.site_id = {$wpdb->site}.id ++ AND ( {$wpdb->blogs}.domain LIKE '%{$s}%' OR {$wpdb->blogs}.path LIKE '%{$s}%' )"; ++ } elseif( !empty($_GET['blog_id']) ) { + $query = "SELECT * ++ FROM {$wpdb->blogs} ++ WHERE site_id = '{$wpdb->siteid}' ++ AND blog_id = '".intval($_GET['blog_id'])."'"; ++ } elseif( !empty($_GET['ip_address']) ) { ++ $query = "SELECT * ++ FROM {$wpdb->blogs}, {$wpdb->registration_log} ++ WHERE site_id = '{$wpdb->siteid}' ++ AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id ++ AND {$wpdb->registration_log}.IP LIKE ('%".$_GET['ip_address']."%')"; + } ++ ++ if( isset( $_GET['sortby'] ) == false ) { ++ $_GET['sortby'] = 'id'; + } ++ ++ if( $_GET['sortby'] == 'registered' ) { + $query .= ' ORDER BY registered '; ++ } elseif( $_GET['sortby'] == 'id' ) { + $query .= ' ORDER BY ' . $wpdb->blogs . '.blog_id '; ++ } elseif( $_GET['sortby'] == 'lastupdated' ) { + $query .= ' ORDER BY last_updated '; ++ } elseif( $_GET['sortby'] == 'blogname' ) { + $query .= ' ORDER BY domain '; + } ++ ++ $query .= ( $_GET['order'] == 'DESC' ) ? 'DESC' : 'ASC'; ++ ++ if ( $_GET['ip_address'] == '' ) { ++ $query .= " LIMIT " . intval( $start ) . ", " . intval( $num ); + } ++ ++ $blog_list = $wpdb->get_results( $query, ARRAY_A ); ++ ++ $next = ( count( $blog_list ) < $num ) ? false : true; ++ ++ // Pagination ++ $url2 = "order=" . $_GET['order'] . "&sortby=" . $_GET['sortby'] . "&s=" . $_GET['s'] . "&ip_address=" . $_GET['ip_address']; + ++ $blog_navigation = ''; ++ if( $start == 0 ) { ++ $blog_navigation .= __('Previous Blogs'); ++ } elseif( $start <= 30 ) { ++ $blog_navigation .= '' . __('Previous Blogs') . ''; + } else { ++ $blog_navigation .= '' . __('Previous Blogs') . ''; ++ } ++ if ( $next ) { ++ $blog_navigation .= ' || ' . __('Next Blogs') . ''; ++ } else { ++ $blog_navigation .= ' || ' . __('Next Blogs'); + } ++ ?> ++ ++
    ++

    ++
    ++

    ++ ++
    ++ ++
    ++ ++
    ++ ++ ++
    ++ ++
    ++ ++ ++
    ++ ++
    ++ ++ ++
    ++ ++
    + ++ ++
    ++ ++ ++

    ++ ++ ++ 'display name' ++ $posts_columns = array( ++ 'id' => __('ID'), ++ 'blogname' => __('Blog Name'), ++ 'lastupdated' => __('Last Updated'), ++ 'registered' => __('Registered'), ++ 'users' => __('Users'), ++ 'plugins' => __('Actions') ++ ); ++ $posts_columns = apply_filters('manage_posts_columns', $posts_columns); + ++ // you can not edit these at the moment ++ $posts_columns['control_view'] = ''; ++ $posts_columns['control_edit'] = ''; ++ $posts_columns['control_backend'] = ''; ++ $posts_columns['control_deactivate']= ''; ++ $posts_columns['control_archive'] = ''; ++ $posts_columns['control_spam'] = ''; ++ $posts_columns['control_delete'] = ''; + ++ $sortby_url = "s=" . $_GET['s'] . "&ip_address=" . $_GET['ip_address']; ++ ?> ++
    ++ ++ ++ ++ ++ ++ $column_display_name) : ?> ++ ++ ++ ++ ++ ++ "#fee", "spam" => "#faa", "deleted" => "#f55" ); ++ foreach ($blog_list as $blog) { ++ $class = ('alternate' == $class) ? '' : 'alternate'; ++ reset( $status_list ); ++ ++ $bgcolour = ""; ++ foreach ( $status_list as $status => $col ) { ++ if( get_blog_status( $blog['blog_id'], $status ) == 1 ) { ++ $bgcolour = "style='background: $col'"; ++ } ++ } ++ echo ""; ++ ++ $blogname = ( constant( "VHOST" ) == 'yes' ) ? str_replace('.'.$current_site->domain, '', $blog['domain']) : $blog['path']; + ++ foreach( $posts_columns as $column_name=>$column_display_name ) { ++ switch($column_name) { ++ case 'id': ?> ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + ++ ++
    start=">
    ++ ' name='allblogs[]' value='' /> ++ ++ ++ ++ g:i:s a'), $blog['last_updated']); ?> ++ ++ g:i:s a'), $blog['registered']); ?> ++ ++ 10 ) { ++ $blogusers = array_slice( $blogusers, 0, 10 ); ++ } ++ foreach ( $blogusers as $key => $val ) { ++ echo '' . $val->user_login . ' ('.$val->user_email.')
    '; ++ } ++ } ++ ?> ++
    ++ ++ ++ " . __('Edit') . ""; ?> ++ ++ " . __('Backend') . ""; ?> ++ ++ " onclick="return deleteSomething( 'blog', , '' );"> ++ ++ " onclick="return deleteSomething( 'blog', , '' );"> ++ ++ " onclick="return deleteSomething( 'blog', , '' );"> ++ ++ " onclick="return deleteSomething( 'blog', , '' );"> ++ ++ " onclick="return deleteSomething( 'blog', , '' );"> ++ ++ " onclick="return deleteSomething( 'blog', , '' );"> ++ ++ " onclick="return deleteSomething( 'blog', , '' );"> ++ ++ ++ ++ ++
    ++ ++
    ++

    ++ ++
    + ++ ++ ++

    ++
      ++
    • ++
    • ++
    ++ ++

    ++ ++ ' /> ++ ' />

    ++
    ++
    ++ ++
    ++

    ++
    ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++ ++ .domain;?> ++ domain . $current_site->path ?> ++ ++
    ++ ++
    ++
    + \ No newline at end of file diff --git a/wp-content/themes/default/attachment.php b/wp-content/themes/default/attachment.php deleted file mode 100644 index 779af0d..0000000 --- a/wp-content/themes/default/attachment.php +++ /dev/null @@ -1,67 +0,0 @@ - - -
    - - - - -ID, true, array(450, 800)); // This also populates the iconsize for the next line ?> -ID); $classname = ($_post->iconsize[0] <= 128 ? 'small' : '') . 'attachment'; // This lets us style narrow icons specially ?> -
    -

    post_parent); ?> »

    -
    -


    guid); ?>

    - - Read the rest of this entry »

    '); ?> - - '

    Pages: ', 'after' => '

    ', 'next_or_number' => 'number')); ?> - - - -
    -
    - - - - - -

    Sorry, no attachments matched your criteria.

    - - - -
    - - diff --git a/wp-content/themes/default/image.php b/wp-content/themes/default/image.php new file mode 100644 index 0000000..d8e36fd --- /dev/null +++ b/wp-content/themes/default/image.php @@ -0,0 +1,63 @@ + + +
    + + + +
    +

    post_parent); ?> »

    +
    +

    + + Read the rest of this entry »

    '); ?> + + '

    Pages: ', 'after' => '

    ', 'next_or_number' => 'number')); ?> + + +
    + + + +
    + +
    + + + + + +

    Sorry, no attachments matched your criteria.

    + + + +
    + + diff --git a/wp-includes/class-phpass.php b/wp-includes/class-phpass.php new file mode 100644 index 0000000..656caa3 --- /dev/null +++ b/wp-includes/class-phpass.php @@ -0,0 +1,256 @@ + in 2004-2006 and placed in +# the public domain. +# +# There's absolutely no warranty. +# +# The homepage URL for this framework is: +# +# http://www.openwall.com/phpass/ +# +# Please be sure to update the Version line if you edit this file in any way. +# It is suggested that you leave the main version number intact, but indicate +# your project name (after the slash) and add your own revision information. +# +# Please do not change the "private" password hashing method implemented in +# here, thereby making your hashes incompatible. However, if you must, please +# change the hash type identifier (the "$P$") to something different. +# +# Obviously, since this code is in the public domain, the above are not +# requirements (there can be none), but merely suggestions. +# +class PasswordHash { + var $itoa64; + var $iteration_count_log2; + var $portable_hashes; + var $random_state; + + function PasswordHash($iteration_count_log2, $portable_hashes) + { + $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + + if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31) + $iteration_count_log2 = 8; + $this->iteration_count_log2 = $iteration_count_log2; + + $this->portable_hashes = $portable_hashes; + + $this->random_state = microtime() . getmypid(); + } + + function get_random_bytes($count) + { + $output = ''; + if (($fh = @fopen('/dev/urandom', 'rb'))) { + $output = fread($fh, $count); + fclose($fh); + } + + if (strlen($output) < $count) { + $output = ''; + for ($i = 0; $i < $count; $i += 16) { + $this->random_state = + md5(microtime() . $this->random_state); + $output .= + pack('H*', md5($this->random_state)); + } + $output = substr($output, 0, $count); + } + + return $output; + } + + function encode64($input, $count) + { + $output = ''; + $i = 0; + do { + $value = ord($input[$i++]); + $output .= $this->itoa64[$value & 0x3f]; + if ($i < $count) + $value |= ord($input[$i]) << 8; + $output .= $this->itoa64[($value >> 6) & 0x3f]; + if ($i++ >= $count) + break; + if ($i < $count) + $value |= ord($input[$i]) << 16; + $output .= $this->itoa64[($value >> 12) & 0x3f]; + if ($i++ >= $count) + break; + $output .= $this->itoa64[($value >> 18) & 0x3f]; + } while ($i < $count); + + return $output; + } + + function gensalt_private($input) + { + $output = '$P$'; + $output .= $this->itoa64[min($this->iteration_count_log2 + + ((PHP_VERSION >= '5') ? 5 : 3), 30)]; + $output .= $this->encode64($input, 6); + + return $output; + } + + function crypt_private($password, $setting) + { + $output = '*0'; + if (substr($setting, 0, 2) == $output) + $output = '*1'; + + if (substr($setting, 0, 3) != '$P$') + return $output; + + $count_log2 = strpos($this->itoa64, $setting[3]); + if ($count_log2 < 7 || $count_log2 > 30) + return $output; + + $count = 1 << $count_log2; + + $salt = substr($setting, 4, 8); + if (strlen($salt) != 8) + return $output; + + # We're kind of forced to use MD5 here since it's the only + # cryptographic primitive available in all versions of PHP + # currently in use. To implement our own low-level crypto + # in PHP would result in much worse performance and + # consequently in lower iteration counts and hashes that are + # quicker to crack (by non-PHP code). + if (PHP_VERSION >= '5') { + $hash = md5($salt . $password, TRUE); + do { + $hash = md5($hash . $password, TRUE); + } while (--$count); + } else { + $hash = pack('H*', md5($salt . $password)); + do { + $hash = pack('H*', md5($hash . $password)); + } while (--$count); + } + + $output = substr($setting, 0, 12); + $output .= $this->encode64($hash, 16); + + return $output; + } + + function gensalt_extended($input) + { + $count_log2 = min($this->iteration_count_log2 + 8, 24); + # This should be odd to not reveal weak DES keys, and the + # maximum valid value is (2**24 - 1) which is odd anyway. + $count = (1 << $count_log2) - 1; + + $output = '_'; + $output .= $this->itoa64[$count & 0x3f]; + $output .= $this->itoa64[($count >> 6) & 0x3f]; + $output .= $this->itoa64[($count >> 12) & 0x3f]; + $output .= $this->itoa64[($count >> 18) & 0x3f]; + + $output .= $this->encode64($input, 3); + + return $output; + } + + function gensalt_blowfish($input) + { + # This one needs to use a different order of characters and a + # different encoding scheme from the one in encode64() above. + # We care because the last character in our encoded string will + # only represent 2 bits. While two known implementations of + # bcrypt will happily accept and correct a salt string which + # has the 4 unused bits set to non-zero, we do not want to take + # chances and we also do not want to waste an additional byte + # of entropy. + $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + + $output = '$2a$'; + $output .= chr(ord('0') + $this->iteration_count_log2 / 10); + $output .= chr(ord('0') + $this->iteration_count_log2 % 10); + $output .= '$'; + + $i = 0; + do { + $c1 = ord($input[$i++]); + $output .= $itoa64[$c1 >> 2]; + $c1 = ($c1 & 0x03) << 4; + if ($i >= 16) { + $output .= $itoa64[$c1]; + break; + } + + $c2 = ord($input[$i++]); + $c1 |= $c2 >> 4; + $output .= $itoa64[$c1]; + $c1 = ($c2 & 0x0f) << 2; + + $c2 = ord($input[$i++]); + $c1 |= $c2 >> 6; + $output .= $itoa64[$c1]; + $output .= $itoa64[$c2 & 0x3f]; + } while (1); + + return $output; + } + + function HashPassword($password) + { + $random = ''; + + if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) { + $random = $this->get_random_bytes(16); + $hash = + crypt($password, $this->gensalt_blowfish($random)); + if (strlen($hash) == 60) + return $hash; + } + + if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) { + if (strlen($random) < 3) + $random = $this->get_random_bytes(3); + $hash = + crypt($password, $this->gensalt_extended($random)); + if (strlen($hash) == 20) + return $hash; + } + + if (strlen($random) < 6) + $random = $this->get_random_bytes(6); + $hash = + $this->crypt_private($password, + $this->gensalt_private($random)); + if (strlen($hash) == 34) + return $hash; + + # Returning '*' on error is safe here, but would _not_ be safe + # in a crypt(3)-like function used _both_ for generating new + # hashes and for validating passwords against existing hashes. + return '*'; + } + + function CheckPassword($password, $stored_hash) + { + $hash = $this->crypt_private($password, $stored_hash); + if ($hash[0] == '*') + $hash = crypt($password, $stored_hash); + + return $hash == $stored_hash; + } +} + +?> diff --git a/wp-includes/images/audio.png b/wp-includes/images/audio.png new file mode 100644 index 0000000..7b2a854 Binary files /dev/null and b/wp-includes/images/audio.png differ diff --git a/wp-includes/images/crystal/archive.png b/wp-includes/images/crystal/archive.png new file mode 100644 index 0000000..670648a Binary files /dev/null and b/wp-includes/images/crystal/archive.png differ diff --git a/wp-includes/images/crystal/audio.png b/wp-includes/images/crystal/audio.png new file mode 100644 index 0000000..5a3d4d3 Binary files /dev/null and b/wp-includes/images/crystal/audio.png differ diff --git a/wp-includes/images/crystal/code.png b/wp-includes/images/crystal/code.png new file mode 100644 index 0000000..b67c600 Binary files /dev/null and b/wp-includes/images/crystal/code.png differ diff --git a/wp-includes/images/crystal/default.png b/wp-includes/images/crystal/default.png new file mode 100644 index 0000000..b1bbbc7 Binary files /dev/null and b/wp-includes/images/crystal/default.png differ diff --git a/wp-includes/images/crystal/document.png b/wp-includes/images/crystal/document.png new file mode 100644 index 0000000..3295ccd Binary files /dev/null and b/wp-includes/images/crystal/document.png differ diff --git a/wp-includes/images/crystal/interactive.png b/wp-includes/images/crystal/interactive.png new file mode 100644 index 0000000..fd6de7d Binary files /dev/null and b/wp-includes/images/crystal/interactive.png differ diff --git a/wp-includes/images/crystal/license.txt b/wp-includes/images/crystal/license.txt new file mode 100644 index 0000000..cdabd2f --- /dev/null +++ b/wp-includes/images/crystal/license.txt @@ -0,0 +1,9 @@ +Crystal Project Icons +by Everaldo Coelho +http://everaldo.com + +Released under LGPL + +Modified February 2008 +for WordPress +http://wordpress.org \ No newline at end of file diff --git a/wp-includes/images/crystal/spreadsheet.png b/wp-includes/images/crystal/spreadsheet.png new file mode 100644 index 0000000..f2c4d30 Binary files /dev/null and b/wp-includes/images/crystal/spreadsheet.png differ diff --git a/wp-includes/images/crystal/text.png b/wp-includes/images/crystal/text.png new file mode 100644 index 0000000..feaed5b Binary files /dev/null and b/wp-includes/images/crystal/text.png differ diff --git a/wp-includes/images/crystal/video.png b/wp-includes/images/crystal/video.png new file mode 100644 index 0000000..e1b879d Binary files /dev/null and b/wp-includes/images/crystal/video.png differ diff --git a/wp-includes/images/css.png b/wp-includes/images/css.png new file mode 100644 index 0000000..038e34d Binary files /dev/null and b/wp-includes/images/css.png differ diff --git a/wp-includes/images/default.png b/wp-includes/images/default.png new file mode 100644 index 0000000..c551227 Binary files /dev/null and b/wp-includes/images/default.png differ diff --git a/wp-includes/images/doc.png b/wp-includes/images/doc.png new file mode 100644 index 0000000..e4e62a1 Binary files /dev/null and b/wp-includes/images/doc.png differ diff --git a/wp-includes/images/exe.png b/wp-includes/images/exe.png new file mode 100644 index 0000000..d994265 Binary files /dev/null and b/wp-includes/images/exe.png differ diff --git a/wp-includes/images/html.png b/wp-includes/images/html.png new file mode 100644 index 0000000..ed81af1 Binary files /dev/null and b/wp-includes/images/html.png differ diff --git a/wp-includes/images/js.png b/wp-includes/images/js.png new file mode 100644 index 0000000..e0862d3 Binary files /dev/null and b/wp-includes/images/js.png differ diff --git a/wp-includes/images/pdf.png b/wp-includes/images/pdf.png new file mode 100644 index 0000000..b4d5f9c Binary files /dev/null and b/wp-includes/images/pdf.png differ diff --git a/wp-includes/images/swf.png b/wp-includes/images/swf.png new file mode 100644 index 0000000..156e3e4 Binary files /dev/null and b/wp-includes/images/swf.png differ diff --git a/wp-includes/images/tar.png b/wp-includes/images/tar.png new file mode 100644 index 0000000..0468ef8 Binary files /dev/null and b/wp-includes/images/tar.png differ diff --git a/wp-includes/images/text.png b/wp-includes/images/text.png new file mode 100644 index 0000000..10bcf5e Binary files /dev/null and b/wp-includes/images/text.png differ diff --git a/wp-includes/images/video.png b/wp-includes/images/video.png new file mode 100644 index 0000000..f822ac4 Binary files /dev/null and b/wp-includes/images/video.png differ diff --git a/wp-includes/images/zip.png b/wp-includes/images/zip.png new file mode 100644 index 0000000..d1eaf1e Binary files /dev/null and b/wp-includes/images/zip.png differ diff --git a/wp-includes/js/dbx.js b/wp-includes/js/dbx.js deleted file mode 100644 index 8e89c5a..0000000 --- a/wp-includes/js/dbx.js +++ /dev/null @@ -1,6 +0,0 @@ -// DBX2.05 :: Docking Boxes (dbx) -// ***************************************************** -// DOM scripting by brothercake -- http://www.brothercake.com/ -// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html -//****************************************************** -var dbx;function dbxManager(sid){dbx = this;if(!/^[-_a-z0-9]+$/i.test(sid)) { alert('Error from dbxManager:\n"' + sid + '" is an invalid session ID'); return; }this.supported = !(document.getElementsByTagName('*').length == 0 || (navigator.vendor == 'KDE' && typeof window.sidebar == 'undefined'));if(!this.supported) { return; }this.etype = typeof document.addEventListener != 'undefined' ? 'addEventListener' : typeof document.attachEvent != 'undefined' ? 'attachEvent' : 'none';this.eprefix = (this.etype == 'attachEvent' ? 'on' : '');if(typeof window.opera != 'undefined' && parseFloat(navigator.userAgent.toLowerCase().split(/opera[\/ ]/)[1].split(' ')[0], 10) < 7.5){this.etype = 'none';}if(this.etype == 'none') { this.supported = false; return; }this.running = 0;this.sid = sid;this.savedata = {};this.cookiestate = this.getCookieState();};dbxManager.prototype.setCookieState = function(){var now = new Date();now.setTime(now.getTime() + (365*24*60*60*1000));var str = '';for(j in this.savedata){if(typeof this.savedata[j]!='function'){str += j + '=' + this.savedata[j] + '&'}}this.state = str.replace(/^(.+)&$/, '$1');this.cookiestring = this.state.replace(/,/g, '|');this.cookiestring = this.cookiestring.replace(/=/g, ':');if(typeof this.onstatechange == 'undefined' || this.onstatechange()){document.cookie = 'dbx-' + this.sid + '='+ this.cookiestring+ '; expires=' + now.toGMTString()+ '; path=/';}};dbxManager.prototype.getCookieState = function(){this.cookiestate = null;if(document.cookie){if(document.cookie.indexOf('dbx-' + this.sid)!=-1){this.cookie = document.cookie.split('dbx-' + this.sid + '=')[1].split(';')[0].split('&');for(var i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookie[i] = this.cookie[i].replace(/\|/g, ',');this.cookie[i]= this.cookie[i].replace(/:/g, '=');this.cookie[i] = this.cookie[i].split('=');this.cookie[i][1] = this.cookie[i][1].split(',');}}this.cookiestate = {};for(i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookiestate[this.cookie[i][0]] = this.cookie[i][1];}}}}return this.cookiestate;};dbxManager.prototype.addDataMember = function(gid, order){this.savedata[gid] = order;};dbxManager.prototype.createElement = function(tag){return typeof document.createElementNS != 'undefined' ? document.createElementNS('http://www.w3.org/1999/xhtml', tag) : document.createElement(tag);};dbxManager.prototype.getTarget = function(e, pattern, node){if(typeof node != 'undefined'){var target = node;}else{target = typeof e.target != 'undefined' ? e.target : e.srcElement;}var regex = new RegExp(pattern, '');while(!regex.test(target.className)){target = target.parentNode;}return target;};function dbxGroup(gid, dir, thresh, fix, ani, togs, def, open, close, move, toggle, kmove, ktoggle, syntax){if(!/^[-_a-z0-9]+$/i.test(gid)) { alert('Error from dbxGroup:\n"' + gid + '" is an invalid container ID'); return; }this.container = document.getElementById(gid);if(this.container == null || !dbx.supported) { return; }var self = this;this.gid = gid;this.dragok = false;this.box = null;this.vertical = dir == 'vertical';this.threshold = parseInt(thresh, 10);this.restrict = fix == 'yes';this.resolution = parseInt(ani, 10);this.toggles = togs == 'yes';this.defopen = def != 'closed';this.vocab = {'open' : open,'close' : close,'move' : move,'toggle' : toggle,'kmove' : kmove,'ktoggle' : ktoggle,'syntax' : syntax};this.container.style.position = 'relative';this.container.style.display = 'block';if(typeof window.opera != 'undefined'){this.container.style.display = 'run-in';}this.boxes = [];this.buttons = [];this.order = [];this.eles = this.container.getElementsByTagName('*');for(var i=0; i 0)){var sibling = this.boxes[positions[i + (positive ? 1 : -1)][0]];if(this.resolution > 0){var visipos = { 'x' : parent.offsetLeft, 'y' : parent.offsetTop };var siblingpos = { 'x' : sibling.offsetLeft, 'y' : sibling.offsetTop };}var obj = { 'insert' : (positive ? sibling : parent), 'before' : (positive ? parent : sibling) };this.container.insertBefore(obj.insert, obj.before);if(this.resolution > 0){var animators ={'sibling' : new dbxAnimator(this, sibling, siblingpos, this.resolution, true, anchor),'parent' : new dbxAnimator(this, parent, visipos, this.resolution, true, anchor)};}else{anchor.focus();}break;}}}this.getBoxOrder();}};dbxGroup.prototype.compare = function(a, b){return a[1] - b[1];};dbxGroup.prototype.createTooltip = function(isopen, anchor){if(this.keydown){this.tooltip = this.container.appendChild(dbx.createElement('span'));this.tooltip.style.visibility = 'hidden';this.tooltip.className = 'dbx-tooltip';if(isopen != null){this.tooltip.appendChild(document.createTextNode(this.vocab.kmove + this.vocab.ktoggle.replace('%toggle%', isopen ? this.vocab.close : this.vocab.open)));}else{this.tooltip.appendChild(document.createTextNode(this.vocab.kmove));}var parent = dbx.getTarget(null, 'dbx\-box', anchor);this.tooltip.style.left = parent.offsetLeft + 'px';this.tooltip.style.top = parent.offsetTop + 'px';var tooltip = this.tooltip;window.setTimeout(function(){if(tooltip != null) { tooltip.style.visibility = 'visible'; }}, 500);}};dbxGroup.prototype.removeTooltip = function(){if(this.tooltip != null){this.tooltip.parentNode.removeChild(this.tooltip);this.tooltip = null;}};dbxGroup.prototype.mousedown = function(e, box){var node = typeof e.target != 'undefined' ? e.target : e.srcElement;if(node.nodeName == '#text') { node = node.parentNode; }if(!/dbx\-(toggle|box|group)/i.test(node.className)){while(!/dbx\-(handle|box|group)/i.test(node.className)){node = node.parentNode;}}if(/dbx\-handle/i.test(node.className)){this.removeTooltip();this.released = false;this.initial = { 'x' : e.clientX, 'y' : e.clientY };this.current = { 'x' : 0, 'y' : 0 };this.createCloneBox(box);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return false; }}}};dbxGroup.prototype.mousemove = function(e){if(this.dragok && this.box != null){this.positive = this.vertical ? (e.clientY > this.current.y ? true : false) : (e.clientX > this.current.x ? true : false);this.current = { 'x' : e.clientX, 'y' : e.clientY };var overall = { 'x' : this.current.x - this.initial.x, 'y' : this.current.y - this.initial.y };if(((overall.x >= 0 && overall.x <= this.threshold) || (overall.x <= 0 && overall.x >= 0 - this.threshold))&&((overall.y >= 0 && overall.y <= this.threshold) || (overall.y <= 0 && overall.y >= 0 - this.threshold))){this.current.x -= overall.x;this.current.y -= overall.y;}if(this.released || overall.x > this.threshold || overall.x < (0 - this.threshold) || overall.y > this.threshold || overall.y < (0 - this.threshold)){dbx.group = this.container;dbx.box = this.box;dbx.event = e;if(typeof dbx.onboxdrag == 'undefined' || dbx.onboxdrag()){this.released = true;if(!this.restrict || !this.vertical) { this.boxclone.style.left = (this.current.x - this.difference.x) + 'px'; }if(!this.restrict || this.vertical) { this.boxclone.style.top = (this.current.y - this.difference.y) + 'px'; }this.moveOriginalToPosition(this.current.x, this.current.y);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }}}}return true;};dbxGroup.prototype.mouseup = function(e){if(this.box != null){this.moveOriginalToPosition(e.clientX, e.clientY);this.removeCloneBox();this.getBoxOrder();if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return true; }}}this.dragok = false;};dbxGroup.prototype.keypress = function(e, anchor){if(/^(3[7-9])|(40)$/.test(e.keyCode)){this.removeTooltip();if((this.vertical && /^(38|40)$/.test(e.keyCode)) || (!this.vertical && /^(37|39)$/.test(e.keyCode))){this.shiftBoxPosition(e, anchor, /^[3][78]$/.test(e.keyCode) ? false : true);if(typeof e.preventDefault != 'undefined') { e.preventDefault(); }else { return false; }typeof e.stopPropagation != 'undefined' ? e.stopPropagation() : e.cancelBubble = true;this.keydown = false;}}return true;};dbxGroup.prototype.getBoxOrder = function(){this.order = [];var len = this.eles.length;for(var j=0; j boxprops.xy && cloneprops.xy < boxprops.xy)||(!this.positive && cloneprops.xy < boxprops.xy && cloneprops.xy + cloneprops.wh > boxprops.xy)){if(this.boxes[i] == this.box) { return; }var sibling = this.box.nextSibling;while(sibling.className == null || !/dbx\-box/.test(sibling.className)){sibling = sibling.nextSibling;}if(this.boxes[i] == sibling) { return; }if(this.resolution > 0){if(this.box[this.vertical ? 'offsetTop' : 'offsetLeft'] < boxprops.xy){var visibox = this.boxes[i].previousSibling;while(visibox.className == null || !/dbx\-box/.test(visibox.className)){visibox = visibox.previousSibling;}}else{visibox = this.boxes[i];}var visipos = { 'x' : visibox.offsetLeft, 'y' : visibox.offsetTop };}var prepos = { 'x' : this.box.offsetLeft, 'y' : this.box.offsetTop };this.container.insertBefore(this.box, this.boxes[i]);this.initial.x += (this.box.offsetLeft - prepos.x);this.initial.y += (this.box.offsetTop - prepos.y);if(this.resolution > 0 && visibox != this.box){var animator = new dbxAnimator(this, visibox, visipos, this.resolution, false, null);}else{}break;}}};function dbxAnimator(caller, box, pos, res, kbd, anchor){this.caller = caller;this.box = box;this.timer = null;var before = pos[this.caller.vertical ? 'y' : 'x'];var after = this.box[this.caller.vertical ? 'offsetTop' : 'offsetLeft'];if(before != after){if(dbx.running > this.caller.boxes.length - 1) { return; }var clone = this.caller.createClone(this.box, 29999, arguments[2]);clone.style.visibility = 'visible';this.box.style.visibility = 'hidden';this.animateClone(clone,before,after > before ? after - before : 0 - (before - after),this.caller.vertical ? 'top' : 'left',res,kbd,anchor);}};dbxAnimator.prototype.animateClone = function(clone, current, change, dir, res, kbd, anchor){var self = this;var count = 0;dbx.running ++;this.timer = window.setInterval(function(){count ++;current += change / res;clone.style[dir] = current + 'px';if(count == res){window.clearTimeout(self.timer);self.timer = null;dbx.running --;self.caller.container.removeChild(clone);self.box.style.visibility = 'visible';if(kbd){if(anchor != null && anchor.parentNode.style.visibility != 'hidden'){anchor.focus();}else if(self.caller.toggles){var button = self.caller.buttons[parseInt(self.box.className.split('dbxid')[1],10)];if(button != null && typeof button.isactive != 'undefined'){button.focus();}}}}}, 20);};if(typeof window.attachEvent != 'undefined'){window.attachEvent('onunload', function(){var ev = ['mousedown', 'mousemove', 'mouseup', 'mouseout', 'click', 'keydown', 'keyup', 'focus', 'blur', 'selectstart', 'statechange', 'boxdrag', 'boxopen', 'boxclose'];var el = ev.length;var dl = document.all.length;for(var i=0; i1){override=true;i++;} +if(typeof arguments[i]=="object"){for(var option in arguments[i]) +if(typeof ctx[option]!="undefined") +ctx[option]=arguments[i][option];i++;} +if(typeof arguments[i]=="number"||(typeof arguments[i]=="string"&&arguments[i].match(RegExp("^[0-9]+[smhdw]$")))) +ctx["time"]=arguments[i++];if(typeof arguments[i]=="boolean") +ctx["repeat"]=arguments[i++];if(typeof arguments[i]=="boolean") +ctx["protect"]=arguments[i++];if(typeof arguments[i]=="object"&&typeof arguments[i+1]=="string"&&_isfn(arguments[i][arguments[i+1]])){ctx["obj"]=arguments[i++];ctx["func"]=arguments[i++];} +else if(typeof arguments[i]!="undefined"&&(_isfn(arguments[i])||typeof arguments[i]=="string")) +ctx["func"]=arguments[i++];while(typeof arguments[i]!="undefined") +ctx["args"].push(arguments[i++]);if(override){if(typeof arguments[1]=="object"){for(var option in arguments[0]) +if(typeof ctx[option]!="undefined"&&typeof arguments[1][option]=="undefined") +ctx[option]=arguments[0][option];} +else{for(var option in arguments[0]) +if(typeof ctx[option]!="undefined") +ctx[option]=arguments[0][option];} +i++;} +ctx["_scheduler"]=this;ctx["_handle"]=null;var match=String(ctx["time"]).match(RegExp("^([0-9]+)([smhdw])$"));if(match&&match[0]!="undefined"&&match[1]!="undefined") +ctx["time"]=String(parseInt(match[1])*{s:1000,m:1000*60,h:1000*60*60,d:1000*60*60*24,w:1000*60*60*24*7}[match[2]]);if(ctx["id"]==null) +ctx["id"]=(String(ctx["repeat"])+":" ++String(ctx["protect"])+":" ++String(ctx["time"])+":" ++String(ctx["obj"])+":" ++String(ctx["func"])+":" ++String(ctx["args"]));if(ctx["protect"]) +if(typeof this.bucket[ctx["id"]]!="undefined") +return this.bucket[ctx["id"]];if(!_isfn(ctx["func"])){if(ctx["obj"]!=null&&typeof ctx["obj"]=="object"&&typeof ctx["func"]=="string"&&_isfn(ctx["obj"][ctx["func"]])) +ctx["func"]=ctx["obj"][ctx["func"]];else +ctx["func"]=eval("function () { "+ctx["func"]+" }");} +ctx["_handle"]=this._schedule(ctx);this.bucket[ctx["id"]]=ctx;return ctx;},reschedule:function(ctx){if(typeof ctx=="string") +ctx=this.bucket[ctx];ctx["_handle"]=this._schedule(ctx);return ctx;},_schedule:function(ctx){var trampoline=function(){var obj=(ctx["obj"]!=null?ctx["obj"]:ctx);(ctx["func"]).apply(obj,ctx["args"]);if(typeof(ctx["_scheduler"]).bucket[ctx["id"]]!="undefined"&&ctx["repeat"]) +(ctx["_scheduler"])._schedule(ctx);else +delete(ctx["_scheduler"]).bucket[ctx["id"]];};return setTimeout(trampoline,ctx["time"]);},cancel:function(ctx){if(typeof ctx=="string") +ctx=this.bucket[ctx];if(typeof ctx=="object"){clearTimeout(ctx["_handle"]);delete this.bucket[ctx["id"]];}}};$.extend({scheduler$:new $.scheduler(),schedule:function(){return $.scheduler$.schedule.apply($.scheduler$,arguments)},reschedule:function(){return $.scheduler$.reschedule.apply($.scheduler$,arguments)},cancel:function(){return $.scheduler$.cancel.apply($.scheduler$,arguments)}});$.fn.extend({schedule:function(){var a=[{}];for(var i=0;i= options.minchars) { + + cached = checkCache(q); + + if (cached) { + + displayItems(cached['items']); + + } else { + + $.get(options.source, {q: q}, function(txt) { + + $results.hide(); + + var items = parseTxt(txt, q); + + displayItems(items); + addToCache(q, items, txt.length); + + }); + + } + + } else { + + $results.hide(); + + } + + } + + + function checkCache(q) { + + for (var i = 0; i < cache.length; i++) + if (cache[i]['q'] == q) { + cache.unshift(cache.splice(i, 1)[0]); + return cache[0]; + } + + return false; + + } + + function addToCache(q, items, size) { + + while (cache.length && (cacheSize + size > options.maxCacheSize)) { + var cached = cache.pop(); + cacheSize -= cached['size']; + } + + cache.push({ + q: q, + size: size, + items: items + }); + + cacheSize += size; + + } + + function displayItems(items) { + + if (!items) + return; + + if (!items.length) { + $results.hide(); + return; + } + + var html = ''; + for (var i = 0; i < items.length; i++) + html += '
  • ' + items[i] + '
  • '; + + $results.html(html).show(); + + $results + .children('li') + .mouseover(function() { + $results.children('li').removeClass(options.selectClass); + $(this).addClass(options.selectClass); + }) + .click(function(e) { + e.preventDefault(); + e.stopPropagation(); + selectCurrentResult(); + }); + + } + + function parseTxt(txt, q) { + + var items = []; + var tokens = txt.split(options.delimiter); + + // parse returned data for non-empty items + for (var i = 0; i < tokens.length; i++) { + var token = $.trim(tokens[i]); + if (token) { + token = token.replace( + new RegExp(q, 'ig'), + function(q) { return '' + q + '' } + ); + items[items.length] = token; + } + } + + return items; + } + + function getCurrentResult() { + + if (!$results.is(':visible')) + return false; + + var $currentResult = $results.children('li.' + options.selectClass); + + if (!$currentResult.length) + $currentResult = false; + + return $currentResult; + + } + + function selectCurrentResult() { + + $currentResult = getCurrentResult(); + + if ($currentResult) { + $input.val($currentResult.text()); + $results.hide(); + + if (options.onSelect) + options.onSelect.apply($input[0]); + + } + + } + + function nextResult() { + + $currentResult = getCurrentResult(); + + if ($currentResult) + $currentResult + .removeClass(options.selectClass) + .next() + .addClass(options.selectClass); + else + $results.children('li:first-child').addClass(options.selectClass); + + } + + function prevResult() { + + $currentResult = getCurrentResult(); + + if ($currentResult) + $currentResult + .removeClass(options.selectClass) + .prev() + .addClass(options.selectClass); + else + $results.children('li:last-child').addClass(options.selectClass); + + } + + } + + $.fn.suggest = function(source, options) { + + if (!source) + return; + + options = options || {}; + options.source = source; + options.delay = options.delay || 100; + options.resultsClass = options.resultsClass || 'ac_results'; + options.selectClass = options.selectClass || 'ac_over'; + options.matchClass = options.matchClass || 'ac_match'; + options.minchars = options.minchars || 2; + options.delimiter = options.delimiter || '\n'; + options.onSelect = options.onSelect || false; + options.maxCacheSize = options.maxCacheSize || 65536; + + this.each(function() { + new $.suggest(this, options); + }); + + return this; + + }; + +})(jQuery); \ No newline at end of file diff --git a/wp-includes/js/jquery/ui.tabs.js b/wp-includes/js/jquery/ui.tabs.js new file mode 100644 index 0000000..8634b41 --- /dev/null +++ b/wp-includes/js/jquery/ui.tabs.js @@ -0,0 +1,529 @@ +/* + * Tabs 3 - New Wave Tabs + * + * Copyright (c) 2007 Klaus Hartl (stilbuero.de) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + */ + +(function($) { + + // if the UI scope is not availalable, add it + $.ui = $.ui || {}; + + // tabs initialization + $.fn.tabs = function(initial, options) { + if (initial && initial.constructor == Object) { // shift arguments + options = initial; + initial = null; + } + options = options || {}; + + initial = initial && initial.constructor == Number && --initial || 0; + + return this.each(function() { + new $.ui.tabs(this, $.extend(options, { initial: initial })); + }); + }; + + // other chainable tabs methods + $.each(['Add', 'Remove', 'Enable', 'Disable', 'Click', 'Load', 'Href'], function(i, method) { + $.fn['tabs' + method] = function() { + var args = arguments; + return this.each(function() { + var instance = $.ui.tabs.getInstance(this); + instance[method.toLowerCase()].apply(instance, args); + }); + }; + }); + $.fn.tabsSelected = function() { + var selected = -1; + if (this[0]) { + var instance = $.ui.tabs.getInstance(this[0]), + $lis = $('li', this); + selected = $lis.index( $lis.filter('.' + instance.options.selectedClass)[0] ); + } + return selected >= 0 ? ++selected : -1; + }; + + // tabs class + $.ui.tabs = function(el, options) { + + this.source = el; + + this.options = $.extend({ + + // basic setup + initial: 0, + event: 'click', + disabled: [], + cookie: null, // pass options object as expected by cookie plugin: { expires: 7, path: '/', domain: 'jquery.com', secure: true } + // TODO bookmarkable: $.ajaxHistory ? true : false, + unselected: false, + unselect: options.unselected ? true : false, + + // Ajax + spinner: 'Loading…', + cache: false, + idPrefix: 'ui-tabs-', + ajaxOptions: {}, + + // animations + /*fxFade: null, + fxSlide: null, + fxShow: null, + fxHide: null,*/ + fxSpeed: 'normal', + /*fxShowSpeed: null, + fxHideSpeed: null,*/ + + // callbacks + add: function() {}, + remove: function() {}, + enable: function() {}, + disable: function() {}, + click: function() {}, + hide: function() {}, + show: function() {}, + load: function() {}, + + // templates + tabTemplate: '
  • #{text}
  • ', + panelTemplate: '
    ', + + // CSS classes + navClass: 'ui-tabs-nav', + selectedClass: 'ui-tabs-selected', + unselectClass: 'ui-tabs-unselect', + disabledClass: 'ui-tabs-disabled', + panelClass: 'ui-tabs-panel', + hideClass: 'ui-tabs-hide', + loadingClass: 'ui-tabs-loading' + + }, options); + + this.options.event += '.ui-tabs'; // namespace event + this.options.cookie = $.cookie && $.cookie.constructor == Function && this.options.cookie; + + // save instance for later + $.data(el, $.ui.tabs.INSTANCE_KEY, this); + + // create tabs + this.tabify(true); + }; + + // static + $.ui.tabs.INSTANCE_KEY = 'ui_tabs_instance'; + $.ui.tabs.getInstance = function(el) { + return $.data(el, $.ui.tabs.INSTANCE_KEY); + }; + + // instance methods + $.extend($.ui.tabs.prototype, { + tabId: function(a) { + return a.title ? a.title.replace(/\s/g, '_') + : this.options.idPrefix + $.data(a); + }, + tabify: function(init) { + + this.$lis = $('li:has(a[href])', this.source); + this.$tabs = this.$lis.map(function() { return $('a', this)[0] }); + this.$panels = $([]); + + var self = this, o = this.options; + + this.$tabs.each(function(i, a) { + // inline tab + if (a.hash && a.hash.replace('#', '')) { // Safari 2 reports '#' for an empty hash + self.$panels = self.$panels.add(a.hash); + } + // remote tab + else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#" + $.data(a, 'href', a.href); + var id = self.tabId(a); + a.href = '#' + id; + self.$panels = self.$panels.add( + $('#' + id)[0] || $(o.panelTemplate).attr('id', id).addClass(o.panelClass) + .insertAfter( self.$panels[i - 1] || self.source ) + ); + } + // invalid tab href + else { + o.disabled.push(i + 1); + } + }); + + if (init) { + + // attach necessary classes for styling if not present + $(this.source).hasClass(o.navClass) || $(this.source).addClass(o.navClass); + this.$panels.each(function() { + var $this = $(this); + $this.hasClass(o.panelClass) || $this.addClass(o.panelClass); + }); + + // disabled tabs + for (var i = 0, position; position = o.disabled[i]; i++) { + this.disable(position); + } + + // Try to retrieve initial tab: + // 1. from fragment identifier in url if present + // 2. from cookie + // 3. from selected class attribute on
  • + // 4. otherwise use given initial argument + // 5. check if tab is disabled + this.$tabs.each(function(i, a) { + if (location.hash) { + if (a.hash == location.hash) { + o.initial = i; + // prevent page scroll to fragment + //if (($.browser.msie || $.browser.opera) && !o.remote) { + if ($.browser.msie || $.browser.opera) { + var $toShow = $(location.hash), toShowId = $toShow.attr('id'); + $toShow.attr('id', ''); + setTimeout(function() { + $toShow.attr('id', toShowId); // restore id + }, 500); + } + scrollTo(0, 0); + return false; // break + } + } else if (o.cookie) { + o.initial = parseInt($.cookie( $.ui.tabs.INSTANCE_KEY + $.data(self.source) )) || 0; + return false; // break + } else if ( self.$lis.eq(i).hasClass(o.selectedClass) ) { + o.initial = i; + return false; // break + } + }); + var n = this.$lis.length; + while (this.$lis.eq(o.initial).hasClass(o.disabledClass) && n) { + o.initial = ++o.initial < this.$lis.length ? o.initial : 0; + n--; + } + if (!n) { // all tabs disabled, set option unselected to true + o.unselected = o.unselect = true; + } + + // highlight selected tab + this.$panels.addClass(o.hideClass); + this.$lis.removeClass(o.selectedClass); + if (!o.unselected) { + this.$panels.eq(o.initial).show().removeClass(o.hideClass); // use show and remove class to show in any case no matter how it has been hidden before + this.$lis.eq(o.initial).addClass(o.selectedClass); + } + + // load if remote tab + var href = !o.unselected && $.data(this.$tabs[o.initial], 'href'); + if (href) { + this.load(o.initial + 1, href); + } + + // disable click if event is configured to something else + if (!/^click/.test(o.event)) { + this.$tabs.bind('click', function(e) { e.preventDefault(); }); + } + + } + + // setup animations + var showAnim = {}, showSpeed = o.fxShowSpeed || o.fxSpeed, + hideAnim = {}, hideSpeed = o.fxHideSpeed || o.fxSpeed; + if (o.fxSlide || o.fxFade) { + if (o.fxSlide) { + showAnim['height'] = 'show'; + hideAnim['height'] = 'hide'; + } + if (o.fxFade) { + showAnim['opacity'] = 'show'; + hideAnim['opacity'] = 'hide'; + } + } else { + if (o.fxShow) { + showAnim = o.fxShow; + } else { // use some kind of animation to prevent browser scrolling to the tab + showAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox + showSpeed = 1; // as little as 1 is sufficient + } + if (o.fxHide) { + hideAnim = o.fxHide; + } else { // use some kind of animation to prevent browser scrolling to the tab + hideAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox + hideSpeed = 1; // as little as 1 is sufficient + } + } + + // reset some styles to maintain print style sheets etc. + var resetCSS = { display: '', overflow: '', height: '' }; + if (!$.browser.msie) { // not in IE to prevent ClearType font issue + resetCSS['opacity'] = ''; + } + + // Hide a tab, animation prevents browser scrolling to fragment, + // $show is optional. + function hideTab(clicked, $hide, $show) { + $hide.animate(hideAnim, hideSpeed, function() { // + $hide.addClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc. + if ($.browser.msie && hideAnim['opacity']) { + $hide[0].style.filter = ''; + } + o.hide(clicked, $hide[0], $show && $show[0] || null); + if ($show) { + showTab(clicked, $show, $hide); + } + }); + } + + // Show a tab, animation prevents browser scrolling to fragment, + // $hide is optional + function showTab(clicked, $show, $hide) { + if (!(o.fxSlide || o.fxFade || o.fxShow)) { + $show.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab panels + } + $show.animate(showAnim, showSpeed, function() { + $show.removeClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc. + if ($.browser.msie && showAnim['opacity']) { + $show[0].style.filter = ''; + } + o.show(clicked, $show[0], $hide && $hide[0] || null); + }); + } + + // switch a tab + function switchTab(clicked, $li, $hide, $show) { + /*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click + $.ajaxHistory.update(clicked.hash); + }*/ + $li.addClass(o.selectedClass) + .siblings().removeClass(o.selectedClass); + hideTab(clicked, $hide, $show); + } + + // attach tab event handler, unbind to avoid duplicates from former tabifying... + this.$tabs.unbind(o.event).bind(o.event, function() { + + //var trueClick = e.clientX; // add to history only if true click occured, not a triggered click + var $li = $(this).parents('li:eq(0)'), + $hide = self.$panels.filter(':visible'), + $show = $(this.hash); + + // If tab is already selected and not unselectable or tab disabled or click callback returns false stop here. + // Check if click handler returns false last so that it is not executed for a disabled tab! + if (($li.hasClass(o.selectedClass) && !o.unselect) || $li.hasClass(o.disabledClass) + || o.click(this, $show[0], $hide[0]) === false) { + this.blur(); + return false; + } + + if (o.cookie) { + $.cookie($.ui.tabs.INSTANCE_KEY + $.data(self.source), self.$tabs.index(this), o.cookie); + } + + // if tab may be closed + if (o.unselect) { + if ($li.hasClass(o.selectedClass)) { + $li.removeClass(o.selectedClass); + self.$panels.stop(); + hideTab(this, $hide); + this.blur(); + return false; + } else if (!$hide.length) { + self.$panels.stop(); + if ($.data(this, 'href')) { // remote tab + var a = this; + self.load(self.$tabs.index(this) + 1, $.data(this, 'href'), function() { + $li.addClass(o.selectedClass).addClass(o.unselectClass); + showTab(a, $show); + }); + } else { + $li.addClass(o.selectedClass).addClass(o.unselectClass); + showTab(this, $show); + } + this.blur(); + return false; + } + } + + // stop possibly running animations + self.$panels.stop(); + + // show new tab + if ($show.length) { + + // prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled + /*if ($.browser.msie && o.bookmarkable) { + var showId = this.hash.replace('#', ''); + $show.attr('id', ''); + setTimeout(function() { + $show.attr('id', showId); // restore id + }, 0); + }*/ + + if ($.data(this, 'href')) { // remote tab + var a = this; + self.load(self.$tabs.index(this) + 1, $.data(this, 'href'), function() { + switchTab(a, $li, $hide, $show); + }); + } else { + switchTab(this, $li, $hide, $show); + } + + // Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash + /*var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0; + var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0; + setTimeout(function() { + scrollTo(scrollX, scrollY); + }, 0);*/ + + } else { + throw 'jQuery UI Tabs: Mismatching fragment identifier.'; + } + + // Prevent IE from keeping other link focussed when using the back button + // and remove dotted border from clicked link. This is controlled in modern + // browsers via CSS, also blur removes focus from address bar in Firefox + // which can become a usability and annoying problem with tabsRotate. + if ($.browser.msie) { + this.blur(); + } + + //return o.bookmarkable && !!trueClick; // convert trueClick == undefined to Boolean required in IE + return false; + + }); + + }, + add: function(url, text, position) { + if (url && text) { + position = position || this.$tabs.length; // append by default + + var o = this.options, + $li = $(o.tabTemplate.replace(/#\{href\}/, url).replace(/#\{text\}/, text)); + + var id = url.indexOf('#') == 0 ? url.replace('#', '') : this.tabId( $('a:first-child', $li)[0] ); + + // try to find an existing element before creating a new one + var $panel = $('#' + id); + $panel = $panel.length && $panel + || $(o.panelTemplate).attr('id', id).addClass(o.panelClass).addClass(o.hideClass); + if (position >= this.$lis.length) { + $li.appendTo(this.source); + $panel.appendTo(this.source.parentNode); + } else { + $li.insertBefore(this.$lis[position - 1]); + $panel.insertBefore(this.$panels[position - 1]); + } + + this.tabify(); + + if (this.$tabs.length == 1) { + $li.addClass(o.selectedClass); + $panel.removeClass(o.hideClass); + var href = $.data(this.$tabs[0], 'href'); + if (href) { + this.load(position + 1, href); + } + } + o.add(this.$tabs[position], this.$panels[position]); // callback + } else { + throw 'jQuery UI Tabs: Not enough arguments to add tab.'; + } + }, + remove: function(position) { + if (position && position.constructor == Number) { + var o = this.options, $li = this.$lis.eq(position - 1).remove(), + $panel = this.$panels.eq(position - 1).remove(); + + // If selected tab was removed focus tab to the right or + // tab to the left if last tab was removed. + if ($li.hasClass(o.selectedClass) && this.$tabs.length > 1) { + this.click(position + (position < this.$tabs.length ? 1 : -1)); + } + this.tabify(); + o.remove($li.end()[0], $panel[0]); // callback + } + }, + enable: function(position) { + var o = this.options, $li = this.$lis.eq(position - 1); + $li.removeClass(o.disabledClass); + if ($.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2... + $li.css('display', 'inline-block'); + setTimeout(function() { + $li.css('display', 'block') + }, 0) + } + o.enable(this.$tabs[position - 1], this.$panels[position - 1]); // callback + }, + disable: function(position) { + var o = this.options; + this.$lis.eq(position - 1).addClass(o.disabledClass); + o.disable(this.$tabs[position - 1], this.$panels[position - 1]); // callback + }, + click: function(position) { + this.$tabs.eq(position - 1).trigger(this.options.event); + }, + load: function(position, url, callback) { + var self = this, o = this.options, + $a = this.$tabs.eq(position - 1), a = $a[0], $span = $('span', a); + + // shift arguments + if (url && url.constructor == Function) { + callback = url; + url = null; + } + + // set new URL or get existing + if (url) { + $.data(a, 'href', url); + } else { + url = $.data(a, 'href'); + } + + // load + if (o.spinner) { + $.data(a, 'title', $span.html()); + $span.html('' + o.spinner + ''); + } + var finish = function() { + self.$tabs.filter('.' + o.loadingClass).each(function() { + $(this).removeClass(o.loadingClass); + if (o.spinner) { + $('span', this).html( $.data(this, 'title') ); + } + }); + self.xhr = null; + }; + var ajaxOptions = $.extend(o.ajaxOptions, { + url: url, + success: function(r) { + $(a.hash).html(r); + finish(); + // This callback is required because the switch has to take + // place after loading has completed. + if (callback && callback.constructor == Function) { + callback(); + } + if (o.cache) { + $.removeData(a, 'href'); // if loaded once do not load them again + } + o.load(self.$tabs[position - 1], self.$panels[position - 1]); // callback + } + }); + if (this.xhr) { + // terminate pending requests from other tabs and restore title + this.xhr.abort(); + finish(); + } + $a.addClass(o.loadingClass); + setTimeout(function() { // timeout is again required in IE, "wait" for id being restored + self.xhr = $.ajax(ajaxOptions); + }, 0); + + }, + href: function(position, href) { + $.data(this.$tabs.eq(position - 1)[0], 'href', href); + } + }); + +})(jQuery); diff --git a/wp-includes/js/list-manipulation.js b/wp-includes/js/list-manipulation.js deleted file mode 100644 index e522709..0000000 --- a/wp-includes/js/list-manipulation.js +++ /dev/null @@ -1,295 +0,0 @@ -addLoadEvent( function() { - if ( 'undefined' != typeof listManL10n ) - Object.extend(listMan.prototype, listManL10n); - theList = new listMan(); -} ); - -function deleteSomething( what, id, message, obj ) { - if ( !obj ) - obj=theList; - if ( !message ) - message = obj.delText.replace(/%thing%/g, what); - if( confirm(message) ) - return obj.ajaxDelete( what, id ); - else return false; -} - -function dimSomething( what, id, dimClass, obj ) { - if ( !obj ) - obj = theList; - return obj.ajaxDimmer(what,id,dimClass); -} - -var listMan = Class.create(); -Object.extend(listMan.prototype, { - ajaxRespEl: 'ajax-response', - ajaxHandler: false, - inputData: '', - clearInputs: [], - showLink: true, - topAdder: false, - alt: 'alternate', - altOffset: 0, - addComplete: null, - delComplete: null, - dimComplete: null, - dataStore: null, - formStore: null, - - jumpText: '', // We get these from listManL10n - delText: '', - - initialize: function(theListId) { - this.theList = $(theListId ? theListId : 'the-list'); - if ( !this.theList ) - return false; - Element.cleanWhitespace(this.theList); - }, - - // sends add-what and fields contained in where - // recieves html with top element having an id like what-# - ajaxAdder: function( what, where, update ) { // Do NOT wrap TR in TABLE TBODY - var ajaxAdd = new WPAjax( this.ajaxHandler, this.ajaxRespEl ); - if ( ajaxAdd.notInitialized() ) - return true; - var action = ( update ? 'update-' : 'add-' ) + what; - ajaxAdd.options.parameters = $H(ajaxAdd.options.parameters).merge({action: action}).merge(this.inputData.toQueryParams()).merge(this.grabInputs( where, ajaxAdd ).toQueryParams()); - - var tempObj=this; - ajaxAdd.addOnComplete( function(transport) { - var newItems = $A(transport.responseXML.getElementsByTagName(what)); - if ( newItems ) { - var showLinkMessage = ''; - var m = ''; - newItems.each( function(i) { - var id = i.getAttribute('id'); - var exists = $(what+'-'+id); - if ( exists ) - tempObj.replaceListItem( exists, getNodeValue(i,'response_data'), update ); - else - tempObj.addListItem( getNodeValue(i, 'response_data') ); - m = getNodeValue(i, 'show-link'); - showLinkMessage += showLinkMessage ? "
    \n" : ''; - if ( m ) - showLinkMessage += m; - else - showLinkMessage += "" + tempObj.jumpText + ""; - }); - if ( tempObj.showLink && showLinkMessage ) - Element.update(ajaxAdd.myResponseElement,""); - } - if ( tempObj.addComplete && typeof tempObj.addComplete == 'function' ) - tempObj.addComplete( what, where, update, transport ); - tempObj.recolorList(); - ajaxAdd.restoreInputs = null; - }); - if ( !update ) - ajaxAdd.addOnWPError( function(transport) { tempObj.restoreForm(ajaxAdd.restoreInputs); }); - ajaxAdd.request(ajaxAdd.url); - if ( !update ) - this.clear(); - return false; - }, - - // sends update-what and fields contained in where - // recieves html with top element having an id like what-# - ajaxUpdater: function( what, where ) { return this.ajaxAdder( what, where, true ); }, - - // sends delete-what and id# - ajaxDelete: function( what, id ) { - var ajaxDel = new WPAjax( this.ajaxHandler, this.ajaxRespEl ); - if( ajaxDel.notInitialized() ) - return true; - var tempObj = this; - var action = 'delete-' + what; - var actionId = action + '&id=' + id; - var idName = what.replace('-as-spam','') + '-' + id; - ajaxDel.addOnComplete( function(transport) { - Element.update(ajaxDel.myResponseElement,''); - tempObj.destore(actionId); - if( tempObj.delComplete && typeof tempObj.delComplete == 'function' ) - tempObj.delComplete( what, id, transport ); - }); - ajaxDel.addOnWPError( function(transport) { tempObj.restore(actionId, true); }); - ajaxDel.options.parameters = $H(ajaxDel.options.parameters).merge({action: action, id: id}).merge(this.inputData.toQueryParams()); - ajaxDel.request(ajaxDel.url); - this.store(actionId, idName); - tempObj.removeListItem( idName ); - return false; - }, - - // Toggles class nomes - // sends dim-what and id# - ajaxDimmer: function( what, id, dimClass ) { - ajaxDim = new WPAjax( this.ajaxHandler, this.ajaxRespEl ); - if ( ajaxDim.notInitialized() ) - return true; - var tempObj = this; - var action = 'dim-' + what; - var actionId = action + '&id=' + id; - var idName = what + '-' + id; - ajaxDim.addOnComplete( function(transport) { - Element.update(ajaxDim.myResponseElement,''); - tempObj.destore(actionId); - if ( tempObj.dimComplete && typeof tempObj.dimComplete == 'function' ) - tempObj.dimComplete( what, id, dimClass, transport ); - }); - ajaxDim.addOnWPError( function(transport) { tempObj.restore(actionId, true); }); - ajaxDim.options.parameters = $H(ajaxDim.options.parameters).merge({action: action, id: id}).merge(this.inputData.toQueryParams()); - ajaxDim.request(ajaxDim.url); - this.store(actionId, idName); - this.dimItem( idName, dimClass ); - return false; - }, - - addListItem: function( h ) { - new Insertion[this.topAdder ? 'Top' : 'Bottom'](this.theList,h); - Element.cleanWhitespace(this.theList); - var id = this.topAdder ? this.theList.firstChild.id : this.theList.lastChild.id; - if ( this.alt ) - if ( ( this.theList.childNodes.length + this.altOffset ) % 2 ) - Element.addClassName($(id),this.alt); - Fat.fade_element(id); - }, - - // only hides the element sa it can be put back again if necessary - removeListItem: function( id, noFade ) { - id = $(id); - if ( !noFade ) { - Fat.fade_element(id.id,null,700,'#FF3333'); - var tempObj = this; - var func = function() { id.hide(); tempObj.recolorList(); } - setTimeout(func, 705); - } else { - id.hide(); - this.recolorList(); - } - }, - - replaceListItem: function( id, h, update ) { - id = $(id); - if ( !update ) { - Element.remove(id); - this.addListItem( h ); - return; - } - id.replace(h); - Fat.fade_element(id.id); - }, - - // toggles class - dimItem: function( id, dimClass, noFade ) { - id = $(id); - if ( Element.hasClassName(id,dimClass) ) { - if ( !noFade ) - Fat.fade_element(id.id,null,700,null); - Element.removeClassName(id,dimClass); - } else { - if ( !noFade ) - Fat.fade_element(id.id,null,700,'#FF3333'); - Element.addClassName(id,dimClass); - } - }, - - // store an element in case we need it later - store: function(action, id) { - if ( !this.dataStore ) - this.dataStore = $H(); - this.dataStore[action] = $(id).cloneNode(true); - }, - - // delete from store - destore: function(action) { delete(this.dataStore[action]); }, - - // restore element from store into existing (possibly hidden) element of same id - restore: function(action, error) { - var id = this.dataStore[action].id; - this.theList.replaceChild(this.dataStore[action], $(id)); - delete(this.dataStore[action]); - if ( error ) { - func = function() { Element.setStyle($(id),{backgroundColor:'#FF3333'}); } - func(); setTimeout(func, 705); // Hit it twice in case it's still fading. - } - }, - - // Like Form.serialize, but excludes action and sets up clearInputs - grabInputs: function( where, ajaxObj ) { - if ( ajaxObj ) - ajaxObj.restoreInputs = []; - var elements = Form.getElements($(where)); - var queryComponents = new Array(); - for (var i = 0; i < elements.length; i++) { - if ( 'action' == elements[i].name ) - continue; - if ( 'hidden' != elements[i].type && 'submit' != elements[i].type && 'button' != elements[i].type ) { - this.clearInputs.push(elements[i]); - if ( ajaxObj ) - ajaxObj.restoreInputs.push([elements[i], elements[i].value]); - } - var queryComponent = Form.Element.serialize(elements[i]); - if (queryComponent) { - queryComponents.push(queryComponent); - } - } - return queryComponents.join('&'); - }, - - // form.reset() can only do whole forms. This can do subsections. - clear: function() { - this.clearInputs.each( function(i) { - i = $(i); - if ( 'textarea' == i.tagName.toLowerCase() ) - i.value = ''; - else - switch ( i.type.toLowerCase() ) { - case 'password': case 'text': - i.value = ''; - break; - case 'checkbox': case 'radio': - i.checked = false; - break; - case 'select': case 'select-one': - i.selectedIndex = null; - break; - case 'select-multiple': - for (var o = 0; o < i.length; o++) i.options[o].selected = false; - break; - } - }); - this.clearInputs = []; - }, - - restoreForm: function(elements) { - elements.each( function(i) { - i[0].value = i[1]; - }); - }, - - recolorList: function() { - if ( !this.alt ) - return; - var alt = this.alt; - var offset = this.altOffset; - var listItems = $A(this.theList.childNodes).findAll( function(i) { return Element.visible(i) } ); - listItems.each( function(i,n) { - if ( ( n + offset ) % 2 ) - Element.removeClassName(i,alt); - else - Element.addClassName(i,alt); - }); - } -}); - -//No submit unless code returns true. -function killSubmit ( code, e ) { - e = e ? e : window.event; - if ( !e ) return; - var t = e.target ? e.target : e.srcElement; - if ( ( 'text' == t.type && e.keyCode == 13 ) || ( 'submit' == t.type && 'click' == e.type ) ) { - if ( ( 'string' == typeof code && !eval(code) ) || ( 'function' == typeof code && !code() ) ) { - e.returnValue = false; e.cancelBubble = true; return false; - } - } -} -//Generic but lame JS closure -function encloseFunc(f){var a=arguments[1];return function(){return f(a);}} diff --git a/wp-includes/js/swfupload/handlers.js b/wp-includes/js/swfupload/handlers.js new file mode 100644 index 0000000..c53edf1 --- /dev/null +++ b/wp-includes/js/swfupload/handlers.js @@ -0,0 +1,227 @@ +function uploadLoaded() { + jQuery("#html-upload-ui").remove(); + jQuery("#flash-upload-ui").show(); +} + +function fileDialogStart() { + jQuery("#media-upload-error").empty(); +} + +// progress and success handlers for media multi uploads +function fileQueued(fileObj) { + // Get rid of unused form + jQuery('.media-blank').remove(); + // Collapse a single item + if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) { + jQuery('.toggle').toggle(); + jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden'); + } + // Create a progress bar containing the filename + jQuery('#media-items').append('
    ' + fileObj.name + '
    '); + + // Disable the submit button + jQuery('#insert-gallery').attr('disabled', 'disabled'); +} + +function uploadStart(fileObj) { return true; } + +function uploadProgress(fileObj, bytesDone, bytesTotal) { + // Lengthen the progress bar + jQuery('#media-item-' + fileObj.id + ' .bar').width(620*bytesDone/bytesTotal); + + if ( bytesDone== bytesTotal ) + jQuery('#media-item-' + fileObj.id + ' .bar').html('' + swfuploadL10n.crunching + ''); +} + +function prepareMediaItem(fileObj, serverData) { + // Move the progress bar to 100% + jQuery('#media-item-' + fileObj.id + ' .bar').remove(); + + // Append the HTML returned by the server -- thumbnail and form inputs + jQuery('#media-item-' + fileObj.id).append(serverData); + + // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename + jQuery('#media-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail toggle').prependTo('#media-item-' + fileObj.id); + + // Replace the original filename with the new (unique) one assigned during upload + jQuery('#media-item-' + fileObj.id + ' .filename.original').replaceWith(jQuery('#media-item-' + fileObj.id + ' .filename.new')); + + // Bind toggle function to a new mask over the progress bar area + jQuery('#media-item-' + fileObj.id + ' .progress').clone().empty().addClass('clickmask').bind('click', function(){jQuery(this).siblings('.slidetoggle').slideToggle(150);jQuery(this).siblings('.toggle').toggle();}).appendTo('#media-item-' + fileObj.id); + + // Also bind toggle to the links + jQuery('#media-item-' + fileObj.id + ' a.toggle').bind('click', function(){jQuery(this).siblings('.slidetoggle').slideToggle(150);jQuery(this).parent().eq(0).children('.toggle').toggle();jQuery(this).siblings('a.toggle').focus();return false;}); + + // Bind AJAX to the new Delete button + jQuery('#media-item-' + fileObj.id + ' a.delete').bind('click',function(){ + // Tell the server to delete it. TODO: handle exceptions + jQuery.ajax({url:'admin-ajax.php',type:'post',success:deleteSuccess,error:deleteError,id:fileObj.id,data:{ + id : this.id.replace(/[^0-9]/g,''), + action : 'delete-post', + _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')} + }); + return false; + }); + + // Open this item if it says to start open (e.g. to display an error) + jQuery('#media-item-' + fileObj.id + '.startopen') + .removeClass('startopen') + .slideToggle(500) + .parent().eq(0).children('.toggle').toggle(); +} + +function itemAjaxError(id, html) { + var error = jQuery('#media-item-error' + id); + + error.html('
    '+html+'
    '); + jQuery('#dismiss-'+id).click(function(){jQuery(this).parents('.file-error').slideUp(200, function(){jQuery(this).empty();})}); +} + +function deleteSuccess(data, textStatus) { + if ( data == '-1' ) + return itemAjaxError(this.id, 'You do not have permission. Has your session expired?'); + if ( data == '0' ) + return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?'); + + var item = jQuery('#media-item-' + this.id); + + // Decrement the counters. + if ( type = jQuery('#type-of-' + this.id).val() ) + jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-1); + if ( item.hasClass('child-of-'+post_id) ) + jQuery('#attachments-count').text(jQuery('#attachments-count').text()-1); + + if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) { + jQuery('.toggle').toggle(); + jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden'); + } + + jQuery('#media-item-' + this.id + ' .filename:empty').remove(); + jQuery('#media-item-' + this.id + ' .filename').append(' '+swfuploadL10n.deleted+'').siblings('a.toggle').remove(); + jQuery('#media-item-' + this.id + ' .describe').slideUp(500, function(){jQuery(this).parents('.media-item').slideUp(1500,function(){jQuery(this).remove();updateMediaForm();})}).end.remove(); + + return; + // Vanish it. + item.slideToggle(300,function(){jQuery(this).remove();if(jQuery('.media-item').length==0)jQuery('.insert-gallery').hide();updateMediaForm();}); +} + +function deleteError(X, textStatus, errorThrown) { + // TODO +} + +function updateMediaForm() { + // Just one file, no need for collapsible part + if ( jQuery('.type-form #media-items>*').length == 1 ) { + jQuery('#media-items .slidetoggle').slideDown(500).parent().eq(0).children('.toggle').toggle(); + jQuery('.type-form .slidetoggle').siblings().addClass('hidden'); + } + + // Only show Save buttons when there is at least one file. + if ( jQuery('#media-items>*').not('.media-blank').length > 0 ) + jQuery('.savebutton').show(); + else + jQuery('.savebutton').hide(); + + // Only show Gallery button when there are at least two files. + if ( jQuery('#media-items>*').length > 1 ) + jQuery('.insert-gallery').show(); + else + jQuery('.insert-gallery').hide(); +} + +function uploadSuccess(fileObj, serverData) { + // if async-upload returned an error message, place it in the media item div and return + if ( serverData.match('media-upload-error') ) { + jQuery('#media-item-' + fileObj.id).html(serverData); + return; + } + + prepareMediaItem(fileObj, serverData); + updateMediaForm(); + + // Increment the counter. + if ( jQuery('#media-item-' + fileObj.id).hasClass('child-of-' + post_id) ) + jQuery('#attachments-count').text(1 * jQuery('#attachments-count').text() + 1); +} + +function uploadComplete(fileObj) { + // If no more uploads queued, enable the submit button + if ( swfu.getStats().files_queued == 0 ) + jQuery('#insert-gallery').attr('disabled', ''); +} + + +// wp-specific error handlers + +// generic message +function wpQueueError(message) { + jQuery('#media-upload-error').show().text(message); +} + +// file-specific message +function wpFileError(fileObj, message) { + jQuery('#media-item-' + fileObj.id + ' .filename').after('
    '+message+'
    ').siblings('.toggle').remove(); + jQuery('#dismiss-' + fileObj.id).click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})}); +} + +function fileQueueError(fileObj, error_code, message) { + // Handle this error separately because we don't want to create a FileProgress element for it. + if ( error_code == SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED ) { + wpQueueError(swfuploadL10n.queue_limit_exceeded); + } + else if ( error_code == SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT ) { + fileQueued(fileObj); + wpFileError(fileObj, swfuploadL10n.file_exceeds_size_limit); + } + else if ( error_code == SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE ) { + fileQueued(fileObj); + wpFileError(fileObj, swfuploadL10n.zero_byte_file); + } + else if ( error_code == SWFUpload.QUEUE_ERROR.INVALID_FILETYPE ) { + fileQueued(fileObj); + wpFileError(fileObj, swfuploadL10n.invalid_filetype); + } + else { + wpQueueError(swfuploadL10n.default_error); + } +} + +function fileDialogComplete(num_files_queued) { + try { + if (num_files_queued > 0) { + this.startUpload(); + } + } catch (ex) { + this.debug(ex); + } +} + +function uploadError(fileObj, error_code, message) { + // first the file specific error + if ( error_code == SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL ) { + wpFileError(fileObj, swfuploadL10n.missing_upload_url); + } + else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED ) { + wpFileError(fileObj, swfuploadL10n.upload_limit_exceeded); + } + else { + wpFileError(fileObj, swfuploadL10n.default_error); + } + + // now the general upload status + if ( error_code == SWFUpload.UPLOAD_ERROR.HTTP_ERROR ) { + wpQueueError(swfuploadL10n.http_error); + } + else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED ) { + wpQueueError(swfuploadL10n.upload_failed); + } + else if ( error_code == SWFUpload.UPLOAD_ERROR.IO_ERROR ) { + wpQueueError(swfuploadL10n.io_error); + } + else if ( error_code == SWFUpload.UPLOAD_ERROR.SECURITY_ERROR ) { + wpQueueError(swfuploadL10n.security_error); + } + else if ( error_code == SWFUpload.UPLOAD_ERROR.FILE_CANCELLED ) { + wpQueueError(swfuploadL10n.security_error); + } +} diff --git a/wp-includes/js/swfupload/plugins/swfupload.cookies.js b/wp-includes/js/swfupload/plugins/swfupload.cookies.js new file mode 100644 index 0000000..4d41612 --- /dev/null +++ b/wp-includes/js/swfupload/plugins/swfupload.cookies.js @@ -0,0 +1,50 @@ +/* + Cookie Plug-in + + This plug in automatically gets all the cookies for this site and adds them to the post_params. + Cookies are loaded only on initialization. The refreshCookies function can be called to update the post_params. + The cookies will override any other post params with the same name. +*/ + +var SWFUpload; +if (typeof(SWFUpload) === "function") { + SWFUpload.prototype.initSettings = function (old_initSettings) { + return function (init_settings) { + if (typeof(old_initSettings) === "function") { + old_initSettings.call(this, init_settings); + } + + this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point + }; + }(SWFUpload.prototype.initSettings); + + // refreshes the post_params and updates SWFUpload. The send_to_flash parameters is optional and defaults to True + SWFUpload.prototype.refreshCookies = function (send_to_flash) { + if (send_to_flash !== false) send_to_flash = true; + + // Get the post_params object + var post_params = this.getSetting("post_params"); + + // Get the cookies + var i, cookie_array = document.cookie.split(';'), ca_length = cookie_array.length, c, eq_index, name, value; + for(i = 0; i < ca_length; i++) { + c = cookie_array[i]; + + // Left Trim spaces + while (c.charAt(0) == " ") { + c = c.substring(1, c.length); + } + eq_index = c.indexOf("="); + if (eq_index > 0) { + name = c.substring(0, eq_index); + value = c.substring(eq_index+1); + post_params[name] = value; + } + } + + if (send_to_flash) { + this.setPostParams(post_params); + } + }; + +} diff --git a/wp-includes/js/swfupload/plugins/swfupload.documentready.js b/wp-includes/js/swfupload/plugins/swfupload.documentready.js new file mode 100644 index 0000000..a95bac5 --- /dev/null +++ b/wp-includes/js/swfupload/plugins/swfupload.documentready.js @@ -0,0 +1,102 @@ +/* + DocumentReady Plug-in + + This plugin loads SWFUpload as soon as the document is ready. You should not load SWFUpload inside window.onload using this plugin. + You can also chain other functions by calling SWFUpload.DocumentReady(your function). + + Warning: Embedded Ads or other scripts that overwrite window.onload or use their own document ready functions may interfer with this plugin. You + should not set window.onload when using this plugin. + + Usage Example: + + var swfu = new SWFUpload(your settings object); + SWFUpload.DocumentReady(function () { alert('Document Ready!'; }); + +*/ + +var SWFUpload; +if (typeof(SWFUpload) === "function") { + // Override iniSWFUpload so SWFUpload gets inited when the document is ready rather than immediately + SWFUpload.prototype.initSWFUpload = function (old_initSWFUpload) { + return function (init_settings) { + var self = this; + if (typeof(old_initSWFUpload) === "function") { + SWFUpload.DocumentReady(function () { + old_initSWFUpload.call(self, init_settings); + }); + } + } + + }(SWFUpload.prototype.initSWFUpload); + + + // The DocumentReady function adds the passed in function to + // the functions that will be executed when the document is ready/loaded + SWFUpload.DocumentReady = function (fn) { + // Add the function to the chain + SWFUpload.DocumentReady.InternalOnloadChain = function (previous_link_fn) { + return function () { + if (typeof(previous_link_fn) === "function") { + previous_link_fn(); + } + fn(); + }; + }(SWFUpload.DocumentReady.InternalOnloadChain); + }; + SWFUpload.DocumentReady.InternalOnloadChain = null; + SWFUpload.DocumentReady.Onload = function () { + // Execute the onload function chain + if (typeof(SWFUpload.DocumentReady.InternalOnloadChain) === "function") { + SWFUpload.DocumentReady.InternalOnloadChain(); + } + }; + SWFUpload.DocumentReady.SetupComplete = false; + + + /* ******************************************** + This portion of the code gets executed as soon it is loaded. + It binds the proper event for executing JavaScript is + early as possible. This is a per browser function and so + some browser sniffing is used. + + This solution still has the "exposed" issue (See the Global Delegation section at http://peter.michaux.ca/article/553 ) + + Base solution from http://dean.edwards.name/weblog/2006/06/again/ and http://dean.edwards.name/weblog/2005/09/busted/ + ******************************************** */ + if (!SWFUpload.DocumentReady.SetupComplete) { + // for Internet Explorer (using conditional comments) + /*@cc_on @*/ + /*@if (@_win32) + document.write(" + + + + +
    + +
    + + + + + diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css b/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css deleted file mode 100644 index 43be823..0000000 --- a/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css +++ /dev/null @@ -1,69 +0,0 @@ -/* Window classes */ - -.mceWindow { - position: absolute; - left: 0; - top: 0; - border: 1px solid black; - background-color: #D4D0C8; -} - -.mceWindowHead { - background-color: #334F8D; - width: 100%; - height: 18px; - cursor: move; - overflow: hidden; -} - -.mceWindowBody { - clear: both; - background-color: white; -} - -.mceWindowStatusbar { - background-color: #D4D0C8; - height: 12px; - border-top: 1px solid black; -} - -.mceWindowTitle { - float: left; - font-family: "MS Sans Serif"; - font-size: 9pt; - font-weight: bold; - line-height: 18px; - color: white; - margin-left: 2px; - overflow: hidden; -} - -.mceWindowHeadTools { - margin-right: 2px; -} - -.mceWindowClose, .mceWindowMinimize, .mceWindowMaximize { - display: block; - float: right; - overflow: hidden; - margin-top: 2px; -} - -.mceWindowClose { - margin-left: 2px; -} - -.mceWindowMinimize { -} - -.mceWindowMaximize { -} - -.mceWindowResize { - display: block; - float: right; - overflow: hidden; - cursor: se-resize; - width: 12px; - height: 12px; -} diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/spacer.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/spacer.gif deleted file mode 100644 index fc25609..0000000 Binary files a/wp-includes/js/tinymce/plugins/inlinepopups/images/spacer.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_close.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/window_close.gif deleted file mode 100644 index 3469e5a..0000000 Binary files a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_close.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_maximize.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/window_maximize.gif deleted file mode 100644 index fcae73e..0000000 Binary files a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_maximize.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_minimize.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/window_minimize.gif deleted file mode 100644 index 94f167a..0000000 Binary files a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_minimize.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_resize.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/window_resize.gif deleted file mode 100644 index 6c402d0..0000000 Binary files a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_resize.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js b/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js deleted file mode 100644 index 325d293..0000000 --- a/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js +++ /dev/null @@ -1,453 +0,0 @@ -/** - * $Id: mcwindows.js 18 2006-06-29 14:11:23Z spocke $ - * - * Moxiecode DHTML Windows script. - * - * @author Moxiecode - * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved. - */ - -// Windows handler -function MCWindows() { - this.settings = new Array(); - this.windows = new Array(); - this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); - this.isGecko = navigator.userAgent.indexOf('Gecko') != -1; - this.isSafari = navigator.userAgent.indexOf('Safari') != -1; - this.isMac = navigator.userAgent.indexOf('Mac') != -1; - this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1); - this.action = "none"; - this.selectedWindow = null; - this.zindex = 100; - this.mouseDownScreenX = 0; - this.mouseDownScreenY = 0; - this.mouseDownLayerX = 0; - this.mouseDownLayerY = 0; - this.mouseDownWidth = 0; - this.mouseDownHeight = 0; -}; - -MCWindows.prototype.init = function(settings) { - this.settings = settings; - - if (this.isMSIE) - this.addEvent(document, "mousemove", mcWindows.eventDispatcher); - else - this.addEvent(window, "mousemove", mcWindows.eventDispatcher); - - this.addEvent(document, "mouseup", mcWindows.eventDispatcher); -}; - -MCWindows.prototype.getParam = function(name, default_value) { - var value = null; - - value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name]; - - // Fix bool values - if (value == "true" || value == "false") - return (value == "true"); - - return value; -}; - -MCWindows.prototype.eventDispatcher = function(e) { - e = typeof(e) == "undefined" ? window.event : e; - - if (mcWindows.selectedWindow == null) - return; - - // Switch focus - if (mcWindows.isGecko && e.type == "mousedown") { - var elm = e.currentTarget; - - for (var n in mcWindows.windows) { - var win = mcWindows.windows[n]; - if (typeof(win) == 'function') - continue; - - if (win.headElement == elm || win.resizeElement == elm) { - win.focus(); - break; - } - } - } - - switch (e.type) { - case "mousemove": - mcWindows.selectedWindow.onMouseMove(e); - break; - - case "mouseup": - mcWindows.selectedWindow.onMouseUp(e); - break; - - case "mousedown": - mcWindows.selectedWindow.onMouseDown(e); - break; - - case "focus": - mcWindows.selectedWindow.onFocus(e); - break; - } -} - -MCWindows.prototype.addEvent = function(obj, name, handler) { - if (this.isMSIE) - obj.attachEvent("on" + name, handler); - else - obj.addEventListener(name, handler, true); -}; - -MCWindows.prototype.cancelEvent = function(e) { - if (this.isMSIE) { - e.returnValue = false; - e.cancelBubble = true; - } else - e.preventDefault(); -}; - -MCWindows.prototype.parseFeatures = function(opts) { - // Cleanup the options - opts = opts.toLowerCase(); - opts = opts.replace(/;/g, ","); - opts = opts.replace(/[^0-9a-z=,]/g, ""); - - var optionChunks = opts.split(','); - var options = new Array(); - - options['left'] = 10; - options['top'] = 10; - options['width'] = 300; - options['height'] = 300; - options['resizable'] = true; - options['minimizable'] = true; - options['maximizable'] = true; - options['close'] = true; - options['movable'] = true; - - if (opts == "") - return options; - - for (var i=0; i'; - - html += '
    '; - html += '
    '; - html += '
    '; -// html += ' '; -// html += ' '; - html += '
    '; - html += '
    '; - html += '
    '; - html += '
    '; - html += '
    '; - html += '
    '; - html += '
    '; - - html += ''; - html += ''; - - // Create iframe - this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html); -}; - -// Gets called when wrapper iframe is initialized -MCWindows.prototype.onLoad = function(name) { - var win = mcWindows.windows[name]; - var id = "mcWindow_" + name; - var wrapperIframe = window.frames[id + "_iframe"].frames[0]; - var wrapperDoc = window.frames[id + "_iframe"].document; - var doc = window.frames[id + "_iframe"].document; - var winDiv = document.getElementById("mcWindow_" + name + "_div"); - var realIframe = window.frames[id + "_iframe"].frames[0]; - - // Set window data - win.id = "mcWindow_" + name + "_iframe"; - win.winElement = winDiv; - win.bodyElement = doc.getElementById(id + '_body'); - win.iframeElement = doc.getElementById(id + '_iframe'); - win.headElement = doc.getElementById(id + '_head'); - win.titleElement = doc.getElementById(id + '_title'); - win.resizeElement = doc.getElementById(id + '_resize'); - win.containerElement = doc.getElementById(id + '_container'); - win.left = win.features['left']; - win.top = win.features['top']; - win.frame = window.frames[id + '_iframe'].frames[0]; - win.wrapperFrame = window.frames[id + '_iframe']; - win.wrapperIFrameElement = document.getElementById(id + "_iframe"); - - // Add event handlers - mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher); - mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher); - - if (mcWindows.isMSIE) { - mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher); - mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher); - } else { - mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher); - mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher); - mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher); - } - - for (var i=0; i --> + + +Template for dialogs + + + + +
    +
    +
    +
    +
    +
    +
    + Blured +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Focused +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Statusbar +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Statusbar, Resizable +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Resizable, Maximizable +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Blurred, Maximizable, Statusbar, Resizable +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Maximized, Maximizable, Minimizable +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Blured +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Alert +
    + +
    +
    + + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + +
    +
    +
    + +
    +
    +
    +
    +
    + + + Ok + +
    +
    + +
    +
    +
    +
    +
    +
    + Confirm +
    + +
    +
    + + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + +
    +
    +
    + +
    +
    +
    +
    +
    + + + Ok + Cancel + +
    +
    +
    + + + diff --git a/wp-includes/js/tinymce/plugins/media/css/content.css b/wp-includes/js/tinymce/plugins/media/css/content.css new file mode 100644 index 0000000..7739381 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/media/css/content.css @@ -0,0 +1,6 @@ +.mceItemFlash, .mceItemShockWave, .mceItemQuickTime, .mceItemWindowsMedia, .mceItemRealMedia {border:1px dotted #cc0000; background-position:center; background-repeat:no-repeat; background-color:#ffffcc;} +.mceItemShockWave {background-image: url(../img/shockwave.gif);} +.mceItemFlash {background-image:url(../img/flash.gif);} +.mceItemQuickTime {background-image:url(../img/quicktime.gif);} +.mceItemWindowsMedia {background-image:url(../img/windowsmedia.gif);} +.mceItemRealMedia {background-image:url(../img/realmedia.gif);} diff --git a/wp-includes/js/tinymce/plugins/media/css/media.css b/wp-includes/js/tinymce/plugins/media/css/media.css new file mode 100644 index 0000000..62d666a --- /dev/null +++ b/wp-includes/js/tinymce/plugins/media/css/media.css @@ -0,0 +1,68 @@ +#id, #name, #hspace, #vspace, #class_name, #align { + width: 100px; +} + +#hspace, #vspace { + width: 50px; +} + +#flash_quality, #flash_align, #flash_scale, #flash_salign, #flash_wmode { + width: 100px; +} + +#flash_base, #flash_flashvars { + width: 240px; +} + +#width, #height { + width: 40px; +} + +#src, #media_type { + width: 250px; +} + +#class { + width: 120px; +} + +#prev { + margin: 0; + border: 1px solid black; + width: 99%; + height: 230px; + overflow: auto; +} + +.panel_wrapper div.current { + height: 390px; + overflow: auto; +} + +#flash_options, #shockwave_options, #qt_options, #wmp_options, #rmp_options { + display: none; +} + +.mceAddSelectValue { + background-color: #DDDDDD; +} + +#qt_starttime, #qt_endtime, #qt_fov, #qt_href, #qt_moveid, #qt_moviename, #qt_node, #qt_pan, #qt_qtsrc, #qt_qtsrcchokespeed, #qt_target, #qt_tilt, #qt_urlsubstituten, #qt_volume { + width: 70px; +} + +#wmp_balance, #wmp_baseurl, #wmp_captioningid, #wmp_currentmarker, #wmp_currentposition, #wmp_defaultframe, #wmp_playcount, #wmp_rate, #wmp_uimode, #wmp_volume { + width: 70px; +} + +#rmp_console, #rmp_numloop, #rmp_controls, #rmp_scriptcallbacks { + width: 70px; +} + +#shockwave_swvolume, #shockwave_swframe, #shockwave_swurl, #shockwave_swstretchvalign, #shockwave_swstretchhalign, #shockwave_swstretchstyle { + width: 90px; +} + +#qt_qtsrc { + width: 200px; +} diff --git a/wp-includes/js/tinymce/plugins/media/editor_plugin.js b/wp-includes/js/tinymce/plugins/media/editor_plugin.js new file mode 100644 index 0000000..948db7c --- /dev/null +++ b/wp-includes/js/tinymce/plugins/media/editor_plugin.js @@ -0,0 +1 @@ +(function(){var each=tinymce.each;tinymce.create('tinymce.plugins.MediaPlugin',{init:function(ed,url){var t=this;t.editor=ed;t.url=url;function isMediaElm(n){return/^(mceItemFlash|mceItemShockWave|mceItemWindowsMedia|mceItemQuickTime|mceItemRealMedia)$/.test(n.className);};ed.addCommand('mceMedia',function(){ed.windowManager.open({file:url+'/media.htm',width:430+parseInt(ed.getLang('media.delta_width',0)),height:470+parseInt(ed.getLang('media.delta_height',0)),inline:1},{plugin_url:url});});ed.addButton('media',{title:'media.desc',cmd:'mceMedia'});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('media',n.nodeName=='IMG'&&isMediaElm(n));});ed.onInit.add(function(){var lo={mceItemFlash:'flash',mceItemShockWave:'shockwave',mceItemWindowsMedia:'windowsmedia',mceItemQuickTime:'quicktime',mceItemRealMedia:'realmedia'};ed.dom.loadCSS(url+"/css/content.css");if(ed.theme.onResolveName){ed.theme.onResolveName.add(function(th,o){if(o.name=='img'){each(lo,function(v,k){if(ed.dom.hasClass(o.node,k)){o.name=v;o.title=ed.dom.getAttrib(o.node,'title');return false;}});}});}if(ed&&ed.plugins.contextmenu){ed.plugins.contextmenu.onContextMenu.add(function(th,m,e){if(e.nodeName=='IMG'&&/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(e.className)){m.add({title:'media.edit',icon:'media',cmd:'mceMedia'});}});}});ed.onBeforeSetContent.add(function(ed,o){var h=o.content;h=h.replace(/]*>\s*write(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)\(\{([^\)]*)\}\);\s*<\/script>/gi,function(a,b,c){var o=t._parse(c);return''});h=h.replace(/]*)>/gi,'');h=h.replace(/]*)>/gi,'');h=h.replace(/<\/(object|embed)([^>]*)>/gi,'');h=h.replace(/]*)>/gi,function(a,b){return''});h=h.replace(/\/ class=\"mceItemParam\"><\/span>/gi,'class="mceItemParam">');o.content=h;});ed.onSetContent.add(function(){t._spansToImgs(ed.getBody());});ed.onPreProcess.add(function(ed,o){var dom=ed.dom;if(o.set){t._spansToImgs(o.node);each(dom.select('IMG',o.node),function(n){var p;if(isMediaElm(n)){p=t._parse(n.title);dom.setAttrib(n,'width',dom.getAttrib(n,'width',p.width||100));dom.setAttrib(n,'height',dom.getAttrib(n,'height',p.height||100));}});}if(o.get){each(dom.select('IMG',o.node),function(n){var ci,cb,mt;if(ed.getParam('media_use_script')){if(isMediaElm(n))n.className=n.className.replace(/mceItem/g,'mceTemp');return;}switch(n.className){case'mceItemFlash':ci='d27cdb6e-ae6d-11cf-96b8-444553540000';cb='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';mt='application/x-shockwave-flash';break;case'mceItemShockWave':ci='166b1bca-3f9c-11cf-8075-444553540000';cb='http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0';mt='application/x-director';break;case'mceItemWindowsMedia':ci=ed.getParam('media_wmp6_compatible')?'05589fa1-c356-11ce-bf01-00aa0055595a':'6bf52a52-394a-11d3-b153-00c04f79faa6';cb='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';mt='application/x-mplayer2';break;case'mceItemQuickTime':ci='02bf25d5-8c17-4b23-bc80-d3488abddc6b';cb='http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0';mt='video/quicktime';break;case'mceItemRealMedia':ci='cfcdaa03-8be4-11cf-b84b-0020afbbccfa';cb='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';mt='audio/x-pn-realaudio-plugin';break;}if(ci){dom.replace(t._buildObj({classid:ci,codebase:cb,type:mt},n),n);}});}});ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/_value=/g,'value=');});if(ed.getParam('media_use_script')){function getAttr(s,n){n=new RegExp(n+'=\"([^\"]+)\"','g').exec(s);return n?ed.dom.decode(n[1]):'';};ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/]+>/g,function(im){var cl=getAttr(im,'class');if(/^(mceTempFlash|mceTempShockWave|mceTempWindowsMedia|mceTempQuickTime|mceTempRealMedia)$/.test(cl)){at=t._parse(getAttr(im,'title'));at.width=getAttr(im,'width');at.height=getAttr(im,'height');im='';}return im;});});}},getInfo:function(){return{longname:'Media',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/media',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_buildObj:function(o,n){var ob,ed=this.editor,dom=ed.dom,p=this._parse(n.title);p.width=o.width=dom.getAttrib(n,'width')||100;p.height=o.height=dom.getAttrib(n,'height')||100;ob=dom.create('span',{mce_name:'object',classid:"clsid:"+o.classid,codebase:o.codebase,width:o.width,height:o.height});if(p.src)p.src=ed.convertURL(p.src,'src',n);each(p,function(v,k){if(!/^(width|height|codebase|classid)$/.test(k))dom.add(ob,'span',{mce_name:'param',name:k,'_value':v});});dom.add(ob,'span',tinymce.extend({mce_name:'embed',type:o.type},p));return ob;},_spansToImgs:function(p){var t=this,dom=t.editor.dom,im,ci;each(dom.select('span',p),function(n){if(dom.getAttrib(n,'class')=='mceItemObject'){ci=dom.getAttrib(n,"classid").toLowerCase().replace(/\s+/g,'');switch(ci){case'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000':dom.replace(t._createImg('mceItemFlash',n),n);break;case'clsid:166b1bca-3f9c-11cf-8075-444553540000':dom.replace(t._createImg('mceItemShockWave',n),n);break;case'clsid:6bf52a52-394a-11d3-b153-00c04f79faa6':case'clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95':case'clsid:05589fa1-c356-11ce-bf01-00aa0055595a':dom.replace(t._createImg('mceItemWindowsMedia',n),n);break;case'clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b':dom.replace(t._createImg('mceItemQuickTime',n),n);break;case'clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa':dom.replace(t._createImg('mceItemRealMedia',n),n);break;default:dom.replace(t._createImg('mceItemFlash',n),n);}return;}if(dom.getAttrib(n,'class')=='mceItemEmbed'){switch(dom.getAttrib(n,'type')){case'application/x-shockwave-flash':dom.replace(t._createImg('mceItemFlash',n),n);break;case'application/x-director':dom.replace(t._createImg('mceItemShockWave',n),n);break;case'application/x-mplayer2':dom.replace(t._createImg('mceItemWindowsMedia',n),n);break;case'video/quicktime':dom.replace(t._createImg('mceItemQuickTime',n),n);break;case'audio/x-pn-realaudio-plugin':dom.replace(t._createImg('mceItemRealMedia',n),n);break;default:dom.replace(t._createImg('mceItemFlash',n),n);}}});},_createImg:function(cl,n){var im,dom=this.editor.dom,pa={},ti='';im=dom.create('img',{src:this.url+'/img/trans.gif',width:dom.getAttrib(n,'width')||100,height:dom.getAttrib(n,'height')||100,'class':cl});each(['id','name','width','height','bgcolor','align','flashvars','src','wmode'],function(na){var v=dom.getAttrib(n,na);if(v)pa[na]=v;});each(dom.select('span',n),function(n){if(dom.hasClass(n,'mceItemParam'))pa[dom.getAttrib(n,'name')]=dom.getAttrib(n,'_value');});if(pa.movie){pa.src=pa.movie;delete pa.movie;}delete pa.width;delete pa.height;im.title=this._serialize(pa);return im;},_parse:function(s){return tinymce.util.JSON.parse('{'+s+'}');},_serialize:function(o){return tinymce.util.JSON.serialize(o).replace(/[{}]/g,'');}});tinymce.PluginManager.add('media',tinymce.plugins.MediaPlugin);})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/media/img/flash.gif b/wp-includes/js/tinymce/plugins/media/img/flash.gif new file mode 100644 index 0000000..cb192e6 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/flash.gif differ diff --git a/wp-includes/js/tinymce/plugins/media/img/flv_player.swf b/wp-includes/js/tinymce/plugins/media/img/flv_player.swf new file mode 100644 index 0000000..042c2ab Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/flv_player.swf differ diff --git a/wp-includes/js/tinymce/plugins/media/img/quicktime.gif b/wp-includes/js/tinymce/plugins/media/img/quicktime.gif new file mode 100644 index 0000000..3b04991 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/quicktime.gif differ diff --git a/wp-includes/js/tinymce/plugins/media/img/realmedia.gif b/wp-includes/js/tinymce/plugins/media/img/realmedia.gif new file mode 100644 index 0000000..fdfe0b9 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/realmedia.gif differ diff --git a/wp-includes/js/tinymce/plugins/media/img/shockwave.gif b/wp-includes/js/tinymce/plugins/media/img/shockwave.gif new file mode 100644 index 0000000..5f235df Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/shockwave.gif differ diff --git a/wp-includes/js/tinymce/plugins/media/img/trans.gif b/wp-includes/js/tinymce/plugins/media/img/trans.gif new file mode 100644 index 0000000..3884865 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/trans.gif differ diff --git a/wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif b/wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif new file mode 100644 index 0000000..ab50f2d Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif differ diff --git a/wp-includes/js/tinymce/plugins/media/js/embed.js b/wp-includes/js/tinymce/plugins/media/js/embed.js new file mode 100644 index 0000000..6fe25de --- /dev/null +++ b/wp-includes/js/tinymce/plugins/media/js/embed.js @@ -0,0 +1,73 @@ +/** + * This script contains embed functions for common plugins. This scripts are complety free to use for any purpose. + */ + +function writeFlash(p) { + writeEmbed( + 'D27CDB6E-AE6D-11cf-96B8-444553540000', + 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0', + 'application/x-shockwave-flash', + p + ); +} + +function writeShockWave(p) { + writeEmbed( + '166B1BCA-3F9C-11CF-8075-444553540000', + 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0', + 'application/x-director', + p + ); +} + +function writeQuickTime(p) { + writeEmbed( + '02BF25D5-8C17-4B23-BC80-D3488ABDDC6B', + 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0', + 'video/quicktime', + p + ); +} + +function writeRealMedia(p) { + writeEmbed( + 'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA', + 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0', + 'audio/x-pn-realaudio-plugin', + p + ); +} + +function writeWindowsMedia(p) { + p.url = p.src; + writeEmbed( + '6BF52A52-394A-11D3-B153-00C04F79FAA6', + 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701', + 'application/x-mplayer2', + p + ); +} + +function writeEmbed(cls, cb, mt, p) { + var h = '', n; + + h += ''; + + h += ''); + +function init() { + var pl = "", f, val; + var type = "flash", fe, i; + + ed = tinyMCEPopup.editor; + + tinyMCEPopup.resizeToInnerSize(); + f = document.forms[0] + + fe = ed.selection.getNode(); + if (/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(ed.dom.getAttrib(fe, 'class'))) { + pl = fe.title; + + switch (ed.dom.getAttrib(fe, 'class')) { + case 'mceItemFlash': + type = 'flash'; + break; + + case 'mceItemFlashVideo': + type = 'flv'; + break; + + case 'mceItemShockWave': + type = 'shockwave'; + break; + + case 'mceItemWindowsMedia': + type = 'wmp'; + break; + + case 'mceItemQuickTime': + type = 'qt'; + break; + + case 'mceItemRealMedia': + type = 'rmp'; + break; + } + + document.forms[0].insert.value = ed.getLang('update', 'Insert', true); + } + + document.getElementById('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media'); + document.getElementById('qtsrcfilebrowsercontainer').innerHTML = getBrowserHTML('qtsrcfilebrowser','qt_qtsrc','media','media'); + document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor'); + + var html = getMediaListHTML('medialist','src','media','media'); + if (html == "") + document.getElementById("linklistrow").style.display = 'none'; + else + document.getElementById("linklistcontainer").innerHTML = html; + + // Resize some elements + if (isVisible('filebrowser')) + document.getElementById('src').style.width = '230px'; + + // Setup form + if (pl != "") { + pl = tinyMCEPopup.editor.plugins.media._parse(pl); + + switch (type) { + case "flash": + setBool(pl, 'flash', 'play'); + setBool(pl, 'flash', 'loop'); + setBool(pl, 'flash', 'menu'); + setBool(pl, 'flash', 'swliveconnect'); + setStr(pl, 'flash', 'quality'); + setStr(pl, 'flash', 'scale'); + setStr(pl, 'flash', 'salign'); + setStr(pl, 'flash', 'wmode'); + setStr(pl, 'flash', 'base'); + setStr(pl, 'flash', 'flashvars'); + break; + + case "qt": + setBool(pl, 'qt', 'loop'); + setBool(pl, 'qt', 'autoplay'); + setBool(pl, 'qt', 'cache'); + setBool(pl, 'qt', 'controller'); + setBool(pl, 'qt', 'correction'); + setBool(pl, 'qt', 'enablejavascript'); + setBool(pl, 'qt', 'kioskmode'); + setBool(pl, 'qt', 'autohref'); + setBool(pl, 'qt', 'playeveryframe'); + setBool(pl, 'qt', 'tarsetcache'); + setStr(pl, 'qt', 'scale'); + setStr(pl, 'qt', 'starttime'); + setStr(pl, 'qt', 'endtime'); + setStr(pl, 'qt', 'tarset'); + setStr(pl, 'qt', 'qtsrcchokespeed'); + setStr(pl, 'qt', 'volume'); + setStr(pl, 'qt', 'qtsrc'); + break; + + case "shockwave": + setBool(pl, 'shockwave', 'sound'); + setBool(pl, 'shockwave', 'progress'); + setBool(pl, 'shockwave', 'autostart'); + setBool(pl, 'shockwave', 'swliveconnect'); + setStr(pl, 'shockwave', 'swvolume'); + setStr(pl, 'shockwave', 'swstretchstyle'); + setStr(pl, 'shockwave', 'swstretchhalign'); + setStr(pl, 'shockwave', 'swstretchvalign'); + break; + + case "wmp": + setBool(pl, 'wmp', 'autostart'); + setBool(pl, 'wmp', 'enabled'); + setBool(pl, 'wmp', 'enablecontextmenu'); + setBool(pl, 'wmp', 'fullscreen'); + setBool(pl, 'wmp', 'invokeurls'); + setBool(pl, 'wmp', 'mute'); + setBool(pl, 'wmp', 'stretchtofit'); + setBool(pl, 'wmp', 'windowlessvideo'); + setStr(pl, 'wmp', 'balance'); + setStr(pl, 'wmp', 'baseurl'); + setStr(pl, 'wmp', 'captioningid'); + setStr(pl, 'wmp', 'currentmarker'); + setStr(pl, 'wmp', 'currentposition'); + setStr(pl, 'wmp', 'defaultframe'); + setStr(pl, 'wmp', 'playcount'); + setStr(pl, 'wmp', 'rate'); + setStr(pl, 'wmp', 'uimode'); + setStr(pl, 'wmp', 'volume'); + break; + + case "rmp": + setBool(pl, 'rmp', 'autostart'); + setBool(pl, 'rmp', 'loop'); + setBool(pl, 'rmp', 'autogotourl'); + setBool(pl, 'rmp', 'center'); + setBool(pl, 'rmp', 'imagestatus'); + setBool(pl, 'rmp', 'maintainaspect'); + setBool(pl, 'rmp', 'nojava'); + setBool(pl, 'rmp', 'prefetch'); + setBool(pl, 'rmp', 'shuffle'); + setStr(pl, 'rmp', 'console'); + setStr(pl, 'rmp', 'controls'); + setStr(pl, 'rmp', 'numloop'); + setStr(pl, 'rmp', 'scriptcallbacks'); + break; + } + + setStr(pl, null, 'src'); + setStr(pl, null, 'id'); + setStr(pl, null, 'name'); + setStr(pl, null, 'vspace'); + setStr(pl, null, 'hspace'); + setStr(pl, null, 'bgcolor'); + setStr(pl, null, 'align'); + setStr(pl, null, 'width'); + setStr(pl, null, 'height'); + + if ((val = ed.dom.getAttrib(fe, "width")) != "") + pl.width = f.width.value = val; + + if ((val = ed.dom.getAttrib(fe, "height")) != "") + pl.height = f.height.value = val; + + oldWidth = pl.width ? parseInt(pl.width) : 0; + oldHeight = pl.height ? parseInt(pl.height) : 0; + } else + oldWidth = oldHeight = 0; + + selectByValue(f, 'media_type', type); + changedType(type); + updateColor('bgcolor_pick', 'bgcolor'); + + TinyMCE_EditableSelects.init(); + generatePreview(); +} + +function insertMedia() { + var fe, f = document.forms[0], h; + + tinyMCEPopup.restoreSelection(); + + if (!AutoValidator.validate(f)) { + alert(ed.getLang('invalid_data')); + return false; + } + + f.width.value = f.width.value == "" ? 100 : f.width.value; + f.height.value = f.height.value == "" ? 100 : f.height.value; + + fe = ed.selection.getNode(); + if (fe != null && /mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(ed.dom.getAttrib(fe, 'class'))) { + switch (f.media_type.options[f.media_type.selectedIndex].value) { + case "flash": + fe.className = "mceItemFlash"; + break; + + case "flv": + fe.className = "mceItemFlashVideo"; + break; + + case "shockwave": + fe.className = "mceItemShockWave"; + break; + + case "qt": + fe.className = "mceItemQuickTime"; + break; + + case "wmp": + fe.className = "mceItemWindowsMedia"; + break; + + case "rmp": + fe.className = "mceItemRealMedia"; + break; + } + + if (fe.width != f.width.value || fe.height != f.height.height) + ed.execCommand('mceRepaint'); + + fe.title = serializeParameters(); + fe.width = f.width.value; + fe.height = f.height.value; + fe.style.width = f.width.value + (f.width.value.indexOf('%') == -1 ? 'px' : ''); + fe.style.height = f.height.value + (f.height.value.indexOf('%') == -1 ? 'px' : ''); + fe.align = f.align.options[f.align.selectedIndex].value; + } else { + h = ' 0) { + var html = ""; + + html += ''; + + return html; + } + + return ""; +} + +function getType(v) { + var fo, i, c, el, x, f = document.forms[0]; + + fo = ed.getParam("media_types", "flash=swf;flv=flv;shockwave=dcr;qt=mov,qt,mpg,mp3,mp4,mpeg;shockwave=dcr;wmp=avi,wmv,wm,asf,asx,wmx,wvx;rmp=rm,ra,ram").split(';'); + + // YouTube + if (v.match(/watch\?v=(.+)(.*)/)) { + f.width.value = '425'; + f.height.value = '350'; + f.src.value = 'http://www.youtube.com/v/' + v.match(/v=(.*)(.*)/)[0].split('=')[1]; + return 'flash'; + } + + // Google video + if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) { + f.width.value = '425'; + f.height.value = '326'; + f.src.value = 'http://video.google.com/googleplayer.swf?docId=' + v.substring('http://video.google.com/videoplay?docid='.length) + '&hl=en'; + return 'flash'; + } + + for (i=0; i 0 ? s.substring(0, s.length - 1) : s; + + return s; +} + +function setBool(pl, p, n) { + if (typeof(pl[n]) == "undefined") + return; + + document.forms[0].elements[p + "_" + n].checked = pl[n]; +} + +function setStr(pl, p, n) { + var f = document.forms[0], e = f.elements[(p != null ? p + "_" : '') + n]; + + if (typeof(pl[n]) == "undefined") + return; + + if (e.type == "text") + e.value = pl[n]; + else + selectByValue(f, (p != null ? p + "_" : '') + n, pl[n]); +} + +function getBool(p, n, d, tv, fv) { + var v = document.forms[0].elements[p + "_" + n].checked; + + tv = typeof(tv) == 'undefined' ? 'true' : "'" + jsEncode(tv) + "'"; + fv = typeof(fv) == 'undefined' ? 'false' : "'" + jsEncode(fv) + "'"; + + return (v == d) ? '' : n + (v ? ':' + tv + ',' : ':' + fv + ','); +} + +function getStr(p, n, d) { + var e = document.forms[0].elements[(p != null ? p + "_" : "") + n]; + var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value; + + if (n == 'src') + v = tinyMCEPopup.editor.convertURL(v, 'src', null); + + return ((n == d || v == '') ? '' : n + ":'" + jsEncode(v) + "',"); +} + +function getInt(p, n, d) { + var e = document.forms[0].elements[(p != null ? p + "_" : "") + n]; + var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value; + + return ((n == d || v == '') ? '' : n + ":" + v.replace(/[^0-9]+/g, '') + ","); +} + +function jsEncode(s) { + s = s.replace(new RegExp('\\\\', 'g'), '\\\\'); + s = s.replace(new RegExp('"', 'g'), '\\"'); + s = s.replace(new RegExp("'", 'g'), "\\'"); + + return s; +} + +function generatePreview(c) { + var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh; + + p.innerHTML = ''; + + nw = parseInt(f.width.value); + nh = parseInt(f.height.value); + + if (f.width.value != "" && f.height.value != "") { + if (f.constrain.checked) { + if (c == 'width' && oldWidth != 0) { + wp = nw / oldWidth; + nh = Math.round(wp * nh); + f.height.value = nh; + } else if (c == 'height' && oldHeight != 0) { + hp = nh / oldHeight; + nw = Math.round(hp * nw); + f.width.value = nw; + } + } + } + + if (f.width.value != "") + oldWidth = nw; + + if (f.height.value != "") + oldHeight = nh; + + // After constrain + pl = serializeParameters(); + + switch (f.media_type.options[f.media_type.selectedIndex].value) { + case "flash": + cls = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; + codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'; + type = 'application/x-shockwave-flash'; + break; + + case "shockwave": + cls = 'clsid:166B1BCA-3F9C-11CF-8075-444553540000'; + codebase = 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0'; + type = 'application/x-director'; + break; + + case "qt": + cls = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'; + codebase = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0'; + type = 'video/quicktime'; + break; + + case "wmp": + cls = ed.getParam('media_wmp6_compatible') ? 'clsid:05589FA1-C356-11CE-BF01-00AA0055595A' : 'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6'; + codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; + type = 'application/x-mplayer2'; + break; + + case "rmp": + cls = 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'; + codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; + type = 'audio/x-pn-realaudio-plugin'; + break; + } + + if (pl == '') { + p.innerHTML = ''; + return; + } + + pl = tinyMCEPopup.editor.plugins.media._parse(pl); + + if (!pl.src) { + p.innerHTML = ''; + return; + } + + pl.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(pl.src); + pl.width = !pl.width ? 100 : pl.width; + pl.height = !pl.height ? 100 : pl.height; + pl.id = !pl.id ? 'obj' : pl.id; + pl.name = !pl.name ? 'eobj' : pl.name; + pl.align = !pl.align ? '' : pl.align; + + h += ''; + + for (n in pl) { + h += ''; + + // Add extra url parameter if it's an absolute URL + if (n == 'src' && pl[n].indexOf('://') != -1) + h += ''; + } + + h += ' + + + {#media_dlg.title} + + + + + + + + + + +
    + + +
    +
    +
    + {#media_dlg.general} + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + +
     
    +
     
    + + + + + + +
    x   
    +
    +
    + +
    + {#media_dlg.preview} + +
    +
    + +
    +
    + {#media_dlg.advanced} + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + +
     
    +
    +
    + +
    + {#media_dlg.flash_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    + + + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + + + + + + + +
    +
    + +
    + {#media_dlg.flv_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    +
    + +
    + {#media_dlg.qt_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    +  
    + + + + + +
     
    +
    +
    + +
    + {#media_dlg.wmp_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    +
    + +
    + {#media_dlg.rmp_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    +   +
    +
    + +
    + {#media_dlg.shockwave_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    +
    +
    +
    + +
    +
    + +
    + +
    + +
    +
    +
    + + diff --git a/wp-includes/js/tinymce/plugins/paste/images/pastetext.gif b/wp-includes/js/tinymce/plugins/paste/images/pastetext.gif deleted file mode 100644 index e381cc6..0000000 Binary files a/wp-includes/js/tinymce/plugins/paste/images/pastetext.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/paste/images/pasteword.gif b/wp-includes/js/tinymce/plugins/paste/images/pasteword.gif deleted file mode 100644 index 0ccb008..0000000 Binary files a/wp-includes/js/tinymce/plugins/paste/images/pasteword.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/paste/images/selectall.gif b/wp-includes/js/tinymce/plugins/paste/images/selectall.gif deleted file mode 100644 index c4f9901..0000000 Binary files a/wp-includes/js/tinymce/plugins/paste/images/selectall.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/paste/js/pastetext.js b/wp-includes/js/tinymce/plugins/paste/js/pastetext.js new file mode 100644 index 0000000..2807387 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/paste/js/pastetext.js @@ -0,0 +1,42 @@ +tinyMCEPopup.requireLangPack(); + +function saveContent() { + if (document.forms[0].htmlSource.value == '') { + tinyMCEPopup.close(); + return false; + } + + tinyMCEPopup.execCommand('mcePasteText', false, { + html : document.forms[0].htmlSource.value, + linebreaks : document.forms[0].linebreaks.checked + }); + + tinyMCEPopup.close(); +} + +function onLoadInit() { + tinyMCEPopup.resizeToInnerSize(); + + // Remove Gecko spellchecking + if (tinymce.isGecko) + document.body.spellcheck = tinyMCEPopup.getParam("gecko_spellcheck"); + + resizeInputs(); +} + +var wHeight=0, wWidth=0, owHeight=0, owWidth=0; + +function resizeInputs() { + if (!tinymce.isIE) { + wHeight = self.innerHeight-80; + wWidth = self.innerWidth-17; + } else { + wHeight = document.body.clientHeight-80; + wWidth = document.body.clientWidth-17; + } + + document.forms[0].htmlSource.style.height = Math.abs(wHeight) + 'px'; + document.forms[0].htmlSource.style.width = Math.abs(wWidth) + 'px'; +} + +tinyMCEPopup.onInit.add(onLoadInit); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/paste/js/pasteword.js b/wp-includes/js/tinymce/plugins/paste/js/pasteword.js new file mode 100644 index 0000000..ea9c29c --- /dev/null +++ b/wp-includes/js/tinymce/plugins/paste/js/pasteword.js @@ -0,0 +1,56 @@ +tinyMCEPopup.requireLangPack(); + +function saveContent() { + var html = document.getElementById("frmData").contentWindow.document.body.innerHTML; + + if (html == ''){ + tinyMCEPopup.close(); + return false; + } + + tinyMCEPopup.execCommand('mcePasteWord', false, html); + tinyMCEPopup.close(); +} + +function onLoadInit() { + tinyMCEPopup.resizeToInnerSize(); + + // Fix for endless reloading in FF + window.setTimeout(createIFrame, 10); +} + +function createIFrame() { + document.getElementById('iframecontainer').innerHTML = ''; +} + +var wHeight=0, wWidth=0, owHeight=0, owWidth=0; + +function initIframe(doc) { + var dir = tinyMCEPopup.editor.settings.directionality; + + doc.body.dir = dir; + + // Remove Gecko spellchecking + if (tinymce.isGecko) + doc.body.spellcheck = tinyMCEPopup.getParam("gecko_spellcheck"); + + resizeInputs(); +} + +function resizeInputs() { + if (!tinymce.isIE) { + wHeight = self.innerHeight - 80; + wWidth = self.innerWidth - 18; + } else { + wHeight = document.body.clientHeight - 80; + wWidth = document.body.clientWidth - 18; + } + + var elm = document.getElementById('frmData'); + if (elm) { + elm.style.height = Math.abs(wHeight) + 'px'; + elm.style.width = Math.abs(wWidth) + 'px'; + } +} + +tinyMCEPopup.onInit.add(onLoadInit); diff --git a/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js b/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js deleted file mode 100644 index 4c07691..0000000 --- a/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js +++ /dev/null @@ -1,38 +0,0 @@ -function saveContent() { - if (document.forms[0].htmlSource.value == '') { - tinyMCEPopup.close(); - return false; - } - - tinyMCEPopup.execCommand('mcePasteText', false, { - html : document.forms[0].htmlSource.value, - linebreaks : document.forms[0].linebreaks.checked - }); - - tinyMCEPopup.close(); -} - -function onLoadInit() { - tinyMCEPopup.resizeToInnerSize(); - - // Remove Gecko spellchecking - if (tinyMCE.isGecko) - document.body.spellcheck = tinyMCE.getParam("gecko_spellcheck"); - - resizeInputs(); -} - -var wHeight=0, wWidth=0, owHeight=0, owWidth=0; - -function resizeInputs() { - if (!tinyMCE.isMSIE) { - wHeight = self.innerHeight-80; - wWidth = self.innerWidth-17; - } else { - wHeight = document.body.clientHeight-80; - wWidth = document.body.clientWidth-17; - } - - document.forms[0].htmlSource.style.height = Math.abs(wHeight) + 'px'; - document.forms[0].htmlSource.style.width = Math.abs(wWidth) + 'px'; -} diff --git a/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js b/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js deleted file mode 100644 index b243a10..0000000 --- a/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js +++ /dev/null @@ -1,52 +0,0 @@ -function saveContent() { - var html = document.getElementById("frmData").contentWindow.document.body.innerHTML; - - if (html == ''){ - tinyMCEPopup.close(); - return false; - } - - tinyMCEPopup.execCommand('mcePasteWord', false, html); - tinyMCEPopup.close(); -} - -function onLoadInit() { - tinyMCEPopup.resizeToInnerSize(); - - // Fix for endless reloading in FF - window.setTimeout('createIFrame();', 10); -} - -function createIFrame() { - document.getElementById('iframecontainer').innerHTML = ''; -} - -var wHeight=0, wWidth=0, owHeight=0, owWidth=0; - -function initIframe(doc) { - var dir = tinyMCE.selectedInstance.settings['directionality']; - - doc.body.dir = dir; - - // Remove Gecko spellchecking - if (tinyMCE.isGecko) - doc.body.spellcheck = tinyMCE.getParam("gecko_spellcheck"); - - resizeInputs(); -} - -function resizeInputs() { - if (!tinyMCE.isMSIE) { - wHeight = self.innerHeight - 80; - wWidth = self.innerWidth - 18; - } else { - wHeight = document.body.clientHeight - 80; - wWidth = document.body.clientWidth - 18; - } - - var elm = document.getElementById('frmData'); - if (elm) { - elm.style.height = Math.abs(wHeight) + 'px'; - elm.style.width = Math.abs(wWidth) + 'px'; - } -} diff --git a/wp-includes/js/tinymce/plugins/paste/langs/en.js b/wp-includes/js/tinymce/plugins/paste/langs/en.js deleted file mode 100644 index b125d51..0000000 --- a/wp-includes/js/tinymce/plugins/paste/langs/en.js +++ /dev/null @@ -1,10 +0,0 @@ -// UK lang variables - -tinyMCE.addToLang('',{ -paste_text_desc : 'Paste as Plain Text', -paste_text_title : 'Use CTRL+V on your keyboard to paste the text into the window.', -paste_text_linebreaks : 'Keep linebreaks', -paste_word_desc : 'Paste from Word', -paste_word_title : 'Use CTRL+V on your keyboard to paste the text into the window.', -selectall_desc : 'Select All' -}); diff --git a/wp-includes/js/tinymce/plugins/safari/blank.htm b/wp-includes/js/tinymce/plugins/safari/blank.htm new file mode 100644 index 0000000..266808c --- /dev/null +++ b/wp-includes/js/tinymce/plugins/safari/blank.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/safari/editor_plugin.js b/wp-includes/js/tinymce/plugins/safari/editor_plugin.js new file mode 100644 index 0000000..960fc71 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/safari/editor_plugin.js @@ -0,0 +1 @@ +(function(){var Event=tinymce.dom.Event,grep=tinymce.grep,each=tinymce.each,inArray=tinymce.inArray,isOldWebKit=tinymce.isOldWebKit;tinymce.create('tinymce.plugins.Safari',{init:function(ed){var t=this,dom;if(!tinymce.isWebKit)return;t.editor=ed;t.webKitFontSizes=['x-small','small','medium','large','x-large','xx-large','-webkit-xxx-large'];t.namedFontSizes=['xx-small','x-small','small','medium','large','x-large','xx-large'];ed.onKeyUp.add(function(ed,e){var h;if(e.keyCode==46||e.keyCode==8){h=ed.getBody().innerHTML;if(!/<(img|hr)/.test(h)&&tinymce.trim(h.replace(/<[^>]+>/g,'')).length==0)ed.setContent('',{format:'raw'});}});ed.addCommand('FormatBlock',function(u,v){var dom=ed.dom,e=dom.getParent(ed.selection.getNode(),dom.isBlock);if(e)dom.replace(dom.create(v),e,1);else ed.getDoc().execCommand("FormatBlock",false,v);});ed.addCommand('mceInsertContent',function(u,v){ed.getDoc().execCommand("InsertText",false,'mce_marker');ed.getBody().innerHTML=ed.getBody().innerHTML.replace(/mce_marker/g,v+'XX');ed.selection.select(ed.dom.get('_mce_tmp'));ed.getDoc().execCommand("Delete",false,' ');});ed.onKeyPress.add(function(ed,e){if(e.keyCode==13&&(e.shiftKey||ed.settings.force_br_newlines&&ed.selection.getNode().nodeName!='LI')){t._insertBR(ed);Event.cancel(e);}});ed.addQueryValueHandler('FontSize',function(u,v){var e,v;if((e=ed.dom.getParent(ed.selection.getStart(),'span'))&&(v=e.style.fontSize))return tinymce.inArray(t.namedFontSizes,v)+1;if((e=ed.dom.getParent(ed.selection.getEnd(),'span'))&&(v=e.style.fontSize))return tinymce.inArray(t.namedFontSizes,v)+1;return ed.getDoc().queryCommandValue('FontSize');});ed.addQueryValueHandler('FontName',function(u,v){var e,v;if((e=ed.dom.getParent(ed.selection.getStart(),'span'))&&(v=e.style.fontFamily))return v.replace(/, /g,',');if((e=ed.dom.getParent(ed.selection.getEnd(),'span'))&&(v=e.style.fontFamily))return v.replace(/, /g,',');return ed.getDoc().queryCommandValue('FontName');});ed.onClick.add(function(ed,e){e=e.target;if(e.nodeName=='IMG'){t.selElm=e;ed.selection.select(e);}else t.selElm=null;});ed.onBeforeExecCommand.add(function(ed,c,b){var r=t.bookmarkRng;if(r){ed.selection.setRng(r);t.bookmarkRng=null;}});ed.onInit.add(function(){t._fixWebKitSpans();ed.windowManager.onOpen.add(function(){var r=ed.selection.getRng();if(r.startContainer!=ed.getDoc()){t.bookmarkRng=r.cloneRange();}});ed.windowManager.onClose.add(function(){t.bookmarkRng=null;});if(isOldWebKit)t._patchSafari2x(ed);});ed.onSetContent.add(function(){dom=ed.dom;each(['strong','b','em','u','strike','sub','sup','a'],function(v){each(grep(dom.select(v)).reverse(),function(n){var nn=n.nodeName.toLowerCase(),st;if(nn=='a'){if(n.name)dom.replace(dom.create('img',{mce_name:'a',name:n.name,'class':'mceItemAnchor'}),n);return;}switch(nn){case'b':case'strong':if(nn=='b')nn='strong';st='font-weight: bold;';break;case'em':st='font-style: italic;';break;case'u':st='text-decoration: underline;';break;case'sub':st='vertical-align: sub;';break;case'sup':st='vertical-align: super;';break;case'strike':st='text-decoration: line-through;';break;}dom.replace(dom.create('span',{mce_name:nn,style:st,'class':'Apple-style-span'}),n,1);});});});ed.onPreProcess.add(function(ed,o){dom=ed.dom;each(grep(o.node.getElementsByTagName('span')).reverse(),function(n){var v,bg;if(o.get){if(dom.hasClass(n,'Apple-style-span')){bg=n.style.backgroundColor;switch(dom.getAttrib(n,'mce_name')){case'font':if(!ed.settings.convert_fonts_to_spans)dom.setAttrib(n,'style','');break;case'strong':case'em':case'sub':case'sup':dom.setAttrib(n,'style','');break;case'strike':case'u':if(!ed.settings.inline_styles)dom.setAttrib(n,'style','');else dom.setAttrib(n,'mce_name','');break;default:if(!ed.settings.inline_styles)dom.setAttrib(n,'style','');}if(bg)n.style.backgroundColor=bg;}}if(dom.hasClass(n,'mceItemRemoved'))dom.remove(n,1);});});ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/
    <\/(h[1-6]|div|p|address|pre)>/g,'');o.content=o.content.replace(/ id=\"undefined\"/g,'');});},_fixWebKitSpans:function(){var t=this,ed=t.editor;if(!isOldWebKit){Event.add(ed.getDoc(),'DOMNodeInserted',function(e){e=e.target;if(e&&e.nodeType==1)t._fixAppleSpan(e);});}else{ed.onExecCommand.add(function(){each(ed.dom.select('span'),function(n){t._fixAppleSpan(n);});ed.nodeChanged();});}},_fixAppleSpan:function(e){var ed=this.editor,dom=ed.dom,fz=this.webKitFontSizes,fzn=this.namedFontSizes,s=ed.settings,st,p;if(dom.getAttrib(e,'mce_fixed'))return;if(e.nodeName=='SPAN'&&e.className=='Apple-style-span'){st=e.style;if(!s.convert_fonts_to_spans){if(st.fontSize){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'size',inArray(fz,st.fontSize)+1);}if(st.fontFamily){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'face',st.fontFamily);}if(st.color){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'color',dom.toHex(st.color));}if(st.backgroundColor){dom.setAttrib(e,'mce_name','font');dom.setStyle(e,'background-color',st.backgroundColor);}}else{if(st.fontSize)dom.setStyle(e,'fontSize',fzn[inArray(fz,st.fontSize)]);}if(st.fontWeight=='bold')dom.setAttrib(e,'mce_name','strong');if(st.fontStyle=='italic')dom.setAttrib(e,'mce_name','em');if(st.textDecoration=='underline')dom.setAttrib(e,'mce_name','u');if(st.textDecoration=='line-through')dom.setAttrib(e,'mce_name','strike');if(st.verticalAlign=='super')dom.setAttrib(e,'mce_name','sup');if(st.verticalAlign=='sub')dom.setAttrib(e,'mce_name','sub');dom.setAttrib(e,'mce_fixed','1');}},_patchSafari2x:function(ed){var t=this,setContent,getNode,dom=ed.dom,lr;if(ed.windowManager.onBeforeOpen){ed.windowManager.onBeforeOpen.add(function(){r=ed.selection.getRng();});}ed.selection.select=function(n){this.getSel().setBaseAndExtent(n,0,n,1);};getNode=ed.selection.getNode;ed.selection.getNode=function(){return t.selElm||getNode.call(this);};ed.selection.getRng=function(){var t=this,s=t.getSel(),d=ed.getDoc(),r,rb,ra,di;if(s.anchorNode){r=d.createRange();try{rb=d.createRange();rb.setStart(s.anchorNode,s.anchorOffset);rb.collapse(1);ra=d.createRange();ra.setStart(s.focusNode,s.focusOffset);ra.collapse(1);di=rb.compareBoundaryPoints(rb.START_TO_END,ra)<0;r.setStart(di?s.anchorNode:s.focusNode,di?s.anchorOffset:s.focusOffset);r.setEnd(di?s.focusNode:s.anchorNode,di?s.focusOffset:s.anchorOffset);lr=r;}catch(ex){}}return r||lr;};setContent=ed.selection.setContent;ed.selection.setContent=function(h,s){var r=this.getRng(),b;try{setContent.call(this,h,s);}catch(ex){b=dom.create('body');b.innerHTML=h;each(b.childNodes,function(n){r.insertNode(n.cloneNode(true));});}};},_insertBR:function(ed){var dom=ed.dom,s=ed.selection,r=s.getRng(),br;r.insertNode(br=dom.create('br'));r.setStartAfter(br);r.setEndAfter(br);s.setRng(r);if(s.getSel().focusNode==br.previousSibling){s.select(dom.insertAfter(dom.doc.createTextNode('\u00a0'),br));s.collapse(1);}ed.getWin().scrollTo(0,dom.getPos(s.getRng().startContainer).y);}});tinymce.PluginManager.add('safari',tinymce.plugins.Safari);})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php new file mode 100644 index 0000000..00c9f9f --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php @@ -0,0 +1,158 @@ +_getMatches($lang, $wordstr); + $words = array(); + + for ($i=0; $i_unhtmlentities(mb_substr($wordstr, $matches[$i][1], $matches[$i][2], "UTF-8")); + + return $words; + } + + /** + * Returns suggestions of for a specific word. + * + * @param {String} $lang Language code like sv or en. + * @param {String} $word Specific word to get suggestions for. + * @return {Array} Array of suggestions for the specified word. + */ + function &getSuggestions($lang, $word) { + $sug = array(); + $osug = array(); + $matches = $this->_getMatches($lang, $word); + + if (count($matches) > 0) + $sug = explode("\t", utf8_encode($this->_unhtmlentities($matches[0][4]))); + + // Remove empty + foreach ($sug as $item) { + if ($item) + $osug[] = $item; + } + + return $osug; + } + + function &_getMatches($lang, $str) { + $server = "www.google.com"; + $port = 443; + $path = "/tbproxy/spell?lang=" . $lang . "&hl=en"; + $host = "www.google.com"; + $url = "https://" . $server; + + // Setup XML request + $xml = '' . $str . ''; + + $header = "POST ".$path." HTTP/1.0 \r\n"; + $header .= "MIME-Version: 1.0 \r\n"; + $header .= "Content-type: application/PTI26 \r\n"; + $header .= "Content-length: ".strlen($xml)." \r\n"; + $header .= "Content-transfer-encoding: text \r\n"; + $header .= "Request-number: 1 \r\n"; + $header .= "Document-type: Request \r\n"; + $header .= "Interface-Version: Test 1.4 \r\n"; + $header .= "Connection: close \r\n\r\n"; + $header .= $xml; + + // Use curl if it exists + if (function_exists('curl_init')) { + // Use curl + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + $xml = curl_exec($ch); + curl_close($ch); + } else { + // Use raw sockets + $fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30); + if ($fp) { + // Send request + fwrite($fp, $header); + + // Read response + $xml = ""; + while (!feof($fp)) + $xml .= fgets($fp, 128); + + fclose($fp); + } else + echo "Could not open SSL connection to google."; + } + + // Grab and parse content + $matches = array(); + preg_match_all('/([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER); + + return $matches; + } + + function _unhtmlentities($string) { + $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); + $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string); + + $trans_tbl = get_html_translation_table(HTML_ENTITIES); + $trans_tbl = array_flip($trans_tbl); + + return strtr($string, $trans_tbl); + } +} + +// Patch in multibyte support +if (!function_exists('mb_substr')) { + function mb_substr($str, $start, $len = '', $encoding="UTF-8"){ + $limit = strlen($str); + + for ($s = 0; $start > 0;--$start) {// found the real start + if ($s >= $limit) + break; + + if ($str[$s] <= "\x7F") + ++$s; + else { + ++$s; // skip length + + while ($str[$s] >= "\x80" && $str[$s] <= "\xBF") + ++$s; + } + } + + if ($len == '') + return substr($str, $s); + else + for ($e = $s; $len > 0; --$len) {//found the real end + if ($e >= $limit) + break; + + if ($str[$e] <= "\x7F") + ++$e; + else { + ++$e;//skip length + + while ($str[$e] >= "\x80" && $str[$e] <= "\xBF" && $e < $limit) + ++$e; + } + } + + return substr($str, $s, $e - $s); + } +} + +?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php deleted file mode 100755 index cae27f0..0000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php +++ /dev/null @@ -1,339 +0,0 @@ -cookies array ready for the next request - // Note: This currently ignores the cookie path (and time) completely. Time is not important, - // but path could possibly lead to security problems. - var $persist_referers = true; // For each request, sends path of last request as referer - var $debug = false; - var $handle_redirects = true; // Auaomtically redirect if Location or URI header is found - var $max_redirects = 5; - var $headers_only = false; // If true, stops receiving once headers have been read. - // Basic authorization variables - var $username; - var $password; - // Response vars - var $status; - var $headers = array(); - var $content = ''; - var $errormsg; - // Tracker variables - var $redirect_count = 0; - var $cookie_host = ''; - function HttpClient($host, $port=80) { - $this->host = $host; - $this->port = $port; - } - function get($path, $data = false) { - $this->path = $path; - $this->method = 'GET'; - if ($data) { - $this->path .= '?'.$this->buildQueryString($data); - } - return $this->doRequest(); - } - function post($path, $data) { - $this->path = $path; - $this->method = 'POST'; - $this->postdata = $this->buildQueryString($data); - return $this->doRequest(); - } - function buildQueryString($data) { - $querystring = ''; - if (is_array($data)) { - // Change data in to postable data - foreach ($data as $key => $val) { - if (is_array($val)) { - foreach ($val as $val2) { - $querystring .= urlencode($key).'='.urlencode($val2).'&'; - } - } else { - $querystring .= urlencode($key).'='.urlencode($val).'&'; - } - } - $querystring = substr($querystring, 0, -1); // Eliminate unnecessary & - } else { - $querystring = $data; - } - return $querystring; - } - function doRequest() { - // Performs the actual HTTP request, returning true or false depending on outcome - if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) { - // Set error message - switch($errno) { - case -3: - $this->errormsg = 'Socket creation failed (-3)'; - case -4: - $this->errormsg = 'DNS lookup failure (-4)'; - case -5: - $this->errormsg = 'Connection refused or timed out (-5)'; - default: - $this->errormsg = 'Connection failed ('.$errno.')'; - $this->errormsg .= ' '.$errstr; - $this->debug($this->errormsg); - } - return false; - } - socket_set_timeout($fp, $this->timeout); - $request = $this->buildRequest(); - $this->debug('Request', $request); - fwrite($fp, $request); - // Reset all the variables that should not persist between requests - $this->headers = array(); - $this->content = ''; - $this->errormsg = ''; - // Set a couple of flags - $inHeaders = true; - $atStart = true; - // Now start reading back the response - while (!feof($fp)) { - $line = fgets($fp, 4096); - if ($atStart) { - // Deal with first line of returned data - $atStart = false; - if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) { - $this->errormsg = "Status code line invalid: ".htmlentities($line); - $this->debug($this->errormsg); - return false; - } - $http_version = $m[1]; // not used - $this->status = $m[2]; - $status_string = $m[3]; // not used - $this->debug(trim($line)); - continue; - } - if ($inHeaders) { - if (trim($line) == '') { - $inHeaders = false; - $this->debug('Received Headers', $this->headers); - if ($this->headers_only) { - break; // Skip the rest of the input - } - continue; - } - if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) { - // Skip to the next header - continue; - } - $key = strtolower(trim($m[1])); - $val = trim($m[2]); - // Deal with the possibility of multiple headers of same name - if (isset($this->headers[$key])) { - if (is_array($this->headers[$key])) { - $this->headers[$key][] = $val; - } else { - $this->headers[$key] = array($this->headers[$key], $val); - } - } else { - $this->headers[$key] = $val; - } - continue; - } - // We're not in the headers, so append the line to the contents - $this->content .= $line; - } - fclose($fp); - // If data is compressed, uncompress it - if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') { - $this->debug('Content is gzip encoded, unzipping it'); - $this->content = substr($this->content, 10); // See http://www.php.net/manual/en/function.gzencode.php - $this->content = gzinflate($this->content); - } - // If $persist_cookies, deal with any cookies - if ($this->persist_cookies && isset($this->headers['set-cookie']) && $this->host == $this->cookie_host) { - $cookies = $this->headers['set-cookie']; - if (!is_array($cookies)) { - $cookies = array($cookies); - } - foreach ($cookies as $cookie) { - if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) { - $this->cookies[$m[1]] = $m[2]; - } - } - // Record domain of cookies for security reasons - $this->cookie_host = $this->host; - } - // If $persist_referers, set the referer ready for the next request - if ($this->persist_referers) { - $this->debug('Persisting referer: '.$this->getRequestURL()); - $this->referer = $this->getRequestURL(); - } - // Finally, if handle_redirects and a redirect is sent, do that - if ($this->handle_redirects) { - if (++$this->redirect_count >= $this->max_redirects) { - $this->errormsg = 'Number of redirects exceeded maximum ('.$this->max_redirects.')'; - $this->debug($this->errormsg); - $this->redirect_count = 0; - return false; - } - $location = isset($this->headers['location']) ? $this->headers['location'] : ''; - $uri = isset($this->headers['uri']) ? $this->headers['uri'] : ''; - if ($location || $uri) { - $url = parse_url($location.$uri); - // This will FAIL if redirect is to a different site - return $this->get($url['path']); - } - } - return true; - } - function buildRequest() { - $headers = array(); - $headers[] = "{$this->method} {$this->path} HTTP/1.0"; // Using 1.1 leads to all manner of problems, such as "chunked" encoding - $headers[] = "Host: {$this->host}"; - $headers[] = "User-Agent: {$this->user_agent}"; - $headers[] = "Accept: {$this->accept}"; - if ($this->use_gzip) { - $headers[] = "Accept-encoding: {$this->accept_encoding}"; - } - $headers[] = "Accept-language: {$this->accept_language}"; - if ($this->referer) { - $headers[] = "Referer: {$this->referer}"; - } - // Cookies - if ($this->cookies) { - $cookie = 'Cookie: '; - foreach ($this->cookies as $key => $value) { - $cookie .= "$key=$value; "; - } - $headers[] = $cookie; - } - // Basic authentication - if ($this->username && $this->password) { - $headers[] = 'Authorization: BASIC '.base64_encode($this->username.':'.$this->password); - } - // If this is a POST, set the content type and length - if ($this->postdata) { - $headers[] = 'Content-Type: application/x-www-form-urlencoded'; - $headers[] = 'Content-Length: '.strlen($this->postdata); - } - $request = implode("\r\n", $headers)."\r\n\r\n".$this->postdata; - return $request; - } - function getStatus() { - return $this->status; - } - function getContent() { - return $this->content; - } - function getHeaders() { - return $this->headers; - } - function getHeader($header) { - $header = strtolower($header); - if (isset($this->headers[$header])) { - return $this->headers[$header]; - } else { - return false; - } - } - function getError() { - return $this->errormsg; - } - function getCookies() { - return $this->cookies; - } - function getRequestURL() { - $url = 'http://'.$this->host; - if ($this->port != 80) { - $url .= ':'.$this->port; - } - $url .= $this->path; - return $url; - } - // Setter methods - function setUserAgent($string) { - $this->user_agent = $string; - } - function setAuthorization($username, $password) { - $this->username = $username; - $this->password = $password; - } - function setCookies($array) { - $this->cookies = $array; - } - // Option setting methods - function useGzip($boolean) { - $this->use_gzip = $boolean; - } - function setPersistCookies($boolean) { - $this->persist_cookies = $boolean; - } - function setPersistReferers($boolean) { - $this->persist_referers = $boolean; - } - function setHandleRedirects($boolean) { - $this->handle_redirects = $boolean; - } - function setMaxRedirects($num) { - $this->max_redirects = $num; - } - function setHeadersOnly($boolean) { - $this->headers_only = $boolean; - } - function setDebug($boolean) { - $this->debug = $boolean; - } - // "Quick" static methods - function quickGet($url) { - $bits = parse_url($url); - $host = $bits['host']; - $port = isset($bits['port']) ? $bits['port'] : 80; - $path = isset($bits['path']) ? $bits['path'] : '/'; - if (isset($bits['query'])) { - $path .= '?'.$bits['query']; - } - $client = new HttpClient($host, $port); - if (!$client->get($path)) { - return false; - } else { - return $client->getContent(); - } - } - function quickPost($url, $data) { - $bits = parse_url($url); - $host = $bits['host']; - $port = isset($bits['port']) ? $bits['port'] : 80; - $path = isset($bits['path']) ? $bits['path'] : '/'; - $client = new HttpClient($host, $port); - if (!$client->post($path, $data)) { - return false; - } else { - return $client->getContent(); - } - } - function debug($msg, $object = false) { - if ($this->debug) { - print '
    HttpClient Debug: '.$msg; - if ($object) { - ob_start(); - print_r($object); - $content = htmlentities(ob_get_contents()); - ob_end_clean(); - print '
    '.$content.'
    '; - } - print '
    '; - } - } -} - -?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php new file mode 100644 index 0000000..48af873 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php @@ -0,0 +1,81 @@ +_getPLink($lang); + + $outWords = array(); + foreach ($words as $word) { + if (!pspell_check($plink, trim($word))) + $outWords[] = utf8_encode($word); + } + + return $outWords; + } + + /** + * Returns suggestions of for a specific word. + * + * @param {String} $lang Language code like sv or en. + * @param {String} $word Specific word to get suggestions for. + * @return {Array} Array of suggestions for the specified word. + */ + function &getSuggestions($lang, $word) { + $words = pspell_suggest($this->_getPLink($lang), $word); + + for ($i=0; $ithrowError("PSpell support not found in PHP installation."); + + // Setup PSpell link + $plink = pspell_new( + $lang, + $this->_config['PSpell.spelling'], + $this->_config['PSpell.jargon'], + $this->_config['PSpell.encoding'], + $this->_config['PSpell.mode'] + ); + + // Setup PSpell link +/* if (!$plink) { + $pspellConfig = pspell_config_create( + $lang, + $this->_config['PSpell.spelling'], + $this->_config['PSpell.jargon'], + $this->_config['PSpell.encoding'] + ); + + $plink = pspell_new_config($pspell_config); + }*/ + + if (!$plink) + $this->throwError("No PSpell link found opened."); + + return $plink; + } +} + +?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php new file mode 100644 index 0000000..779e837 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php @@ -0,0 +1,112 @@ +_getCMD($lang); + + if ($fh = fopen($this->_tmpfile, "w")) { + fwrite($fh, "!\n"); + + foreach($words as $key => $value) + fwrite($fh, "^" . $value . "\n"); + + fclose($fh); + } else + $this->throwError("PSpell support was not found."); + + $data = shell_exec($cmd); + @unlink($this->_tmpfile); + + $returnData = array(); + $dataArr = preg_split("/[\r\n]/", $data, -1, PREG_SPLIT_NO_EMPTY); + + foreach ($dataArr as $dstr) { + $matches = array(); + + // Skip this line. + if (strpos($dstr, "@") === 0) + continue; + + preg_match("/\& ([^ ]+) .*/i", $dstr, $matches); + + if (!empty($matches[1])) + $returnData[] = utf8_encode(trim($matches[1])); + } + + return $returnData; + } + + /** + * Returns suggestions of for a specific word. + * + * @param {String} $lang Language code like sv or en. + * @param {String} $word Specific word to get suggestions for. + * @return {Array} Array of suggestions for the specified word. + */ + function &getSuggestions($lang, $word) { + $cmd = $this->_getCMD($lang); + + if (function_exists("mb_convert_encoding")) + $word = mb_convert_encoding($word, "ISO-8859-1", mb_detect_encoding($word, "UTF-8")); + else + $word = utf8_encode($word); + + if ($fh = fopen($this->_tmpfile, "w")) { + fwrite($fh, "!\n"); + fwrite($fh, "^$word\n"); + fclose($fh); + } else + $this->throwError("Error opening tmp file."); + + $data = shell_exec($cmd); + @unlink($this->_tmpfile); + + $returnData = array(); + $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); + + foreach($dataArr as $dstr) { + $matches = array(); + + // Skip this line. + if (strpos($dstr, "@") === 0) + continue; + + preg_match("/\&[^:]+:(.*)/i", $dstr, $matches); + + if (!empty($matches[1])) { + $words = array_slice(explode(',', $matches[1]), 0, 10); + + for ($i=0; $i_tmpfile = tempnam($this->_config['PSpellShell.tmp'], "tinyspell"); + + if(preg_match("#win#i", php_uname())) + return $this->_config['PSpellShell.aspell'] . " -a --lang=". $lang . " --encoding=utf-8 -H < " . $this->_tmpfile . " 2>&1"; + + return "cat ". $this->_tmpfile ." | " . $this->_config['PSpellShell.aspell'] . " -a --encoding=utf-8 -H --lang=". $lang; + } +} + +?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php new file mode 100644 index 0000000..ca7b143 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php @@ -0,0 +1,61 @@ +_config = $config; + } + + /** + * Simple loopback function everything that gets in will be send back. + * + * @param $args.. Arguments. + * @return {Array} Array of all input arguments. + */ + function &loopback(/* args.. */) { + return func_get_args(); + } + + /** + * Spellchecks an array of words. + * + * @param {String} $lang Language code like sv or en. + * @param {Array} $words Array of words to spellcheck. + * @return {Array} Array of misspelled words. + */ + function &checkWords($lang, $words) { + return $words; + } + + /** + * Returns suggestions of for a specific word. + * + * @param {String} $lang Language code like sv or en. + * @param {String} $word Specific word to get suggestions for. + * @return {Array} Array of suggestions for the specified word. + */ + function &getSuggestions($lang, $word) { + return array(); + } + + /** + * Throws an error message back to the user. This will stop all execution. + * + * @param {String} $str Message to send back to user. + */ + function throwError($str) { + die('{"result":null,"id":null,"error":{"errstr":"' . addslashes($str) . '","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}'); + } +} + +?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php deleted file mode 100755 index 0127ff1..0000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php +++ /dev/null @@ -1,126 +0,0 @@ -lang = $lang; - } - - // Returns array with bad words or false if failed. - function checkWords($word_array) { - $words = array(); - $wordstr = implode(' ', $word_array); - - $matches = $this->_getMatches($wordstr); - - for ($i=0; $iunhtmlentities(mb_substr($wordstr, $matches[$i][1], $matches[$i][2], "UTF-8")); - - return $words; - } - - function unhtmlentities($string) { - $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); - $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string); - - $trans_tbl = get_html_translation_table(HTML_ENTITIES); - $trans_tbl = array_flip($trans_tbl); - - return strtr($string, $trans_tbl); - } - - // Returns array with suggestions or false if failed. - function getSuggestion($word) { - $sug = array(); - - $matches = $this->_getMatches($word); - - if (count($matches) > 0) - $sug = explode("\t", utf8_encode($this->unhtmlentities($matches[0][4]))); - - return $sug; - } - - function _xmlChars($string) { - $trans = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES); - - foreach ($trans as $k => $v) - $trans[$k] = "&#".ord($k).";"; - - return strtr($string, $trans); - } - - function _getMatches($word_list) { - $server = "www.google.com"; - $port = 443; - $path = "/tbproxy/spell?lang=" . $this->lang . "&hl=en"; - $host = "www.google.com"; - $url = "https://" . $server; - - // Setup XML request - $xml = '' . $word_list . ''; - - $header = "POST ".$path." HTTP/1.0 \r\n"; - $header .= "MIME-Version: 1.0 \r\n"; - $header .= "Content-type: application/PTI26 \r\n"; - $header .= "Content-length: ".strlen($xml)." \r\n"; - $header .= "Content-transfer-encoding: text \r\n"; - $header .= "Request-number: 1 \r\n"; - $header .= "Document-type: Request \r\n"; - $header .= "Interface-Version: Test 1.4 \r\n"; - $header .= "Connection: close \r\n\r\n"; - $header .= $xml; - //$this->_debugData($xml); - - // Use curl if it exists - if (function_exists('curl_init')) { - // Use curl - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL,$url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - $xml = curl_exec($ch); - curl_close($ch); - } else { - // Use raw sockets - $fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30); - if ($fp) { - // Send request - fwrite($fp, $header); - - // Read response - $xml = ""; - while (!feof($fp)) - $xml .= fgets($fp, 128); - - fclose($fp); - } else - echo "Could not open SSL connection to google."; - } - - //$this->_debugData($xml); - - // Grab and parse content - preg_match_all('/([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER); - - return $matches; - } - - function _debugData($data) { - $fh = @fopen("debug.log", 'a+'); - @fwrite($fh, $data); - @fclose($fh); - } -} - -// Setup classname, should be the same as the name of the spellchecker class -$spellCheckerConfig['class'] = "TinyGoogleSpell"; - -?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php deleted file mode 100755 index 21fb194..0000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php +++ /dev/null @@ -1,64 +0,0 @@ -lang = $lang; - $this->mode = $mode; - $this->plink = false; - $this->errorMsg = array(); - - if (!function_exists("pspell_new")) { - $this->errorMsg[] = "PSpell not found."; - return; - } - - $this->plink = pspell_new($this->lang, $this->spelling, $this->jargon, $this->encoding, $this->mode); - } - - // Returns array with bad words or false if failed. - function checkWords($wordArray) { - if (!$this->plink) { - $this->errorMsg[] = "No PSpell link found for checkWords."; - return array(); - } - - $wordError = array(); - foreach($wordArray as $word) { - if(!pspell_check($this->plink, trim($word))) - $wordError[] = $word; - } - - return $wordError; - } - - // Returns array with suggestions or false if failed. - function getSuggestion($word) { - if (!$this->plink) { - $this->errorMsg[] = "No PSpell link found for getSuggestion."; - return array(); - } - - return pspell_suggest($this->plink, $word); - } -} - -// Setup classname, should be the same as the name of the spellchecker class -$spellCheckerConfig['class'] = "TinyPspell"; - -?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php deleted file mode 100755 index 5723d2f..0000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php +++ /dev/null @@ -1,121 +0,0 @@ -lang = $lang; - $this->mode = $mode; - $this->error = false; - $this->errorMsg = array(); - - $this->tmpfile = tempnam($config['tinypspellshell.tmp'], "tinyspell"); - - if(preg_match("#win#i",php_uname())) - $this->cmd = $config['tinypspellshell.aspell'] . " -a --lang=". $this->lang." --encoding=utf-8 -H < $this->tmpfile 2>&1"; - else - $this->cmd = "cat ". $this->tmpfile ." | " . $config['tinypspellshell.aspell'] . " -a --encoding=utf-8 -H --lang=". $this->lang; - } - - // Returns array with bad words or false if failed. - function checkWords($wordArray) { - if ($fh = fopen($this->tmpfile, "w")) { - fwrite($fh, "!\n"); - foreach($wordArray as $key => $value) - fwrite($fh, "^" . $value . "\n"); - fclose($fh); - } else { - $this->errorMsg[] = "PSpell not found."; - return array(); - } - - $data = shell_exec($this->cmd); - @unlink($this->tmpfile); - - $returnData = array(); - $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); - - foreach($dataArr as $dstr) { - $matches = array(); - - // Skip this line. - if (strpos($dstr, "@") === 0) - continue; - - preg_match("/\& (.*) .* .*: .*/i", $dstr, $matches); - - if (!empty($matches[1])) - $returnData[] = $matches[1]; - } - - return $returnData; - } - - // Returns array with suggestions or false if failed. - function getSuggestion($word) { - if (function_exists("mb_convert_encoding")) - $word = mb_convert_encoding($word, "ISO-8859-1", mb_detect_encoding($word, "UTF-8")); - else - $word = utf8_encode($word); - - if ($fh = fopen($this->tmpfile, "w")) { - fwrite($fh, "!\n"); - fwrite($fh, "^$word\n"); - fclose($fh); - } else - die("Error opening tmp file."); - - $data = shell_exec($this->cmd); - - @unlink($this->tmpfile); - - $returnData = array(); - $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); - - foreach($dataArr as $dstr) { - $matches = array(); - - // Skip this line. - if (strpos($dstr, "@") === 0) - continue; - - preg_match("/\& .* .* .*: (.*)/i", $dstr, $matches); - - if (!empty($matches[1])) { - // For some reason, the exec version seems to add commas? - $returnData[] = str_replace(",", "", $matches[1]); - } - } - return $returnData; - } - - function _debugData($data) { - $fh = @fopen("debug.log", 'a+'); - @fwrite($fh, $data); - @fclose($fh); - } - -} - -// Setup classname, should be the same as the name of the spellchecker class -$spellCheckerConfig['class'] = "TinyPspellShell"; - -?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php new file mode 100644 index 0000000..1c46116 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php @@ -0,0 +1,595 @@ +_data = $data; + $this->_len = strlen($data); + $this->_pos = -1; + $this->_location = JSON_IN_BETWEEN; + $this->_lastLocations = array(); + $this->_needProp = false; + } + + function getToken() { + return $this->_token; + } + + function getLocation() { + return $this->_location; + } + + function getTokenName() { + switch ($this->_token) { + case JSON_BOOL: + return 'JSON_BOOL'; + + case JSON_INT: + return 'JSON_INT'; + + case JSON_STR: + return 'JSON_STR'; + + case JSON_FLOAT: + return 'JSON_FLOAT'; + + case JSON_NULL: + return 'JSON_NULL'; + + case JSON_START_OBJ: + return 'JSON_START_OBJ'; + + case JSON_END_OBJ: + return 'JSON_END_OBJ'; + + case JSON_START_ARRAY: + return 'JSON_START_ARRAY'; + + case JSON_END_ARRAY: + return 'JSON_END_ARRAY'; + + case JSON_KEY: + return 'JSON_KEY'; + } + + return 'UNKNOWN'; + } + + function getValue() { + return $this->_value; + } + + function readToken() { + $chr = $this->read(); + + if ($chr != null) { + switch ($chr) { + case '[': + $this->_lastLocation[] = $this->_location; + $this->_location = JSON_IN_ARRAY; + $this->_token = JSON_START_ARRAY; + $this->_value = null; + $this->readAway(); + return true; + + case ']': + $this->_location = array_pop($this->_lastLocation); + $this->_token = JSON_END_ARRAY; + $this->_value = null; + $this->readAway(); + + if ($this->_location == JSON_IN_OBJECT) + $this->_needProp = true; + + return true; + + case '{': + $this->_lastLocation[] = $this->_location; + $this->_location = JSON_IN_OBJECT; + $this->_needProp = true; + $this->_token = JSON_START_OBJ; + $this->_value = null; + $this->readAway(); + return true; + + case '}': + $this->_location = array_pop($this->_lastLocation); + $this->_token = JSON_END_OBJ; + $this->_value = null; + $this->readAway(); + + if ($this->_location == JSON_IN_OBJECT) + $this->_needProp = true; + + return true; + + // String + case '"': + case '\'': + return $this->_readString($chr); + + // Null + case 'n': + return $this->_readNull(); + + // Bool + case 't': + case 'f': + return $this->_readBool($chr); + + default: + // Is number + if (is_numeric($chr) || $chr == '-' || $chr == '.') + return $this->_readNumber($chr); + + return true; + } + } + + return false; + } + + function _readBool($chr) { + $this->_token = JSON_BOOL; + $this->_value = $chr == 't'; + + if ($chr == 't') + $this->skip(3); // rue + else + $this->skip(4); // alse + + $this->readAway(); + + if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) + $this->_needProp = true; + + return true; + } + + function _readNull() { + $this->_token = JSON_NULL; + $this->_value = null; + + $this->skip(3); // ull + $this->readAway(); + + if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) + $this->_needProp = true; + + return true; + } + + function _readString($quote) { + $output = ""; + $this->_token = JSON_STR; + $endString = false; + + while (($chr = $this->peek()) != -1) { + switch ($chr) { + case '\\': + // Read away slash + $this->read(); + + // Read escape code + $chr = $this->read(); + switch ($chr) { + case 't': + $output .= "\t"; + break; + + case 'b': + $output .= "\b"; + break; + + case 'f': + $output .= "\f"; + break; + + case 'r': + $output .= "\r"; + break; + + case 'n': + $output .= "\n"; + break; + + case 'u': + $output .= $this->_int2utf8(hexdec($this->read(4))); + break; + + default: + $output .= $chr; + break; + } + + break; + + case '\'': + case '"': + if ($chr == $quote) + $endString = true; + + $chr = $this->read(); + if ($chr != -1 && $chr != $quote) + $output .= $chr; + + break; + + default: + $output .= $this->read(); + } + + // String terminated + if ($endString) + break; + } + + $this->readAway(); + $this->_value = $output; + + // Needed a property + if ($this->_needProp) { + $this->_token = JSON_KEY; + $this->_needProp = false; + return true; + } + + if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) + $this->_needProp = true; + + return true; + } + + function _int2utf8($int) { + $int = intval($int); + + switch ($int) { + case 0: + return chr(0); + + case ($int & 0x7F): + return chr($int); + + case ($int & 0x7FF): + return chr(0xC0 | (($int >> 6) & 0x1F)) . chr(0x80 | ($int & 0x3F)); + + case ($int & 0xFFFF): + return chr(0xE0 | (($int >> 12) & 0x0F)) . chr(0x80 | (($int >> 6) & 0x3F)) . chr (0x80 | ($int & 0x3F)); + + case ($int & 0x1FFFFF): + return chr(0xF0 | ($int >> 18)) . chr(0x80 | (($int >> 12) & 0x3F)) . chr(0x80 | (($int >> 6) & 0x3F)) . chr(0x80 | ($int & 0x3F)); + } + } + + function _readNumber($start) { + $value = ""; + $isFloat = false; + + $this->_token = JSON_INT; + $value .= $start; + + while (($chr = $this->peek()) != -1) { + if (is_numeric($chr) || $chr == '-' || $chr == '.') { + if ($chr == '.') + $isFloat = true; + + $value .= $this->read(); + } else + break; + } + + $this->readAway(); + + if ($isFloat) { + $this->_token = JSON_FLOAT; + $this->_value = floatval($value); + } else + $this->_value = intval($value); + + if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) + $this->_needProp = true; + + return true; + } + + function readAway() { + while (($chr = $this->peek()) != null) { + if ($chr != ':' && $chr != ',' && $chr != ' ') + return; + + $this->read(); + } + } + + function read($len = 1) { + if ($this->_pos < $this->_len) { + if ($len > 1) { + $str = substr($this->_data, $this->_pos + 1, $len); + $this->_pos += $len; + + return $str; + } else + return $this->_data[++$this->_pos]; + } + + return null; + } + + function skip($len) { + $this->_pos += $len; + } + + function peek() { + if ($this->_pos < $this->_len) + return $this->_data[$this->_pos + 1]; + + return null; + } +} + +/** + * This class handles JSON stuff. + * + * @package MCManager.utils + */ +class Moxiecode_JSON { + function Moxiecode_JSON() { + } + + function decode($input) { + $reader = new Moxiecode_JSONReader($input); + + return $this->readValue($reader); + } + + function readValue(&$reader) { + $this->data = array(); + $this->parents = array(); + $this->cur =& $this->data; + $key = null; + $loc = JSON_IN_ARRAY; + + while ($reader->readToken()) { + switch ($reader->getToken()) { + case JSON_STR: + case JSON_INT: + case JSON_BOOL: + case JSON_FLOAT: + case JSON_NULL: + switch ($reader->getLocation()) { + case JSON_IN_OBJECT: + $this->cur[$key] = $reader->getValue(); + break; + + case JSON_IN_ARRAY: + $this->cur[] = $reader->getValue(); + break; + + default: + return $reader->getValue(); + } + break; + + case JSON_KEY: + $key = $reader->getValue(); + break; + + case JSON_START_OBJ: + case JSON_START_ARRAY: + if ($loc == JSON_IN_OBJECT) + $this->addArray($key); + else + $this->addArray(null); + + $cur =& $obj; + + $loc = $reader->getLocation(); + break; + + case JSON_END_OBJ: + case JSON_END_ARRAY: + $loc = $reader->getLocation(); + + if (count($this->parents) > 0) { + $this->cur =& $this->parents[count($this->parents) - 1]; + array_pop($this->parents); + } + break; + } + } + + return $this->data[0]; + } + + // This method was needed since PHP is crapy and doesn't have pointers/references + function addArray($key) { + $this->parents[] =& $this->cur; + $ar = array(); + + if ($key) + $this->cur[$key] =& $ar; + else + $this->cur[] =& $ar; + + $this->cur =& $ar; + } + + function getDelim($index, &$reader) { + switch ($reader->getLocation()) { + case JSON_IN_ARRAY: + case JSON_IN_OBJECT: + if ($index > 0) + return ","; + break; + } + + return ""; + } + + function encode($input) { + switch (gettype($input)) { + case 'boolean': + return $input ? 'true' : 'false'; + + case 'integer': + return (int) $input; + + case 'float': + case 'double': + return (float) $input; + + case 'NULL': + return 'null'; + + case 'string': + return $this->encodeString($input); + + case 'array': + return $this->_encodeArray($input); + + case 'object': + return $this->_encodeArray(get_object_vars($input)); + } + + return ''; + } + + function encodeString($input) { + // Needs to be escaped + if (preg_match('/[^a-zA-Z0-9]/', $input)) { + $output = ''; + + for ($i=0; $i_utf82utf16($char))); + } if (($byte & 0xF0) == 0xE0) { + $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2])); + $i += 2; + $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); + } if (($byte & 0xF8) == 0xF0) { + $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]))); + $i += 3; + $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); + } if (($byte & 0xFC) == 0xF8) { + $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]), ord($input[$i + 4]))); + $i += 4; + $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); + } if (($byte & 0xFE) == 0xFC) { + $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]), ord($input[$i + 4]), ord($input[$i + 5]))); + $i += 5; + $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); + } else if ($byte < 128) + $output .= $input[$i]; + } + } + + return '"' . $output . '"'; + } + + return '"' . $input . '"'; + } + + function _utf82utf16($utf8) { + if (function_exists('mb_convert_encoding')) + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); + + switch (strlen($utf8)) { + case 1: + return $utf8; + + case 2: + return chr(0x07 & (ord($utf8[0]) >> 2)) . chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1]))); + + case 3: + return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))) . chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2]))); + } + + return ''; + } + + function _encodeArray($input) { + $output = ''; + $isIndexed = true; + + $keys = array_keys($input); + for ($i=0; $iencodeString($keys[$i]) . ':' . $this->encode($input[$keys[$i]]); + $isIndexed = false; + } else + $output .= $this->encode($input[$keys[$i]]); + + if ($i != count($keys) - 1) + $output .= ','; + } + + return $isIndexed ? '[' . $output . ']' : '{' . $output . '}'; + } +} + +?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php new file mode 100644 index 0000000..a1fb4cd --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php @@ -0,0 +1,268 @@ +_path = ""; + $this->_filename = "{level}.log"; + $this->setMaxSize("100k"); + $this->_maxFiles = 10; + $this->_level = MC_LOGGER_DEBUG; + $this->_format = "[{time}] [{level}] {message}"; + } + + /** + * Sets the current log level, use the MC_LOGGER constants. + * + * @param int $level Log level instance for example MC_LOGGER_DEBUG. + */ + function setLevel($level) { + if (is_string($level)) { + switch (strtolower($level)) { + case "debug": + $level = MC_LOGGER_DEBUG; + break; + + case "info": + $level = MC_LOGGER_INFO; + break; + + case "warn": + case "warning": + $level = MC_LOGGER_WARN; + break; + + case "error": + $level = MC_LOGGER_ERROR; + break; + + case "fatal": + $level = MC_LOGGER_FATAL; + break; + + default: + $level = MC_LOGGER_FATAL; + } + } + + $this->_level = $level; + } + + /** + * Returns the current log level for example MC_LOGGER_DEBUG. + * + * @return int Current log level for example MC_LOGGER_DEBUG. + */ + function getLevel() { + return $this->_level; + } + + function setPath($path) { + $this->_path = $path; + } + + function getPath() { + return $this->_path; + } + + function setFileName($file_name) { + $this->_filename = $file_name; + } + + function getFileName() { + return $this->_filename; + } + + function setFormat($format) { + $this->_format = $format; + } + + function getFormat() { + return $this->_format; + } + + function setMaxSize($size) { + // Fix log max size + $logMaxSizeBytes = intval(preg_replace("/[^0-9]/", "", $size)); + + // Is KB + if (strpos((strtolower($size)), "k") > 0) + $logMaxSizeBytes *= 1024; + + // Is MB + if (strpos((strtolower($size)), "m") > 0) + $logMaxSizeBytes *= (1024 * 1024); + + $this->_maxSizeBytes = $logMaxSizeBytes; + $this->_maxSize = $size; + } + + function getMaxSize() { + return $this->_maxSize; + } + + function setMaxFiles($max_files) { + $this->_maxFiles = $max_files; + } + + function getMaxFiles() { + return $this->_maxFiles; + } + + function debug($msg) { + $args = func_get_args(); + $this->_logMsg(MC_LOGGER_DEBUG, implode(', ', $args)); + } + + function info($msg) { + $args = func_get_args(); + $this->_logMsg(MC_LOGGER_INFO, implode(', ', $args)); + } + + function warn($msg) { + $args = func_get_args(); + $this->_logMsg(MC_LOGGER_WARN, implode(', ', $args)); + } + + function error($msg) { + $args = func_get_args(); + $this->_logMsg(MC_LOGGER_ERROR, implode(', ', $args)); + } + + function fatal($msg) { + $args = func_get_args(); + $this->_logMsg(MC_LOGGER_FATAL, implode(', ', $args)); + } + + function isDebugEnabled() { + return $this->_level >= MC_LOGGER_DEBUG; + } + + function isInfoEnabled() { + return $this->_level >= MC_LOGGER_INFO; + } + + function isWarnEnabled() { + return $this->_level >= MC_LOGGER_WARN; + } + + function isErrorEnabled() { + return $this->_level >= MC_LOGGER_ERROR; + } + + function isFatalEnabled() { + return $this->_level >= MC_LOGGER_FATAL; + } + + function _logMsg($level, $message) { + $roll = false; + + if ($level < $this->_level) + return; + + $logFile = $this->toOSPath($this->_path . "/" . $this->_filename); + + switch ($level) { + case MC_LOGGER_DEBUG: + $levelName = "DEBUG"; + break; + + case MC_LOGGER_INFO: + $levelName = "INFO"; + break; + + case MC_LOGGER_WARN: + $levelName = "WARN"; + break; + + case MC_LOGGER_ERROR: + $levelName = "ERROR"; + break; + + case MC_LOGGER_FATAL: + $levelName = "FATAL"; + break; + } + + $logFile = str_replace('{level}', strtolower($levelName), $logFile); + + $text = $this->_format; + $text = str_replace('{time}', date("Y-m-d H:i:s"), $text); + $text = str_replace('{level}', strtolower($levelName), $text); + $text = str_replace('{message}', $message, $text); + $message = $text . "\r\n"; + + // Check filesize + if (file_exists($logFile)) { + $size = @filesize($logFile); + + if ($size + strlen($message) > $this->_maxSizeBytes) + $roll = true; + } + + // Roll if the size is right + if ($roll) { + for ($i=$this->_maxFiles-1; $i>=1; $i--) { + $rfile = $this->toOSPath($logFile . "." . $i); + $nfile = $this->toOSPath($logFile . "." . ($i+1)); + + if (@file_exists($rfile)) + @rename($rfile, $nfile); + } + + @rename($logFile, $this->toOSPath($logFile . ".1")); + + // Delete last logfile + $delfile = $this->toOSPath($logFile . "." . ($this->_maxFiles + 1)); + if (@file_exists($delfile)) + @unlink($delfile); + } + + // Append log line + if (($fp = @fopen($logFile, "a")) != null) { + @fputs($fp, $message); + @fflush($fp); + @fclose($fp); + } + } + + /** + * Converts a Unix path to OS specific path. + * + * @param String $path Unix path to convert. + */ + function toOSPath($path) { + return str_replace("/", DIRECTORY_SEPARATOR, $path); + } +} + +?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css b/wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css deleted file mode 100755 index f2c6ac7..0000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css +++ /dev/null @@ -1,35 +0,0 @@ -.mceMsgBox { - border: 1px solid gray; - padding: 8px; -} - -.mceMsgBox span { - vertical-align: top; - color: #555555; -} - -/* Misc */ - -.mceBlockBox { - display: none; - position: absolute; - left: 0; - top: 0; - z-index: 100; - filter:progid:DXImageTransform.Microsoft.Alpha(style=0, opacity=60); - -moz-opacity:0.6; - opacity: 0.6; - background-color: white; -} - -.mceMsgBox { - display: none; - z-index: 101; - position: absolute; - left: 0; - top: 0; - font-family: Arial, Verdana, Tahoma, Helvetica; - font-weight: bold; - font-size: 11px; - background-color: #FFF; -} diff --git a/wp-includes/js/tinymce/plugins/spellchecker/images/spellchecker.gif b/wp-includes/js/tinymce/plugins/spellchecker/images/spellchecker.gif deleted file mode 100755 index 294a9d2..0000000 Binary files a/wp-includes/js/tinymce/plugins/spellchecker/images/spellchecker.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/spellchecker/images/wline.gif b/wp-includes/js/tinymce/plugins/spellchecker/images/wline.gif deleted file mode 100755 index 7d0a4db..0000000 Binary files a/wp-includes/js/tinymce/plugins/spellchecker/images/wline.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/spellchecker/img/wline.gif b/wp-includes/js/tinymce/plugins/spellchecker/img/wline.gif new file mode 100644 index 0000000..7d0a4db Binary files /dev/null and b/wp-includes/js/tinymce/plugins/spellchecker/img/wline.gif differ diff --git a/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php b/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php new file mode 100644 index 0000000..9a12145 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php @@ -0,0 +1,98 @@ + $value) + $newarray[formatParam($name, $sanitize)] = formatParam($value, $sanitize); + + return $newarray; + } + + return formatParam($_REQUEST[$name], $sanitize); +} + +function &getLogger() { + global $mcLogger, $man; + + if (isset($man)) + $mcLogger = $man->getLogger(); + + if (!$mcLogger) { + $mcLogger = new Moxiecode_Logger(); + + // Set logger options + $mcLogger->setPath(dirname(__FILE__) . "/../logs"); + $mcLogger->setMaxSize("100kb"); + $mcLogger->setMaxFiles("10"); + $mcLogger->setFormat("{time} - {message}"); + } + + return $mcLogger; +} + +function debug($msg) { + $args = func_get_args(); + + $log = getLogger(); + $log->debug(implode(', ', $args)); +} + +function info($msg) { + $args = func_get_args(); + + $log = getLogger(); + $log->info(implode(', ', $args)); +} + +function error($msg) { + $args = func_get_args(); + + $log = getLogger(); + $log->error(implode(', ', $args)); +} + +function warn($msg) { + $args = func_get_args(); + + $log = getLogger(); + $log->warn(implode(', ', $args)); +} + +function fatal($msg) { + $args = func_get_args(); + + $log = getLogger(); + $log->fatal(implode(', ', $args)); +} + +?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/langs/en.js b/wp-includes/js/tinymce/plugins/spellchecker/langs/en.js deleted file mode 100755 index 02fdac5..0000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/langs/en.js +++ /dev/null @@ -1,15 +0,0 @@ -// UK lang variables - -tinyMCE.addToLang('spellchecker',{ - desc : 'Toggle spellchecker', - menu : 'Spellchecker settings', - ignore_word : 'Ignore word', - ignore_words : 'Ignore all', - langs : 'Languages', - wait : 'Please wait...', - swait : 'Spellchecking, please wait...', - sug : 'Suggestions', - no_sug : 'No suggestions', - no_mpell : 'No misspellings found.', - mpell_found : 'Found {$words} misspellings.' -}); diff --git a/wp-includes/js/tinymce/plugins/spellchecker/rpc.php b/wp-includes/js/tinymce/plugins/spellchecker/rpc.php new file mode 100644 index 0000000..d7b7436 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/rpc.php @@ -0,0 +1,75 @@ +decode($raw); + +// Execute RPC +if (isset($config['general.engine'])) { + $spellchecker = new $config['general.engine']($config); + $result = call_user_func_array(array($spellchecker, $input['method']), $input['params']); +} else + die('{"result":null,"id":null,"error":{"errstr":"You must choose an spellchecker engine in the config.php file.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}'); + +// Request and response id should always be the same +$output = array( + "id" => $input->id, + "result" => $result, + "error" => null +); + +// Return JSON encoded string +echo $json->encode($output); + +?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php b/wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php deleted file mode 100755 index 6b977c6..0000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php +++ /dev/null @@ -1,164 +0,0 @@ -'; - die; - } - - // Basic config - $defaultLanguage = $spellCheckerConfig['default.language']; - $defaultMode = $spellCheckerConfig['default.mode']; - - // Normaly not required to configure - $defaultSpelling = $spellCheckerConfig['default.spelling']; - $defaultJargon = $spellCheckerConfig['default.jargon']; - $defaultEncoding = $spellCheckerConfig['default.encoding']; - $outputType = "xml"; // Do not change - - // Get input parameters. - - $check = urldecode(getRequestParam('check')); - $cmd = sanitize(getRequestParam('cmd')); - $lang = sanitize(getRequestParam('lang'), "strict"); - $mode = sanitize(getRequestParam('mode'), "strict"); - $spelling = sanitize(getRequestParam('spelling'), "strict"); - $jargon = sanitize(getRequestParam('jargon'), "strict"); - $encoding = sanitize(getRequestParam('encoding'), "strict"); - $sg = sanitize(getRequestParam('sg'), "bool"); - $words = array(); - - $validRequest = true; - - if (empty($check)) - $validRequest = false; - - if (empty($lang)) - $lang = $defaultLanguage; - - if (empty($mode)) - $mode = $defaultMode; - - if (empty($spelling)) - $spelling = $defaultSpelling; - - if (empty($jargon)) - $jargon = $defaultJargon; - - if (empty($encoding)) - $encoding = $defaultEncoding; - - function sanitize($str, $type="strict") { - switch ($type) { - case "strict": - $str = preg_replace("/[^a-zA-Z0-9_\-]/i", "", $str); - break; - case "loose": - $str = preg_replace("//i", "<", $str); - break; - case "bool": - if ($str == "true" || $str == true) - $str = true; - else - $str = false; - break; - } - - return $str; - } - - function getRequestParam($name, $default_value = false) { - if (!isset($_REQUEST[$name])) - return $default_value; - - if (!isset($_GLOBALS['magic_quotes_gpc'])) - $_GLOBALS['magic_quotes_gpc'] = ini_get("magic_quotes_gpc"); - - if (isset($_GLOBALS['magic_quotes_gpc'])) { - if (is_array($_REQUEST[$name])) { - $newarray = array(); - - foreach($_REQUEST[$name] as $name => $value) - $newarray[stripslashes($name)] = stripslashes($value); - - return $newarray; - } - return stripslashes($_REQUEST[$name]); - } - - return $_REQUEST[$name]; - } - - $result = array(); - $tinyspell = new $spellCheckerConfig['class']($spellCheckerConfig, $lang, $mode, $spelling, $jargon, $encoding); - - if (count($tinyspell->errorMsg) == 0) { - switch($cmd) { - case "spell": - // Space for non-exec version and \n for the exec version. - $words = preg_split("/ |\n/", $check, -1, PREG_SPLIT_NO_EMPTY); - $result = $tinyspell->checkWords($words); - break; - - case "suggest": - $result = $tinyspell->getSuggestion($check); - break; - - default: - // Just use this for now. - $tinyspell->errorMsg[] = "No command."; - $outputType = $outputType . "error"; - break; - } - } else - $outputType = $outputType . "error"; - - if (!$result) - $result = array(); - - // Output data - switch($outputType) { - case "xml": - header('Content-type: text/xml; charset=utf-8'); - $body = ''; - $body .= "\n"; - - if (count($result) == 0) - $body .= ''; - else - $body .= ''. urlencode(implode(" ", $result)) .''; - - echo $body; - break; - case "xmlerror"; - header('Content-type: text/xml; charset=utf-8'); - $body = ''; - $body .= "\n"; - $body .= 'errorMsg) .'" />'; - echo $body; - break; - case "html": - var_dump($result); - break; - case "htmlerror": - echo "Error"; - break; - } - -?> diff --git a/wp-includes/js/tinymce/plugins/wordpress/css/content.css b/wp-includes/js/tinymce/plugins/wordpress/css/content.css new file mode 100644 index 0000000..a542e6e --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wordpress/css/content.css @@ -0,0 +1,15 @@ + +.mceWPnextpage, .mceWPmore { + border: 0px; + border-top: 1px dotted #cccccc; + display: block; + width: 100%; + height: 12px; + margin-top: 15px; +} +.mceWPmore { + background: #ffffff url(../img/more_bug.gif) no-repeat right top; +} +.mceWPnextpage { + background: #ffffff url(../img/page_bug.gif) no-repeat right top; +} \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/help.gif b/wp-includes/js/tinymce/plugins/wordpress/images/help.gif deleted file mode 100644 index 51a1ee4..0000000 Binary files a/wp-includes/js/tinymce/plugins/wordpress/images/help.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/more.gif b/wp-includes/js/tinymce/plugins/wordpress/images/more.gif deleted file mode 100644 index 4ff564d..0000000 Binary files a/wp-includes/js/tinymce/plugins/wordpress/images/more.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/more_bug.gif b/wp-includes/js/tinymce/plugins/wordpress/images/more_bug.gif deleted file mode 100644 index 4589cb4..0000000 Binary files a/wp-includes/js/tinymce/plugins/wordpress/images/more_bug.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/page.gif b/wp-includes/js/tinymce/plugins/wordpress/images/page.gif deleted file mode 100644 index 1cea78a..0000000 Binary files a/wp-includes/js/tinymce/plugins/wordpress/images/page.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif b/wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif deleted file mode 100644 index 9ea3565..0000000 Binary files a/wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/toolbars.gif b/wp-includes/js/tinymce/plugins/wordpress/images/toolbars.gif deleted file mode 100755 index dcb7066..0000000 Binary files a/wp-includes/js/tinymce/plugins/wordpress/images/toolbars.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/img/help.gif b/wp-includes/js/tinymce/plugins/wordpress/img/help.gif new file mode 100644 index 0000000..51a1ee4 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wordpress/img/help.gif differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/img/more.gif b/wp-includes/js/tinymce/plugins/wordpress/img/more.gif new file mode 100644 index 0000000..4ff564d Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wordpress/img/more.gif differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif b/wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif new file mode 100644 index 0000000..4589cb4 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/img/page.gif b/wp-includes/js/tinymce/plugins/wordpress/img/page.gif new file mode 100644 index 0000000..1cea78a Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wordpress/img/page.gif differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif b/wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif new file mode 100644 index 0000000..9ea3565 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif b/wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif new file mode 100644 index 0000000..dcb7066 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif b/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif new file mode 100644 index 0000000..3884865 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js deleted file mode 100644 index b431fb6..0000000 --- a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js +++ /dev/null @@ -1,37 +0,0 @@ -// EN lang variables - -if (navigator.userAgent.indexOf('Mac OS') != -1) { -// Mac OS browsers use Ctrl to hit accesskeys - var metaKey = 'Ctrl'; -} -else if (navigator.userAgent.indexOf('Firefox/2') != -1) { -// Firefox 2.x uses Alt+Shift to hit accesskeys - var metaKey = 'Alt+Shift'; -} -else { - var metaKey = 'Alt'; -} - -tinyMCE.addToLang('',{ -wordpress_more_button : 'Split post with More tag (' + metaKey + '+t)', -wordpress_page_button : 'Split post with Page tag', -wordpress_adv_button : 'Show/Hide Advanced Toolbar (' + metaKey + '+v)', -wordpress_more_alt : 'More...', -wordpress_page_alt : '...page...', -help_button_title : 'Help (' + metaKey + '+h)', -bold_desc : 'Bold (Ctrl+B)', -italic_desc : 'Italic (Ctrl+I)', -underline_desc : 'Underline (Ctrl+U)', -link_desc : 'Insert/edit link (' + metaKey + '+a)', -unlink_desc : 'Unlink (' + metaKey + '+s)', -image_desc : 'Insert/edit image (' + metaKey + '+m)', -striketrough_desc : 'Strikethrough (' + metaKey + '+k)', -justifyleft_desc : 'Align left (' + metaKey + '+f)', -justifycenter_desc : 'Align center (' + metaKey + '+c)', -justifyright_desc : 'Align right (' + metaKey + '+r)', -justifyfull_desc : 'Align full (' + metaKey + '+j)', -bullist_desc : 'Unordered list (' + metaKey + '+l)', -numlist_desc : 'Ordered list (' + metaKey + '+o)', -outdent_desc : 'Outdent (' + metaKey + '+w)', -indent_desc : 'Indent list/blockquote (' + metaKey + '+q)' -}); diff --git a/wp-includes/js/tinymce/plugins/wordpress/wordpress.css b/wp-includes/js/tinymce/plugins/wordpress/wordpress.css deleted file mode 100644 index 00b454f..0000000 --- a/wp-includes/js/tinymce/plugins/wordpress/wordpress.css +++ /dev/null @@ -1,81 +0,0 @@ -.mce_plugin_wordpress_more { - border: 0px; - border-top: 1px dotted #cccccc; - display:block; - background-color: #ffffff; - margin-top:15px; - background-image: url(images/more_bug.gif); - background-repeat: no-repeat; - background-position: right top; -} - -.mce_plugin_wordpress_page { - border: 0px; - border-top: 1px dotted #cccccc; - display:block; - background-color: #ffffff; - margin-top:15px; - background-image: url(images/page_bug.gif); - background-repeat: no-repeat; - background-position: right top; -} - -/* This file contains the CSS data for the editable area(iframe) of TinyMCE */ -/* You can extend this CSS by adding your own CSS file with the the content_css option */ - -body { - background: #fff; - font: 1em/1.3em Georgia, "Times New Roman", Times, serif; - padding: .5em; -} - -td { - font-size: 10px; -} - -pre { - font-family: "Courier New", fixed; - font-size: 11px; - line-height: 13px; -} - -.mceVisualAid { - border: 1px dashed #BBBBBB !important; -} - -.mceItemAnchor { - width: 12px; - line-height: 6px; - overflow: hidden; - padding-left: 12px; - background-position: bottom; - background-repeat: no-repeat; -} - -/* Important is needed in Gecko browsers inorder to style links */ -/* -a { - color: green !important; -} -*/ - -/* Style selection range colors in Gecko browsers */ -/* -::-moz-selection { - background-color: red; - color: green; -} -*/ - -/* MSIE specific */ - -* html body { - scrollbar-3dlight-color: #F0F0EE; - scrollbar-arrow-color: #676662; - scrollbar-base-color: #F0F0EE; - scrollbar-darkshadow-color: #DDDDDD; - scrollbar-face-color: #E0E0DD; - scrollbar-highlight-color: #F0F0EE; - scrollbar-shadow-color: #F0F0EE; - scrollbar-track-color: #F5F5F5; -} diff --git a/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js b/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js deleted file mode 100644 index 204e447..0000000 --- a/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js +++ /dev/null @@ -1,57 +0,0 @@ -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('wphelp', ''); - -function TinyMCE_wphelp_getControlHTML(control_name) { - switch (control_name) { - case "wphelp": - var titleHelp = tinyMCE.getLang('lang_help_button_title'); - var buttons = ''; - var hiddenControls = '
    ' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '
    '; - return buttons+hiddenControls; - } - - return ""; -} - -function TinyMCE_wphelp_execCommand(editor_id, element, command, user_interface, value) { - - // Handle commands - switch (command) { - case "mceWordPressHelp": - var template = new Array(); - - template['file'] = tinyMCE.baseURL + '/wp-mce-help.php'; - template['width'] = 480; - template['height'] = 380; - - args = { - resizable : 'yes', - scrollbars : 'yes' - }; - - tinyMCE.openWindow(template, args); - return true; - } - - // Pass to next handler in chain - return false; -} diff --git a/wp-includes/js/tinymce/plugins/wphelp/images/help.gif b/wp-includes/js/tinymce/plugins/wphelp/images/help.gif deleted file mode 100644 index 51a1ee4..0000000 Binary files a/wp-includes/js/tinymce/plugins/wphelp/images/help.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/wphelp/langs/en.js b/wp-includes/js/tinymce/plugins/wphelp/langs/en.js deleted file mode 100644 index b7b2aba..0000000 --- a/wp-includes/js/tinymce/plugins/wphelp/langs/en.js +++ /dev/null @@ -1,5 +0,0 @@ -// EN lang variables - -tinyMCE.addToLang('',{ -help_button_title : 'Help (Alt+h)' -}); diff --git a/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css b/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css deleted file mode 100644 index 4b0360b..0000000 --- a/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css +++ /dev/null @@ -1,53 +0,0 @@ -/* Colorpicker dialog specific CSS */ - -#preview { - float: right; - width: 50px; - height: 14px; - line-height: 1px; - border: 1px solid black; - margin-left: 5px; -} - -#colorpicker { - float: left; - cursor: crosshair; -} - -#light { - border: 1px solid gray; - margin-left: 5px; - float: left; - width: 15px; - cursor: crosshair; -} - -#light div { - overflow: hidden; -} - -#previewblock { - float: right; - padding-left: 10px; - height: 20px; -} - -.panel_wrapper div.current { - height: 175px; -} - -#namedcolors { - width: 150px; -} - -#namedcolors a { - display: block; - float: left; - width: 10px; height: 10px; - margin: 1px 1px 0 0; - overflow: hidden; -} - -#colornamecontainer { - margin-top: 5px; -} \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_content.css b/wp-includes/js/tinymce/themes/advanced/css/editor_content.css deleted file mode 100644 index 182e791..0000000 --- a/wp-includes/js/tinymce/themes/advanced/css/editor_content.css +++ /dev/null @@ -1,58 +0,0 @@ -/* This file contains the CSS data for the editable area(iframe) of TinyMCE */ -/* You can extend this CSS by adding your own CSS file with the the content_css option */ - -body, td, pre { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 10px; -} - -body { - background-color: #FFFFFF; -} - -.mceVisualAid { - border: 1px dashed #BBBBBB !important; -} - -div.mceVisualAid { - background-image:url('../images/spacer.gif'); - visibility: visible !important; -} - -.mceItemAnchor { - width: 12px; - line-height: 6px; - overflow: hidden; - padding-left: 12px; - background-image: url('../images/anchor_symbol.gif'); - background-position: bottom; - background-repeat: no-repeat; -} - -/* Important is needed in Gecko browsers inorder to style links */ -/* -a { - color: green !important; -} -*/ - -/* Style selection range colors in Gecko browsers */ -/* -::-moz-selection { - background-color: red; - color: green; -} -*/ - -/* MSIE specific */ - -* html body { - scrollbar-3dlight-color: #F0F0EE; - scrollbar-arrow-color: #676662; - scrollbar-base-color: #F0F0EE; - scrollbar-darkshadow-color: #DDDDDD; - scrollbar-face-color: #E0E0DD; - scrollbar-highlight-color: #F0F0EE; - scrollbar-shadow-color: #F0F0EE; - scrollbar-track-color: #F5F5F5; -} diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css deleted file mode 100644 index 079470c..0000000 --- a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css +++ /dev/null @@ -1,358 +0,0 @@ -/* This file contains the CSS data for all popups in TinyMCE */ - -body { - background-color: #F0F0EE; - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; - scrollbar-3dlight-color: #F0F0EE; - scrollbar-arrow-color: #676662; - scrollbar-base-color: #F0F0EE; - scrollbar-darkshadow-color: #DDDDDD; - scrollbar-face-color: #E0E0DD; - scrollbar-highlight-color: #F0F0EE; - scrollbar-shadow-color: #F0F0EE; - scrollbar-track-color: #F5F5F5; - margin: 8px; -} - -td { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; -} - -input { - background: #FFFFFF; - border: 1px solid #cccccc; -} - -td, input, select, textarea { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 10px; -} - -input, select, textarea { - border: 1px solid #808080; -} - -.input_noborder { - border: 0; -} - -#insert, .updateButton { - font-weight: bold; - width: 90px; - height: 21px; - border: 0; - background-image: url('../images/insert_button_bg.gif'); - cursor: pointer; -} - -#cancel { - font-weight: bold; - width: 90px; - height: 21px; - border: 0; - background-image: url('../images/cancel_button_bg.gif'); - cursor: pointer; -} - -/* Mozilla only style */ -html>body #insert, html>body #cancel { - padding-bottom: 2px; -} - -.title { - font-size: 12px; - font-weight: bold; - color: #2B6FB6; -} - -table.charmap { - border-style: solid; - border-width: 1px; - border-color: #AAAAAA; -} - -td.charmap, td.charmapOver { - color: #000000; - border-color: #AAAAAA; - border-style: solid; - border-width: 1px; - text-align: center; - font-size: 12px; -} - -td.charmapOver { - background-color: #CCCCCC; - cursor: default; -} - -a.charmap { - color: #000000; - text-decoration: none -} - -.wordWrapCode { - vertical-align: middle; - border: 1px none #000000; - background-color: transparent; -} - -input.radio { - border: 1px none #000000; - background-color: transparent; - vertical-align: middle; -} - -input.checkbox { - border: 1px none #000000; - background-color: transparent; - vertical-align: middle; -} - -.mceButtonNormal, .mceButtonOver, .mceButtonDown, .mceSeparator, .mceButtonDisabled, .mceButtonSelected { - margin-left: 1px; -} - -.mceButtonNormal { - border-top: 1px solid; - border-left: 1px solid; - border-bottom: 1px solid; - border-right: 1px solid; - border-color: #F0F0EE; - cursor: default; -} - -.mceButtonOver { - border: 1px solid #0A246A; - cursor: default; - background-color: #B6BDD2; -} - -.mceButtonDown { - cursor: default; - border: 1px solid #0A246A; - background-color: #8592B5; -} - -.mceButtonDisabled { - filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); - -moz-opacity:0.3; - opacity: 0.3; - border-top: 1px solid; - border-left: 1px solid; - border-bottom: 1px solid; - border-right: 1px solid; - border-color: #F0F0EE; - cursor: default; -} - -.mceActionPanel { - margin-top: 5px; -} - -/* Tabs classes */ - -.tabs { - float: left; - width: 100%; - line-height: normal; - background-image: url("../images/xp/tabs_bg.gif"); -} - -.tabs ul { - margin: 0; - padding: 0 0 0; - list-style: none; -} - -.tabs li { - float: left; - background: url("../images/xp/tab_bg.gif") no-repeat left top; - margin: 0; - margin-left: 0; - margin-right: 2px; - padding: 0 0 0 10px; - line-height: 18px; -} - -.tabs li.current { - background: url("../images/xp/tab_sel_bg.gif") no-repeat left top; - margin-right: 2px; -} - -.tabs span { - float: left; - display: block; - background: url("../images/xp/tab_end.gif") no-repeat right top; - padding: 0px 10px 0 0; -} - -.tabs .current span { - background: url("../images/xp/tab_sel_end.gif") no-repeat right top; -} - -.tabs a { - text-decoration: none; - font-family: Verdana, Arial; - font-size: 10px; -} - -.tabs a:link, .tabs a:visited, .tabs a:hover { - color: black; -} - -.tabs a:hover { -} - -.tabs .current { -} - -.tabs .current a, .tabs .current a:link, .tabs .current a:visited { -} - -.panel_wrapper div.panel { - display: none; -} - -.panel_wrapper div.current { - display: block; - width: 100%; - height: 300px; - overflow: visible; /* Should be auto but that breaks Safari */ -} - -.panel_wrapper { - border: 1px solid #919B9C; - border-top: 0px; - padding: 10px; - padding-top: 5px; - clear: both; - background-color: white; -} - -fieldset { - border: 1px solid #919B9C; - font-family: Verdana, Arial; - font-size: 10px; - padding: 0; - margin: 0; - padding: 4px; -} - -legend { - color: #2B6FB6; - font-weight: bold; -} - -.properties { - width: 100%; -} - -.properties .column1 { -} - -.properties .column2 { - text-align: left; -} - -a:link, a:visited { - color: black; -} - -a:hover { - color: #2B6FB6; -} - -#plugintable thead { - font-weight: bold; - background-color: #DDDDDD; -} - -#plugintable, #about #plugintable td { - border: 1px solid #919B9C; -} - -#plugintable { - width: 99%; - margin-top: 10px; -} - -#pluginscontainer { - height: 290px; - overflow: auto; -} - -/* MSIE Specific styles */ - -* html .panel_wrapper { - width: 100%; -} - -.column { - float: left; -} - -h1, h2, h3, h4 { - color: #2B6FB6; - margin: 0; - padding: 0; - padding-top: 5px; -} - -h3 { - font-size: 14px; -} - -#link .panel_wrapper, #link div.current { - height: 125px; -} - -#image .panel_wrapper, #image div.current { - height: 190px; -} - -label.msg { display: none; } -label.invalid { color: #EE0000; display: inline; } -input.invalid { border: 1px solid #EE0000; } - -/* Disables the advanced tab in the table plugin. */ -/* -#table #advanced_tab { - display: none; -} -*/ - -/* Disables the border input field and label in the table plugin. */ -/* -#table #border, #table #borderlabel { - display: none; -} -*/ - -/* Below this line is WordPress customizations */ -#insert, #cancel, .submitbutton { - font: 11px Verdana, Arial, Helvetica, sans-serif; - height: auto; - width: auto; - background-color: transparent; - background-image: url(../../../../../../wp-admin/images/fade-butt.png); - background-repeat: repeat; - border: 3px double; - border-right-color: rgb(153, 153, 153); - border-bottom-color: rgb(153, 153, 153); - border-left-color: rgb(204, 204, 204); - border-top-color: rgb(204, 204, 204); - color: rgb(51, 51, 51); - padding: 0.1em 0.5em; -} - -#insert:active, #cancel:active, .submitbutton:active { - background: #f4f4f4; - border-left-color: #999; - border-top-color: #999; -} - -#styleSelectRow { - display: none; -} diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css deleted file mode 100644 index 851837d..0000000 --- a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css +++ /dev/null @@ -1,97 +0,0 @@ -/* This file contains the CSS data for the editor UI of TinyMCE instances */ - -.mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover {border: 0; margin: 0; padding: 0; background: transparent;} -.mceSeparatorLine {border: 0; padding: 0; margin-left: 4px; margin-right: 2px;} -.mceSelectList {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 7pt !important; font-weight: normal; margin-top: 3px; padding: 0; display: inline; vertical-align: top; background-color: #F0F0EE;} -.mceLabel, .mceLabelDisabled {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt;} -.mceLabel {color: #000000;} -.mceLabelDisabled {cursor: text; color: #999999;} -.mceEditor {background: #F0F0EE; border: 1px solid #cccccc; padding: 0; margin: 0;} -.mceEditorArea { font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; background: #FFFFFF; padding: 0; margin: 0; } -.mceToolbarTop, .mceToolbarBottom {background: #F0F0EE; line-height: 1px; font-size: 1px;} -.mceToolbarTop {border-bottom: 1px solid #cccccc; padding-bottom: 1px;} -.mceToolbarBottom {border-top: 1px solid #cccccc;} -.mceToolbarContainer {display: block; position: relative; left: 0; top: 0; width: 100%;} -.mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {height: 20px;} -.mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; padding: 2px; line-height: 16px; overflow: visible;} -.mceStatusbarTop {border-bottom: 1px solid #cccccc;} -.mceStatusbarBottom {border-top: 1px solid #cccccc;} -.mceStatusbar {border-bottom: 1px solid #cccccc;} -.mcePathItem, .mcePathItem:link, .mcePathItem:visited, .mcePathItem:hover {text-decoration: none; font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; color: #000000;} -.mcePathItem:hover {text-decoration: underline;} -.mceStatusbarPathText {float: left;} -.mceStatusbarResize {float: right; background-image: url('../images/statusbar_resize.gif'); background-repeat: no-repeat; width: 11px; height: 20px; cursor: se-resize;} -.mceResizeBox {width: 10px; height: 10px; display: none; border: 1px dotted gray; margin: 0; padding: 0;} -.mceEditorIframe {border: 0;} - -/* Button CSS rules */ - -a.mceButtonDisabled img, a.mceButtonNormal img, a.mceButtonSelected img {width: 20px; height: 20px; cursor: default; margin-top: 1px; margin-left: 1px;} -a.mceButtonDisabled img {border: 0 !important;} -a.mceButtonNormal img, a.mceButtonSelected img {border: 1px solid #F0F0EE !important;} -a.mceButtonSelected img {border: 1px solid #6779AA !important; background-color: #D4D5D8;} -a.mceButtonNormal img:hover, a.mceButtonSelected img:hover {border: 1px solid #0A246A !important; cursor: default; background-color: #B6BDD2;} -a.mceButtonDisabled img {-moz-opacity:0.3; opacity: 0.3; border: 1px solid #F0F0EE !important; cursor: default;} -a.mceTiledButton img {background-image: url('../images/buttons.gif'); background-repeat: no-repeat;} - -/* Menu button CSS rules */ - -span.mceMenuButton img, span.mceMenuButtonSelected img {border: 1px solid #F0F0EE; margin-left: 1px;} -span.mceMenuButtonSelected img {border: 1px solid #6779AA; background-color: #B6BDD2;} -span.mceMenuButtonSelected img.mceMenuButton {border: 1px solid #F0F0EE; background-color: transparent;} -span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton {border-left: 0; margin-left: 0;} -span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img {border: 1px solid #0A246A; background-color: #B6BDD2;} -span.mceMenuButton:hover img.mceMenuButton, span.mceMenuButtonSelected:hover img.mceMenuButton {border-left: 0;} -span.mceMenuButtonFocus img {border: 1px solid gray; border-right: 0; margin-left: 1px; background-color: #F5F4F2;} -span.mceMenuButtonFocus img.mceMenuButton {border: 1px solid gray; border-left: 1px solid #F5F4F2; margin-left: 0;} -span.mceMenuHover img {border: 1px solid #0A246A; background-color: #B6BDD2;} -span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {border: 1px solid #0A246A; background-color: #B6BDD2; border-left: 0;} - -/* Menu */ - -.mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 1000; background-color: white; border: 1px solid gray; font-weight: normal;} -.mceMenu a, .mceMenuTitle, .mceMenuDisabled {display: block; width: 100%; text-decoration: none; background-color: white; font-family: Tahoma, Verdana, Arial, Helvetica; font-size: 11px; line-height: 20px; color: black;} -.mceMenu a:hover {background-color: #B6BDD2; color: black; text-decoration: none !important;} -.mceMenu span {padding-left: 10px; padding-right: 10px; display: block; line-height: 20px;} -.mceMenuSeparator {border-bottom: 1px solid gray; background-color: gray; height: 1px;} -.mceMenuTitle span {padding-left: 5px;} -.mceMenuTitle {background-color: #DDDDDD; font-weight: bold;} -.mceMenuDisabled {color: gray;} -span.mceMenuSelectedItem {background-image: url('../images/menu_check.gif'); background-repeat: no-repeat; background-position: 5px 8px; padding-left: 20px;} -span.mceMenuCheckItem {padding-left: 20px;} -span.mceMenuLine {display: block; position: absolute; left: 0; top: -1px; background-color: #F5F4F2; width: 30px; height: 1px; overflow: hidden; padding-left: 0; padding-right: 0;} -.mceColors table, .mceColors td {margin: 0; padding: 2px;} -a.mceMoreColors {width: auto; padding: 0; margin: 0 3px 3px 3px; text-align: center; border: 1px solid white; text-decoration: none !important;} -.mceColorPreview {position: absolute; overflow:hidden; left: 0; top: 0; margin-left: 3px; margin-top: 15px; width: 16px; height: 4px; background-color: red;} -a.mceMoreColors:hover {border: 1px solid #0A246A;} -.mceColors td a {width: 9px; height: 9px; overflow: hidden; border: 1px solid #808080;} - -/* MSIE 6 specific rules */ - -* html a.mceButtonNormal img, * html a.mceButtonSelected img, * html a.mceButtonDisabled img {border: 0 !important; margin-top: 2px; margin-bottom: 1px;} -* html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); border: 0 !important;} -* html a.mceButtonDisabled {border: 1px solid #F0F0EE !important;} -* html a.mceButtonNormal, * html a.mceButtonSelected {border: 1px solid #F0F0EE !important; cursor: default;} -* html a.mceButtonSelected {border: 1px solid #6779AA !important; background-color: #D4D5D8;} -* html a.mceButtonNormal:hover, * html a.mceButtonSelected:hover {border: 1px solid #0A246A !important; background-color: #B6BDD2; cursor: default;} -* html .mceSelectList {margin-top: 2px;} -* html span.mceMenuButton, * html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;} -* html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {position: relative; top: 1px;} -* html a.mceMoreColors {width: auto;} -* html .mceColors td a {width: 10px; height: 10px;} -* html .mceColorPreview {margin-left: 2px; margin-top: 14px;} - -/* MSIE 7 specific rules */ - -*:first-child+html a.mceButtonNormal img, *:first-child+html a.mceButtonSelected img, *:first-child+html a.mceButtonDisabled img {border: 0 !important; margin-top: 2px; margin-bottom: 1px;} -*:first-child+html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); border: 0 !important;} -*:first-child+html a.mceButtonDisabled {border: 1px solid #F0F0EE !important;} -*:first-child+html a.mceButtonNormal, *:first-child+html a.mceButtonSelected {border: 1px solid #F0F0EE !important; cursor: default;} -*:first-child+html a.mceButtonSelected {border: 1px solid #6779AA !important; background-color: #D4D5D8;} -*:first-child+html a.mceButtonNormal:hover, *:first-child+html a.mceButtonSelected:hover {border: 1px solid #0A246A !important; background-color: #B6BDD2; cursor: default;} -*:first-child+html .mceSelectList {margin-top: 2px;} -*:first-child+html span.mceMenuButton, *:first-child+html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;} -*:first-child+html span.mceMenuButton img, *:first-child+html span.mceMenuButtonSelected img, *:first-child+html span.mceMenuButtonFocus img {position: relative; top: 1px;} -*:first-child+html a.mceMoreColors {width: 137px;} -*:first-child+html .mceColors td a {width: 10px; height: 10px;} -*:first-child+html .mceColorPreview {margin: 0; padding-left: 4px; margin-top: 14px; width: 14px;} diff --git a/wp-includes/js/tinymce/themes/advanced/images/anchor.gif b/wp-includes/js/tinymce/themes/advanced/images/anchor.gif deleted file mode 100644 index 34ab715..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/anchor.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/anchor_symbol.gif b/wp-includes/js/tinymce/themes/advanced/images/anchor_symbol.gif deleted file mode 100644 index 2eafd79..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/anchor_symbol.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif b/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif deleted file mode 100644 index d03e206..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold.gif b/wp-includes/js/tinymce/themes/advanced/images/bold.gif deleted file mode 100644 index d6a9cc2..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_de_se.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_de_se.gif deleted file mode 100644 index 9b129de..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold_de_se.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_es.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_es.gif deleted file mode 100644 index ea341e6..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold_es.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_fr.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_fr.gif deleted file mode 100644 index 2816454..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold_fr.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_ru.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_ru.gif deleted file mode 100644 index e000d46..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold_ru.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_tw.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_tw.gif deleted file mode 100644 index 8208543..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold_tw.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/browse.gif b/wp-includes/js/tinymce/themes/advanced/images/browse.gif deleted file mode 100644 index c786d0b..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/browse.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bullist.gif b/wp-includes/js/tinymce/themes/advanced/images/bullist.gif deleted file mode 100644 index 6e19467..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bullist.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/button_menu.gif b/wp-includes/js/tinymce/themes/advanced/images/button_menu.gif deleted file mode 100644 index c3d8fa2..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/button_menu.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/buttons.gif b/wp-includes/js/tinymce/themes/advanced/images/buttons.gif deleted file mode 100644 index 5ad99a7..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/buttons.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/cancel_button_bg.gif b/wp-includes/js/tinymce/themes/advanced/images/cancel_button_bg.gif deleted file mode 100644 index 4b4aeef..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/cancel_button_bg.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/center.gif b/wp-includes/js/tinymce/themes/advanced/images/center.gif deleted file mode 100644 index 42d609a..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/center.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/charmap.gif b/wp-includes/js/tinymce/themes/advanced/images/charmap.gif deleted file mode 100644 index 3cdc4ac..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/charmap.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/cleanup.gif b/wp-includes/js/tinymce/themes/advanced/images/cleanup.gif deleted file mode 100644 index 16491f6..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/cleanup.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/close.gif b/wp-includes/js/tinymce/themes/advanced/images/close.gif deleted file mode 100644 index 679ca2a..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/close.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/code.gif b/wp-includes/js/tinymce/themes/advanced/images/code.gif deleted file mode 100644 index c5d5a67..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/code.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/color.gif b/wp-includes/js/tinymce/themes/advanced/images/color.gif deleted file mode 100644 index 1ecd574..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/color.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/colors.jpg b/wp-includes/js/tinymce/themes/advanced/images/colors.jpg deleted file mode 100644 index b4c542d..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/colors.jpg and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/copy.gif b/wp-includes/js/tinymce/themes/advanced/images/copy.gif deleted file mode 100644 index dc14686..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/copy.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/custom_1.gif b/wp-includes/js/tinymce/themes/advanced/images/custom_1.gif deleted file mode 100644 index 4cbccda..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/custom_1.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/cut.gif b/wp-includes/js/tinymce/themes/advanced/images/cut.gif deleted file mode 100644 index 4e9a70b..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/cut.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif b/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif deleted file mode 100644 index 8b70361..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/full.gif b/wp-includes/js/tinymce/themes/advanced/images/full.gif deleted file mode 100644 index c8504f6..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/full.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/help.gif b/wp-includes/js/tinymce/themes/advanced/images/help.gif deleted file mode 100644 index 51a1ee4..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/help.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/hr.gif b/wp-includes/js/tinymce/themes/advanced/images/hr.gif deleted file mode 100644 index 1a1ba2a..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/hr.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/image.gif b/wp-includes/js/tinymce/themes/advanced/images/image.gif deleted file mode 100644 index 4b88edd..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/image.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/indent.gif b/wp-includes/js/tinymce/themes/advanced/images/indent.gif deleted file mode 100644 index acd315b..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/indent.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/insert_button_bg.gif b/wp-includes/js/tinymce/themes/advanced/images/insert_button_bg.gif deleted file mode 100644 index 69c131c..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/insert_button_bg.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic.gif b/wp-includes/js/tinymce/themes/advanced/images/italic.gif deleted file mode 100644 index 8bb330b..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/italic.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic_de_se.gif b/wp-includes/js/tinymce/themes/advanced/images/italic_de_se.gif deleted file mode 100644 index feb0309..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/italic_de_se.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic_es.gif b/wp-includes/js/tinymce/themes/advanced/images/italic_es.gif deleted file mode 100644 index 4572cdb..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/italic_es.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic_ru.gif b/wp-includes/js/tinymce/themes/advanced/images/italic_ru.gif deleted file mode 100644 index a2bb69a..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/italic_ru.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic_tw.gif b/wp-includes/js/tinymce/themes/advanced/images/italic_tw.gif deleted file mode 100644 index 4f6eeaa..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/italic_tw.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifycenter.gif b/wp-includes/js/tinymce/themes/advanced/images/justifycenter.gif deleted file mode 100644 index 42d609a..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/justifycenter.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifyfull.gif b/wp-includes/js/tinymce/themes/advanced/images/justifyfull.gif deleted file mode 100644 index c8504f6..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/justifyfull.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifyleft.gif b/wp-includes/js/tinymce/themes/advanced/images/justifyleft.gif deleted file mode 100644 index e8f7e42..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/justifyleft.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifyright.gif b/wp-includes/js/tinymce/themes/advanced/images/justifyright.gif deleted file mode 100644 index e4cea97..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/justifyright.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/left.gif b/wp-includes/js/tinymce/themes/advanced/images/left.gif deleted file mode 100644 index e8f7e42..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/left.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/link.gif b/wp-includes/js/tinymce/themes/advanced/images/link.gif deleted file mode 100644 index 1accf42..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/link.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/menu_check.gif b/wp-includes/js/tinymce/themes/advanced/images/menu_check.gif deleted file mode 100644 index 50d6afd..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/menu_check.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/newdocument.gif b/wp-includes/js/tinymce/themes/advanced/images/newdocument.gif deleted file mode 100644 index a9d2938..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/newdocument.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/numlist.gif b/wp-includes/js/tinymce/themes/advanced/images/numlist.gif deleted file mode 100644 index a268352..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/numlist.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/opacity.png b/wp-includes/js/tinymce/themes/advanced/images/opacity.png deleted file mode 100644 index b4217cb..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/opacity.png and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/outdent.gif b/wp-includes/js/tinymce/themes/advanced/images/outdent.gif deleted file mode 100644 index 23f6aa4..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/outdent.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/paste.gif b/wp-includes/js/tinymce/themes/advanced/images/paste.gif deleted file mode 100644 index 1b45000..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/paste.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/redo.gif b/wp-includes/js/tinymce/themes/advanced/images/redo.gif deleted file mode 100644 index 3af9069..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/redo.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/removeformat.gif b/wp-includes/js/tinymce/themes/advanced/images/removeformat.gif deleted file mode 100644 index 0fa3cb7..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/removeformat.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/right.gif b/wp-includes/js/tinymce/themes/advanced/images/right.gif deleted file mode 100644 index e4cea97..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/right.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/separator.gif b/wp-includes/js/tinymce/themes/advanced/images/separator.gif deleted file mode 100644 index 4f39b80..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/separator.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/spacer.gif b/wp-includes/js/tinymce/themes/advanced/images/spacer.gif deleted file mode 100644 index 3884865..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/spacer.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/statusbar_resize.gif b/wp-includes/js/tinymce/themes/advanced/images/statusbar_resize.gif deleted file mode 100644 index af89d80..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/statusbar_resize.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/strikethrough.gif b/wp-includes/js/tinymce/themes/advanced/images/strikethrough.gif deleted file mode 100644 index 3264635..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/strikethrough.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/sub.gif b/wp-includes/js/tinymce/themes/advanced/images/sub.gif deleted file mode 100644 index 4d7ce30..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/sub.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/sup.gif b/wp-includes/js/tinymce/themes/advanced/images/sup.gif deleted file mode 100644 index a7145e0..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/sup.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table.gif b/wp-includes/js/tinymce/themes/advanced/images/table.gif deleted file mode 100644 index 2911830..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_delete_col.gif b/wp-includes/js/tinymce/themes/advanced/images/table_delete_col.gif deleted file mode 100644 index 91f53af..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_delete_col.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_delete_row.gif b/wp-includes/js/tinymce/themes/advanced/images/table_delete_row.gif deleted file mode 100644 index 7025733..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_delete_row.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_after.gif b/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_after.gif deleted file mode 100644 index 8505808..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_after.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_before.gif b/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_before.gif deleted file mode 100644 index b669d4f..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_before.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_after.gif b/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_after.gif deleted file mode 100644 index b9c1446..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_after.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_before.gif b/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_before.gif deleted file mode 100644 index 157d373..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_before.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline.gif b/wp-includes/js/tinymce/themes/advanced/images/underline.gif deleted file mode 100644 index 1dfeb5f..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/underline.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_es.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_es.gif deleted file mode 100644 index 551d914..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/underline_es.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_fr.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_fr.gif deleted file mode 100644 index 551d914..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/underline_fr.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_ru.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_ru.gif deleted file mode 100644 index b78e2a4..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/underline_ru.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_tw.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_tw.gif deleted file mode 100644 index b715390..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/underline_tw.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/undo.gif b/wp-includes/js/tinymce/themes/advanced/images/undo.gif deleted file mode 100644 index 520796d..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/undo.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/unlink.gif b/wp-includes/js/tinymce/themes/advanced/images/unlink.gif deleted file mode 100644 index 5c8a33d..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/unlink.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/visualaid.gif b/wp-includes/js/tinymce/themes/advanced/images/visualaid.gif deleted file mode 100644 index 63caf18..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/visualaid.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_bg.gif b/wp-includes/js/tinymce/themes/advanced/images/xp/tab_bg.gif deleted file mode 100644 index 897a01f..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_bg.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_end.gif b/wp-includes/js/tinymce/themes/advanced/images/xp/tab_end.gif deleted file mode 100644 index aee442b..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_end.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_bg.gif b/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_bg.gif deleted file mode 100644 index 9dc8abe..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_bg.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_end.gif b/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_end.gif deleted file mode 100644 index 616a889..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_end.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/xp/tabs_bg.gif b/wp-includes/js/tinymce/themes/advanced/images/xp/tabs_bg.gif deleted file mode 100644 index c303f66..0000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/xp/tabs_bg.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/img/colorpicker.jpg b/wp-includes/js/tinymce/themes/advanced/img/colorpicker.jpg new file mode 100644 index 0000000..b4c542d Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/img/colorpicker.jpg differ diff --git a/wp-includes/js/tinymce/themes/advanced/img/fm.gif b/wp-includes/js/tinymce/themes/advanced/img/fm.gif new file mode 100644 index 0000000..b5f022b Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/img/fm.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/img/gotmoxie.png b/wp-includes/js/tinymce/themes/advanced/img/gotmoxie.png new file mode 100644 index 0000000..8a396e0 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/img/gotmoxie.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/img/icons.gif b/wp-includes/js/tinymce/themes/advanced/img/icons.gif new file mode 100644 index 0000000..6870827 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/img/icons.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/img/sflogo.png b/wp-includes/js/tinymce/themes/advanced/img/sflogo.png new file mode 100644 index 0000000..142a6f9 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/img/sflogo.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/js/about.js b/wp-includes/js/tinymce/themes/advanced/js/about.js new file mode 100644 index 0000000..277550f --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/js/about.js @@ -0,0 +1,72 @@ +tinyMCEPopup.requireLangPack(); + +function init() { + var ed, tcont; + + tinyMCEPopup.resizeToInnerSize(); + ed = tinyMCEPopup.editor; + + // Give FF some time + window.setTimeout('insertHelpIFrame();', 10); + + tcont = document.getElementById('plugintablecontainer'); + document.getElementById('plugins_tab').style.display = 'none'; + + var html = ""; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + + tinymce.each(ed.plugins, function(p, n) { + var info; + + if (!p.getInfo) + return; + + html += ''; + + info = p.getInfo(); + + if (info.infourl != null && info.infourl != '') + html += ''; + else + html += ''; + + if (info.authorurl != null && info.authorurl != '') + html += ''; + else + html += ''; + + html += ''; + html += ''; + + document.getElementById('plugins_tab').style.display = ''; + + }); + + html += ''; + html += '
    ' + ed.getLang('advanced_dlg.about_plugin') + '' + ed.getLang('advanced_dlg.about_author') + '' + ed.getLang('advanced_dlg.about_version') + '
    ' + info.longname + '' + info.longname + '' + info.author + '' + info.author + '' + info.version + '
    '; + + tcont.innerHTML = html; + + tinyMCEPopup.dom.get('version').innerHTML = tinymce.majorVersion + "." + tinymce.minorVersion; + tinyMCEPopup.dom.get('date').innerHTML = tinymce.releaseDate; +} + +function insertHelpIFrame() { + var html; + + if (tinyMCEPopup.getParam('docs_url')) { + html = ''; + document.getElementById('iframecontainer').innerHTML = html; + document.getElementById('help_tab').style.display = 'block'; + } +} + +tinyMCEPopup.onInit.add(init); diff --git a/wp-includes/js/tinymce/themes/advanced/js/anchor.js b/wp-includes/js/tinymce/themes/advanced/js/anchor.js new file mode 100644 index 0000000..f1d01ea --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/js/anchor.js @@ -0,0 +1,33 @@ +tinyMCEPopup.requireLangPack(); + +var AnchorDialog = { + init : function(ed) { + var action, elm, f = document.forms[0]; + + this.editor = ed; + elm = ed.dom.getParent(ed.selection.getNode(), 'A,IMG'); + v = ed.dom.getAttrib(elm, 'name'); + + if (v) + f.anchorName.value = v; + + f.insert.value = ed.getLang(elm ? 'update' : 'insert'); + }, + + update : function() { + var ed = this.editor; + + tinyMCEPopup.restoreSelection(); + ed.selection.collapse(1); + + // Webkit acts weird if empty inline element is inserted so we need to use a image instead + if (tinymce.isWebKit) + ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('img', {mce_name : 'a', name : document.forms[0].anchorName.value, 'class' : 'mceItemAnchor'})); + else + ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : document.forms[0].anchorName.value, 'class' : 'mceItemAnchor'}, '')); + + tinyMCEPopup.close(); + } +}; + +tinyMCEPopup.onInit.add(AnchorDialog.init, AnchorDialog); diff --git a/wp-includes/js/tinymce/themes/advanced/js/charmap.js b/wp-includes/js/tinymce/themes/advanced/js/charmap.js new file mode 100644 index 0000000..d9fd8d3 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/js/charmap.js @@ -0,0 +1,325 @@ +tinyMCEPopup.requireLangPack(); + +var charmap = [ + [' ', ' ', true, 'no-break space'], + ['&', '&', true, 'ampersand'], + ['"', '"', true, 'quotation mark'], +// finance + ['¢', '¢', true, 'cent sign'], + ['€', '€', true, 'euro sign'], + ['£', '£', true, 'pound sign'], + ['¥', '¥', true, 'yen sign'], +// signs + ['©', '©', true, 'copyright sign'], + ['®', '®', true, 'registered sign'], + ['™', '™', true, 'trade mark sign'], + ['‰', '‰', true, 'per mille sign'], + ['µ', 'µ', true, 'micro sign'], + ['·', '·', true, 'middle dot'], + ['•', '•', true, 'bullet'], + ['…', '…', true, 'three dot leader'], + ['′', '′', true, 'minutes / feet'], + ['″', '″', true, 'seconds / inches'], + ['§', '§', true, 'section sign'], + ['¶', '¶', true, 'paragraph sign'], + ['ß', 'ß', true, 'sharp s / ess-zed'], +// quotations + ['‹', '‹', true, 'single left-pointing angle quotation mark'], + ['›', '›', true, 'single right-pointing angle quotation mark'], + ['«', '«', true, 'left pointing guillemet'], + ['»', '»', true, 'right pointing guillemet'], + ['‘', '‘', true, 'left single quotation mark'], + ['’', '’', true, 'right single quotation mark'], + ['“', '“', true, 'left double quotation mark'], + ['”', '”', true, 'right double quotation mark'], + ['‚', '‚', true, 'single low-9 quotation mark'], + ['„', '„', true, 'double low-9 quotation mark'], + ['<', '<', true, 'less-than sign'], + ['>', '>', true, 'greater-than sign'], + ['≤', '≤', true, 'less-than or equal to'], + ['≥', '≥', true, 'greater-than or equal to'], + ['–', '–', true, 'en dash'], + ['—', '—', true, 'em dash'], + ['¯', '¯', true, 'macron'], + ['‾', '‾', true, 'overline'], + ['¤', '¤', true, 'currency sign'], + ['¦', '¦', true, 'broken bar'], + ['¨', '¨', true, 'diaeresis'], + ['¡', '¡', true, 'inverted exclamation mark'], + ['¿', '¿', true, 'turned question mark'], + ['ˆ', 'ˆ', true, 'circumflex accent'], + ['˜', '˜', true, 'small tilde'], + ['°', '°', true, 'degree sign'], + ['−', '−', true, 'minus sign'], + ['±', '±', true, 'plus-minus sign'], + ['÷', '÷', true, 'division sign'], + ['⁄', '⁄', true, 'fraction slash'], + ['×', '×', true, 'multiplication sign'], + ['¹', '¹', true, 'superscript one'], + ['²', '²', true, 'superscript two'], + ['³', '³', true, 'superscript three'], + ['¼', '¼', true, 'fraction one quarter'], + ['½', '½', true, 'fraction one half'], + ['¾', '¾', true, 'fraction three quarters'], +// math / logical + ['ƒ', 'ƒ', true, 'function / florin'], + ['∫', '∫', true, 'integral'], + ['∑', '∑', true, 'n-ary sumation'], + ['∞', '∞', true, 'infinity'], + ['√', '√', true, 'square root'], + ['∼', '∼', false,'similar to'], + ['≅', '≅', false,'approximately equal to'], + ['≈', '≈', true, 'almost equal to'], + ['≠', '≠', true, 'not equal to'], + ['≡', '≡', true, 'identical to'], + ['∈', '∈', false,'element of'], + ['∉', '∉', false,'not an element of'], + ['∋', '∋', false,'contains as member'], + ['∏', '∏', true, 'n-ary product'], + ['∧', '∧', false,'logical and'], + ['∨', '∨', false,'logical or'], + ['¬', '¬', true, 'not sign'], + ['∩', '∩', true, 'intersection'], + ['∪', '∪', false,'union'], + ['∂', '∂', true, 'partial differential'], + ['∀', '∀', false,'for all'], + ['∃', '∃', false,'there exists'], + ['∅', '∅', false,'diameter'], + ['∇', '∇', false,'backward difference'], + ['∗', '∗', false,'asterisk operator'], + ['∝', '∝', false,'proportional to'], + ['∠', '∠', false,'angle'], +// undefined + ['´', '´', true, 'acute accent'], + ['¸', '¸', true, 'cedilla'], + ['ª', 'ª', true, 'feminine ordinal indicator'], + ['º', 'º', true, 'masculine ordinal indicator'], + ['†', '†', true, 'dagger'], + ['‡', '‡', true, 'double dagger'], +// alphabetical special chars + ['À', 'À', true, 'A - grave'], + ['Á', 'Á', true, 'A - acute'], + ['Â', 'Â', true, 'A - circumflex'], + ['Ã', 'Ã', true, 'A - tilde'], + ['Ä', 'Ä', true, 'A - diaeresis'], + ['Å', 'Å', true, 'A - ring above'], + ['Æ', 'Æ', true, 'ligature AE'], + ['Ç', 'Ç', true, 'C - cedilla'], + ['È', 'È', true, 'E - grave'], + ['É', 'É', true, 'E - acute'], + ['Ê', 'Ê', true, 'E - circumflex'], + ['Ë', 'Ë', true, 'E - diaeresis'], + ['Ì', 'Ì', true, 'I - grave'], + ['Í', 'Í', true, 'I - acute'], + ['Î', 'Î', true, 'I - circumflex'], + ['Ï', 'Ï', true, 'I - diaeresis'], + ['Ð', 'Ð', true, 'ETH'], + ['Ñ', 'Ñ', true, 'N - tilde'], + ['Ò', 'Ò', true, 'O - grave'], + ['Ó', 'Ó', true, 'O - acute'], + ['Ô', 'Ô', true, 'O - circumflex'], + ['Õ', 'Õ', true, 'O - tilde'], + ['Ö', 'Ö', true, 'O - diaeresis'], + ['Ø', 'Ø', true, 'O - slash'], + ['Œ', 'Œ', true, 'ligature OE'], + ['Š', 'Š', true, 'S - caron'], + ['Ù', 'Ù', true, 'U - grave'], + ['Ú', 'Ú', true, 'U - acute'], + ['Û', 'Û', true, 'U - circumflex'], + ['Ü', 'Ü', true, 'U - diaeresis'], + ['Ý', 'Ý', true, 'Y - acute'], + ['Ÿ', 'Ÿ', true, 'Y - diaeresis'], + ['Þ', 'Þ', true, 'THORN'], + ['à', 'à', true, 'a - grave'], + ['á', 'á', true, 'a - acute'], + ['â', 'â', true, 'a - circumflex'], + ['ã', 'ã', true, 'a - tilde'], + ['ä', 'ä', true, 'a - diaeresis'], + ['å', 'å', true, 'a - ring above'], + ['æ', 'æ', true, 'ligature ae'], + ['ç', 'ç', true, 'c - cedilla'], + ['è', 'è', true, 'e - grave'], + ['é', 'é', true, 'e - acute'], + ['ê', 'ê', true, 'e - circumflex'], + ['ë', 'ë', true, 'e - diaeresis'], + ['ì', 'ì', true, 'i - grave'], + ['í', 'í', true, 'i - acute'], + ['î', 'î', true, 'i - circumflex'], + ['ï', 'ï', true, 'i - diaeresis'], + ['ð', 'ð', true, 'eth'], + ['ñ', 'ñ', true, 'n - tilde'], + ['ò', 'ò', true, 'o - grave'], + ['ó', 'ó', true, 'o - acute'], + ['ô', 'ô', true, 'o - circumflex'], + ['õ', 'õ', true, 'o - tilde'], + ['ö', 'ö', true, 'o - diaeresis'], + ['ø', 'ø', true, 'o slash'], + ['œ', 'œ', true, 'ligature oe'], + ['š', 'š', true, 's - caron'], + ['ù', 'ù', true, 'u - grave'], + ['ú', 'ú', true, 'u - acute'], + ['û', 'û', true, 'u - circumflex'], + ['ü', 'ü', true, 'u - diaeresis'], + ['ý', 'ý', true, 'y - acute'], + ['þ', 'þ', true, 'thorn'], + ['ÿ', 'ÿ', true, 'y - diaeresis'], + ['Α', 'Α', true, 'Alpha'], + ['Β', 'Β', true, 'Beta'], + ['Γ', 'Γ', true, 'Gamma'], + ['Δ', 'Δ', true, 'Delta'], + ['Ε', 'Ε', true, 'Epsilon'], + ['Ζ', 'Ζ', true, 'Zeta'], + ['Η', 'Η', true, 'Eta'], + ['Θ', 'Θ', true, 'Theta'], + ['Ι', 'Ι', true, 'Iota'], + ['Κ', 'Κ', true, 'Kappa'], + ['Λ', 'Λ', true, 'Lambda'], + ['Μ', 'Μ', true, 'Mu'], + ['Ν', 'Ν', true, 'Nu'], + ['Ξ', 'Ξ', true, 'Xi'], + ['Ο', 'Ο', true, 'Omicron'], + ['Π', 'Π', true, 'Pi'], + ['Ρ', 'Ρ', true, 'Rho'], + ['Σ', 'Σ', true, 'Sigma'], + ['Τ', 'Τ', true, 'Tau'], + ['Υ', 'Υ', true, 'Upsilon'], + ['Φ', 'Φ', true, 'Phi'], + ['Χ', 'Χ', true, 'Chi'], + ['Ψ', 'Ψ', true, 'Psi'], + ['Ω', 'Ω', true, 'Omega'], + ['α', 'α', true, 'alpha'], + ['β', 'β', true, 'beta'], + ['γ', 'γ', true, 'gamma'], + ['δ', 'δ', true, 'delta'], + ['ε', 'ε', true, 'epsilon'], + ['ζ', 'ζ', true, 'zeta'], + ['η', 'η', true, 'eta'], + ['θ', 'θ', true, 'theta'], + ['ι', 'ι', true, 'iota'], + ['κ', 'κ', true, 'kappa'], + ['λ', 'λ', true, 'lambda'], + ['μ', 'μ', true, 'mu'], + ['ν', 'ν', true, 'nu'], + ['ξ', 'ξ', true, 'xi'], + ['ο', 'ο', true, 'omicron'], + ['π', 'π', true, 'pi'], + ['ρ', 'ρ', true, 'rho'], + ['ς', 'ς', true, 'final sigma'], + ['σ', 'σ', true, 'sigma'], + ['τ', 'τ', true, 'tau'], + ['υ', 'υ', true, 'upsilon'], + ['φ', 'φ', true, 'phi'], + ['χ', 'χ', true, 'chi'], + ['ψ', 'ψ', true, 'psi'], + ['ω', 'ω', true, 'omega'], +// symbols + ['ℵ', 'ℵ', false,'alef symbol'], + ['ϖ', 'ϖ', false,'pi symbol'], + ['ℜ', 'ℜ', false,'real part symbol'], + ['ϑ','ϑ', false,'theta symbol'], + ['ϒ', 'ϒ', false,'upsilon - hook symbol'], + ['℘', '℘', false,'Weierstrass p'], + ['ℑ', 'ℑ', false,'imaginary part'], +// arrows + ['←', '←', true, 'leftwards arrow'], + ['↑', '↑', true, 'upwards arrow'], + ['→', '→', true, 'rightwards arrow'], + ['↓', '↓', true, 'downwards arrow'], + ['↔', '↔', true, 'left right arrow'], + ['↵', '↵', false,'carriage return'], + ['⇐', '⇐', false,'leftwards double arrow'], + ['⇑', '⇑', false,'upwards double arrow'], + ['⇒', '⇒', false,'rightwards double arrow'], + ['⇓', '⇓', false,'downwards double arrow'], + ['⇔', '⇔', false,'left right double arrow'], + ['∴', '∴', false,'therefore'], + ['⊂', '⊂', false,'subset of'], + ['⊃', '⊃', false,'superset of'], + ['⊄', '⊄', false,'not a subset of'], + ['⊆', '⊆', false,'subset of or equal to'], + ['⊇', '⊇', false,'superset of or equal to'], + ['⊕', '⊕', false,'circled plus'], + ['⊗', '⊗', false,'circled times'], + ['⊥', '⊥', false,'perpendicular'], + ['⋅', '⋅', false,'dot operator'], + ['⌈', '⌈', false,'left ceiling'], + ['⌉', '⌉', false,'right ceiling'], + ['⌊', '⌊', false,'left floor'], + ['⌋', '⌋', false,'right floor'], + ['⟨', '〈', false,'left-pointing angle bracket'], + ['⟩', '〉', false,'right-pointing angle bracket'], + ['◊', '◊', true,'lozenge'], + ['♠', '♠', false,'black spade suit'], + ['♣', '♣', true, 'black club suit'], + ['♥', '♥', true, 'black heart suit'], + ['♦', '♦', true, 'black diamond suit'], + [' ', ' ', false,'en space'], + [' ', ' ', false,'em space'], + [' ', ' ', false,'thin space'], + ['‌', '‌', false,'zero width non-joiner'], + ['‍', '‍', false,'zero width joiner'], + ['‎', '‎', false,'left-to-right mark'], + ['‏', '‏', false,'right-to-left mark'], + ['­', '­', false,'soft hyphen'] +]; + +tinyMCEPopup.onInit.add(function() { + tinyMCEPopup.dom.setHTML('charmapView', renderCharMapHTML()); +}); + +function renderCharMapHTML() { + var charsPerRow = 20, tdWidth=20, tdHeight=20, i; + var html = ''; + var cols=-1; + + for (i=0; i' + + '' + + charmap[i][1] + + ''; + if ((cols+1) % charsPerRow == 0) + html += ''; + } + } + + if (cols % charsPerRow > 0) { + var padd = charsPerRow - (cols % charsPerRow); + for (var i=0; i '; + } + + html += '
    '; + + return html; +} + +function insertChar(chr) { + tinyMCEPopup.execCommand('mceInsertContent', false, '&#' + chr + ';'); + + // Refocus in window + if (tinyMCEPopup.isWindow) + window.focus(); + + tinyMCEPopup.editor.focus(); + tinyMCEPopup.close(); +} + +function previewChar(codeA, codeB, codeN) { + var elmA = document.getElementById('codeA'); + var elmB = document.getElementById('codeB'); + var elmV = document.getElementById('codeV'); + var elmN = document.getElementById('codeN'); + + if (codeA=='#160;') { + elmV.innerHTML = '__'; + } else { + elmV.innerHTML = '&' + codeA; + } + + elmB.innerHTML = '&' + codeA; + elmA.innerHTML = '&' + codeB; + elmN.innerHTML = codeN; +} diff --git a/wp-includes/js/tinymce/themes/advanced/js/color_picker.js b/wp-includes/js/tinymce/themes/advanced/js/color_picker.js new file mode 100644 index 0000000..148d7f5 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/js/color_picker.js @@ -0,0 +1,245 @@ +tinyMCEPopup.requireLangPack(); + +var detail = 50, strhex = "0123456789abcdef", i, isMouseDown = false, isMouseOver = false; + +var colors = new Array( + "#000000","#000033","#000066","#000099","#0000cc","#0000ff","#330000","#330033", + "#330066","#330099","#3300cc","#3300ff","#660000","#660033","#660066","#660099", + "#6600cc","#6600ff","#990000","#990033","#990066","#990099","#9900cc","#9900ff", + "#cc0000","#cc0033","#cc0066","#cc0099","#cc00cc","#cc00ff","#ff0000","#ff0033", + "#ff0066","#ff0099","#ff00cc","#ff00ff","#003300","#003333","#003366","#003399", + "#0033cc","#0033ff","#333300","#333333","#333366","#333399","#3333cc","#3333ff", + "#663300","#663333","#663366","#663399","#6633cc","#6633ff","#993300","#993333", + "#993366","#993399","#9933cc","#9933ff","#cc3300","#cc3333","#cc3366","#cc3399", + "#cc33cc","#cc33ff","#ff3300","#ff3333","#ff3366","#ff3399","#ff33cc","#ff33ff", + "#006600","#006633","#006666","#006699","#0066cc","#0066ff","#336600","#336633", + "#336666","#336699","#3366cc","#3366ff","#666600","#666633","#666666","#666699", + "#6666cc","#6666ff","#996600","#996633","#996666","#996699","#9966cc","#9966ff", + "#cc6600","#cc6633","#cc6666","#cc6699","#cc66cc","#cc66ff","#ff6600","#ff6633", + "#ff6666","#ff6699","#ff66cc","#ff66ff","#009900","#009933","#009966","#009999", + "#0099cc","#0099ff","#339900","#339933","#339966","#339999","#3399cc","#3399ff", + "#669900","#669933","#669966","#669999","#6699cc","#6699ff","#999900","#999933", + "#999966","#999999","#9999cc","#9999ff","#cc9900","#cc9933","#cc9966","#cc9999", + "#cc99cc","#cc99ff","#ff9900","#ff9933","#ff9966","#ff9999","#ff99cc","#ff99ff", + "#00cc00","#00cc33","#00cc66","#00cc99","#00cccc","#00ccff","#33cc00","#33cc33", + "#33cc66","#33cc99","#33cccc","#33ccff","#66cc00","#66cc33","#66cc66","#66cc99", + "#66cccc","#66ccff","#99cc00","#99cc33","#99cc66","#99cc99","#99cccc","#99ccff", + "#cccc00","#cccc33","#cccc66","#cccc99","#cccccc","#ccccff","#ffcc00","#ffcc33", + "#ffcc66","#ffcc99","#ffcccc","#ffccff","#00ff00","#00ff33","#00ff66","#00ff99", + "#00ffcc","#00ffff","#33ff00","#33ff33","#33ff66","#33ff99","#33ffcc","#33ffff", + "#66ff00","#66ff33","#66ff66","#66ff99","#66ffcc","#66ffff","#99ff00","#99ff33", + "#99ff66","#99ff99","#99ffcc","#99ffff","#ccff00","#ccff33","#ccff66","#ccff99", + "#ccffcc","#ccffff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff" +); + +var named = { + '#F0F8FF':'AliceBlue','#FAEBD7':'AntiqueWhite','#00FFFF':'Aqua','#7FFFD4':'Aquamarine','#F0FFFF':'Azure','#F5F5DC':'Beige', + '#FFE4C4':'Bisque','#000000':'Black','#FFEBCD':'BlanchedAlmond','#0000FF':'Blue','#8A2BE2':'BlueViolet','#A52A2A':'Brown', + '#DEB887':'BurlyWood','#5F9EA0':'CadetBlue','#7FFF00':'Chartreuse','#D2691E':'Chocolate','#FF7F50':'Coral','#6495ED':'CornflowerBlue', + '#FFF8DC':'Cornsilk','#DC143C':'Crimson','#00FFFF':'Cyan','#00008B':'DarkBlue','#008B8B':'DarkCyan','#B8860B':'DarkGoldenRod', + '#A9A9A9':'DarkGray','#A9A9A9':'DarkGrey','#006400':'DarkGreen','#BDB76B':'DarkKhaki','#8B008B':'DarkMagenta','#556B2F':'DarkOliveGreen', + '#FF8C00':'Darkorange','#9932CC':'DarkOrchid','#8B0000':'DarkRed','#E9967A':'DarkSalmon','#8FBC8F':'DarkSeaGreen','#483D8B':'DarkSlateBlue', + '#2F4F4F':'DarkSlateGray','#2F4F4F':'DarkSlateGrey','#00CED1':'DarkTurquoise','#9400D3':'DarkViolet','#FF1493':'DeepPink','#00BFFF':'DeepSkyBlue', + '#696969':'DimGray','#696969':'DimGrey','#1E90FF':'DodgerBlue','#B22222':'FireBrick','#FFFAF0':'FloralWhite','#228B22':'ForestGreen', + '#FF00FF':'Fuchsia','#DCDCDC':'Gainsboro','#F8F8FF':'GhostWhite','#FFD700':'Gold','#DAA520':'GoldenRod','#808080':'Gray','#808080':'Grey', + '#008000':'Green','#ADFF2F':'GreenYellow','#F0FFF0':'HoneyDew','#FF69B4':'HotPink','#CD5C5C':'IndianRed','#4B0082':'Indigo','#FFFFF0':'Ivory', + '#F0E68C':'Khaki','#E6E6FA':'Lavender','#FFF0F5':'LavenderBlush','#7CFC00':'LawnGreen','#FFFACD':'LemonChiffon','#ADD8E6':'LightBlue', + '#F08080':'LightCoral','#E0FFFF':'LightCyan','#FAFAD2':'LightGoldenRodYellow','#D3D3D3':'LightGray','#D3D3D3':'LightGrey','#90EE90':'LightGreen', + '#FFB6C1':'LightPink','#FFA07A':'LightSalmon','#20B2AA':'LightSeaGreen','#87CEFA':'LightSkyBlue','#778899':'LightSlateGray','#778899':'LightSlateGrey', + '#B0C4DE':'LightSteelBlue','#FFFFE0':'LightYellow','#00FF00':'Lime','#32CD32':'LimeGreen','#FAF0E6':'Linen','#FF00FF':'Magenta','#800000':'Maroon', + '#66CDAA':'MediumAquaMarine','#0000CD':'MediumBlue','#BA55D3':'MediumOrchid','#9370D8':'MediumPurple','#3CB371':'MediumSeaGreen','#7B68EE':'MediumSlateBlue', + '#00FA9A':'MediumSpringGreen','#48D1CC':'MediumTurquoise','#C71585':'MediumVioletRed','#191970':'MidnightBlue','#F5FFFA':'MintCream','#FFE4E1':'MistyRose','#FFE4B5':'Moccasin', + '#FFDEAD':'NavajoWhite','#000080':'Navy','#FDF5E6':'OldLace','#808000':'Olive','#6B8E23':'OliveDrab','#FFA500':'Orange','#FF4500':'OrangeRed','#DA70D6':'Orchid', + '#EEE8AA':'PaleGoldenRod','#98FB98':'PaleGreen','#AFEEEE':'PaleTurquoise','#D87093':'PaleVioletRed','#FFEFD5':'PapayaWhip','#FFDAB9':'PeachPuff', + '#CD853F':'Peru','#FFC0CB':'Pink','#DDA0DD':'Plum','#B0E0E6':'PowderBlue','#800080':'Purple','#FF0000':'Red','#BC8F8F':'RosyBrown','#4169E1':'RoyalBlue', + '#8B4513':'SaddleBrown','#FA8072':'Salmon','#F4A460':'SandyBrown','#2E8B57':'SeaGreen','#FFF5EE':'SeaShell','#A0522D':'Sienna','#C0C0C0':'Silver', + '#87CEEB':'SkyBlue','#6A5ACD':'SlateBlue','#708090':'SlateGray','#708090':'SlateGrey','#FFFAFA':'Snow','#00FF7F':'SpringGreen', + '#4682B4':'SteelBlue','#D2B48C':'Tan','#008080':'Teal','#D8BFD8':'Thistle','#FF6347':'Tomato','#40E0D0':'Turquoise','#EE82EE':'Violet', + '#F5DEB3':'Wheat','#FFFFFF':'White','#F5F5F5':'WhiteSmoke','#FFFF00':'Yellow','#9ACD32':'YellowGreen' +}; + +function init() { + var inputColor = convertRGBToHex(tinyMCEPopup.getWindowArg('input_color')); + + tinyMCEPopup.resizeToInnerSize(); + + generatePicker(); + + if (inputColor) { + changeFinalColor(inputColor); + + col = convertHexToRGB(inputColor); + + if (col) + updateLight(col.r, col.g, col.b); + } +} + +function insertAction() { + var color = document.getElementById("color").value, f = tinyMCEPopup.getWindowArg('func'); + + tinyMCEPopup.restoreSelection(); + + if (f) + f(color); + + tinyMCEPopup.close(); +} + +function showColor(color, name) { + if (name) + document.getElementById("colorname").innerHTML = name; + + document.getElementById("preview").style.backgroundColor = color; + document.getElementById("color").value = color.toLowerCase(); +} + +function convertRGBToHex(col) { + var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi"); + + if (!col) + return col; + + var rgb = col.replace(re, "$1,$2,$3").split(','); + if (rgb.length == 3) { + r = parseInt(rgb[0]).toString(16); + g = parseInt(rgb[1]).toString(16); + b = parseInt(rgb[2]).toString(16); + + r = r.length == 1 ? '0' + r : r; + g = g.length == 1 ? '0' + g : g; + b = b.length == 1 ? '0' + b : b; + + return "#" + r + g + b; + } + + return col; +} + +function convertHexToRGB(col) { + if (col.indexOf('#') != -1) { + col = col.replace(new RegExp('[^0-9A-F]', 'gi'), ''); + + r = parseInt(col.substring(0, 2), 16); + g = parseInt(col.substring(2, 4), 16); + b = parseInt(col.substring(4, 6), 16); + + return {r : r, g : g, b : b}; + } + + return null; +} + +function generatePicker() { + var el = document.getElementById('light'), h = '', i; + + for (i = 0; i < detail; i++){ + h += '
    '; + } + + el.innerHTML = h; +} + +function generateWebColors() { + var el = document.getElementById('webcolors'), h = '', i; + + if (el.className == 'generated') + return; + + h += '' + + ''; + + for (i=0; i' + + '' + + ''; + if ((i+1) % 18 == 0) + h += ''; + } + + h += '
    '; + + el.innerHTML = h; + el.className = 'generated'; +} + +function generateNamedColors() { + var el = document.getElementById('namedcolors'), h = '', n, v, i = 0; + + if (el.className == 'generated') + return; + + for (n in named) { + v = named[n]; + h += '' + } + + el.innerHTML = h; + el.className = 'generated'; +} + +function dechex(n) { + return strhex.charAt(Math.floor(n / 16)) + strhex.charAt(n % 16); +} + +function computeColor(e) { + var x, y, partWidth, partDetail, imHeight, r, g, b, coef, i, finalCoef, finalR, finalG, finalB; + + x = e.offsetX ? e.offsetX : (e.target ? e.clientX - e.target.x : 0); + y = e.offsetY ? e.offsetY : (e.target ? e.clientY - e.target.y : 0); + + partWidth = document.getElementById('colors').width / 6; + partDetail = detail / 2; + imHeight = document.getElementById('colors').height; + + r = (x >= 0)*(x < partWidth)*255 + (x >= partWidth)*(x < 2*partWidth)*(2*255 - x * 255 / partWidth) + (x >= 4*partWidth)*(x < 5*partWidth)*(-4*255 + x * 255 / partWidth) + (x >= 5*partWidth)*(x < 6*partWidth)*255; + g = (x >= 0)*(x < partWidth)*(x * 255 / partWidth) + (x >= partWidth)*(x < 3*partWidth)*255 + (x >= 3*partWidth)*(x < 4*partWidth)*(4*255 - x * 255 / partWidth); + b = (x >= 2*partWidth)*(x < 3*partWidth)*(-2*255 + x * 255 / partWidth) + (x >= 3*partWidth)*(x < 5*partWidth)*255 + (x >= 5*partWidth)*(x < 6*partWidth)*(6*255 - x * 255 / partWidth); + + coef = (imHeight - y) / imHeight; + r = 128 + (r - 128) * coef; + g = 128 + (g - 128) * coef; + b = 128 + (b - 128) * coef; + + changeFinalColor('#' + dechex(r) + dechex(g) + dechex(b)); + updateLight(r, g, b); +} + +function updateLight(r, g, b) { + var i, partDetail = detail / 2, finalCoef, finalR, finalG, finalB, color; + + for (i=0; i=0) && (i'); + }, + + init : function() { + var f = document.forms[0], ed = tinyMCEPopup.editor; + + // Setup browse button + document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image'); + if (isVisible('srcbrowser')) + document.getElementById('src').style.width = '180px'; + + e = ed.selection.getNode(); + + this.fillFileList('image_list', 'tinyMCEImageList'); + + if (e.nodeName == 'IMG') { + f.src.value = ed.dom.getAttrib(e, 'src'); + f.alt.value = ed.dom.getAttrib(e, 'alt'); + f.border.value = this.getAttrib(e, 'border'); + f.vspace.value = this.getAttrib(e, 'vspace'); + f.hspace.value = this.getAttrib(e, 'hspace'); + f.width.value = ed.dom.getAttrib(e, 'width'); + f.height.value = ed.dom.getAttrib(e, 'height'); + f.insert.value = ed.getLang('update'); + f.class_name.value = ed.dom.getAttrib(e, 'class'); + this.styleVal = ed.dom.getAttrib(e, 'style'); + selectByValue(f, 'image_list', f.src.value); + selectByValue(f, 'align', this.getAttrib(e, 'align')); + this.updateStyle(); + } + }, + + fillFileList : function(id, l) { + var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; + + l = window[l]; + + if (l && l.length > 0) { + lst.options[lst.options.length] = new Option('', ''); + + tinymce.each(l, function(o) { + lst.options[lst.options.length] = new Option(o[0], o[1]); + }); + } else + dom.remove(dom.getParent(id, 'tr')); + }, + + update : function() { + var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, args = {}, el; + + tinyMCEPopup.restoreSelection(); + + if (f.src.value === '') { + if (ed.selection.getNode().nodeName == 'IMG') { + ed.dom.remove(ed.selection.getNode()); + ed.execCommand('mceRepaint'); + } + + tinyMCEPopup.close(); + return; + } + + if (!ed.settings.inline_styles) { + args = tinymce.extend(args, { + vspace : nl.vspace.value, + hspace : nl.hspace.value, + border : nl.border.value, + align : getSelectValue(f, 'align') + }); + } else + args.style = this.styleVal; + + tinymce.extend(args, { + src : f.src.value, + alt : f.alt.value, + width : f.width.value, + height : f.height.value, + 'class' : f.class_name.value + }); + + el = ed.selection.getNode(); + + if (el && el.nodeName == 'IMG') { + ed.dom.setAttribs(el, args); + } else { + ed.execCommand('mceInsertContent', false, '', {skip_undo : 1}); + ed.dom.setAttribs('__mce_tmp', args); + ed.dom.setAttrib('__mce_tmp', 'id', ''); + ed.undoManager.add(); + } + + tinyMCEPopup.close(); + }, + + updateStyle : function() { + var dom = tinyMCEPopup.dom, st, v, cls, oldcls, rep, f = document.forms[0]; + + if (tinyMCEPopup.editor.settings.inline_styles) { + st = tinyMCEPopup.dom.parseStyle(this.styleVal); + + // Handle align + v = getSelectValue(f, 'align'); + cls = f.class_name.value || ''; + cls = cls ? cls.replace(/alignright\s*|alignleft\s*/g, '') : ''; + cls = cls ? cls.replace(/^\s*(.+?)\s*$/, '$1') : ''; + if (v) { + if (v == 'left' || v == 'right') { + st['float'] = v; + delete st['vertical-align']; + oldcls = cls ? ' '+cls : ''; + f.class_name.value = 'align' + v + oldcls; + } else { + st['vertical-align'] = v; + delete st['float']; + f.class_name.value = cls; + } + } else { + delete st['float']; + delete st['vertical-align']; + f.class_name.value = cls; + } + + // Handle border + v = f.border.value; + if (v || v == '0') { + if (v == '0') + st['border'] = '0'; + else + st['border'] = v + 'px solid black'; + } else + delete st['border']; + + // Handle hspace + v = f.hspace.value; + if (v) { + delete st['margin']; + st['margin-left'] = v + 'px'; + st['margin-right'] = v + 'px'; + } else { + delete st['margin-left']; + delete st['margin-right']; + } + + // Handle vspace + v = f.vspace.value; + if (v) { + delete st['margin']; + st['margin-top'] = v + 'px'; + st['margin-bottom'] = v + 'px'; + } else { + delete st['margin-top']; + delete st['margin-bottom']; + } + + // Merge + st = tinyMCEPopup.dom.parseStyle(dom.serializeStyle(st)); + this.styleVal = dom.serializeStyle(st); + } + }, + + getAttrib : function(e, at) { + var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2; + + if (ed.settings.inline_styles) { + switch (at) { + case 'align': + if (v = dom.getStyle(e, 'float')) + return v; + + if (v = dom.getStyle(e, 'vertical-align')) + return v; + + break; + + case 'hspace': + v = dom.getStyle(e, 'margin-left') + v2 = dom.getStyle(e, 'margin-right'); + if (v && v == v2) + return parseInt(v.replace(/[^0-9]/g, '')); + + break; + + case 'vspace': + v = dom.getStyle(e, 'margin-top') + v2 = dom.getStyle(e, 'margin-bottom'); + if (v && v == v2) + return parseInt(v.replace(/[^0-9]/g, '')); + + break; + + case 'border': + v = 0; + + tinymce.each(['top', 'right', 'bottom', 'left'], function(sv) { + sv = dom.getStyle(e, 'border-' + sv + '-width'); + + // False or not the same as prev + if (!sv || (sv != v && v !== 0)) { + v = 0; + return false; + } + + if (sv) + v = sv; + }); + + if (v) + return parseInt(v.replace(/[^0-9]/g, '')); + + break; + } + } + + if (v = dom.getAttrib(e, at)) + return v; + + return ''; + }, + + resetImageData : function() { + var f = document.forms[0]; + + f.width.value = f.height.value = ""; + }, + + updateImageData : function() { + var f = document.forms[0], t = ImageDialog; + + if (f.width.value == "") + f.width.value = t.preloadImg.width; + + if (f.height.value == "") + f.height.value = t.preloadImg.height; + }, + + getImageData : function() { + var f = document.forms[0]; + + this.preloadImg = new Image(); + this.preloadImg.onload = this.updateImageData; + this.preloadImg.onerror = this.resetImageData; + this.preloadImg.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.src.value); + } +}; + +ImageDialog.preInit(); +tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog); diff --git a/wp-includes/js/tinymce/themes/advanced/js/link.js b/wp-includes/js/tinymce/themes/advanced/js/link.js new file mode 100644 index 0000000..bf310a3 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/js/link.js @@ -0,0 +1,126 @@ +tinyMCEPopup.requireLangPack(); + +var LinkDialog = { + preInit : function() { + var url; + + if (url = tinyMCEPopup.getParam("external_link_list_url")) + document.write(''); + }, + + init : function() { + var f = document.forms[0], ed = tinyMCEPopup.editor; + + // Setup browse button + document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser', 'href', 'file', 'theme_advanced_link'); + if (isVisible('hrefbrowser')) + document.getElementById('href').style.width = '180px'; + + this.fillClassList('class_list'); + this.fillFileList('link_list', 'tinyMCELinkList'); + this.fillTargetList('target_list'); + + if (e = ed.dom.getParent(ed.selection.getNode(), 'A')) { + f.href.value = ed.dom.getAttrib(e, 'href'); + f.linktitle.value = ed.dom.getAttrib(e, 'title'); + f.insert.value = ed.getLang('update'); + selectByValue(f, 'link_list', f.href.value); + selectByValue(f, 'target_list', ed.dom.getAttrib(e, 'target')); + selectByValue(f, 'class_list', ed.dom.getAttrib(e, 'class')); + } + }, + + update : function() { + var f = document.forms[0], ed = tinyMCEPopup.editor, e, b; + + tinyMCEPopup.restoreSelection(); + + // Remove element if there is no href + if (!f.href.value) { + e = ed.dom.getParent(ed.selection.getNode(), 'A'); + if (e) { + tinyMCEPopup.execCommand("mceBeginUndoLevel"); + b = ed.selection.getBookmark(); + ed.dom.remove(e, 1); + ed.selection.moveToBookmark(b); + tinyMCEPopup.execCommand("mceEndUndoLevel"); + tinyMCEPopup.close(); + return; + } + } + + ed.execCommand('mceInsertLink', false, { + href : f.href.value, + title : f.linktitle.value, + target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null, + 'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null + }); + + tinyMCEPopup.close(); + }, + + checkPrefix : function(n) { + if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_email'))) + n.value = 'mailto:' + n.value; + + if (/^\s*www./i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_external'))) + n.value = 'http://' + n.value; + }, + + fillFileList : function(id, l) { + var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; + + l = window[l]; + + if (l && l.length > 0) { + lst.options[lst.options.length] = new Option('', ''); + + tinymce.each(l, function(o) { + lst.options[lst.options.length] = new Option(o[0], o[1]); + }); + } else + dom.remove(dom.getParent(id, 'tr')); + }, + + fillClassList : function(id) { + var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; + + if (v = tinyMCEPopup.getParam('theme_advanced_styles')) { + cl = []; + + tinymce.each(v.split(';'), function(v) { + var p = v.split('='); + + cl.push({'title' : p[0], 'class' : p[1]}); + }); + } else + cl = tinyMCEPopup.editor.dom.getClasses(); + + if (cl.length > 0) { + lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), ''); + + tinymce.each(cl, function(o) { + lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']); + }); + } else + dom.remove(dom.getParent(id, 'tr')); + }, + + fillTargetList : function(id) { + var dom = tinyMCEPopup.dom, lst = dom.get(id), v; + + lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), ''); + lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_same'), '_self'); + lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_blank'), '_blank'); + + if (v = tinyMCEPopup.getParam('theme_advanced_link_targets')) { + tinymce.each(v.split(','), function(v) { + v = v.split('='); + html += ''; + }); + } + } +}; + +LinkDialog.preInit(); +tinyMCEPopup.onInit.add(LinkDialog.init, LinkDialog); diff --git a/wp-includes/js/tinymce/themes/advanced/js/source_editor.js b/wp-includes/js/tinymce/themes/advanced/js/source_editor.js new file mode 100644 index 0000000..a6235a3 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/js/source_editor.js @@ -0,0 +1,62 @@ +tinyMCEPopup.requireLangPack(); +tinyMCEPopup.onInit.add(onLoadInit); + +function saveContent() { + tinyMCEPopup.editor.setContent(document.getElementById('htmlSource').value); + tinyMCEPopup.close(); +} + +function onLoadInit() { + tinyMCEPopup.resizeToInnerSize(); + + // Remove Gecko spellchecking + if (tinymce.isGecko) + document.body.spellcheck = tinyMCEPopup.editor.getParam("gecko_spellcheck"); + + document.getElementById('htmlSource').value = tinyMCEPopup.editor.getContent(); + + if (tinyMCEPopup.editor.getParam("theme_advanced_source_editor_wrap", true)) { + setWrap('soft'); + document.getElementById('wraped').checked = true; + } + + resizeInputs(); +} + +function setWrap(val) { + var v, n, s = document.getElementById('htmlSource'); + + s.wrap = val; + + if (!tinymce.isIE) { + v = s.value; + n = s.cloneNode(false); + n.setAttribute("wrap", val); + s.parentNode.replaceChild(n, s); + n.value = v; + } +} + +function toggleWordWrap(elm) { + if (elm.checked) + setWrap('soft'); + else + setWrap('off'); +} + +var wHeight=0, wWidth=0, owHeight=0, owWidth=0; + +function resizeInputs() { + var el = document.getElementById('htmlSource'); + + if (!tinymce.isIE) { + wHeight = self.innerHeight - 65; + wWidth = self.innerWidth - 16; + } else { + wHeight = document.body.clientHeight - 70; + wWidth = document.body.clientWidth - 16; + } + + el.style.height = Math.abs(wHeight) + 'px'; + el.style.width = Math.abs(wWidth) + 'px'; +} diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/about.js b/wp-includes/js/tinymce/themes/advanced/jscripts/about.js deleted file mode 100644 index f60e6f6..0000000 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/about.js +++ /dev/null @@ -1,75 +0,0 @@ -function init() { - var inst; - - tinyMCEPopup.resizeToInnerSize(); - inst = tinyMCE.selectedInstance; - - // Give FF some time - window.setTimeout('insertHelpIFrame();', 10); - - var tcont = document.getElementById('plugintablecontainer'); - var plugins = tinyMCE.getParam('plugins', '', true, ','); - if (plugins.length == 0) - document.getElementById('plugins_tab').style.display = 'none'; - - var html = ""; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - - for (var i=0; i' + info.longname + ''; - else - html += ''; - - if (info.authorurl != null && info.authorurl != '') - html += ''; - else - html += ''; - - html += ''; - html += ''; - } - - html += ''; - html += '
    ' + tinyMCE.getLang('lang_plugin') + '' + tinyMCE.getLang('lang_author') + '' + tinyMCE.getLang('lang_version') + '
    ' + info.longname + '' + info.author + '' + info.author + '' + info.version + '
    '; - - tcont.innerHTML = html; -} - -function getPluginInfo(name) { - if (tinyMCE.plugins[name].getInfo) - return tinyMCE.plugins[name].getInfo(); - - return { - longname : name, - authorurl : '', - infourl : '', - author : '--', - version : '--' - }; -} - -function insertHelpIFrame() { - var html = ''; - - document.getElementById('iframecontainer').innerHTML = html; - - html = ''; - html += 'Got Moxie? '; - html += 'Hosted By Sourceforge '; - html += 'Also on freshmeat '; - - document.getElementById('buttoncontainer').innerHTML = html; -} diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js b/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js deleted file mode 100644 index f2e5d48..0000000 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js +++ /dev/null @@ -1,74 +0,0 @@ -var action, element; - -function init() { - tinyMCEPopup.resizeToInnerSize(); - - var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id')); - var anchor = tinyMCE.getParentElement(inst.getFocusElement(), "a", "name"); - var img = inst.getFocusElement(); - action = 'insert'; - - if (anchor != null) { - element = anchor; - action = "update"; - } - - if (tinyMCE.getAttrib(img, "class") == "mceItemAnchor") { - element = img; - action = "update"; - } - - if (action == "update") - document.forms[0].anchorName.value = element.nodeName == "IMG" ? element.getAttribute("title") : element.getAttribute("name"); - - document.forms[0].insert.value = tinyMCE.getLang('lang_' + action, 'Insert', true); -} - -function insertAnchor() { - var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id')); - var name = document.forms[0].anchorName.value, e; - - tinyMCEPopup.execCommand("mceBeginUndoLevel"); - - if (action == "update") { - if (element.nodeName == "IMG") - element.setAttribute("title", name); - else - element.setAttribute("name", name); - } else { - var rng = inst.getRng(); - - if (rng.collapse) - rng.collapse(false); - - name = name.replace(/&/g, '&'); - name = name.replace(/\"/g, '"'); - name = name.replace(//g, '>'); - - // Fix for bug #1447335 - if (tinyMCE.isGecko) - html = ''; - else - html = ''; - - tinyMCEPopup.execCommand("mceInsertContent", false, html); - - // Fix for bug #1447335 force cursor after the anchor element - if (tinyMCE.isGecko) { - e = inst.getDoc().getElementById('mceNewAnchor'); - - if (e) { - inst.selection.selectNode(e, true, false, false); - e.removeAttribute('id'); - } - } - - tinyMCE.handleVisualAid(inst.getBody(), true, inst.visualAid, inst); - } - - tinyMCEPopup.execCommand("mceEndUndoLevel"); - - tinyMCE.triggerNodeChange(); - tinyMCEPopup.close(); -} diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js b/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js deleted file mode 100644 index c4ec326..0000000 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js +++ /dev/null @@ -1,326 +0,0 @@ -function init() { - tinyMCEPopup.resizeToInnerSize(); -} - -var charmap = new Array(); - -// for mor details please see w3c.org -// now here is the complete list ;) - -charmap = [ - [' ', ' ', true, 'no-break space'], - ['&', '&', true, 'ampersand'], - ['"', '"', true, 'quotation mark'], -// finance - ['¢', '¢', true, 'cent sign'], - ['€', '€', true, 'euro sign'], - ['£', '£', true, 'pound sign'], - ['¥', '¥', true, 'yen sign'], -// signs - ['©', '©', true, 'copyright sign'], - ['®', '®', true, 'registered sign'], - ['™', '™', true, 'trade mark sign'], - ['‰', '‰', true, 'per mille sign'], - ['µ', 'µ', true, 'micro sign'], - ['·', '·', true, 'middle dot'], - ['•', '•', true, 'bullet'], - ['…', '…', true, 'three dot leader'], - ['′', '′', true, 'minutes / feet'], - ['″', '″', true, 'seconds / inches'], - ['§', '§', true, 'section sign'], - ['¶', '¶', true, 'paragraph sign'], - ['ß', 'ß', true, 'sharp s / ess-zed'], -// quotations - ['‹', '‹', true, 'single left-pointing angle quotation mark'], - ['›', '›', true, 'single right-pointing angle quotation mark'], - ['«', '«', true, 'left pointing guillemet'], - ['»', '»', true, 'right pointing guillemet'], - ['‘', '‘', true, 'left single quotation mark'], - ['’', '’', true, 'right single quotation mark'], - ['“', '“', true, 'left double quotation mark'], - ['”', '”', true, 'right double quotation mark'], - ['‚', '‚', true, 'single low-9 quotation mark'], - ['„', '„', true, 'double low-9 quotation mark'], - ['<', '<', true, 'less-than sign'], - ['>', '>', true, 'greater-than sign'], - ['≤', '≤', true, 'less-than or equal to'], - ['≥', '≥', true, 'greater-than or equal to'], - ['–', '–', true, 'en dash'], - ['—', '—', true, 'em dash'], - ['¯', '¯', true, 'macron'], - ['‾', '‾', true, 'overline'], - ['¤', '¤', true, 'currency sign'], - ['¦', '¦', true, 'broken bar'], - ['¨', '¨', true, 'diaeresis'], - ['¡', '¡', true, 'inverted exclamation mark'], - ['¿', '¿', true, 'turned question mark'], - ['ˆ', 'ˆ', true, 'circumflex accent'], - ['˜', '˜', true, 'small tilde'], - ['°', '°', true, 'degree sign'], - ['−', '−', true, 'minus sign'], - ['±', '±', true, 'plus-minus sign'], - ['÷', '÷', true, 'division sign'], - ['⁄', '⁄', true, 'fraction slash'], - ['×', '×', true, 'multiplication sign'], - ['¹', '¹', true, 'superscript one'], - ['²', '²', true, 'superscript two'], - ['³', '³', true, 'superscript three'], - ['¼', '¼', true, 'fraction one quarter'], - ['½', '½', true, 'fraction one half'], - ['¾', '¾', true, 'fraction three quarters'], -// math / logical - ['ƒ', 'ƒ', true, 'function / florin'], - ['∫', '∫', true, 'integral'], - ['∑', '∑', true, 'n-ary sumation'], - ['∞', '∞', true, 'infinity'], - ['√', '√', true, 'square root'], - ['∼', '∼', false,'similar to'], - ['≅', '≅', false,'approximately equal to'], - ['≈', '≈', true, 'almost equal to'], - ['≠', '≠', true, 'not equal to'], - ['≡', '≡', true, 'identical to'], - ['∈', '∈', false,'element of'], - ['∉', '∉', false,'not an element of'], - ['∋', '∋', false,'contains as member'], - ['∏', '∏', true, 'n-ary product'], - ['∧', '∧', false,'logical and'], - ['∨', '∨', false,'logical or'], - ['¬', '¬', true, 'not sign'], - ['∩', '∩', true, 'intersection'], - ['∪', '∪', false,'union'], - ['∂', '∂', true, 'partial differential'], - ['∀', '∀', false,'for all'], - ['∃', '∃', false,'there exists'], - ['∅', '∅', false,'diameter'], - ['∇', '∇', false,'backward difference'], - ['∗', '∗', false,'asterisk operator'], - ['∝', '∝', false,'proportional to'], - ['∠', '∠', false,'angle'], -// undefined - ['´', '´', true, 'acute accent'], - ['¸', '¸', true, 'cedilla'], - ['ª', 'ª', true, 'feminine ordinal indicator'], - ['º', 'º', true, 'masculine ordinal indicator'], - ['†', '†', true, 'dagger'], - ['‡', '‡', true, 'double dagger'], -// alphabetical special chars - ['À', 'À', true, 'A - grave'], - ['Á', 'Á', true, 'A - acute'], - ['Â', 'Â', true, 'A - circumflex'], - ['Ã', 'Ã', true, 'A - tilde'], - ['Ä', 'Ä', true, 'A - diaeresis'], - ['Å', 'Å', true, 'A - ring above'], - ['Æ', 'Æ', true, 'ligature AE'], - ['Ç', 'Ç', true, 'C - cedilla'], - ['È', 'È', true, 'E - grave'], - ['É', 'É', true, 'E - acute'], - ['Ê', 'Ê', true, 'E - circumflex'], - ['Ë', 'Ë', true, 'E - diaeresis'], - ['Ì', 'Ì', true, 'I - grave'], - ['Í', 'Í', true, 'I - acute'], - ['Î', 'Î', true, 'I - circumflex'], - ['Ï', 'Ï', true, 'I - diaeresis'], - ['Ð', 'Ð', true, 'ETH'], - ['Ñ', 'Ñ', true, 'N - tilde'], - ['Ò', 'Ò', true, 'O - grave'], - ['Ó', 'Ó', true, 'O - acute'], - ['Ô', 'Ô', true, 'O - circumflex'], - ['Õ', 'Õ', true, 'O - tilde'], - ['Ö', 'Ö', true, 'O - diaeresis'], - ['Ø', 'Ø', true, 'O - slash'], - ['Œ', 'Œ', true, 'ligature OE'], - ['Š', 'Š', true, 'S - caron'], - ['Ù', 'Ù', true, 'U - grave'], - ['Ú', 'Ú', true, 'U - acute'], - ['Û', 'Û', true, 'U - circumflex'], - ['Ü', 'Ü', true, 'U - diaeresis'], - ['Ý', 'Ý', true, 'Y - acute'], - ['Ÿ', 'Ÿ', true, 'Y - diaeresis'], - ['Þ', 'Þ', true, 'THORN'], - ['à', 'à', true, 'a - grave'], - ['á', 'á', true, 'a - acute'], - ['â', 'â', true, 'a - circumflex'], - ['ã', 'ã', true, 'a - tilde'], - ['ä', 'ä', true, 'a - diaeresis'], - ['å', 'å', true, 'a - ring above'], - ['æ', 'æ', true, 'ligature ae'], - ['ç', 'ç', true, 'c - cedilla'], - ['è', 'è', true, 'e - grave'], - ['é', 'é', true, 'e - acute'], - ['ê', 'ê', true, 'e - circumflex'], - ['ë', 'ë', true, 'e - diaeresis'], - ['ì', 'ì', true, 'i - grave'], - ['í', 'í', true, 'i - acute'], - ['î', 'î', true, 'i - circumflex'], - ['ï', 'ï', true, 'i - diaeresis'], - ['ð', 'ð', true, 'eth'], - ['ñ', 'ñ', true, 'n - tilde'], - ['ò', 'ò', true, 'o - grave'], - ['ó', 'ó', true, 'o - acute'], - ['ô', 'ô', true, 'o - circumflex'], - ['õ', 'õ', true, 'o - tilde'], - ['ö', 'ö', true, 'o - diaeresis'], - ['ø', 'ø', true, 'o slash'], - ['œ', 'œ', true, 'ligature oe'], - ['š', 'š', true, 's - caron'], - ['ù', 'ù', true, 'u - grave'], - ['ú', 'ú', true, 'u - acute'], - ['û', 'û', true, 'u - circumflex'], - ['ü', 'ü', true, 'u - diaeresis'], - ['ý', 'ý', true, 'y - acute'], - ['þ', 'þ', true, 'thorn'], - ['ÿ', 'ÿ', true, 'y - diaeresis'], - ['Α', 'Α', true, 'Alpha'], - ['Β', 'Β', true, 'Beta'], - ['Γ', 'Γ', true, 'Gamma'], - ['Δ', 'Δ', true, 'Delta'], - ['Ε', 'Ε', true, 'Epsilon'], - ['Ζ', 'Ζ', true, 'Zeta'], - ['Η', 'Η', true, 'Eta'], - ['Θ', 'Θ', true, 'Theta'], - ['Ι', 'Ι', true, 'Iota'], - ['Κ', 'Κ', true, 'Kappa'], - ['Λ', 'Λ', true, 'Lambda'], - ['Μ', 'Μ', true, 'Mu'], - ['Ν', 'Ν', true, 'Nu'], - ['Ξ', 'Ξ', true, 'Xi'], - ['Ο', 'Ο', true, 'Omicron'], - ['Π', 'Π', true, 'Pi'], - ['Ρ', 'Ρ', true, 'Rho'], - ['Σ', 'Σ', true, 'Sigma'], - ['Τ', 'Τ', true, 'Tau'], - ['Υ', 'Υ', true, 'Upsilon'], - ['Φ', 'Φ', true, 'Phi'], - ['Χ', 'Χ', true, 'Chi'], - ['Ψ', 'Ψ', true, 'Psi'], - ['Ω', 'Ω', true, 'Omega'], - ['α', 'α', true, 'alpha'], - ['β', 'β', true, 'beta'], - ['γ', 'γ', true, 'gamma'], - ['δ', 'δ', true, 'delta'], - ['ε', 'ε', true, 'epsilon'], - ['ζ', 'ζ', true, 'zeta'], - ['η', 'η', true, 'eta'], - ['θ', 'θ', true, 'theta'], - ['ι', 'ι', true, 'iota'], - ['κ', 'κ', true, 'kappa'], - ['λ', 'λ', true, 'lambda'], - ['μ', 'μ', true, 'mu'], - ['ν', 'ν', true, 'nu'], - ['ξ', 'ξ', true, 'xi'], - ['ο', 'ο', true, 'omicron'], - ['π', 'π', true, 'pi'], - ['ρ', 'ρ', true, 'rho'], - ['ς', 'ς', true, 'final sigma'], - ['σ', 'σ', true, 'sigma'], - ['τ', 'τ', true, 'tau'], - ['υ', 'υ', true, 'upsilon'], - ['φ', 'φ', true, 'phi'], - ['χ', 'χ', true, 'chi'], - ['ψ', 'ψ', true, 'psi'], - ['ω', 'ω', true, 'omega'], -// symbols - ['ℵ', 'ℵ', false,'alef symbol'], - ['ϖ', 'ϖ', false,'pi symbol'], - ['ℜ', 'ℜ', false,'real part symbol'], - ['ϑ','ϑ', false,'theta symbol'], - ['ϒ', 'ϒ', false,'upsilon - hook symbol'], - ['℘', '℘', false,'Weierstrass p'], - ['ℑ', 'ℑ', false,'imaginary part'], -// arrows - ['←', '←', true, 'leftwards arrow'], - ['↑', '↑', true, 'upwards arrow'], - ['→', '→', true, 'rightwards arrow'], - ['↓', '↓', true, 'downwards arrow'], - ['↔', '↔', true, 'left right arrow'], - ['↵', '↵', false,'carriage return'], - ['⇐', '⇐', false,'leftwards double arrow'], - ['⇑', '⇑', false,'upwards double arrow'], - ['⇒', '⇒', false,'rightwards double arrow'], - ['⇓', '⇓', false,'downwards double arrow'], - ['⇔', '⇔', false,'left right double arrow'], - ['∴', '∴', false,'therefore'], - ['⊂', '⊂', false,'subset of'], - ['⊃', '⊃', false,'superset of'], - ['⊄', '⊄', false,'not a subset of'], - ['⊆', '⊆', false,'subset of or equal to'], - ['⊇', '⊇', false,'superset of or equal to'], - ['⊕', '⊕', false,'circled plus'], - ['⊗', '⊗', false,'circled times'], - ['⊥', '⊥', false,'perpendicular'], - ['⋅', '⋅', false,'dot operator'], - ['⌈', '⌈', false,'left ceiling'], - ['⌉', '⌉', false,'right ceiling'], - ['⌊', '⌊', false,'left floor'], - ['⌋', '⌋', false,'right floor'], - ['⟨', '〈', false,'left-pointing angle bracket'], - ['⟩', '〉', false,'right-pointing angle bracket'], - ['◊', '◊', true,'lozenge'], - ['♠', '♠', false,'black spade suit'], - ['♣', '♣', true, 'black club suit'], - ['♥', '♥', true, 'black heart suit'], - ['♦', '♦', true, 'black diamond suit'], - [' ', ' ', false,'en space'], - [' ', ' ', false,'em space'], - [' ', ' ', false,'thin space'], - ['‌', '‌', false,'zero width non-joiner'], - ['‍', '‍', false,'zero width joiner'], - ['‎', '‎', false,'left-to-right mark'], - ['‏', '‏', false,'right-to-left mark'], - ['­', '­', false,'soft hyphen'] -]; - -function renderCharMapHTML() { - var charsPerRow = 20, tdWidth=20, tdHeight=20; - var html = ''; - var cols=-1; - for (var i=0; i' - + charmap[i][1] - + ''; - if ((cols+1) % charsPerRow == 0) - html += ''; - } - } - if (cols % charsPerRow > 0) { - var padd = charsPerRow - (cols % charsPerRow); - for (var i=0; i '; - } - html += '
    '; - document.write(html); -} - -function insertChar(chr) { - tinyMCEPopup.execCommand('mceInsertContent', false, '&#' + chr + ';'); - - // Refocus in window - if (tinyMCEPopup.isWindow) - window.focus(); - - tinyMCEPopup.close(); -} - -function previewChar(codeA, codeB, codeN) { - var elmA = document.getElementById('codeA'); - var elmB = document.getElementById('codeB'); - var elmV = document.getElementById('codeV'); - var elmN = document.getElementById('codeN'); - - if (codeA=='#160;') { - elmV.innerHTML = '__'; - } else { - elmV.innerHTML = '&' + codeA; - } - - elmB.innerHTML = '&' + codeA; - elmA.innerHTML = '&' + codeB; - elmN.innerHTML = codeN; -} diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js b/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js deleted file mode 100644 index 9236fd0..0000000 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js +++ /dev/null @@ -1,240 +0,0 @@ -var detail = 50, strhex = "0123456789abcdef", i, isMouseDown = false, isMouseOver = false; - -var colors = new Array( - "#000000","#000033","#000066","#000099","#0000cc","#0000ff","#330000","#330033", - "#330066","#330099","#3300cc","#3300ff","#660000","#660033","#660066","#660099", - "#6600cc","#6600ff","#990000","#990033","#990066","#990099","#9900cc","#9900ff", - "#cc0000","#cc0033","#cc0066","#cc0099","#cc00cc","#cc00ff","#ff0000","#ff0033", - "#ff0066","#ff0099","#ff00cc","#ff00ff","#003300","#003333","#003366","#003399", - "#0033cc","#0033ff","#333300","#333333","#333366","#333399","#3333cc","#3333ff", - "#663300","#663333","#663366","#663399","#6633cc","#6633ff","#993300","#993333", - "#993366","#993399","#9933cc","#9933ff","#cc3300","#cc3333","#cc3366","#cc3399", - "#cc33cc","#cc33ff","#ff3300","#ff3333","#ff3366","#ff3399","#ff33cc","#ff33ff", - "#006600","#006633","#006666","#006699","#0066cc","#0066ff","#336600","#336633", - "#336666","#336699","#3366cc","#3366ff","#666600","#666633","#666666","#666699", - "#6666cc","#6666ff","#996600","#996633","#996666","#996699","#9966cc","#9966ff", - "#cc6600","#cc6633","#cc6666","#cc6699","#cc66cc","#cc66ff","#ff6600","#ff6633", - "#ff6666","#ff6699","#ff66cc","#ff66ff","#009900","#009933","#009966","#009999", - "#0099cc","#0099ff","#339900","#339933","#339966","#339999","#3399cc","#3399ff", - "#669900","#669933","#669966","#669999","#6699cc","#6699ff","#999900","#999933", - "#999966","#999999","#9999cc","#9999ff","#cc9900","#cc9933","#cc9966","#cc9999", - "#cc99cc","#cc99ff","#ff9900","#ff9933","#ff9966","#ff9999","#ff99cc","#ff99ff", - "#00cc00","#00cc33","#00cc66","#00cc99","#00cccc","#00ccff","#33cc00","#33cc33", - "#33cc66","#33cc99","#33cccc","#33ccff","#66cc00","#66cc33","#66cc66","#66cc99", - "#66cccc","#66ccff","#99cc00","#99cc33","#99cc66","#99cc99","#99cccc","#99ccff", - "#cccc00","#cccc33","#cccc66","#cccc99","#cccccc","#ccccff","#ffcc00","#ffcc33", - "#ffcc66","#ffcc99","#ffcccc","#ffccff","#00ff00","#00ff33","#00ff66","#00ff99", - "#00ffcc","#00ffff","#33ff00","#33ff33","#33ff66","#33ff99","#33ffcc","#33ffff", - "#66ff00","#66ff33","#66ff66","#66ff99","#66ffcc","#66ffff","#99ff00","#99ff33", - "#99ff66","#99ff99","#99ffcc","#99ffff","#ccff00","#ccff33","#ccff66","#ccff99", - "#ccffcc","#ccffff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff" -); - -var named = { - '#F0F8FF':'AliceBlue','#FAEBD7':'AntiqueWhite','#00FFFF':'Aqua','#7FFFD4':'Aquamarine','#F0FFFF':'Azure','#F5F5DC':'Beige', - '#FFE4C4':'Bisque','#000000':'Black','#FFEBCD':'BlanchedAlmond','#0000FF':'Blue','#8A2BE2':'BlueViolet','#A52A2A':'Brown', - '#DEB887':'BurlyWood','#5F9EA0':'CadetBlue','#7FFF00':'Chartreuse','#D2691E':'Chocolate','#FF7F50':'Coral','#6495ED':'CornflowerBlue', - '#FFF8DC':'Cornsilk','#DC143C':'Crimson','#00FFFF':'Cyan','#00008B':'DarkBlue','#008B8B':'DarkCyan','#B8860B':'DarkGoldenRod', - '#A9A9A9':'DarkGray','#A9A9A9':'DarkGrey','#006400':'DarkGreen','#BDB76B':'DarkKhaki','#8B008B':'DarkMagenta','#556B2F':'DarkOliveGreen', - '#FF8C00':'Darkorange','#9932CC':'DarkOrchid','#8B0000':'DarkRed','#E9967A':'DarkSalmon','#8FBC8F':'DarkSeaGreen','#483D8B':'DarkSlateBlue', - '#2F4F4F':'DarkSlateGray','#2F4F4F':'DarkSlateGrey','#00CED1':'DarkTurquoise','#9400D3':'DarkViolet','#FF1493':'DeepPink','#00BFFF':'DeepSkyBlue', - '#696969':'DimGray','#696969':'DimGrey','#1E90FF':'DodgerBlue','#B22222':'FireBrick','#FFFAF0':'FloralWhite','#228B22':'ForestGreen', - '#FF00FF':'Fuchsia','#DCDCDC':'Gainsboro','#F8F8FF':'GhostWhite','#FFD700':'Gold','#DAA520':'GoldenRod','#808080':'Gray','#808080':'Grey', - '#008000':'Green','#ADFF2F':'GreenYellow','#F0FFF0':'HoneyDew','#FF69B4':'HotPink','#CD5C5C':'IndianRed','#4B0082':'Indigo','#FFFFF0':'Ivory', - '#F0E68C':'Khaki','#E6E6FA':'Lavender','#FFF0F5':'LavenderBlush','#7CFC00':'LawnGreen','#FFFACD':'LemonChiffon','#ADD8E6':'LightBlue', - '#F08080':'LightCoral','#E0FFFF':'LightCyan','#FAFAD2':'LightGoldenRodYellow','#D3D3D3':'LightGray','#D3D3D3':'LightGrey','#90EE90':'LightGreen', - '#FFB6C1':'LightPink','#FFA07A':'LightSalmon','#20B2AA':'LightSeaGreen','#87CEFA':'LightSkyBlue','#778899':'LightSlateGray','#778899':'LightSlateGrey', - '#B0C4DE':'LightSteelBlue','#FFFFE0':'LightYellow','#00FF00':'Lime','#32CD32':'LimeGreen','#FAF0E6':'Linen','#FF00FF':'Magenta','#800000':'Maroon', - '#66CDAA':'MediumAquaMarine','#0000CD':'MediumBlue','#BA55D3':'MediumOrchid','#9370D8':'MediumPurple','#3CB371':'MediumSeaGreen','#7B68EE':'MediumSlateBlue', - '#00FA9A':'MediumSpringGreen','#48D1CC':'MediumTurquoise','#C71585':'MediumVioletRed','#191970':'MidnightBlue','#F5FFFA':'MintCream','#FFE4E1':'MistyRose','#FFE4B5':'Moccasin', - '#FFDEAD':'NavajoWhite','#000080':'Navy','#FDF5E6':'OldLace','#808000':'Olive','#6B8E23':'OliveDrab','#FFA500':'Orange','#FF4500':'OrangeRed','#DA70D6':'Orchid', - '#EEE8AA':'PaleGoldenRod','#98FB98':'PaleGreen','#AFEEEE':'PaleTurquoise','#D87093':'PaleVioletRed','#FFEFD5':'PapayaWhip','#FFDAB9':'PeachPuff', - '#CD853F':'Peru','#FFC0CB':'Pink','#DDA0DD':'Plum','#B0E0E6':'PowderBlue','#800080':'Purple','#FF0000':'Red','#BC8F8F':'RosyBrown','#4169E1':'RoyalBlue', - '#8B4513':'SaddleBrown','#FA8072':'Salmon','#F4A460':'SandyBrown','#2E8B57':'SeaGreen','#FFF5EE':'SeaShell','#A0522D':'Sienna','#C0C0C0':'Silver', - '#87CEEB':'SkyBlue','#6A5ACD':'SlateBlue','#708090':'SlateGray','#708090':'SlateGrey','#FFFAFA':'Snow','#00FF7F':'SpringGreen', - '#4682B4':'SteelBlue','#D2B48C':'Tan','#008080':'Teal','#D8BFD8':'Thistle','#FF6347':'Tomato','#40E0D0':'Turquoise','#EE82EE':'Violet', - '#F5DEB3':'Wheat','#FFFFFF':'White','#F5F5F5':'WhiteSmoke','#FFFF00':'Yellow','#9ACD32':'YellowGreen' -}; - -function init() { - var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color')); - - if (tinyMCE.isMSIE) - tinyMCEPopup.resizeToInnerSize(); - - generatePicker(); - - if (inputColor) { - changeFinalColor(inputColor); - - col = convertHexToRGB(inputColor); - - if (col) - updateLight(col.r, col.g, col.b); - } -} - -function insertAction() { - var color = document.getElementById("color").value; - - tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color); - tinyMCEPopup.close(); -} - -function showColor(color, name) { - if (name) - document.getElementById("colorname").innerHTML = name; - - document.getElementById("preview").style.backgroundColor = color; - document.getElementById("color").value = color; -} - -function convertRGBToHex(col) { - var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi"); - - if (!col) - return col; - - var rgb = col.replace(re, "$1,$2,$3").split(','); - if (rgb.length == 3) { - r = parseInt(rgb[0]).toString(16); - g = parseInt(rgb[1]).toString(16); - b = parseInt(rgb[2]).toString(16); - - r = r.length == 1 ? '0' + r : r; - g = g.length == 1 ? '0' + g : g; - b = b.length == 1 ? '0' + b : b; - - return "#" + r + g + b; - } - - return col; -} - -function convertHexToRGB(col) { - if (col.indexOf('#') != -1) { - col = col.replace(new RegExp('[^0-9A-F]', 'gi'), ''); - - r = parseInt(col.substring(0, 2), 16); - g = parseInt(col.substring(2, 4), 16); - b = parseInt(col.substring(4, 6), 16); - - return {r : r, g : g, b : b}; - } - - return null; -} - -function generatePicker() { - var el = document.getElementById('light'), h = '', i; - - for (i = 0; i < detail; i++){ - h += '
    '; - } - - el.innerHTML = h; -} - -function generateWebColors() { - var el = document.getElementById('webcolors'), h = '', i; - - if (el.className == 'generated') - return; - - h += '' - + ''; - - for (i=0; i' - + '' - + '' + colors[i] +  ''; - if ((i+1) % 18 == 0) - h += ''; - } - - h += '
    '; - - el.innerHTML = h; - el.className = 'generated'; -} - -function generateNamedColors() { - var el = document.getElementById('namedcolors'), h = '', n, v, i = 0; - - if (el.className == 'generated') - return; - - for (n in named) { - v = named[n]; - h += '' - } - - el.innerHTML = h; - el.className = 'generated'; -} - -function dechex(n) { - return strhex.charAt(Math.floor(n / 16)) + strhex.charAt(n % 16); -} - -function computeColor(e) { - var x, y, partWidth, partDetail, imHeight, r, g, b, coef, i, finalCoef, finalR, finalG, finalB; - - x = e.offsetX ? e.offsetX : (e.target ? e.clientX - e.target.x : 0); - y = e.offsetY ? e.offsetY : (e.target ? e.clientY - e.target.y : 0); - - partWidth = document.getElementById('colorpicker').width / 6; - partDetail = detail / 2; - imHeight = document.getElementById('colorpicker').height; - - r = (x >= 0)*(x < partWidth)*255 + (x >= partWidth)*(x < 2*partWidth)*(2*255 - x * 255 / partWidth) + (x >= 4*partWidth)*(x < 5*partWidth)*(-4*255 + x * 255 / partWidth) + (x >= 5*partWidth)*(x < 6*partWidth)*255; - g = (x >= 0)*(x < partWidth)*(x * 255 / partWidth) + (x >= partWidth)*(x < 3*partWidth)*255 + (x >= 3*partWidth)*(x < 4*partWidth)*(4*255 - x * 255 / partWidth); - b = (x >= 2*partWidth)*(x < 3*partWidth)*(-2*255 + x * 255 / partWidth) + (x >= 3*partWidth)*(x < 5*partWidth)*255 + (x >= 5*partWidth)*(x < 6*partWidth)*(6*255 - x * 255 / partWidth); - - coef = (imHeight - y) / imHeight; - r = 128 + (r - 128) * coef; - g = 128 + (g - 128) * coef; - b = 128 + (b - 128) * coef; - - changeFinalColor('#' + dechex(r) + dechex(g) + dechex(b)); - updateLight(r, g, b); -} - -function updateLight(r, g, b) { - var i, partDetail = detail / 2, finalCoef, finalR, finalG, finalB, color; - - for (i=0; i=0) && (i'); -} - -function insertImage() { - var src = document.forms[0].src.value; - var alt = document.forms[0].alt.value; - var border = document.forms[0].border.value; - var vspace = document.forms[0].vspace.value; - var hspace = document.forms[0].hspace.value; - var width = document.forms[0].width.value; - var height = document.forms[0].height.value; - var align = document.forms[0].align.options[document.forms[0].align.selectedIndex].value; - - tinyMCEPopup.restoreSelection(); - tinyMCE.themes['advanced']._insertImage(src, alt, border, hspace, vspace, width, height, align); - tinyMCEPopup.close(); -} - -function init() { - tinyMCEPopup.resizeToInnerSize(); - - document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image'); - - var formObj = document.forms[0]; - - for (var i=0; i 0) { - for (var i=0; i'); -} - -function init() { - tinyMCEPopup.resizeToInnerSize(); - - document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','theme_advanced_link'); - - // Handle file browser - if (isVisible('hrefbrowser')) - document.getElementById('href').style.width = '180px'; - - var formObj = document.forms[0]; - - for (var i=0; i 0) { - var formObj = document.forms[0]; - - for (var i=0; i'; + response.errors.push( anError ); + parsed.errors = true; + } ).size() ) { response.errors = false; } + parsed.responses.push( response ); + } ); + if ( err.length ) { re.html( '
    ' + err + '
    ' ); } + return parsed; + } + if ( isNaN(x) ) { return !re.html('

    ' + x + '

    '); } + x = parseInt(x,10); + if ( -1 == x ) { return !re.html('

    ' + this.noPerm + '

    '); } + else if ( 0 === x ) { return !re.html('

    ' + this.broken + '

    '); } + return true; + }, + validateForm: function( selector ) { + selector = jQuery( selector ); + return !selector.find('.form-required').andSelf().filter('.form-required:has(:input[value=""]), .form-required:input[value=""]').addClass( 'form-invalid' ).change( function() { jQuery(this).removeClass( 'form-invalid' ); } ).size(); + } +}, wpAjax || { noPerm: 'You do not have permission to do that.', broken: 'AJAX is teh b0rked.' } ); diff --git a/wp-includes/js/wp-lists.js b/wp-includes/js/wp-lists.js new file mode 100644 index 0000000..e0c5b25 --- /dev/null +++ b/wp-includes/js/wp-lists.js @@ -0,0 +1,369 @@ +(function($) { +var currentFormEl = false; +var fs = {add:'ajaxAdd',del:'ajaxDel',dim:'ajaxDim',process:'process',recolor:'recolor'}; + +var wpList = { + settings: { + url: wpListL10n.url, type: 'POST', + response: 'ajax-response', + + what: '', + alt: 'alternate', altOffset: 0, + addColor: null, delColor: null, dimAddColor: null, dimDelColor: null, + + confirm: null, + addBefore: null, addAfter: null, + delBefore: null, delAfter: null, + dimBefore: null, dimAfter: null + }, + + nonce: function(e,s) { + var url = wpAjax.unserialize(e.attr('href')); + return s.nonce || url._ajax_nonce || $('#' + s.element + ' input[name=_ajax_nonce]').val() || url._wpnonce || $('#' + s.element + ' input[name=_wpnonce]').val() || 0; + }, + + parseClass: function(e,t) { + var c = [], cl; + try { + cl = $(e).attr('class') || ''; + cl = cl.match(new RegExp(t+':[A-Za-z0-9:_=-]+')); + if ( cl ) { c = cl[0].split(':'); } + } catch(r) {} + return c; + }, + + pre: function(e,s,a) { + var bg; var r; + s = $.extend( {}, this.wpList.settings, { + element: null, + nonce: 0 + }, s || {} ); + if ( $.isFunction( s.confirm ) ) { + if ( 'add' != a ) { + bg = $('#' + s.element).css('backgroundColor'); + $('#' + s.element).css('backgroundColor', '#FF9966'); + } + r = s.confirm.call(this,e,s,a,bg); + if ( 'add' != a ) { $('#' + s.element).css('backgroundColor', bg ); } + if ( !r ) { return false; } + } + return s; + }, + + ajaxAdd: function( e, s ) { + var list = this; e = $(e); s = s || {}; + var cls = wpList.parseClass(e,'add'); + s = wpList.pre.call( list, e, s, 'add' ); + + s.element = cls[2] || e.attr( 'id' ) || s.element || null; + if ( cls[3] ) { s.addColor = '#' + cls[3]; } + else { s.addColor = s.addColor || '#FFFF33'; } + + if ( !s ) { return false; } + + if ( !e.is("[class^=add:" + list.id + ":]") ) { return !wpList.add.call( list, e, s ); } + + if ( !s.element ) { return true; } + + s.action = 'add-' + s.what; + + s.nonce = wpList.nonce(e,s); + + var es = $('#' + s.element + ' :input').not('[name=_ajax_nonce], [name=_wpnonce], [name=action]'); + var valid = wpAjax.validateForm( '#' + s.element ); + if ( !valid ) { return false; } + + s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) ); + var formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize(); + if ( formData ) { s.data += '&' + formData; } + + if ( $.isFunction(s.addBefore) ) { + s = s.addBefore( s ); + if ( !s ) { return true; } + } + if ( !s.data.match(/_ajax_nonce=[a-f0-9]+/) ) { return true; } + + s.success = function(r) { + var res = wpAjax.parseAjaxResponse(r, s.response, s.element); + if ( !res || res.errors ) { return false; } + + jQuery.each( res.responses, function() { + wpList.add.call( list, this.data, $.extend( {}, s, { // this.firstChild.nodevalue + pos: this.position || 0, + id: this.id || 0, + oldId: this.oldId || null + } ) ); + } ); + + if ( $.isFunction(s.addAfter) ) { + var o = this.complete; + this.complete = function(x,st) { + var _s = $.extend( { xml: x, status: st, parsed: res }, s ); + s.addAfter( r, _s ); + if ( $.isFunction(o) ) { o(x,st); } + }; + } + list.wpList.recolor(); + wpList.clear.call(list,'#' + s.element); + }; + + $.ajax( s ); + return false; + }, + + ajaxDel: function( e, s ) { + var list = this; e = $(e); s = s || {}; + var cls = wpList.parseClass(e,'delete'); + s = wpList.pre.call( list, e, s, 'delete' ); + + s.element = cls[2] || s.element || null; + if ( cls[3] ) { s.delColor = '#' + cls[3]; } + else { s.delColor = s.delColor || '#FF3333'; } + + if ( !s || !s.element ) { return false; } + + s.action = 'delete-' + s.what; + + s.nonce = wpList.nonce(e,s); + + s.data = $.extend( + { action: s.action, id: s.element.split('-').pop(), _ajax_nonce: s.nonce }, + wpAjax.unserialize( cls[4] || '' ) + ); + + if ( $.isFunction(s.delBefore) ) { + s = s.delBefore( s ); + if ( !s ) { return true; } + } + if ( !s.data._ajax_nonce ) { return true; } + + var element = $('#' + s.element); + + if ( 'none' != s.delColor ) { + var anim = 'slideUp'; + if ( element.css( 'display' ).match(/table/) ) + anim = 'fadeOut'; // Can't slideup table rows and other table elements. Known jQuery bug + element + .animate( { backgroundColor: s.delColor }, 'fast' )[anim]( 'fast' ) + .queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); + } else { + list.wpList.recolor(); + } + + s.success = function(r) { + var res = wpAjax.parseAjaxResponse(r, s.response, s.element); + if ( !res || res.errors ) { + element.stop().css( 'backgroundColor', '#FF3333' ).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); + return false; + } + if ( $.isFunction(s.delAfter) ) { + var o = this.complete; + this.complete = function(x,st) { + element.queue( function() { + var _s = $.extend( { xml: x, status: st, parsed: res }, s ); + s.delAfter( r, _s ); + if ( $.isFunction(o) ) { o(x,st); } + } ).dequeue(); + }; + } + }; + $.ajax( s ); + return false; + }, + + ajaxDim: function( e, s ) { + var list = this; e = $(e); s = s || {}; + var cls = wpList.parseClass(e,'dim'); + s = wpList.pre.call( list, e, s, 'dim' ); + + s.element = cls[2] || s.element || null; + s.dimClass = cls[3] || s.dimClass || null; + if ( cls[4] ) { s.dimAddColor = '#' + cls[4]; } + else { s.dimAddColor = s.dimAddColor || '#FFFF33'; } + if ( cls[5] ) { s.dimDelColor = '#' + cls[5]; } + else { s.dimDelColor = s.dimDelColor || '#FF3333'; } + + if ( !s || !s.element || !s.dimClass ) { return true; } + + s.action = 'dim-' + s.what; + + s.nonce = wpList.nonce(e,s); + + s.data = $.extend( + { action: s.action, id: s.element.split('-').pop(), dimClass: s.dimClass, _ajax_nonce : s.nonce }, + wpAjax.unserialize( cls[6] || '' ) + ); + + if ( $.isFunction(s.dimBefore) ) { + s = s.dimBefore( s ); + if ( !s ) { return true; } + } + + var element = $('#' + s.element); + var isClass = element.toggleClass(s.dimClass).is('.' + s.dimClass); + var color = wpList.getColor( element ); + element.toggleClass( s.dimClass ) + var dimColor = isClass ? s.dimAddColor : s.dimDelColor; + if ( 'none' != dimColor ) { + element + .animate( { backgroundColor: dimColor }, 'fast' ) + .queue( function() { element.toggleClass(s.dimClass); $(this).dequeue(); } ) + .animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } ); + } + + if ( !s.data._ajax_nonce ) { return true; } + + s.success = function(r) { + var res = wpAjax.parseAjaxResponse(r, s.response, s.element); + if ( !res || res.errors ) { + element.stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); + return false; + } + if ( $.isFunction(s.dimAfter) ) { + var o = this.complete; + this.complete = function(x,st) { + element.queue( function() { + var _s = $.extend( { xml: x, status: st, parsed: res }, s ); + s.dimAfter( r, _s ); + if ( $.isFunction(o) ) { o(x,st); } + } ).dequeue(); + }; + } + }; + + $.ajax( s ); + return false; + }, + + // From jquery.color.js: jQuery Color Animation by John Resig + getColor: function( el ) { + if ( el.constructor == Object ) + el = el.get(0); + var elem = el, color, rgbaTrans = new RegExp( "rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)", "i" ); + do { + color = jQuery.curCSS(elem, 'backgroundColor'); + if ( color != '' && color != 'transparent' && !color.match(rgbaTrans) || jQuery.nodeName(elem, "body") ) + break; + } while ( elem = elem.parentNode ); + return color || '#ffffff'; + }, + + add: function( e, s ) { + var list = $(this); + e = $(e); + + var old = false; + var _s = { pos: 0, id: 0, oldId: null }; + if ( 'string' == typeof s ) { s = { what: s }; } + s = $.extend(_s, this.wpList.settings, s); + if ( !e.size() || !s.what ) { return false; } + if ( s.oldId ) { old = $('#' + s.what + '-' + s.oldId); } + if ( s.id && ( s.id != s.oldId || !old || !old.size() ) ) { $('#' + s.what + '-' + s.id).remove(); } + + if ( old && old.size() ) { + old.replaceWith(e); + } else if ( isNaN(s.pos) ) { + var ba = 'after'; + if ( '-' == s.pos.substr(0,1) ) { + s.pos = s.pos.substr(1); + ba = 'before'; + } + var ref = list.find( '#' + s.pos ); + if ( 1 === ref.size() ) { ref[ba](e); } + else { list.append(e); } + } else if ( s.pos < 0 ) { + list.prepend(e); + } else { + list.append(e); + } + + if ( s.alt ) { + if ( ( list.children(':visible').index( e[0] ) + s.altOffset ) % 2 ) { e.removeClass( s.alt ); } + else { e.addClass( s.alt ); } + } + + if ( 'none' != s.addColor ) { + var color = wpList.getColor( e ); + e.css( 'backgroundColor', s.addColor ).animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } ); + } + list.each( function() { this.wpList.process( e ); } ); + return e; + }, + + clear: function(e) { + var list = this; + e = $(e); + if ( list.wpList && e.parents( '#' + list.id ).size() ) { return; } + e.find(':input').each( function() { + if ( $(this).parents('.form-no-clear').size() ) + return; + var t = this.type.toLowerCase(); var tag = this.tagName.toLowerCase(); + if ( 'text' == t || 'password' == t || 'textarea' == tag ) { this.value = ''; } + else if ( 'checkbox' == t || 'radio' == t ) { this.checked = false; } + else if ( 'select' == tag ) { this.selectedIndex = null; } + }); + }, + + process: function(el) { + var list = this; + $("[class^=add:" + list.id + ":]", el || null) + .filter('form').submit( function() { return list.wpList.add(this); } ).end() + .not('form').click( function() { return list.wpList.add(this); } ).each( function() { + var addEl = this; + var c = wpList.parseClass(this,'add')[2] || addEl.id; + if ( !c ) { return; } + var forms = []; var ins = []; + $('#' + c + ' :input').focus( function() { currentFormEl = this; } ).blur( function() { currentFormEl = false; } ).each( function() { + ins.push(this); + $.merge(forms,$(this).parents('form')); + forms = $.unique(forms); + } ); + $(forms).submit( function() { + if ( 0 <= $.inArray(currentFormEl,ins) ) { + $(addEl).trigger( 'click' ); + $(currentFormEl).focus(); + return false; + } + } ); + } ); + $("[class^=delete:" + list.id + ":]", el || null).click( function() { return list.wpList.del(this); } ); + $("[class^=dim:" + list.id + ":]", el || null).click( function() { return list.wpList.dim(this); } ); + }, + + recolor: function() { + var list = this; + if ( !list.wpList.settings.alt ) { return; } + var items = $('.list-item:visible', list); + if ( !items.size() ) { items = $(list).children(':visible'); } + var eo = [':even',':odd']; + if ( list.wpList.settings.altOffset % 2 ) { eo.reverse(); } + items.filter(eo[0]).addClass(list.wpList.settings.alt).end().filter(eo[1]).removeClass(list.wpList.settings.alt); + }, + + init: function() { + var lists = this; + lists.wpList.process = function(a) { + lists.each( function() { + this.wpList.process(a); + } ); + }; + lists.wpList.recolor = function() { + lists.each( function() { + this.wpList.recolor(); + } ); + }; + } +}; + +$.fn.wpList = function( settings ) { + this.each( function() { + var _this = this; + this.wpList = { settings: $.extend( {}, wpList.settings, { what: wpList.parseClass(this,'list')[1] || '' }, settings ) }; + $.each( fs, function(i,f) { _this.wpList[i] = function( e, s ) { return wpList[f].call( _this, e, s ); }; } ); + } ); + wpList.init.call(this); + this.wpList.process(); + return this; +}; + +})(jQuery); diff --git a/wp-includes/media.php b/wp-includes/media.php new file mode 100644 index 0000000..742b1bc --- /dev/null +++ b/wp-includes/media.php @@ -0,0 +1,404 @@ + tag. Empty values will be omitted. +function image_hwstring($width, $height) { + $out = ''; + if ($width) + $out .= 'width="'.intval($width).'" '; + if ($height) + $out .= 'height="'.intval($height).'" '; + return $out; +} + +// Scale an image to fit a particular size (such as 'thumb' or 'medium'), and return an image URL, height and width. +// The URL might be the original image, or it might be a resized version. This function won't create a new resized copy, it will just return an already resized one if it exists. +// returns an array($url, $width, $height) +function image_downsize($id, $size = 'medium') { + + if ( !wp_attachment_is_image($id) ) + return false; + + $img_url = wp_get_attachment_url($id); + $meta = wp_get_attachment_metadata($id); + $width = $height = 0; + + // plugins can use this to provide resize services + if ( $out = apply_filters('image_downsize', false, $id, $size) ) + return $out; + + // try for a new style intermediate size + if ( $intermediate = image_get_intermediate_size($id, $size) ) { + $img_url = str_replace(basename($img_url), $intermediate['file'], $img_url); + $width = $intermediate['width']; + $height = $intermediate['height']; + } + elseif ( $size == 'thumbnail' ) { + // fall back to the old thumbnail + if ( $thumb_file = wp_get_attachment_thumb_file() && $info = getimagesize($thumb_file) ) { + $img_url = str_replace(basename($img_url), basename($thumb_file), $img_url); + $width = $info[0]; + $height = $info[1]; + } + } + if ( !$width && !$height && isset($meta['width'], $meta['height']) ) { + // any other type: use the real image and constrain it + list( $width, $height ) = image_constrain_size_for_editor( $meta['width'], $meta['height'], $size ); + } + + if ( $img_url) + return array( $img_url, $width, $height ); + return false; + +} + +// return an tag for the given image attachment, scaling it down if requested +function get_image_tag($id, $alt, $title, $align, $rel = false, $size='medium') { + + list( $img_src, $width, $height ) = image_downsize($id, $size); + $hwstring = image_hwstring($width, $height); + + $html = ''.attribute_escape($alt).''; + + $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url ); + + return $html; +} + +// same as wp_shrink_dimensions, except the max parameters are optional. +// if either width or height are empty, no constraint is applied on that dimension. +function wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 ) { + if ( !$max_width and !$max_height ) + return array( $current_width, $current_height ); + + $width_ratio = $height_ratio = 1.0; + + if ( $max_width > 0 && $current_width > $max_width ) + $width_ratio = $max_width / $current_width; + + if ( $max_height > 0 && $current_height > $max_height ) + $height_ratio = $max_height / $current_height; + + // the smaller ratio is the one we need to fit it to the constraining box + $ratio = min( $width_ratio, $height_ratio ); + + return array( intval($current_width * $ratio), intval($current_height * $ratio) ); +} + +// calculate dimensions and coordinates for a resized image that fits within a specified width and height +// if $crop is true, the largest matching central portion of the image will be cropped out and resized to the required size +function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop=false) { + + if ($orig_w <= 0 || $orig_h <= 0) + return false; + // at least one of dest_w or dest_h must be specific + if ($dest_w <= 0 && $dest_h <= 0) + return false; + + if ( $crop ) { + // crop the largest possible portion of the original image that we can size to $dest_w x $dest_h + $aspect_ratio = $orig_w / $orig_h; + $new_w = min($dest_w, $orig_w); + $new_h = min($dest_h, $orig_h); + if (!$new_w) { + $new_w = intval($new_h * $aspect_ratio); + } + if (!$new_h) { + $new_h = intval($new_w / $aspect_ratio); + } + + $size_ratio = max($new_w / $orig_w, $new_h / $orig_h); + + $crop_w = ceil($new_w / $size_ratio); + $crop_h = ceil($new_h / $size_ratio); + + $s_x = floor(($orig_w - $crop_w)/2); + $s_y = floor(($orig_h - $crop_h)/2); + } + else { + // don't crop, just resize using $dest_w x $dest_h as a maximum bounding box + $crop_w = $orig_w; + $crop_h = $orig_h; + + $s_x = 0; + $s_y = 0; + + list( $new_w, $new_h ) = wp_constrain_dimensions( $orig_w, $orig_h, $dest_w, $dest_h ); + } + + // if the resulting image would be the same size or larger we don't want to resize it + if ($new_w >= $orig_w && $new_h >= $orig_h) + return false; + + // the return array matches the parameters to imagecopyresampled() + // int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h + return array(0, 0, $s_x, $s_y, $new_w, $new_h, $crop_w, $crop_h); + +} + +// Scale down an image to fit a particular size and save a new copy of the image +function image_resize( $file, $max_w, $max_h, $crop=false, $suffix=null, $dest_path=null, $jpeg_quality=75) { + + $image = wp_load_image( $file ); + if ( !is_resource( $image ) ) + return new WP_Error('error_loading_image', $image); + + list($orig_w, $orig_h, $orig_type) = getimagesize( $file ); + $dims = image_resize_dimensions($orig_w, $orig_h, $max_w, $max_h, $crop); + if (!$dims) + return $dims; + list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims; + + $newimage = imagecreatetruecolor( $dst_w, $dst_h); + + // preserve PNG transparency + if ( IMAGETYPE_PNG == $orig_type && function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) { + imagealphablending( $newimage, false); + imagesavealpha( $newimage, true); + } + + imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); + + // we don't need the original in memory anymore + imagedestroy( $image ); + + // $suffix will be appended to the destination filename, just before the extension + if ( !$suffix ) + $suffix = "{$dst_w}x{$dst_h}"; + + $info = pathinfo($file); + $dir = $info['dirname']; + $ext = $info['extension']; + $name = basename($file, ".{$ext}"); + if ( !is_null($dest_path) and $_dest_path = realpath($dest_path) ) + $dir = $_dest_path; + $destfilename = "{$dir}/{$name}-{$suffix}.{$ext}"; + + if ( $orig_type == IMAGETYPE_GIF ) { + if (!imagegif( $newimage, $destfilename ) ) + return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); + } + elseif ( $orig_type == IMAGETYPE_PNG ) { + if (!imagepng( $newimage, $destfilename ) ) + return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); + } + else { + // all other formats are converted to jpg + $destfilename = "{$dir}/{$name}-{$suffix}.jpg"; + if (!imagejpeg( $newimage, $destfilename, $jpeg_quality ) ) + return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); + } + + imagedestroy( $newimage ); + + // Set correct file permissions + $stat = stat( dirname( $destfilename )); + $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits + @ chmod( $destfilename, $perms ); + + return $destfilename; +} + +// resize an image to make a thumbnail or intermediate size, and return metadata describing the new copy +// returns false if no image was created +function image_make_intermediate_size($file, $width, $height, $crop=false) { + if ( $width || $height ) { + $resized_file = image_resize($file, $width, $height, $crop); + if ( !is_wp_error($resized_file) && $resized_file && $info = getimagesize($resized_file) ) { + return array( + 'file' => basename( $resized_file ), + 'width' => $info[0], + 'height' => $info[1], + ); + } + } + return false; +} + +function image_get_intermediate_size($post_id, $size='thumbnail') { + if ( !$imagedata = wp_get_attachment_metadata( $post_id ) ) + return false; + + // get the best one for a specified set of dimensions + if ( is_array($size) && !empty($imagedata['sizes']) ) { + foreach ( $imagedata['sizes'] as $_size => $data ) { + // already cropped to width or height; so use this size + if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) { + $file = $data['file']; + list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); + return compact( 'file', 'width', 'height' ); + } + // add to lookup table: area => size + $areas[$data['width'] * $data['height']] = $_size; + } + if ( !$size || !empty($areas) ) { + // find for the smallest image not smaller than the desired size + ksort($areas); + foreach ( $areas as $_size ) { + $data = $imagedata['sizes'][$_size]; + if ( $data['width'] >= $size[0] || $data['height'] >= $size[1] ) { + $file = $data['file']; + list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); + return compact( 'file', 'width', 'height' ); + } + } + } + } + + if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) ) + return false; + + $data = $imagedata['sizes'][$size]; + // include the full filesystem path of the intermediate file + if ( empty($data['path']) && !empty($data['file']) ) { + $file_url = wp_get_attachment_url($post_id); + $data['path'] = path_join( dirname($imagedata['file']), $data['file'] ); + $data['url'] = path_join( dirname($file_url), $data['file'] ); + } + return $data; +} + +// get an image to represent an attachment - a mime icon for files, thumbnail or intermediate size for images +// returns an array (url, width, height), or false if no image is available +function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) { + + // get a thumbnail or intermediate image if there is one + if ( $image = image_downsize($attachment_id, $size) ) + return $image; + + if ( $icon && $src = wp_mime_type_icon($attachment_id) ) { + $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' ); + $src_file = $icon_dir . '/' . basename($src); + @list($width, $height) = getimagesize($src_file); + } + if ( $src && $width && $height ) + return array( $src, $width, $height ); + return false; +} + +// as per wp_get_attachment_image_src, but returns an tag +function wp_get_attachment_image($attachment_id, $size='thumbnail', $icon = false) { + + $html = ''; + $image = wp_get_attachment_image_src($attachment_id, $size, $icon); + if ( $image ) { + list($src, $width, $height) = $image; + $hwstring = image_hwstring($width, $height); + if ( is_array($size) ) + $size = join('x', $size); + $html = ''; + } + + return $html; +} + +add_shortcode('gallery', 'gallery_shortcode'); + +function gallery_shortcode($attr) { + global $post; + + // Allow plugins/themes to override the default gallery template. + $output = apply_filters('post_gallery', '', $attr); + if ( $output != '' ) + return $output; + + $attachments = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&orderby=\"menu_order ASC, ID ASC\""); + + if ( empty($attachments) ) + return ''; + + $output = apply_filters('gallery_style', " + + \n"; + + return $output; +} + +function previous_image_link() { + adjacent_image_link(true); +} + +function next_image_link() { + adjacent_image_link(false); +} + +function adjacent_image_link($prev = true) { + global $post; + $post = get_post($post); + $attachments = array_values(get_children("post_parent=$post->post_parent&post_type=attachment&post_mime_type=image&orderby=\"menu_order ASC, ID ASC\"")); + + foreach ( $attachments as $k => $attachment ) + if ( $attachment->ID == $post->ID ) + break; + + $k = $prev ? $k - 1 : $k + 1; + + if ( isset($attachments[$k]) ) + echo wp_get_attachment_link($attachments[$k]->ID, 'thumbnail', true); +} + +?> diff --git a/wp-includes/shortcodes.php b/wp-includes/shortcodes.php new file mode 100644 index 0000000..7e3bf44 --- /dev/null +++ b/wp-includes/shortcodes.php @@ -0,0 +1,133 @@ + 'no foo', + 'baz' => 'default baz', + ), $atts)); + + return "foo = {$foo}"; +} +add_shortcode('bartag', 'bartag_func'); + +Example with enclosed content: + +// [baztag]content[/baztag] +function baztag_func($atts, $content='') { + return "content = $content"; +} +add_shortcode('baztag', 'baztag_func'); + +*/ + +$shortcode_tags = array(); + +function add_shortcode($tag, $func) { + global $shortcode_tags; + + if ( is_callable($func) ) + $shortcode_tags[$tag] = $func; +} + +function remove_shortcode($tag) { + global $shortcode_tags; + + unset($shortcode_tags[$tag]); +} + +function remove_all_shortcodes() { + global $shortcode_tags; + + $shortcode_tags = array(); +} + +function do_shortcode($content) { + global $shortcode_tags; + + if (empty($shortcode_tags) || !is_array($shortcode_tags)) + return $content; + + $tagnames = array_keys($shortcode_tags); + $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); + + $pattern = '/\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?/s'; + + return preg_replace_callback($pattern, 'do_shortcode_tag', $content); +} + +function do_shortcode_tag($m) { + global $shortcode_tags; + + $tag = $m[1]; + $attr = shortcode_parse_atts($m[2]); + + if ( isset($m[4]) ) { + // enclosing tag - extra parameter + return call_user_func($shortcode_tags[$tag], $attr, $m[4]); + } else { + // self-closing tag + return call_user_func($shortcode_tags[$tag], $attr); + } +} + +function shortcode_parse_atts($text) { + $atts = array(); + $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/'; + if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) { + foreach ($match as $m) { + if (!empty($m[1])) + $atts[strtolower($m[1])] = stripcslashes($m[2]); + elseif (!empty($m[3])) + $atts[strtolower($m[3])] = stripcslashes($m[4]); + elseif (!empty($m[5])) + $atts[strtolower($m[5])] = stripcslashes($m[6]); + elseif (isset($m[7]) and strlen($m[7])) + $atts[] = stripcslashes($m[7]); + elseif (isset($m[8])) + $atts[] = stripcslashes($m[8]); + } + } else { + $atts = ltrim($text); + } + return $atts; +} + +function shortcode_atts($pairs, $atts) { + $out = array(); + foreach($pairs as $name => $default) { + if ( array_key_exists($name, $atts) ) + $out[$name] = $atts[$name]; + else + $out[$name] = $default; + } + return $out; +} + +add_filter('the_content', 'do_shortcode'); + +?> -- cgit