From ff81ee6e8304a1982a3ec4f5b134764a29d502cf Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 2 Nov 2009 18:42:54 -0500 Subject: [PATCH 1/1] Wordpress 2.0.2 Signed-off-by: Edward Z. Yang --- index.php | 5 + license.txt | 280 + readme.html | 120 + wp-admin/admin-db.php | 349 + wp-admin/admin-footer.php | 19 + wp-admin/admin-functions.php | 1889 +++++ wp-admin/admin-header.php | 72 + wp-admin/admin.php | 106 + wp-admin/bookmarklet.php | 104 + wp-admin/cat-js.php | 178 + wp-admin/categories.php | 169 + wp-admin/edit-comments.php | 172 + wp-admin/edit-form-advanced.php | 275 + wp-admin/edit-form-ajax-cat.php | 37 + wp-admin/edit-form-comment.php | 122 + wp-admin/edit-form.php | 75 + wp-admin/edit-link-form.php | 236 + wp-admin/edit-page-form.php | 225 + wp-admin/edit-pages.php | 79 + wp-admin/edit.php | 299 + wp-admin/execute-pings.php | 25 + wp-admin/images/box-bg.gif | Bin 0 -> 111 bytes wp-admin/images/box-butt.gif | Bin 0 -> 347 bytes wp-admin/images/box-head.gif | Bin 0 -> 879 bytes wp-admin/images/browse-happy.gif | Bin 0 -> 4398 bytes wp-admin/images/fade-butt.png | Bin 0 -> 785 bytes wp-admin/images/notice.gif | Bin 0 -> 156 bytes wp-admin/images/toggle.gif | Bin 0 -> 216 bytes wp-admin/images/wordpress-logo.png | Bin 0 -> 2345 bytes wp-admin/import.php | 62 + wp-admin/import/b2.php | 0 wp-admin/import/blogger.php | 667 ++ wp-admin/import/dotclear.php | 741 ++ wp-admin/import/greymatter.php | 0 wp-admin/import/livejournal.php | 171 + wp-admin/import/mt.php | 430 ++ wp-admin/import/rss.php | 171 + wp-admin/import/textpattern.php | 663 ++ wp-admin/index.php | 172 + wp-admin/inline-uploading.php | 715 ++ wp-admin/install-helper.php | 152 + wp-admin/install.php | 226 + wp-admin/link-add.php | 47 + wp-admin/link-categories.php | 455 ++ wp-admin/link-import.php | 132 + wp-admin/link-manager.php | 445 ++ wp-admin/link-parse-opml.php | 65 + wp-admin/list-manipulation.js | 96 + wp-admin/list-manipulation.php | 81 + wp-admin/menu-header.php | 61 + wp-admin/menu.php | 64 + wp-admin/moderation.php | 222 + wp-admin/options-discussion.php | 100 + wp-admin/options-general.php | 110 + wp-admin/options-head.php | 24 + wp-admin/options-misc.php | 51 + wp-admin/options-permalink.php | 175 + wp-admin/options-reading.php | 63 + wp-admin/options-writing.php | 99 + wp-admin/options.php | 120 + wp-admin/page-new.php | 25 + wp-admin/plugin-editor.php | 123 + wp-admin/plugins.php | 133 + wp-admin/post.php | 429 ++ wp-admin/profile-update.php | 33 + wp-admin/profile.php | 144 + wp-admin/setup-config.php | 156 + wp-admin/sidebar.php | 80 + wp-admin/templates.php | 167 + wp-admin/theme-editor.php | 158 + wp-admin/themes.php | 131 + wp-admin/update-links.php | 44 + wp-admin/upgrade-functions.php | 847 +++ wp-admin/upgrade-schema.php | 339 + wp-admin/upgrade.php | 104 + wp-admin/user-edit.php | 206 + wp-admin/users.php | 328 + wp-admin/wp-admin.css | 949 +++ wp-admin/xfn.js | 46 + wp-atom.php | 45 + wp-blog-header.php | 21 + wp-comments-post.php | 64 + wp-commentsrss2.php | 86 + wp-config-sample.php | 21 + wp-content/index.php | 3 + wp-content/plugins/akismet/akismet.php | 294 + wp-content/plugins/hello.php | 73 + wp-content/plugins/wp-db-backup.php | 889 +++ wp-content/themes/classic/comments-popup.php | 113 + wp-content/themes/classic/comments.php | 75 + wp-content/themes/classic/footer.php | 12 + wp-content/themes/classic/header.php | 30 + wp-content/themes/classic/index.php | 32 + wp-content/themes/classic/screenshot.png | Bin 0 -> 8412 bytes wp-content/themes/classic/sidebar.php | 43 + wp-content/themes/classic/style.css | 313 + wp-content/themes/default/404.php | 11 + wp-content/themes/default/archive.php | 68 + wp-content/themes/default/archives.php | 25 + wp-content/themes/default/attachment.php | 67 + wp-content/themes/default/comments-popup.php | 113 + wp-content/themes/default/comments.php | 104 + wp-content/themes/default/footer.php | 19 + wp-content/themes/default/functions.php | 395 ++ wp-content/themes/default/header.php | 56 + wp-content/themes/default/images/audio.jpg | Bin 0 -> 4671 bytes .../themes/default/images/header-img.php | 77 + .../themes/default/images/kubrickbg.jpg | Bin 0 -> 1043 bytes .../themes/default/images/kubrickbgcolor.jpg | Bin 0 -> 556 bytes .../themes/default/images/kubrickbgwide.jpg | Bin 0 -> 1014 bytes .../themes/default/images/kubrickfooter.jpg | Bin 0 -> 2443 bytes .../themes/default/images/kubrickheader.jpg | Bin 0 -> 7868 bytes wp-content/themes/default/index.php | 39 + wp-content/themes/default/links.php | 18 + wp-content/themes/default/page.php | 21 + wp-content/themes/default/screenshot.png | Bin 0 -> 10608 bytes wp-content/themes/default/search.php | 42 + wp-content/themes/default/searchform.php | 5 + wp-content/themes/default/sidebar.php | 72 + wp-content/themes/default/single.php | 65 + wp-content/themes/default/style.css | 622 ++ wp-feed.php | 37 + wp-includes/cache.php | 427 ++ wp-includes/capabilities.php | 421 ++ wp-includes/class-IXR.php | 815 +++ wp-includes/class-pop3.php | 680 ++ wp-includes/class-snoopy.php | 1259 ++++ wp-includes/classes.php | 1720 +++++ wp-includes/comment-functions.php | 906 +++ wp-includes/default-filters.php | 88 + wp-includes/feed-functions.php | 164 + wp-includes/functions-compat.php | 100 + wp-includes/functions-formatting.php | 1021 +++ wp-includes/functions-post.php | 964 +++ wp-includes/functions.php | 2290 +++++++ wp-includes/gettext.php | 361 + wp-includes/images/smilies/icon_arrow.gif | Bin 0 -> 170 bytes wp-includes/images/smilies/icon_biggrin.gif | Bin 0 -> 172 bytes wp-includes/images/smilies/icon_confused.gif | Bin 0 -> 171 bytes wp-includes/images/smilies/icon_cool.gif | Bin 0 -> 172 bytes wp-includes/images/smilies/icon_cry.gif | Bin 0 -> 498 bytes wp-includes/images/smilies/icon_eek.gif | Bin 0 -> 170 bytes wp-includes/images/smilies/icon_evil.gif | Bin 0 -> 236 bytes wp-includes/images/smilies/icon_exclaim.gif | Bin 0 -> 236 bytes wp-includes/images/smilies/icon_idea.gif | Bin 0 -> 176 bytes wp-includes/images/smilies/icon_lol.gif | Bin 0 -> 336 bytes wp-includes/images/smilies/icon_mad.gif | Bin 0 -> 174 bytes wp-includes/images/smilies/icon_mrgreen.gif | Bin 0 -> 349 bytes wp-includes/images/smilies/icon_neutral.gif | Bin 0 -> 171 bytes wp-includes/images/smilies/icon_question.gif | Bin 0 -> 248 bytes wp-includes/images/smilies/icon_razz.gif | Bin 0 -> 176 bytes wp-includes/images/smilies/icon_redface.gif | Bin 0 -> 650 bytes wp-includes/images/smilies/icon_rolleyes.gif | Bin 0 -> 485 bytes wp-includes/images/smilies/icon_sad.gif | Bin 0 -> 171 bytes wp-includes/images/smilies/icon_smile.gif | Bin 0 -> 174 bytes wp-includes/images/smilies/icon_surprised.gif | Bin 0 -> 174 bytes wp-includes/images/smilies/icon_twisted.gif | Bin 0 -> 238 bytes wp-includes/images/smilies/icon_wink.gif | Bin 0 -> 170 bytes wp-includes/js/colorpicker.js | 707 ++ wp-includes/js/dbx-key.js | 39 + wp-includes/js/dbx.js | 6 + wp-includes/js/fat.js | 90 + wp-includes/js/quicktags.js | 389 ++ wp-includes/js/tinymce/blank.htm | 9 + wp-includes/js/tinymce/langs/en.js | 47 + wp-includes/js/tinymce/license.html | 465 ++ wp-includes/js/tinymce/license.txt | 437 ++ .../tinymce/plugins/autosave/editor_plugin.js | 2 + .../plugins/autosave/editor_plugin_src.js | 30 + .../js/tinymce/plugins/autosave/langs/cs.js | 0 .../js/tinymce/plugins/autosave/langs/en.js | 5 + .../js/tinymce/plugins/autosave/langs/sv.js | 0 .../js/tinymce/plugins/autosave/readme.txt | 1 + .../plugins/directionality/editor_plugin.js | 83 + .../plugins/directionality/images/ltr.gif | Bin 0 -> 155 bytes .../plugins/directionality/images/rtl.gif | Bin 0 -> 153 bytes .../plugins/directionality/langs/en.js | 6 + .../plugins/inlinepopups/css/inlinepopup.css | 0 .../plugins/inlinepopups/editor_plugin.js | 0 .../plugins/inlinepopups/editor_plugin_src.js | 0 .../plugins/inlinepopups/images/spacer.gif | Bin 0 -> 43 bytes .../inlinepopups/images/window_close.gif | Bin 0 -> 110 bytes .../inlinepopups/images/window_maximize.gif | Bin 0 -> 111 bytes .../inlinepopups/images/window_minimize.gif | Bin 0 -> 112 bytes .../inlinepopups/images/window_resize.gif | Bin 0 -> 74 bytes .../inlinepopups/jscripts/mcwindows.js | 0 .../tinymce/plugins/inlinepopups/readme.txt | 0 .../plugins/wordpress/editor_plugin.js | 285 + .../tinymce/plugins/wordpress/images/help.gif | Bin 0 -> 92 bytes .../tinymce/plugins/wordpress/images/more.gif | Bin 0 -> 108 bytes .../plugins/wordpress/images/more_bug.gif | Bin 0 -> 146 bytes .../tinymce/plugins/wordpress/images/page.gif | Bin 0 -> 108 bytes .../plugins/wordpress/images/page_bug.gif | Bin 0 -> 180 bytes .../js/tinymce/plugins/wordpress/langs/en.js | 16 + .../tinymce/plugins/wordpress/wordpress.css | 21 + .../tinymce/plugins/wphelp/editor_plugin.js | 57 + .../js/tinymce/plugins/wphelp/images/help.gif | Bin 0 -> 295 bytes .../js/tinymce/plugins/wphelp/langs/en.js | 5 + .../js/tinymce/themes/advanced/about.htm | 52 + .../js/tinymce/themes/advanced/anchor.htm | 32 + .../js/tinymce/themes/advanced/charmap.htm | 52 + .../tinymce/themes/advanced/color_picker.htm | 12 + .../themes/advanced/css/editor_content.css | 49 + .../themes/advanced/css/editor_popup.css | 319 + .../tinymce/themes/advanced/css/editor_ui.css | 181 + .../themes/advanced/editor_template.js | 13 + .../themes/advanced/editor_template_src.js | 0 .../js/tinymce/themes/advanced/image.htm | 112 + .../tinymce/themes/advanced/images/anchor.gif | Bin 0 -> 171 bytes .../themes/advanced/images/anchor_symbol.gif | Bin 0 -> 70 bytes .../themes/advanced/images/backcolor.gif | Bin 0 -> 174 bytes .../tinymce/themes/advanced/images/bold.gif | Bin 0 -> 76 bytes .../themes/advanced/images/bold_de_se.gif | Bin 0 -> 73 bytes .../themes/advanced/images/bold_fr.gif | Bin 0 -> 78 bytes .../themes/advanced/images/bold_ru.gif | Bin 0 -> 77 bytes .../tinymce/themes/advanced/images/browse.gif | Bin 0 -> 113 bytes .../themes/advanced/images/bullist.gif | Bin 0 -> 108 bytes .../themes/advanced/images/buttons.gif | Bin 0 -> 3286 bytes .../advanced/images/cancel_button_bg.gif | Bin 0 -> 677 bytes .../tinymce/themes/advanced/images/center.gif | Bin 0 -> 70 bytes .../themes/advanced/images/charmap.gif | Bin 0 -> 245 bytes .../themes/advanced/images/cleanup.gif | Bin 0 -> 256 bytes .../tinymce/themes/advanced/images/close.gif | Bin 0 -> 102 bytes .../tinymce/themes/advanced/images/code.gif | Bin 0 -> 110 bytes .../tinymce/themes/advanced/images/color.gif | Bin 0 -> 125 bytes .../tinymce/themes/advanced/images/copy.gif | Bin 0 -> 263 bytes .../themes/advanced/images/custom_1.gif | Bin 0 -> 76 bytes .../js/tinymce/themes/advanced/images/cut.gif | Bin 0 -> 187 bytes .../themes/advanced/images/forecolor.gif | Bin 0 -> 272 bytes .../tinymce/themes/advanced/images/full.gif | Bin 0 -> 71 bytes .../js/tinymce/themes/advanced/images/hr.gif | Bin 0 -> 63 bytes .../tinymce/themes/advanced/images/image.gif | Bin 0 -> 194 bytes .../tinymce/themes/advanced/images/indent.gif | Bin 0 -> 112 bytes .../advanced/images/insert_button_bg.gif | Bin 0 -> 703 bytes .../tinymce/themes/advanced/images/italic.gif | Bin 0 -> 79 bytes .../themes/advanced/images/italic_de_se.gif | Bin 0 -> 75 bytes .../themes/advanced/images/italic_ru.gif | Bin 0 -> 78 bytes .../tinymce/themes/advanced/images/left.gif | Bin 0 -> 71 bytes .../tinymce/themes/advanced/images/link.gif | Bin 0 -> 175 bytes .../themes/advanced/images/newdocument.gif | Bin 0 -> 170 bytes .../themes/advanced/images/numlist.gif | Bin 0 -> 111 bytes .../themes/advanced/images/outdent.gif | Bin 0 -> 110 bytes .../tinymce/themes/advanced/images/paste.gif | Bin 0 -> 286 bytes .../tinymce/themes/advanced/images/redo.gif | Bin 0 -> 169 bytes .../themes/advanced/images/removeformat.gif | Bin 0 -> 168 bytes .../tinymce/themes/advanced/images/right.gif | Bin 0 -> 70 bytes .../tinymce/themes/advanced/images/spacer.gif | Bin 0 -> 43 bytes .../advanced/images/statusbar_resize.gif | Bin 0 -> 79 bytes .../themes/advanced/images/strikethrough.gif | Bin 0 -> 83 bytes .../js/tinymce/themes/advanced/images/sub.gif | Bin 0 -> 148 bytes .../js/tinymce/themes/advanced/images/sup.gif | Bin 0 -> 147 bytes .../tinymce/themes/advanced/images/table.gif | Bin 0 -> 287 bytes .../advanced/images/table_delete_col.gif | Bin 0 -> 163 bytes .../advanced/images/table_delete_row.gif | Bin 0 -> 171 bytes .../images/table_insert_col_after.gif | Bin 0 -> 165 bytes .../images/table_insert_col_before.gif | Bin 0 -> 165 bytes .../images/table_insert_row_after.gif | Bin 0 -> 163 bytes .../images/table_insert_row_before.gif | Bin 0 -> 159 bytes .../themes/advanced/images/underline.gif | Bin 0 -> 88 bytes .../themes/advanced/images/underline_fr.gif | Bin 0 -> 79 bytes .../themes/advanced/images/underline_ru.gif | Bin 0 -> 77 bytes .../tinymce/themes/advanced/images/undo.gif | Bin 0 -> 175 bytes .../tinymce/themes/advanced/images/unlink.gif | Bin 0 -> 190 bytes .../themes/advanced/images/visualaid.gif | Bin 0 -> 206 bytes .../themes/advanced/images/xp/tab_bg.gif | Bin 0 -> 694 bytes .../themes/advanced/images/xp/tab_end.gif | Bin 0 -> 169 bytes .../themes/advanced/images/xp/tab_sel_bg.gif | Bin 0 -> 428 bytes .../themes/advanced/images/xp/tab_sel_end.gif | Bin 0 -> 101 bytes .../themes/advanced/images/xp/tabs_bg.gif | Bin 0 -> 48 bytes .../tinymce/themes/advanced/jscripts/about.js | 74 + .../themes/advanced/jscripts/anchor.js | 59 + .../themes/advanced/jscripts/charmap.js | 324 + .../themes/advanced/jscripts/color_picker.js | 107 + .../tinymce/themes/advanced/jscripts/image.js | 82 + .../tinymce/themes/advanced/jscripts/link.js | 64 + .../themes/advanced/jscripts/source_editor.js | 56 + .../js/tinymce/themes/advanced/langs/en.js | 76 + .../js/tinymce/themes/advanced/link.htm | 113 + .../tinymce/themes/advanced/source_editor.htm | 51 + wp-includes/js/tinymce/tiny_mce.js | 6081 +++++++++++++++++ wp-includes/js/tinymce/tiny_mce_gzip.php | 172 + wp-includes/js/tinymce/tiny_mce_popup.js | 250 + wp-includes/js/tinymce/utils/form_utils.js | 204 + wp-includes/js/tinymce/utils/mctabs.js | 76 + wp-includes/js/tinymce/utils/validate.js | 50 + wp-includes/js/tinymce/wp-mce-help.php | 172 + wp-includes/js/tw-sack.js | 133 + wp-includes/kses.php | 546 ++ wp-includes/links.php | 565 ++ wp-includes/locale.php | 70 + wp-includes/pluggable-functions.php | 432 ++ wp-includes/registration-functions.php | 144 + wp-includes/rss-functions.php | 856 +++ wp-includes/streams.php | 159 + wp-includes/template-functions-author.php | 234 + wp-includes/template-functions-category.php | 415 ++ wp-includes/template-functions-general.php | 707 ++ wp-includes/template-functions-links.php | 526 ++ wp-includes/template-functions-post.php | 567 ++ wp-includes/template-loader.php | 67 + wp-includes/vars.php | 113 + wp-includes/version.php | 8 + wp-includes/wp-db.php | 363 + wp-includes/wp-l10n.php | 97 + wp-links-opml.php | 61 + wp-login.php | 258 + wp-mail.php | 166 + wp-pass.php | 11 + wp-rdf.php | 57 + wp-register.php | 161 + wp-rss.php | 37 + wp-rss2.php | 56 + wp-settings.php | 226 + wp-trackback.php | 98 + xmlrpc.php | 1289 ++++ 315 files changed, 50999 insertions(+) create mode 100644 index.php create mode 100644 license.txt create mode 100644 readme.html create mode 100644 wp-admin/admin-db.php create mode 100644 wp-admin/admin-footer.php create mode 100644 wp-admin/admin-functions.php create mode 100644 wp-admin/admin-header.php create mode 100644 wp-admin/admin.php create mode 100644 wp-admin/bookmarklet.php create mode 100644 wp-admin/cat-js.php create mode 100644 wp-admin/categories.php create mode 100644 wp-admin/edit-comments.php create mode 100644 wp-admin/edit-form-advanced.php create mode 100644 wp-admin/edit-form-ajax-cat.php create mode 100644 wp-admin/edit-form-comment.php create mode 100644 wp-admin/edit-form.php create mode 100644 wp-admin/edit-link-form.php create mode 100644 wp-admin/edit-page-form.php create mode 100644 wp-admin/edit-pages.php create mode 100644 wp-admin/edit.php create mode 100644 wp-admin/execute-pings.php create mode 100644 wp-admin/images/box-bg.gif create mode 100644 wp-admin/images/box-butt.gif create mode 100644 wp-admin/images/box-head.gif create mode 100644 wp-admin/images/browse-happy.gif create mode 100644 wp-admin/images/fade-butt.png create mode 100644 wp-admin/images/notice.gif create mode 100644 wp-admin/images/toggle.gif create mode 100644 wp-admin/images/wordpress-logo.png create mode 100644 wp-admin/import.php create mode 100644 wp-admin/import/b2.php create mode 100644 wp-admin/import/blogger.php create mode 100644 wp-admin/import/dotclear.php create mode 100644 wp-admin/import/greymatter.php create mode 100644 wp-admin/import/livejournal.php create mode 100644 wp-admin/import/mt.php create mode 100644 wp-admin/import/rss.php create mode 100644 wp-admin/import/textpattern.php create mode 100644 wp-admin/index.php create mode 100644 wp-admin/inline-uploading.php create mode 100644 wp-admin/install-helper.php create mode 100644 wp-admin/install.php create mode 100644 wp-admin/link-add.php create mode 100644 wp-admin/link-categories.php create mode 100644 wp-admin/link-import.php create mode 100644 wp-admin/link-manager.php create mode 100644 wp-admin/link-parse-opml.php create mode 100644 wp-admin/list-manipulation.js create mode 100644 wp-admin/list-manipulation.php create mode 100644 wp-admin/menu-header.php create mode 100644 wp-admin/menu.php create mode 100644 wp-admin/moderation.php create mode 100644 wp-admin/options-discussion.php create mode 100644 wp-admin/options-general.php create mode 100644 wp-admin/options-head.php create mode 100644 wp-admin/options-misc.php create mode 100644 wp-admin/options-permalink.php create mode 100644 wp-admin/options-reading.php create mode 100644 wp-admin/options-writing.php create mode 100644 wp-admin/options.php create mode 100644 wp-admin/page-new.php create mode 100644 wp-admin/plugin-editor.php create mode 100644 wp-admin/plugins.php create mode 100644 wp-admin/post.php create mode 100644 wp-admin/profile-update.php create mode 100644 wp-admin/profile.php create mode 100644 wp-admin/setup-config.php create mode 100644 wp-admin/sidebar.php create mode 100644 wp-admin/templates.php create mode 100644 wp-admin/theme-editor.php create mode 100644 wp-admin/themes.php create mode 100644 wp-admin/update-links.php create mode 100644 wp-admin/upgrade-functions.php create mode 100644 wp-admin/upgrade-schema.php create mode 100644 wp-admin/upgrade.php create mode 100644 wp-admin/user-edit.php create mode 100644 wp-admin/users.php create mode 100644 wp-admin/wp-admin.css create mode 100644 wp-admin/xfn.js create mode 100644 wp-atom.php create mode 100644 wp-blog-header.php create mode 100644 wp-comments-post.php create mode 100644 wp-commentsrss2.php create mode 100644 wp-config-sample.php create mode 100644 wp-content/index.php create mode 100644 wp-content/plugins/akismet/akismet.php create mode 100644 wp-content/plugins/hello.php create mode 100644 wp-content/plugins/wp-db-backup.php create mode 100644 wp-content/themes/classic/comments-popup.php create mode 100644 wp-content/themes/classic/comments.php create mode 100644 wp-content/themes/classic/footer.php create mode 100644 wp-content/themes/classic/header.php create mode 100644 wp-content/themes/classic/index.php create mode 100644 wp-content/themes/classic/screenshot.png create mode 100644 wp-content/themes/classic/sidebar.php create mode 100644 wp-content/themes/classic/style.css create mode 100644 wp-content/themes/default/404.php create mode 100644 wp-content/themes/default/archive.php create mode 100644 wp-content/themes/default/archives.php create mode 100644 wp-content/themes/default/attachment.php create mode 100644 wp-content/themes/default/comments-popup.php create mode 100644 wp-content/themes/default/comments.php create mode 100644 wp-content/themes/default/footer.php create mode 100644 wp-content/themes/default/functions.php create mode 100644 wp-content/themes/default/header.php create mode 100644 wp-content/themes/default/images/audio.jpg create mode 100644 wp-content/themes/default/images/header-img.php create mode 100644 wp-content/themes/default/images/kubrickbg.jpg create mode 100644 wp-content/themes/default/images/kubrickbgcolor.jpg create mode 100644 wp-content/themes/default/images/kubrickbgwide.jpg create mode 100644 wp-content/themes/default/images/kubrickfooter.jpg create mode 100644 wp-content/themes/default/images/kubrickheader.jpg create mode 100644 wp-content/themes/default/index.php create mode 100644 wp-content/themes/default/links.php create mode 100644 wp-content/themes/default/page.php create mode 100644 wp-content/themes/default/screenshot.png create mode 100644 wp-content/themes/default/search.php create mode 100644 wp-content/themes/default/searchform.php create mode 100644 wp-content/themes/default/sidebar.php create mode 100644 wp-content/themes/default/single.php create mode 100644 wp-content/themes/default/style.css create mode 100644 wp-feed.php create mode 100644 wp-includes/cache.php create mode 100644 wp-includes/capabilities.php create mode 100644 wp-includes/class-IXR.php create mode 100644 wp-includes/class-pop3.php create mode 100644 wp-includes/class-snoopy.php create mode 100644 wp-includes/classes.php create mode 100644 wp-includes/comment-functions.php create mode 100644 wp-includes/default-filters.php create mode 100644 wp-includes/feed-functions.php create mode 100644 wp-includes/functions-compat.php create mode 100644 wp-includes/functions-formatting.php create mode 100644 wp-includes/functions-post.php create mode 100644 wp-includes/functions.php create mode 100644 wp-includes/gettext.php create mode 100644 wp-includes/images/smilies/icon_arrow.gif create mode 100644 wp-includes/images/smilies/icon_biggrin.gif create mode 100644 wp-includes/images/smilies/icon_confused.gif create mode 100644 wp-includes/images/smilies/icon_cool.gif create mode 100644 wp-includes/images/smilies/icon_cry.gif create mode 100644 wp-includes/images/smilies/icon_eek.gif create mode 100644 wp-includes/images/smilies/icon_evil.gif create mode 100644 wp-includes/images/smilies/icon_exclaim.gif create mode 100644 wp-includes/images/smilies/icon_idea.gif create mode 100644 wp-includes/images/smilies/icon_lol.gif create mode 100644 wp-includes/images/smilies/icon_mad.gif create mode 100644 wp-includes/images/smilies/icon_mrgreen.gif create mode 100644 wp-includes/images/smilies/icon_neutral.gif create mode 100644 wp-includes/images/smilies/icon_question.gif create mode 100644 wp-includes/images/smilies/icon_razz.gif create mode 100644 wp-includes/images/smilies/icon_redface.gif create mode 100644 wp-includes/images/smilies/icon_rolleyes.gif create mode 100644 wp-includes/images/smilies/icon_sad.gif create mode 100644 wp-includes/images/smilies/icon_smile.gif create mode 100644 wp-includes/images/smilies/icon_surprised.gif create mode 100644 wp-includes/images/smilies/icon_twisted.gif create mode 100644 wp-includes/images/smilies/icon_wink.gif create mode 100644 wp-includes/js/colorpicker.js create mode 100644 wp-includes/js/dbx-key.js create mode 100644 wp-includes/js/dbx.js create mode 100644 wp-includes/js/fat.js create mode 100644 wp-includes/js/quicktags.js create mode 100644 wp-includes/js/tinymce/blank.htm create mode 100644 wp-includes/js/tinymce/langs/en.js create mode 100644 wp-includes/js/tinymce/license.html create mode 100644 wp-includes/js/tinymce/license.txt create mode 100644 wp-includes/js/tinymce/plugins/autosave/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js create mode 100644 wp-includes/js/tinymce/plugins/autosave/langs/cs.js create mode 100644 wp-includes/js/tinymce/plugins/autosave/langs/en.js create mode 100644 wp-includes/js/tinymce/plugins/autosave/langs/sv.js create mode 100644 wp-includes/js/tinymce/plugins/autosave/readme.txt create mode 100644 wp-includes/js/tinymce/plugins/directionality/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/directionality/images/ltr.gif create mode 100644 wp-includes/js/tinymce/plugins/directionality/images/rtl.gif create mode 100644 wp-includes/js/tinymce/plugins/directionality/langs/en.js create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/images/spacer.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/images/window_close.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/images/window_maximize.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/images/window_minimize.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/images/window_resize.gif create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js create mode 100644 wp-includes/js/tinymce/plugins/inlinepopups/readme.txt create mode 100644 wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/help.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/more.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/more_bug.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/page.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif create mode 100644 wp-includes/js/tinymce/plugins/wordpress/langs/en.js create mode 100644 wp-includes/js/tinymce/plugins/wordpress/wordpress.css create mode 100644 wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/wphelp/images/help.gif create mode 100644 wp-includes/js/tinymce/plugins/wphelp/langs/en.js create mode 100644 wp-includes/js/tinymce/themes/advanced/about.htm create mode 100644 wp-includes/js/tinymce/themes/advanced/anchor.htm create mode 100644 wp-includes/js/tinymce/themes/advanced/charmap.htm create mode 100644 wp-includes/js/tinymce/themes/advanced/color_picker.htm create mode 100644 wp-includes/js/tinymce/themes/advanced/css/editor_content.css create mode 100644 wp-includes/js/tinymce/themes/advanced/css/editor_popup.css create mode 100644 wp-includes/js/tinymce/themes/advanced/css/editor_ui.css create mode 100644 wp-includes/js/tinymce/themes/advanced/editor_template.js create mode 100644 wp-includes/js/tinymce/themes/advanced/editor_template_src.js create mode 100644 wp-includes/js/tinymce/themes/advanced/image.htm create mode 100644 wp-includes/js/tinymce/themes/advanced/images/anchor.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/anchor_symbol.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/backcolor.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/bold.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/bold_de_se.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/bold_fr.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/bold_ru.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/browse.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/bullist.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/buttons.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/cancel_button_bg.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/center.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/charmap.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/cleanup.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/close.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/code.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/color.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/copy.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/custom_1.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/cut.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/forecolor.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/full.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/hr.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/image.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/indent.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/insert_button_bg.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/italic.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/italic_de_se.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/italic_ru.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/left.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/link.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/newdocument.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/numlist.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/outdent.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/paste.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/redo.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/removeformat.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/right.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/spacer.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/statusbar_resize.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/strikethrough.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/sub.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/sup.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/table.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_delete_col.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_delete_row.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_insert_col_after.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_insert_col_before.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_insert_row_after.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/table_insert_row_before.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/underline.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/underline_fr.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/underline_ru.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/undo.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/unlink.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/visualaid.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/xp/tab_bg.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/xp/tab_end.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_bg.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_end.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/images/xp/tabs_bg.gif create mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/about.js create mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js create mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js create mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js create mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/image.js create mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/link.js create mode 100644 wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js create mode 100644 wp-includes/js/tinymce/themes/advanced/langs/en.js create mode 100644 wp-includes/js/tinymce/themes/advanced/link.htm create mode 100644 wp-includes/js/tinymce/themes/advanced/source_editor.htm create mode 100644 wp-includes/js/tinymce/tiny_mce.js create mode 100644 wp-includes/js/tinymce/tiny_mce_gzip.php create mode 100644 wp-includes/js/tinymce/tiny_mce_popup.js create mode 100644 wp-includes/js/tinymce/utils/form_utils.js create mode 100644 wp-includes/js/tinymce/utils/mctabs.js create mode 100644 wp-includes/js/tinymce/utils/validate.js create mode 100644 wp-includes/js/tinymce/wp-mce-help.php create mode 100644 wp-includes/js/tw-sack.js create mode 100644 wp-includes/kses.php create mode 100644 wp-includes/links.php create mode 100644 wp-includes/locale.php create mode 100644 wp-includes/pluggable-functions.php create mode 100644 wp-includes/registration-functions.php create mode 100644 wp-includes/rss-functions.php create mode 100644 wp-includes/streams.php create mode 100644 wp-includes/template-functions-author.php create mode 100644 wp-includes/template-functions-category.php create mode 100644 wp-includes/template-functions-general.php create mode 100644 wp-includes/template-functions-links.php create mode 100644 wp-includes/template-functions-post.php create mode 100644 wp-includes/template-loader.php create mode 100644 wp-includes/vars.php create mode 100644 wp-includes/version.php create mode 100644 wp-includes/wp-db.php create mode 100644 wp-includes/wp-l10n.php create mode 100644 wp-links-opml.php create mode 100644 wp-login.php create mode 100644 wp-mail.php create mode 100644 wp-pass.php create mode 100644 wp-rdf.php create mode 100644 wp-register.php create mode 100644 wp-rss.php create mode 100644 wp-rss2.php create mode 100644 wp-settings.php create mode 100644 wp-trackback.php create mode 100644 xmlrpc.php diff --git a/index.php b/index.php new file mode 100644 index 00000000..3e3db402 --- /dev/null +++ b/index.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/license.txt b/license.txt new file mode 100644 index 00000000..88822058 --- /dev/null +++ b/license.txt @@ -0,0 +1,280 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + diff --git a/readme.html b/readme.html new file mode 100644 index 00000000..2a630165 --- /dev/null +++ b/readme.html @@ -0,0 +1,120 @@ + + + +WordPress › ReadMe + + + + +

WordPress
+ Version 2.0

+

Semantic Personal Publishing Platform

+

First Things First

+

Welcome. WordPress is a very special project to me. Every developer and contributor adds something unique to the mix, and together we create something beautiful that I'm proud to be a part of. Thousands of hours have gone into WordPress, and we're dedicated to making it better every day. Thank you for making it part of your world.

+

— Matt Mullenweg

+ +

Installation: Famous 5-minute install

+
    +
  1. Unzip the package in an empty directory
  2. +
  3. Open up wp-config-sample.php with a text editor like WordPad or similar and fill in your database connection details
  4. +
  5. Save the file as wp-config.php
  6. +
  7. Upload everything.
  8. +
  9. Open /wp-admin/install.php in your browser. This should setup the tables needed for your blog. If there is an error, double check your wp-config.php file, and try again. If it fails again, please go to the support forums with as much data as you can gather.
  10. +
  11. Note the password given to you.
  12. +
  13. The install script should then send you to the login page. Sign in with the username admin and the password generated during the installation. You can then click on 'Profile' to change the password.
  14. +
+ +

Upgrading

+

Before you upgrade anything, make sure you have backup copies of any files you may have modified such as index.php.

+

Upgrading from any previous WordPress to 2.0:

+
    +
  1. Delete your old WP files, saving ones you've modified
  2. +
  3. Upload the new files
  4. +
  5. Point your browser to /wp-admin/upgrade.php
  6. +
  7. You wanted more, perhaps? That's it!
  8. +
+

Template Changes

+

If you have customized your templates you will probably have to make some changes to them. If you're converting your 1.2 or earlier templates, we've created a special guide for you.

+

Online Resources

+

If you have any questions that aren't addressed in this document, please take advantage of WordPress' numerous online resources:

+
+
The WordPress Codex
+
The Codex is the encyclopedia of all things WordPress. It is the most comprehensive source of information for WordPress available.
+
The Development Blog
+
This is where you'll find the latest updates and news related to WordPress. Bookmark and check often.
+
WordPress Planet
+
The WordPress Planet is a news aggregator that brings together posts from WordPress blogs around the web.
+
WordPress Support Forums
+
If you've looked everywhere and still can't find an answer, the support forums are very active and have a large community ready to help. To help them help you be sure to use a descriptive thread title and describe your question in as much detail as possible.
+
WordPress IRC Channel
+
Finally, there is an online chat channel that is used for discussion amoung people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (irc.freenode.net #wordpresss)
+
+ +

System Recommendations

+ +

WordPress is the official continuation of b2/cafélog, which came from Michel V. The work has been continued by the WordPress developers. If you would like to support WordPress, please consider donating.

+ +

Upgrading from another system

+

WordPress can import from a number of systems. First you need to get WordPress installed and working as described above.

+ +

XML-RPC Interface

+

You can now post to your WordPress blog with tools like Ecto, BlogBuddy, Bloggar, WapBlogger (post from your Wap cellphone!), Radio Userland (which means you can use Radio's email-to-blog feature), Zempt, NewzCrawler, and other tools that support the Blogging APIs! :) You can read more about XML-RPC support on the Codex.

+ +

Post via Email

+

You can post from an email client! To set this up go to your "Writing" options screen and fill in the connection details for your secret POP3 account. Then you need to set up wp-mail.php to execute periodically to check the mailbox for new posts. You can do it with Cron-jobs, or if your host doesn't support it you can look into the various website-monitoring services, and make them check your wp-mail.php URL.

+

Posting is easy: Any email sent to the address you specify will be posted, with the subject as the title. It is best to keep the address dicrete. The script will delete emails that are successfully posted.

+

User Roles

+ +

We've eliminated user levels in order to make way for the much more flexible roles system introduced in 2.0. You can read more about Roles and Capabilities on the Codex.

+ +

Final notes

+ + +

Share the Love

+

WordPress has no multi-million dollar marketing campaign or celebrity sponsors, but we do have something even better—you. If you enjoy WordPress please consider telling a friend, setting it up for someone less knowledgable than yourself, or writing the author of a media article that overlooks us.

+ +

Copyright

+

WordPress is released under the GPL (see license.txt).

+ + + \ No newline at end of file diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php new file mode 100644 index 00000000..bf8692ab --- /dev/null +++ b/wp-admin/admin-db.php @@ -0,0 +1,349 @@ +posts WHERE post_status = 'draft' AND post_author = $user_id ORDER BY ID DESC"; + $query = apply_filters('get_users_drafts', $query); + return $wpdb->get_results( $query ); +} + +function get_others_drafts( $user_id ) { + global $wpdb; + $user = get_userdata( $user_id ); + $level_key = $wpdb->prefix . 'user_level'; + + $editable = get_editable_user_ids( $user_id ); + + if( !$editable ) { + $other_drafts = ''; + } else { + $editable = join(',', $editable); + $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' "); + } + + return apply_filters('get_others_drafts', $other_drafts); +} + +function get_editable_authors( $user_id ) { + global $wpdb; + + $editable = get_editable_user_ids( $user_id ); + + if( !$editable ) { + return false; + } else { + $editable = join(',', $editable); + $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable)" ); + } + + return apply_filters('get_editable_authors', $authors); +} + +function get_editable_user_ids( $user_id, $exclude_zeros = true ) { + global $wpdb; + + $user = new WP_User( $user_id ); + + if ( ! $user->has_cap('edit_others_posts') ) { + if ( $user->has_cap('edit_posts') || $exclude_zeros == false ) + return array($user->id); + else + return false; + } + + $level_key = $wpdb->prefix . 'user_level'; + + $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key'"; + if ( $exclude_zeros ) + $query .= " AND meta_value != '0'"; + + return $wpdb->get_col( $query ); +} + +function get_author_user_ids() { + global $wpdb; + $level_key = $wpdb->prefix . 'user_level'; + + $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value != '0'"; + + return $wpdb->get_col( $query ); +} + +function get_nonauthor_user_ids() { + global $wpdb; + $level_key = $wpdb->prefix . 'user_level'; + + $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value = '0'"; + + return $wpdb->get_col( $query ); +} + +function wp_insert_category($catarr) { + global $wpdb; + + extract($catarr); + + $cat_ID = (int) $cat_ID; + + // Are we updating or creating? + if (!empty ($cat_ID)) + $update = true; + else + $update = false; + + $cat_name = wp_specialchars($cat_name); + + if (empty ($category_nicename)) + $category_nicename = sanitize_title($cat_name); + else + $category_nicename = sanitize_title($category_nicename); + + if (empty ($category_description)) + $category_description = ''; + + if (empty ($category_parent)) + $category_parent = 0; + + if (!$update) { + $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent')"); + $cat_ID = $wpdb->insert_id; + } else { + $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'"); + } + + if ( $category_nicename == '' ) { + $category_nicename = sanitize_title($cat_name, $cat_ID ); + $wpdb->query( "UPDATE $wpdb->categories SET category_nicename = '$category_nicename' WHERE cat_ID = '$cat_ID'" ); + } + + wp_cache_delete($cat_ID, 'category'); + + if ($update) { + do_action('edit_category', $cat_ID); + } else { + wp_cache_delete('all_category_ids', 'category'); + do_action('create_category', $cat_ID); + do_action('add_category', $cat_ID); + } + + return $cat_ID; +} + +function wp_update_category($catarr) { + global $wpdb; + + $cat_ID = (int) $catarr['cat_ID']; + + // First, get all of the original fields + $category = get_category($cat_ID, ARRAY_A); + + // Escape data pulled from DB. + $category = add_magic_quotes($category); + + // Merge old and new fields with new fields overwriting old ones. + $catarr = array_merge($category, $catarr); + + return wp_insert_category($catarr); +} + +function wp_delete_category($cat_ID) { + global $wpdb; + + $cat_ID = (int) $cat_ID; + + // Don't delete the default cat. + if (1 == $cat_ID) + return 0; + + $category = get_category($cat_ID); + + $parent = $category->category_parent; + + // Delete the category. + $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); + + // Update children to point to new parent. + $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'"); + + // TODO: Only set categories to general if they're not in another category already + $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'"); + + wp_cache_delete($cat_ID, 'category'); + wp_cache_delete('all_category_ids', 'category'); + + do_action('delete_category', $cat_ID); + + return 1; +} + +function wp_create_category($cat_name) { + $cat_array = compact('cat_name'); + return wp_insert_category($cat_array); +} + +function wp_create_categories($categories, $post_id = '') { + $cat_ids = array (); + foreach ($categories as $category) { + if ($id = category_exists($category)) + $cat_ids[] = $id; + else + if ($id = wp_create_category($category)) + $cat_ids[] = $id; + } + + if ($post_id) + wp_set_post_cats('', $post_id, $cat_ids); + + return $cat_ids; +} + +function category_exists($cat_name) { + global $wpdb; + if (!$category_nicename = sanitize_title($cat_name)) + return 0; + + return $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'"); +} + +function wp_delete_user($id, $reassign = 'novalue') { + global $wpdb; + + $id = (int) $id; + $user = get_userdata($id); + + if ($reassign == 'novalue') { + $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); + + if ($post_ids) { + foreach ($post_ids as $post_id) + wp_delete_post($post_id); + } + + // Clean links + $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id"); + } else { + $reassign = (int) $reassign; + $wpdb->query("UPDATE $wpdb->posts SET post_author = {$reassign} WHERE post_author = {$id}"); + $wpdb->query("UPDATE $wpdb->links SET link_owner = {$reassign} WHERE link_owner = {$id}"); + } + + // FINALLY, delete user + $wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id"); + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$id'"); + + wp_cache_delete($id, 'users'); + wp_cache_delete($user->user_login, 'userlogins'); + + do_action('delete_user', $id); + + return true; +} + +function get_link($link_id, $output = OBJECT) { + global $wpdb; + + $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$link_id'"); + + if ( $output == OBJECT ) { + return $link; + } elseif ( $output == ARRAY_A ) { + return get_object_vars($link); + } elseif ( $output == ARRAY_N ) { + return array_values(get_object_vars($link)); + } else { + return $link; + } +} + +function wp_insert_link($linkdata) { + global $wpdb, $current_user; + + extract($linkdata); + + $update = false; + if ( !empty($link_id) ) + $update = true; + + if ( empty($link_rating) ) + $link_rating = 0; + + if ( empty($link_target) ) + $link_target = ''; + + if ( empty($link_visible) ) + $link_visible = 'Y'; + + if ( empty($link_owner) ) + $link_owner = $current_user->id; + + if ( empty($link_notes) ) + $link_notes = ''; + + if ( $update ) { + $wpdb->query("UPDATE $wpdb->links SET link_url='$link_url', + link_name='$link_name', link_image='$link_image', + link_target='$link_target', link_category='$link_category', + link_visible='$link_visible', link_description='$link_description', + link_rating='$link_rating', link_rel='$link_rel', + link_notes='$link_notes', link_rss = '$link_rss' + WHERE link_id='$link_id'"); + } else { + $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_category', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')"); + $link_id = $wpdb->insert_id; + } + + if ( $update ) + do_action('edit_link', $link_id); + else + do_action('add_link', $link_id); + + return $link_id; +} + +function wp_update_link($linkdata) { + global $wpdb; + + $link_id = (int) $linkdata['link_id']; + + $link = get_link($link_id, ARRAY_A); + + // Escape data pulled from DB. + $link = add_magic_quotes($link); + + // Merge old and new fields with new fields overwriting old ones. + $linkdata = array_merge($link, $linkdata); + + return wp_insert_link($linkdata); +} + +function wp_delete_link($link_id) { + global $wpdb; + + do_action('delete_link', $link_id); + return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'"); +} + +function post_exists($title, $content = '', $post_date = '') { + global $wpdb; + + if (!empty ($post_date)) + $post_date = "AND post_date = '$post_date'"; + + if (!empty ($title)) + return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' $post_date"); + else + if (!empty ($content)) + return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' $post_date"); + + return 0; +} + +function comment_exists($comment_author, $comment_date) { + global $wpdb; + + return $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments + WHERE comment_author = '$comment_author' AND comment_date = '$comment_date'"); +} + +?> diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php new file mode 100644 index 00000000..e660be28 --- /dev/null +++ b/wp-admin/admin-footer.php @@ -0,0 +1,19 @@ + + + + + +'; +} +?> + + + diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php new file mode 100644 index 00000000..6afef35b --- /dev/null +++ b/wp-admin/admin-functions.php @@ -0,0 +1,1889 @@ + 31) ? 31 : $jj; + $hh = ($hh > 23) ? $hh -24 : $hh; + $mn = ($mn > 59) ? $mn -60 : $mn; + $ss = ($ss > 59) ? $ss -60 : $ss; + $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; + $_POST['post_date_gmt'] = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss"); + } + + // Create the post. + $post_ID = wp_insert_post($_POST); + add_meta($post_ID); + + // Reunite any orphaned attachments with their parent + if ( $_POST['temp_ID'] ) + relocate_children($_POST['temp_ID'], $post_ID); + + // Now that we have an ID we can fix any attachment anchor hrefs + fix_attachment_links($post_ID); + + return $post_ID; +} + +// Move child posts to a new parent +function relocate_children($old_ID, $new_ID) { + global $wpdb; + $old_ID = (int) $old_ID; + $new_ID = (int) $new_ID; + return $wpdb->query("UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID"); +} + +// Replace hrefs of attachment anchors with up-to-date permalinks. +function fix_attachment_links($post_ID) { + global $wp_rewrite; + + $post = & get_post($post_ID, ARRAY_A); + + $search = "#]+rel=('|\")[^'\"]*attachment[^>]*>#ie"; + + // See if we have any rel="attachment" links + if ( 0 == preg_match_all($search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER) ) + return; + + $i = 0; + $search = "# id=(\"|')p(\d+)\\1#i"; + foreach ( $anchor_matches[0] as $anchor ) { + if ( 0 == preg_match($search, $anchor, $id_matches) ) + continue; + + $id = $id_matches[2]; + + // While we have the attachment ID, let's adopt any orphans. + $attachment = & get_post($id, ARRAY_A); + if ( ! empty($attachment) && ! is_object(get_post($attachment['post_parent'])) ) { + $attachment['post_parent'] = $post_ID; + // Escape data pulled from DB. + $attachment = add_magic_quotes($attachment); + wp_update_post($attachment); + } + + $post_search[$i] = $anchor; + $post_replace[$i] = preg_replace("#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor); + ++$i; + } + + $post['post_content'] = str_replace($post_search, $post_replace, $post['post_content']); + + // Escape data pulled from DB. + $post = add_magic_quotes($post); + + return wp_update_post($post); +} + +// Update an existing post with values provided in $_POST. +function edit_post() { + global $user_ID; + + $post_ID = (int) $_POST['post_ID']; + + if (!current_user_can('edit_post', $post_ID)) + die(__('You are not allowed to edit this post.')); + + // Rename. + $_POST['ID'] = (int) $_POST['post_ID']; + $_POST['post_content'] = $_POST['content']; + $_POST['post_excerpt'] = $_POST['excerpt']; + $_POST['post_parent'] = $_POST['parent_id']; + $_POST['to_ping'] = $_POST['trackback_url']; + + if (!empty ($_POST['post_author_override'])) { + $_POST['post_author'] = (int) $_POST['post_author_override']; + } else + if (!empty ($_POST['post_author'])) { + $_POST['post_author'] = (int) $_POST['post_author']; + } else { + $_POST['post_author'] = (int) $_POST['user_ID']; + } + + if (($_POST['post_author'] != $_POST['user_ID']) && !current_user_can('edit_others_posts')) + die(__('You cannot post as this user.')); + + // What to do based on which button they pressed + if ('' != $_POST['saveasdraft']) + $_POST['post_status'] = 'draft'; + if ('' != $_POST['saveasprivate']) + $_POST['post_status'] = 'private'; + if ('' != $_POST['publish']) + $_POST['post_status'] = 'publish'; + if ('' != $_POST['advanced']) + $_POST['post_status'] = 'draft'; + if ('' != $_POST['savepage']) + $_POST['post_status'] = 'static'; + + if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts')) + $_POST['post_status'] = 'draft'; + + if ('static' == $_POST['post_status'] && !current_user_can('edit_pages')) + die(__('This user cannot edit pages.')); + + if (!isset ($_POST['comment_status'])) + $_POST['comment_status'] = 'closed'; + + if (!isset ($_POST['ping_status'])) + $_POST['ping_status'] = 'closed'; + + if (!empty ($_POST['edit_date'])) { + $aa = $_POST['aa']; + $mm = $_POST['mm']; + $jj = $_POST['jj']; + $hh = $_POST['hh']; + $mn = $_POST['mn']; + $ss = $_POST['ss']; + $jj = ($jj > 31) ? 31 : $jj; + $hh = ($hh > 23) ? $hh -24 : $hh; + $mn = ($mn > 59) ? $mn -60 : $mn; + $ss = ($ss > 59) ? $ss -60 : $ss; + $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; + $_POST['post_date_gmt'] = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss"); + } + + // Meta Stuff + if ($_POST['meta']) { + foreach ($_POST['meta'] as $key => $value) + update_meta($key, $value['key'], $value['value']); + } + + if ($_POST['deletemeta']) { + foreach ($_POST['deletemeta'] as $key => $value) + delete_meta($key); + } + + add_meta($post_ID); + + wp_update_post($_POST); + + // Now that we have an ID we can fix any attachment anchor hrefs + fix_attachment_links($post_ID); + + return $post_ID; +} + +function edit_comment() { + global $user_ID; + + $comment_ID = (int) $_POST['comment_ID']; + $comment_post_ID = (int) $_POST['comment_post_ID']; + + if (!current_user_can('edit_post', $comment_post_ID)) + die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.')); + + $_POST['comment_author'] = $_POST['newcomment_author']; + $_POST['comment_author_email'] = $_POST['newcomment_author_email']; + $_POST['comment_author_url'] = $_POST['newcomment_author_url']; + $_POST['comment_approved'] = $_POST['comment_status']; + $_POST['comment_content'] = $_POST['content']; + $_POST['comment_ID'] = (int) $_POST['comment_ID']; + + if (!empty ($_POST['edit_date'])) { + $aa = $_POST['aa']; + $mm = $_POST['mm']; + $jj = $_POST['jj']; + $hh = $_POST['hh']; + $mn = $_POST['mn']; + $ss = $_POST['ss']; + $jj = ($jj > 31) ? 31 : $jj; + $hh = ($hh > 23) ? $hh -24 : $hh; + $mn = ($mn > 59) ? $mn -60 : $mn; + $ss = ($ss > 59) ? $ss -60 : $ss; + $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; + } + + wp_update_comment($_POST); +} + +// Get an existing post and format it for editing. +function get_post_to_edit($id) { + global $richedit; + $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false; + + $post = get_post($id); + + $post->post_content = format_to_edit($post->post_content, $richedit); + $post->post_content = apply_filters('content_edit_pre', $post->post_content); + + $post->post_excerpt = format_to_edit($post->post_excerpt); + $post->post_excerpt = apply_filters('excerpt_edit_pre', $post->post_excerpt); + + $post->post_title = format_to_edit($post->post_title); + $post->post_title = apply_filters('title_edit_pre', $post->post_title); + + if ($post->post_status == 'static') + $post->page_template = get_post_meta($id, '_wp_page_template', true); + + return $post; +} + +// Default post information to use when populating the "Write Post" form. +function get_default_post_to_edit() { + if ( !empty($_REQUEST['post_title']) ) + $post_title = wp_specialchars(stripslashes($_REQUEST['post_title'])); + else if ( !empty($_REQUEST['popuptitle']) ) { + $post_title = wp_specialchars(stripslashes($_REQUEST['popuptitle'])); + $post_title = funky_javascript_fix($post_title); + } else { + $post_title = ''; + } + + if ( !empty($_REQUEST['content']) ) + $post_content = wp_specialchars(stripslashes($_REQUEST['content'])); + else if ( !empty($post_title) ) { + $text = wp_specialchars(stripslashes(urldecode($_REQUEST['text']))); + $text = funky_javascript_fix($text); + $popupurl = wp_specialchars($_REQUEST['popupurl']); + $post_content = ''.$post_title.''."\n$text"; + } + + if ( !empty($_REQUEST['excerpt']) ) + $post_excerpt = wp_specialchars(stripslashes($_REQUEST['excerpt'])); + else + $post_excerpt = ''; + + $post->post_status = 'draft'; + $post->comment_status = get_settings('default_comment_status'); + $post->ping_status = get_settings('default_ping_status'); + $post->post_pingback = get_settings('default_pingback_flag'); + $post->post_category = get_settings('default_category'); + $post->post_content = apply_filters('default_content', $post_content); + $post->post_title = apply_filters('default_title', $post_title); + $post->post_excerpt = apply_filters('default_excerpt', $post_excerpt); + $post->page_template = 'default'; + $post->post_parent = 0; + $post->menu_order = 0; + + return $post; +} + +function get_comment_to_edit($id) { + global $richedit; + $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false; + + $comment = get_comment($id); + + $comment->comment_content = format_to_edit($comment->comment_content, $richedit); + $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content); + + $comment->comment_author = format_to_edit($comment->comment_author); + $comment->comment_author_email = format_to_edit($comment->comment_author_email); + $comment->comment_author_url = format_to_edit($comment->comment_author_url); + + return $comment; +} + +function get_category_to_edit($id) { + $category = get_category($id); + + return $category; +} + +// Creates a new user from the "Users" form using $_POST information. + +function add_user() { + return edit_user(); +} + +function edit_user($user_id = 0) { + global $current_user, $wp_roles, $wpdb; + + if ($user_id != 0) { + $update = true; + $user->ID = $user_id; + $userdata = get_userdata($user_id); + $user->user_login = $wpdb->escape($userdata->user_login); + } else { + $update = false; + $user = ''; + } + + if (isset ($_POST['user_login'])) + $user->user_login = wp_specialchars(trim($_POST['user_login'])); + + $pass1 = $pass2 = ''; + if (isset ($_POST['pass1'])) + $pass1 = $_POST['pass1']; + if (isset ($_POST['pass2'])) + $pass2 = $_POST['pass2']; + + if (isset ($_POST['role'])) { + if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users')) + $user->role = $_POST['role']; + } + + if (isset ($_POST['email'])) + $user->user_email = wp_specialchars(trim($_POST['email'])); + if (isset ($_POST['url'])) { + $user->user_url = wp_specialchars(trim($_POST['url'])); + $user->user_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; + } + if (isset ($_POST['first_name'])) + $user->first_name = wp_specialchars(trim($_POST['first_name'])); + if (isset ($_POST['last_name'])) + $user->last_name = wp_specialchars(trim($_POST['last_name'])); + if (isset ($_POST['nickname'])) + $user->nickname = wp_specialchars(trim($_POST['nickname'])); + if (isset ($_POST['display_name'])) + $user->display_name = wp_specialchars(trim($_POST['display_name'])); + if (isset ($_POST['description'])) + $user->description = wp_specialchars(trim($_POST['description'])); + if (isset ($_POST['jabber'])) + $user->jabber = wp_specialchars(trim($_POST['jabber'])); + if (isset ($_POST['aim'])) + $user->aim = wp_specialchars(trim($_POST['aim'])); + if (isset ($_POST['yim'])) + $user->yim = wp_specialchars(trim($_POST['yim'])); + + $errors = array (); + + /* checking that username has been typed */ + if ($user->user_login == '') + $errors['user_login'] = __('ERROR: Please enter a username.'); + + /* checking the password has been typed twice */ + do_action('check_passwords', array ($user->user_login, & $pass1, & $pass2)); + + if (!$update) { + if ($pass1 == '' || $pass2 == '') + $errors['pass'] = __('ERROR: Please enter your password twice.'); + } else { + if ((empty ($pass1) && !empty ($pass2)) || (empty ($pass2) && !empty ($pass1))) + $errors['pass'] = __("ERROR: you typed your new password only once."); + } + + /* Check for "\" in password */ + if( strpos( " ".$pass1, "\\" ) ) + $errors['pass'] = __('ERROR: Passwords may not contain the character "\\".'); + + /* checking the password has been typed twice the same */ + if ($pass1 != $pass2) + $errors['pass'] = __('ERROR: Please type the same password in the two password fields.'); + + if (!empty ($pass1)) + $user->user_pass = $pass1; + + if ( !validate_username($user->user_login) ) + $errors['user_login'] = __('ERROR: This username is invalid. Please enter a valid username.'); + + if (!$update && username_exists($user->user_login)) + $errors['user_login'] = __('ERROR: This username is already registered, please choose another one.'); + + /* checking e-mail address */ + if (empty ($user->user_email)) { + $errors['user_email'] = __("ERROR: please type an e-mail address"); + } else + if (!is_email($user->user_email)) { + $errors['user_email'] = __("ERROR: the email address isn't correct"); + } + + if (count($errors) != 0) + return $errors; + + if ($update) { + $user_id = wp_update_user(get_object_vars($user)); + } else { + $user_id = wp_insert_user(get_object_vars($user)); + wp_new_user_notification($user_id); + } + + return $errors; +} + + +function get_link_to_edit($link_id) { + $link = get_link($link_id); + + $link->link_url = wp_specialchars($link->link_url, 1); + $link->link_name = wp_specialchars($link->link_name, 1); + $link->link_description = wp_specialchars($link->link_description); + $link->link_notes = wp_specialchars($link->link_notes); + $link->link_rss = wp_specialchars($link->link_rss); + + return $link; +} + +function get_default_link_to_edit() { + if ( isset($_GET['linkurl']) ) + $link->link_url = wp_specialchars($_GET['linkurl'], 1); + else + $link->link_url = ''; + + if ( isset($_GET['name']) ) + $link->link_name = wp_specialchars($_GET['name'], 1); + else + $link->link_name = ''; + + return $link; +} + +function add_link() { + return edit_link(); +} + +function edit_link($link_id = '') { + if (!current_user_can('manage_links')) + die(__("Cheatin' uh ?")); + + $_POST['link_url'] = wp_specialchars($_POST['link_url']); + $_POST['link_url'] = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $_POST['link_url']) ? $_POST['link_url'] : 'http://' . $_POST['link_url']; + $_POST['link_name'] = wp_specialchars($_POST['link_name']); + $_POST['link_image'] = wp_specialchars($_POST['link_image']); + $_POST['link_rss'] = wp_specialchars($_POST['link_rss']); + $auto_toggle = get_autotoggle($_POST['link_category']); + + // if we are in an auto toggle category and this one is visible then we + // need to make the others invisible before we add this new one. + // FIXME Add category toggle func. + //if (($auto_toggle == 'Y') && ($link_visible == 'Y')) { + // $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category"); + //} + + if ( !empty($link_id) ) { + $_POST['link_id'] = $link_id; + return wp_update_link($_POST); + } else { + return wp_insert_link($_POST); + } +} + +function url_shorten($url) { + $short_url = str_replace('http://', '', stripslashes($url)); + $short_url = str_replace('www.', '', $short_url); + if ('/' == substr($short_url, -1)) + $short_url = substr($short_url, 0, -1); + if (strlen($short_url) > 35) + $short_url = substr($short_url, 0, 32).'...'; + return $short_url; +} + +function selected($selected, $current) { + if ($selected == $current) + echo ' selected="selected"'; +} + +function checked($checked, $current) { + if ($checked == $current) + echo ' checked="checked"'; +} + +function return_categories_list($parent = 0) { + global $wpdb; + return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC LIMIT 100"); +} + +function sort_cats($cat1, $cat2) { + return strcasecmp($cat1['cat_name'], $cat2['cat_name']); +} + +function get_nested_categories($default = 0, $parent = 0) { + global $post_ID, $mode, $wpdb; + + if ($post_ID) { + $checked_categories = $wpdb->get_col(" + SELECT category_id + FROM $wpdb->categories, $wpdb->post2cat + WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID' + "); + + if (count($checked_categories) == 0) { + // No selected categories, strange + $checked_categories[] = $default; + } + + } else { + $checked_categories[] = $default; + } + + $cats = return_categories_list($parent); + $result = array (); + + if (is_array($cats)) { + foreach ($cats as $cat) { + $result[$cat]['children'] = get_nested_categories($default, $cat); + $result[$cat]['cat_ID'] = $cat; + $result[$cat]['checked'] = in_array($cat, $checked_categories); + $result[$cat]['cat_name'] = get_the_category_by_ID($cat); + } + } + + usort($result, 'sort_cats'); + + return $result; +} + +function write_nested_categories($categories) { + foreach ($categories as $category) { + echo '\n"; + + if (isset ($category['children'])) { + echo "\n\n"; + write_nested_categories($category['children']); + echo "\n"; + } + } +} + +function dropdown_categories($default = 0) { + write_nested_categories(get_nested_categories($default)); +} + +// Dandy new recursive multiple category stuff. +function cat_rows($parent = 0, $level = 0, $categories = 0) { + global $wpdb, $class; + + if (!$categories) + $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name"); + + if ($categories) { + foreach ($categories as $category) { + if ($category->category_parent == $parent) { + $category->cat_name = wp_specialchars($category->cat_name); + $pad = str_repeat('— ', $level); + if ( current_user_can('manage_categories') ) { + $edit = "".__('Edit').""; + $default_cat_id = get_option('default_category'); + + if ($category->cat_ID != $default_cat_id) + $edit .= "cat_ID, '".sprintf(__("You are about to delete the category "%s". All of its posts will go to the default category.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete').""; + else + $edit .= "".__("Default"); + } + else + $edit = ''; + + $class = ('alternate' == $class) ? '' : 'alternate'; + echo "$category->cat_ID$pad $category->cat_name + $category->category_description + $category->category_count + $edit + "; + cat_rows($category->cat_ID, $level +1, $categories); + } + } + } else { + return false; + } +} + +function page_rows($parent = 0, $level = 0, $pages = 0) { + global $wpdb, $class, $post; + if (!$pages) + $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' ORDER BY menu_order"); + + if ($pages) { + foreach ($pages as $post) { + start_wp(); + if ($post->post_parent == $parent) { + $post->post_title = wp_specialchars($post->post_title); + $pad = str_repeat('— ', $level); + $id = $post->ID; + $class = ('alternate' == $class) ? '' : 'alternate'; +?> + + ID; ?> + + + + + post_modified); ?> + + " . __('Edit') . ""; } ?> + " . __('Delete') . ""; } ?> + + +get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name"); + } + if ($categories) { + foreach ($categories as $category) { + if ($currentcat != $category->cat_ID && $parent == $category->category_parent) { + $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID"); + $pad = str_repeat('– ', $level); + $category->cat_name = wp_specialchars($category->cat_name); + echo "\n\t"; + wp_dropdown_cats($currentcat, $currentparent, $category->cat_ID, $level +1, $categories); + } + } + } else { + return false; + } +} + +function link_category_dropdown($fieldname, $selected = 0) { + global $wpdb; + + $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); + echo "\n\n"; +} + +function wp_create_thumbnail($file, $max_side, $effect = '') { + + // 1 = GIF, 2 = JPEG, 3 = PNG + + if (file_exists($file)) { + $type = getimagesize($file); + + // if the associated function doesn't exist - then it's not + // handle. duh. i hope. + + if (!function_exists('imagegif') && $type[2] == 1) { + $error = __('Filetype not supported. Thumbnail not created.'); + } + elseif (!function_exists('imagejpeg') && $type[2] == 2) { + $error = __('Filetype not supported. Thumbnail not created.'); + } + elseif (!function_exists('imagepng') && $type[2] == 3) { + $error = __('Filetype not supported. Thumbnail not created.'); + } else { + + // create the initial copy from the original file + if ($type[2] == 1) { + $image = imagecreatefromgif($file); + } + elseif ($type[2] == 2) { + $image = imagecreatefromjpeg($file); + } + elseif ($type[2] == 3) { + $image = imagecreatefrompng($file); + } + + if (function_exists('imageantialias')) + imageantialias($image, TRUE); + + $image_attr = getimagesize($file); + + // figure out the longest side + + if ($image_attr[0] > $image_attr[1]) { + $image_width = $image_attr[0]; + $image_height = $image_attr[1]; + $image_new_width = $max_side; + + $image_ratio = $image_width / $image_new_width; + $image_new_height = $image_height / $image_ratio; + //width is > height + } else { + $image_width = $image_attr[0]; + $image_height = $image_attr[1]; + $image_new_height = $max_side; + + $image_ratio = $image_height / $image_new_height; + $image_new_width = $image_width / $image_ratio; + //height > width + } + + $thumbnail = imagecreatetruecolor($image_new_width, $image_new_height); + @ imagecopyresampled($thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1]); + + // If no filters change the filename, we'll do a default transformation. + if ( basename($file) == $thumb = apply_filters('thumbnail_filename', basename($file)) ) + $thumb = preg_replace('!(\.[^.]+)?$!', __('.thumbnail').'$1', basename($file), 1); + + $thumbpath = str_replace(basename($file), $thumb, $file); + + // move the thumbnail to it's final destination + if ($type[2] == 1) { + if (!imagegif($thumbnail, $thumbpath)) { + $error = __("Thumbnail path invalid"); + } + } + elseif ($type[2] == 2) { + if (!imagejpeg($thumbnail, $thumbpath)) { + $error = __("Thumbnail path invalid"); + } + } + elseif ($type[2] == 3) { + if (!imagepng($thumbnail, $thumbpath)) { + $error = __("Thumbnail path invalid"); + } + } + + } + } else { + $error = __('File not found'); + } + + if (!empty ($error)) { + return $error; + } else { + return $thumbpath; + } +} + +// Some postmeta stuff +function has_meta($postid) { + global $wpdb; + + return $wpdb->get_results(" + SELECT meta_key, meta_value, meta_id, post_id + FROM $wpdb->postmeta + WHERE post_id = '$postid' + ORDER BY meta_key,meta_id", ARRAY_A); + +} + +function list_meta($meta) { + global $post_ID; + // Exit if no meta + if (!$meta) + return; + $count = 0; +?> + + + + + + + + + + + + "; + } + echo " +

+
+ "; +} + +// Get a list of previously defined keys +function get_meta_keys() { + global $wpdb; + + $keys = $wpdb->get_col(" + SELECT meta_key + FROM $wpdb->postmeta + GROUP BY meta_key + ORDER BY meta_key"); + + return $keys; +} + +function meta_form() { + global $wpdb; + $keys = $wpdb->get_col(" + SELECT meta_key + FROM $wpdb->postmeta + GROUP BY meta_key + ORDER BY meta_id DESC + LIMIT 10"); +?> +

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

+escape(stripslashes(trim($_POST['metakeyselect']))); + $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput']))); + $metavalue = $wpdb->escape(stripslashes(trim($_POST['metavalue']))); + + if ( ('0' === $metavalue || !empty ($metavalue)) && ((('#NONE#' != $metakeyselect) && !empty ($metakeyselect)) || !empty ($metakeyinput)) ) { + // We have a key/value pair. If both the select and the + // input for the key have data, the input takes precedence: + + if ('#NONE#' != $metakeyselect) + $metakey = $metakeyselect; + + if ($metakeyinput) + $metakey = $metakeyinput; // default + + $result = $wpdb->query(" + INSERT INTO $wpdb->postmeta + (post_id,meta_key,meta_value) + VALUES ('$post_ID','$metakey','$metavalue') + "); + } +} // add_meta + +function delete_meta($mid) { + global $wpdb; + + $result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'"); +} + +function update_meta($mid, $mkey, $mvalue) { + global $wpdb; + + return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'"); +} + +function touch_time($edit = 1, $for_post = 1) { + global $month, $post, $comment; + + if ( $for_post ) + $edit = ( ('draft' == $post->post_status) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date) ) ? false : true; + + echo '
'; + + $time_adj = time() + (get_settings('gmt_offset') * 3600); + $post_date = ($for_post) ? $post->post_date : $comment->comment_date; + $jj = ($edit) ? mysql2date('d', $post_date) : gmdate('d', $time_adj); + $mm = ($edit) ? mysql2date('m', $post_date) : gmdate('m', $time_adj); + $aa = ($edit) ? mysql2date('Y', $post_date) : gmdate('Y', $time_adj); + $hh = ($edit) ? mysql2date('H', $post_date) : gmdate('H', $time_adj); + $mn = ($edit) ? mysql2date('i', $post_date) : gmdate('i', $time_adj); + $ss = ($edit) ? mysql2date('s', $post_date) : gmdate('s', $time_adj); + + echo " + + @ + : + + + +
+ using_mod_rewrite_permalinks()) + return; + + if (!((!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess'))) + return; + + if (! got_mod_rewrite()) + return; + + $rules = explode("\n", $wp_rewrite->mod_rewrite_rules()); + insert_with_markers($home_path.'.htaccess', 'WordPress', $rules); +} + +function the_quicktags() { + // Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP + if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Safari')) + echo ' +
+ + +
+'; + else echo ' + +'; +} + +function validate_current_theme() { + $theme_loc = 'wp-content/themes'; + $theme_root = ABSPATH.$theme_loc; + + $template = get_settings('template'); + $stylesheet = get_settings('stylesheet'); + + if (($template != 'default') && (!file_exists("$theme_root/$template/index.php"))) { + update_option('template', 'default'); + update_option('stylesheet', 'default'); + do_action('switch_theme', 'Default'); + return false; + } + + if (($stylesheet != 'default') && (!file_exists("$theme_root/$stylesheet/style.css"))) { + update_option('template', 'default'); + update_option('stylesheet', 'default'); + do_action('switch_theme', 'Default'); + return false; + } + + return true; +} + +function get_broken_themes() { + global $wp_broken_themes; + + get_themes(); + return $wp_broken_themes; +} + +function get_page_templates() { + $themes = get_themes(); + $theme = get_current_theme(); + $templates = $themes[$theme]['Template Files']; + $page_templates = array (); + + if (is_array($templates)) { + foreach ($templates as $template) { + $template_data = implode('', file(ABSPATH.$template)); + preg_match("|Template Name:(.*)|i", $template_data, $name); + preg_match("|Description:(.*)|i", $template_data, $description); + + $name = $name[1]; + $description = $description[1]; + + if (!empty ($name)) { + $page_templates[trim($name)] = basename($template); + } + } + } + + return $page_templates; +} + +function page_template_dropdown($default = '') { + $templates = get_page_templates(); + foreach (array_keys($templates) as $template) + : if ($default == $templates[$template]) + $selected = " selected='selected'"; + else + $selected = ''; + echo "\n\t"; + endforeach; +} + +function parent_dropdown($default = 0, $parent = 0, $level = 0) { + global $wpdb, $post_ID; + $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_status = 'static' ORDER BY menu_order"); + + if ($items) { + foreach ($items as $item) { + // A page cannot be it's own parent. + if (!empty ($post_ID)) { + if ($item->ID == $post_ID) { + continue; + } + } + $pad = str_repeat(' ', $level * 3); + if ($item->ID == $default) + $current = ' selected="selected"'; + else + $current = ''; + + echo "\n\t"; + parent_dropdown($default, $item->ID, $level +1); + } + } else { + return false; + } +} + +function user_can_access_admin_page() { + global $pagenow; + global $menu; + global $submenu; + + $parent = get_admin_page_parent(); + + foreach ($menu as $menu_array) { + //echo "parent array: " . $menu_array[2]; + if ($menu_array[2] == $parent) { + if (!current_user_can($menu_array[1])) { + return false; + } else { + break; + } + } + } + + if (isset ($submenu[$parent])) { + foreach ($submenu[$parent] as $submenu_array) { + if ($submenu_array[2] == $pagenow) { + if (!current_user_can($submenu_array[1])) { + return false; + } else { + return true; + } + } + } + } + + return true; +} + +function get_admin_page_title() { + global $title; + global $menu; + global $submenu; + global $pagenow; + global $plugin_page; + + if (isset ($title) && !empty ($title)) { + return $title; + } + + $hook = get_plugin_page_hook($plugin_page, $pagenow); + + $parent = $parent1 = get_admin_page_parent(); + if (empty ($parent)) { + foreach ($menu as $menu_array) { + if (isset ($menu_array[3])) { + if ($menu_array[2] == $pagenow) { + $title = $menu_array[3]; + return $menu_array[3]; + } else + if (isset ($plugin_page) && ($plugin_page == $menu_array[2]) && ($hook == $menu_array[3])) { + $title = $menu_array[3]; + return $menu_array[3]; + } + } + } + } else { + foreach (array_keys($submenu) as $parent) { + foreach ($submenu[$parent] as $submenu_array) { + if (isset ($submenu_array[3])) { + if ($submenu_array[2] == $pagenow) { + $title = $submenu_array[3]; + return $submenu_array[3]; + } else + if (isset ($plugin_page) && ($plugin_page == $submenu_array[2]) && (($parent == $pagenow) || ($parent == $plugin_page) || ($plugin_page == $hook) || (($pagenow == 'admin.php') && ($parent1 != $submenu_array[2])))) { + $title = $submenu_array[3]; + return $submenu_array[3]; + } + } + } + } + } + + return ''; +} + +function get_admin_page_parent() { + global $parent_file; + global $menu; + global $submenu; + global $pagenow; + global $plugin_page; + + if (isset ($parent_file) && !empty ($parent_file)) { + return $parent_file; + } + + if ($pagenow == 'admin.php' && isset ($plugin_page)) { + foreach ($menu as $parent_menu) { + if ($parent_menu[2] == $plugin_page) { + $parent_file = $plugin_page; + return $plugin_page; + } + } + } + + foreach (array_keys($submenu) as $parent) { + foreach ($submenu[$parent] as $submenu_array) { + if ($submenu_array[2] == $pagenow) { + $parent_file = $parent; + return $parent; + } else + if (isset ($plugin_page) && ($plugin_page == $submenu_array[2])) { + $parent_file = $parent; + return $parent; + } + } + } + + $parent_file = ''; + return ''; +} + +function add_menu_page($page_title, $menu_title, $access_level, $file, $function = '') { + global $menu, $admin_page_hooks; + + $file = plugin_basename($file); + + $menu[] = array ($menu_title, $access_level, $file, $page_title); + + $admin_page_hooks[$file] = sanitize_title($menu_title); + + $hookname = get_plugin_page_hookname($file, ''); + if (!empty ($function) && !empty ($hookname)) + add_action($hookname, $function); + + return $hookname; +} + +function add_submenu_page($parent, $page_title, $menu_title, $access_level, $file, $function = '') { + global $submenu; + global $menu; + + $parent = plugin_basename($parent); + $file = plugin_basename($file); + + // If the parent doesn't already have a submenu, add a link to the parent + // as the first item in the submenu. If the submenu file is the same as the + // parent file someone is trying to link back to the parent manually. In + // this case, don't automatically add a link back to avoid duplication. + if (!isset ($submenu[$parent]) && $file != $parent) { + foreach ($menu as $parent_menu) { + if ($parent_menu[2] == $parent) { + $submenu[$parent][] = $parent_menu; + } + } + } + + $submenu[$parent][] = array ($menu_title, $access_level, $file, $page_title); + + $hookname = get_plugin_page_hookname($file, $parent); + if (!empty ($function) && !empty ($hookname)) + add_action($hookname, $function); + + return $hookname; +} + +function add_options_page($page_title, $menu_title, $access_level, $file, $function = '') { + return add_submenu_page('options-general.php', $page_title, $menu_title, $access_level, $file, $function); +} + +function add_management_page($page_title, $menu_title, $access_level, $file, $function = '') { + return add_submenu_page('edit.php', $page_title, $menu_title, $access_level, $file, $function); +} + +function add_theme_page($page_title, $menu_title, $access_level, $file, $function = '') { + return add_submenu_page('themes.php', $page_title, $menu_title, $access_level, $file, $function); +} + +function validate_file($file, $allowed_files = '') { + if (false !== strpos($file, './')) + return 1; + + if (':' == substr($file, 1, 1)) + return 2; + + if (!empty ($allowed_files) && (!in_array($file, $allowed_files))) + return 3; + + return 0; +} + +function validate_file_to_edit($file, $allowed_files = '') { + $file = stripslashes($file); + + $code = validate_file($file, $allowed_files); + + if (!$code) + return $file; + + switch ($code) { + case 1 : + die(__('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.')); + + case 2 : + die(__('Sorry, can’t call files with their real path.')); + + case 3 : + die(__('Sorry, that file cannot be edited.')); + } +} + +function get_home_path() { + $home = get_settings('home'); + if ($home != '' && $home != get_settings('siteurl')) { + $home_path = parse_url($home); + $home_path = $home_path['path']; + $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"]); + $home_path = trailingslashit($root.$home_path); + } else { + $home_path = ABSPATH; + } + + return $home_path; +} + +function get_real_file_to_edit($file) { + if ('index.php' == $file || '.htaccess' == $file) { + $real_file = get_home_path().$file; + } else { + $real_file = ABSPATH.$file; + } + + return $real_file; +} + +$wp_file_descriptions = array ('index.php' => __('Main Index Template'), 'style.css' => __('Stylesheet'), 'comments.php' => __('Comments'), 'comments-popup.php' => __('Popup Comments'), 'footer.php' => __('Footer'), 'header.php' => __('Header'), 'sidebar.php' => __('Sidebar'), 'archive.php' => __('Archives'), 'category.php' => __('Category Template'), 'page.php' => __('Page Template'), 'search.php' => __('Search Results'), 'single.php' => __('Single Post'), '404.php' => __('404 Template'), 'my-hacks.php' => __('my-hacks.php (legacy hacks support)'), '.htaccess' => __('.htaccess (for rewrite rules)'), + // Deprecated files + 'wp-layout.css' => __('Stylesheet'), 'wp-comments.php' => __('Comments Template'), 'wp-comments-popup.php' => __('Popup Comments Template')); + +function get_file_description($file) { + global $wp_file_descriptions; + + if (isset ($wp_file_descriptions[basename($file)])) { + return $wp_file_descriptions[basename($file)]; + } + elseif (file_exists(ABSPATH.$file)) { + $template_data = implode('', file(ABSPATH.$file)); + if (preg_match("|Template Name:(.*)|i", $template_data, $name)) + return $name[1]; + } + + return basename($file); +} + +function update_recently_edited($file) { + $oldfiles = (array) get_option('recently_edited'); + if ($oldfiles) { + $oldfiles = array_reverse($oldfiles); + $oldfiles[] = $file; + $oldfiles = array_reverse($oldfiles); + $oldfiles = array_unique($oldfiles); + if (5 < count($oldfiles)) + array_pop($oldfiles); + } else { + $oldfiles[] = $file; + } + update_option('recently_edited', $oldfiles); +} + +function get_plugin_data($plugin_file) { + $plugin_data = implode('', file($plugin_file)); + preg_match("|Plugin Name:(.*)|i", $plugin_data, $plugin_name); + preg_match("|Plugin URI:(.*)|i", $plugin_data, $plugin_uri); + preg_match("|Description:(.*)|i", $plugin_data, $description); + preg_match("|Author:(.*)|i", $plugin_data, $author_name); + preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri); + if (preg_match("|Version:(.*)|i", $plugin_data, $version)) + $version = $version[1]; + else + $version = ''; + + $description = wptexturize($description[1]); + + $name = $plugin_name[1]; + $name = trim($name); + $plugin = $name; + if ('' != $plugin_uri[1] && '' != $name) { + $plugin = ''.$plugin.''; + } + + if ('' == $author_uri[1]) { + $author = $author_name[1]; + } else { + $author = ''.$author_name[1].''; + } + + return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1]); +} + +function get_plugins() { + global $wp_plugins; + + if (isset ($wp_plugins)) { + return $wp_plugins; + } + + $wp_plugins = array (); + $plugin_loc = 'wp-content/plugins'; + $plugin_root = ABSPATH.$plugin_loc; + + // Files in wp-content/plugins directory + $plugins_dir = @ dir($plugin_root); + if ($plugins_dir) { + while (($file = $plugins_dir->read()) !== false) { + if (preg_match('|^\.+$|', $file)) + continue; + if (is_dir($plugin_root.'/'.$file)) { + $plugins_subdir = @ dir($plugin_root.'/'.$file); + if ($plugins_subdir) { + while (($subfile = $plugins_subdir->read()) !== false) { + if (preg_match('|^\.+$|', $subfile)) + continue; + if (preg_match('|\.php$|', $subfile)) + $plugin_files[] = "$file/$subfile"; + } + } + } else { + if (preg_match('|\.php$|', $file)) + $plugin_files[] = $file; + } + } + } + + if (!$plugins_dir || !$plugin_files) { + return $wp_plugins; + } + + sort($plugin_files); + + foreach ($plugin_files as $plugin_file) { + if ( !is_readable("$plugin_root/$plugin_file")) + continue; + + $plugin_data = get_plugin_data("$plugin_root/$plugin_file"); + + if (empty ($plugin_data['Name'])) { + continue; + } + + $wp_plugins[plugin_basename($plugin_file)] = $plugin_data; + } + + return $wp_plugins; +} + +function get_plugin_page_hookname($plugin_page, $parent_page) { + global $admin_page_hooks; + + $parent = get_admin_page_parent(); + + if (empty ($parent_page) || 'admin.php' == $parent_page) { + if (isset ($admin_page_hooks[$plugin_page])) + $page_type = 'toplevel'; + else + if (isset ($admin_page_hooks[$parent])) + $page_type = $admin_page_hooks[$parent]; + } else + if (isset ($admin_page_hooks[$parent_page])) { + $page_type = $admin_page_hooks[$parent_page]; + } else { + $page_type = 'admin'; + } + + $plugin_name = preg_replace('!\.php!', '', $plugin_page); + + return $page_type.'_page_'.$plugin_name; +} + +function get_plugin_page_hook($plugin_page, $parent_page) { + global $wp_filter; + + $hook = get_plugin_page_hookname($plugin_page, $parent_page); + if (isset ($wp_filter[$hook])) + return $hook; + else + return ''; +} + +function browse_happy() { + $getit = __('WordPress recommends a better browser'); + echo ' +

Browse Happy

+ '; +} +if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) + add_action('admin_footer', 'browse_happy'); + +function documentation_link($for) { + return; +} + +function register_importer($id, $name, $description, $callback) { + global $wp_importers; + + $wp_importers[$id] = array ($name, $description, $callback); +} + +function get_importers() { + global $wp_importers; + + return $wp_importers; +} + +function current_theme_info() { + $themes = get_themes(); + $current_theme = get_current_theme(); + $ct->name = $current_theme; + $ct->title = $themes[$current_theme]['Title']; + $ct->version = $themes[$current_theme]['Version']; + $ct->parent_theme = $themes[$current_theme]['Parent Theme']; + $ct->template_dir = $themes[$current_theme]['Template Dir']; + $ct->stylesheet_dir = $themes[$current_theme]['Stylesheet Dir']; + $ct->template = $themes[$current_theme]['Template']; + $ct->stylesheet = $themes[$current_theme]['Stylesheet']; + $ct->screenshot = $themes[$current_theme]['Screenshot']; + $ct->description = $themes[$current_theme]['Description']; + $ct->author = $themes[$current_theme]['Author']; + return $ct; +} + + +// array wp_handle_upload ( array &file [, array overrides] ) +// file: reference to a single element of $_FILES. Call the function once for each uploaded file. +// overrides: an associative array of names=>values to override default variables with extract($overrides, EXTR_OVERWRITE). +// On success, returns an associative array of file attributes. +// On failure, returns $overrides['upload_error_handler'](&$file, $message) or array('error'=>$message). +function wp_handle_upload(&$file, $overrides = false) { + // The default error handler. + if (! function_exists('wp_handle_upload_error') ) { + function wp_handle_upload_error(&$file, $message) { + return array('error'=>$message); + } + } + + // You may define your own function and pass the name in $overrides['upload_error_handler'] + $upload_error_handler = 'wp_handle_upload_error'; + + // $_POST['action'] must be set and its value must equal $overrides['action'] or this: + $action = 'wp_handle_upload'; + + // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error']. + $upload_error_strings = array(false, + __("The uploaded file exceeds the upload_max_filesize directive in php.ini."), + __("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form."), + __("The uploaded file was only partially uploaded."), + __("No file was uploaded."), + __("Missing a temporary folder."), + __("Failed to write file to disk.")); + + // Accepted MIME types are set here as PCRE. Override with $override['mimes']. + $mimes = apply_filters('upload_mimes', array ( + 'jpg|jpeg|jpe' => 'image/jpeg', + 'gif' => 'image/gif', + 'png' => 'image/png', + 'bmp' => 'image/bmp', + 'tif|tiff' => 'image/tiff', + 'ico' => 'image/x-icon', + 'asf|asx|wax|wmv|wmx' => 'video/asf', + 'avi' => 'video/avi', + 'mov|qt' => 'video/quicktime', + 'mpeg|mpg|mpe' => 'video/mpeg', + 'txt|c|cc|h' => 'text/plain', + 'rtx' => 'text/richtext', + 'css' => 'text/css', + 'htm|html' => 'text/html', + 'mp3|mp4' => 'audio/mpeg', + 'ra|ram' => 'audio/x-realaudio', + 'wav' => 'audio/wav', + 'ogg' => 'audio/ogg', + 'mid|midi' => 'audio/midi', + 'wma' => 'audio/wma', + 'rtf' => 'application/rtf', + 'js' => 'application/javascript', + 'pdf' => 'application/pdf', + 'doc' => 'application/msword', + 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', + 'wri' => 'application/vnd.ms-write', + 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', + 'mdb' => 'application/vnd.ms-access', + 'mpp' => 'application/vnd.ms-project', + 'swf' => 'application/x-shockwave-flash', + 'class' => 'application/java', + 'tar' => 'application/x-tar', + 'zip' => 'application/zip', + 'gz|gzip' => 'application/x-gzip', + 'exe' => 'application/x-msdownload' + )); + + // All tests are on by default. Most can be turned off by $override[{test_name}] = false; + $test_form = true; + $test_size = true; + + // If you override this, you must provide $ext and $type!!!! + $test_type = true; + + // Install user overrides. Did we mention that this voids your warranty? + if ( is_array($overrides) ) + extract($overrides, EXTR_OVERWRITE); + + // A correct form post will pass this test. + if ( $test_form && (!isset($_POST['action']) || ($_POST['action'] != $action)) ) + return $upload_error_handler($file, __('Invalid form submission.')); + + // A successful upload will pass this test. It makes no sense to override this one. + if ( $file['error'] > 0 ) + return $upload_error_handler($file, $upload_error_strings[$file['error']]); + + // A non-empty file will pass this test. + if ( $test_size && !($file['size'] > 0) ) + return $upload_error_handler($file, __('File is empty. Please upload something more substantial.')); + + // A properly uploaded file will pass this test. There should be no reason to override this one. + if (! @ is_uploaded_file($file['tmp_name']) ) + return $upload_error_handler($file, __('Specified file failed upload test.')); + + // A correct MIME type will pass this test. + if ( $test_type ) { + $type = false; + $ext = false; + foreach ($mimes as $ext_preg => $mime_match) { + $ext_preg = '![^.]\.(' . $ext_preg . ')$!i'; + if ( preg_match($ext_preg, $file['name'], $ext_matches) ) { + $type = $mime_match; + $ext = $ext_matches[1]; + } + } + + if ( !$type || !$ext ) + return $upload_error_handler($file, __('File type does not meet security guidelines. Try another.')); + } + + // A writable uploads dir will pass this test. Again, there's no point overriding this one. + if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) + return $upload_error_handler($file, $uploads['error']); + + // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied. + if ( isset($unique_filename_callback) && function_exists($unique_filename_callback) ) { + $filename = $unique_filename_callback($uploads['path'], $file['name']); + } else { + $number = ''; + $filename = str_replace('#', '_', $file['name']); + $filename = str_replace(array('\\', "'"), '', $filename); + if ( empty($ext) ) + $ext = ''; + else + $ext = ".$ext"; + while ( file_exists($uploads['path'] . "/$filename") ) { + if ( '' == "$number$ext" ) + $filename = $filename . ++$number . $ext; + else + $filename = str_replace("$number$ext", ++$number . $ext, $filename); + } + } + + // Move the file to the uploads dir + $new_file = $uploads['path'] . "/$filename"; + if ( false === @ move_uploaded_file($file['tmp_name'], $new_file) ) + die(printf(__('The uploaded file could not be moved to %s.'), $file['path'])); + + // Set correct file permissions + $stat = stat(dirname($new_file)); + $perms = $stat['mode'] & 0000666; + @ chmod($new_file, $perms); + + // Compute the URL + $url = $uploads['url'] . "/$filename"; + + return array('file' => $new_file, 'url' => $url, 'type' => $type); +} + +function wp_shrink_dimensions($width, $height, $wmax = 128, $hmax = 96) { + if ( $height <= $hmax && $width <= $wmax ) + return array($width, $height); + elseif ( $width / $height > $wmax / $hmax ) + return array($wmax, (int) ($height / $width * $wmax)); + else + return array((int) ($width / $height * $hmax), $hmax); +} + +function wp_import_cleanup($id) { + wp_delete_attachment($id); +} + +function wp_import_upload_form($action) { +?> + +
+ + +
+ + +
+
+ false, 'test_type' => false); + $file = wp_handle_upload($_FILES['import'], $overrides); + + if ( isset($file['error']) ) + return $file; + + $url = $file['url']; + $file = $file['file']; + $filename = basename($file); + + // Construct the object array + $object = array( + 'post_title' => $filename, + 'post_content' => $url, + 'post_mime_type' => 'import', + 'guid' => $url + ); + + // Save the data + $id = wp_insert_attachment($object, $file); + + return array('file' => $file, 'id' => $id); +} + +function user_can_richedit() { + if ( 'true' != get_user_option('rich_editing') ) + return false; + + if ( preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) ) + return false; + + return true; // Best guess +} + +function the_attachment_links($id = false) { + $id = (int) $id; + $post = & get_post($id); + + if ( $post->post_status != 'attachment' ) + return false; + + $icon = get_attachment_icon($post->ID); + +?> +


+

+


+

+ +


+

+


+

+ + 4 / 3 ) + return array(128, (int) ($height / $width * 128)); + else + return array((int) ($width / $height * 96), 96); +} + +?> diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php new file mode 100644 index 00000000..b994f7c5 --- /dev/null +++ b/wp-admin/admin-header.php @@ -0,0 +1,72 @@ + + + + + + +<?php bloginfo('name') ?> › <?php echo $title; ?> — WordPress + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

%s.'), $user_identity) ?> [, ]

+ + diff --git a/wp-admin/admin.php b/wp-admin/admin.php new file mode 100644 index 00000000..9c5a88c8 --- /dev/null +++ b/wp-admin/admin.php @@ -0,0 +1,106 @@ +upgrade."), get_option('siteurl') . '/wp-admin/upgrade.php')); + +require_once(ABSPATH . 'wp-admin/admin-functions.php'); +require_once(ABSPATH . 'wp-admin/admin-db.php'); +require_once(ABSPATH . WPINC . '/registration-functions.php'); + +auth_redirect(); + +nocache_headers(); + +update_category_cache(); + +get_currentuserinfo(); + +$posts_per_page = get_settings('posts_per_page'); +$what_to_show = get_settings('what_to_show'); +$date_format = get_settings('date_format'); +$time_format = get_settings('time_format'); + +$wpvarstoreset = array('profile','redirect','redirect_url','a','popuptitle','popupurl','text', 'trackback', 'pingback'); +for ($i=0; $i diff --git a/wp-admin/bookmarklet.php b/wp-admin/bookmarklet.php new file mode 100644 index 00000000..195e35cc --- /dev/null +++ b/wp-admin/bookmarklet.php @@ -0,0 +1,104 @@ + + + + + + + +post_title = stripslashes($post_title); +else + $post->post_title = $popuptitle; + + +$content = wp_specialchars($_REQUEST['content']); +$popupurl = wp_specialchars($_REQUEST['popupurl']); + if ( !empty($content) ) { + $post->post_content = wp_specialchars( stripslashes($_REQUEST['content']) ); + } else { + $post->post_content = ''.$popuptitle.''."\n$text"; + } + + /* /big funky fixes */ + +?> + + +<?php bloginfo('name') ?> › Bookmarklet — WordPress + + + + + + + + + + + + + + diff --git a/wp-admin/cat-js.php b/wp-admin/cat-js.php new file mode 100644 index 00000000..156e8f5c --- /dev/null +++ b/wp-admin/cat-js.php @@ -0,0 +1,178 @@ + +var ajaxCat = new sack(); +var newcat; + +function newCatAddIn() { + if ( !document.getElementById('jaxcat') ) return false; + var ajaxcat = document.createElement('span'); + ajaxcat.id = 'ajaxcat'; + + newcat = document.createElement('input'); + newcat.type = 'text'; + newcat.name = 'newcat'; + newcat.id = 'newcat'; + newcat.size = '16'; + newcat.setAttribute('autocomplete', 'off'); + newcat.onkeypress = ajaxNewCatKeyPress; + + var newcatSub = document.createElement('input'); + newcatSub.type = 'button'; + newcatSub.name = 'Button'; + newcatSub.id = 'catadd'; + newcatSub.value = ''; + newcatSub.onclick = ajaxNewCat; + + ajaxcat.appendChild(newcat); + ajaxcat.appendChild(newcatSub); + document.getElementById('jaxcat').appendChild(ajaxcat); + + howto = document.createElement('span'); + howto.innerHTML = ''; + howto.id = 'howto'; + ajaxcat.appendChild(howto); +} + +addLoadEvent(newCatAddIn); + +function getResponseElement() { + var p = document.getElementById('ajaxcatresponse'); + if (!p) { + p = document.createElement('span'); + document.getElementById('jaxcat').appendChild(p); + p.id = 'ajaxcatresponse'; + } + return p; +} + +function newCatLoading() { + var p = getResponseElement(); + p.innerHTML = ''; +} + +function newCatLoaded() { + var p = getResponseElement(); + p.innerHTML = ''; +} + +function newCatInteractive() { + var p = getResponseElement(); + p.innerHTML = ''; +} + +function newCatCompletion() { + var p = getResponseElement(); + var id = 0; + var ids = new Array(); + var names = new Array(); + + ids = myPload( ajaxCat.response ); + names = myPload( newcat.value ); + for ( i = 0; i < ids.length; i++ ) { + id = ids[i].replace(/[\n\r]+/g, ""); + if ( id == '-1' ) { + p.innerHTML = ""; + return; + } + if ( id == '0' ) { + p.innerHTML = ""; + return; + } + + var exists = document.getElementById('category-' + id); + + if (exists) { + var moveIt = exists.parentNode; + var container = moveIt.parentNode; + container.removeChild(moveIt); + container.insertBefore(moveIt, container.firstChild); + moveIt.id = 'new-category-' + id; + exists.checked = 'checked'; + var nowClass = moveIt.className; + moveIt.className = nowClass + ' fade'; + Fat.fade_all(); + moveIt.className = nowClass; + } else { + var catDiv = document.getElementById('categorychecklist'); + var newLabel = document.createElement('label'); + newLabel.setAttribute('for', 'category-' + id); + newLabel.id = 'new-category-' + id; + newLabel.className = 'selectit fade'; + + var newCheck = document.createElement('input'); + newCheck.type = 'checkbox'; + newCheck.value = id; + newCheck.name = 'post_category[]'; + newCheck.id = 'category-' + id; + newLabel.appendChild(newCheck); + + var newLabelText = document.createTextNode(' ' + names[i]); + newLabel.appendChild(newLabelText); + + catDiv.insertBefore(newLabel, catDiv.firstChild); + newCheck.checked = 'checked'; + + Fat.fade_all(); + newLabel.className = 'selectit'; + } + newcat.value = ''; + } + p.parentNode.removeChild(p); +// var id = parseInt(ajaxCat.response, 10); +} + +function ajaxNewCatKeyPress(e) { + if (!e) { + if (window.event) { + e = window.event; + } else { + return; + } + } + if (e.keyCode == 13) { + ajaxNewCat(); + e.returnValue = false; + e.cancelBubble = true; + return false; + } +} + +function ajaxNewCat() { + var newcat = document.getElementById('newcat'); + var split_cats = new Array(1); + var catString = ''; + + catString = 'ajaxnewcat=' + encodeURIComponent(newcat.value); + ajaxCat.requestFile = 'edit-form-ajax-cat.php'; + ajaxCat.method = 'GET'; + ajaxCat.onLoading = newCatLoading; + ajaxCat.onLoaded = newCatLoaded; + ajaxCat.onInteractive = newCatInteractive; + ajaxCat.onCompletion = newCatCompletion; + ajaxCat.runAJAX(catString); +} + +function myPload( str ) { + var fixedExplode = new Array(); + var comma = new String(','); + var count = 0; + var currentElement = ''; + + for( x=0; x < str.length; x++) { + andy = str.charAt(x); + if ( comma.indexOf(andy) != -1 ) { + currentElement = currentElement.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // trim + fixedExplode[count] = currentElement; + currentElement = ""; + count++; + } else { + currentElement += andy; + } + } + + if ( currentElement != "" ) + fixedExplode[count] = currentElement; + return fixedExplode; +} \ No newline at end of file diff --git a/wp-admin/categories.php b/wp-admin/categories.php new file mode 100644 index 00000000..79163a98 --- /dev/null +++ b/wp-admin/categories.php @@ -0,0 +1,169 @@ +%s category: this is the default one"), $cat_name)); + + wp_delete_category($cat_ID); + + header('Location: categories.php?message=2'); + +break; + +case 'edit': + + require_once ('admin-header.php'); + $cat_ID = (int) $_GET['cat_ID']; + $category = get_category_to_edit($cat_ID); + ?> + +
+

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

+
+

+
+ + + +

+ + +
+ +

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

+ +

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

Note:
Deleting a category does not delete posts from that category, it will just set them back to the default category %s.'), get_catname(get_option('default_category'))) ?>

+
+ +
+

+
+ +


+

+


+

+


+

+

+
+
+ + + diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php new file mode 100644 index 00000000..e74ebb49 --- /dev/null +++ b/wp-admin/edit-comments.php @@ -0,0 +1,172 @@ + + + +
+

+
+
+ + + + + +
+
+

|

+get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment"); + $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") ); + if ( current_user_can('edit_post', $post_id) ) : + wp_set_comment_status($comment, "delete"); + ++$i; + endif; + endforeach; + echo "

" . sprintf(__('%s comments deleted.'), $i) . "

"; +endif; + +if (isset($_GET['s'])) { + $s = $wpdb->escape($_GET['s']); + $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE + (comment_author LIKE '%$s%' OR + comment_author_email LIKE '%$s%' OR + comment_author_url LIKE ('%$s%') OR + comment_author_IP LIKE ('%$s%') OR + comment_content LIKE ('%$s%') ) AND + comment_approved != 'spam' + ORDER BY comment_date DESC"); +} else { + if ( isset($_GET['offset']) ) + $offset = (int) $_GET['offset'] * 20; + else + $offset = 0; + + $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $offset,20"); +} +if ('view' == $mode) { + if ($comments) { + if ($offset) + $start = " start='$offset'"; + else + $start = ''; + + echo "
    "; + $i = 0; + foreach ($comments as $comment) { + ++$i; $class = ''; + $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); + $comment_status = wp_get_comment_status($comment->comment_ID); + if ('unapproved' == $comment_status) + $class .= ' unapproved'; + if ($i % 2) + $class .= ' alternate'; + echo "
  1. "; +?> +

    comment_author_email) { ?>| comment_author_url && 'http://' != $comment->comment_author_url ) { ?> | |

    + + + +

    comment_post_ID) ) { + echo " | comment_ID."\">" . __('Edit Comment') . ""; + echo " | comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), wp_specialchars( $comment->comment_author, 1 )) . "' );\">" . __('Delete Comment') . " — "; + } // end if any comments to show + // Get post title + if ( current_user_can('edit_post', $comment->comment_post_ID) ) { + $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"); + $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; + ?> + + |

    +
  2. + + +
+ +
+ + +

+

+ + + + + + + + + + + '; + foreach ($comments as $comment) { + $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); + $class = ('alternate' == $class) ? '' : 'alternate'; +?> + + + + + + + + + + +
*' . __('Name') . '' . __('E-mail') . '' . __('IP') . '' . __('Comment Excerpt') . '' . __('Actions') . '
comment_post_ID) ) { ?>comment_post_ID) ) { + echo "" . __('Edit') . ""; } ?>comment_post_ID) ) { + echo "comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\" class='delete'>" . __('Delete') . ""; } ?>
+

+

')" />

+ + +

+ +

+ + +
+ + diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php new file mode 100644 index 00000000..3f9390a8 --- /dev/null +++ b/wp-admin/edit-form-advanced.php @@ -0,0 +1,275 @@ + + +

+ + +
+ + + + +
+

+

+"; +} else { + $form_action = 'editpost'; + $form_extra = ""; +} + +$form_pingback = ''; + +$form_prevstatus = ''; + +$form_trackback = 'to_ping) .'" />'; + +if ('' != $post->pinged) { + $pings = '

'. __('Already pinged:') . '

    '; + $already_pinged = explode("\n", trim($post->pinged)); + foreach ($already_pinged as $pinged_url) { + $pings .= "\n\t
  • $pinged_url
  • "; + } + $pings .= '
'; +} + +$saveasdraft = ''; + +if (empty($post->post_status)) $post->post_status = 'draft'; + +?> + + + + + + + $_GET['message']) : ?> + + +
+ +
+
+ +
+

+
+ + + +
+
+ +
+

+
+
+ +
+

+
+
+ +
+

+
+

+
+
+ +
+

+
+ + + +
+
+ + +
+

:

+
+
+ + +id ) ) : // TODO: ROLE SYSTEM ?> +
+

:

+
+ +
+
+ + + + +
+
+ +
+ +
+
+ +
+ + + 100)) { + $rows = 12; + } +?> + + +
+
+ + + + + + + +

+post_status || 0 == $post_ID) { +?> + + + + +

+ + + +' . __('This feature requires iframe support.') . ''; +} +?> + +
+ +
+

+
+
+ +
+

+
: () + +
+
+ +
+

+
+ + + +
+
+ + + +
+ + +post_title) ) . "')\""; ?> /> + + +
+ +
+ +
diff --git a/wp-admin/edit-form-ajax-cat.php b/wp-admin/edit-form-ajax-cat.php new file mode 100644 index 00000000..d023f946 --- /dev/null +++ b/wp-admin/edit-form-ajax-cat.php @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php new file mode 100644 index 00000000..fb72058f --- /dev/null +++ b/wp-admin/edit-form-comment.php @@ -0,0 +1,122 @@ +comment_ID); +$form_action = 'editedcomment'; +$form_extra = "' />\n\n' /> + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ + + + 100)) { + $rows = 10; + } +?> +
+
+ + + +

+ +

+ + + +
+

+ + + + + + + + + + + + + + + + + + +
:
+
+
:
:

+ +
+ + diff --git a/wp-admin/edit-form.php b/wp-admin/edit-form.php new file mode 100644 index 00000000..dd4bc758 --- /dev/null +++ b/wp-admin/edit-form.php @@ -0,0 +1,75 @@ + +
+

+
+ + + + + + + + + +
+
+ +
+
+ +
+ +
post_category); ?>
+
+ +
+
+ + + 100)) { + $rows = 10; + } +?> +
+
+ + + + + + +

(Separate multiple URIs with spaces.)
'), 'http://wordpress.org/docs/reference/post/#trackback') ?> +

+ +

+ + + + + + +'; + } ?> + +

+ + + +
+
+ +
diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php new file mode 100644 index 00000000..d782813e --- /dev/null +++ b/wp-admin/edit-link-form.php @@ -0,0 +1,236 @@ +'; +} else { + $editing = false; + $heading = __('Add a link:'); + $submit_text = __('Add Link »'); + $form = '
'; +} + +function xfn_check($class, $value = '', $type = 'check') { + global $link; + + $link_rel = $link->link_rel; + $rels = preg_split('/\s+/', $link_rel); + + if ('' != $value && in_array($value, $rels) ) { + echo ' checked="checked"'; + } + + if ('' == $value) { + if ('family' == $class && !strstr($link_rel, 'child') && !strstr($link_rel, 'parent') && !strstr($link_rel, 'sibling') && !strstr($link_rel, 'spouse') && !strstr($link_rel, 'kin')) echo ' checked="checked"'; + if ('friendship' == $class && !strstr($link_rel, 'friend') && !strstr($link_rel, 'acquaintance') && !strstr($link_rel, 'contact') ) echo ' checked="checked"'; + if ('geographical' == $class && !strstr($link_rel, 'co-resident') && !strstr($link_rel, 'neighbor') ) echo ' checked="checked"'; + if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; + } +} + +?> + +
+ +

+
+ + + + + + + + + + + + + + + + + + +
link_category); ?>
+
+

+ +

+
+ + + + + + + + + + +
XFN Creator:') ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ +
+ + +
+ + + +
+ + + + + + +
+ + + + +
+
+
+

+ +

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

+
+
+target attribute is illegal in XHTML 1.1 and 1.0 Strict.)') ?>

+
+

+ + + + + + + + + +
\ No newline at end of file diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php new file mode 100644 index 00000000..ae594897 --- /dev/null +++ b/wp-admin/edit-page-form.php @@ -0,0 +1,225 @@ + +
+

+

+"; +} else { + $form_action = 'editpost'; + $form_extra = ""; +} + +$sendto = $_SERVER['HTTP_REFERER']; + +if ( 0 != $post_ID && $sendto == get_permalink($post_ID) ) + $sendto = 'redo'; +$sendto = wp_specialchars( $sendto ); + +?> + +
+ +'; +} +?> + + + + + + +
+ +
+
+
+

+
+ + + +
+
+ +
+

+
+
+ +
+

+

+
+
+ + +
+

+

+
+
+ + +
+

+
+
+ +id ) ) : // TODO: ROLE SYSTEM ?> +
+

:

+
+ +
+
+ + +
+

+

+
+ + + +
+
+ +
+ +
+
+ + +
+ + 100)) { + $rows = 10; + } +?> + + +
+
+ + + +

+ + + + + + + +

+ + + +' . __('This feature requires iframe support.') . ''; +} +?> + +
+ +
+

+
+ + + +
+
+ + + +
+ + + escape($post->post_title) ) . "')\""; ?> /> + + + +
+ +
diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php new file mode 100644 index 00000000..8d44faf7 --- /dev/null +++ b/wp-admin/edit-pages.php @@ -0,0 +1,79 @@ + + +
+

+

»

+ +
+
+ + + +
+
+ +get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'"); + +if ($posts) { +?> + + + + + + + + + + + + + + + + + + + + + +
ID; ?> + + post_modified); ?>ID' class='edit'>" . __('Edit') . ""; } ?>ID' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . ""; } ?>
+ +
+ + +

+ + +

»

+ +
+ + diff --git a/wp-admin/edit.php b/wp-admin/edit.php new file mode 100644 index 00000000..27d3bc45 --- /dev/null +++ b/wp-admin/edit.php @@ -0,0 +1,299 @@ + +
+ +

+ post_title = stripslashes($draft->post_title); + if ($draft->post_title == '') + $draft->post_title = sprintf(__('Post #%s'), $draft->ID); + echo "$draft->post_title"; + ++$i; + } + ?> + .

+ + + +

+ post_title = stripslashes($draft->post_title); + if ($draft->post_title == '') + $draft->post_title = sprintf(__('Post #%s'), $draft->ID); + echo "$draft->post_title"; + ++$i; + } + ?> + .

+ + + +
+ + +
+

+post_title); + elseif ( ! is_paged() || get_query_var('paged') == 1 ) + _e('Last 15 Posts'); + else + _e('Previous Posts'); +} +?> +

+ +
+
+ + + +
+
+ +get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_date != '0000-00-00 00:00:00' ORDER BY post_date DESC"); + +if ( count($arc_result) ) { ?> + +
+
+ + + +
+
+ + + +
+ + 'display name' +$posts_columns = array( + 'id' => __('ID'), + 'date' => __('When'), + 'title' => __('Title'), + 'categories' => __('Categories'), + 'comments' => __('Comments'), + 'author' => __('Author') +); +$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_delete'] = ''; + +?> + + + + + + + + + + + + +$column_display_name) { + + switch($column_name) { + + case 'id': + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + +
g:i:s a'); ?> + post_status) _e(' - Private'); ?> + + ID) ) { echo "" . __('Edit') . ""; } ?>ID) ) { echo "" . __('Delete') . ""; } ?>
+ +
+ + + +get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date"); + if ($comments) { + ?> +

+
    +comment_ID); +?> + +
  1. > + + @ + + ID) ) { + echo "[ comment_ID."\">" . __('Edit') . ""; + echo " - ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), $comment->comment_author) . "')\">" . __('Delete') . " "; + if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { + if ('approved' == wp_get_comment_status($comment->comment_ID)) { + echo " - ID."&comment=".$comment->comment_ID."\">" . __('Unapprove') . " "; + } else { + echo " - ID."&comment=".$comment->comment_ID."\">" . __('Approve') . " "; + } + } + echo "]"; + } // end if any comments to show + ?> +
    + + + ( + + / + + ) (IP: + + ) + + +
  2. + +'; + }//end if comments + ?> + +
+ diff --git a/wp-admin/execute-pings.php b/wp-admin/execute-pings.php new file mode 100644 index 00000000..8dc2945f --- /dev/null +++ b/wp-admin/execute-pings.php @@ -0,0 +1,25 @@ +get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { + $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); + pingback($ping->post_content, $ping->ID); +} + +// Do Enclosures +while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { + $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); + do_enclose($enclosure->post_content, $enclosure->ID); +} + +// Do Trackbacks +$trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status != 'draft'"); +if ( is_array($trackbacks) ) { + foreach ( $trackbacks as $trackback ) { + do_trackbacks($trackback->ID); + } +} + +?> diff --git a/wp-admin/images/box-bg.gif b/wp-admin/images/box-bg.gif new file mode 100644 index 0000000000000000000000000000000000000000..2eb7f58240d65642c84c50658edce03e42c74deb GIT binary patch literal 111 zcmZ?wbhEHb+{3`eu!w=-_wV0dzI=K0>eZb)cmDtX&j168KUu&`9S{jp%fM{H;dtkt z!70zxdo5m{eJ#Mapd=-8UdAe;c#CxfI_I}s?($yyzJ~v<{`>+D6UO4BONxFnGYT+9d&-|z45gxOZ`~Uy{ z000000000000000A^8LV00000EC2ui0K5PS000Hppf+q|X`X1Ru59bRa4gSsdu4+L z3_|Vyz@TtQ3>X>%0Dzz&I-k&}bcJyw2!H^iFztH3;FVxvc`yP3MS&Y`yWhcuV^L5D z1b_n~k%RmHfFv3e6%G;z2LL?*8UzRn5D^9j7nPQmn3qmn06X~Sw^#rG literal 0 HcmV?d00001 diff --git a/wp-admin/images/box-head.gif b/wp-admin/images/box-head.gif new file mode 100644 index 0000000000000000000000000000000000000000..5c09a9ae0810da2d923470dcc42dbc7c959e2188 GIT binary patch literal 879 zcmV-#1CabjNk%w1VY~nt0M!5hCWWphhOZ@pts{J@B!8gwv;+}!;9 z{Qdp?{{H^;_4WGt`u6tr`1ttw`T6(v_w)1fWS_z9?d>CXr^nstE`O{ygRk)L@Ku(( z>FMe3@9)dr>fhhr>+9>t-s#=l-Q(lqSD3sdgsvldsV9iABYmnRgRLQWrzeN6B6z4K zg|8xdsU(1`B6+Cv^z{4t`yh3u|Ns9000000000000000000000000000000000000 z00000A^8LV00000EC2ui0K5Ph000L6K$?)oU@R0!nR3Z&I-k&}bV{vSuh{GrsaO<; z;G+ZbXf$Hzw0g~MyWjA*d`_?1?{)J7;^=~D3o;Qh3x9@(h>41ejE#(BTJr4xiaIxY*A?5%(=7Y&!9t#9!C>oFs}7BMFbx8*W6PdRySDAy zxO3~?&AYen-@tFTruw3|@#DyoD__pMx%21Hqf4Joy*l&ZGzw_n&b_<$@8H9WA5Xr# z`Sa-0s}GM|fcy9GNG7S|l1w(~WRchfAmx-)R%zvxSZ1l^mRxq}<(FWFDQ1?~ ztzhPvXr`&=nryb|=9_TFDd(JY)@f&(*qxx~o_zM{=bwNED(Iku7Ha6Bh$gCNpqK># F06T}^*w_F7 literal 0 HcmV?d00001 diff --git a/wp-admin/images/browse-happy.gif b/wp-admin/images/browse-happy.gif new file mode 100644 index 0000000000000000000000000000000000000000..09f13bc3c77d38bbf59d7a1d076df9fc1342c1d0 GIT binary patch literal 4398 zcmW-ji$Bx*cfR3kBx#!({GNV%qw+`_)+_j~>cujk|ScsyNPo#{3{$-oTEDnWTg#m}XmE1Fll z-?_7^t4n!dLuqMg(P)uWDlLvbd9wH9##b9}e7@70?M+Kd z%gD$mE-t=yZXe+}AwE6<-+))<+jNQp*0ikQ^ZAkekpTe#34;lZjg5=Ti+{fTv$L~P z@ImnC+aqP`#T)!nZEbDGdydOwvewqt`ic6H7a^~Hyh7KbBSVkw_;*J)i&a}&>(=Qe z7!XV?P6dAmp7=Gvlk<9JdX_5efCOClc)?I=nDiydtksO%NPhV6q1Fqnfw=*ncRsgb z&nO?CkBJDqapT6{fB${?(`CEYc6HzD8Was)-CiwIEy`57;+JB4VLUQ2vZ<*leJH)5 zp&>XpxVpO9rrpM=!$}|z45l)b9U&JkT&S6-@rm?lnQqC;%cHl`e{cK!%9SgPipD2T zo-k$118)wjd$~>|5@ii%DI0>lySeSJ9M}q@Sq}|O8<44ZU&GIkvuUrn5&&n|^n97W+nw+~HZe0%CN8`6>6S9v zx1g|ad~6&vfy&{^<6Xyz&xxO=K2=p!H8(fsM(=O^w^jN>ig<=lJ`X*5^r*kD|G+?h z;_bVSsvoB&rzXl1+rG6as}Jt_cUR?5<;IsATUuIrM|x#HWKn`^+|$ROPCorM|1B{k zLz&Gy^Y)C^b1l19cCTW#|EvvCR-Bugn|uBG_0rPP$jHdsw{MmIkKsIo06+;W!GHYU zCjd?fl=#K&2cr52oQ8#$RGjrZhGguPp2C$&!pkb}b^hbJ+U4d-`#6HDdTvX+se86p zQTegf+m=4H*IWaS>z^-!59gM}p>v%78%xD@zgb7lA}#7&?2COJ1*|On42y>+yGr(# z9emY#zT}VlOZvYbDT{Nq=Py~?s%u$zZ*%^;|LJx2&7X?d=?ou>H$|m=&#s_euOy_1 zGe~dlF##TjGMu za6+xl2g`OQ{R0?Ll~AHocg5%<%r$d~Yv;$ei|mb)htmbi*Bso|6bKz!%}aUV1I7g* z<$^V7VkBN*IwSpjbHjq};LQpGO=7I+5aJu@tWM`8I3Y(~-_kUy$+dU-&DA8C43E6t zc1Mx3n^~#2^*T0@emmd()T5%~rU~~79sL*Ws*a zeOpx22{i^jYQv76;oNqo(VKZ^tcpkSlH4pt@}svU5bY~Nq_6#!=>zG-MWv%BOYX9j zNc@`AwptuDUpyL1P4UlKxZI3$7T+q0Y{y1H@sTYi z54#TP7d`6Lf4qC!gKIrEx8+4v=h%;JL&C;cmQ@qAh2x`f)U;}cmb>lDy@GwewW?Fh zi+NUOpW!O*DC*(OZHgNx%VGr(vOOmoNnt9J&$U<7Ok`{BHV=3~-hDwFdqmqeDs{|l zz{@Oazk?g~(z>B?`-Ia8Eyk(7O52pKlod0?^My)nJ`{q?a z&4T3NYuWN?YMe>HV|w6|dqWYe#*3Ea(xMFEz)kZU-T=-dE&W`aWp?!#ajb1i_u^Fh zmTm_k+3xJ+X_;TxlbLsCzh9n}e>Zk-UCQN9$C5q6GtI*ij9Txd)@2u)EY~#%*s~D> zEwbyC4lTxs!#(DdEd2iQh%3ts5i+Af0$GuCwkl94(_sm0tq9j_6rndr>s3QZ{3KnE znD!SpS%ZG+w_+jFjXnaFqk|@EL%OkZJbsvCv_4%9QSE&2`zpi9H7HKM(jXpowQOGP zvLib%F}BfU0ToX6&(=(3IhpS2i1Vn+)~=Ag2-t)?f4r60?k|bmIfspgx*Vx9O>z1M z!nN*jA`P~7!0Ok-SI_bv@W7zeYt+2ooPXsT|i)S-MTNqp@KWhK6ebl(mC>O!RH zE`H9YZAbn|=Rg)ydnCIq4QS-YJKA#&G&ysRXl4n&P!5gU^cv3Aj_rDZx+{!XDH#xo z-y!s63LY>h$5n?kpw20pz25QR*d385q^tYB9xD%B5EW=qqr|z46H)>!oh&SvyaTe1 zjdvJMW}7<%e{6IRW{eOlb7Uxuxg1=WKQPdg@XQFEcndiXToLmygFb0bJOTC{2Scx9 z2*(vn4Z4KSVadU}I)n>Z5P^{e?tiG6V@#6>><P-|Iv0WI zqJZcqae&EaX* zHTc{2I2yb4Uxn{+G%Twfts42N2bAMcC54`UnOK$Kk)mv^i~6Ev8hK^dr6Z!SMF@Fd z4W&_k>XtLh+(L=d-J2^u|XTivYRb6HRxZ z@jsr)*2)=fgjh7jpNPTGW6&GIAcj&o8vTSC zMBy_(GLSkU;r55Q{3X~5Y@#%*qL82sA%6&0i6S(nUwSL8)eC1dbEw52Iv~Wzu@o>U zEHTkdj8qalMCi5t3O;mNg8uCtg8-L>lY9-erFDiTUwOO+rh{gIzcYG~2|w}R6Ck%2 zdV@mb4w8JuKkt~tcVg^z3={o`&cJ-Nkz#T6*kuxgEwz-I;rKdNqzqkx9m4fMRShWw8=P2U6ICJQ9WgX97CsMt>{ovowY=JqDZI1 zxAe^fQ`Jo2on8FC`S2zvIyz2GfwFb?Q-}0U!%?n__=to14bgeJXg#(9bE&akuUQshSH}wv zQ5b4ptDd9Q-dA&@hu==qb=WY~fp=$fkogK1v>62+Vsq49>Y+Ag`%BkuG{mw!fsu|;ki(=SILX$>|cJoeQ#yTSyPlX0R1H%8+62~+H>6B)eEkNR=mjPO;k zWYOCUh1Qj$)>)I|&e$VSmeNMBo4~VHY}Z;&0ZMf8QJ(ewZCa~k1@>{j;E0DLN>aLhA-#BCx+lu5rknN z4>6FLY`B|-^X91Sm0@4`5ihY3D>>*p3b;t!wht4@+{596keB4pvIMOs!R#Wj#3Dcg&@w>MNKhE> zm>%tHjRb6!Kzv^nX9i>-IgiIhX9yW-GR$foNDvxe$A~%1 zK|~3W*SM;yX^16?3Zy_#V-e>oVLt{U-c)6ivt@e+&X0t<`ju$T#oh80@PY(l;CmcE z;|e5|=bP1h{-k8D4h@MVp)UZW0b7+o`@>p-IVD7R(S+k%aFT(wW*lA?sSp@grUdd4 zVy#Kg!M6}@&gCZ*y(q^uB;zq+h})E42>vsHJVU|9OW;BU?5X78CP=8?#e_hS+FglG z85iTOK&2V$n!5wXbn&y$)VjG6(hh} z#l|2M>A^e>B2gz3v1?^O@4&iFW#bmA52a32#NU*#y`!A;Zn zyEJ%7f-j`73rTPu_h4WD{zV1ux&*#SaqjFAMR%na__4ZOqoONS)G0t9@(lA;Sx36K zW6mUAhBMAplm1s57g)(+d_Fm3{TzHpl$j^T7fNtd^V_ch_`1ktLlyttXVJC=mt$-c z*_NeI%-TYNkaCO@Km^Nytq^fic7msQXDUlgHy%#Q(kDO6Bj>?|LRh3Ymm;73gIkYHSMl57p_Q=arn!}I~&K||zOC{cCfN(#z!p03(833Fs z66=?g+m=+?mY6Wq+Sn!YJT(&@p*FPW3me%*Beru?%NHDOmBD^Yl3hG(Z>TAQ?~CN* zLJ52i#6S$BA;rZ|jQm)OG#A6O+mV)>Tbpg*JP?s3$D4EQI~Gb6`VXdTA50&7FcbPf zVWC~b)_&hssbPeejqI|G02s>2+i6f4 zPmH^&iW8}sGgS1ph^ZIL&F++2JTA9jxy)rl9Mwn%LP*puyzuCjPMwJ95JKF>j+PKsXg_GsnhtD8 zh=^TCB+KZ+w1O@i>_T)@BanhF!iyL+Vms&T{MtEZJ7;Iq>;Dih&-?H^?}zX6eBpgE zG}u$CKdlD<)Vh0}!!XywXhAgaPSf^0Oxh{bg97mO^W~b@aosrU8k@a3GdX+De+L6- za3+9R-8cPH*f8b~KDeF6Iv|7(4UD)7Bq<02RVXNmg6H!LO&2+?R4U1`OcDggapiKE zFY+wIunf!d#VW*b2^}-T9V2H+?-(*rOF(SfEtt}NrEU;s|w4ql}aU_%l$QMw*#Qsc019L z`$qxet-2wzufeA~GdF29GQ(3k#HwpP=Tp5>sTUs~bbFp^79H8|jwMGn{Nu=E4WHV@ z<`Pj1OGKNZ!frxXz@l>r$fB|FiN4r)-$3m7_{6|c6Ou{+s8EME>s@=BuaUFM*eAr; zY2XyDLos!9uJm+8Ui3todx6%dF|QjeX0yfetkJS=SZ+O-Jgk9eC?1L*hC<0?DEZSH ziYJrFcpRuw8!vzFO2-wvIO)u`0SmbDZ3PihhCn+Q-Xj2f-scY3wf=tci0 Zqyhce4|i>ku8hL(3f!(i=T4U|@(=9Ekd*)c literal 0 HcmV?d00001 diff --git a/wp-admin/images/notice.gif b/wp-admin/images/notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..ba6eab02de9413f685e9fc41d699b9efe32747e5 GIT binary patch literal 156 zcmV;N0Av40Nk%w1VGRHc0J9GOI(oPXN{d;V*4O&|sO$da`TPJodfxT>!vN)X0%lR0RQM9D!25FM*cCnwTO KDwm8T0suSBOiFqH literal 0 HcmV?d00001 diff --git a/wp-admin/images/toggle.gif b/wp-admin/images/toggle.gif new file mode 100644 index 0000000000000000000000000000000000000000..72e8b4499a2685b20dce3644ef0447a0f5b860a1 GIT binary patch literal 216 zcmV;}04M)PNk%w1VH*H40J9GO#og&bj-kG0_K^8f$M)j@V!r z134K0V5m}oAO-vcb713$9u9?okdR0agn>eeQvf)giNzxEbO36ch7&5KJ^_smLm?;= zjb(v?Ard?Vw!`xfpW6g2IE+zd+x~!of`f#GhKGoWii?XtNRLQL9Zgl0RaYHamX=^* SWNDyfYmB6&rl+VM5db?0@>*8_ literal 0 HcmV?d00001 diff --git a/wp-admin/images/wordpress-logo.png b/wp-admin/images/wordpress-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..3c852f4090c453c5e0bf03a821701aa2c9308599 GIT binary patch literal 2345 zcmV+^3D)+BP)*CP;hW?udlDg%G{5Sk5XTkiRKvA4X_Z+fWU;Naus?iea`00030|NjQN zTmt|A03&o#PE-H?|NsC0|NsC0|NsC0|NsC0|NsC0|NsC0|NsC0|NsC00A?wJmH+?< z7fD1xRCwC#TiKH9C=A6L-tFv*yL%@1|37j-NJ7}%_tx}u)zo#uOYjoMM;wk8h?<|a zsTcGY^cVCO^e2R_t1e57Z&@=I&jMYKrA1t}3R;udgSso80D9Uuq^UerI9rs}#-Z!h zn1*quX-?-=V(N6u(3J(Q0kq0$n(JNf43Jy!ZN63Ld1gvCr;COpj#}&3p0_4Rw+X#S zj5|m(^GT~6_&zb!7NJ*(8&f;9U$oL*)um~+2fZ>$0pt30v$y73!mfzz4tZyO*)l70 ztx?;8t^s-TYvi>`Vch#oK`%}ETja>}yiW9npex7X-?5!NLFoSZ(6uS8!u=Y#aBIqp zn}MF0V$Pkm*I5QpTw*^<033QEnyC{A>xM^YC%ACi-{AAKIREXJiyTZ}{5bS9a#*ST zmBpySFAH(&y~^(e^c`HdKko3kTb%!HTj^~6!_Zs9x>YF!qu!}8oXMohS=(5e_+g*V z9{ur#myVAk_HIXeet-VYuU7!&h>Z|?{2+8K23<%Unqyp^m~9eM@yvg7(D!(7v3;_F zHOl=b-cMsNWldiGFm`1pR52G7sW-P#{B$(znSGI@#Dnv}!hI8VxO4ydGcQ;YbT3EQ zPeQM2>(X0NurRU2Pa7$8S?$EAi(3MU*K#=*$Db!EW zswFv0SR8B?ZkpcTjh@MvF6}#xr4_=Vcg?oPrkpu@Z6WCK>do-g8kd7^L@q(o(6 zbdHb!x}&bMShr$4aypM0KZ2R65ZxV+<&NXB4}Lz3UIdPygG%m$4T%Bo?uKCjy$I8g zpbI77`>cw2)eaC^L!?3D__^+mB)cG%R;~mFce`3D7c=jN|8W`gt zg1*NuETDseOc5kk6t;6MkD)8Z$M@Mc(?DVHh1y?Z)#~5@O$43z-K{c~NCv7T&dwyBX(3`ZfdQNxc=*k#8 zLQ5LGfKL3b*P*L`Uaz5h#(R$Yfj)SBe*_H^fauCF40maq2>K8~Z_+d@hY)moYD~iP zRm;#T_;u6ZcT*}o0__F#YQgxDlbZ0*!mJ4I0loXtgLL(TTn$5YWp-3^UH%g7G=pC6YN$?1Sg{8NxA~;g8PbC4b;UgmIIoP#j6s z`fYlXl48hVVK@5?B!Onn*nSNiB)nP&ymV77q&{=dGf@OkoW96p%`-mN z;lV8;PH^-^`a(p$3*UVbbhz?tK3`e!QSL4hyM%rTvnC5c*%CS=DD;XdM5Hb}hnvRW z(4i2=bD?x$3?;47wU5Mi{?W?IUT;|CqVnBIlxI%Nck+99bUrei3n~3clrHZ9`dOqk zwe&U8LGyc644vy3rH77}@)~q3Wu>=+YWa+%iYQsr#CMjy+;gI#dC|ocgL5cRxc;;V zV(!)~x4RhO6MKA-qO$|d-H2}Z#J zRUEpO#CPUQ3y2d^!(=fIlPJVZQ3d)UiV!aP)N=bdVtZwKfl$6}qgVw=er9m|qgl&p=er=+v5+}Azd6IqsI zmfu7_F2r8m0O{`SGB2w%dlZ0WJ7PWm)72jpul?3vtqRXB@^ZT*YAofX&MCL9Zo)Bi~ghMhC`=pzZw4BHaJ6`T|Q3ZIrQ;CNCsctQsWf;wFZkzY^C`L6);6aN7OM)+C(_Ji5WbN<=uY1#|=3;GNC3;M>}KLQK@JuEX4OGyzW P00000NkvXXu0mjfkXWNG literal 0 HcmV?d00001 diff --git a/wp-admin/import.php b/wp-admin/import.php new file mode 100644 index 00000000..2ed94ee8 --- /dev/null +++ b/wp-admin/import.php @@ -0,0 +1,62 @@ + + +
+

+

+ +read()) !== false) { + if (preg_match('|^\.+$|', $file)) + continue; + if (preg_match('|\.php$|', $file)) + require_once("$import_root/$file"); + } +} + +$importers = get_importers(); + +if (empty ($importers)) { + echo '

'.__('No importers are available.').'

'; // TODO: make more helpful +} else { +?> + + + $data) { + $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate'; + $action = "{$data[0]}"; + + if ($style != '') + $style = 'class="'.$style.'"'; + echo " + + + + "; + } +?> + +
$action{$data[1]}
+ + +
+ + + diff --git a/wp-admin/import/b2.php b/wp-admin/import/b2.php new file mode 100644 index 00000000..e69de29b diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php new file mode 100644 index 00000000..88aa4059 --- /dev/null +++ b/wp-admin/import/blogger.php @@ -0,0 +1,667 @@ +

$title

$welcome

"; + if ( function_exists('curl_init') ) + echo "

$reset

"; + else + echo "

$incompat

"; + echo "\n"; + } + + // Deletes saved data and redirect. + function restart() { + delete_option('import-blogger'); + header("Location: admin.php?import=blogger"); + die(); + } + + // Generates a string that will make the page reload in a specified interval. + function refresher($msec) { + if ( $msec ) + return "\n\n\n"; + else + return "\n\n\n"; + } + + // Returns associative array of code, header, cookies, body. Based on code from php.net. + function parse_response($this_response) { + // Split response into header and body sections + list($response_headers, $response_body) = explode("\r\n\r\n", $this_response, 2); + $response_header_lines = explode("\r\n", $response_headers); + + // First line of headers is the HTTP response code + $http_response_line = array_shift($response_header_lines); + if(preg_match('@^HTTP/[0-9]\.[0-9] ([0-9]{3})@',$http_response_line, $matches)) { $response_code = $matches[1]; } + + // put the rest of the headers in an array + $response_header_array = array(); + foreach($response_header_lines as $header_line) { + list($header,$value) = explode(': ', $header_line, 2); + $response_header_array[$header] .= $value."\n"; + } + + $cookie_array = array(); + $cookies = explode("\n", $response_header_array["Set-Cookie"]); + foreach($cookies as $this_cookie) { array_push($cookie_array, "Cookie: ".$this_cookie); } + + return array("code" => $response_code, "header" => $response_header_array, "cookies" => $cookie_array, "body" => $response_body); + } + + // Prints a form for the user to enter Blogger creds. + function login_form($text='') { + echo '

' . __('Log in to Blogger') . "

\n$text\n"; + echo '
' . __('Username') . ':
' . __('Password') . ':
'; + die; + } + + // Sends creds to Blogger, returns the session cookies an array of headers. + function login_blogger($user, $pass) { + $_url = 'http://www.blogger.com/login.do'; + $params = "username=$user&password=$pass"; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_POST,1); + curl_setopt($ch, CURLOPT_POSTFIELDS,$params); + curl_setopt($ch, CURLOPT_URL,$_url); + curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter'); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); + curl_setopt($ch, CURLOPT_HEADER,1); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); + $response = curl_exec ($ch); + + $response = $this->parse_response($response); + + sleep(1); + + return $response['cookies']; + } + + // Requests page from Blogger, returns the response array. + function get_blogger($url, $header = '', $user=false, $pass=false) { + $ch = curl_init(); + if ($user && $pass) curl_setopt($ch, CURLOPT_USERPWD,"{$user}:{$pass}"); + curl_setopt($ch, CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter'); + curl_setopt($ch, CURLOPT_HEADER,1); + if (is_array($header)) curl_setopt($ch, CURLOPT_HTTPHEADER, $header); + $response = curl_exec ($ch); + + $response = $this->parse_response($response); + $response['url'] = $url; + + if (curl_errno($ch)) { + print curl_error($ch); + } else { + curl_close($ch); + } + + return $response; + } + + // Posts data to Blogger, returns response array. + function post_blogger($url, $header = false, $paramary = false, $parse=true) { + $params = ''; + if ( is_array($paramary) ) { + foreach($paramary as $key=>$value) + if($key && $value != '') + $params.=$key."=".urlencode(stripslashes($value))."&"; + } + if ($user && $pass) $params .= "username=$user&password=$pass"; + $params = trim($params,'&'); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_POST,1); + curl_setopt($ch, CURLOPT_POSTFIELDS,$params); + if ($user && $pass) curl_setopt($ch, CURLOPT_USERPWD,"{$user}:{$pass}"); + curl_setopt($ch, CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter'); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_HEADER,$parse); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); + if ($header) curl_setopt($ch, CURLOPT_HTTPHEADER, $header); + $response = curl_exec ($ch); + + if ($parse) { + $response = $this->parse_response($response); + $response['url'] = $url; + return $response; + } + + return $response; + } + + // Prints the list of blogs for import. + function show_blogs() { + global $import; + echo '

' . __('Selecting a Blog') . "

\n
    "; + foreach ( $this->import['blogs'] as $blog ) { + if (9 == $blog['nextstep']) $status = "100%"; + elseif (8 == $blog['nextstep']) $status = "90%"; + elseif (7 == $blog['nextstep']) $status = "82.5%"; + elseif (6 == $blog['nextstep']) $status = "75%"; + elseif (5 == $blog['nextstep']) $status = "57%"; + elseif (4 == $blog['nextstep']) $status = "28%"; + elseif (3 == $blog['nextstep']) $status = "14%"; + else $status = "0%"; + echo "\t
  • {$blog['title']} $status
  • \n"; + } + die("
\n"); + } + + // Publishes. + function publish_blogger($i, $text) { + $head = $this->refresher(2000) . "

$text

\n"; + if ( ! strstr($this->import['blogs'][$_GET['blog']]['publish'][$i], 'http') ) { + // First call. Start the publish process with a fresh set of cookies. + $this->import['cookies'] = $this->login_blogger($this->import['user'], $this->import['pass']); + update_option('import-blogger', $this->import); + $paramary = array('blogID' => $_GET['blog'], 'all' => '1', 'republishAll' => 'Republish Entire Blog', 'publish' => '1', 'redirectUrl' => "/publish.do?blogID={$_GET['blog']}&inprogress=true"); + + $response = $this->post_blogger("http://www.blogger.com/publish.do?blogID={$_GET['blog']}", $this->import['cookies'], $paramary); + if ( $response['code'] == '302' ) { + $url = str_replace('publish.g', 'publish-body.g', $response['header']['Location']); + $this->import['blogs'][$_GET['blog']]['publish'][$i] = $url; + update_option('import-blogger', $this->import); + $response = $this->get_blogger($url, $this->import['cookies']); + preg_match('#

.*

#U', $response['body'], $matches); + $progress = $matches[0]; + die($head . $progress); + } else { + $this->import['blogs'][$_GET['blog']]['publish'][$i] = false; + update_option('import-blogger', $this->import); + die($head); + } + } else { + // Subsequent call. Keep checking status until Blogger reports publish complete. + $url = $this->import['blogs'][$_GET['blog']]['publish'][$i]; + $response = $this->get_blogger($url, $this->import['cookies']); + if ( preg_match('#

.*

#U', $response['body'], $matches) ) { + $progress = $matches[0]; + if ( strstr($progress, '100%') ) { + $this->set_next_step($i); + $progress .= '

'.__('Moving on...').'

'; + } + die($head . $progress); + } else { + $this->import['blogs'][$_GET['blog']]['publish'][$i] = false; + update_option('import-blogger', $this->import); + die("$head

" . __('Trying again...') . '

'); + } + } + } + + // Sets next step, saves options + function set_next_step($step) { + $this->import['blogs'][$_GET['blog']]['nextstep'] = $step; + update_option('import-blogger', $this->import); + } + + // Redirects to next step + function do_next_step() { + header("Location: admin.php?import=blogger&noheader=true&blog={$_GET['blog']}"); + die(); + } + + // Step 0: Do Blogger login, get blogid/title pairs. + function do_login() { + if ( ( ! $this->import['user'] && ! is_array($this->import['cookies']) ) ) { + // The user must provide a Blogger username and password. + if ( ! ( $_POST['user'] && $_POST['pass'] ) ) { + $this->login_form(__('The script will log into your Blogger account, change some settings so it can read your blog, and restore the original settings when it\'s done. Here\'s what you do:').'

  1. '.__('Back up your Blogger template.').'
  2. '.__('Back up any other Blogger settings you might need later.').'
  3. '.__('Log out of Blogger').'
  4. '.__('Log in here with your Blogger username and password.').'
  5. '.__('On the next screen, click one of your Blogger blogs.').'
  6. '.__('Do not close this window or navigate away until the process is complete.').'
'); + } + + // Try logging in. If we get an array of cookies back, we at least connected. + $this->import['cookies'] = $this->login_blogger($_POST['user'], $_POST['pass']); + if ( !is_array( $this->import['cookies'] ) ) { + $this->login_form(__('Login failed. Please enter your credentials again.')); + } + + // Save the password so we can log the browser in when it's time to publish. + $this->import['pass'] = $_POST['pass']; + $this->import['user'] = $_POST['user']; + + // Get the Blogger welcome page and scrape the blog numbers and names from it + $response = $this->get_blogger('http://www.blogger.com/home', $this->import['cookies']); + if (! stristr($response['body'], 'signed in as') ) $this->login_form(__('Login failed. Please re-enter your username and password.')); + $blogsary = array(); + preg_match_all('#posts\.g\?blogID=(\d+)">([^<]+)#U', $response['body'], $blogsary); + if ( ! count( $blogsary[1] < 1 ) ) + die(__('No blogs found for this user.')); + $this->import['blogs'] = array(); + $template = '


'.__('Are you looking for %title%? It is temporarily out of service. Please try again in a few minutes. Meanwhile, discover a better blogging tool.').'

<$BlogArchiveName$>
<$BlogItemDateTime$>|W|P|<$BlogItemAuthorNickname$>|W|P|<$BlogItemBody$>|W|P|<$BlogItemNumber$>|W|P|<$BlogItemTitle$>|W|P|<$BlogItemAuthorEmail$><$BlogCommentDateTime$>|W|P|<$BlogCommentAuthor$>|W|P|<$BlogCommentBody$>'; + foreach ( $blogsary[1] as $key => $id ) { + // Define the required Blogger options. + $blog_opts = array( + 'blog-options-basic' => false, + 'blog-options-archiving' => array('archiveFrequency' => 'm'), + 'blog-publishing' => array('publishMode'=>'0', 'blogID' => "$id", 'subdomain' => mt_rand().mt_rand(), 'pingWeblogs' => 'false'), + 'blog-formatting' => array('timeStampFormat' => '0', 'encoding'=>'UTF-8', 'convertLineBreaks'=>'false', 'floatAlignment'=>'false'), + 'blog-comments' => array('commentsTimeStampFormat' => '0'), + 'template-edit' => array( 'templateText' => str_replace('%title%', trim($blogsary[2][$key]), $template) ) + ); + + // Build the blog options array template + foreach ($blog_opts as $blog_opt => $modify) + $new_opts["$blog_opt"] = array('backup'=>false, 'modify' => $modify, 'error'=>false); + + $this->import['blogs']["$id"] = array( + 'id' => $id, + 'title' => trim($blogsary[2][$key]), + 'options' => $new_opts, + 'url' => false, + 'publish_cookies' => false, + 'published' => false, + 'archives' => false, + 'lump_authors' => false, + 'newusers' => array(), + 'nextstep' => 2 + ); + } + update_option('import-blogger', $this->import); + header("Location: admin.php?import=blogger&noheader=true&step=1"); + } + die(); + } + + // Step 1: Select one of the blogs belonging to the user logged in. + function select_blog() { + if ( is_array($this->import['blogs']) ) { + $this->show_blogs(); + die(); + } else { + $this->restart(); + } + } + + // Step 2: Backup the Blogger options pages, updating some of them. + function backup_settings() { + $output.= '

'.__('Backing up Blogger options')."

\n"; + $form = false; + foreach ($this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary) { + if ( $blog_opt == $_GET['form'] ) { + // Save the posted form data + $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['backup'] = $_POST; + update_option('import-blogger',$this->import); + + // Post the modified form data to Blogger + if ( $optary['modify'] ) { + $posturl = "http://www.blogger.com/{$blog_opt}.do"; + $headers = array_merge($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'], $this->import['cookies']); + if ( 'blog-publishing' == $blog_opt ) { + if ( $_POST['publishMode'] > 0 ) { + $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode=0", $headers); + if ( $response['code'] >= 400 ) + die('

'.__('Failed attempt to change publish mode from FTP to BlogSpot.').'

' . addslashes(print_r($headers, 1)) . addslashes(print_r($response, 1)) . '
'); + $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $optary['modify']['subdomain'] . '.blogspot.com/'; + sleep(2); + } else { + $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $_POST['subdomain'] . '.blogspot.com/'; + update_option('import-blogger', $this->import); + $output .= "

$blog_opt

\n"; + continue; + } + $paramary = $optary['modify']; + } else { + $paramary = array_merge($_POST, $optary['modify']); + } + $response = $this->post_blogger($posturl, $headers, $paramary); + if ( $response['code'] >= 400 || strstr($response['body'], 'There are errors on this form') ) + die('

'.__('Error on form submission. Retry or reset the importer.').'

' . addslashes(print_r($response, 1))); + } + $output .= "

$blog_opt

\n"; + } elseif ( is_array($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['backup']) ) { + // This option set has already been backed up. + $output .= "

$blog_opt

\n"; + } elseif ( ! $form ) { + // This option page needs to be downloaded and given to the browser for submission back to this script. + $response = $this->get_blogger("http://www.blogger.com/{$blog_opt}.g?blogID={$_GET['blog']}", $this->import['cookies']); + $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'] = $response['cookies']; + update_option('import-blogger',$this->import); + $body = $response['body']; + $body = preg_replace("|\]*>|ms","",$body); + $body = preg_replace("|/?{$blog_opt}.do|","admin.php?import=blogger&noheader=true&step=2&blog={$_GET['blog']}&form={$blog_opt}",$body); + $body = str_replace("name='submit'","name='supermit'",$body); + $body = str_replace('name="submit"','name="supermit"',$body); + $body = str_replace('','',str_replace('','',$body)); + $form = "
"; + $form.= $body; + $form.= "
"; + $output.= '

'.sprintf('%s in progress, please wait...', $blog_opt)."

\n"; + } else { + $output.= "

$blog_opt

\n"; + } + } + if ( $form ) + die($output . $form); + + $this->set_next_step(4); + $this->do_next_step(); + } + + // Step 3: Cancelled :-) + + // Step 4: Publish with the new template and settings. + function publish_blog() { + $this->publish_blogger(5, __('Publishing with new template and options')); + } + + // Step 5: Get the archive URLs from the new blog. + function get_archive_urls() { + $bloghtml = $this->get_blogger($this->import['blogs'][$_GET['blog']]['url']); + if (! strstr($bloghtml['body'], 'import['blogs'][$_GET['blog']]['archives'][$archive] = false; + } + $this->set_next_step(6); + $this->do_next_step(); + } + + // Step 6: Get each monthly archive, import it, mark it done. + function get_archive() { + global $wpdb; + $output = '

'.__('Importing Blogger archives into WordPress').'

'; + $did_one = false; + $post_array = $posts = array(); + foreach ( $this->import['blogs'][$_GET['blog']]['archives'] as $url => $status ) { + $archivename = substr(basename($url),0,7); + if ( $status || $did_one ) { + $foo = 'bar'; + // Do nothing. + } else { + // Import the selected month + $postcount = 0; + $skippedpostcount = 0; + $commentcount = 0; + $skippedcommentcount = 0; + $status = __('in progress...'); + $this->import['blogs'][$_GET['blog']]['archives']["$url"] = $status; + update_option('import-blogger', $import); + $archive = $this->get_blogger($url); + if ( $archive['code'] > 200 ) + continue; + $posts = explode('', $archive['body']); + for ($i = 1; $i < count($posts); $i = $i + 1) { + $postparts = explode('', $posts[$i]); + $postinfo = explode('|W|P|', $postparts[0]); + $post_date = $postinfo[0]; + $post_content = $postinfo[2]; + // Don't try to re-use the original numbers + // because the new, longer numbers are too + // big to handle as ints. + //$post_number = $postinfo[3]; + $post_title = ( $postinfo[4] != '' ) ? $postinfo[4] : $postinfo[3]; + $post_author_name = $wpdb->escape(trim($postinfo[1])); + $post_author_email = $postinfo[5] ? $postinfo[5] : 'user@wordpress.org'; + + if ( $this->lump_authors ) { + // Ignore Blogger authors. Use the current user_ID for all posts imported. + $post_author = $GLOBALS['user_ID']; + } else { + // Add a user for each new author encountered. + if (! username_exists($post_author_name) ) { + $user_login = $wpdb->escape($post_author_name); + $user_email = $wpdb->escape($post_author_email); + $user_password = substr(md5(uniqid(microtime())), 0, 6); + $result = wp_create_user( $user_login, $user_password, $user_email ); + $status.= sprintf('Registered user %s.', $user_login); + $this->import['blogs'][$_GET['blog']]['newusers'][] = $user_login; + } + $userdata = get_userdatabylogin( $post_author_name ); + $post_author = $userdata->ID; + } + $post_date = explode(' ', $post_date); + $post_date_Ymd = explode('/', $post_date[0]); + $postyear = $post_date_Ymd[2]; + $postmonth = zeroise($post_date_Ymd[0], 2); + $postday = zeroise($post_date_Ymd[1], 2); + $post_date_His = explode(':', $post_date[1]); + $posthour = zeroise($post_date_His[0], 2); + $postminute = zeroise($post_date_His[1], 2); + $postsecond = zeroise($post_date_His[2], 2); + + if (($post_date[2] == 'PM') && ($posthour != '12')) + $posthour = $posthour + 12; + else if (($post_date[2] == 'AM') && ($posthour == '12')) + $posthour = '00'; + + $post_date = "$postyear-$postmonth-$postday $posthour:$postminute:$postsecond"; + + $post_content = addslashes($post_content); + $post_content = str_replace(array('
','
','
','
','
','
'), "\n", $post_content); // the XHTML touch... ;) + + $post_title = addslashes($post_title); + + $post_status = 'publish'; + + if ( $ID = post_exists($post_title, '', $post_date) ) { + $post_array[$i]['ID'] = $ID; + $skippedpostcount++; + } else { + $post_array[$i]['post'] = compact('post_author', 'post_content', 'post_title', 'post_category', 'post_author', 'post_date', 'post_status'); + $post_array[$i]['comments'] = false; + } + + // Import any comments attached to this post. + if ($postparts[1]) : + for ($j = 1; $j < count($postparts); $j = $j + 1) { + $commentinfo = explode('|W|P|', $postparts[$j]); + $comment_date = explode(' ', $commentinfo[0]); + $comment_date_Ymd = explode('/', $comment_date[0]); + $commentyear = $comment_date_Ymd[2]; + $commentmonth = zeroise($comment_date_Ymd[0], 2); + $commentday = zeroise($comment_date_Ymd[1], 2); + $comment_date_His = explode(':', $comment_date[1]); + $commenthour = zeroise($comment_date_His[0], 2); + $commentminute = zeroise($comment_date_His[1], 2); + $commentsecond = '00'; + if (($comment_date[2] == 'PM') && ($commenthour != '12')) + $commenthour = $commenthour + 12; + else if (($comment_date[2] == 'AM') && ($commenthour == '12')) + $commenthour = '00'; + $comment_date = "$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond"; + $comment_author = addslashes(strip_tags($commentinfo[1])); + if ( strpos($commentinfo[1], 'a href') ) { + $comment_author_parts = explode('"', htmlentities($commentinfo[1])); + $comment_author_url = $comment_author_parts[1]; + } else $comment_author_url = ''; + $comment_content = $commentinfo[2]; + $comment_content = str_replace(array('
','
','
','
','
','
'), "\n", $comment_content); + $comment_approved = 1; + if ( comment_exists($comment_author, $comment_date) ) { + $skippedcommentcount++; + } else { + $comment = compact('comment_author', 'comment_author_url', 'comment_date', 'comment_content', 'comment_approved'); + $post_array[$i]['comments'][$j] = wp_filter_comment($comment); + } + $commentcount++; + } + endif; + $postcount++; + } + if ( count($post_array) ) { + krsort($post_array); + foreach($post_array as $post) { + if ( ! $comment_post_ID = $post['ID'] ) + $comment_post_ID = wp_insert_post($post['post']); + if ( $post['comments'] ) { + foreach ( $post['comments'] as $comment ) { + $comment['comment_post_ID'] = $comment_post_ID; + wp_insert_comment($comment); + } + } + } + } + $status = sprintf(__('%s post(s) parsed, %s skipped...'), $postcount, $skippedpostcount).' '. + sprintf(__('%s comment(s) parsed, %s skipped...'), $commentcoun, $skippedcommentcount).' '. + ' '.__('Done').''; + $import = $this->import; + $import['blogs'][$_GET['blog']]['archives']["$url"] = $status; + update_option('import-blogger', $import); + $did_one = true; + } + $output.= "

$archivename $status

\n"; + } + if ( ! $did_one ) + $this->set_next_step(7); + die( $this->refresher(1000) . $output ); + } + + // Step 7: Restore the backed-up settings to Blogger + function restore_settings() { + $output = '

'.__('Restoring your Blogger options')."

\n"; + $did_one = false; + // Restore options in reverse order. + if ( ! $this->import['reversed'] ) { + $this->import['blogs'][$_GET['blog']]['options'] = array_reverse($this->import['blogs'][$_GET['blog']]['options'], true); + $this->import['reversed'] = true; + update_option('import-blogger', $this->import); + } + foreach ( $this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary ) { + if ( $did_one ) { + $output .= "

$blog_opt

\n"; + } elseif ( $optary['restored'] || ! $optary['modify'] ) { + $output .= "

$blog_opt

\n"; + } else { + $posturl = "http://www.blogger.com/{$blog_opt}.do"; + $headers = array_merge($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'], $this->import['cookies']); + if ( 'blog-publishing' == $blog_opt) { + if ( $optary['backup']['publishMode'] > 0 ) { + $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode={$optary['backup']['publishMode']}", $headers); + sleep(2); + if ( $response['code'] >= 400 ) + die('

Error restoring publishMode.

Please tell the devs.

' . addslashes(print_r($response, 1)) ); + } + } + if ( $optary['backup'] != $optary['modify'] ) { + $response = $this->post_blogger($posturl, $headers, $optary['backup']); + if ( $response['code'] >= 400 || strstr($response['body'], 'There are errors on this form') ) { + $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['error'] = true; + update_option('import-blogger', $this->import); + $output .= sprintf(__('%s failed. Trying again.'), "

$blog_opt ").'

'; + } else { + $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['restored'] = true; + update_option('import-blogger', $this->import); + $output .= sprintf(__('%s restored.'), "

$blog_opt ").'

'; + } + } + $did_one = true; + } + } + + if ( $did_one ) { + die( $this->refresher(1000) . $output ); + } elseif ( $this->import['blogs'][$_GET['blog']]['options']['blog-publishing']['backup']['publishMode'] > 0 ) { + $this->set_next_step(9); + } else { + $this->set_next_step(8); + } + + $this->do_next_step(); + } + + // Step 8: Republish, all back to normal + function republish_blog() { + $this->publish_blogger(9, __('Publishing with original template and options')); + } + + // Step 9: Congratulate the user + function congrats() { + echo '

'.__('Congratulations!').'

'.__('Now that you have imported your Blogger blog into WordPress, what are you going to do? Here are some suggestions:').'

'; + } + + // Figures out what to do, then does it. + function start() { + if ( $_GET['restart'] == 'true' ) { + $this->restart(); + } + + if ( isset($_GET['noheader']) ) { + header('Content-Type: text/html; charset=utf-8'); + + $this->import = get_settings('import-blogger'); + + if ( false === $this->import ) { + $step = 0; + } elseif ( isset($_GET['step']) ) { + $step = (int) $_GET['step']; + } elseif ( isset($_GET['blog']) && isset($this->import['blogs'][$_GET['blog']]['nextstep']) ) { + $step = $this->import['blogs'][$_GET['blog']]['nextstep']; + } elseif ( is_array($this->import['blogs']) ) { + $step = 1; + } else { + $step = 0; + } +//echo "Step $step."; +//die('
'.print_r($this->import,1).'do_login();
+					break;
+				case 1 :
+					$this->select_blog();
+					break;
+				case 2 :
+					$this->backup_settings();
+					break;
+				case 3 :
+					$this->wait_for_blogger();
+					break;
+				case 4 :
+					$this->publish_blog();
+					break;
+				case 5 :
+					$this->get_archive_urls();
+					break;
+				case 6 :
+					$this->get_archive();
+					break;
+				case 7 :
+					$this->restore_settings();
+					break;
+				case 8 :
+					$this->republish_blog();
+					break;
+				case 9 :
+					$this->congrats();
+					break;
+			}
+			die;
+			
+		} else {
+			$this->greet();
+		}
+	}
+
+	function Blogger_Import() {
+		// This space intentionally left blank.
+	}
+}
+
+$blogger_import = new Blogger_Import();
+
+register_importer('blogger', 'Blogger', __('Import posts and comments from a Blogger account'), array ($blogger_import, 'start'));
+
+?>
diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php
new file mode 100644
index 00000000..2caab8c3
--- /dev/null
+++ b/wp-admin/import/dotclear.php
@@ -0,0 +1,741 @@
+get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
+	
+	return $name;
+	}
+}
+
+if(!function_exists('get_comment_count'))
+{
+	function get_comment_count($post_ID)
+	{
+		global $wpdb;
+		return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID);
+	}
+}
+
+if(!function_exists('link_cat_exists'))
+{
+	function link_cat_exists($catname)
+	{
+		global $wpdb;
+		return $wpdb->get_var('SELECT cat_id FROM '.$wpdb->linkcategories.' WHERE cat_name = "'.$wpdb->escape($catname).'"');
+	}
+}
+
+if(!function_exists('link_exists'))
+{
+	function link_exists($linkname)
+	{
+		global $wpdb;
+		return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$linkname.'"');
+	}
+}
+
+/*
+ Identify UTF-8 text
+ Taken from http://www.php.net/manual/fr/function.mb-detect-encoding.php#50087
+*/
+//
+//    utf8 encoding validation developed based on Wikipedia entry at:
+//    http://en.wikipedia.org/wiki/UTF-8
+//
+//    Implemented as a recursive descent parser based on a simple state machine
+//    copyright 2005 Maarten Meijer
+//
+//    This cries out for a C-implementation to be included in PHP core
+//
+   function valid_1byte($char) {
+       if(!is_int($char)) return false;
+       return ($char & 0x80) == 0x00;
+   }
+  
+   function valid_2byte($char) {
+       if(!is_int($char)) return false;
+       return ($char & 0xE0) == 0xC0;
+   }
+
+   function valid_3byte($char) {
+       if(!is_int($char)) return false;
+       return ($char & 0xF0) == 0xE0;
+   }
+
+   function valid_4byte($char) {
+       if(!is_int($char)) return false;
+       return ($char & 0xF8) == 0xF0;
+   }
+  
+   function valid_nextbyte($char) {
+       if(!is_int($char)) return false;
+       return ($char & 0xC0) == 0x80;
+   }
+  
+   function valid_utf8($string) {
+       $len = strlen($string);
+       $i = 0;   
+       while( $i < $len ) {
+           $char = ord(substr($string, $i++, 1));
+           if(valid_1byte($char)) {    // continue
+               continue;
+           } else if(valid_2byte($char)) { // check 1 byte
+               if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+                   return false;
+           } else if(valid_3byte($char)) { // check 2 bytes
+               if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+                   return false;
+               if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+                   return false;
+           } else if(valid_4byte($char)) { // check 3 bytes
+               if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+                   return false;
+               if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+                   return false;
+               if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+                   return false;
+           } // goto next char
+       }
+       return true; // done
+   }
+
+function csc ($s) {
+	if (valid_utf8 ($s)) {
+		return $s;
+	} else {
+		return iconv(get_option ("dccharset"),"UTF-8",$s);
+	}
+}
+
+function textconv ($s) {
+	return csc (preg_replace ('|(?)\s*\n|', ' ', $s));
+}
+
+/**
+	The Main Importer Class
+**/
+class Dotclear_Import {
+
+	function header() 
+	{
+		echo '
'; + echo '

'.__('Import Dotclear').'

'; + echo '

'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'

'; + } + + function footer() + { + echo '
'; + } + + function greet() + { + echo '

'.__('Howdy! This importer allows you to extract posts from a Dotclear database into your blog. Mileage may vary.').'

'; + echo '

'.__('Your Dotclear Configuration settings are as follows:').'

'; + echo '
'; + $this->db_form(); + echo ''; + echo '
'; + } + + function get_dc_cats() + { + global $wpdb; + // General Housekeeping + $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); + set_magic_quotes_runtime(0); + $prefix = get_option('tpre'); + + // Get Categories + return $dcdb->get_results('SELECT * FROM dc_categorie', ARRAY_A); + } + + function get_dc_users() + { + global $wpdb; + // General Housekeeping + $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); + set_magic_quotes_runtime(0); + $prefix = get_option('tpre'); + + // Get Users + + return $dcdb->get_results('SELECT * FROM dc_user', ARRAY_A); + } + + function get_dc_posts() + { + // General Housekeeping + $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); + set_magic_quotes_runtime(0); + $prefix = get_option('tpre'); + + // Get Posts + return $dcdb->get_results('SELECT dc_post.*, dc_categorie.cat_libelle_url AS post_cat_name + FROM dc_post INNER JOIN dc_categorie + ON dc_post.cat_id = dc_categorie.cat_id', ARRAY_A); + } + + function get_dc_comments() + { + global $wpdb; + // General Housekeeping + $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); + set_magic_quotes_runtime(0); + $prefix = get_option('tpre'); + + // Get Comments + return $dcdb->get_results('SELECT * FROM dc_comment', ARRAY_A); + } + + function get_dc_links() + { + //General Housekeeping + $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); + set_magic_quotes_runtime(0); + $prefix = get_option('tpre'); + + return $dcdb->get_results('SELECT * FROM dc_link ORDER BY position', ARRAY_A); + } + + function cat2wp($categories='') + { + // General Housekeeping + global $wpdb; + $count = 0; + $dccat2wpcat = array(); + // Do the Magic + if(is_array($categories)) + { + echo '

'.__('Importing Categories...').'

'; + foreach ($categories as $category) + { + $count++; + extract($category); + + // Make Nice Variables + $name = $wpdb->escape($cat_libelle_url); + $title = $wpdb->escape(csc ($cat_libelle)); + $desc = $wpdb->escape(csc ($cat_desc)); + + if($cinfo = category_exists($name)) + { + $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc)); + } + else + { + $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc)); + } + $dccat2wpcat[$id] = $ret_id; + } + + // Store category translation for future use + add_option('dccat2wpcat',$dccat2wpcat); + echo '

'.sprintf(__('Done! %1$s categories imported.'), $count).'

'; + return true; + } + echo __('No Categories to Import!'); + return false; + } + + function users2wp($users='') + { + // General Housekeeping + global $wpdb; + $count = 0; + $dcid2wpid = array(); + + // Midnight Mojo + if(is_array($users)) + { + echo '

'.__('Importing Users...').'

'; + foreach($users as $user) + { + $count++; + extract($user); + + // Make Nice Variables + $name = $wpdb->escape(csc ($name)); + $RealName = $wpdb->escape(csc ($user_pseudo)); + + if($uinfo = get_userdatabylogin($name)) + { + + $ret_id = wp_insert_user(array( + 'ID' => $uinfo->ID, + 'user_login' => $user_id, + 'user_nicename' => $Realname, + 'user_email' => $user_email, + 'user_url' => 'http://', + 'display_name' => $Realname) + ); + } + else + { + $ret_id = wp_insert_user(array( + 'user_login' => $user_id, + 'user_nicename' => csc ($user_pseudo), + 'user_email' => $user_email, + 'user_url' => 'http://', + 'display_name' => $Realname) + ); + } + $dcid2wpid[$user_id] = $ret_id; + + // Set Dotclear-to-WordPress permissions translation + + // Update Usermeta Data + $user = new WP_User($ret_id); + $wp_perms = $user_level + 1; + if(10 == $wp_perms) { $user->set_role('administrator'); } + else if(9 == $wp_perms) { $user->set_role('editor'); } + else if(5 <= $wp_perms) { $user->set_role('editor'); } + else if(4 <= $wp_perms) { $user->set_role('author'); } + else if(3 <= $wp_perms) { $user->set_role('contributor'); } + else if(2 <= $wp_perms) { $user->set_role('contributor'); } + else { $user->set_role('subscriber'); } + + update_usermeta( $ret_id, 'wp_user_level', $wp_perms); + update_usermeta( $ret_id, 'rich_editing', 'false'); + update_usermeta( $ret_id, 'first_name', csc ($user_prenom)); + update_usermeta( $ret_id, 'last_name', csc ($user_nom)); + }// End foreach($users as $user) + + // Store id translation array for future use + add_option('dcid2wpid',$dcid2wpid); + + + echo '

'.sprintf(__('Done! %1$s users imported.'), $count).'

'; + return true; + }// End if(is_array($users) + + echo __('No Users to Import!'); + return false; + + }// End function user2wp() + + function posts2wp($posts='') + { + // General Housekeeping + global $wpdb; + $count = 0; + $dcposts2wpposts = array(); + $cats = array(); + + // Do the Magic + if(is_array($posts)) + { + echo '

'.__('Importing Posts...').'

'; + foreach($posts as $post) + { + $count++; + extract($post); + + // Set Dotclear-to-WordPress status translation + $stattrans = array(0 => 'draft', 1 => 'publish'); + $comment_status_map = array (0 => 'closed', 1 => 'open'); + + //Can we do this more efficiently? + $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1; + $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ; + + $Title = $wpdb->escape(csc ($post_titre)); + $post_content = textconv ($post_content); + if ($post_chapo != "") { + $post_excerpt = textconv ($post_chapo); + $post_content = $post_excerpt ."\n\n".$post_content; + } + $post_excerpt = $wpdb->escape ($post_excerpt); + $post_content = $wpdb->escape ($post_content); + $post_status = $stattrans[$post_pub]; + + // Import Post data into WordPress + + if($pinfo = post_exists($Title,$post_content)) + { + $ret_id = wp_insert_post(array( + 'ID' => $pinfo, + 'post_author' => $authorid, + 'post_date' => $post_dt, + 'post_date_gmt' => $post_dt, + 'post_modified' => $post_upddt, + 'post_modified_gmt' => $post_upddt, + 'post_title' => $Title, + 'post_content' => $post_content, + 'post_excerpt' => $post_excerpt, + 'post_status' => $post_status, + 'post_name' => $post_titre_url, + 'comment_status' => $comment_status_map[$post_open_comment], + 'ping_status' => $comment_status_map[$post_open_tb], + 'comment_count' => $post_nb_comment + $post_nb_trackback) + ); + } + else + { + $ret_id = wp_insert_post(array( + 'post_author' => $authorid, + 'post_date' => $post_dt, + 'post_date_gmt' => $post_dt, + 'post_modified' => $post_modified_gmt, + 'post_modified_gmt' => $post_modified_gmt, + 'post_title' => $Title, + 'post_content' => $post_content, + 'post_excerpt' => $post_excerpt, + 'post_status' => $post_status, + 'post_name' => $post_titre_url, + 'comment_status' => $comment_status_map[$post_open_comment], + 'ping_status' => $comment_status_map[$post_open_tb], + 'comment_count' => $post_nb_comment + $post_nb_trackback) + ); + } + $dcposts2wpposts[$post_id] = $ret_id; + + // Make Post-to-Category associations + $cats = array(); + if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; } + + if(!empty($cats)) { wp_set_post_cats('', $ret_id, $cats); } + } + } + // Store ID translation for later use + add_option('dcposts2wpposts',$dcposts2wpposts); + + echo '

'.sprintf(__('Done! %1$s posts imported.'), $count).'

'; + return true; + } + + function comments2wp($comments='') + { + // General Housekeeping + global $wpdb; + $count = 0; + $dccm2wpcm = array(); + $postarr = get_option('dcposts2wpposts'); + + // Magic Mojo + if(is_array($comments)) + { + echo '

'.__('Importing Comments...').'

'; + foreach($comments as $comment) + { + $count++; + extract($comment); + + // WordPressify Data + $comment_ID = ltrim($comment_id, '0'); + $comment_post_ID = $postarr[$post_id]; + $comment_approved = "$comment_pub"; + $name = $wpdb->escape(csc ($comment_auteur)); + $email = $wpdb->escape($comment_email); + $web = "http://".$wpdb->escape($comment_site); + $message = $wpdb->escape(textconv ($comment_content)); + + if($cinfo = comment_exists($name, $comment_dt)) + { + // Update comments + $ret_id = wp_update_comment(array( + 'comment_ID' => $cinfo, + 'comment_post_ID' => $comment_post_ID, + 'comment_author' => $name, + 'comment_author_email' => $email, + 'comment_author_url' => $web, + 'comment_author_IP' => $comment_ip, + 'comment_date' => $comment_dt, + 'comment_date_gmt' => $comment_dt, + 'comment_content' => $message, + 'comment_approved' => $comment_approved) + ); + } + else + { + // Insert comments + $ret_id = wp_insert_comment(array( + 'comment_post_ID' => $comment_post_ID, + 'comment_author' => $name, + 'comment_author_email' => $email, + 'comment_author_url' => $web, + 'comment_author_IP' => $comment_ip, + 'comment_date' => $comment_dt, + 'comment_date_gmt' => $comment_dt, + 'comment_content' => $message, + 'comment_approved' => $comment_approved) + ); + } + $dccm2wpcm[$comment_ID] = $ret_id; + } + // Store Comment ID translation for future use + add_option('dccm2wpcm', $dccm2wpcm); + + // Associate newly formed categories with posts + get_comment_count($ret_id); + + + echo '

'.sprintf(__('Done! %1$s comments imported.'), $count).'

'; + return true; + } + echo __('No Comments to Import!'); + return false; + } + + function links2wp($links='') + { + // General Housekeeping + global $wpdb; + $count = 0; + + // Deal with the links + if(is_array($links)) + { + echo '

'.__('Importing Links...').'

'; + foreach($links as $link) + { + $count++; + extract($link); + + if ($title != "") { + if ($cinfo = link_cat_exists (csc ($title))) { + $category = $cinfo; + } else { + $wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('". + $wpdb->escape (csc ($title))."')"); + $category = $wpdb->insert_id; + } + } else { + $linkname = $wpdb->escape(csc ($label)); + $description = $wpdb->escape(csc ($title)); + + if($linfo = link_exists($linkname)) { + $ret_id = wp_insert_link(array( + 'link_id' => $linfo, + 'link_url' => $href, + 'link_name' => $linkname, + 'link_category' => $category, + 'link_description' => $description) + ); + } else { + $ret_id = wp_insert_link(array( + 'link_url' => $url, + 'link_name' => $linkname, + 'link_category' => $category, + 'link_description' => $description) + ); + } + $dclinks2wplinks[$link_id] = $ret_id; + } + } + add_option('dclinks2wplinks',$dclinks2wplinks); + echo '

'; + printf(__('Done! %s links or link categories imported'), $count); + echo '

'; + return true; + } + echo __('No Links to Import!'); + return false; + } + + function import_categories() + { + // Category Import + $cats = $this->get_dc_cats(); + $this->cat2wp($cats); + add_option('dc_cats', $cats); + + + + echo '
'; + printf('', __('Import Users')); + echo '
'; + + } + + function import_users() + { + // User Import + $users = $this->get_dc_users(); + $this->users2wp($users); + + echo '
'; + printf('', __('Import Posts')); + echo '
'; + } + + function import_posts() + { + // Post Import + $posts = $this->get_dc_posts(); + $this->posts2wp($posts); + + echo '
'; + printf('', __('Import Comments')); + echo '
'; + } + + function import_comments() + { + // Comment Import + $comments = $this->get_dc_comments(); + $this->comments2wp($comments); + + echo '
'; + printf('', __('Import Links')); + echo '
'; + } + + function import_links() + { + //Link Import + $links = $this->get_dc_links(); + $this->links2wp($links); + add_option('dc_links', $links); + + echo '
'; + printf('', __('Finish')); + echo '
'; + } + + function cleanup_dcimport() + { + delete_option('tpre'); + delete_option('dc_cats'); + delete_option('dcid2wpid'); + delete_option('dccat2wpcat'); + delete_option('dcposts2wpposts'); + delete_option('dccm2wpcm'); + delete_option('dclinks2wplinks'); + delete_option('dcuser'); + delete_option('dcpass'); + delete_option('dcname'); + delete_option('dchost'); + delete_option('dccharset'); + $this->tips(); + } + + function tips() + { + echo '

'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Dotclear, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.').'

'; + echo '

'.__('Users').'

'; + echo '

'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in Dotclear, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Dotclear uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. Every user has the same username, but their passwords are reset to password123. So Login and change it.'), '/wp-login.php').'

'; + echo '

'.__('Preserving Authors').'

'; + echo '

'.__('Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'

'; + echo '

'.__('Textile').'

'; + echo '

'.__('Also, since you\'re coming from Dotclear, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing Textile for WordPress. Trust me... You\'ll want it.').'

'; + echo '

'.__('WordPress Resources').'

'; + echo '

'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'

'; + echo ''; + echo '

'.sprintf(__('That\'s it! What are you waiting for? Go login!'), '/wp-login.php').'

'; + } + + function db_form() + { + echo '
    '; + printf('
  • ', __('Dotclear Database User:')); + printf('
  • ', __('Dotclear Database Password:')); + printf('
  • ', __('Dotclear Database Name:')); + printf('
  • ', __('Dotclear Database Host:')); + /* printf('
  • ', __('Dotclear Table prefix (if any):')); */ + printf('
  • ', __('Originating character set:')); + echo '
'; + } + + function dispatch() + { + + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + $this->header(); + + if ( $step > 0 ) + { + if($_POST['dbuser']) + { + if(get_option('dcuser')) + delete_option('dcuser'); + add_option('dcuser',$_POST['dbuser']); + } + if($_POST['dbpass']) + { + if(get_option('dcpass')) + delete_option('dcpass'); + add_option('dcpass',$_POST['dbpass']); + } + + if($_POST['dbname']) + { + if(get_option('dcname')) + delete_option('dcname'); + add_option('dcname',$_POST['dbname']); + } + if($_POST['dbhost']) + { + if(get_option('dchost')) + delete_option('dchost'); + add_option('dchost',$_POST['dbhost']); + } + if($_POST['dccharset']) + { + if(get_option('dccharset')) + delete_option('dccharset'); + add_option('dccharset',$_POST['dccharset']); + } + if($_POST['dbprefix']) + { + if(get_option('tpre')) + delete_option('tpre'); + add_option('tpre',$_POST['dbprefix']); + } + + + } + + switch ($step) + { + default: + case 0 : + $this->greet(); + break; + case 1 : + $this->import_categories(); + break; + case 2 : + $this->import_users(); + break; + case 3 : + $this->import_posts(); + break; + case 4 : + $this->import_comments(); + break; + case 5 : + $this->import_links(); + break; + case 6 : + $this->cleanup_dcimport(); + break; + } + + $this->footer(); + } + + function Dotclear_Import() + { + // Nothing. + } +} + +$dc_import = new Dotclear_Import(); +register_importer('dotclear', 'Dotclear', __('Import posts from a Dotclear Blog'), array ($dc_import, 'dispatch')); +?> diff --git a/wp-admin/import/greymatter.php b/wp-admin/import/greymatter.php new file mode 100644 index 00000000..e69de29b diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php new file mode 100644 index 00000000..e8c48c4a --- /dev/null +++ b/wp-admin/import/livejournal.php @@ -0,0 +1,171 @@ +'; + echo '

'.__('Import LiveJournal').'

'; + } + + function footer() { + echo ''; + } + + function unhtmlentities($string) { // From php.net for < 4.3 compat + $trans_tbl = get_html_translation_table(HTML_ENTITIES); + $trans_tbl = array_flip($trans_tbl); + return strtr($string, $trans_tbl); + } + + function greet() { + echo '

'.__('Howdy! This importer allows you to extract posts from LiveJournal XML export file into your blog. Pick a LiveJournal file to upload and click Import.').'

'; + wp_import_upload_form("admin.php?import=livejournal&step=1"); + } + + function import_posts() { + global $wpdb, $current_user; + + set_magic_quotes_runtime(0); + $importdata = file($this->file); // Read the file into an array + $importdata = implode('', $importdata); // squish it + $importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata); + + preg_match_all('|(.*?)|is', $importdata, $posts); + $posts = $posts[1]; + unset($importdata); + echo '
    '; + foreach ($posts as $post) { + flush(); + preg_match('|(.*?)|is', $post, $post_title); + $post_title = $wpdb->escape(trim($post_title[1])); + if ( empty($post_title) ) { + preg_match('|(.*?)|is', $post, $post_title); + $post_title = $wpdb->escape(trim($post_title[1])); + } + + preg_match('|(.*?)|is', $post, $post_date); + $post_date = strtotime($post_date[1]); + $post_date = gmdate('Y-m-d H:i:s', $post_date); + + preg_match('|(.*?)|is', $post, $post_content); + $post_content = str_replace(array (''), '', trim($post_content[1])); + $post_content = $this->unhtmlentities($post_content); + + // Clean up content + $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); + $post_content = str_replace('
    ', '
    ', $post_content); + $post_content = str_replace('
    ', '
    ', $post_content); + $post_content = $wpdb->escape($post_content); + + $post_author = $current_user->ID; + $post_status = 'publish'; + + echo '
  1. '; + if ($post_id = post_exists($post_title, $post_content, $post_date)) { + printf(__('Post %s already exists.'), stripslashes($post_title)); + } else { + printf(__('Importing post %s...'), stripslashes($post_title)); + $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status'); + $post_id = wp_insert_post($postdata); + if (!$post_id) { + _e("Couldn't get post ID"); + echo '
  2. '; + break; + } + } + + preg_match_all('|(.*?)|is', $post, $comments); + $comments = $comments[1]; + + if ( $comments ) { + $comment_post_ID = $post_id; + $num_comments = 0; + foreach ($comments as $comment) { + preg_match('|(.*?)|is', $comment, $comment_content); + $comment_content = str_replace(array (''), '', trim($comment_content[1])); + $comment_content = $this->unhtmlentities($comment_content); + + // Clean up content + $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content); + $comment_content = str_replace('
    ', '
    ', $comment_content); + $comment_content = str_replace('
    ', '
    ', $comment_content); + $comment_content = $wpdb->escape($comment_content); + + preg_match('|(.*?)|is', $comment, $comment_date); + $comment_date = trim($comment_date[1]); + $comment_date = date('Y-m-d H:i:s', strtotime($comment_date)); + + preg_match('|(.*?)|is', $comment, $comment_author); + $comment_author = $wpdb->escape(trim($comment_author[1])); + + preg_match('|(.*?)|is', $comment, $comment_author_email); + $comment_author_email = $wpdb->escape(trim($comment_author_email[1])); + + $comment_approved = 1; + // Check if it's already there + if (!comment_exists($comment_author, $comment_date)) { + $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_date', 'comment_content', 'comment_approved'); + $commentdata = wp_filter_comment($commentdata); + wp_insert_comment($commentdata); + $num_comments++; + } + } + } + if ( $num_comments ) { + echo ' '; + printf(__('(%s comments)'), $num_comments); + } + echo ''; + flush(); + ob_flush(); + } + echo '
'; + } + + function import() { + $file = wp_import_handle_upload(); + if ( isset($file['error']) ) { + echo $file['error']; + return; + } + + $this->file = $file['file']; + $this->import_posts(); + wp_import_cleanup($file['id']); + + echo '

'; + printf(__('All done. Have fun!'), get_option('home')); + echo '

'; + } + + function dispatch() { + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + + $this->header(); + + switch ($step) { + case 0 : + $this->greet(); + break; + case 1 : + $this->import(); + break; + } + + $this->footer(); + } + + function LJ_Import() { + // Nothing. + } +} + +$livejournal_import = new LJ_Import(); + +register_importer('livejournal', 'LiveJournal', __('Import posts from LiveJournal'), array ($livejournal_import, 'dispatch')); +?> diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php new file mode 100644 index 00000000..3281f087 --- /dev/null +++ b/wp-admin/import/mt.php @@ -0,0 +1,430 @@ +'; + echo '

'.__('Import Movable Type').'

'; + } + + function footer() { + echo ''; + } + + function greet() { + $this->header(); +?> +

+ +

out of memory error try splitting up the import file into pieces.'); ?>

+footer(); + } + + function users_form($n) { + global $wpdb, $testing; + $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID"); +?> + mtnames))) { //a new mt author name is found + ++ $this->j; + $this->mtnames[$this->j] = $author; //add that new mt author name to an array + $user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user + if (!$user_id) { //banging my head against the desk now. + if ($newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname + $user_id = wp_create_user($author, $pass); + $this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank. + } else { + $user_id = wp_create_user($this->newauthornames[$this->j], $pass); + } + } else { + return $user_id; // return pre-existing wp username if it exists + } + } else { + $key = array_search($author, $this->mtnames); //find the array key for $author in the $mtnames array + $user_id = username_exists($this->newauthornames[$key]); //use that key to get the value of the author's name from $newauthornames + } + + return $user_id; + } + + function get_entries() { + set_magic_quotes_runtime(0); + $importdata = file($this->file); // Read the file into an array + $importdata = implode('', $importdata); // squish it + $importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata); + $importdata = preg_replace("/\n--------\n/", "--MT-ENTRY--\n", $importdata); + $this->posts = explode("--MT-ENTRY--", $importdata); + } + + function get_mt_authors() { + $temp = array (); + $i = -1; + foreach ($this->posts as $post) { + if ('' != trim($post)) { + ++ $i; + preg_match("|AUTHOR:(.*)|", $post, $thematch); + $thematch = trim($thematch[1]); + array_push($temp, "$thematch"); //store the extracted author names in a temporary array + } + } + + //we need to find unique values of author names, while preserving the order, so this function emulates the unique_value(); php function, without the sorting. + $authors[0] = array_shift($temp); + $y = count($temp) + 1; + for ($x = 1; $x < $y; $x ++) { + $next = array_shift($temp); + if (!(in_array($next, $authors))) + array_push($authors, "$next"); + } + + return $authors; + } + + function get_authors_from_post() { + $formnames = array (); + $selectnames = array (); + + foreach ($_POST['user'] as $key => $line) { + $newname = trim(stripslashes($line)); + if ($newname == '') + $newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form. + array_push($formnames, "$newname"); + } // $formnames is the array with the form entered names + + foreach ($_POST['userselect'] as $user => $key) { + $selected = trim(stripslashes($key)); + array_push($selectnames, "$selected"); + } + + $count = count($formnames); + for ($i = 0; $i < $count; $i ++) { + if ($selectnames[$i] != '#NONE#') { //if no name was selected from the select menu, use the name entered in the form + array_push($this->newauthornames, "$selectnames[$i]"); + } else { + array_push($this->newauthornames, "$formnames[$i]"); + } + } + } + + function mt_authors_form() { +?> +

admins entries.'); ?>

+

italics. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?>

+

+ get_mt_authors(); + echo '
    '; + echo '
    '; + $j = -1; + foreach ($authors as $author) { + ++ $j; + echo '
  1. '.$author.'
    '.''; + $this->users_form($j); + echo '
  2. '; + } + + echo ''.'
    '; + echo '
    '; + echo '
'; + + flush(); + } + + function select_authors() { + $file = wp_import_handle_upload(); + if ( isset($file['error']) ) { + echo $file['error']; + return; + } + $this->file = $file['file']; + $this->id = $file['id']; + + $this->get_entries(); + $this->mt_authors_form(); + } + + function process_posts() { + global $wpdb; + $i = -1; + echo "
    "; + foreach ($this->posts as $post) { + if ('' != trim($post)) { + ++ $i; + unset ($post_categories); + + // Take the pings out first + preg_match("|(-----\n\nPING:.*)|s", $post, $pings); + $post = preg_replace("|(-----\n\nPING:.*)|s", '', $post); + + // Then take the comments out + preg_match("|(-----\nCOMMENT:.*)|s", $post, $comments); + $post = preg_replace("|(-----\nCOMMENT:.*)|s", '', $post); + + // We ignore the keywords + $post = preg_replace("|(-----\nKEYWORDS:.*)|s", '', $post); + + // We want the excerpt + preg_match("|-----\nEXCERPT:(.*)|s", $post, $excerpt); + $excerpt = $wpdb->escape(trim($excerpt[1])); + $post = preg_replace("|(-----\nEXCERPT:.*)|s", '', $post); + + // We're going to put extended body into main body with a more tag + preg_match("|-----\nEXTENDED BODY:(.*)|s", $post, $extended); + $extended = trim($extended[1]); + if ('' != $extended) + $extended = "\n\n$extended"; + $post = preg_replace("|(-----\nEXTENDED BODY:.*)|s", '', $post); + + // Now for the main body + preg_match("|-----\nBODY:(.*)|s", $post, $body); + $body = trim($body[1]); + $post_content = $wpdb->escape($body.$extended); + $post = preg_replace("|(-----\nBODY:.*)|s", '', $post); + + // Grab the metadata from what's left + $metadata = explode("\n", $post); + foreach ($metadata as $line) { + preg_match("/^(.*?):(.*)/", $line, $token); + $key = trim($token[1]); + $value = trim($token[2]); + // Now we decide what it is and what to do with it + switch ($key) { + case '' : + break; + case 'AUTHOR' : + $post_author = $value; + break; + case 'TITLE' : + $post_title = $wpdb->escape($value); + break; + case 'STATUS' : + // "publish" and "draft" enumeration items match up; no change required + $post_status = $value; + if (empty ($post_status)) + $post_status = 'publish'; + break; + case 'ALLOW COMMENTS' : + $post_allow_comments = $value; + if ($post_allow_comments == 1) { + $comment_status = 'open'; + } else { + $comment_status = 'closed'; + } + break; + case 'CONVERT BREAKS' : + $post_convert_breaks = $value; + break; + case 'ALLOW PINGS' : + $ping_status = trim($meta[2][0]); + if ($ping_status == 1) { + $ping_status = 'open'; + } else { + $ping_status = 'closed'; + } + break; + case 'PRIMARY CATEGORY' : + if (! empty ($value) ) + $post_categories[] = $wpdb->escape($value); + break; + case 'CATEGORY' : + if (! empty ($value) ) + $post_categories[] = $wpdb->escape($value); + break; + case 'DATE' : + $post_modified = strtotime($value); + $post_modified = date('Y-m-d H:i:s', $post_modified); + $post_modified_gmt = get_gmt_from_date("$post_modified"); + $post_date = $post_modified; + $post_date_gmt = $post_modified_gmt; + break; + default : + // echo "\n$key: $value"; + break; + } // end switch + } // End foreach + + // Let's check to see if it's in already + if ($post_id = post_exists($post_title, '', $post_date)) { + echo '
  1. '; + printf(__('Post %s already exists.'), stripslashes($post_title)); + } else { + echo '
  2. '; + printf(__('Importing post %s...'), stripslashes($post_title)); + + $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor + + $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt'); + $post_id = wp_insert_post($postdata); + // Add categories. + if (0 != count($post_categories)) { + wp_create_categories($post_categories, $post_id); + } + } + + $comment_post_ID = $post_id; + $comment_approved = 1; + + // Now for comments + $comments = explode("-----\nCOMMENT:", $comments[0]); + $num_comments = 0; + foreach ($comments as $comment) { + if ('' != trim($comment)) { + // Author + preg_match("|AUTHOR:(.*)|", $comment, $comment_author); + $comment_author = $wpdb->escape(trim($comment_author[1])); + $comment = preg_replace('|(\n?AUTHOR:.*)|', '', $comment); + preg_match("|EMAIL:(.*)|", $comment, $comment_author_email); + $comment_author_email = $wpdb->escape(trim($comment_author_email[1])); + $comment = preg_replace('|(\n?EMAIL:.*)|', '', $comment); + + preg_match("|IP:(.*)|", $comment, $comment_author_IP); + $comment_author_IP = trim($comment_author_IP[1]); + $comment = preg_replace('|(\n?IP:.*)|', '', $comment); + + preg_match("|URL:(.*)|", $comment, $comment_author_url); + $comment_author_url = $wpdb->escape(trim($comment_author_url[1])); + $comment = preg_replace('|(\n?URL:.*)|', '', $comment); + + preg_match("|DATE:(.*)|", $comment, $comment_date); + $comment_date = trim($comment_date[1]); + $comment_date = date('Y-m-d H:i:s', strtotime($comment_date)); + $comment = preg_replace('|(\n?DATE:.*)|', '', $comment); + + $comment_content = $wpdb->escape(trim($comment)); + $comment_content = str_replace('-----', '', $comment_content); + // Check if it's already there + if (!comment_exists($comment_author, $comment_date)) { + $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_approved'); + $commentdata = wp_filter_comment($commentdata); + wp_insert_comment($commentdata); + $num_comments++; + } + } + } + if ( $num_comments ) + printf(__('(%s comments)'), $num_comments); + + // Finally the pings + // fix the double newline on the first one + $pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]); + $pings = explode("-----\nPING:", $pings[0]); + $num_pings = 0; + foreach ($pings as $ping) { + if ('' != trim($ping)) { + // 'Author' + preg_match("|BLOG NAME:(.*)|", $ping, $comment_author); + $comment_author = $wpdb->escape(trim($comment_author[1])); + $ping = preg_replace('|(\n?BLOG NAME:.*)|', '', $ping); + + preg_match("|IP:(.*)|", $ping, $comment_author_IP); + $comment_author_IP = trim($comment_author_IP[1]); + $ping = preg_replace('|(\n?IP:.*)|', '', $ping); + + preg_match("|URL:(.*)|", $ping, $comment_author_url); + $comment_author_url = $wpdb->escape(trim($comment_author_url[1])); + $ping = preg_replace('|(\n?URL:.*)|', '', $ping); + + preg_match("|DATE:(.*)|", $ping, $comment_date); + $comment_date = trim($comment_date[1]); + $comment_date = date('Y-m-d H:i:s', strtotime($comment_date)); + $ping = preg_replace('|(\n?DATE:.*)|', '', $ping); + + preg_match("|TITLE:(.*)|", $ping, $ping_title); + $ping_title = $wpdb->escape(trim($ping_title[1])); + $ping = preg_replace('|(\n?TITLE:.*)|', '', $ping); + + $comment_content = $wpdb->escape(trim($ping)); + $comment_content = str_replace('-----', '', $comment_content); + + $comment_content = "$ping_title\n\n$comment_content"; + + $comment_type = 'trackback'; + + // Check if it's already there + if (!comment_exists($comment_author, $comment_date)) { + $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_type', 'comment_approved'); + $commentdata = wp_filter_comment($commentdata); + wp_insert_comment($commentdata); + $num_pings++; + } + } + } + if ( $num_pings ) + printf(__('(%s pings)'), $num_pings); + + echo "
  3. "; + } + flush(); + } + + echo '
'; + + wp_import_cleanup($this->id); + + echo '

'.sprintf(__('All done. Have fun!'), get_option('home')).'

'; + } + + function import() { + $this->id = (int) $_GET['id']; + $this->file = get_attached_file($this->id); + $this->get_authors_from_post(); + $this->get_entries(); + $this->process_posts(); + } + + function dispatch() { + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + + switch ($step) { + case 0 : + $this->greet(); + break; + case 1 : + $this->select_authors(); + break; + case 2: + $this->import(); + break; + } + } + + function MT_Import() { + // Nothing. + } +} + +$mt_import = new MT_Import(); + +register_importer('mt', 'Movable Type', __('Import posts and comments from your Movable Type blog'), array ($mt_import, 'dispatch')); +?> diff --git a/wp-admin/import/rss.php b/wp-admin/import/rss.php new file mode 100644 index 00000000..e4a81673 --- /dev/null +++ b/wp-admin/import/rss.php @@ -0,0 +1,171 @@ +'; + echo '

'.__('Import RSS').'

'; + } + + function footer() { + echo ''; + } + + function unhtmlentities($string) { // From php.net for < 4.3 compat + $trans_tbl = get_html_translation_table(HTML_ENTITIES); + $trans_tbl = array_flip($trans_tbl); + return strtr($string, $trans_tbl); + } + + function greet() { + echo '

'.__('Howdy! This importer allows you to extract posts from any RSS 2.0 file into your blog. This is useful if you want to import your posts from a system that is not handled by a custom import tool. Pick an RSS file to upload and click Import.').'

'; + wp_import_upload_form("admin.php?import=rss&step=1"); + } + + function get_posts() { + global $wpdb; + + set_magic_quotes_runtime(0); + $datalines = file($this->file); // Read the file into an array + $importdata = implode('', $datalines); // squish it + $importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata); + + preg_match_all('|(.*?)|is', $importdata, $this->posts); + $this->posts = $this->posts[1]; + $index = 0; + foreach ($this->posts as $post) { + preg_match('|(.*?)|is', $post, $post_title); + $post_title = $wpdb->escape(trim($post_title[1])); + + preg_match('|(.*?)|is', $post, $post_date); + + if ($post_date) { + $post_date = strtotime($post_date[1]); + } else { + // if we don't already have something from pubDate + preg_match('|(.*?)|is', $post, $post_date); + $post_date = preg_replace('|([-+])([0-9]+):([0-9]+)$|', '\1\2\3', $post_date[1]); + $post_date = str_replace('T', ' ', $post_date); + $post_date = strtotime($post_date); + } + + $post_date = gmdate('Y-m-d H:i:s', $post_date); + + preg_match_all('|(.*?)|is', $post, $categories); + $categories = $categories[1]; + + if (!$categories) { + preg_match_all('|(.*?)|is', $post, $categories); + $categories = $categories[1]; + } + + $cat_index = 0; + foreach ($categories as $category) { + $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category)); + $cat_index++; + } + + preg_match('|(.*?)|is', $post, $guid); + if ($guid) + $guid = $wpdb->escape(trim($guid[1])); + else + $guid = ''; + + preg_match('|(.*?)|is', $post, $post_content); + $post_content = str_replace(array (''), '', $wpdb->escape(trim($post_content[1]))); + + if (!$post_content) { + // This is for feeds that put content in description + preg_match('|(.*?)|is', $post, $post_content); + $post_content = $wpdb->escape($this->unhtmlentities(trim($post_content[1]))); + } + + // Clean up content + $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); + $post_content = str_replace('
', '
', $post_content); + $post_content = str_replace('
', '
', $post_content); + + $post_author = 1; + $post_status = 'publish'; + $this->posts[$index] = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status', 'guid', 'categories'); + $index++; + } + } + + function import_posts() { + echo '
    '; + + foreach ($this->posts as $post) { + echo "
  1. ".__('Importing post...'); + + extract($post); + + if ($post_id = post_exists($post_title, $post_content, $post_date)) { + _e('Post already imported'); + } else { + $post_id = wp_insert_post($post); + if (!$post_id) { + _e("Couldn't get post ID"); + return; + } + + if (0 != count($categories)) + wp_create_categories($categories, $post_id); + _e('Done !'); + } + echo '
  2. '; + } + + echo '
'; + + } + + function import() { + $file = wp_import_handle_upload(); + if ( isset($file['error']) ) { + echo $file['error']; + return; + } + + $this->file = $file['file']; + $this->get_posts(); + $this->import_posts(); + wp_import_cleanup($file['id']); + + echo '

'; + printf(__('All done. Have fun!'), get_option('home')); + echo '

'; + } + + function dispatch() { + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + + $this->header(); + + switch ($step) { + case 0 : + $this->greet(); + break; + case 1 : + $this->import(); + break; + } + + $this->footer(); + } + + function RSS_Import() { + // Nothing. + } +} + +$rss_import = new RSS_Import(); + +register_importer('rss', 'RSS', __('Import posts from an RSS feed'), array ($rss_import, 'dispatch')); +?> diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php new file mode 100644 index 00000000..29010812 --- /dev/null +++ b/wp-admin/import/textpattern.php @@ -0,0 +1,663 @@ +get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"'); + + return $name; + } +} + +if(!function_exists('get_comment_count')) +{ + function get_comment_count($post_ID) + { + global $wpdb; + return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID); + } +} + +if(!function_exists('link_exists')) +{ + function link_exists($linkname) + { + global $wpdb; + return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$wpdb->escape($linkname).'"'); + } +} + +/** + The Main Importer Class +**/ +class Textpattern_Import { + + function header() + { + echo '
'; + echo '

'.__('Import Textpattern').'

'; + echo '

'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'

'; + } + + function footer() + { + echo '
'; + } + + function greet() + { + echo '

'.__('Howdy! This importer allows you to extract posts from any Textpattern 4.0.2+ into your blog. This has not been tested on previous versions of Textpattern. Mileage may vary.').'

'; + echo '

'.__('Your Textpattern Configuration settings are as follows:').'

'; + echo '
'; + $this->db_form(); + echo ''; + echo '
'; + } + + function get_txp_cats() + { + global $wpdb; + // General Housekeeping + $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); + set_magic_quotes_runtime(0); + $prefix = get_option('tpre'); + + // Get Categories + return $txpdb->get_results('SELECT + id, + name, + title + FROM '.$prefix.'txp_category + WHERE type = "article"', + ARRAY_A); + } + + function get_txp_users() + { + global $wpdb; + // General Housekeeping + $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); + set_magic_quotes_runtime(0); + $prefix = get_option('tpre'); + + // Get Users + + return $txpdb->get_results('SELECT + user_id, + name, + RealName, + email, + privs + FROM '.$prefix.'txp_users', ARRAY_A); + } + + function get_txp_posts() + { + // General Housekeeping + $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); + set_magic_quotes_runtime(0); + $prefix = get_option('tpre'); + + // Get Posts + return $txpdb->get_results('SELECT + ID, + Posted, + AuthorID, + LastMod, + Title, + Body, + Excerpt, + Category1, + Category2, + Status, + Keywords, + url_title, + comments_count + FROM '.$prefix.'textpattern + ', ARRAY_A); + } + + function get_txp_comments() + { + global $wpdb; + // General Housekeeping + $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); + set_magic_quotes_runtime(0); + $prefix = get_option('tpre'); + + // Get Comments + return $txpdb->get_results('SELECT * FROM '.$prefix.'txp_discuss', ARRAY_A); + } + + function get_txp_links() + { + //General Housekeeping + $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); + set_magic_quotes_runtime(0); + $prefix = get_option('tpre'); + + return $txpdb->get_results('SELECT + id, + date, + category, + url, + linkname, + description + FROM '.$prefix.'txp_link', + ARRAY_A); + } + + function cat2wp($categories='') + { + // General Housekeeping + global $wpdb; + $count = 0; + $txpcat2wpcat = array(); + // Do the Magic + if(is_array($categories)) + { + echo '

'.__('Importing Categories...').'

'; + foreach ($categories as $category) + { + $count++; + extract($category); + + + // Make Nice Variables + $name = $wpdb->escape($name); + $title = $wpdb->escape($title); + + if($cinfo = category_exists($name)) + { + $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title)); + } + else + { + $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title)); + } + $txpcat2wpcat[$id] = $ret_id; + } + + // Store category translation for future use + add_option('txpcat2wpcat',$txpcat2wpcat); + echo '

'.sprintf(__('Done! %1$s categories imported.'), $count).'

'; + return true; + } + echo __('No Categories to Import!'); + return false; + } + + function users2wp($users='') + { + // General Housekeeping + global $wpdb; + $count = 0; + $txpid2wpid = array(); + + // Midnight Mojo + if(is_array($users)) + { + echo '

'.__('Importing Users...').'

'; + foreach($users as $user) + { + $count++; + extract($user); + + // Make Nice Variables + $name = $wpdb->escape($name); + $RealName = $wpdb->escape($RealName); + + if($uinfo = get_userdatabylogin($name)) + { + + $ret_id = wp_insert_user(array( + 'ID' => $uinfo->ID, + 'user_login' => $name, + 'user_nicename' => $RealName, + 'user_email' => $email, + 'user_url' => 'http://', + 'display_name' => $name) + ); + } + else + { + $ret_id = wp_insert_user(array( + 'user_login' => $name, + 'user_nicename' => $RealName, + 'user_email' => $email, + 'user_url' => 'http://', + 'display_name' => $name) + ); + } + $txpid2wpid[$user_id] = $ret_id; + + // Set Textpattern-to-WordPress permissions translation + $transperms = array(1 => '10', 2 => '9', 3 => '5', 4 => '4', 5 => '3', 6 => '2', 7 => '0'); + + // Update Usermeta Data + $user = new WP_User($ret_id); + if('10' == $transperms[$privs]) { $user->set_role('administrator'); } + if('9' == $transperms[$privs]) { $user->set_role('editor'); } + if('5' == $transperms[$privs]) { $user->set_role('editor'); } + if('4' == $transperms[$privs]) { $user->set_role('author'); } + if('3' == $transperms[$privs]) { $user->set_role('contributor'); } + if('2' == $transperms[$privs]) { $user->set_role('contributor'); } + if('0' == $transperms[$privs]) { $user->set_role('subscriber'); } + + update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] ); + update_usermeta( $ret_id, 'rich_editing', 'false'); + }// End foreach($users as $user) + + // Store id translation array for future use + add_option('txpid2wpid',$txpid2wpid); + + + echo '

'.sprintf(__('Done! %1$s users imported.'), $count).'

'; + return true; + }// End if(is_array($users) + + echo __('No Users to Import!'); + return false; + + }// End function user2wp() + + function posts2wp($posts='') + { + // General Housekeeping + global $wpdb; + $count = 0; + $txpposts2wpposts = array(); + $cats = array(); + + // Do the Magic + if(is_array($posts)) + { + echo '

'.__('Importing Posts...').'

'; + foreach($posts as $post) + { + $count++; + extract($post); + + // Set Textpattern-to-WordPress status translation + $stattrans = array(1 => 'draft', 2 => 'private', 3 => 'draft', 4 => 'publish', 5 => 'publish'); + + //Can we do this more efficiently? + $uinfo = ( get_userdatabylogin( $AuthorID ) ) ? get_userdatabylogin( $AuthorID ) : 1; + $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ; + + $Title = $wpdb->escape($Title); + $Body = $wpdb->escape($Body); + $Excerpt = $wpdb->escape($Excerpt); + $post_status = $stattrans[$Status]; + + // Import Post data into WordPress + + if($pinfo = post_exists($Title,$Body)) + { + $ret_id = wp_insert_post(array( + 'ID' => $pinfo, + 'post_date' => $Posted, + 'post_date_gmt' => $post_date_gmt, + 'post_author' => $authorid, + 'post_modified' => $LastMod, + 'post_modified_gmt' => $post_modified_gmt, + 'post_title' => $Title, + 'post_content' => $Body, + 'post_excerpt' => $Excerpt, + 'post_status' => $post_status, + 'post_name' => $url_title, + 'comment_count' => $comments_count) + ); + } + else + { + $ret_id = wp_insert_post(array( + 'post_date' => $Posted, + 'post_date_gmt' => $post_date_gmt, + 'post_author' => $authorid, + 'post_modified' => $LastMod, + 'post_modified_gmt' => $post_modified_gmt, + 'post_title' => $Title, + 'post_content' => $Body, + 'post_excerpt' => $Excerpt, + 'post_status' => $post_status, + 'post_name' => $url_title, + 'comment_count' => $comments_count) + ); + } + $txpposts2wpposts[$ID] = $ret_id; + + // Make Post-to-Category associations + $cats = array(); + if($cat1 = get_catbynicename($Category1)) { $cats[1] = $cat1; } + if($cat2 = get_catbynicename($Category2)) { $cats[2] = $cat2; } + + if(!empty($cats)) { wp_set_post_cats('', $ret_id, $cats); } + } + } + // Store ID translation for later use + add_option('txpposts2wpposts',$txpposts2wpposts); + + echo '

'.sprintf(__('Done! %1$s posts imported.'), $count).'

'; + return true; + } + + function comments2wp($comments='') + { + // General Housekeeping + global $wpdb; + $count = 0; + $txpcm2wpcm = array(); + $postarr = get_option('txpposts2wpposts'); + + // Magic Mojo + if(is_array($comments)) + { + echo '

'.__('Importing Comments...').'

'; + foreach($comments as $comment) + { + $count++; + extract($comment); + + // WordPressify Data + $comment_ID = ltrim($discussid, '0'); + $comment_post_ID = $postarr[$parentid]; + $comment_approved = (1 == $visible) ? 1 : 0; + $name = $wpdb->escape($name); + $email = $wpdb->escape($email); + $web = $wpdb->escape($web); + $message = $wpdb->escape($message); + + if($cinfo = comment_exists($name, $posted)) + { + // Update comments + $ret_id = wp_update_comment(array( + 'comment_ID' => $cinfo, + 'comment_post_ID' => $comment_post_ID, + 'comment_author' => $name, + 'comment_author_email' => $email, + 'comment_author_url' => $web, + 'comment_date' => $posted, + 'comment_content' => $message, + 'comment_approved' => $comment_approved) + ); + } + else + { + // Insert comments + $ret_id = wp_insert_comment(array( + 'comment_post_ID' => $comment_post_ID, + 'comment_author' => $name, + 'comment_author_email' => $email, + 'comment_author_url' => $web, + 'comment_author_IP' => $ip, + 'comment_date' => $posted, + 'comment_content' => $message, + 'comment_approved' => $comment_approved) + ); + } + $txpcm2wpcm[$comment_ID] = $ret_id; + } + // Store Comment ID translation for future use + add_option('txpcm2wpcm', $txpcm2wpcm); + + // Associate newly formed categories with posts + get_comment_count($ret_id); + + + echo '

'.sprintf(__('Done! %1$s comments imported.'), $count).'

'; + return true; + } + echo __('No Comments to Import!'); + return false; + } + + function links2wp($links='') + { + // General Housekeeping + global $wpdb; + $count = 0; + + // Deal with the links + if(is_array($links)) + { + echo '

'.__('Importing Links...').'

'; + foreach($links as $link) + { + $count++; + extract($link); + + // Make nice vars + $category = $wpdb->escape($category); + $linkname = $wpdb->escape($linkname); + $description = $wpdb->escape($description); + + if($linfo = link_exists($linkname)) + { + $ret_id = wp_insert_link(array( + 'link_id' => $linfo, + 'link_url' => $url, + 'link_name' => $linkname, + 'link_category' => $category, + 'link_description' => $description, + 'link_updated' => $date) + ); + } + else + { + $ret_id = wp_insert_link(array( + 'link_url' => $url, + 'link_name' => $linkname, + 'link_category' => $category, + 'link_description' => $description, + 'link_updated' => $date) + ); + } + $txplinks2wplinks[$link_id] = $ret_id; + } + add_option('txplinks2wplinks',$txplinks2wplinks); + echo '

'; + printf(__('Done! %s Links imported'), $count); + echo '

'; + return true; + } + echo __('No Links to Import!'); + return false; + } + + function import_categories() + { + // Category Import + $cats = $this->get_txp_cats(); + $this->cat2wp($cats); + add_option('txp_cats', $cats); + + + + echo '
'; + printf('', __('Import Users')); + echo '
'; + + } + + function import_users() + { + // User Import + $users = $this->get_txp_users(); + $this->users2wp($users); + + echo '
'; + printf('', __('Import Posts')); + echo '
'; + } + + function import_posts() + { + // Post Import + $posts = $this->get_txp_posts(); + $this->posts2wp($posts); + + echo '
'; + printf('', __('Import Comments')); + echo '
'; + } + + function import_comments() + { + // Comment Import + $comments = $this->get_txp_comments(); + $this->comments2wp($comments); + + echo '
'; + printf('', __('Import Links')); + echo '
'; + } + + function import_links() + { + //Link Import + $links = $this->get_txp_links(); + $this->links2wp($links); + add_option('txp_links', $links); + + echo '
'; + printf('', __('Finish')); + echo '
'; + } + + function cleanup_txpimport() + { + delete_option('tpre'); + delete_option('txp_cats'); + delete_option('txpid2wpid'); + delete_option('txpcat2wpcat'); + delete_option('txpposts2wpposts'); + delete_option('txpcm2wpcm'); + delete_option('txplinks2wplinks'); + delete_option('txpuser'); + delete_option('txppass'); + delete_option('txpname'); + delete_option('txphost'); + $this->tips(); + } + + function tips() + { + echo '

'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Textpattern, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.').'

'; + echo '

'.__('Users').'

'; + echo '

'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in Textpattern, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. Every user has the same username, but their passwords are reset to password123. So Login and change it.'), '/wp-login.php').'

'; + echo '

'.__('Preserving Authors').'

'; + echo '

'.__('Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'

'; + echo '

'.__('Textile').'

'; + echo '

'.__('Also, since you\'re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing Textile for WordPress. Trust me... You\'ll want it.').'

'; + echo '

'.__('WordPress Resources').'

'; + echo '

'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'

'; + echo ''; + echo '

'.sprintf(__('That\'s it! What are you waiting for? Go login!'), '/wp-login.php').'

'; + } + + function db_form() + { + echo '
    '; + printf('
  • ', __('Textpattern Database User:')); + printf('
  • ', __('Textpattern Database Password:')); + printf('
  • ', __('Textpattern Database Name:')); + printf('
  • ', __('Textpattern Database Host:')); + printf('
  • ', __('Textpattern Table prefix (if any):')); + echo '
'; + } + + function dispatch() + { + + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + $this->header(); + + if ( $step > 0 ) + { + if($_POST['dbuser']) + { + if(get_option('txpuser')) + delete_option('txpuser'); + add_option('txpuser',$_POST['dbuser']); + } + if($_POST['dbpass']) + { + if(get_option('txppass')) + delete_option('txppass'); + add_option('txppass',$_POST['dbpass']); + } + + if($_POST['dbname']) + { + if(get_option('txpname')) + delete_option('txpname'); + add_option('txpname',$_POST['dbname']); + } + if($_POST['dbhost']) + { + if(get_option('txphost')) + delete_option('txphost'); + add_option('txphost',$_POST['dbhost']); + } + if($_POST['dbprefix']) + { + if(get_option('tpre')) + delete_option('tpre'); + add_option('tpre',$_POST['dbprefix']); + } + + + } + + switch ($step) + { + default: + case 0 : + $this->greet(); + break; + case 1 : + $this->import_categories(); + break; + case 2 : + $this->import_users(); + break; + case 3 : + $this->import_posts(); + break; + case 4 : + $this->import_comments(); + break; + case 5 : + $this->import_links(); + break; + case 6 : + $this->cleanup_txpimport(); + break; + } + + $this->footer(); + } + + function Textpattern_Import() + { + // Nothing. + } +} + +$txp_import = new Textpattern_Import(); +register_importer('textpattern', 'Textpattern', __('Import posts from a Textpattern Blog'), array ($txp_import, 'dispatch')); +?> diff --git a/wp-admin/index.php b/wp-admin/index.php new file mode 100644 index 00000000..f5852a39 --- /dev/null +++ b/wp-admin/index.php @@ -0,0 +1,172 @@ + + +
+ +

+ +
+

+ +items) && 0 != count($rss->items) ) { +?> + + + +get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 5"); +$numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'"); + +if ( $comments || $numcomments ) : +?> +
+

»

+ + +

»

+ +
+ + + + + +get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) : +?> +
+

»

+ +
+ + +get_results("SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt > '$today' ORDER BY post_date ASC") ) : +?> +
+

+
    +post_title == '') + $post->post_title = sprintf(__('Post #%s'), $post->ID); + echo "
  • " . sprintf(__('%1$s in %2$s'), "$post->post_title", human_time_diff( current_time('timestamp', 1), strtotime($post->post_date_gmt. ' GMT') )) . "
  • "; +} +?> +
+
+ + +
+

+get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'"); +if (0 < $numposts) $numposts = number_format($numposts); + +$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); +if (0 < $numcomms) $numcomms = number_format($numcomms); + +$numcats = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories"); +if (0 < $numcats) $numcats = number_format($numcats); +?> +

posts and %3$s comments, contained within %5$s categories.'), $numposts, 'edit.php', $numcomms, 'edit-comments.php', $numcats, 'categories.php'); ?>

+
+ + +
+ +

+ +

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

great documentation or if that doesn't help visit the support forums."); ?>

+items) && 0 != count($rss->items) ) { +?> +

+items = array_slice($rss->items, 0, 3); +foreach ($rss->items as $item ) { +?> +

'>

+

+ + + +items) && 0 != count($rss->items) ) { +?> +
+

»

+
    +items = array_slice($rss->items, 0, 20); +foreach ($rss->items as $item ) { +?> +
  • '>
  • + +
+
+ +
  +
+
+
+ + diff --git a/wp-admin/inline-uploading.php b/wp-admin/inline-uploading.php new file mode 100644 index 00000000..c2334cd9 --- /dev/null +++ b/wp-admin/inline-uploading.php @@ -0,0 +1,715 @@ +".__('Go back').''); + +wp_delete_attachment($attachment); + +header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&start=$start"); +die; + +case 'save': + +$overrides = array('action'=>'save'); + +$file = wp_handle_upload($_FILES['image'], $overrides); + +if ( isset($file['error']) ) + die($file['error'] . '
'.__('Back to Image Uploading').''); + +$url = $file['url']; +$type = $file['type']; +$file = $file['file']; +$filename = basename($file); + +// Construct the attachment array +$attachment = array( + 'post_title' => $imgtitle ? $imgtitle : $filename, + 'post_content' => $descr, + 'post_status' => 'attachment', + 'post_parent' => $post, + 'post_mime_type' => $type, + 'guid' => $url + ); + +// Save the data +$id = wp_insert_attachment($attachment, $file, $post); + +if ( preg_match('!^image/!', $attachment['post_mime_type']) ) { + // Generate the attachment's postmeta. + $imagesize = getimagesize($file); + $imagedata['width'] = $imagesize['0']; + $imagedata['height'] = $imagesize['1']; + list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']); + $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'"; + $imagedata['file'] = $file; + + add_post_meta($id, '_wp_attachment_metadata', $imagedata); + + if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) { + if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 ) + $thumb = wp_create_thumbnail($file, 128); + elseif ( $imagedata['height'] > 96 ) + $thumb = wp_create_thumbnail($file, 96); + + if ( @file_exists($thumb) ) { + $newdata = $imagedata; + $newdata['thumb'] = basename($thumb); + update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata); + } else { + $error = $thumb; + } + } +} else { + add_post_meta($id, '_wp_attachment_metadata', array()); +} + +header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&start=0"); +die(); + +case 'upload': + +$current_1 = ' class="current"'; +$back = $next = false; +break; + +case 'view': + +// How many images do we show? How many do we query? +$num = 5; +$double = $num * 2; + +if ( $post && (empty($all) || $all == 'false') ) { + $and_post = "AND post_parent = '$post'"; + $current_2 = ' class="current"'; +} else { + $current_3 = ' class="current"'; +} + +if (! current_user_can('edit_others_posts') ) + $and_user = "AND post_author = " . $user_ID; + +if ( $last ) + $start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment' $and_user $and_post") - $num; +else + $start = (int) $start; + +if ( $start < 0 ) + $start = 0; + +if ( '' == $sort ) + $sort = "post_date_gmt DESC"; + +$attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_status = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A); + +if ( count($attachments) == 0 ) { + header("Location: ".basename(__FILE__)."?post=$post&action=upload"); + die; +} elseif ( count($attachments) > $num ) { + $next = $start + count($attachments) - $num; +} else { + $next = false; +} + +if ( $start > 0 ) { + $back = $start - $num; + if ( $back < 1 ) + $back = '0'; +} else { + $back = false; +} + +$uwidth_sum = 0; +$html = ''; +$popups = ''; +$style = ''; +$script = ''; +if ( count($attachments) > 0 ) { + $attachments = array_slice( $attachments, 0, $num ); + $__delete = __('Delete'); + $__not_linked = __('Not Linked'); + $__linked_to_page = __('Linked to Page'); + $__linked_to_image = __('Linked to Image'); + $__linked_to_file = __('Linked to File'); + $__using_thumbnail = __('Using Thumbnail'); + $__using_original = __('Using Original'); + $__using_title = __('Using Title'); + $__using_filename = __('Using Filename'); + $__using_icon = __('Using Icon'); + $__no_thumbnail = ''.__('No Thumbnail').''; + $__send_to_editor = __('Send to editor'); + $__close = __('Close Options'); + $__confirmdelete = __('Delete this file from the server?'); + $__nothumb = __('There is no thumbnail associated with this photo.'); + $script .= "notlinked = '$__not_linked'; +linkedtoimage = '$__linked_to_image'; +linkedtopage = '$__linked_to_page'; +linkedtofile = '$__linked_to_file'; +usingthumbnail = '$__using_thumbnail'; +usingoriginal = '$__using_original'; +usingtitle = '$__using_title'; +usingfilename = '$__using_filename'; +usingicon = '$__using_icon'; +var aa = new Array(); +var ab = new Array(); +var imga = new Array(); +var imgb = new Array(); +var srca = new Array(); +var srcb = new Array(); +var title = new Array(); +var filename = new Array(); +var icon = new Array(); +"; + foreach ( $attachments as $key => $attachment ) { + $ID = $attachment['ID']; + $href = get_attachment_link($ID); + $meta = get_post_meta($ID, '_wp_attachment_metadata', true); + if (!is_array($meta)) { + $meta = get_post_meta($ID, 'imagedata', true); // Try 1.6 Alpha meta key + if (!is_array($meta)) { + $meta = array(); + } + add_post_meta($ID, '_wp_attachment_metadata', $meta); + } + $attachment = array_merge($attachment, $meta); + $noscript = " +"; + $send_delete_cancel = "$__send_to_editor +$__delete + $__close +"; + $uwidth_sum += 128; + if ( preg_match('!^image/!', $attachment['post_mime_type'] ) ) { + $image = & $attachment; + if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) { + $src = str_replace(basename($image['guid']), $image['thumb'], $image['guid']); + $script .= "srca[{$ID}] = '$src'; +srcb[{$ID}] = '{$image['guid']}'; +"; + $thumb = 'true'; + $thumbtext = $__using_thumbnail; + } else { + $src = $image['guid']; + $thumb = 'false'; + $thumbtext = $__no_thumbnail; + } + list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']); + $height_width = 'height="'.$image['uheight'].'" width="'.$image['uwidth'].'"'; + $xpadding = (128 - $image['uwidth']) / 2; + $ypadding = (96 - $image['uheight']) / 2; + $style .= "#target{$ID} img { padding: {$ypadding}px {$xpadding}px; }\n"; + $title = htmlentities($image['post_title'], ENT_QUOTES); + $script .= "aa[{$ID}] = ''; +ab[{$ID}] = ''; +imga[{$ID}] = '\"{$title}\"'; +imgb[{$ID}] = '\"{$title}\"'; +"; + $html .= "
+
+ \"{$title}\" +
+ {$noscript} +
+"; + $popups .= "
+"; + } else { + $title = htmlentities($attachment['post_title'], ENT_QUOTES); + $filename = basename($attachment['guid']); + $icon = get_attachment_icon($ID); + $toggle_icon = "$__using_title"; + $script .= "aa[{$ID}] = ''; +ab[{$ID}] = ''; +title[{$ID}] = '{$title}'; +filename[{$ID}] = '{$filename}'; +icon[{$ID}] = '{$icon}'; +"; + $html .= "
+ + {$noscript} +
+"; + $popups .= " +"; + } + } +} + +$images_width = $uwidth_sum + ( count($images) * 6 ) + 35; + +break; + +default: +die(__('This script was not meant to be called directly.')); +} + +?> + + + + + + + + + +
    +> +get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post'") ) { ?> +> + +get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment'")) { ?> +> + +
  • + + +
  • +
  • «
  • + +
  • +
  • «
  • + + +
  • »
  • +
  • »|
  • + +
  • »
  • +
  • »|
  • + + +
+ +
+ +
+ + +
+
+ +
+
+ + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+
+ +
+ + + + + diff --git a/wp-admin/install-helper.php b/wp-admin/install-helper.php new file mode 100644 index 00000000..86138db1 --- /dev/null +++ b/wp-admin/install-helper.php @@ -0,0 +1,152 @@ +get_col("SHOW TABLES",0) as $table ) { + if ($table == $table_name) { + return true; + } + } + //didn't find it try to create it. + $q = $wpdb->query($create_ddl); + // we cannot directly tell that whether this succeeded! + foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { + if ($table == $table_name) { + return true; + } + } + return false; +} + +/** + ** maybe_add_column() + ** Add column to db table if it doesn't exist. + ** Returns: true if already exists or on successful completion + ** false on error + */ +function maybe_add_column($table_name, $column_name, $create_ddl) { + global $wpdb, $debug; + foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { + if ($debug) echo("checking $column == $column_name
"); + if ($column == $column_name) { + return true; + } + } + //didn't find it try to create it. + $q = $wpdb->query($create_ddl); + // we cannot directly tell that whether this succeeded! + foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { + if ($column == $column_name) { + return true; + } + } + return false; +} + + +/** + ** maybe_drop_column() + ** Drop column from db table if it exists. + ** Returns: true if it doesn't already exist or on successful drop + ** false on error + */ +function maybe_drop_column($table_name, $column_name, $drop_ddl) { + global $wpdb; + foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { + if ($column == $column_name) { + //found it try to drop it. + $q = $wpdb->query($drop_ddl); + // we cannot directly tell that whether this succeeded! + foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { + if ($column == $column_name) { + return false; + } + } + } + } + // else didn't find it + return true; +} + + +/** + ** check_column() + ** Check column matches passed in criteria. + ** Pass in null to skip checking that criteria + ** Returns: true if it matches + ** false otherwise + ** (case sensitive) Column names returned from DESC table are: + ** Field + ** Type + ** Null + ** Key + ** Default + ** Extra + */ +function check_column($table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null) { + global $wpdb, $debug; + $diffs = 0; + $results = $wpdb->get_results("DESC $table_name"); + + foreach ($results as $row ) { + if ($debug > 1) print_r($row); + if ($row->Field == $col_name) { + // got our column, check the params + if ($debug) echo ("checking $row->Type against $col_type\n"); + if (($col_type != null) && ($row->Type != $col_type)) { + ++$diffs; + } + if (($is_null != null) && ($row->Null != $is_null)) { + ++$diffs; + } + if (($key != null) && ($row->Key != $key)) { + ++$diffs; + } + if (($default != null) && ($row->Default != $default)) { + ++$diffs; + } + if (($extra != null) && ($row->Extra != $extra)) { + ++$diffs; + } + if ($diffs > 0) { + if ($debug) echo ("diffs = $diffs returning false\n"); + return false; + } + return true; + } // end if found our column + } + return false; +} + +/* +echo "

testing

"; +echo "
";
+
+//check_column('wp_links', 'link_description', 'mediumtext'); 
+//if (check_column($wpdb->comments, 'comment_author', 'tinytext'))
+//    echo "ok\n";
+$error_count = 0;
+$tablename = $wpdb->links;
+// check the column
+if (!check_column($wpdb->links, 'link_description', 'varchar(255)'))
+{
+    $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
+    $q = $wpdb->query($ddl);
+}
+if (check_column($wpdb->links, 'link_description', 'varchar(255)')) {
+    $res .= $tablename . ' - ok 
'; +} else { + $res .= 'There was a problem with ' . $tablename . '
'; + ++$error_count; +} +echo "
"; +*/ +?> \ No newline at end of file diff --git a/wp-admin/install.php b/wp-admin/install.php new file mode 100644 index 00000000..ffa33ce7 --- /dev/null +++ b/wp-admin/install.php @@ -0,0 +1,226 @@ +wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file."); + +require_once('../wp-config.php'); +require_once('./upgrade-functions.php'); + +$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://'; +$guessurl = str_replace('/wp-admin/install.php?step=2', '', $schema . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) ); + +if (isset($_GET['step'])) + $step = $_GET['step']; +else + $step = 0; +header( 'Content-Type: text/html; charset=utf-8' ); +?> + + + + <?php _e('WordPress › Installation'); ?> + + + + +

WordPress

+hide_errors(); +$installed = $wpdb->get_results("SELECT * FROM $wpdb->users"); +if ($installed) die('

'.__('Already Installed').'

'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'

'); +$wpdb->show_errors(); + +switch($step) { + + case 0: +?> +

ReadMe documentation at your leisure.'), '../readme.html'); ?>

+

+ +

+

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

+

+ +

+
+ +ERROR: please type your e-mail address")); +} else if (!is_email($admin_email)) { + die (__("ERROR: the e-mail address isn't correct")); +} + +?> +

+

+ + +query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".$wpdb->escape(__('Blogroll'))."')"); +$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/', '');"); +$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/', '');"); +$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/', '');"); +$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/', '');"); +$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/', '');"); +$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php', '');"); +$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/', '');"); + +// Default category +$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')"); + +// First post +$now = date('Y-m-d H:i:s'); +$now_gmt = gmdate('Y-m-d H:i:s'); +$wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, comment_count, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '1', '', '', '')"); + +$wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" ); + +// Default comment +$wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.
To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')"); + +// First Page + +$wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'static', '', '', '')"); +$wp_rewrite->flush_rules(); + +// Set up admin user +$random_password = substr(md5(uniqid(microtime())), 0, 6); +$display_name_array = explode('@', $admin_email); +$display_name = $display_name_array[0]; +$wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_registered, display_name, user_nicename) VALUES ( '1', 'admin', MD5('$random_password'), '$admin_email', NOW(), '$display_name', 'admin')"); +$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}user_level', '10');"); +$admin_caps = serialize(array('administrator' => true)); +$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}capabilities', '{$admin_caps}');"); + +$message_headers = 'From: ' . $weblog_title . ' '; +$message = sprintf(__("Your new WordPress blog has been successfully set up at: + +%1\$s + +You can log in to the administrator account with the following information: + +Username: admin +Password: %2\$s + +We hope you enjoy your new weblog. Thanks! + +--The WordPress Team +http://wordpress.org/ +"), $guessurl, $random_password); + +@wp_mail($admin_email, __('New WordPress Blog'), $message, $message_headers); + +wp_cache_flush(); +?> + +

+ +

log in with the username "admin" and password "%2$s".'), '../wp-login.php', $random_password); ?>

+

Note that password carefully! It is a random password that was generated just for you. If you lose it, you will have to delete the tables from the database yourself, and re-install WordPress. So to review:'); ?> +

+
+
+
admin
+
+
+
+
wp-login.php
+
+

+ + + + diff --git a/wp-admin/link-add.php b/wp-admin/link-add.php new file mode 100644 index 00000000..8a6553a2 --- /dev/null +++ b/wp-admin/link-add.php @@ -0,0 +1,47 @@ + + + +

+ + + + +
+You can drag Link This to your toolbar and when you click it a window will pop up that will allow you to add whatever site you’re on to your links! Right now this only works on Mozilla or Netscape, but we’re working on it.

'), "javascript:void(linkmanpopup=window.open('" . get_settings('siteurl') . "/wp-admin/link-add.php?action=popup&linkurl='+escape(location.href)+'&name='+escape(document.title),'LinkManager','scrollbars=yes,width=750,height=550,left=15,top=15,status=yes,resizable=yes'));linkmanpopup.focus();window.focus();linkmanpopup.focus();") ?> +
+ + diff --git a/wp-admin/link-categories.php b/wp-admin/link-categories.php new file mode 100644 index 00000000..10fb2277 --- /dev/null +++ b/wp-admin/link-categories.php @@ -0,0 +1,455 @@ +query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name, auto_toggle, show_images, show_description, \n" . + " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, text_after_all, list_limit) \n" . + " VALUES ('0', '$cat_name', '$auto_toggle', '$show_images', '$show_description', \n" . + " '$show_rating', '$show_updated', '$sort_order', '$sort_desc', '$text_before_link', '$text_after_link', \n" . + " '$text_after_all', $list_limit)"); + + header('Location: link-categories.php'); + break; + } // end addcat + case 'Delete': + { + $cat_id = (int) $_GET['cat_id']; + $cat_name=get_linkcatname($cat_id); + + if ($cat_id=="1") + die(sprintf(__("Can't delete the %s link category: this is the default one"), $cat_name)); + + if ( !current_user_can('manage_links') ) + die (__("Cheatin' uh ?")); + + $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$cat_id'"); + $wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$cat_id'"); + + header('Location: link-categories.php'); + break; + } // end delete + case 'Edit': + { + include_once ('admin-header.php'); + $cat_id = (int) $_GET['cat_id']; + $row = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, " + . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, " + . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$cat_id"); + if ($row) { + if ($row->list_limit == -1) { + $row->list_limit = ''; + } +?> + +
+

cat_name)); ?>

+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+ + title regardless)') ?>
+
+ +title regardless)') ?>
+ + +
+ + +
+
+
+ + + + + + + + + + + + + + +
+
+

+
+ +
+query("UPDATE $wpdb->linkcategories set + cat_name='$cat_name', + auto_toggle='$auto_toggle', + show_images='$show_images', + show_description='$show_description', + show_rating='$show_rating', + show_updated='$show_updated', + sort_order='$sort_order', + sort_desc='$sort_desc', + text_before_link='$text_before_link', + text_after_link='$text_after_link', + text_after_all='$text_after_all', + list_limit=$list_limit + WHERE cat_id=$cat_id + "); + } // end if save + + + header("Location: link-categories.php"); + break; + } // end editcat + default: + { + include_once ("admin-header.php"); + if ( !current_user_can('manage_links') ) + die(__("You have do not have sufficient permissions to edit the link categories for this blog. :)")); +?> + +
+

+ + + + + + + + + + + + + + + + + + + + + +get_results("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, " + . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, " + . " text_after_all, list_limit FROM $wpdb->linkcategories ORDER BY cat_id"); +$i = 1; +foreach ($results as $row) { + if ($row->list_limit == -1) { + $row->list_limit = __('none'); + } + $style = ($i % 2) ? ' class="alternate"' : ''; + /* + Manually internationalize every sort order option. + */ + switch ($row->sort_order) { + case 'name': + $row->sort_order = __('name'); + break; + case 'id': + $row->sort_order = __('id'); + break; + case 'url': + $row->sort_order = __('url'); + break; + case 'rating': + $row->sort_order = __('rating'); + break; + case 'updated': + $row->sort_order = __('updated'); + break; + case 'rand': + $row->sort_order = __('rand'); + break; + case 'length': + $row->sort_order = __('length'); + break; + } +?> + style="border-bottom: 1px dotted #9C9A9C;"> + + + + + + + + + + + + + + + + + +
 
+

+ +
+ +
+ +
+
+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+ + title regardless)') ?>
+
+ +title regardless)') ?>
+ + +
+ +
+
+
+ + + + + + + + + + + + + + +
+
+

+
+
+
+

+

It will just set them back to the default category %s.'), get_linkcatname(1)) ?>

+
+ + diff --git a/wp-admin/link-import.php b/wp-admin/link-import.php new file mode 100644 index 00000000..713686b3 --- /dev/null +++ b/wp-admin/link-import.php @@ -0,0 +1,132 @@ + + + +
+

+
+ +

+

+ + +
+

+ +
+ +
+

+ +
+ + +
+ +


+

+ +

+
+ +
+ +
+ +

+ false, 'test_type' => false); + $file = wp_handle_upload($_FILES['userfile'], $overrides); + + if ( isset($file['error']) ) + die($file['error']); + + $url = $file['url']; + $opml_url = $file['file']; + $blogrolling = false; + } + + if (isset($opml_url) && $opml_url != '') { + $opml = wp_remote_fopen($opml_url); + include_once('link-parse-opml.php'); + + $link_count = count($names); + for ($i = 0; $i < $link_count; $i++) { + if ('Last' == substr($titles[$i], 0, 4)) + $titles[$i] = ''; + if ('http' == substr($titles[$i], 0, 4)) + $titles[$i] = ''; + // FIXME: Use wp_insert_link(). + $query = "INSERT INTO $wpdb->links (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss) + VALUES('{$urls[$i]}', '".$wpdb->escape($names[$i])."', '', $cat_id, '".$wpdb->escape($descriptions[$i])."', $user_ID, '{$feeds[$i]}')\n"; + $result = $wpdb->query($query); + echo sprintf('

'.__('Inserted %s').'

', $names[$i]); + } +?> +

manage those links.'), $link_count, $cat_id, 'link-manager.php') ?>

+" . __("You need to supply your OPML url. Press back on your browser and try again") . "

\n"; + } // end else + + if ( ! $blogrolling ) + @unlink($opml_url); +?> +
+ diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php new file mode 100644 index 00000000..5626570f --- /dev/null +++ b/wp-admin/link-manager.php @@ -0,0 +1,445 @@ += the + //userlevel of the owner of the link then we can proceed. + + if (count($linkcheck) == 0) { + header('Location: ' . $this_file); + exit; + } + $all_links = join(',', $linkcheck); + $results = $wpdb->get_results("SELECT link_id, link_owner FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)"); + foreach ($results as $row) { + $ids_to_change[] = $row->link_id; + } + + // should now have an array of links we can change + $all_links = join(',', $ids_to_change); + $q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)"); + + header('Location: ' . $this_file); + break; + } + case 'visibility': + { + check_admin_referer(); + + // check the current user's level first. + if ( !current_user_can('manage_links') ) + die (__("Cheatin' uh ?")); + + //for each link id (in $linkcheck[]): toggle the visibility + if (count($linkcheck) == 0) { + header('Location: ' . $this_file); + exit; + } + $all_links = join(',', $linkcheck); + $results = $wpdb->get_results("SELECT link_id, link_visible FROM $wpdb->links WHERE link_id in ($all_links)"); + foreach ($results as $row) { + if ($row->link_visible == 'Y') { // ok to proceed + $ids_to_turnoff[] = $row->link_id; + } else { + $ids_to_turnon[] = $row->link_id; + } + } + + // should now have two arrays of links to change + if (count($ids_to_turnoff)) { + $all_linksoff = join(',', $ids_to_turnoff); + $q = $wpdb->query("update $wpdb->links SET link_visible='N' WHERE link_id IN ($all_linksoff)"); + } + + if (count($ids_to_turnon)) { + $all_linkson = join(',', $ids_to_turnon); + $q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)"); + } + + header('Location: ' . $this_file); + break; + } + case 'move': + { + check_admin_referer(); + + // check the current user's level first. + if ( !current_user_can('manage_links') ) + die (__("Cheatin' uh ?")); + + //for each link id (in $linkcheck[]) change category to selected value + if (count($linkcheck) == 0) { + header('Location: ' . $this_file); + exit; + } + $all_links = join(',', $linkcheck); + // should now have an array of links we can change + $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)"); + + header('Location: ' . $this_file); + break; + } + + case 'Add': + { + check_admin_referer(); + + add_link(); + + header('Location: ' . $_SERVER['HTTP_REFERER'] . '?added=true'); + break; + } // end Add + + case 'editlink': + { + + check_admin_referer(); + + if (isset($links_show_cat_id) && ($links_show_cat_id != '')) + $cat_id = $links_show_cat_id; + + if (!isset($cat_id) || ($cat_id == '')) { + if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) + $cat_id = 'All'; + } + $links_show_cat_id = $cat_id; + + $link_id = (int) $_POST['link_id']; + edit_link($link_id); + + setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); + wp_redirect($this_file); + break; + } // end Save + + case 'Delete': + { + check_admin_referer(); + + if ( !current_user_can('manage_links') ) + die (__("Cheatin' uh ?")); + + $link_id = (int) $_GET['link_id']; + + wp_delete_link($link_id); + + if (isset($links_show_cat_id) && ($links_show_cat_id != '')) + $cat_id = $links_show_cat_id; + + if (!isset($cat_id) || ($cat_id == '')) { + if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) + $cat_id = 'All'; + } + $links_show_cat_id = $cat_id; + setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); + wp_redirect($this_file); + break; + } // end Delete + + case 'linkedit': { + $xfn_js = true; + include_once ('admin-header.php'); + if ( !current_user_can('manage_links') ) + die(__('You do not have sufficient permissions to edit the links for this blog.')); + + $link_id = (int) $_GET['link_id']; + + if ( !$link = get_link_to_edit($link_id) ) + die( __('Link not found.') ); + + include('edit-link-form.php'); + break; + } // end linkedit + case __("Show"): + { + if (!isset($cat_id) || ($cat_id == '')) { + if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) + $cat_id = 'All'; + } + $links_show_cat_id = $cat_id; + if (!isset($order_by) || ($order_by == '')) { + if (!isset($links_show_order) || ($links_show_order == '')) + $order_by = 'order_name'; + } + $links_show_order = $order_by; + //break; fall through + } // end Show + case "popup": + { + $link_url = stripslashes($_GET["linkurl"]); + $link_name = stripslashes($_GET["name"]); + //break; fall through + } + default: + { + if (isset($links_show_cat_id) && ($links_show_cat_id != '')) + $cat_id = $links_show_cat_id; + + if (!isset($cat_id) || ($cat_id == '')) { + if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) + $cat_id = 'All'; + } + $links_show_cat_id = $cat_id; + if (isset($links_show_order) && ($links_show_order != '')) + $order_by = $links_show_order; + + if (!isset($order_by) || ($order_by == '')) + $order_by = 'order_name'; + $links_show_order = $order_by; + + setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); + setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600); + include_once ("./admin-header.php"); + if ( !current_user_can('manage_links') ) + die(__("You do not have sufficient permissions to edit the links for this blog.")); + + switch ($order_by) + { + case 'order_id': $sqlorderby = 'id'; break; + case 'order_url': $sqlorderby = 'url'; break; + case 'order_desc': $sqlorderby = 'description'; break; + case 'order_owner': $sqlorderby = 'owner'; break; + case 'order_rating': $sqlorderby = 'rating'; break; + case 'order_name': + default: $sqlorderby = 'name'; break; + } + + if ($action != "popup") { +?> + + +
+
+ + + + + + + + + + + +
+ Show links in category:'); ?>
+
+ Order by:');?> +  
+get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); + echo " \n"; +?> + + + + +
+
+ +
+ + + + + + + diff --git a/wp-admin/link-parse-opml.php b/wp-admin/link-parse-opml.php new file mode 100644 index 00000000..196f3cb0 --- /dev/null +++ b/wp-admin/link-parse-opml.php @@ -0,0 +1,65 @@ + 'link_url', + 'HTMLURL' => 'link_url', + 'TEXT' => 'link_name', + 'TITLE' => 'link_name', + 'TARGET' => 'link_target', + 'DESCRIPTION' => 'link_description', + 'XMLURL' => 'link_rss' +); + +$map = $opml_map; + +/** + ** startElement() + ** Callback function. Called at the start of a new xml tag. + **/ +function startElement($parser, $tagName, $attrs) { + global $updated_timestamp, $all_links, $map; + global $names, $urls, $targets, $descriptions, $feeds; + + if ($tagName == 'OUTLINE') { + foreach (array_keys($map) as $key) { + if (isset($attrs[$key])) { + $$map[$key] = $attrs[$key]; + } + } + + //echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]
\n"); + + // save the data away. + $names[] = $link_name; + $urls[] = $link_url; + $targets[] = $link_target; + $feeds[] = $link_rss; + $descriptions[] = $link_description; + } // end if outline +} + +/** + ** endElement() + ** Callback function. Called at the end of an xml tag. + **/ +function endElement($parser, $tagName) { + // nothing to do. +} + +// Create an XML parser +$xml_parser = xml_parser_create(); + +// Set the functions to handle opening and closing tags +xml_set_element_handler($xml_parser, "startElement", "endElement"); + +if (!xml_parse($xml_parser, $opml, true)) { + echo(sprintf(__('XML error: %1$s at line %2$s'), + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser))); +} + +// Free up memory used by the XML parser +xml_parser_free($xml_parser); +?> diff --git a/wp-admin/list-manipulation.js b/wp-admin/list-manipulation.js new file mode 100644 index 00000000..38cc6024 --- /dev/null +++ b/wp-admin/list-manipulation.js @@ -0,0 +1,96 @@ +var listItems; +var reg_color = '#FFFFFF'; +var alt_color = '#F1F1F1'; + +addLoadEvent(getListItems); + +function deleteSomething( what, id, message ) { + what.replace('-', ' '); + if (!message) message = 'Are you sure you want to delete this ' + what + '?'; + if ( confirm(message) ) { + return ajaxDelete( what.replace(' ', '-'), id ); + } else { + return false; + } +} + +function getResponseElement() { + var p = document.getElementById('ajax-response-p'); + if (!p) { + p = document.createElement('p'); + p.id = 'ajax-response-p'; + document.getElementById('ajax-response').appendChild(p); + return p; + } +} + +function ajaxDelete(what, id) { + ajaxDel = new sack('list-manipulation.php'); + if ( ajaxDel.failed ) return true; + ajaxDel.myResponseElement = getResponseElement(); + ajaxDel.method = 'POST'; + ajaxDel.onLoading = function() { ajaxDel.myResponseElement.innerHTML = 'Sending Data...'; }; + ajaxDel.onLoaded = function() { ajaxDel.myResponseElement.innerHTML = 'Data Sent...'; }; + ajaxDel.onInteractive = function() { ajaxDel.myResponseElement.innerHTML = 'Processing Data...'; }; + ajaxDel.onCompletion = function() { removeThisItem( what + '-' + id ); }; + ajaxDel.runAJAX('action=delete-' + what + '&id=' + id); + return false; +} + +function removeThisItem(id) { + var response = ajaxDel.response; + if ( isNaN(response) ) { alert(response); } + response = parseInt(response, 10); + if ( -1 == response ) { ajaxDel.myResponseElement.innerHTML = "You don't have permission to do that."; } + else if ( 0 == response ) { ajaxDel.myResponseElement.interHTML = "Something odd happened. Try refreshing the page? Either that or what you tried to delete never existed in the first place."; } + else if ( 1 == response ) { + theItem = document.getElementById(id); + Fat.fade_element(id,null,700,'#FF3333'); + setTimeout('theItem.parentNode.removeChild(theItem)', 705); + var pos = getListPos(id); + listItems.splice(pos,1); + recolorList(pos); + ajaxDel.myResponseElement.parentNode.removeChild(ajaxDel.myResponseElement); + + } +} + +function getListPos(id) { + for (var i = 0; i < listItems.length; i++) { + if (id == listItems[i]) { + var pos = i; + break; + } + } + return pos; +} + +function getListItems() { + if (list) return; + listItems = new Array(); + var extra = false; + var list = document.getElementById('the-list'); + if (!list) { var list = document.getElementById('the-list-x'); extra = true; } + if (list) { + var items = list.getElementsByTagName('tr'); + if (!items[0]) { items = list.getElementsByTagName('li'); } + for (var i=0; icomment_post_ID) ) + die('-1'); + + if ( wp_delete_comment($comment->comment_ID) ) { + die('1'); + } else { + die('0'); + } + break; +case 'delete-link-category' : + $id = (int) $_POST['id']; + if ( 1 == $id ) + die('0'); + if ( !current_user_can('manage_links') ) + die('-1'); + + if ( $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$id'") ) { + $wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$id'"); + die('1'); + } else { + die('0'); + } + break; +endswitch; +?> diff --git a/wp-admin/menu-header.php b/wp-admin/menu-header.php new file mode 100644 index 00000000..352e3458 --- /dev/null +++ b/wp-admin/menu-header.php @@ -0,0 +1,61 @@ + + + + + \ No newline at end of file diff --git a/wp-admin/menu.php b/wp-admin/menu.php new file mode 100644 index 00000000..ed58186c --- /dev/null +++ b/wp-admin/menu.php @@ -0,0 +1,64 @@ +get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'"); +$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), $awaiting_mod), 'edit_posts', 'moderation.php'); +$submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php'); + +$submenu['link-manager.php'][5] = array(__('Manage Links'), 'manage_links', 'link-manager.php'); +$submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php'); +$submenu['link-manager.php'][15] = array(__('Link Categories'), 'manage_links', 'link-categories.php'); +$submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php'); + +$submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php'); +$submenu['profile.php'][10] = array(__('Authors & Users'), 'edit_users', 'users.php'); + +$submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php'); +$submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php'); +$submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php'); +$submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php'); +$submenu['options-general.php'][30] = array(__('Permalinks'), 'manage_options', 'options-permalink.php'); +$submenu['options-general.php'][35] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php'); + +$submenu['plugins.php'][5] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); +$submenu['plugins.php'][10] = array(__('Plugin Editor'), 'edit_plugins', 'plugin-editor.php'); + +$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php'); +$submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php'); + +// Create list of page plugin hook names. +foreach ($menu as $menu_page) { + $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]); +} + +do_action('admin_menu', ''); +ksort($menu); // make it all pretty + +if (! user_can_access_admin_page()) { + die( __('You do not have sufficient permissions to access this page.') ); +} + +?> diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php new file mode 100644 index 00000000..48a8b23a --- /dev/null +++ b/wp-admin/moderation.php @@ -0,0 +1,222 @@ + $v) { + $comment[intval($k)] = $v; + } +} + +switch($action) { + +case 'update': + + if ( ! current_user_can('moderate_comments') ) + die('

'.__('Your level is not high enough to moderate comments.').'

'); + + $item_ignored = 0; + $item_deleted = 0; + $item_approved = 0; + $item_spam = 0; + + foreach($comment as $key => $value) { + if ($feelinglucky && 'later' == $value) + $value = 'delete'; + switch($value) { + case 'later': + // do nothing with that comment + // wp_set_comment_status($key, "hold"); + ++$item_ignored; + break; + case 'delete': + wp_set_comment_status($key, 'delete'); + ++$item_deleted; + break; + case 'spam': + wp_set_comment_status($key, 'spam'); + ++$item_spam; + break; + case 'approve': + wp_set_comment_status($key, 'approve'); + if ( get_settings('comments_notify') == true ) { + wp_notify_postauthor($key); + } + ++$item_approved; + break; + } + } + + $file = basename(__FILE__); + header("Location: $file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam"); + exit(); + +break; + +default: + +require_once('admin-header.php'); + +if ( isset($_GET['deleted']) || isset($_GET['approved']) || isset($_GET['ignored']) ) { + echo "
\n

"; + $approved = (int) $_GET['approved']; + $deleted = (int) $_GET['deleted']; + $ignored = (int) $_GET['ignored']; + $spam = (int) $_GET['spam']; + if ($approved) { + if ('1' == $approved) { + echo __("1 comment approved") . "
\n"; + } else { + echo sprintf(__("%s comments approved
"), $approved) . "\n"; + } + } + if ($deleted) { + if ('1' == $deleted) { + echo __("1 comment deleted") . "
\n"; + } else { + echo sprintf(__("%s comments deleted"), $deleted) . "
\n"; + } + } + if ($spam) { + if ('1' == $spam) { + echo __("1 comment marked as spam") . "
\n"; + } else { + echo sprintf(__("%s comments marked as spam"), $spam) . "
\n"; + } + } + if ($ignored) { + if ('1' == $ignored) { + echo __("1 comment unchanged") . "
\n"; + } else { + echo sprintf(__("%s comments unchanged"), $ignored) . "
\n"; + } + } + echo "

\n"; +} + +?> + +
+ +get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'"); +else + $comments = ''; + +if ($comments) { + // list all comments that are waiting for approval + $file = basename(__FILE__); +?> +

+
+ +
    +comment_date); + $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'"); + if ($i % 2) $class = 'class="alternate"'; + else $class = ''; + echo "\n\t
  1. "; + ?> +

    comment_author_email) { ?>| comment_author_url && 'http://' != $comment->comment_author_url) { ?> | | |

    + +

    comment_ID.'">' . __('Edit') . ' | ';?> + | +comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($comment->comment_author, 1)) . "' );\">" . __('Delete just this comment') . " | "; ?> + + + + +

    + +
  2. + +
+ +
+ +

+ + + +
+'.__("Currently there are no comments for you to moderate.") . "

\n"; +} +?> + +
+ + diff --git a/wp-admin/options-discussion.php b/wp-admin/options-discussion.php new file mode 100644 index 00000000..af2db9a6 --- /dev/null +++ b/wp-admin/options-discussion.php @@ -0,0 +1,100 @@ +find_spam(); + echo $retrospaminator->display_edit_form( $result ); + include('./admin-footer.php'); + exit; +} +?> + +
+

+
+
+(These settings may be overridden for individual articles.)') ?> +
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+ +
    +
  • + +
  • +
  • + +
  • +
+
+
+ +
    +
  • + +
  • +
  • +
  • +
+
+
+ +

' ) ?>

+ +

Common spam words.') ?>

+

+ +

+

+ +

+
+
+ +

+

+ +

+

+
+

+ + + +

+
+
+ diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php new file mode 100644 index 00000000..1d9c453f --- /dev/null +++ b/wp-admin/options-general.php @@ -0,0 +1,110 @@ + + +
+

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

to be different than the directory you installed WordPress in, enter that address here.'); ?>
+
+

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
UTC time is:') ?>
+

+

+
 Documentation on date formatting. Save option to update sample output.') ?>
+
+ +

+ + +

+
+ +
+ + \ No newline at end of file diff --git a/wp-admin/options-head.php b/wp-admin/options-head.php new file mode 100644 index 00000000..579da0a3 --- /dev/null +++ b/wp-admin/options-head.php @@ -0,0 +1,24 @@ + + +
+ + +

+ \ No newline at end of file diff --git a/wp-admin/options-misc.php b/wp-admin/options-misc.php new file mode 100644 index 00000000..711a4ccd --- /dev/null +++ b/wp-admin/options-misc.php @@ -0,0 +1,51 @@ + + +
+

+
+ +
+ + + + + + + + + + +
: +
+wp-content/uploads'); ?> +
+ +
+
+ +

/> +

+

+ +

+ +

+ + + +

+
+
+ + \ No newline at end of file diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php new file mode 100644 index 00000000..ff65875b --- /dev/null +++ b/wp-admin/options-permalink.php @@ -0,0 +1,175 @@ + + +set_permalink_structure($permalink_structure); + } + + if ( isset($_POST['category_base']) ) { + $category_base = $_POST['category_base']; + if (! empty($category_base) ) + $category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']); + $wp_rewrite->set_category_base($category_base); + } +} + +$permalink_structure = get_settings('permalink_structure'); +$category_base = get_settings('category_base'); + +if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') ) + $writable = true; +else + $writable = false; + +if ($wp_rewrite->using_index_permalinks()) + $usingpi = true; +else + $usingpi = false; + +$wp_rewrite->flush_rules(); +?> + + +

+ + +
+

+

number of tags are available, and here are some examples to get you started.'); ?>

+ + +
+

+

+ +

+

+ +

+

+ +

+

+ +
+

+

:

+ +

+ +

/taxonomy/tags would make your category links like http://example.org/taxonomy/tags/uncategorized/. If you leave this blank the default will be used.') ?>

+ +

/index.php/taxonomy/tags would make your category links like http://example.org/index.php/taxonomy/tags/uncategorized/. If you leave this blank the default will be used.') ?>

+ +

+ : +

+

+ +

+
+ +

.htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.') ?>

+
+

+ +

+
+ + +
+ + diff --git a/wp-admin/options-reading.php b/wp-admin/options-reading.php new file mode 100644 index 00000000..30f06d27 --- /dev/null +++ b/wp-admin/options-reading.php @@ -0,0 +1,63 @@ + + +
+

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

+recommended)') ?>
+

+ +

+

+ + + +

+
+
+ \ No newline at end of file diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php new file mode 100644 index 00000000..d3d2fbae --- /dev/null +++ b/wp-admin/options-writing.php @@ -0,0 +1,99 @@ + + +
+

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

%s, %s, %s.'), substr(md5(uniqid(microtime())),0,5), substr(md5(uniqid(microtime())),0,5), substr(md5(uniqid(microtime())),0,5)) ?>

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

Update Services on the Codex. Separate multiple service URIs with line breaks.') ?>

+ + +
+ +

+ + + +

+
+
+ + \ No newline at end of file diff --git a/wp-admin/options.php b/wp-admin/options.php new file mode 100644 index 00000000..de5999c6 --- /dev/null +++ b/wp-admin/options.php @@ -0,0 +1,120 @@ + $value) { + $options[] = $key; + } + } else { + $options = explode(',', stripslashes($_POST['page_options'])); + } + + // Save for later. + $old_siteurl = get_settings('siteurl'); + $old_home = get_settings('home'); + + // HACK + // Options that if not there have 0 value but need to be something like "closed" + $nonbools = array('default_ping_status', 'default_comment_status'); + if ($options) { + foreach ($options as $option) { + $option = trim($option); + $value = trim(stripslashes($_POST[$option])); + if( in_array($option, $nonbools) && ( $value == '0' || $value == '') ) + $value = 'closed'; + + if( $option == 'blogdescription' || $option == 'blogname' ) + if (current_user_can('unfiltered_html') == false) + $value = wp_filter_post_kses( $value ); + + if (update_option($option, $value) ) { + $any_changed++; + } + } + } + + if ($any_changed) { + // If siteurl or home changed, reset cookies. + if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) { + // If home changed, write rewrite rules to new location. + $wp_rewrite->flush_rules(); + // Get currently logged in user and password. + get_currentuserinfo(); + // Clear cookies for old paths. + wp_clearcookie(); + // Set cookies for new paths. + wp_setcookie($user_login, $user_pass_md5, true, get_settings('home'), get_settings('siteurl')); + } + + //$message = sprintf(__('%d setting(s) saved... '), $any_changed); + } + + $referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']); + $goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']); + $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback); + wp_redirect($goback); + break; + +default: + include('admin-header.php'); ?> + +
+

+
+ + +get_results("SELECT * FROM $wpdb->options ORDER BY option_name"); + +foreach ($options as $option) : + $value = wp_specialchars($option->option_value); + echo " + + + + +"; +endforeach; +?> +
$option->option_description
+

+
+
+ + + diff --git a/wp-admin/page-new.php b/wp-admin/page-new.php new file mode 100644 index 00000000..4defde16 --- /dev/null +++ b/wp-admin/page-new.php @@ -0,0 +1,25 @@ + + + + + + +post_status = 'static'; + + include('edit-page-form.php'); +} +?> + + \ No newline at end of file diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php new file mode 100644 index 00000000..37aed6b0 --- /dev/null +++ b/wp-admin/plugin-editor.php @@ -0,0 +1,123 @@ +'.__('You have do not have sufficient permissions to edit templates for this blog.').'

'); + + $newcontent = stripslashes($_POST['newcontent']); + if (is_writeable($real_file)) { + $f = fopen($real_file, 'w+'); + fwrite($f, $newcontent); + fclose($f); + header("Location: plugin-editor.php?file=$file&a=te"); + } else { + header("Location: plugin-editor.php?file=$file"); + } + + exit(); + +break; + +default: + + require_once('admin-header.php'); + if ( !current_user_can('edit_plugins') ) + die('

'.__('You have do not have sufficient permissions to edit plugins for this blog.').'

'); + + update_recently_edited("wp-content/plugins/$file"); + + if (!is_file($real_file)) + $error = 1; + + if (!$error) { + $f = fopen($real_file, 'r'); + $content = fread($f, filesize($real_file)); + $content = htmlspecialchars($content); + } + + ?> + +

+ +
+ ' . sprintf(__('Editing %s'), $file) . ''; + } else { + echo '

' . sprintf(__('Browsing %s'), $file) . '

'; + } + ?> +
+

+ + +
    + +
  • ">
  • + +
+ +
+ +
+
+ + +
+ +

+"; +?> +

+ +

+ +
+

' . __('Oops, no such file exists! Double check the name and try again, merci.') . '

'; + } + ?> +
 
+ + diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php new file mode 100644 index 00000000..69d31ec0 --- /dev/null +++ b/wp-admin/plugins.php @@ -0,0 +1,133 @@ + + + +

activated.') ?>

+
+ + +

deactivated.') ?>

+
+ + +
+

+

+'; + _e("Couldn't open plugins directory or there are no plugins available."); // TODO: make more helpful + echo '

'; +} else { +?> + + + + + + + + $plugin_data) { + $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate'; + + if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) { + $action = "".__('Deactivate').""; + $plugin_data['Title'] = "{$plugin_data['Title']}"; + $style .= $style == 'alternate' ? ' active' : 'active'; + } else { + $action = "".__('Activate').""; + } + $plugin_data['Description'] = wp_kses($plugin_data['Description'], array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()) ); ; + if ($style != '') $style = 'class="' . $style . '"'; + echo " + + + + + + "; + } +?> + +
{$plugin_data['Title']}{$plugin_data['Version']}{$plugin_data['Description']} ".sprintf(__('By %s'), $plugin_data['Author']).".$action
+ + +

wp-content/plugins directory and it will be automatically deactivated.'); ?>

+ +

+

WordPress plugin directory. To install a plugin you generally just need to upload the plugin file into your wp-content/plugins directory. Once a plugin is uploaded, you may activate it here.'); ?>

+ +
+ + diff --git a/wp-admin/post.php b/wp-admin/post.php new file mode 100644 index 00000000..0f4187e9 --- /dev/null +++ b/wp-admin/post.php @@ -0,0 +1,429 @@ +post_status == 'static') + include('edit-page-form.php'); + else + include('edit-form-advanced.php'); + + ?> +
+

+ +
+ post_status == 'attachment' ) { + if ( ! wp_delete_attachment($post_id) ) + die( __('Error in deleting...') ); + } else { + if ( !wp_delete_post($post_id) ) + die( __('Error in deleting...') ); + } + + $sendback = $_SERVER['HTTP_REFERER']; + if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post.php'; + elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php'; + $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); + header ('Location: ' . $sendback); + break; + +case 'editcomment': + $title = __('Edit Comment'); + $parent_file = 'edit.php'; + require_once ('admin-header.php'); + + get_currentuserinfo(); + + $comment = (int) $_GET['comment']; + + if ( ! $comment = get_comment($comment) ) + die(sprintf(__('Oops, no comment with this ID. Go back!'), 'javascript:history.go(-1)')); + + if ( !current_user_can('edit_post', $comment->comment_post_ID) ) + die( __('You are not allowed to edit comments on this post.') ); + + $comment = get_comment_to_edit($comment); + + include('edit-form-comment.php'); + + break; + +case 'confirmdeletecomment': + + require_once('./admin-header.php'); + + $comment = (int) $_GET['comment']; + $p = (int) $_GET['p']; + + if ( ! $comment = get_comment($comment) ) + die(sprintf(__('Oops, no comment with this ID. Go back!'), 'edit.php')); + + if ( !current_user_can('edit_post', $comment->comment_post_ID) ) + die( __('You are not allowed to delete comments on this post.') ); + + echo "
\n"; + echo "

" . __('Caution: You are about to delete the following comment:') . "

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
" . __('Author:') . "$comment->comment_author
" . __('E-mail:') . "$comment->comment_author_email
". __('URL:') . "$comment->comment_author_url
". __('Comment:') . "$comment->comment_content
\n"; + echo "

" . __('Are you sure you want to do that?') . "

\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + echo "  "; + echo "\n"; + echo "
\n"; + echo "
\n"; + + break; + +case 'deletecomment': + + check_admin_referer(); + + $comment = (int) $_GET['comment']; + $p = (int) $_GET['p']; + if (isset($_GET['noredir'])) { + $noredir = true; + } else { + $noredir = false; + } + + $postdata = get_post($p) or die(sprintf(__('Oops, no post with this ID. Go back!'), 'edit.php')); + + if ( ! $comment = get_comment($comment) ) + die(sprintf(__('Oops, no comment with this ID. Go back!'), 'post.php')); + + if ( !current_user_can('edit_post', $comment->comment_post_ID) ) + die( __('You are not allowed to edit comments on this post.') ); + + wp_set_comment_status($comment->comment_ID, "delete"); + do_action('delete_comment', $comment->comment_ID); + + if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) { + header('Location: ' . $_SERVER['HTTP_REFERER']); + } else { + header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments'); + } + + break; + +case 'unapprovecomment': + + check_admin_referer(); + + $comment = (int) $_GET['comment']; + $p = (int) $_GET['p']; + if (isset($_GET['noredir'])) { + $noredir = true; + } else { + $noredir = false; + } + + if ( ! $comment = get_comment($comment) ) + die(sprintf(__('Oops, no comment with this ID. Go back!'), 'edit.php')); + + if ( !current_user_can('edit_post', $comment->comment_post_ID) ) + die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') ); + + wp_set_comment_status($comment->comment_ID, "hold"); + + if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) { + header('Location: ' . $_SERVER['HTTP_REFERER']); + } else { + header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments'); + } + + break; + +case 'mailapprovecomment': + + $comment = (int) $_GET['comment']; + + if ( ! $comment = get_comment($comment) ) + die(sprintf(__('Oops, no comment with this ID. Go back!'), 'edit.php')); + + if ( !current_user_can('edit_post', $comment->comment_post_ID) ) + die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') ); + + if ('1' != $comment->comment_approved) { + wp_set_comment_status($comment->comment_ID, 'approve'); + if (true == get_option('comments_notify')) + wp_notify_postauthor($comment->comment_ID); + } + + header('Location: ' . get_option('siteurl') . '/wp-admin/moderation.php?approved=1'); + + break; + +case 'approvecomment': + + $comment = (int) $_GET['comment']; + $p = (int) $_GET['p']; + if (isset($_GET['noredir'])) { + $noredir = true; + } else { + $noredir = false; + } + + if ( ! $comment = get_comment($comment) ) + die(sprintf(__('Oops, no comment with this ID. Go back!'), 'edit.php')); + + if ( !current_user_can('edit_post', $comment->comment_post_ID) ) + die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') ); + + wp_set_comment_status($comment->comment_ID, "approve"); + if (get_settings("comments_notify") == true) { + wp_notify_postauthor($comment->comment_ID); + } + + + if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) { + header('Location: ' . $_SERVER['HTTP_REFERER']); + } else { + header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments'); + } + + break; + +case 'editedcomment': + + edit_comment(); + + $referredby = $_POST['referredby']; + if (!empty($referredby)) { + header('Location: ' . $referredby); + } else { + header ("Location: edit.php?p=$comment_post_ID&c=1#comments"); + } + + break; + +default: + $title = __('Create New Post'); + require_once ('./admin-header.php'); +?> + +

View site »'), get_bloginfo('home') . '/'); ?>

+ + +
+

+ 15 ) $num_drafts = 15; + for ( $i = 0; $i < $num_drafts; $i++ ) { + $draft = $drafts[$i]; + if ( 0 != $i ) + echo ', '; + $draft->post_title = stripslashes($draft->post_title); + if ( empty($draft->post_title) ) + $draft->post_title = sprintf(__('Post # %s'), $draft->ID); + echo "$draft->post_title"; + } + ?> + + , » + + .

+
+ +
+'.__('WordPress bookmarklet').' +

'.__('Right click on the following link and choose "Add to favorites" to create a posting shortcut.').'

'; ?> +

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

+
+ +
+

+You can also e-mail the admin to ask for a promotion.
+When you’re promoted, just reload this page and you’ll be able to blog. :)'), get_settings('admin_email')); ?> +

+
+ */ +include('admin-footer.php'); +?> diff --git a/wp-admin/profile-update.php b/wp-admin/profile-update.php new file mode 100644 index 00000000..b3cb166f --- /dev/null +++ b/wp-admin/profile-update.php @@ -0,0 +1,33 @@ + $error) { + echo $error . '
'; + } + exit; +} + +if ( !isset( $_POST['rich_editing'] ) ) + $_POST['rich_editing'] = 'false'; +update_user_option( $current_user->id, 'rich_editing', $_POST['rich_editing'], true ); + +do_action('personal_options_update'); + +if ( 'profile' == $_POST['from'] ) + $to = 'profile.php?updated=true'; +else + $to = 'profile.php?updated=true'; + +wp_redirect( $to ); +exit; + +?> \ No newline at end of file diff --git a/wp-admin/profile.php b/wp-admin/profile.php new file mode 100644 index 00000000..1966cef8 --- /dev/null +++ b/wp-admin/profile.php @@ -0,0 +1,144 @@ + + + +
+

+
+ + +
+

+
+

+ + +

+ +
+ +

+ +

+ +

+ +

+ +

+
+ +
+ + +

+ +

+ +

+ +

+ +

+

+
+
+
+ +

+

+
+ + +
+ +

+

+

+
+ + + + +
+ +

+ +

+ + + + + caps) > count($profileuser->roles)): + ?> + + + + + +
caps as $cap => $value) { + if(!$wp_roles->is_role($cap)) { + if($output != '') $output .= ', '; + $output .= $value ? $cap : "Denied: {$cap}"; + } + } + echo $output; + ?>
+

+ +

+
+ +
+ + diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php new file mode 100644 index 00000000..38efd2b7 --- /dev/null +++ b/wp-admin/setup-config.php @@ -0,0 +1,156 @@ +installing now."); + +if (!file_exists('../wp-config-sample.php')) + die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.'); +$configFile = file('../wp-config-sample.php'); + +if (!is_writable('../')) die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually."); + +$step = 0; +if(isset($_GET['step'])) $step = $_GET['step']; +header( 'Content-Type: text/html; charset=utf-8' ); +?> + + + +WordPress › Setup Configuration File + + + + +

WordPress

+ +

Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.

+
    +
  1. Database name
  2. +
  3. Database username
  4. +
  5. Database password
  6. +
  7. Database host
  8. +
  9. Table prefix (if you want to run more than one WordPress in a single database)
  10. +
+

If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open wp-config-sample.php in a text editor, fill in your information, and save it as wp-config.php.

+

In all likelihood, these items were supplied to you by your ISP. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready, let’s go!

+ +

+
+

Below you should enter your database connection details. If you're not sure about these, contact your host.

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Database NameThe name of the database you want to run WP in.
User NameYour MySQL username
Password...and MySQL password.
Database Host99% chance you won't need to change this value.
Table PrefixIf you want to run multiple WordPress installations in a single database, change this.
+ +
+ $line) { + switch (substr($line,0,16)) { + case "define('DB_NAME'": + fwrite($handle, str_replace("wordpress", $dbname, $line)); + break; + case "define('DB_USER'": + fwrite($handle, str_replace("'username'", "'$uname'", $line)); + break; + case "define('DB_PASSW": + fwrite($handle, str_replace("'password'", "'$passwrd'", $line)); + break; + case "define('DB_HOST'": + fwrite($handle, str_replace("localhost", $dbhost, $line)); + break; + case '$table_prefix =': + fwrite($handle, str_replace('wp_', $prefix, $line)); + break; + default: + fwrite($handle, $line); + } + } + fclose($handle); + chmod('../wp-config.php', 0666); +?> +

All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to run the install!

+ + + diff --git a/wp-admin/sidebar.php b/wp-admin/sidebar.php new file mode 100644 index 00000000..17fd3cb4 --- /dev/null +++ b/wp-admin/sidebar.php @@ -0,0 +1,80 @@ + + + +WordPress › Posted + + + + +

Posted !

+

Click here to post again.

+ + + + +WordPress › Sidebar + + + + + +

WordPress

+
+
+ + +

Title: + +

+

Categories: + + + +

+

+Post: + +

+

+ + + + +

+
+
+ + + + \ No newline at end of file diff --git a/wp-admin/templates.php b/wp-admin/templates.php new file mode 100644 index 00000000..3e120504 --- /dev/null +++ b/wp-admin/templates.php @@ -0,0 +1,167 @@ +'.__('You have do not have sufficient permissions to edit templates for this blog.').'

'); + + $newcontent = stripslashes($_POST['newcontent']); + if (is_writeable($real_file)) { + $f = @ fopen($real_file, 'w+'); + if ( $f ) { + fwrite($f, $newcontent); + fclose($f); + header("Location: templates.php?file=$file&a=te"); + } else { + header("Location: templates.php?file=$file&a=err"); + } + } else { + header("Location: templates.php?file=$file&a=err"); + } + + exit(); + +break; + +default: + + require_once('./admin-header.php'); + + if ( ! current_user_can('edit_files') ) + die('

'.__('You have do not have sufficient permissions to edit templates for this blog.').'

'); + + if ( strstr( $file, 'wp-config.php' ) ) + die('

'.__('The config file cannot be edited or viewed through the web interface. Sorry!').'

'); + + update_recently_edited($file); + + if (!is_file($real_file)) + $error = true; + + if (!$error) { + $f = @ fopen($real_file, 'r'); + if ( $f ) { + $content = fread($f, filesize($real_file)); + $content = htmlspecialchars($content); + } else { + $error = true; + } + } + + ?> + + +

+ +

+ + +
+' . sprintf(__('Editing %s'), wp_specialchars($file) ) . ''; +} else { + echo '

' . sprintf(__('Browsing %s'), wp_specialchars($file) ) . '

'; +} +?> +
+ +

+'; +foreach ($recents as $recent) : + echo "
  • " . get_file_description(basename($recent)) . "
  • "; +endforeach; +echo ''; +endif; +?> +

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

    +"; +?> +

    + +

    + +
    +

    ' . __('Oops, no such file exists! Double check the name and try again, merci.') . '

    '; + } + ?> +
     
    + +
    +

    + +

    writable by the server, e.g. CHMOD 666.') ?>

    +
    + + +
    + +

    +
    + diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php new file mode 100644 index 00000000..8ed51079 --- /dev/null +++ b/wp-admin/theme-editor.php @@ -0,0 +1,158 @@ +'.__('You have do not have sufficient permissions to edit templates for this blog.').'

    '); + + $newcontent = stripslashes($_POST['newcontent']); + $theme = urlencode($theme); + if (is_writeable($real_file)) { + $f = fopen($real_file, 'w+'); + fwrite($f, $newcontent); + fclose($f); + header("Location: theme-editor.php?file=$file&theme=$theme&a=te"); + } else { + header("Location: theme-editor.php?file=$file&theme=$theme"); + } + + exit(); + +break; + +default: + + require_once('admin-header.php'); + if ( !current_user_can('edit_themes') ) + die('

    '.__('You have do not have sufficient permissions to edit themes for this blog.').'

    '); + + update_recently_edited($file); + + if (!is_file($real_file)) + $error = 1; + + if (!$error && filesize($real_file) > 0) { + $f = fopen($real_file, 'r'); + $content = fread($f, filesize($real_file)); + $content = htmlspecialchars($content); + } + + ?> + +

    + +
    +
    + + + +
    +
    + +
    + ' . sprintf(__('Editing %s'), $file_show) . ''; + } else { + echo '

    ' . sprintf(__('Browsing %s'), $file_show) . '

    '; + } + ?> +
    +

    '%s' theme files"), $theme) ?>

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

    +"; +?> +

    + +

    + +
    +

    ' . __('Oops, no such file exists! Double check the name and try again, merci.') . '

    '; + } + ?> +
     
    + + diff --git a/wp-admin/themes.php b/wp-admin/themes.php new file mode 100644 index 00000000..a17ea3cd --- /dev/null +++ b/wp-admin/themes.php @@ -0,0 +1,131 @@ + + + +

    + +

    View site »'), get_bloginfo('home') . '/'); ?>

    + + + + +
    +

    +
    +screenshot ) : ?> +<?php _e('Current theme preview'); ?> + +

    title, $ct->version, $ct->author) ; ?>

    +

    description; ?>

    +parent_theme) { ?> +

    %2$s. The stylesheet files are located in %3$s. %4$s uses templates from %5$s. Changes made to the templates will affect both themes.'), $ct->title, $ct->template_dir, $ct->stylesheet_dir, $ct->title, $ct->parent_theme); ?>

    + +

    %2$s.'), $ct->title, $ct->template_dir, $ct->stylesheet_dir); ?>

    + +
    + +

    + + +name ) + continue; + $template = $themes[$theme_name]['Template']; + $stylesheet = $themes[$theme_name]['Stylesheet']; + $title = $themes[$theme_name]['Title']; + $version = $themes[$theme_name]['Version']; + $description = $themes[$theme_name]['Description']; + $author = $themes[$theme_name]['Author']; + $screenshot = $themes[$theme_name]['Screenshot']; + $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir']; + $activate_link = "themes.php?action=activate&template=$template&stylesheet=$stylesheet"; +?> +
    +

    + + + + + + + +

    +
    + + + + + + +

    +

    + + + + + + + + + + "; + } +?> +
    $title$description
    + + +

    +

    WordPress theme directory. To install a theme you generally just need to upload the theme folder into your wp-content/themes directory. Once a theme is uploaded, you should see it on this page.'); ?>

    + +
    + + diff --git a/wp-admin/update-links.php b/wp-admin/update-links.php new file mode 100644 index 00000000..46a7f5a8 --- /dev/null +++ b/wp-admin/update-links.php @@ -0,0 +1,44 @@ +get_col("SELECT link_url FROM $wpdb->links"); + +if ( !$link_uris ) + die('No links'); + +$link_uris = urlencode( join( $link_uris, "\n" ) ); + +$query_string = "uris=$link_uris"; + +$http_request = "POST /updated-batch/ HTTP/1.0\r\n"; +$http_request .= "Host: api.pingomatic.com\r\n"; +$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n"; +$http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n"; +$http_request .= 'User-Agent: WordPress/' . $wp_version . "\r\n"; +$http_request .= "\r\n"; +$http_request .= $query_string; + +$response = ''; +if( false !== ( $fs = fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) { + fwrite($fs, $http_request); + while ( !feof($fs) ) + $response .= fgets($fs, 1160); // One TCP-IP packet + fclose($fs); + + $response = explode("\r\n\r\n", $response, 2); + $body = trim( $response[1] ); + $body = str_replace(array("\r\n", "\r"), "\n", $body); + + $returns = explode("\n", $body); + + foreach ($returns as $return) : + $time = $wpdb->escape( substr($return, 0, 19) ); + $uri = $wpdb->escape( preg_replace('/(.*?) | (.*?)/', '$2', $return) ); + $wpdb->query("UPDATE $wpdb->links SET link_updated = '$time' WHERE link_url = '$uri'"); + endforeach; +} +?> diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php new file mode 100644 index 00000000..37112769 --- /dev/null +++ b/wp-admin/upgrade-functions.php @@ -0,0 +1,847 @@ +flush_rules(); + + update_option('db_version', $wp_db_version); +} + +function upgrade_100() { + global $wpdb; + + // Get the title and ID of every post, post_name to check if it already has a value + $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''"); + if ($posts) { + foreach($posts as $post) { + if ('' == $post->post_name) { + $newtitle = sanitize_title($post->post_title); + $wpdb->query("UPDATE $wpdb->posts SET post_name = '$newtitle' WHERE ID = '$post->ID'"); + } + } + } + + $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories"); + foreach ($categories as $category) { + if ('' == $category->category_nicename) { + $newtitle = sanitize_title($category->cat_name); + $wpdb->query("UPDATE $wpdb->categories SET category_nicename = '$newtitle' WHERE cat_ID = '$category->cat_ID'"); + } + } + + + $wpdb->query("UPDATE $wpdb->options SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/') + WHERE option_name LIKE 'links_rating_image%' + AND option_value LIKE 'wp-links/links-images/%'"); + + $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat"); + if ($done_ids) : + foreach ($done_ids as $done_id) : + $done_posts[] = $done_id->post_id; + endforeach; + $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')'; + else: + $catwhere = ''; + endif; + + $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere"); + if ($allposts) : + foreach ($allposts as $post) { + // Check to see if it's already been imported + $cat = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post->ID AND category_id = $post->post_category"); + if (!$cat && 0 != $post->post_category) { // If there's no result + $wpdb->query(" + INSERT INTO $wpdb->post2cat + (post_id, category_id) + VALUES + ('$post->ID', '$post->post_category') + "); + } + } + endif; +} + +function upgrade_101() { + global $wpdb; + + // Clean up indices, add a few + add_clean_index($wpdb->posts, 'post_name'); + add_clean_index($wpdb->posts, 'post_status'); + add_clean_index($wpdb->categories, 'category_nicename'); + add_clean_index($wpdb->comments, 'comment_approved'); + add_clean_index($wpdb->comments, 'comment_post_ID'); + add_clean_index($wpdb->links , 'link_category'); + add_clean_index($wpdb->links , 'link_visible'); +} + + +function upgrade_110() { + global $wpdb; + + // Set user_nicename. + $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users"); + foreach ($users as $user) { + if ('' == $user->user_nicename) { + $newname = sanitize_title($user->user_nickname); + $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'"); + } + } + + $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users"); + foreach ($users as $row) { + if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) { + $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\''); + } + } + + + // Get the GMT offset, we'll use that later on + $all_options = get_alloptions_110(); + + $time_difference = $all_options->time_difference; + + $server_time = time()+date('Z'); + $weblogger_time = $server_time + $time_difference*3600; + $gmt_time = time(); + + $diff_gmt_server = ($gmt_time - $server_time) / 3600; + $diff_weblogger_server = ($weblogger_time - $server_time) / 3600; + $diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server; + $gmt_offset = -$diff_gmt_weblogger; + + // Add a gmt_offset option, with value $gmt_offset + add_option('gmt_offset', $gmt_offset); + + // Check if we already set the GMT fields (if we did, then + // MAX(post_date_gmt) can't be '0000-00-00 00:00:00' + // I just slapped myself silly for not thinking about it earlier + $got_gmt_fields = ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00') ? false : true; + + if (!$got_gmt_fields) { + + // Add or substract time to all dates, to get GMT dates + $add_hours = intval($diff_gmt_weblogger); + $add_minutes = intval(60 * ($diff_gmt_weblogger - $add_hours)); + $wpdb->query("UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"); + $wpdb->query("UPDATE $wpdb->posts SET post_modified = post_date"); + $wpdb->query("UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'"); + $wpdb->query("UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"); + $wpdb->query("UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"); + } + +} + +function upgrade_130() { + global $wpdb, $table_prefix; + + // Remove extraneous backslashes. + $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts"); + if ($posts) { + foreach($posts as $post) { + $post_content = addslashes(deslash($post->post_content)); + $post_title = addslashes(deslash($post->post_title)); + $post_excerpt = addslashes(deslash($post->post_excerpt)); + if ( empty($post->guid) ) + $guid = get_permalink($post->ID); + else + $guid = $post->guid; + + $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'"); + } + } + + // Remove extraneous backslashes. + $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments"); + if ($comments) { + foreach($comments as $comment) { + $comment_content = addslashes(deslash($comment->comment_content)); + $comment_author = addslashes(deslash($comment->comment_author)); + $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'"); + } + } + + // Remove extraneous backslashes. + $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links"); + if ($links) { + foreach($links as $link) { + $link_name = addslashes(deslash($link->link_name)); + $link_description = addslashes(deslash($link->link_description)); + $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'"); + } + } + + // The "paged" option for what_to_show is no more. + if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') { + $wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'"); + } + + $active_plugins = __get_option('active_plugins'); + + // If plugins are not stored in an array, they're stored in the old + // newline separated format. Convert to new format. + if ( !is_array( $active_plugins ) ) { + $active_plugins = explode("\n", trim($active_plugins)); + update_option('active_plugins', $active_plugins); + } + + // Obsolete tables + $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optionvalues'); + $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optiontypes'); + $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optiongroups'); + $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optiongroup_options'); + + // Update comments table to use comment_type + $wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '', '') WHERE comment_content LIKE '%'"); + $wpdb->query("UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '', '') WHERE comment_content LIKE '%'"); + + // Some versions have multiple duplicate option_name rows with the same values + $options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name"); + foreach ( $options as $option ) { + if ( 1 != $option->dupes ) { // Could this be done in the query? + $limit = $option->dupes - 1; + $dupe_ids = $wpdb->get_col("SELECT option_id FROM $wpdb->options WHERE option_name = '$option->option_name' LIMIT $limit"); + $dupe_ids = join($dupe_ids, ','); + $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)"); + } + } + + make_site_theme(); +} + +function upgrade_160() { + global $wpdb, $table_prefix, $wp_current_db_version; + + populate_roles_160(); + + $users = $wpdb->get_results("SELECT * FROM $wpdb->users"); + foreach ( $users as $user ) : + if ( !empty( $user->user_firstname ) ) + update_usermeta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) ); + if ( !empty( $user->user_lastname ) ) + update_usermeta( $user->ID, 'last_name', $wpdb->escape($user->user_lastname) ); + if ( !empty( $user->user_nickname ) ) + update_usermeta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) ); + if ( !empty( $user->user_level ) ) + update_usermeta( $user->ID, $table_prefix . 'user_level', $user->user_level ); + if ( !empty( $user->user_icq ) ) + update_usermeta( $user->ID, 'icq', $wpdb->escape($user->user_icq) ); + if ( !empty( $user->user_aim ) ) + update_usermeta( $user->ID, 'aim', $wpdb->escape($user->user_aim) ); + if ( !empty( $user->user_msn ) ) + update_usermeta( $user->ID, 'msn', $wpdb->escape($user->user_msn) ); + if ( !empty( $user->user_yim ) ) + update_usermeta( $user->ID, 'yim', $wpdb->escape($user->user_icq) ); + if ( !empty( $user->user_description ) ) + update_usermeta( $user->ID, 'description', $wpdb->escape($user->user_description) ); + + if ( isset( $user->user_idmode ) ): + $idmode = $user->user_idmode; + if ($idmode == 'nickname') $id = $user->user_nickname; + if ($idmode == 'login') $id = $user->user_login; + if ($idmode == 'firstname') $id = $user->user_firstname; + if ($idmode == 'lastname') $id = $user->user_lastname; + if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname; + if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname; + if (!$idmode) $id = $user->user_nickname; + $id = $wpdb->escape( $id ); + $wpdb->query("UPDATE $wpdb->users SET display_name = '$id' WHERE ID = '$user->ID'"); + endif; + + // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set. + $caps = get_usermeta( $user->ID, $table_prefix . 'capabilities'); + if ( empty($caps) || defined('RESET_CAPS') ) { + $level = get_usermeta($user->ID, $table_prefix . 'user_level'); + $role = translate_level_to_role($level); + update_usermeta( $user->ID, $table_prefix . 'capabilities', array($role => true) ); + } + + endforeach; + $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' ); + $wpdb->hide_errors(); + foreach ( $old_user_fields as $old ) + $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); + $wpdb->show_errors(); + + if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts + $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories"); + foreach ( $categories as $cat_id ) { + $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status='publish' AND category_id = '$cat_id'"); + $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'"); + } + } + + // populate comment_count field of posts table + $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); + if( is_array( $comments ) ) { + foreach ($comments as $comment) { + $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" ); + } + } + + // Some alpha versions used a post status of object instead of attachment and put + // the mime type in post_type instead of post_mime_type. + if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) { + $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'"); + foreach ($objects as $object) { + $wpdb->query("UPDATE $wpdb->posts SET post_status = 'attachment', + post_mime_type = '$object->post_type', + post_type = '' + WHERE ID = $object->ID"); + + $meta = get_post_meta($object->ID, 'imagedata', true); + if ( ! empty($meta['file']) ) + add_post_meta($object->ID, '_wp_attached_file', $meta['file']); + } + } +} + +// The functions we use to actually do stuff + +// General +function maybe_create_table($table_name, $create_ddl) { + global $wpdb; + foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { + if ($table == $table_name) { + return true; + } + } + //didn't find it try to create it. + $q = $wpdb->query($create_ddl); + // we cannot directly tell that whether this succeeded! + foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { + if ($table == $table_name) { + return true; + } + } + return false; +} + +function drop_index($table, $index) { + global $wpdb; + $wpdb->hide_errors(); + $wpdb->query("ALTER TABLE `$table` DROP INDEX `$index`"); + // Now we need to take out all the extra ones we may have created + for ($i = 0; $i < 25; $i++) { + $wpdb->query("ALTER TABLE `$table` DROP INDEX `{$index}_$i`"); + } + $wpdb->show_errors(); + return true; +} + +function add_clean_index($table, $index) { + global $wpdb; + drop_index($table, $index); + $wpdb->query("ALTER TABLE `$table` ADD INDEX ( `$index` )"); + return true; +} + +/** + ** maybe_add_column() + ** Add column to db table if it doesn't exist. + ** Returns: true if already exists or on successful completion + ** false on error + */ +function maybe_add_column($table_name, $column_name, $create_ddl) { + global $wpdb, $debug; + foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) { + if ($debug) echo("checking $column == $column_name
    "); + if ($column == $column_name) { + return true; + } + } + //didn't find it try to create it. + $q = $wpdb->query($create_ddl); + // we cannot directly tell that whether this succeeded! + foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) { + if ($column == $column_name) { + return true; + } + } + return false; +} + + +// get_alloptions as it was for 1.2. +function get_alloptions_110() { + global $wpdb; + if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) { + foreach ($options as $option) { + // "When trying to design a foolproof system, + // never underestimate the ingenuity of the fools :)" -- Dougal + if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value); + if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value); + if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value); + $all_options->{$option->option_name} = stripslashes($option->option_value); + } + } + return $all_options; +} + +// Version of get_option that is private to install/upgrade. +function __get_option($setting) { + global $wpdb; + + $option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'"); + + if ( 'home' == $setting && '' == $option ) + return __get_option('siteurl'); + + if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting ) + $option = preg_replace('|/+$|', '', $option); + + @ $kellogs = unserialize($option); + if ($kellogs !== FALSE) + return $kellogs; + else + return $option; +} + +function deslash($content) { + // Note: \\\ inside a regex denotes a single backslash. + + // Replace one or more backslashes followed by a single quote with + // a single quote. + $content = preg_replace("/\\\+'/", "'", $content); + + // Replace one or more backslashes followed by a double quote with + // a double quote. + $content = preg_replace('/\\\+"/', '"', $content); + + // Replace one or more backslashes with one backslash. + $content = preg_replace("/\\\+/", "\\", $content); + + return $content; +} + +function dbDelta($queries, $execute = true) { + global $wpdb; + + // Seperate individual queries into an array + if( !is_array($queries) ) { + $queries = explode( ';', $queries ); + if('' == $queries[count($queries) - 1]) array_pop($queries); + } + + $cqueries = array(); // Creation Queries + $iqueries = array(); // Insertion Queries + $for_update = array(); + + // Create a tablename index for an array ($cqueries) of queries + foreach($queries as $qry) { + if(preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) { + $cqueries[strtolower($matches[1])] = $qry; + $for_update[$matches[1]] = 'Created table '.$matches[1]; + } + else if(preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) { + array_unshift($cqueries, $qry); + } + else if(preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) { + $iqueries[] = $qry; + } + else if(preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) { + $iqueries[] = $qry; + } + else { + // Unrecognized query type + } + } + + // Check to see which tables and fields exist + if($tables = $wpdb->get_col('SHOW TABLES;')) { + // For every table in the database + foreach($tables as $table) { + // If a table query exists for the database table... + if( array_key_exists(strtolower($table), $cqueries) ) { + // Clear the field and index arrays + unset($cfields); + unset($indices); + // Get all of the field names in the query from between the parens + preg_match("|\((.*)\)|ms", $cqueries[strtolower($table)], $match2); + $qryline = trim($match2[1]); + + // Separate field lines into an array + $flds = explode("\n", $qryline); + + //echo "
    \n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."

    "; + + // For every field line specified in the query + foreach($flds as $fld) { + // Extract the field name + preg_match("|^([^ ]*)|", trim($fld), $fvals); + $fieldname = $fvals[1]; + + // Verify the found field name + $validfield = true; + switch(strtolower($fieldname)) + { + case '': + case 'primary': + case 'index': + case 'fulltext': + case 'unique': + case 'key': + $validfield = false; + $indices[] = trim(trim($fld), ", \n"); + break; + } + $fld = trim($fld); + + // If it's a valid field, add it to the field array + if($validfield) { + $cfields[strtolower($fieldname)] = trim($fld, ", \n"); + } + } + + // Fetch the table column structure from the database + $tablefields = $wpdb->get_results("DESCRIBE {$table};"); + + // For every field in the table + foreach($tablefields as $tablefield) { + // If the table field exists in the field array... + if(array_key_exists(strtolower($tablefield->Field), $cfields)) { + // Get the field type from the query + preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches); + $fieldtype = $matches[1]; + + // Is actual field type different from the field type in query? + if($tablefield->Type != $fieldtype) { + // Add a query to change the column type + $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)]; + $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; + } + + // Get the default value from the array + //echo "{$cfields[strtolower($tablefield->Field)]}
    "; + if(preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) { + $default_value = $matches[1]; + if($tablefield->Default != $default_value) + { + // Add a query to change the column's default value + $cqueries[] = "ALTER TABLE {$table} ALTER COLUMN {$tablefield->Field} SET DEFAULT '{$default_value}'"; + $for_update[$table.'.'.$tablefield->Field] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}"; + } + } + + // Remove the field from the array (so it's not added) + unset($cfields[strtolower($tablefield->Field)]); + } + else { + // This field exists in the table, but not in the creation queries? + } + } + + // For every remaining field specified for the table + foreach($cfields as $fieldname => $fielddef) { + // Push a query line into $cqueries that adds the field to that table + $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef"; + $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname; + } + + // Index stuff goes here + // Fetch the table index structure from the database + $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};"); + + if($tableindices) { + // Clear the index array + unset($index_ary); + + // For every index in the table + foreach($tableindices as $tableindex) { + // Add the index to the index data array + $keyname = $tableindex->Key_name; + $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part); + $index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false; + } + + // For each actual index in the index array + foreach($index_ary as $index_name => $index_data) { + // Build a create string to compare to the query + $index_string = ''; + if($index_name == 'PRIMARY') { + $index_string .= 'PRIMARY '; + } + else if($index_data['unique']) { + $index_string .= 'UNIQUE '; + } + $index_string .= 'KEY '; + if($index_name != 'PRIMARY') { + $index_string .= $index_name; + } + $index_columns = ''; + // For each column in the index + foreach($index_data['columns'] as $column_data) { + if($index_columns != '') $index_columns .= ','; + // Add the field to the column list string + $index_columns .= $column_data['fieldname']; + if($column_data['subpart'] != '') { + $index_columns .= '('.$column_data['subpart'].')'; + } + } + // Add the column list to the index create string + $index_string .= ' ('.$index_columns.')'; + + if(!(($aindex = array_search($index_string, $indices)) === false)) { + unset($indices[$aindex]); + //echo "
    {$table}:
    Found index:".$index_string."
    \n"; + } + //else echo "
    {$table}:
    Did not find index:".$index_string."
    ".print_r($indices, true)."
    \n"; + } + } + + // For every remaining index specified for the table + foreach($indices as $index) { + // Push a query line into $cqueries that adds the index to that table + $cqueries[] = "ALTER TABLE {$table} ADD $index"; + $for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index; + } + + // Remove the original table creation query from processing + unset($cqueries[strtolower($table)]); + unset($for_update[strtolower($table)]); + } else { + // This table exists in the database, but not in the creation queries? + } + } + } + + $allqueries = array_merge($cqueries, $iqueries); + if($execute) { + foreach($allqueries as $query) { + //echo "
    ".print_r($query, true)."
    \n"; + $wpdb->query($query); + } + } + + return $for_update; +} + +function make_db_current() { + global $wp_queries; + + $alterations = dbDelta($wp_queries); + echo "
      \n"; + foreach($alterations as $alteration) echo "
    1. $alteration
    2. \n"; + echo "
    \n"; +} + +function make_db_current_silent() { + global $wp_queries; + + $alterations = dbDelta($wp_queries); +} + +function make_site_theme_from_oldschool($theme_name, $template) { + $home_path = get_home_path(); + $site_dir = ABSPATH . "wp-content/themes/$template"; + + if (! file_exists("$home_path/index.php")) + return false; + + // Copy files from the old locations to the site theme. + // TODO: This does not copy arbitarary include dependencies. Only the + // standard WP files are copied. + $files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php'); + + foreach ($files as $oldfile => $newfile) { + if ($oldfile == 'index.php') + $oldpath = $home_path; + else + $oldpath = ABSPATH; + + if ($oldfile == 'index.php') { // Check to make sure it's not a new index + $index = implode('', file("$oldpath/$oldfile")); + if ( strstr( $index, 'WP_USE_THEMES' ) ) { + if (! @copy(ABSPATH . 'wp-content/themes/default/index.php', "$site_dir/$newfile")) + return false; + continue; // Don't copy anything + } + } + + if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) + return false; + + chmod("$site_dir/$newfile", 0777); + + // Update the blog header include in each file. + $lines = explode("\n", implode('', file("$site_dir/$newfile"))); + if ($lines) { + $f = fopen("$site_dir/$newfile", 'w'); + + foreach ($lines as $line) { + if (preg_match('/require.*wp-blog-header/', $line)) + $line = '//' . $line; + + // Update stylesheet references. + $line = str_replace("/wp-layout.css", "", $line); + + // Update comments template inclusion. + $line = str_replace("", "", $line); + + fwrite($f, "{$line}\n"); + } + fclose($f); + } + } + + // Add a theme header. + $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the upgrade.\nVersion: 1.0\nAuthor: Moi\n*/\n"; + + $stylelines = file_get_contents("$site_dir/style.css"); + if ($stylelines) { + $f = fopen("$site_dir/style.css", 'w'); + + fwrite($f, $header); + fwrite($f, $stylelines); + fclose($f); + } + + return true; +} + +function make_site_theme_from_default($theme_name, $template) { + $site_dir = ABSPATH . "wp-content/themes/$template"; + $default_dir = ABSPATH . 'wp-content/themes/default'; + + // Copy files from the default theme to the site theme. + //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css'); + + $theme_dir = @ dir("$default_dir"); + if ($theme_dir) { + while(($theme_file = $theme_dir->read()) !== false) { + if (is_dir("$default_dir/$theme_file")) + continue; + if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) + return; + chmod("$site_dir/$theme_file", 0777); + } + } + + // Rewrite the theme header. + $stylelines = explode("\n", implode('', file("$site_dir/style.css"))); + if ($stylelines) { + $f = fopen("$site_dir/style.css", 'w'); + + foreach ($stylelines as $line) { + if (strstr($line, "Theme Name:")) $line = "Theme Name: $theme_name"; + elseif (strstr($line, "Theme URI:")) $line = "Theme URI: " . __get_option('siteurl'); + elseif (strstr($line, "Description:")) $line = "Description: Your theme"; + elseif (strstr($line, "Version:")) $line = "Version: 1"; + elseif (strstr($line, "Author:")) $line = "Author: You"; + fwrite($f, "{$line}\n"); + } + fclose($f); + } + + // Copy the images. + umask(0); + if (! mkdir("$site_dir/images", 0777)) { + return false; + } + + $images_dir = @ dir("$default_dir/images"); + if ($images_dir) { + while(($image = $images_dir->read()) !== false) { + if (is_dir("$default_dir/images/$image")) + continue; + if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) + return; + chmod("$site_dir/images/$image", 0777); + } + } +} + +// Create a site theme from the default theme. +function make_site_theme() { + // Name the theme after the blog. + $theme_name = __get_option('blogname'); + $template = sanitize_title($theme_name); + $site_dir = ABSPATH . "wp-content/themes/$template"; + + // If the theme already exists, nothing to do. + if ( is_dir($site_dir)) { + return false; + } + + // We must be able to write to the themes dir. + if (! is_writable(ABSPATH . "wp-content/themes")) { + return false; + } + + umask(0); + if (! mkdir($site_dir, 0777)) { + return false; + } + + if (file_exists(ABSPATH . 'wp-layout.css')) { + if (! make_site_theme_from_oldschool($theme_name, $template)) { + // TODO: rm -rf the site theme directory. + return false; + } + } else { + if (! make_site_theme_from_default($theme_name, $template)) + // TODO: rm -rf the site theme directory. + return false; + } + + // Make the new site theme active. + $current_template = __get_option('template'); + if ($current_template == 'default') { + update_option('template', $template); + update_option('stylesheet', $template); + } + return $template; +} + +function translate_level_to_role($level) { + switch ($level) { + case 10: + case 9: + case 8: + return 'administrator'; + case 7: + case 6: + case 5: + return 'editor'; + case 4: + case 3: + case 2: + return 'author'; + case 1: + return 'contributor'; + case 0: + return 'subscriber'; + } +} + +?> diff --git a/wp-admin/upgrade-schema.php b/wp-admin/upgrade-schema.php new file mode 100644 index 00000000..e89b893d --- /dev/null +++ b/wp-admin/upgrade-schema.php @@ -0,0 +1,339 @@ +categories ( + cat_ID bigint(20) NOT NULL auto_increment, + cat_name varchar(55) NOT NULL default '', + category_nicename varchar(200) NOT NULL default '', + category_description longtext NOT NULL, + category_parent bigint(20) NOT NULL default '0', + category_count bigint(20) NOT NULL default '0', + PRIMARY KEY (cat_ID), + KEY category_nicename (category_nicename) +); +CREATE TABLE $wpdb->comments ( + comment_ID bigint(20) unsigned NOT NULL auto_increment, + comment_post_ID int(11) NOT NULL default '0', + comment_author tinytext NOT NULL, + comment_author_email varchar(100) NOT NULL default '', + comment_author_url varchar(200) NOT NULL default '', + comment_author_IP varchar(100) NOT NULL default '', + comment_date datetime NOT NULL default '0000-00-00 00:00:00', + comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00', + comment_content text NOT NULL, + comment_karma int(11) NOT NULL default '0', + comment_approved enum('0','1','spam') NOT NULL default '1', + comment_agent varchar(255) NOT NULL default '', + comment_type varchar(20) NOT NULL default '', + comment_parent bigint(20) NOT NULL default '0', + user_id bigint(20) NOT NULL default '0', + PRIMARY KEY (comment_ID), + KEY comment_approved (comment_approved), + KEY comment_post_ID (comment_post_ID) +); +CREATE TABLE $wpdb->linkcategories ( + cat_id bigint(20) NOT NULL auto_increment, + cat_name tinytext NOT NULL, + auto_toggle enum('Y','N') NOT NULL default 'N', + show_images enum('Y','N') NOT NULL default 'Y', + show_description enum('Y','N') NOT NULL default 'N', + show_rating enum('Y','N') NOT NULL default 'Y', + show_updated enum('Y','N') NOT NULL default 'Y', + sort_order varchar(64) NOT NULL default 'rand', + sort_desc enum('Y','N') NOT NULL default 'N', + text_before_link varchar(128) NOT NULL default '
  • ', + text_after_link varchar(128) NOT NULL default '
    ', + text_after_all varchar(128) NOT NULL default '
  • ', + list_limit int(11) NOT NULL default '-1', + PRIMARY KEY (cat_id) +); +CREATE TABLE $wpdb->links ( + link_id bigint(20) NOT NULL auto_increment, + link_url varchar(255) NOT NULL default '', + link_name varchar(255) NOT NULL default '', + link_image varchar(255) NOT NULL default '', + link_target varchar(25) NOT NULL default '', + link_category bigint(20) NOT NULL default '0', + link_description varchar(255) NOT NULL default '', + link_visible enum('Y','N') NOT NULL default 'Y', + link_owner int(11) NOT NULL default '1', + link_rating int(11) NOT NULL default '0', + link_updated datetime NOT NULL default '0000-00-00 00:00:00', + link_rel varchar(255) NOT NULL default '', + link_notes mediumtext NOT NULL, + link_rss varchar(255) NOT NULL default '', + PRIMARY KEY (link_id), + KEY link_category (link_category), + KEY link_visible (link_visible) +); +CREATE TABLE $wpdb->options ( + option_id bigint(20) NOT NULL auto_increment, + blog_id int(11) NOT NULL default '0', + option_name varchar(64) NOT NULL default '', + option_can_override enum('Y','N') NOT NULL default 'Y', + option_type int(11) NOT NULL default '1', + option_value longtext NOT NULL, + option_width int(11) NOT NULL default '20', + option_height int(11) NOT NULL default '8', + option_description tinytext NOT NULL, + option_admin_level int(11) NOT NULL default '1', + autoload enum('yes','no') NOT NULL default 'yes', + PRIMARY KEY (option_id,blog_id,option_name), + KEY option_name (option_name) +); +CREATE TABLE $wpdb->post2cat ( + rel_id bigint(20) NOT NULL auto_increment, + post_id bigint(20) NOT NULL default '0', + category_id bigint(20) NOT NULL default '0', + PRIMARY KEY (rel_id), + KEY post_id (post_id,category_id) +); +CREATE TABLE $wpdb->postmeta ( + meta_id bigint(20) NOT NULL auto_increment, + post_id bigint(20) NOT NULL default '0', + meta_key varchar(255) default NULL, + meta_value longtext, + PRIMARY KEY (meta_id), + KEY post_id (post_id), + KEY meta_key (meta_key) +); +CREATE TABLE $wpdb->posts ( + ID bigint(20) unsigned NOT NULL auto_increment, + post_author bigint(20) NOT NULL default '0', + post_date datetime NOT NULL default '0000-00-00 00:00:00', + post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00', + post_content longtext NOT NULL, + post_title text NOT NULL, + post_category int(4) NOT NULL default '0', + post_excerpt text NOT NULL, + post_status enum('publish','draft','private','static','object','attachment') NOT NULL default 'publish', + comment_status enum('open','closed','registered_only') NOT NULL default 'open', + ping_status enum('open','closed') NOT NULL default 'open', + post_password varchar(20) NOT NULL default '', + post_name varchar(200) NOT NULL default '', + to_ping text NOT NULL, + pinged text NOT NULL, + post_modified datetime NOT NULL default '0000-00-00 00:00:00', + post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00', + post_content_filtered text NOT NULL, + post_parent bigint(20) NOT NULL default '0', + guid varchar(255) NOT NULL default '', + menu_order int(11) NOT NULL default '0', + post_type varchar(100) NOT NULL default '', + post_mime_type varchar(100) NOT NULL default '', + comment_count bigint(20) NOT NULL default '0', + PRIMARY KEY (ID), + KEY post_name (post_name) +); +CREATE TABLE $wpdb->users ( + ID bigint(20) unsigned NOT NULL auto_increment, + user_login varchar(60) NOT NULL default '', + user_pass varchar(64) NOT NULL default '', + user_nicename varchar(50) NOT NULL default '', + user_email varchar(100) NOT NULL default '', + user_url varchar(100) NOT NULL default '', + user_registered datetime NOT NULL default '0000-00-00 00:00:00', + user_activation_key varchar(60) NOT NULL default '', + user_status int(11) NOT NULL default '0', + display_name varchar(250) NOT NULL default '', + PRIMARY KEY (ID), + KEY user_login_key (user_login) +); +CREATE TABLE $wpdb->usermeta ( + umeta_id bigint(20) NOT NULL auto_increment, + user_id bigint(20) NOT NULL default '0', + meta_key varchar(255) default NULL, + meta_value longtext, + PRIMARY KEY (umeta_id), + KEY user_id (user_id), + KEY meta_key (meta_key) +);"; + +function populate_options() { + global $wpdb, $wp_db_version; + + $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://'; + $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); + add_option('siteurl', $guessurl, __('WordPress web address')); + add_option('blogname', __('My Weblog'), __('Blog title')); + add_option('blogdescription', __('Just another WordPress weblog'), __('Short tagline')); + add_option('new_users_can_blog', 0); + add_option('users_can_register', 0); + add_option('admin_email', 'you@example.com'); + add_option('start_of_week', 1); + add_option('use_balanceTags', 0); + add_option('use_smilies', 1); + add_option('require_name_email', 1); + add_option('comments_notify', 1); + add_option('posts_per_rss', 10); + add_option('rss_excerpt_length', 50); + add_option('rss_use_excerpt', 0); + add_option('mailserver_url', 'mail.example.com'); + add_option('mailserver_login', 'login@example.com'); + add_option('mailserver_pass', 'password'); + add_option('mailserver_port', 110); + add_option('default_category', 1); + add_option('default_comment_status', 'open'); + add_option('default_ping_status', 'open'); + add_option('default_pingback_flag', 1); + add_option('default_post_edit_rows', 10); + add_option('posts_per_page', 10); + add_option('what_to_show', 'posts'); + add_option('date_format', __('F j, Y')); + add_option('time_format', __('g:i a')); + add_option('links_updated_date_format', __('F j, Y g:i a')); + add_option('links_recently_updated_prepend', ''); + add_option('links_recently_updated_append', ''); + add_option('links_recently_updated_time', 120); + add_option('comment_moderation', 0); + add_option('moderation_notify', 1); + add_option('permalink_structure'); + add_option('gzipcompression', 0); + add_option('hack_file', 0); + add_option('blog_charset', 'UTF-8'); + add_option('moderation_keys'); + add_option('active_plugins'); + add_option('home', $guessurl); + // in case it is set, but blank, update "home" + if ( !__get_option('home') ) update_option('home', $guessurl); + add_option('category_base'); + add_option('ping_sites', 'http://rpc.pingomatic.com/'); + add_option('advanced_edit', 0); + add_option('comment_max_links', 2); + add_option('gmt_offset', date('Z') / 3600); + // 1.5 + add_option('default_email_category', 1, __('Posts by email go to this category')); + add_option('recently_edited'); + add_option('use_linksupdate', 0); + add_option('template', 'default'); + add_option('stylesheet', 'default'); + add_option('comment_whitelist', 1); + add_option('page_uris'); + add_option('blacklist_keys'); + add_option('comment_registration', 0); + add_option('open_proxy_check', 1); + add_option('rss_language', 'en'); + add_option('html_type', 'text/html'); + // 1.5.1 + add_option('use_trackback', 0); + // 2.0 + add_option('default_role', 'subscriber'); + add_option('rich_editing', 'true'); + add_option('db_version', $wp_db_version); + // 2.0.1 + if ( ini_get('safe_mode') ) { + // Safe mode screws up mkdir(), so we must use a flat structure. + add_option('uploads_use_yearmonth_folders', 0); + add_option('upload_path', 'wp-content'); + } else { + add_option('uploads_use_yearmonth_folders', 1); + add_option('upload_path', 'wp-content/uploads'); + } + + // Delete unused options + $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog'); + foreach ($unusedoptions as $option) : + delete_option($option); + endforeach; + + // Set up a few options not to load by default + $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' ); + foreach ($fatoptions as $fatoption) : + $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'"); + endforeach; +} + +function populate_roles() { + populate_roles_160(); +} + +function populate_roles_160() { + global $wp_roles; + + // Add roles + add_role('administrator', __('Administrator')); + add_role('editor', __('Editor')); + add_role('author', __('Author')); + add_role('contributor', __('Contributor')); + add_role('subscriber', __('Subscriber')); + + // Add caps for Administrator role + $role = get_role('administrator'); + $role->add_cap('switch_themes'); + $role->add_cap('edit_themes'); + $role->add_cap('activate_plugins'); + $role->add_cap('edit_plugins'); + $role->add_cap('edit_users'); + $role->add_cap('edit_files'); + $role->add_cap('manage_options'); + $role->add_cap('moderate_comments'); + $role->add_cap('manage_categories'); + $role->add_cap('manage_links'); + $role->add_cap('upload_files'); + $role->add_cap('import'); + $role->add_cap('unfiltered_html'); + $role->add_cap('edit_posts'); + $role->add_cap('edit_others_posts'); + $role->add_cap('edit_published_posts'); + $role->add_cap('publish_posts'); + $role->add_cap('edit_pages'); + $role->add_cap('read'); + $role->add_cap('level_10'); + $role->add_cap('level_9'); + $role->add_cap('level_8'); + $role->add_cap('level_7'); + $role->add_cap('level_6'); + $role->add_cap('level_5'); + $role->add_cap('level_4'); + $role->add_cap('level_3'); + $role->add_cap('level_2'); + $role->add_cap('level_1'); + $role->add_cap('level_0'); + + // Add caps for Editor role + $role = get_role('editor'); + $role->add_cap('moderate_comments'); + $role->add_cap('manage_categories'); + $role->add_cap('manage_links'); + $role->add_cap('upload_files'); + $role->add_cap('unfiltered_html'); + $role->add_cap('edit_posts'); + $role->add_cap('edit_others_posts'); + $role->add_cap('edit_published_posts'); + $role->add_cap('publish_posts'); + $role->add_cap('edit_pages'); + $role->add_cap('read'); + $role->add_cap('level_7'); + $role->add_cap('level_6'); + $role->add_cap('level_5'); + $role->add_cap('level_4'); + $role->add_cap('level_3'); + $role->add_cap('level_2'); + $role->add_cap('level_1'); + $role->add_cap('level_0'); + + // Add caps for Author role + $role = get_role('author'); + $role->add_cap('upload_files'); + $role->add_cap('edit_posts'); + $role->add_cap('edit_published_posts'); + $role->add_cap('publish_posts'); + $role->add_cap('read'); + $role->add_cap('level_2'); + $role->add_cap('level_1'); + $role->add_cap('level_0'); + + // Add caps for Contributor role + $role = get_role('contributor'); + $role->add_cap('edit_posts'); + $role->add_cap('read'); + $role->add_cap('level_1'); + $role->add_cap('level_0'); + + // Add caps for Subscriber role + $role = get_role('subscriber'); + $role->add_cap('read'); + $role->add_cap('level_0'); +} + +?> diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php new file mode 100644 index 00000000..53eb1549 --- /dev/null +++ b/wp-admin/upgrade.php @@ -0,0 +1,104 @@ + + + + + WordPress › Upgrade + + + + +

    WordPress

    + +

    +

    + +

    +

    Have fun!"), $backto); ?>

    + + + + + + diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php new file mode 100644 index 00000000..430c8233 --- /dev/null +++ b/wp-admin/user-edit.php @@ -0,0 +1,206 @@ + + + +
    +

    +
    + + +
    +
      + $error"; + ?> +
    +
    + + +
    +

    + +
    +

    + + +

    + +
    + +

    + +

    + +

    + +

    + +

    + +

    +
    + +
    + + +

    + +

    + +

    + +

    + +

    +

    +
    +
    +
    + +

    +

    +
    + + +
    + +

    +

    +

    +
    + + + + +
    + + caps) > count($profileuser->roles)): + ?> + + + + + +
    caps as $cap => $value) { + if(!$wp_roles->is_role($cap)) { + if($output != '') $output .= ', '; + $output .= $value ? $cap : "Denied: {$cap}"; + } + } + echo $output; + ?>
    +

    + + + +

    +
    +
    + diff --git a/wp-admin/users.php b/wp-admin/users.php new file mode 100644 index 00000000..ab555323 --- /dev/null +++ b/wp-admin/users.php @@ -0,0 +1,328 @@ +id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) { + $update = 'err_admin_role'; + continue; + } + + $user = new WP_User($id); + $user->set_role($_POST['new_role']); + } + + header('Location: users.php?update=' . $update); + +break; + +case 'dodelete': + + check_admin_referer(); + + if ( empty($_POST['users']) ) { + header('Location: users.php'); + } + + if ( !current_user_can('edit_users') ) + die(__('You can’t delete users.')); + + $userids = $_POST['users']; + + $update = 'del'; + foreach ($userids as $id) { + if($id == $current_user->id) { + $update = 'err_admin_del'; + continue; + } + switch($_POST['delete_option']) { + case 'delete': + wp_delete_user($id); + break; + case 'reassign': + wp_delete_user($id, $_POST['reassign_user']); + break; + } + } + + header('Location: users.php?update=' . $update); + +break; + +case 'delete': + + check_admin_referer(); + + if (empty($_POST['users'])) { + header('Location: users.php'); + } + + if ( !current_user_can('edit_users') ) + $error['edit_users'] = __('You can’t delete users.'); + + $userids = $_POST['users']; + + include ('admin-header.php'); +?> +
    +
    +

    +

    +
      +id) { + echo "
    • " . sprintf(__('ID #%1s: %2s The current user will not be deleted.'), $id, $user->user_login) . "
    • \n"; + } else { + echo "
    • " . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "
    • \n"; + $go_delete = true; + } + } + $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login"); + $user_dropdown = ''; + ?> +
    + +

    +
      +
    • +
    • + '.__('Attribute all posts and links to:')." $user_dropdown"; ?>
    • +
    + +

    + +

    + +
    +
    +get_col("SELECT ID FROM $wpdb->users;"); + + foreach($userids as $userid) { + $tmp_user = new WP_User($userid); + $roles = $tmp_user->roles; + $role = array_shift($roles); + $roleclasses[$role][$tmp_user->user_login] = $tmp_user; + } + + ?> + + +

    + +

    + +

    + +

    +

    + +

    +

    + +
    +
      + $error"; + ?> +
    +
    + + +
    +
    +

    + + $roleclass) { + ksort($roleclass); + ?> + + + + + + + + + + + + + + user_email; + $url = $user_object->user_url; + $short_url = str_replace('http://', '', $url); + $short_url = str_replace('www.', '', $short_url); + if ('/' == substr($short_url, -1)) + $short_url = substr($short_url, 0, -1); + if (strlen($short_url) > 35) + $short_url = substr($short_url, 0, 32).'...'; + $style = ('class="alternate"' == $style) ? '' : 'class="alternate"'; + $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$user_object->ID' and post_status = 'publish'"); + if (0 < $numposts) $numposts = "$numposts"; + echo " + + + + + + "; + echo ""; + echo ''; + echo ''; + } + + ?> + + + +
    +

    role_names[$role]; ?>

    +
     
    $email$short_url$numposts'; + if (current_user_can('edit_users')) + echo "".__('Edit').""; + echo '
    + + +

    +'; +foreach($wp_roles->role_names as $role => $name) { + $role_select .= ""; +} +$role_select .= ''; +?> +
      +
    • +
    • '.__('Set the Role of checked users to:')." $role_select"; ?>
    • +
    +

    +
    +
    + +
    +

    +'.sprintf(__('Users can register themselves or you can manually create users here.'), get_settings('siteurl').'/wp-register.php').'

    '; ?> +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +

    + +

    +
    +
    + diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css new file mode 100644 index 00000000..9e7ec06f --- /dev/null +++ b/wp-admin/wp-admin.css @@ -0,0 +1,949 @@ +* html #poststuff { + height: 100%; /* kill peekaboo bug in IE */ +} + +/* This is the Holly Hack \*/ +* html .wrap { height: 1% } +/* For Win IE's eyes only */ + +body { + border: none; +} +a { + border-bottom: 1px solid #69c; + color: #00019b; + text-decoration: none; +} + +a.delete:hover { + background: #c00; + color: #fff; +} + +#planetnews ul { + list-style: none; + margin: 0; + padding: 0; +} + +#planetnews li { + width: 17%; + margin: 1%; + float: left; +} + +#planetnews li a { + display: block; + padding: .5em; + background: #ddd; + height: 6em; + overflow: hidden; +} + +a.edit, a.delete, a.edit:hover, a.delete:hover { + border-bottom: none; + display: block; + padding: 5px 0; + text-align: center; +} + +a.edit:hover { + background: #ccc; + color: #036; +} + +a:visited { + color: #006; +} + +a:hover { +/* border-bottom: 1px solid #3a75ae;*/ + color: #069; +} + +body { + background: #f9fcfe; + color: #000; + margin: 0; + padding: 0; +} + +body, td { + font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana; +} + +fieldset { + border: none; + padding: 3px; +} + +fieldset label.selectit { + display: block; + font-size: 11px; + padding: 0 2px; +} + +fieldset label.selectit:hover { + background: #e9e9e9; +} + +fieldset legend { + padding: .1em .3em; +} + +fieldset span.cat-nest { + display: block; + margin-left: 10px; +} + +fieldset.options { + padding: 1em; +} + +fieldset.options legend { + font-size: 16px; +} + +form, label input { + margin: 0; + padding: 0; +} + +h2 { + border-bottom: .5em solid #f0f8ff; + color: #333; + font: normal 30px/5px serif; + margin: 5px 10px; +} + +h2 small.quickjump { + display: block; + text-align: right; +} + +h2 small.quickjump a { + text-decoration: none; + border-bottom: 0; + font-size: 15px; + background: #f0f8ff; + padding: 5px 10px; +} + +img, #footer a { + border: 0; +} + +input:focus, textarea:focus, label:focus { + background: #fff; + border: 1px solid #686868; +} + +label { + cursor: pointer; +} + +li, dd { + margin-bottom: 6px; +} + +p, li, dl, dd, dt { + line-height: 130%; +} + +textarea, input, select { + background: #f4f4f4; + border: 1px solid #b2b2b2; + color: #000; + font: 13px Verdana, Arial, Helvetica, sans-serif; + margin: 1px; + padding: 3px; +} + +#uploading { + border-style: none; + padding: 0px; + margin-bottom: 16px; + height: 15em; + width: 100%; +/* overflow-y: hidden;*/ +} + +form#upload th { + text-align: right; +} + +form#upload #post_content, form#upload #post_title { + width: 250px; +} + +form#upload #post_content { + height: 50px; +} + +.attpreview { + width: 1px; /* hug */ + text-align: center; +} + +.alignleft { + float: left +} + +.alignright { + float: right; +} + +.alternate { + background: #f1f1f1; +} + +.anchors { + margin: 10px 20px 10px 20px; +} + +.available-theme { + width: 30%; + margin: 0 1em; + float: left; + text-align: center; + height: 28em; + overflow: hidden; +} + +.available-theme a.screenshot { + width: 250px; + height: 200px; + display: block; + margin: auto; + background: #f1f1f1; + border: 1px solid #ccc; + margin-bottom: 10px; + overflow: hidden; +} + +.available-theme a.screenshot:hover { +/* border: 1px solid #666;*/ +} + +.available-theme img { + width: 100%; +} + +.checkbox { + background: #fff; + border: none; + margin: 0; + padding: 0; +} + +.code { + font-family: "Courier New", Courier, monospace; +} + +.commentlist li { + border-bottom: 1px solid #369; + padding: .3em 1em; +} + +.clear { + clear: both; + height: 2px; +} + +.hidden { + display: none; +} + +.navigation { + display: block; + text-align: center; + margin-top: 10px; + margin-bottom: 30px; +} + +.post-categories { + display: inline; + margin: 0; + padding: 0; +} + +.post-categories li, #ed_toolbar { + display: inline; +} + +.quicktags, .search { + background: #ccc; + color: #000; + font: 12px Georgia, "Times New Roman", Times, serif; +} + +.submit input, .submit input:focus, .button { + background: url( images/fade-butt.png ); + border: 3px double #999; + border-left-color: #ccc; + border-top-color: #ccc; + color: #333; + padding: 0.25em; +} + +.submit input:active, .button:active { + background: #f4f4f4; + border: 3px double #ccc; + border-left-color: #999; + border-top-color: #999; +} + +.submit, .editform th, #postcustomsubmit { + text-align: right; +} + +.optiontable { + width: 100%; +} + +.optiontable td, .optiontable th { + padding: .5em; +} + +.optiontable th { + width: 33%; + text-align: right; +} + +.unapproved { + color: #888; +} + +.unapproved a:link { + color: #b9bcff; +} + +.unapproved a:visited { + color: #696dff; +} + +.unapproved a:hover { + color: #009ef0; +} + +.updated { + background: #CFEBF7 url(images/notice.gif) no-repeat 1em ; + border: 1px solid #2580B2; + margin: 1em 5% 10px; + padding: 0 1em 0 3em; +} + +.error { + background: #FFEFF7; + border: 1px solid #c69; + margin: 1em 5% 10px; + padding: 0 1em 0 1em; +} + +.wrap { + background: #fff; + border: 1px solid #ccc; + clear: both; + margin: 15px 5%; + padding: .5em 1em; +} + +.wrap h2 { + margin: .8em 0 .5em; + clear: both; +} + +table .vers, table .name { + text-align: center; +} + +#adminmenu { + background: #6da6d1; + border-top: 3px solid #448abd; + margin: 0; + padding: .2em .2em .2em 2em; +} + +#adminmenu .current, #submenu .current { + font-weight: bold; +} + +#adminmenu a { + color: #000; + font-size: 14px; + font-weight: normal; + margin: 0; + padding: 3px 5px; + text-decoration: none; +} + +#adminmenu a:hover, .current { + background: #ddeaf4; + color: #333; +} + +#adminmenu li, #submenu li { + display: inline; + line-height: 200%; + list-style: none; + text-align: center; +} + +#submenu { + background: #0d324f; + border-bottom: none; + margin: 0; + padding: 3px 2em 0 3em; +} + +#submenu .current { + background: #f9fcfe; + border-top: 1px solid #045290; + border-right: 2px solid #045290; + color: #000; +} + +#submenu a { + border: none; + color: #fff; + font-size: 12px; + padding: .3em .4em .33em; +} + +#submenu a:hover { + background: #ddeaf4; + color: #393939; +} + +#submenu li { + line-height: 170%; +} + + +#categorydiv input, #poststatusdiv input, #commentstatusdiv input, #pingstatusdiv input { + border: none; +} + +#titlediv, #guiddiv { + margin: 0 8px 0 0; + padding: 0px; +} + +#postdiv { + margin: 0 8px 0 0; + padding: 0px; +} + +#postdivrich { + margin: 0px; + padding: 0px; +} + +#content { + margin: 0 0 0 0; + width: 100%; +} + +#titlediv input, #guiddiv input { + margin: 0px; + width: 100%; +} + +#quicktags { + margin-left: -1px; +} + +#currenttheme img { + float: left; + border: 1px solid #666; + margin-right: 1em; + margin-bottom: 1.5em; + width: 300px; +} + +#deletepost:hover { + background: #ce0000; + color: #fff; +} + +#quicktags #ed_strong { + font-weight: bold; +} + +#quicktags #ed_link { + color: blue; + text-decoration: underline; +} + +#quicktags #ed_del { + text-decoration: line-through; +} + +#quicktags #ed_em { + font-style: italic; +} + +#quicktags #ed_code { + font-family: "Courier New", Courier, mono; +} + +#title { + font-size: 1.5em; +} + +#postexcerpt div, #attachmentlinks div { + margin-right: 8px; +} + +#attachmentlinks textarea { + width: 100%; + height: 2.5em; + margin-bottom: 6px; +} + +* html #postexcerpt .dbx-toggle-open, * html #postexcerpt .dbx-toggle-open { + padding-right: 8px; +} + +#excerpt, .attachmentlinks { + margin: 0px; + height: 4em; + width: 100%; +} + +#footer { + clear: both; + text-align: center; +} + +#login { + background: #fff; + border: 1px solid #a2a2a2; + margin: 5em auto; + padding: 1.5em; + width: 25em; +} + +#login #login_error { + background: #c00; + border: 1px solid #a40000; + color: #fff; + font-size: 16px; + font-weight: bold; + padding: .5em; + text-align: center; +} + +#login h1 { + background: url(images/wordpress-logo.png) no-repeat top left; + margin-top: 0; +} + +#login h1 a { + display: block; + text-indent: -1000px; + height: 66px; + border-bottom: none; +} + +#login input { + padding: 3px; +} + +#login ul { + list-style: none; + margin: 0; + padding: 0; +} + +#login ul li { + display: inline; + margin-left: 1.4em; + text-align: center; +} + +#login #log, #pwd { + font-size: 1.7em; + width: 80%; +} + +#login #submit { + font-size: 1.7em; +} + +#postcustom .updatemeta, #postcustom .deletemeta { + margin: auto; +} + +#postcustom table { + border: 1px solid #ccc; + margin: 0px; + width: 100%; +} + +#postcustom table input, #postcustom table textarea { + width: 95%; +} + +#poststuff { + margin-right: 16em; +} + +#save { + width: 15em; +} + +#template div { + margin-right: 190px; +} + +* html #template div { + margin-right: 0px; +} + +#template, #template div, #editcat, #addcat { + zoom: 1; +} + +#template textarea { + font: small 'Courier New', Courier, monospace; + width: 97%; +} + +#templateside { + float: right; + width: 170px; +} + +#templateside h3, #postcustom p { + margin: 0; +} + +#templateside ol, #templateside ul { + list-style: none; + margin: .5em; + padding: 0; +} + +#user_info { + position: absolute; + right: 1em; + top: 0; + color: #fff; + font-size: .9em; +} + +#user_info a { + color: #fff; +} + +#wphead { + background: #14568a; + padding: .8em 19em .8em 2em; + color: #c3def1; +} + +#wphead a { + color: #fff; +} + +#wphead h1 { + font-size: 2.5em; + font-weight: normal; + letter-spacing: -.05em; + margin: 0; + font-family: Georgia, "Times New Roman", Times, serif +} + +#wphead h1 span { + font-size: .4em; + letter-spacing: 0; +} + +#zeitgeist { + background: #eee; + border: 1px solid #69c; + float: right; + font-size: 90%; + margin-bottom: .5em; + margin-left: 1em; + margin-top: .5em; + padding: 1em; + width: 40%; +} + +#zeitgeist h2, fieldset legend a { + border-bottom: none; +} + +#zeitgeist h2 { + margin-top: .4em; +} + +#zeitgeist h3 { + border-bottom: 1px solid #ccc; + font-size: 16px; + margin: 1em 0 0; +} + +#zeitgeist h3 cite { + font-size: 12px; + font-style: normal; +} + +#zeitgeist li, #zeitgeist p { + margin: .2em 0; +} + +#zeitgeist ul { + margin: 0 0 .3em .6em; + padding: 0 0 0 .6em; +} + +.active td { + background: #BEB; +} +.active .name { + background: #9C9; +} +.alternate.active td { + background: #ADA; +} +.alternate.active .name { + background: #8B8; +} + +/* A handy div class for hiding controls. + Some browsers will disable them when you + set display:none; */ +.zerosize { + height: 0px; + width: 0px; + margin: 0px; + border: 0px; + padding: 0px; + overflow: hidden; + position: absolute; +} + +/* Box stuff */ +.dbx-clone { + position:absolute; + visibility:hidden; +} +.dbx-clone, .dbx-clone .dbx-handle-cursor { + cursor:move !important; +} +.dbx-dummy { + display:block; + width:0; + height:0; + overflow:hidden; +} +.dbx-group, .dbx-box, .dbx-handle { + position:relative; + display:block; +} + +#grabit { + width: 188px; +} + +* html #themeselect { + padding: 0px 3px; + height: 22px; +} + +/**************************************************************** + avoid padding, margins or borders on dbx-box, + to reduce visual discrepancies between it and the clone. + overall, dbx-box is best left as visually unstyled as possible +*****************************************************************/ +.dbx-box { + margin:0; + padding:0; + border:none; +} + +/* Can change this */ +#moremeta fieldset, #advancedstuff fieldset { + margin-bottom: 1em; +} +#moremeta fieldset div { + margin: 2px 0 0 0px; + padding: 7px; +} +#moremeta { + line-height: 130%; + margin-right: 15px; + position: absolute; + right: 5%; + width: 14.5em; +} +#moremeta select { + width: 96%; +} + +#slugdiv input, #passworddiv input, #authordiv select, #thumbdiv input, #parentdiv input { + margin-top: .5em; + width: 90%; +} + +#moremeta h3, #advancedstuff h3 { + padding: 3px; + font-weight: normal; + font-size: 13px; +} + +#advancedstuff div { + margin-top: .5em; +} + +#categorydiv div div { + height: 12em; + overflow: auto; +} + +#ajaxcat input { + border: 1px solid #ccc; +} + +#your-profile fieldset { + border: 1px solid #ccc; + float: left; + width: 40%; + padding: .5em 2em; + margin: 1em; +} + +#your-profile fieldset input { + width: 100%; + font-size: 20px; + padding: 2px; +} + +#your-profile fieldset textarea { + width: 100%; + padding: 2px; +} + +#your-profile legend { + font-family: Georgia, "Times New Roman", Times, serif; + font-size: 22px; +} + +/* default box styles */ + +/* toggle state of inner content area */ +.dbx-box-open .dbx-content { + display: block; +} +.dbx-box-closed .dbx-content { + display: none; +} + +#moremeta .dbx-content { + background: url(images/box-butt.gif) no-repeat bottom right; + padding-bottom: 15px; + padding-right: 2px; +} + +/* handles */ + +.dbx-handle { + background: #2685af; + padding: 6px 1em 2px; + font-size: 12px; + margin: 0; + color: #E3EFF5; +} + +#moremeta .dbx-handle { + padding: 6px 1em 2px; + font-size: 12px; + background: #2685af url(images/box-head.gif) no-repeat right; +} + +#moremeta .dbx-box { + background: url(images/box-bg.gif) repeat-y right; +} + +/* handle cursors */ +.dbx-handle-cursor { + cursor: move; +} + +/* toggle images */ +a.dbx-toggle, a.dbx-toggle:visited { + display:block; + overflow: hidden; + background-image: url( images/toggle.gif ); + position: absolute; + top: 0px; + right: 0px; + background-repeat: no-repeat; + border: 0px; + margin: 0px; + padding: 0px; +} + +#moremeta a.dbx-toggle, #moremeta a.dbx-toggle-open:visited { + height: 25px; + width: 27px; + background-position: 0 0px; +} + +#moremeta a.dbx-toggle-open, #moremeta a.dbx-toggle-open:visited { + height: 25px; + width: 27px; + background-position: 0 -25px; +} + +#advancedstuff a.dbx-toggle, #advancedstuff a.dbx-toggle-open:visited { + height: 22px; + width: 22px; + background-position: 0 -3px; +} + +#advancedstuff a.dbx-toggle-open, #advancedstuff a.dbx-toggle-open:visited { + height: 22px; + width: 22px; + background-position: 0 -28px; +} + +#categorychecklist { + margin-right: 6px; +} + +/* additional clone styles */ +.dbx-clone { + opacity: 0.8; + -moz-opacity: 0.8; + -khtml-opacity: 0.8; + filter: alpha(opacity=80); +} + +#newcat { width: 120px; margin-right: 5px; } +input#catadd { background: #a4a4a4; + border-bottom: 1px solid #898989; + border-left: 1px solid #bcbcbc; + border-right: 1px solid #898989; + border-top: 1px solid #bcbcbc; + color: #fff; + font-size: 10px; + padding: 0; + margin: 0; + font-weight: bold; + height: 20px; + margin-bottom: 2px; + text-align: center; + width: 37px; } +#howto { + font-size: 11px; + margin: 0 5px; + display: block; +} +#jaxcat { + margin: 0; + padding: 0; +} \ No newline at end of file diff --git a/wp-admin/xfn.js b/wp-admin/xfn.js new file mode 100644 index 00000000..54c82fbf --- /dev/null +++ b/wp-admin/xfn.js @@ -0,0 +1,46 @@ +function GetElementsWithClassName(elementName, className) { + var allElements = document.getElementsByTagName(elementName); + var elemColl = new Array(); + for (i = 0; i < allElements.length; i++) { + if (allElements[i].className == className) { + elemColl[elemColl.length] = allElements[i]; + } + } + return elemColl; +} + +function meChecked() { + var undefined; + var eMe = document.getElementById('me'); + if (eMe == undefined) return false; + else return eMe.checked; +} + +function upit() { + var isMe = meChecked(); //document.getElementById('me').checked; + var inputColl = GetElementsWithClassName('input', 'valinp'); + var results = document.getElementById('link_rel'); + var linkText, linkUrl, inputs = ''; + for (i = 0; i < inputColl.length; i++) { + inputColl[i].disabled = isMe; + inputColl[i].parentNode.className = isMe ? 'disabled' : ''; + if (!isMe && inputColl[i].checked && inputColl[i].value != '') { + inputs += inputColl[i].value + ' '; + } + } + inputs = inputs.substr(0,inputs.length - 1); + if (isMe) inputs='me'; + results.value = inputs; + } + +function blurry() { + if (!document.getElementById) return; + + var aInputs = document.getElementsByTagName('input'); + + for (var i = 0; i < aInputs.length; i++) { + aInputs[i].onclick = aInputs[i].onkeyup = upit; + } +} + +addLoadEvent(blurry); \ No newline at end of file diff --git a/wp-atom.php b/wp-atom.php new file mode 100644 index 00000000..feb2845b --- /dev/null +++ b/wp-atom.php @@ -0,0 +1,45 @@ + +'; ?> + + > + <?php bloginfo_rss('name') ?> + + + + Copyright + WordPress + + + + + + + <![CDATA[<?php the_title_rss() ?>]]> + + + + + + ]]> + + ]]> + + + + + + diff --git a/wp-blog-header.php b/wp-blog-header.php new file mode 100644 index 00000000..c087324f --- /dev/null +++ b/wp-blog-header.php @@ -0,0 +1,21 @@ +wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file."); +} + +$wp_did_header = true; + +require_once( dirname(__FILE__) . '/wp-config.php'); + +wp(); +gzip_compression(); + +require_once(ABSPATH . WPINC . '/template-loader.php'); + +endif; + +?> \ No newline at end of file diff --git a/wp-comments-post.php b/wp-comments-post.php new file mode 100644 index 00000000..953de684 --- /dev/null +++ b/wp-comments-post.php @@ -0,0 +1,64 @@ +get_row("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = '$comment_post_ID'"); + +if ( empty($status->comment_status) ) { + do_action('comment_id_not_found', $comment_post_ID); + exit; +} elseif ( 'closed' == $status->comment_status ) { + do_action('comment_closed', $comment_post_ID); + die( __('Sorry, comments are closed for this item.') ); +} elseif ( 'draft' == $status->post_status ) { + do_action('comment_on_draft', $comment_post_ID); + exit; +} + +$comment_author = trim($_POST['author']); +$comment_author_email = trim($_POST['email']); +$comment_author_url = trim($_POST['url']); +$comment_content = trim($_POST['comment']); + +// If the user is logged in +get_currentuserinfo(); +if ( $user_ID ) : + $comment_author = $wpdb->escape($user_identity); + $comment_author_email = $wpdb->escape($user_email); + $comment_author_url = $wpdb->escape($user_url); +else : + if ( get_option('comment_registration') ) + die( __('Sorry, you must be logged in to post a comment.') ); +endif; + +$comment_type = ''; + +if ( get_settings('require_name_email') && !$user_ID ) { + if ( 6 > strlen($comment_author_email) || '' == $comment_author ) + die( __('Error: please fill the required fields (name, email).') ); + elseif ( !is_email($comment_author_email)) + die( __('Error: please enter a valid email address.') ); +} + +if ( '' == $comment_content ) + die( __('Error: please type a comment.') ); + +$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID'); + +$comment_id = wp_new_comment( $commentdata ); + +if ( !$user_ID ) : + $comment = get_comment($comment_id); + setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN); + setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN); + setcookie('comment_author_url_' . COOKIEHASH, clean_url($comment->comment_author_url), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN); +endif; + +$location = ( empty( $_POST['redirect_to'] ) ) ? get_permalink( $comment_post_ID ) : $_POST['redirect_to']; + +wp_redirect( $location ); + +?> diff --git a/wp-commentsrss2.php b/wp-commentsrss2.php new file mode 100644 index 00000000..caddaa05 --- /dev/null +++ b/wp-commentsrss2.php @@ -0,0 +1,86 @@ +'; +?> + + + + + <?php if (is_single() || is_page() ) { printf(__('Comments on: %s'), get_the_title_rss()); } else { printf(__('Comments for %s'), get_bloginfo_rss("name")); } ?> + + + + http://wordpress.org/?v= + +get_results("SELECT comment_ID, comment_author, comment_author_email, + comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, + $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments + LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id' + AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status IN ('publish', 'static', 'object') + AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "' + ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') ); + } else { // if no post id passed in, we'll just ue the last 10 comments. + $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, + comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, + $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments + LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status IN ('publish', 'static', 'object') + AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "' + ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') ); + } + // this line is WordPress' motor, do not delete it. + if ($comments) { + foreach ($comments as $comment) { + // Some plugins may need to know the metadata + // associated with this comment's post: + get_post_custom($comment->comment_post_ID); +?> + + <?php if ( ! (is_single() || is_page()) ) { + $title = get_the_title($comment->comment_post_ID); + $title = apply_filters('the_title', $title); + $title = apply_filters('the_title_rss', $title); + printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss()); + } else { + printf(__('by: %s'), get_comment_author_rss()); + } ?> + + + + post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) { + ?> + + ]]> + + + ]]> + + + + + diff --git a/wp-config-sample.php b/wp-config-sample.php new file mode 100644 index 00000000..5cc89738 --- /dev/null +++ b/wp-config-sample.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/wp-content/index.php b/wp-content/index.php new file mode 100644 index 00000000..3d5acf05 --- /dev/null +++ b/wp-content/index.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/wp-content/plugins/akismet/akismet.php b/wp-content/plugins/akismet/akismet.php new file mode 100644 index 00000000..6adb649b --- /dev/null +++ b/wp-content/plugins/akismet/akismet.php @@ -0,0 +1,294 @@ +WordPress.com API key to use this service. You can review the spam it catches under "Manage" and it automatically deletes old spam after 15 days. Hat tip: Michael Hampton and Chris J. Davis for help with the plugin. +Author: Matt Mullenweg +Version: 1.14 +Author URI: http://photomatt.net/ +*/ + +add_action('admin_menu', 'ksd_config_page'); + +function ksd_config_page() { + global $wpdb; + if ( function_exists('add_submenu_page') ) + add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 1, __FILE__, 'akismet_conf'); +} + +function akismet_conf() { + if ( isset($_POST['submit']) ) { + check_admin_referer(); + $key = preg_replace('/[^a-h0-9]/i', '', $_POST['key']); + if ( akismet_verify_key( $key ) ) + update_option('wordpress_api_key', $key); + else + $invalid_key = true; + } + if ( !akismet_verify_key( get_option('wordpress_api_key') ) ) + $invalid_key = true; +?> + +
    +

    +

    Akismet will greatly reduce or even completely eliminate the comment and trackback spam you get on your site. If one does happen to get through, simply mark it as "spam" on the moderation screen and Akismet will learn from the mistakes. If you don\'t have a WordPress.com account yet, you can get one at WordPress.com.'), 'http://akismet.com/', 'http://wordpress.com/api-keys/'); ?>

    + +
    +

    + +

    + +

    (What is this?'); ?>)

    +

    +
    +
    +

    ".__('Akismet is not active.')." ".sprintf(__('You must enter your WordPress.com API key for it to work.'), "plugins.php?page=$path")."

    + + "; + } + add_action('admin_footer', 'akismet_warning'); + return; +} + +$ksd_api_host = get_option('wordpress_api_key') . '.rest.akismet.com'; +$ksd_api_port = 80; +$ksd_user_agent = "WordPress/$wp_version | Akismet/1.14"; + +// Returns array with headers in $response[0] and entity in $response[1] +function ksd_http_post($request, $host, $path, $port = 80) { + global $ksd_user_agent; + + $http_request = "POST $path HTTP/1.0\r\n"; + $http_request .= "Host: $host\r\n"; + $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_settings('blog_charset') . "\r\n"; + $http_request .= "Content-Length: " . strlen($request) . "\r\n"; + $http_request .= "User-Agent: $ksd_user_agent\r\n"; + $http_request .= "\r\n"; + $http_request .= $request; + + $response = ''; + if( false !== ( $fs = @fsockopen($host, $port, $errno, $errstr, 3) ) ) { + fwrite($fs, $http_request); + + while ( !feof($fs) ) + $response .= fgets($fs, 1160); // One TCP-IP packet + fclose($fs); + $response = explode("\r\n\r\n", $response, 2); + } + return $response; +} + +function ksd_auto_check_comment( $comment ) { + global $auto_comment_approved, $ksd_api_host, $ksd_api_port; + $comment['user_ip'] = $_SERVER['REMOTE_ADDR']; + $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT']; + $comment['referrer'] = $_SERVER['HTTP_REFERER']; + $comment['blog'] = get_option('home'); + + $ignore = array( 'HTTP_COOKIE' ); + + foreach ( $_SERVER as $key => $value ) + if ( !in_array( $key, $ignore ) ) + $comment["$key"] = $value; + + $query_string = ''; + foreach ( $comment as $key => $data ) + $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; + + $response = ksd_http_post($query_string, $ksd_api_host, '/1.1/comment-check', $ksd_api_port); + if ( 'true' == $response[1] ) { + $auto_comment_approved = 'spam'; + update_option( 'akismet_spam_count', get_option('akismet_spam_count') + 1 ); + } + akismet_delete_old(); + return $comment; +} + +function akismet_delete_old() { + global $wpdb; + $now_gmt = current_time('mysql', 1); + $wpdb->query("DELETE FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'"); + $n = mt_rand(1, 5); + if ( $n % 5 ) + $wpdb->query("OPTIMIZE TABLE $wpdb->comments"); +} + +function ksd_auto_approved( $approved ) { + global $auto_comment_approved; + if ( 'spam' == $auto_comment_approved ) + $approved = $auto_comment_approved; + return $approved; +} + +function ksd_submit_nonspam_comment ( $comment_id ) { + global $wpdb, $ksd_api_host, $ksd_api_port; + + $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'"); + if ( !$comment ) // it was deleted + return; + $comment->blog = get_option('home'); + $query_string = ''; + foreach ( $comment as $key => $data ) + $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; + $response = ksd_http_post($query_string, $ksd_api_host, "/1.1/submit-ham", $ksd_api_port); +} + +function ksd_submit_spam_comment ( $comment_id ) { + global $wpdb, $ksd_api_host, $ksd_api_port; + + $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'"); + if ( !$comment ) // it was deleted + return; + if ( 'spam' != $comment->comment_approved ) + return; + $comment->blog = get_option('home'); + $query_string = ''; + foreach ( $comment as $key => $data ) + $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; + + $response = ksd_http_post($query_string, $ksd_api_host, "/1.1/submit-spam", $ksd_api_port); +} + +add_action('wp_set_comment_status', 'ksd_submit_spam_comment'); +add_action('edit_comment', 'ksd_submit_spam_comment'); +add_action('preprocess_comment', 'ksd_auto_check_comment', 1); +add_filter('pre_comment_approved', 'ksd_auto_approved'); + + +function ksd_spam_count() { + global $wpdb, $comments; + $count = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'"); + return $count; +} + +function ksd_manage_page() { + global $wpdb; + $count = sprintf(__('Akismet Spam (%s)'), ksd_spam_count()); + if ( function_exists('add_management_page') ) + add_management_page(__('Akismet Spam'), $count, 1, __FILE__, 'ksd_caught'); +} + +function ksd_caught() { + global $wpdb, $comment; + if (isset($_POST['submit']) && 'recover' == $_POST['action'] && ! empty($_POST['not_spam'])) { + $i = 0; + foreach ($_POST['not_spam'] as $comment): + $comment = (int) $comment; + if ( function_exists('wp_set_comment_status') ) + wp_set_comment_status($comment, 'approve'); + else + $wpdb->query("UPDATE $wpdb->comments SET comment_approved = '1' WHERE comment_ID = '$comment'"); + ksd_submit_nonspam_comment($comment); + ++$i; + endforeach; + echo '

    ' . sprintf(__('%1$s comments recovered.'), $i) . "

    "; + } + if ('delete' == $_POST['action']) { + $delete_time = addslashes( $_POST['display_time'] ); + $nuked = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" ); + if (isset($nuked)) { + echo '

    '; + if ($nuked) { + _e('All spam deleted.'); + } + echo "

    "; + } + } +?> +
    +

    + +

    %1$s spam for you since you installed it.'), number_format($count) ); ?>

    +'.__('You have no spam currently in the queue. Must be your lucky day. :)').'

    '; + echo '
    '; +} else { + echo '

    '.__('You can delete all of the spam from your database with a single click. This operation cannot be undone, so you may wish to check to ensure that no legitimate comments got through first. Spam is automatically deleted after 15 days, so don’t sweat it.').'

    '; +?> +
    + +    + +
    + +
    +

    +'.__('These are the latest comments identified as spam by Akismet. If you see any mistakes, simply mark the comment as "not spam" and Akismet will learn from the submission. If you wish to recover a comment from spam, simply select the comment, and click Not Spam. After 15 days we clean out the junk for you.').'

    '; ?> +get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT 150"); + +if ($comments) { +?> +
    + +
      +comment_date); + $post = get_post($comment->comment_post_ID); + $post_title = $post->post_title; + if ($i % 2) $class = 'class="alternate"'; + else $class = ''; + echo "\n\t
    1. "; + ?> +

      comment_author_email) { ?>| comment_author_url && 'http://' != $comment->comment_author_url) { ?> | | |

      + + + +
    +

    + +

    +
    +
    +'.__('Spam').''; + echo '

    '.sprintf(__('Akismet has protected your site from %3$s spam comments.'), 'http://akismet.com/', "edit.php?page=$path", number_format($count) ).'

    '; +} + +add_action('activity_box_end', 'akismet_stats'); + +?> diff --git a/wp-content/plugins/hello.php b/wp-content/plugins/hello.php new file mode 100644 index 00000000..e03dbcc3 --- /dev/null +++ b/wp-content/plugins/hello.php @@ -0,0 +1,73 @@ +Hello, Dolly in the upper right of your admin screen on every page. +Author: Matt Mullenweg +Version: 1.5 +Author URI: http://photomatt.net/ +*/ + +// These are the lyrics to Hello Dolly +$lyrics = "Hello, Dolly +Well, hello, Dolly +It's so nice to have you back where you belong +You're lookin' swell, Dolly +I can tell, Dolly +You're still glowin', you're still crowin' +You're still goin' strong +We feel the room swayin' +While the band's playin' +One of your old favourite songs from way back when +So, take her wrap, fellas +Find her an empty lap, fellas +Dolly'll never go away again +Hello, Dolly +Well, hello, Dolly +It's so nice to have you back where you belong +You're lookin' swell, Dolly +I can tell, Dolly +You're still glowin', you're still crowin' +You're still goin' strong +We feel the room swayin' +While the band's playin' +One of your old favourite songs from way back when +Golly, gee, fellas +Find her a vacant knee, fellas +Dolly'll never go away +Dolly'll never go away +Dolly'll never go away again"; + +// Here we split it into lines +$lyrics = explode("\n", $lyrics); +// And then randomly choose a line +$chosen = wptexturize( $lyrics[ mt_rand(0, count($lyrics) ) ] ); + +// This just echoes the chosen line, we'll position it later +function hello_dolly() { + global $chosen; + echo "

    $chosen

    "; +} + +// Now we set that function up to execute when the admin_footer action is called +add_action('admin_footer', 'hello_dolly'); + +// We need some CSS to position the paragraph +function dolly_css() { + echo " + + "; +} + +add_action('admin_head', 'dolly_css'); + +?> \ No newline at end of file diff --git a/wp-content/plugins/wp-db-backup.php b/wp-content/plugins/wp-db-backup.php new file mode 100644 index 00000000..d8d71421 --- /dev/null +++ b/wp-content/plugins/wp-db-backup.php @@ -0,0 +1,889 @@ +backup_dir = trailingslashit($this->backup_dir); + $this->basename = preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', __FILE__); + + if (isset($_POST['do_backup'])) { + switch($_POST['do_backup']) { + case 'backup': + $this->perform_backup(); + break; + case 'fragments': + add_action('admin_menu', array(&$this, 'fragment_menu')); + break; + } + } elseif (isset($_GET['fragment'] )) { + add_action('init', array(&$this, 'init')); + } elseif (isset($_GET['backup'] )) { + add_action('init', array(&$this, 'init')); + } else { + add_action('admin_menu', array(&$this, 'admin_menu')); + } + } + + function init() { + global $user_level; + get_currentuserinfo(); + + if ($user_level < 9) die(__('Need higher user level.')); + + if (isset($_GET['backup'])) { + $via = isset($_GET['via']) ? $_GET['via'] : 'http'; + + $this->backup_file = $_GET['backup']; + + switch($via) { + case 'smtp': + case 'email': + $this->deliver_backup ($this->backup_file, 'smtp', $_GET['recipient']); + echo ' + + + '; + break; + default: + $this->deliver_backup ($this->backup_file, $via); + } + die(); + } + if (isset($_GET['fragment'] )) { + list($table, $segment, $filename) = explode(':', $_GET['fragment']); + $this->backup_fragment($table, $segment, $filename); + } + + die(); + } + + function build_backup_script() { + global $table_prefix, $wpdb; + + $datum = date("Ymd_B"); + $backup_filename = DB_NAME . "_$table_prefix$datum.sql"; + if ($this->gzip()) $backup_filename .= '.gz'; + + echo "
    "; + //echo "
    " . print_r($_POST, 1) . "
    "; + echo '

    ' . __('Backup') . '

    +
    ' . __('Progress') . ' +

    ' . + __('DO NOT DO THE FOLLOWING AS IT WILL CAUSE YOUR BACKUP TO FAIL:'). + '

    +
      +
    1. '.__('Close this browser').'
    2. +
    3. '.__('Reload this page').'
    4. +
    5. '.__('Click the Stop or Back buttons in your browser').'
    6. +
    +

    ' . __('Progress:') . '

    +
     
    +
    +
    +
    + + +
    + '; + } + + function backup_fragment($table, $segment, $filename) { + global $table_prefix, $wpdb; + + echo "$table:$segment:$filename"; + + if($table == '') { + $msg = __('Creating backup file...'); + } else { + if($segment == -1) { + $msg = sprintf(__('Finished backing up table \\"%s\\".'), $table); + } else { + $msg = sprintf(__('Backing up table \\"%s\\"...'), $table); + } + } + + echo ' + '; + } + else { + echo ' + window.parent.nextStep(); + //--> + '; + } + + die(); + } + + function perform_backup() { + // are we backing up any other tables? + $also_backup = array(); + if (isset($_POST['other_tables'])) { + $also_backup = $_POST['other_tables']; + } + + $core_tables = $_POST['core_tables']; + $this->backup_file = $this->db_backup($core_tables, $also_backup); + if (FALSE !== $backup_file) { + if ('smtp' == $_POST['deliver']) { + $this->deliver_backup ($this->backup_file, $_POST['deliver'], $_POST['backup_recipient']); + } elseif ('http' == $_POST['deliver']) { + $this_basename = preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', __FILE__); + header('Refresh: 3; ' . get_settings('siteurl') . "/wp-admin/edit.php?page={$this_basename}&backup={$this->backup_file}"); + } + // we do this to say we're done. + $this->backup_complete = true; + } + } + + /////////////////////////////// + function admin_menu() { + add_management_page(__('Backup'), __('Backup'), 9, basename(__FILE__), array(&$this, 'backup_menu')); + } + + function fragment_menu() { + add_management_page(__('Backup'), __('Backup'), 9, basename(__FILE__), array(&$this, 'build_backup_script')); + } + + ///////////////////////////////////////////////////////// + function sql_addslashes($a_string = '', $is_like = FALSE) + { + /* + Better addslashes for SQL queries. + Taken from phpMyAdmin. + */ + if ($is_like) { + $a_string = str_replace('\\', '\\\\\\\\', $a_string); + } else { + $a_string = str_replace('\\', '\\\\', $a_string); + } + $a_string = str_replace('\'', '\\\'', $a_string); + + return $a_string; + } // function sql_addslashes($a_string = '', $is_like = FALSE) + + /////////////////////////////////////////////////////////// + function backquote($a_name) + { + /* + Add backqouotes to tables and db-names in + SQL queries. Taken from phpMyAdmin. + */ + if (!empty($a_name) && $a_name != '*') { + if (is_array($a_name)) { + $result = array(); + reset($a_name); + while(list($key, $val) = each($a_name)) { + $result[$key] = '`' . $val . '`'; + } + return $result; + } else { + return '`' . $a_name . '`'; + } + } else { + return $a_name; + } + } // function backquote($a_name, $do_it = TRUE) + + ///////////// + function open($filename = '', $mode = 'w') { + if ('' == $filename) return false; + if ($this->gzip()) { + $fp = @gzopen($filename, $mode); + } else { + $fp = @fopen($filename, $mode); + } + return $fp; + } + + ////////////// + function close($fp) { + if ($this->gzip()) { + gzclose($fp); + } else { + fclose($fp); + } + } + + ////////////// + function stow($query_line) { + if ($this->gzip()) { + if(@gzwrite($this->fp, $query_line) === FALSE) { + backup_error(__('There was an error writing a line to the backup script:')); + backup_error('  ' . $query_line); + } + } else { + if(@fwrite($this->fp, $query_line) === FALSE) { + backup_error(__('There was an error writing a line to the backup script:')); + backup_error('  ' . $query_line); + } + } + } + + function backup_error($err) { + if(count($this->backup_errors) < 20) { + $this->backup_errors[] = $err; + } elseif(count($this->backup_errors) == 20) { + $this->backup_errors[] = __('Subsequent errors have been omitted from this log.'); + } + } + + ///////////////////////////// + function backup_table($table, $segment = 'none') { + global $wpdb; + + /* + Taken partially from phpMyAdmin and partially from + Alain Wolf, Zurich - Switzerland + Website: http://restkultur.ch/personal/wolf/scripts/db_backup/ + + Modified by Scott Merril (http://www.skippy.net/) + to use the WordPress $wpdb object + */ + + $table_structure = $wpdb->get_results("DESCRIBE $table"); + if (! $table_structure) { + backup_errors(__('Error getting table details') . ": $table"); + return FALSE; + } + + if(($segment == 'none') || ($segment == 0)) { + // + // Add SQL statement to drop existing table + $this->stow("\n\n"); + $this->stow("#\n"); + $this->stow("# Delete any existing table " . $this->backquote($table) . "\n"); + $this->stow("#\n"); + $this->stow("\n"); + $this->stow("DROP TABLE IF EXISTS " . $this->backquote($table) . ";\n"); + + // + //Table structure + // Comment in SQL-file + $this->stow("\n\n"); + $this->stow("#\n"); + $this->stow("# Table structure of table " . $this->backquote($table) . "\n"); + $this->stow("#\n"); + $this->stow("\n"); + + $create_table = $wpdb->get_results("SHOW CREATE TABLE $table", ARRAY_N); + if (FALSE === $create_table) { + $this->backup_error(sprintf(__("Error with SHOW CREATE TABLE for %s."), $table)); + $this->stow("#\n# Error with SHOW CREATE TABLE for $table!\n#\n"); + } + $this->stow($create_table[0][1] . ' ;'); + + if (FALSE === $table_structure) { + $this->backup_error(sprintf(__("Error getting table structure of %s"), $table)); + $this->stow("#\n# Error getting table structure of $table!\n#\n"); + } + + // + // Comment in SQL-file + $this->stow("\n\n"); + $this->stow("#\n"); + $this->stow('# Data contents of table ' . $this->backquote($table) . "\n"); + $this->stow("#\n"); + } + + if(($segment == 'none') || ($segment >= 0)) { + $ints = array(); + foreach ($table_structure as $struct) { + if ( (0 === strpos($struct->Type, 'tinyint')) || + (0 === strpos(strtolower($struct->Type), 'smallint')) || + (0 === strpos(strtolower($struct->Type), 'mediumint')) || + (0 === strpos(strtolower($struct->Type), 'int')) || + (0 === strpos(strtolower($struct->Type), 'bigint')) || + (0 === strpos(strtolower($struct->Type), 'timestamp')) ) { + $ints[strtolower($struct->Field)] = "1"; + } + } + + + // Batch by $row_inc + + if($segment == 'none') { + $row_start = 0; + $row_inc = ROWS_PER_SEGMENT; + } else { + $row_start = $segment * ROWS_PER_SEGMENT; + $row_inc = ROWS_PER_SEGMENT; + } + + do { + if ( !ini_get('safe_mode')) @set_time_limit(15*60); + $table_data = $wpdb->get_results("SELECT * FROM $table LIMIT {$row_start}, {$row_inc}", ARRAY_A); + + /* + if (FALSE === $table_data) { + $wp_backup_error .= "Error getting table contents from $table\r\n"; + fwrite($fp, "#\n# Error getting table contents fom $table!\n#\n"); + } + */ + + $entries = 'INSERT INTO ' . $this->backquote($table) . ' VALUES ('; + // \x08\\x09, not required + $search = array("\x00", "\x0a", "\x0d", "\x1a"); + $replace = array('\0', '\n', '\r', '\Z'); + if($table_data) { + foreach ($table_data as $row) { + $values = array(); + foreach ($row as $key => $value) { + if ($ints[strtolower($key)]) { + $values[] = $value; + } else { + $values[] = "'" . str_replace($search, $replace, $this->sql_addslashes($value)) . "'"; + } + } + $this->stow(" \n" . $entries . implode(', ', $values) . ') ;'); + } + $row_start += $row_inc; + } + } while((count($table_data) > 0) and ($segment=='none')); + } + + + if(($segment == 'none') || ($segment < 0)) { + // Create footer/closing comment in SQL-file + $this->stow("\n"); + $this->stow("#\n"); + $this->stow("# End of data contents of table " . $this->backquote($table) . "\n"); + $this->stow("# --------------------------------------------------------\n"); + $this->stow("\n"); + } + + } // end backup_table() + + function return_bytes($val) { + $val = trim($val); + $last = strtolower($val{strlen($val)-1}); + switch($last) { + // The 'G' modifier is available since PHP 5.1.0 + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + + return $val; + } + + //////////////////////////// + function db_backup($core_tables, $other_tables) { + global $table_prefix, $wpdb; + + $datum = date("Ymd_B"); + $wp_backup_filename = DB_NAME . "_$table_prefix$datum.sql"; + if ($this->gzip()) { + $wp_backup_filename .= '.gz'; + } + + if (is_writable(ABSPATH . $this->backup_dir)) { + $this->fp = $this->open(ABSPATH . $this->backup_dir . $wp_backup_filename); + if(!$this->fp) { + $this->backup_error(__('Could not open the backup file for writing!')); + return false; + } + } else { + $this->backup_error(__('The backup directory is not writeable!')); + return false; + } + + //Begin new backup of MySql + $this->stow("# WordPress MySQL database backup\n"); + $this->stow("#\n"); + $this->stow("# Generated: " . date("l j. F Y H:i T") . "\n"); + $this->stow("# Hostname: " . DB_HOST . "\n"); + $this->stow("# Database: " . $this->backquote(DB_NAME) . "\n"); + $this->stow("# --------------------------------------------------------\n"); + + if ( (is_array($other_tables)) && (count($other_tables) > 0) ) + $tables = array_merge($core_tables, $other_tables); + else + $tables = $core_tables; + + foreach ($tables as $table) { + // Increase script execution time-limit to 15 min for every table. + if ( !ini_get('safe_mode')) @set_time_limit(15*60); + // Create the SQL statements + $this->stow("# --------------------------------------------------------\n"); + $this->stow("# Table: " . $this->backquote($table) . "\n"); + $this->stow("# --------------------------------------------------------\n"); + $this->backup_table($table); + } + + $this->close($this->fp); + + if (count($this->backup_errors)) { + return false; + } else { + return $wp_backup_filename; + } + + } //wp_db_backup + + /////////////////////////// + function deliver_backup ($filename = '', $delivery = 'http', $recipient = '') { + if ('' == $filename) { return FALSE; } + + $diskfile = ABSPATH . $this->backup_dir . $filename; + if ('http' == $delivery) { + if (! file_exists($diskfile)) { + $msg = sprintf(__('File not found:%s'), "
    $filename
    "); + $this_basename = preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', __FILE__); + $msg .= '
    ' . __('Return to Backup'); + die($msg); + } + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Length: ' . filesize($diskfile)); + header("Content-Disposition: attachment; filename=$filename"); + readfile($diskfile); + unlink($diskfile); + } elseif ('smtp' == $delivery) { + if (! file_exists($diskfile)) return false; + + if (! is_email ($recipient)) { + $recipient = get_settings('admin_email'); + } + $randomish = md5(time()); + $boundary = "==WPBACKUP-BY-SKIPPY-$randomish"; + $fp = fopen($diskfile,"rb"); + $file = fread($fp,filesize($diskfile)); + $this->close($fp); + $data = chunk_split(base64_encode($file)); + $headers = "MIME-Version: 1.0\n"; + $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\n"; + $headers .= 'From: ' . get_settings('admin_email') . "\n"; + + $message = sprintf(__("Attached to this email is\n %1s\n Size:%2s kilobytes\n"), $filename, round(filesize($diskfile)/1024)); + // Add a multipart boundary above the plain message + $message = "This is a multi-part message in MIME format.\n\n" . + "--{$boundary}\n" . + "Content-Type: text/plain; charset=\"utf-8\"\n" . + "Content-Transfer-Encoding: 7bit\n\n" . + $message . "\n\n"; + + // Add file attachment to the message + $message .= "--{$boundary}\n" . + "Content-Type: application/octet-stream;\n" . + " name=\"{$filename}\"\n" . + "Content-Disposition: attachment;\n" . + " filename=\"{$filename}\"\n" . + "Content-Transfer-Encoding: base64\n\n" . + $data . "\n\n" . + "--{$boundary}--\n"; + + if (function_exists('wp_mail')) { + wp_mail ($recipient, get_bloginfo('name') . ' ' . __('Database Backup'), $message, $headers); + } else { + mail ($recipient, get_bloginfo('name') . ' ' . __('Database Backup'), $message, $headers); + } + + unlink($diskfile); + } + return; + } + + //////////////////////////// + function backup_menu() { + global $table_prefix, $wpdb; + $feedback = ''; + $WHOOPS = FALSE; + + // did we just do a backup? If so, let's report the status + if ( $this->backup_complete ) { + $feedback = '

    ' . __('Backup Successful') . '!'; + $file = $this->backup_file; + switch($_POST['deliver']) { + case 'http': + $feedback .= '
    ' . sprintf(__('Your backup file:
    %2s should begin downloading shortly.'), get_settings('siteurl') . "/{$this->backup_dir}{$this->backup_file}", $this->backup_file); + break; + case 'smtp': + if (! is_email($_POST['backup_recipient'])) { + $feedback .= get_settings('admin_email'); + } else { + $feedback .= $_POST['backup_recipient']; + } + $feedback = '
    ' . sprintf(__('Your backup has been emailed to %s'), $feedback); + break; + case 'none': + $feedback .= '
    ' . __('Your backup file has been saved on the server. If you would like to download it now, right click and select "Save As"'); + $feedback .= ':
    backup_dir}$file\">$file : " . sprintf(__('%s bytes'), filesize(ABSPATH . $this->backup_dir . $file)); + } + $feedback .= '

    '; + } + + if (count($this->backup_errors)) { + $feedback .= '
    ' . __('The following errors were reported:') . "
    ";
    +			foreach($this->backup_errors as $error) {
    +				$feedback .= "{$error}\n";  //Errors are already localized
    +			}
    +			$feedback .= "
    "; + } + + // did we just save options for wp-cron? + if ( (function_exists('wp_cron_init')) && isset($_POST['wp_cron_backup_options']) ) { + update_option('wp_cron_backup_schedule', intval($_POST['cron_schedule']), FALSE); + update_option('wp_cron_backup_tables', $_POST['wp_cron_backup_tables']); + if (is_email($_POST['cron_backup_recipient'])) { + update_option('wp_cron_backup_recipient', $_POST['cron_backup_recipient'], FALSE); + } + $feedback .= '

    ' . __('Scheduled Backup Options Saved!') . '

    '; + } + + // Simple table name storage + $wp_table_names = explode(',','categories,comments,linkcategories,links,options,post2cat,postmeta,posts,users,usermeta'); + // Apply WP DB prefix to table names + $wp_table_names = array_map(create_function('$a', 'global $table_prefix;return "{$table_prefix}{$a}";'), $wp_table_names); + + $other_tables = array(); + $also_backup = array(); + + // Get complete db table list + $all_tables = $wpdb->get_results("SHOW TABLES", ARRAY_N); + $all_tables = array_map(create_function('$a', 'return $a[0];'), $all_tables); + // Get list of WP tables that actually exist in this DB (for 1.6 compat!) + $wp_backup_default_tables = array_intersect($all_tables, $wp_table_names); + // Get list of non-WP tables + $other_tables = array_diff($all_tables, $wp_backup_default_tables); + + if ('' != $feedback) { + echo $feedback; + } + + // Give the new dirs the same perms as wp-content. + $stat = stat( ABSPATH . 'wp-content' ); + $dir_perms = $stat['mode'] & 0000777; // Get the permission bits. + + if ( !file_exists( ABSPATH . $this->backup_dir) ) { + if ( @ mkdir( ABSPATH . $this->backup_dir) ) { + @ chmod( ABSPATH . $this->backup_dir, $dir_perms); + } else { + echo '

    ' . __('WARNING: Your wp-content directory is NOT writable! We can not create the backup directory.') . '
    ' . ABSPATH . $this->backup_dir . "

    "; + $WHOOPS = TRUE; + } + } + + if ( !is_writable( ABSPATH . $this->backup_dir) ) { + echo '

    ' . __('WARNING: Your backup directory is NOT writable! We can not create the backup directory.') . '
    ' . ABSPATH . "

    "; + } + + if ( !file_exists( ABSPATH . $this->backup_dir . 'index.php') ) { + @ touch( ABSPATH . $this->backup_dir . "index.php"); + } + + echo "
    "; + echo '

    ' . __('Backup') . '

    '; + echo '
    ' . __('Tables') . ''; + echo '
    '; + echo '
    '; + echo __('These core WordPress tables will always be backed up:') . '
      '; + foreach ($wp_backup_default_tables as $table) { + echo "
    • $table
    • "; + } + echo '
    '; + if (count($other_tables) > 0) { + echo __('You may choose to include any of the following tables:') . '
    '; + foreach ($other_tables as $table) { + echo ""; + } + } + echo '
    '; + echo '
    ' . __('Backup Options') . ''; + echo __('What to do with the backup file:') . "
    "; + echo '"; + echo ''; + echo '
    '; + echo ''; + + // Check DB dize. + $table_status = $wpdb->get_results("SHOW TABLE STATUS FROM " . $this->backquote(DB_NAME)); + $core_size = $db_size = 0; + foreach($table_status as $table) { + $table_size = $table->Data_length - $table->Data_free; + if(in_array($table->Name, $wp_backup_default_tables)) { + $core_size += $table_size; + } + $db_size += $table_size; + } + $mem_limit = ini_get('memory_limit'); + $mem_limit = $this->return_bytes($mem_limit); + $mem_limit = ($mem_limit == 0) ? 8*1024*1024 : $mem_limit - 2000000; + + if (! $WHOOPS) { + echo '
    '; + echo '

    '; + } else { + echo '

    ' . __('WARNING: Your backup directory is NOT writable!') . '

    '; + } + echo '
    '; + echo ''; + + // this stuff only displays if wp_cron is installed + if (function_exists('wp_cron_init')) { + echo '
    ' . __('Scheduled Backup') . ''; + $datetime = get_settings('date_format') . ' @ ' . get_settings('time_format'); + echo '

    ' . __('Last WP-Cron Daily Execution') . ': ' . date($datetime, get_option('wp_cron_daily_lastrun')) . '
    '; + echo __('Next WP-Cron Daily Execution') . ': ' . date($datetime, (get_option('wp_cron_daily_lastrun') + 86400)) . '

    '; + echo '
    '; + echo ''; + echo ''; + $cron_tables = get_option('wp_cron_backup_tables'); + if (! is_array($cron_tables)) { + $cron_tables = array(); + } + if (count($other_tables) > 0) { + echo ''; + } + echo '
    '; + echo __('Schedule: '); + $wp_cron_backup_schedule = get_option('wp_cron_backup_schedule'); + $schedule = array(0 => __('None'), 1 => __('Daily')); + foreach ($schedule as $value => $name) { + echo ' ' . __($name); + } + echo ''; + $cron_recipient = get_option('wp_cron_backup_recipient'); + if (! is_email($cron_recipient)) { + $cron_recipient = get_settings('admin_email'); + } + echo __('Email backup to:') . ' '; + echo '
    ' . __('Tables to include:') . '
    '; + foreach ($other_tables as $table) { + echo ' {$table}
    "; + } + echo '
    '; + echo '
    '; + } + // end of wp_cron section + + echo '
    '; + + }// end wp_backup_menu() + + ///////////////////////////// + function wp_cron_daily() { + + $schedule = intval(get_option('wp_cron_backup_schedule')); + if (0 == $schedule) { + // Scheduled backup is disabled + return; + } + + global $table_prefix, $wpdb; + + $wp_table_names = explode(',','categories,comments,linkcategories,links,options,post2cat,postmeta,posts,users,usermeta'); + $wp_table_names = array_map(create_function('$a', 'global $table_prefix;return "{$table_prefix}{$a}";'), $wp_table_names); + $all_tables = $wpdb->get_results("SHOW TABLES", ARRAY_N); + $all_tables = array_map(create_function('$a', 'return $a[0];'), $all_tables); + $core_tables = array_intersect($all_tables, $wp_table_names); + $other_tables = get_option('wp_cron_backup_tables'); + + $recipient = get_option('wp_cron_backup_recipient'); + + $backup_file = $this->db_backup($core_tables, $other_tables); + if (FALSE !== $backup_file) { + $this->deliver_backup ($backup_file, 'smtp', $recipient); + } + + return; + } // wp_cron_db_backup +} + +$mywpdbbackup = new wpdbBackup(); + +?> diff --git a/wp-content/themes/classic/comments-popup.php b/wp-content/themes/classic/comments-popup.php new file mode 100644 index 00000000..f42d38dc --- /dev/null +++ b/wp-content/themes/classic/comments-popup.php @@ -0,0 +1,113 @@ + + + + + <?php echo get_settings('blogname'); ?> - <?php echo sprintf(__("Comments on %s"), the_title('','',false)); ?> + + + + + + + +

    + +

    + +

    RSS feed for comments on this post."); ?>

    + +ping_status) { ?> +

    URI to TrackBack this entry is:"); ?>

    + + +post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) { // and it doesn't match the cookie + echo(get_the_password_form()); +} else { ?> + + +
      + +
    1. + +

      @

      +
    2. + + +
    + +

    + + +comment_status) { ?> +

    +

    HTML allowed:"); ?>

    + +
    +

    + + + + " /> +

    + +

    + + +

    + +

    + + +

    + +

    + +
    + +

    + +

    + " /> +

    + ID); ?> +
    + +

    + + +
    + + + + + +

    Powered by Wordpress"),__("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?>

    + + + + diff --git a/wp-content/themes/classic/comments.php b/wp-content/themes/classic/comments.php new file mode 100644 index 00000000..6222f1af --- /dev/null +++ b/wp-content/themes/classic/comments.php @@ -0,0 +1,75 @@ +post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) : ?> +

    + + +

    + + ">» + +

    + + +
      + + +
    1. + +

      @

      +
    2. + + + +
    + + +

    + + +

    RSS feed for comments on this post.')); ?> + + URI'); ?> + +

    + + +

    + + +

    You must be logged in to post a comment.

    + + +
    + + + +

    Logged in as . Logout »

    + + + +

    +

    + +

    +

    + +

    +

    + + + + + +

    + +

    + +

    +ID); ?> + +
    + + + + +

    + diff --git a/wp-content/themes/classic/footer.php b/wp-content/themes/classic/footer.php new file mode 100644 index 00000000..0894f78e --- /dev/null +++ b/wp-content/themes/classic/footer.php @@ -0,0 +1,12 @@ + + + + + +

    WordPress"), __("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?>

    + + + + + + \ No newline at end of file diff --git a/wp-content/themes/classic/header.php b/wp-content/themes/classic/header.php new file mode 100644 index 00000000..e505e298 --- /dev/null +++ b/wp-content/themes/classic/header.php @@ -0,0 +1,30 @@ + + + + + + + <?php bloginfo('name'); ?><?php wp_title(); ?> + + + + + + + + + + + + + + + + +
    +

    + +
    + diff --git a/wp-content/themes/classic/index.php b/wp-content/themes/classic/index.php new file mode 100644 index 00000000..bbee16e7 --- /dev/null +++ b/wp-content/themes/classic/index.php @@ -0,0 +1,32 @@ + + + + +',''); ?> + +
    +

    +
    @
    + +
    + +
    + + + +
    + + + + +

    + + + + + diff --git a/wp-content/themes/classic/screenshot.png b/wp-content/themes/classic/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..6692130614b96db2b3b1509c6e6d3f7a547904a2 GIT binary patch literal 8412 zcmV<2AS2(2P))&bT5)&bT5)&bV<1WOYF|D=86-5U`)h|=jjQj2^ajpUpk&Mw!S;JkDB(`D(} z&AUgL{=r~%%4Bbxg|E)P4i>VVtNh|p1IyLyn7LjExx0vTAJJK@`c81jG}zCB6%gdB zaMymVKO8JAXVKG3!$G`J!o^UB02aB&PZt{cy_BP&@cvLhw@1}2nlhg*3vIX8yCiDd z{qZ_$xs^9$diSv1qo?jh*{K9oZa)+K9ayS=9`m9{dHrPFrF)vw9`IWBmnMbzalq~B ze{tHt`8J!#`2$lz# zTtzYTU87cyW%LHAu(TU@k?=(Cx*J+a1@hTaTmT&RNN{i1-~C9s<}Q<)0(6L69zBq- z|FAVg>Z+^K!p4s@*Q?Y4t7}u_KoqWZMhE*?i@HWKZ&(Qh1#-8`8Rz^ME2r@FRG3}w zHJxSm%sbq{|6TTX(QXfLf3I-W?}}g1Bl5;5nqoJ%eE%U>=}vczhq?2)*3j=Fh0y+1 zJ-kvCd+69lR2z;7t{h-BtR`3JQm2SXFp&>4F_aWDFIAQ))_w>TShzjFYKPq-A;E8v zZDE>CHbml5Hmbbl69BckY9QbMYX_@1Y?sO%ur{f&4M9>IEP)_xRpmugXw1z4*6T-l zMXMbO{tg>7)`Tn%byx17pO;oknfPNPSUX@TqLuGg^-dbM*>3V0PD%oE4%CW96-5a z;O@zC0YRYQ8DrxC)@P1q8vX$5-%oacb%1q%b%1q%^}WDK+fs+{h^*1EmMe)xQrAAJ zYFzb1{UEUXy(#$II(!lO?0nMxJf_Lj35#~ss9LVzA+IaJE;*y@QzPJ;gVi`ETb_oY zHjY@?_&!*cW;rrBR}))Ik5M)1j^zSaqzAC76+Z~9#8~xhG@2m?4q;da}m%DBq_{Zo; zy++@@Rd}MapthwZS*aogAh9NFO}bj>=h}sz-AcYuI-flHd@|(G&pO^H{2P#H;YLmPZuUi<`j+|R9&H|o%z zgS?=8C%ar@n)MS&_E}zd?w)rOomI*>{CC3rf^A~Op_NxWSmkk8e6a47CjVJ7PSF`# z#EBYIn@&nF?_}1Vw;`dkg7b<7Cog1dA$4;7c?rpoMUo7-^aDHdjs)Xu4)6~-nhRhm zLr(;Uh>6T znl8EP@&%uv;63eWI-@FsA=i+G-=#ywaU!9-_L9yS`|~2ZjN6<%+`x*pzeqQcY&7J= zX-mh?s!B4nY0Hxa^fSMt|5CE7CWW_dcLGN?WLn|-hhSCdz~1T4$`8O!(}j1YyO05& z6#@ZK9fuk<3E7Rps#8> zfsfwWaQoUOPe7hFRNO{xndLy`-~!yzvea&eFdh@e%5!Ehwiwwx9Ux{^;*B^155%m; ze~5yADNcAisKZmqg5MDoiQt1aS`k|mQ3ezbeB&pq83{!hVh^yc?HY~3Ot|n!@Ra4| zijc1IJk2BzGjV3qh0F(7I|nL76p|N7$y7MD5!x^wLA}_BIgcQB6lb2FnLAuD1@+c9 zN`(--*~M2hqPA#b0b3}c(KFQMb+tD(rp7th9b>|(S)wffjr${cEXHcZh!7tW56#4{ zAJ||2nafR0kN+$D=JqwE87A>yR2$E2W?+{1zisMz88>t#(yMOUuW>b;~gEoc+PQSv;qp= zkPQkeXcimUNmW6x5na(tH-sJOdi0S^Ux1#{OV%iMLG_Ns9dl`u;IwK)PlG${^X z{A1Pxxfcv1JpBx?-igQdBf;O}<9e3<<%j%kVEq-He+O6xSO-{t09fcox$f7qq5~}S ztnUEruQt2`Ftw!?wT&Vs_*9L1qc+w9@eZ)q=v&_hLaGfM?$7{UtPLf$E*L-$sTKm) z53te#=%fZw!)PBj+`)nu+lTO#Z#_vMdFI-_q{g8l2>ZJ`U36 z`9A9NKpvxSQVp9?xWC}78N&P7{xR+&GPjU@ed`nJTThx`Y(!REfaS|aFzhD5MKzk{ z5s3YiR}O}Z3V5P=aKQ$K8AnO#tcA~u1zV|y=)&rSgDEg7&TRORts$DqJZY5_-SKx zfc5k+A`KT#R@b{K+nUS+thY;@3aDYuqyW-n3P>3`z&Z@+-=eb!LZ5Lqc7WA%)=V@n zF6U{E>HzEgQnxXMDaaD@TMgj>)EqzWq{|7C2+0sp!>7KBok#swFR&1+F=gYTtYM1Y|IH_9wCCTV6xNuu)z&(LmpUNCiuxY1^Z z5W$s0WYPv~t0hd%wxe9+jI)JSt=%#3!F@?*(SW0*lVgLB+US0YBp2~PvSC?~J0 zyE2_1Lu4+L?-NpH3PnNFJh$X_qY+|Nn$IPj;z}1O3fX{6pV~9fm{%d;2as;q_DuVM z);XWoc^+2cA-6EicA{pTr`G?GrWvx*{A*yHlw1wo9B&;Z7$jthWp?i;>tiZ&j#J5^ z$}J*Eo$83zf@?H&T_BiJSB)mc5vk$Ypn>sDGImp0EG@EG3vH1<58V{u!QCJ@*Pm^lm2Mc_sy1DsV}$}rC{cX5#$T!hob3O=79v#E>#4~TEq zW>QVUZ|Av8r8Jq)cosw8+pJj!0biXhE%lb! zH8NUIV(lLLAVHhTkFF6byACkiM{fP*sJ16WETw%d$=G@}(?3-3>NmCvKa4uGsV<)R z60CZ!H~awW+LblYJd+Jn6*<8A2&@8aSZrP4w2Z$4EOeL4`18Q>468OnsExn;b1vIY zbGfxIy}nP^ca`Jsxc>0>FnAM%iJ3b*PJu^Unh$6Jl(AaZ&ymTT3+Wso6^Kn#{uC~v zIoQ_UU9z~qh%=Q~4k@#wMjMhqA0(sre4@Y>fmW3ha4JJjb8J(ZEwMmshB;z-(tI9) zYxO#H9m(=SxcKfmYoY}Y&S*{~kUijv8 z+)vq*GKVs^$$Le86)gXUpo_-e307YO#%15t!xUA5aU65f#(RjNxI|kp$L5)_=)o$w z8pZND%l0)?2280(z@&FkRSLqGT}m;N@yHHF7xWlwGg z1>mll@UQneB${Yx!(CGpJpt<(lMF^Qz}%cy7$;YMj?wL~lYQRTk}y$e#j*{N# z#fKj6qhOifI>bmA36<+$K*kA^!jjD`Eo*#^BerMwQPJ6voPw7EFZ>+%O!sj%1NTbp zN9WME??YV8wLRDQG!BtMzU|4JB>_Tl!5)5o-dU(qgot+r;(rfVz97oiZAJs0$foDK z>gvtfoe4D>u-i1c7%gcxFLusnz0IP(48mWgWm1zGD3zz#^_rJKuJbG=T`yUi(;QPw z+iXvopOjg1N3f*sa-pP|=F>QhozaB`8O*9CI&u>EdEFM{Itu4vBb>%*-de_D&#HDg zLcVk+dV=f+fy@>QndVEEH>&x0JI8+=EbnYLxGG~A&U)&)Nu=#e+bEbz1t?oBF_;eQ zf;4m_PEqwl>N*vzM?=m;QUitqo$>@fJV@6JISF2<@RF1>l%?(Wsu$VC2_#c@`J_B8 zL?ao4Jyj03m|}-}s{4*=#Nl331U$>61)p=7oP@ZLMeBOQg=T222#t7h@R(#Z+qvuJ z`Fzm;z4({Gy1F^qR~b}4wiPSQ9p1Q)f;FG=`;b)QAj>`$<=Z&a{TDmv7OyRSxnJ0E zjlU0HvHr5y?&^0CwWa7Sv)1qGTMliiuDdR7xb9SP8|`Z2Y}W&;j1qltNnJc{!tsFKD-%vulMo)*U%m_|9*F=kN&JzN_|}}uvc%? z9Qob+xuWsTD;jzqEdL1}>VF7W&5dMA3~cGd7R1!pmVYtU<`1+0HP#Py8j$FLF{0PJ zlESrayi1L~HCWIF`Ng+|BW*`k)h2kb>zs)_fW56$ZNx?6X|8nQDOt_)ZEHW%xQkianRVP7@B}i)9(kmEHj9RA z6j(Z=Xkf#IPA8y@TH@hEXE$Z-rxgMByx3t_>u^F=1N{R!#R=C219!Z9N1gTfVB_aU zr2Rx`;AAS*l(`L~#o#B+K&*1e*7d`z_(TZ^m(*Zp_(?W87{}TRON&z^pzjUVFC;^4 z>5sc>DV}L_Pxe56*OWXNCPUv-vVe9oRqd!!UO>?+WDƨIeT2_Ive>JL6%bpAOo zvWiZV9>5}ongvFt6NZApPloVM1@fnL{!vOY6}WB9Iy*;bmc)`NOw_nZ9AG`IhB+{n zvgOSimVy?}Fy^gmi@v!#93;Nm8+?rJyjN-~m_h-I<`UU5Guqk*k5M1$Qu`SlU_DXr zWtdIdi`BR^=xJB-ad(KDD~iX)YEKnB8MLLuRU`P?k=Cc!d=6y4F4b?#0oD^Og@IOK zk1GNtA1vc)nt^gLUw}hp^@h2_61!eX>h2=Dr=5@b_L3TZ5?HU$%-6Pnd_EMmlGwbE zDlUMVTZO8LLG7K*9$l`3b#394Ifoxr4RcfQ+*QOu!IK3y1rJ}Fg0~ZXBN-}nra)ac z(Qk{NPD?d&Al+2DE|yNtp{HbUd?uGUxSs>oy@DrC6?~g7`e+35`M6>9(azI)S<>MA zxs4|9l}6BaYnaX_8hSm=W!f&6xQQPmS&tQbEWqGhxl{1+&DPL!Bp4~02wy-D+m1v< zWNZUJgEheQl0qs%YMt$>)Q;a2J04uF@}{zI@(e&jqNzs=EQ z*rz(&pX#07%SR;N+n1|bxo8t~UuHX2DbNit`H=0MH67X#$4$aRs9XgL!|F$1xIK-c{4LgHego+1+*Yun~k zl(V*Ljx8lAY9bxsRJ6VGc)@}533Am2o<^=NM?t2~_|Ux0YP<_W?|2w`CRyDK7;VCy z#IzVE^+xG%q6=^9edodXnQdAsa|-2rg0h!Pi*Bx9scREwM=2x(&)bY-*8DV6YRGh= zdUEMJZ&65k8oBEhzELgL*j5=wwCd)Qg-UXwtD>kvHmd?-zngh9YjYJlD>H9xDXufK zO5KE}1%4?R2YQObtW!BHcJ72+*{~*fFv!eJa~)=^KQ48fIFl6G=Nq+&AZ^cI^!haW z=L^cALYkHKp5utqTlj(K3jX! zTh4uut6skdMisyFAh-9|=QyF)0_^x?)g zUTre*)fG?r3#fzt<>{ga&-#4lpH-hZ4zTvBh#6BK|Gl)o)kk^XO~yyp&EeV2Hy(OM zPyAJvq3|AoNulkq_*J8I0i^dfdXg$>S3AwhX>CW@8RRp-C z)L8Eh1+BhQiz6^XkNF9Yc3x0vLNJhrE{F_3 z*nfXRhnHZbUjU1ieZXrX1D3P0(}fIlUAT@Boukww@Dd4)V>a5*H3Gksvz=*>(NN%@ z6wf>)NHPv9Kdo*!tl>3&{eO zjX9VgfCDFEKb=JhWU-lXgo)9%7+kW#V-E%hHe`Wd;F^6KJS&(Nm3y#6fHf|C$v`nL zF;WmgWyGY)EN8fQ(Ou|=(~L=&;Cd#brIAy|fyX;TU9kd;f&aT?{R&v-sREPa-+5LO z(I3?sCLDr&`TsohpbocQiha?JN7w)M2Jh@3rLTgO(g@0CZ2mn*z^P}zCD;Mh8(@w7 zOa#LoV<0rx#2u{ztT(_)go?Y);p5rOdMu6Z8R55+yU0xV1c6Iz>yr| zIVkI_vZFu1dcD+1F}9?(dvSZeZDOnruwE^-2g!PIjOYOC==?jtI>7olV5x@@#$I3h z`o_NpEdQlsejbN_S@l-cDK0*#V8q`87DMk#-LnztO|N*H@vyEVP=8)%xrCn%mQTo! z0INAxxjL`%%kIhwwTTbozCFv)8orP$fA65nqno>) zw!IBHz&d!=?<+OJV{>?mK^-0bvtBQCBE)%vnMKKHOmZfex&y4&OU-30V$hPH%5g!Z zAY#gLfc0vrtuVZ-%{ho&gDrx`V5vI5dcD+bn>aS|=0K~tv#jh@Gw%TFiS7ahk3q@T z6e`9CSg)2EnZS!OnTXm;Q196gyoL{xJ?x-k9~2zFrL$zT1aXJRb>1m2iy_RoYD;sU z{`zrSk8Sqs@Sh151LckvV@aBX&97`G^m0#DuylOp^J3i6ha7rnLZwT&O;7Ng zN=}I(!_E1_G!KEdDc{p-PqQ27M(2S{QAPxqCZ4M|GsdFNLWV3xPXEx>aMM%F98`Oi zbm7q&4euX;HOw;)aR%I6@d8`d*45rWUn^|>clqgC`8GO`6~_7L!P(k50j_owN! zZl??%r+GL9?%)Z!MT)7TQ93z`0iHu{tJG##z=vvkGw+L?EEw_%q#7l~;^O~Iu=-L+BBG6~^1_`1O`lHx6)C-~`ub!1 z2)=ZJQ3x>jLRw=+#!`ISy5gV?uQPa_dD$9+=R1S9plJ@U-Yd07z~E8Zr(XXJ%TbR0 ztOKkAtOKkAtOKmS5iE~iUyXrST58YUSit*awXH|{-W6>Z8#I1l`2PEeNLDJ@F{!o* z1sGWhzV?{0YLyi|=lJ7gzg{V}RK`Yzd}>3jKNhUE&l*>m@Z4UUkeo5e2AKHhF#v|e zhox?N-j80jv1o?WyMTOu$?7x9xK}*0U}d&A!5OJ`>2tzZ;g2P&tv_kq0IB+v-rbY% zn}g-KbiBzF<{3k+Gy69J-&@bH$tL{HQh#^J8c~~8{O~t6{|w%zcGBL^r%H|f3b1}x z7Y*i153K=L2Us726`j;FmZ=QY=cV74eRjlk%SeCSO0xOR^K98i)Y`@Gy-D56UFbl!0D~{> zwb25H(a2BB6dr4`S0vA?`qPh>ts!uD!}I={w8^C4dGWcn{V?BF@M!O2{Xxg)6uce# zWslx^x73K*G?o@kjchqc>1U3_tYRUl1FUD~h>aQ8gT9K{wIjY~&xG^&Rx&2v50@D6 zOnWhQ-|?t=`3lVZSrdtg_#R+!phK|`Qs&wdMQEPwL>&+BCzHA+WlgYzG!JYYsu+*9 zb##Y{1}85WHP&Fycp$-NY}*h4vYCO7R9G%JTZsu)5Rx+&y!#$t^^~_ZF!H&kH5gJH zCb@h7mfyDk%kp9`7vZZE6-nI>Bwq-rbyAXC8cL9Px=3w0!Y`d`L0|w4!VeG+cjPP} ziIBSOpZiU87EVS4)k8TFQ;9WKoS@>z4jrc{90iWCSN2BYI;Ud2n=OGDD+CG0j1>Yuw0;5;WiKhC%Hsrk3u55F&XPQ%E z+p6Kxw@v;q<~)yFj1bL2CG$BzJP6wPJlH};;XLkxoj50sYx+iD^*8d#ECNLjf66m^ y^k==Mvq+G1a{oXe|0e3NDb5}FNW=b5fB^vd+IrCN4BWN=0000 + + diff --git a/wp-content/themes/classic/style.css b/wp-content/themes/classic/style.css new file mode 100644 index 00000000..e09122dc --- /dev/null +++ b/wp-content/themes/classic/style.css @@ -0,0 +1,313 @@ +/* +Theme Name: WordPress Classic +Theme URI: http://wordpress.org/ +Description: The original WordPress theme that graced versions 1.2.x and prior. +Version: 1.5 +Author: Dave Shea + +Default WordPress by Dave Shea || http://mezzoblue.com +Modifications by Matthew Mullenweg || http://photomatt.net +This is just a basic layout, with only the bare minimum defined. +Please tweak this and make it your own. :) +*/ + +a { + color: #675; +} + +a img { + border: none; +} + +a:visited { + color: #342; +} + +a:hover { + color: #9a8; +} + +acronym, abbr { + border-bottom: 1px dashed #333; +} + +acronym, abbr, span.caps { + font-size: 90%; + letter-spacing: .07em; +} + +acronym, abbr { + cursor: help; +} + +blockquote { + border-left: 5px solid #ccc; + margin-left: 1.5em; + padding-left: 5px; +} + +body { + background: #fff; + border: solid 2px #565; + border-bottom: solid 1px #565; + border-top: solid 3px #565; + color: #000; + font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; + margin: 0; + padding: 0; +} + +cite { + font-size: 90%; + font-style: normal; +} + +h2 { + border-bottom: 1px dotted #ccc; + font: 95% "Times New Roman", Times, serif; + letter-spacing: 0.2em; + margin: 15px 0 2px 0; + padding-bottom: 2px; +} + +h3 { + border-bottom: dotted 1px #eee; + font-family: "Times New Roman", Times, serif; + margin-top: 0; +} + +ol#comments li p { + font-size: 100%; +} + +p, li, .feedback { + font: 90%/175% 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; + letter-spacing: -1px; +} + +/* classes used by the_meta() */ +ul.post-meta { + list-style: none; +} + +ul.post-meta span.post-meta-key { + font-weight: bold; +} + +.credit { + background: #90a090; + border-top: double 3px #aba; + color: #fff; + font-size: 11px; + margin: 10px 0 0 0; + padding: 3px; + text-align: center; +} + +.credit a:link, .credit a:hover { + color: #fff; +} + +.feedback { + color: #ccc; + text-align: right; + clear: both; +} + +.meta { + font-size: .75em; +} + +.meta li, ul.post-meta li { + display: inline; +} + +.meta ul { + display: inline; + list-style: none; + margin: 0; + padding: 0; +} + +.meta, .meta a { + color: #808080; + font-weight: normal; + letter-spacing: 0; +} + +.storytitle { + margin: 0; +} + +.storytitle a { + text-decoration: none; +} + +#commentform #author, #commentform #email, #commentform #url, #commentform textarea { + background: #fff; + border: 1px solid #333; + padding: .2em; +} + +#commentform textarea { + width: 100%; +} + +#commentlist li ul { + border-left: 1px solid #ddd; + font-size: 110%; + list-style-type: none; +} + +#content { + margin: 30px 13em 0 3em; + padding-right: 60px; +} + +#header { + background: #90a090; + border-bottom: double 3px #aba; + border-left: solid 1px #9a9; + border-right: solid 1px #565; + border-top: solid 1px #9a9; + font: italic normal 230% 'Times New Roman', Times, serif; + letter-spacing: 0.2em; + margin: 0; + padding: 15px 10px 15px 60px; +} + +#header a { + color: #fff; + text-decoration: none; +} + +#header a:hover { + text-decoration: underline; +} + +#menu { + background: #fff; + border-left: 1px dotted #ccc; + border-top: solid 3px #e0e6e0; + padding: 20px 0 10px 30px; + position: absolute; + right: 2px; + top: 0; + width: 11em; +} + +#menu form { + margin: 0 0 0 13px; +} + +#menu input#s { + width: 80%; + background: #eee; + border: 1px solid #999; + color: #000; +} + +#menu ul { + color: #ccc; + font-weight: bold; + list-style-type: none; + margin: 0; + padding-left: 3px; + text-transform: lowercase; +} + +#menu ul li { + font: italic normal 110% 'Times New Roman', Times, serif; + letter-spacing: 0.1em; + margin-top: 10px; + padding-bottom: 2px; /*border-bottom: dotted 1px #ccc;*/ +} + +#menu ul ul { + font-variant: normal; + font-weight: normal; + line-height: 100%; + list-style-type: none; + margin: 0; + padding: 0; + text-align: left; +} + +#menu ul ul li { + border: 0; + font: normal normal 12px/115% 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; + letter-spacing: 0; + margin-top: 0; + padding: 0; + padding-left: 12px; +} + +#menu ul ul li a { + color: #000; + text-decoration: none; +} + +#menu ul ul li a:hover { + border-bottom: 1px solid #809080; +} + +#menu ul ul ul.children { + font-size: 142%; + padding-left: 4px; +} + +#wp-calendar { + border: 1px solid #ddd; + empty-cells: show; + font-size: 14px; + margin: 0; + width: 90%; +} + +#wp-calendar #next a { + padding-right: 10px; + text-align: right; +} + +#wp-calendar #prev a { + padding-left: 10px; + text-align: left; +} + +#wp-calendar a { + display: block; + text-decoration: none; +} + +#wp-calendar a:hover { + background: #e0e6e0; + color: #333; +} + +#wp-calendar caption { + color: #999; + font-size: 16px; + text-align: left; +} + +#wp-calendar td { + color: #ccc; + font: normal 12px 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; + letter-spacing: normal; + padding: 2px 0; + text-align: center; +} + +#wp-calendar td.pad:hover { + background: #fff; +} + +#wp-calendar td:hover, #wp-calendar #today { + background: #eee; + color: #bbb; +} + +#wp-calendar th { + font-style: normal; + text-transform: capitalize; +} diff --git a/wp-content/themes/default/404.php b/wp-content/themes/default/404.php new file mode 100644 index 00000000..01a8e8a6 --- /dev/null +++ b/wp-content/themes/default/404.php @@ -0,0 +1,11 @@ + + +
    + +

    Error 404 - Not Found

    + +
    + + + + \ No newline at end of file diff --git a/wp-content/themes/default/archive.php b/wp-content/themes/default/archive.php new file mode 100644 index 00000000..104c8b27 --- /dev/null +++ b/wp-content/themes/default/archive.php @@ -0,0 +1,68 @@ + + +
    + + + + + +

    Archive for the '' Category

    + + +

    Archive for

    + + +

    Archive for

    + + +

    Archive for

    + + +

    Search Results

    + + +

    Author Archive

    + + +

    Blog Archives

    + + + + + + + +
    +

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

    Not Found

    + + + + +
    + + + + \ No newline at end of file diff --git a/wp-content/themes/default/archives.php b/wp-content/themes/default/archives.php new file mode 100644 index 00000000..ae9d8dd2 --- /dev/null +++ b/wp-content/themes/default/archives.php @@ -0,0 +1,25 @@ + + + + +
    + + + +

    Archives by Month:

    +
      + +
    + +

    Archives by Subject:

    +
      + +
    + +
    + + diff --git a/wp-content/themes/default/attachment.php b/wp-content/themes/default/attachment.php new file mode 100644 index 00000000..b8f33478 --- /dev/null +++ b/wp-content/themes/default/attachment.php @@ -0,0 +1,67 @@ + + +
    + + + + +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: ', '

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

    Sorry, no attachments matched your criteria.

    + + + +
    + + diff --git a/wp-content/themes/default/comments-popup.php b/wp-content/themes/default/comments-popup.php new file mode 100644 index 00000000..d5dd1763 --- /dev/null +++ b/wp-content/themes/default/comments-popup.php @@ -0,0 +1,113 @@ + + + + + <?php echo get_settings('blogname'); ?> - Comments on <?php the_title(); ?> + + + + + + + +

    + +

    Comments

    + +

    RSS feed for comments on this post.

    + +ping_status) { ?> +

    The URI to TrackBack this entry is:

    + + +post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie + echo(get_the_password_form()); +} else { ?> + + +
      + +
    1. + +

      by @

      +
    2. + + +
    + +

    No comments yet.

    + + +comment_status) { ?> +

    Leave a comment

    +

    Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed:

    + +
    +

    + + + + " /> +

    + +

    + + +

    + +

    + + +

    + +

    + +
    + +

    + +

    + +

    + ID); ?> +
    + +

    Sorry, the comment form is closed at this time.

    + + + + + + + + +

    Powered by Wordpress

    + + + + diff --git a/wp-content/themes/default/comments.php b/wp-content/themes/default/comments.php new file mode 100644 index 00000000..dff40d82 --- /dev/null +++ b/wp-content/themes/default/comments.php @@ -0,0 +1,104 @@ +post_password)) { // if there's a password + if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie + ?> + +

    This post is password protected. Enter the password to view comments.

    + + + + + + +

    to “

    + +
      + + + +
    1. + Says: + comment_approved == '0') : ?> + Your comment is awaiting moderation. + +
      + + + + + +
    2. + + + + + +
    + + + + comment_status) : ?> + + + + +

    Comments are closed.

    + + + + + +comment_status) : ?> + +

    Leave a Reply

    + + +

    You must be logged in to post a comment.

    + + +
    + + + +

    Logged in as . Logout »

    + + + +

    +

    + +

    +

    + +

    +

    + + + + + +

    + +

    + +

    +ID); ?> + +
    + + + + diff --git a/wp-content/themes/default/footer.php b/wp-content/themes/default/footer.php new file mode 100644 index 00000000..a6cfd870 --- /dev/null +++ b/wp-content/themes/default/footer.php @@ -0,0 +1,19 @@ + +
    + +
    + + + + + + + diff --git a/wp-content/themes/default/functions.php b/wp-content/themes/default/functions.php new file mode 100644 index 00000000..5587a48b --- /dev/null +++ b/wp-content/themes/default/functions.php @@ -0,0 +1,395 @@ +\n\n"; + if ( '' != $output ) + echo $head . $output . $foot; +} + +add_action('wp_head', 'kubrick_head'); + +function kubrick_header_image() { + return apply_filters('kubrick_header_image', get_settings('kubrick_header_image')); +} + +function kubrick_upper_color() { + if ( strstr( $url = kubrick_header_image_url(), 'header-img.php?' ) ) { + parse_str(substr($url, strpos($url, '?') + 1), $q); + return $q['upper']; + } else + return '69aee7'; +} + +function kubrick_lower_color() { + if ( strstr( $url = kubrick_header_image_url(), 'header-img.php?' ) ) { + parse_str(substr($url, strpos($url, '?') + 1), $q); + return $q['lower']; + } else + return '4180b6'; +} + +function kubrick_header_image_url() { + if ( $image = kubrick_header_image() ) + $url = get_template_directory_uri() . '/images/' . $image; + else + $url = get_template_directory_uri() . '/images/kubrickheader.jpg'; + + return $url; +} + +function kubrick_header_color() { + return apply_filters('kubrick_header_color', get_settings('kubrick_header_color')); +} + +function kubrick_header_color_string() { + $color = kubrick_header_color(); + if ( false === $color ) + return 'white'; + + return $color; +} + +function kubrick_header_display() { + return apply_filters('kubrick_header_display', get_settings('kubrick_header_display')); +} + +function kubrick_header_display_string() { + $display = kubrick_header_display(); + return $display ? $display : 'inline'; +} + +add_action('admin_menu', 'kubrick_add_theme_page'); + +function kubrick_add_theme_page() { + if ( $_GET['page'] == basename(__FILE__) ) { + if ( 'save' == $_REQUEST['action'] ) { + if ( isset($_REQUEST['njform']) ) { + if ( isset($_REQUEST['defaults']) ) { + delete_option('kubrick_header_image'); + delete_option('kubrick_header_color'); + delete_option('kubrick_header_display'); + } else { + if ( '' == $_REQUEST['njfontcolor'] ) + delete_option('kubrick_header_color'); + else + update_option('kubrick_header_color', $_REQUEST['njfontcolor']); + + if ( preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njuppercolor'], $uc) && preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njlowercolor'], $lc) ) { + $uc = ( strlen($uc[0]) == 3 ) ? $uc[0]{0}.$uc[0]{0}.$uc[0]{1}.$uc[0]{1}.$uc[0]{2}.$uc[0]{2} : $uc[0]; + $lc = ( strlen($lc[0]) == 3 ) ? $lc[0]{0}.$lc[0]{0}.$lc[0]{1}.$lc[0]{1}.$lc[0]{2}.$lc[0]{2} : $lc[0]; + update_option('kubrick_header_image', "header-img.php?upper=$uc&lower=$lc"); + } + + if ( isset($_REQUEST['toggledisplay']) ) { + if ( false === get_settings('kubrick_header_display') ) + update_option('kubrick_header_display', 'none'); + else + delete_option('kubrick_header_display'); + } + } + } else { + + if ( isset($_REQUEST['headerimage']) ) { + if ( '' == $_REQUEST['headerimage'] ) + delete_option('kubrick_header_image'); + else + update_option('kubrick_header_image', $_REQUEST['headerimage']); + } + + if ( isset($_REQUEST['fontcolor']) ) { + if ( '' == $_REQUEST['fontcolor'] ) + delete_option('kubrick_header_color'); + else + update_option('kubrick_header_color', $_REQUEST['fontcolor']); + } + + if ( isset($_REQUEST['fontdisplay']) ) { + if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] ) + delete_option('kubrick_header_display'); + else + update_option('kubrick_header_display', 'none'); + } + } + //print_r($_REQUEST); + header("Location: themes.php?page=functions.php&saved=true"); + die; + } + add_action('admin_head', 'kubrick_theme_page_head'); + } + add_theme_page('Customize Header', 'Header Image and Color', 'edit_themes', basename(__FILE__), 'kubrick_theme_page'); +} + +function kubrick_theme_page_head() { +?> + + + +

    Options saved.

    '; +?> +
    +
    +

    Header Image and Color

    +
    + +
    +
    +
    +
    +
    + Any CSS color (red or #FF0000 or rgb(255, 0, 0))
    + HEX only (#FF0000 or #F00)
    + HEX only (#FF0000 or #F00)
    + + + + + + +
    +
    +
    +
    + + + + + + + + + + + + +
    + +
    + +
    +
    +
    +
    + diff --git a/wp-content/themes/default/header.php b/wp-content/themes/default/header.php new file mode 100644 index 00000000..65ea78b3 --- /dev/null +++ b/wp-content/themes/default/header.php @@ -0,0 +1,56 @@ + + + + + + +<?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?> + + + + + + + + + + + + +
    + + + +
    diff --git a/wp-content/themes/default/images/audio.jpg b/wp-content/themes/default/images/audio.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b02e1c86e5eacc83f2189a37e816a9310469d434 GIT binary patch literal 4671 zcmY*cby(ERxBo7?l(53mT}w!}q*Ah!q_D&S64FSof`EjCG)u~=AT3HL0$vf3=Ix0E`T<1MI*c z7(fIAfnlJFHsBd>$qWnvUGn^2kdcsrA>_oDw!e=5?;*Kl3?d?>28b@%5J8ClQu><( zA_Bu8!~hKmH?5?aJ*h7b9X;8Ou@uGx9+B_xUfr*S7Y2a9AYxJo5eNeQ=bpcZ!?-1B zAjE3MnEdy&B=)`$U%o9=??{M@) z_2H+3nOdnXTfHEE(f0Pf?DQTFzP2HmAr*NBO9Q?pspbZj5*o+x6p zG_y?8$T^r(+eKVFF(1{bwh;AXJoy22G0~3GDq1$y1#(p12IEDlXgeus-w`RjJTJtT zjk}I;*r1o?X%H*x)#2=$3=1cUzZ$=>#;&hx!s;Im2+5*%h&%7vk2dh@zDepe4Ghlw~&VJNIE8FfE<&fp)CJ= zqI}E6`S^_(5c=7qS&+kO;E99{7ppZ$nf~|{H1TCyMEkAktd^D&luZifeI7nuh=e$e z!fURex=Ky4>tl0o%7i5pb7vUy>fLYa%6PFza-Pz(=A#?&^pI{O4a01Y*}E#2yEV8~K(yAh`2cw}GaHxmxfi$0ikModsP!xNY^H4ie+ZrTwYR!8$j48>qe^U^;uh_-)H z$EBv=#MtM536|%@Ozw#|sG%L1pKwb}uLxS4db2_4Vd-Vg0p_JSkb|K@|H|kClEG{8 zWBCPc4|G0AMOo+@UP0H2&h9jb*W><7ZYQO6r#@nphX(W(UH~gjp+yQv-3=qpCX>`hZaN$KZr(EFCQ)&o9_Lp*jK=W*Jd zO%Gbe#5>k3AS#y0&uTLAA0#h~Rps?uliAI0rsWX!Wv4;Z^@-aT&mWjR^dCcc(A#iy zY4A2;|NO8E3TA-PnE=`}x7YES$~snq9-JsNHxd4kXcB#G2G(;Uw@El25$P(1tQ(_6 z@>TWa^QID!vnwkHBw;hY!vZx;B?K?(2yCyi#zhF7i;ICV2uGb;uJP zmAMbOKKEUSfT_?|ZBFo_By9Zfb@Ezel<3u; zl~MdkyUkF(0l`np2DPzJ*T=c~Gmt77$<*F8vqvd0*=I36+^`D(b0YYp^A*3N!0(iI zxn1|W>Q1_^9=&ui(FUKT$BHj3lJ=g$#lm!@IsfL+UNoah&JA0|o^jb3dto(*Q_so6GZTl6&7FFg6!A80_v7qRi zNP5yL3`s+q{thFzlM%^QFSX#z;#bses>hpJ-y9k6`xNZT}2&swW3#% z<7=6cei-W@MgGp zg%)pCddH-@RjO{fZs`K$icA!|6&2pqv;JD1!?B%u?TAy&z$4PI0;(r=?Fg3OAh>h{uV+2pDoCk;E2_MF*7gZ?bJvDi{Wc?Y^}<-A;$-_B<}lgz3Ci1e0bF9o5dZmS>XIkJW60$Z z=YU0%`*fTjGv`bSJ4ujz*|89)_X1$8Z-zI>!3;&?XO^LaTP<)T{KqL-!l3aT_f+B= z=wQKRY4vNGu9t-iTZrBLT_Q`8DXT2lEyCQ~arI#W9%f}@IX59uuVVEzHS?OAXJvFh z<(8Qy6{6~Cu_gE3ZTyr8*>%gYNbBbv`;=%91m$fY6t(;!OuDUle}4ZkvQxnG_1;t* zjS+(yPTRFt@b$sy>|KezR`8N6vBN-C8fliYQ8Zohss##1Sw)!v5Aig6-4bPLbU+e& zhZ?#ep^Xbr8Gr15)ahkDwB=SvG=R z>$0ViFa=7hw-<;X;q@6}0kQd}+KgwKvBrN-*L8P=`^SAjnM!w!MkF|Bgbp2j6yW!} zEykg*rf$8=xDl1W=o^}uWPL@u#@}nS#h2M@k4$v&_V&Czl6(2w^1@#y)! zul5>+dgE3>y>&*gi~iogTrM?PffOD~djUKfmF{ZYsbjh-p2>W4H_zd`u@mK7EhkR; z*xvm)Ie!ven}p$M{CjpGWkk7Kj=<`)#kb8qp_42$4jEg2;wOY#n!NzV^|ueI1e+{r zM)DL*@f|{0z1edObl{i1>wIGMgQen0RiCnb*eK)_rTFcP|#=5C%nGiFZzW$UMWUXlwV zb!sbLGjHRE81qz?w{f@7P$PgG&QaI~b=ttG$pqHb(3cjkCW^PdZxc&iB3LaBbMlaw z9HY7qkrjVrEg4T>MRIjf7eJdpmg1}6OoP+iKJFA^Or%04$6DN+ma-H`3%jbv6`?Kr zrYJFNv%-c|C^(!DxDw~=!JNv3IOGU4SFH4QX{^sBY&h5Ba1XK;gP@i(NtVx!(*k~t z#>7)ZYWXK5>HioyGsZGYGg3A?#F&Ss6Y@SLH`nC$UsaU%V zwkB9n6yq*fySI)+6tRw)#NS$;oSJ)E{ZK_%PeO~YXU8;@I%tGR;OILvFgw#`?FCb^ zS&FMW5~1zUeJ!%YTCv)4;LTDMhHxnbHmJMmyo#Gr_o_H1i6;ZHt5Q^4;v&GFJ#~lM z=h+E9lnjHH%`pBtaOEAHqO)WTo}Tz&@q73apYOwdg9MMson%539G_3o|F=z<>6j_5 z)MH2USt)tc^JC20%Ke0?h1b-oXejmJfx^?y$)w-KY8Uq?ygib!OoP3*quw?Zm2GwM z{5lxxFLKf$9e#5n=0vpGTes-)P%h|JQm35<1&CP5$^jE6s+g@BUX_kA)6Ahv~jLRP#X)38V z<)ob!4Fn6lY_Z9y$8w@cv=WYeBwOe_rD2<6(mwCsr4W4D*M}dQ`e!F6Dq1c8(dQ*W zbSx}hiPThC*)rB|onIhVBOis9h`LCv+sRx{BQ?$YbIWP9C-_s3?Y-?#nhDExj`Mk5 zB!=2_(1?AcBWYKAE!>Fb9-{<x+qM-v8tV)({E*le;4EPAa9YVivg?NuQrvhq@}L@sApjM zH7k|Tm9>vI@$qXf{C>=%)0m~kP;92iH0ltyRhb{@bP?eMawU1SoMmqz`1Ei0elsV# zV6$hjP=X;@x3wq3;jt^EuOk9!;wTal0ya0TWjf7qV^L{)iw%iXZe{a&ZN9c*UQau> z!WtghB)=`OukqmHN^_5MvVtQ~%?9^>y{R++xSIBG=jHm=vp6Nw2AW39C1qQl>DrA*(kvAx5% zU8USTW#P;duWcXFWUw+jn`l|cgsPsG^-#4>St$2BG%o)9GCYj?SlEN_xsOL#P2OS{ zNGyTd3F$1-C)DSzBhZ$Hu6b`hbF#QGUW4~g!s~U7*y<@P<;u8ki_*pd!(Et4h588A zF{>?J_TIUbkhmaz6YHls^u<{l<^*ispM)|OBgNeKYU16!?+Ssz`mNhtKuMqe%meYq z_cGbi7ImJ7RLfLp+7R?uxULkGb^*Yz@AJm0`p6q6)Jgx$YSro)>nY1AgfkAG$yFDv zX}OGvEQmNwQypW|P~)F(7|o_8UQwRQm`e;Pu+>XHlAf}*#`TI!u~r&(+-F2jGX`7$ zeEl^V<=v93FBvM?(!jzY@rn#MrbIQ#di&1kQNy}|7xN9+jgB$bN?lD}y-^b^*EV=QwEG+AlewVIl`9r9aKi>zz z)XG*}W(Qa6;Um|X?0IyjWMyNRd1VdmBj?6Sf%y0p;&o-&AAv0?^>T;n2)fWO%^%ez z3JK8j23RzwkN5Uq;M^nPZ#D4*s CUXObK literal 0 HcmV?d00001 diff --git a/wp-content/themes/default/images/header-img.php b/wp-content/themes/default/images/header-img.php new file mode 100644 index 00000000..65a9e875 --- /dev/null +++ b/wp-content/themes/default/images/header-img.php @@ -0,0 +1,77 @@ +array('r1', 'g1', 'b1'), 'lower'=>array('r2', 'g2', 'b2')); +foreach ( $vars as $var => $subvars ) { + if ( isset($_GET[$var]) ) { + foreach ( $subvars as $index => $subvar ) { + $length = strlen($_GET[$var]) / 3; + $v = substr($_GET[$var], $index * $length, $length); + if ( $length == 1 ) $v = '' . $v . $v; + $$subvar = hexdec( $v ); + if ( $$subvar < 0 || $$subvar > 255 ) + $default = true; + } + } else { + $default = true; + } +} + +if ( $default ) + list ( $r1, $g1, $b1, $r2, $g2, $b2 ) = array ( 105, 174, 231, 65, 128, 182 ); + +// Create the image +$im = imagecreatefromjpeg($img); + +// Get the background color, define the rectangle height +$white = imagecolorat( $im, 15, 15 ); +$h = 182; + +// Define the boundaries of the rounded edges ( y => array ( x1, x2 ) ) +$corners = array( + 0 => array ( 25, 734 ), + 1 => array ( 23, 736 ), + 2 => array ( 22, 737 ), + 3 => array ( 21, 738 ), + 4 => array ( 21, 738 ), + 177 => array ( 21, 738 ), + 178 => array ( 21, 738 ), + 179 => array ( 22, 737 ), + 180 => array ( 23, 736 ), + 181 => array ( 25, 734 ), + ); + +// Blank out the blue thing +for ( $i = 0; $i < $h; $i++ ) { + $x1 = 19; + $x2 = 740; + imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white ); +} + +// Draw a new color thing +for ( $i = 0; $i < $h; $i++ ) { + $x1 = 20; + $x2 = 739; + $r = ( $r2 - $r1 != 0 ) ? $r1 + ( $r2 - $r1 ) * ( $i / $h ) : $r1; + $g = ( $g2 - $g1 != 0 ) ? $g1 + ( $g2 - $g1 ) * ( $i / $h ) : $g1; + $b = ( $b2 - $b1 != 0 ) ? $b1 + ( $b2 - $b1 ) * ( $i / $h ) : $b1; + $color = imagecolorallocate( $im, $r, $g, $b ); + if ( array_key_exists($i, $corners) ) { + imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white ); + list ( $x1, $x2 ) = $corners[$i]; + } + imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $color ); +} + +//die; +header("Content-Type: image/jpeg"); +imagejpeg($im, '', 92); +imagedestroy($im); +?> diff --git a/wp-content/themes/default/images/kubrickbg.jpg b/wp-content/themes/default/images/kubrickbg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..dc74fb8d3d14f0c2dfd717b9a76cfb95cbf2c0c1 GIT binary patch literal 1043 zcma)3&r1|h9RIu@GrP^s=o`lcb)`0xG!e2Ax>&9u%Wib)FBob)iI{>?bZ}V&uerzY z(xnhYqGJbHBCy1ZF8?fdT!_Jm&M`z3+VHJHe;mE5w~*xd=jm zio6gU!5yD_F!>k+9KeW_e&W(tW%~XEDh;U+hAd~MVX*XohbNMpU+f-&#)Phk(euw|Gxd=Ris@MdYWv_TF)Aq#?W2G*yZ;FlZwRw8B*MS znO|K~EDm@>@oOu!vqf8wUzC=gN(_1^Zrqz4cXn5n*<4?5;h_9M3Qw9o4gEh~nwUi} zrRFG|3UF*h2_e$?HNW#cv%a`Ab^hU-AEgBH|Lu&7UL5xG&dox9Pm$u|F0CcgE5~WV z{U>P@*8fG&a&JB9t|_sEHihFr>jfk>sh9Iw2iG{(N9#|K9Hw5|Z{DAe@lXB@_GGzQf&@_Wfq#cPzB<3W20;Osv-E+3qk4UIf%<_J zk|>qbY0h}ZxdFt0^U%NI23jcm)O2nx(0+W*gQFM|LzcMKK;1#jL8T z*=`#Y$8m1*iM5ky>B?#Q@L%v7xP)!bB{>L3(vg3}8bs{98*xv8{athFddf~uDSC>3 zfsw@9rQ;8}?{4ifmnCe1B0*ae0cAiT^r9({0f}0bBrW!u2?6B~1}FA*wg2b+Ho^@y LjA`&|4CC`Bv}sKI literal 0 HcmV?d00001 diff --git a/wp-content/themes/default/images/kubrickbgwide.jpg b/wp-content/themes/default/images/kubrickbgwide.jpg new file mode 100644 index 0000000000000000000000000000000000000000..77096f24a454461210f8aae017e0b2cfa2d03166 GIT binary patch literal 1014 zcmex=Zw2Bn|8Fz2FtD+(u&}bQv9hvpvH>wS2OAp)HxCyV zHy0O=01p@l@bK{q@bmEq3yX*d3(H7LOUuZ^0V6v*J1-Bfgn)pAl&GMn6kLK>#{WYM zf*cGQOh1?z1sRwG8JPtc{~uv!WMBjWpz9HUnS~uq1SluKz>KOc!I(vWp#f+TP#mF` zfw544X;T7&5V9CZxP)I)4%X0%r%c(35TF_c7J_OfFc5N#r%D6D_X5wd@7WX!&s<;e@r+;E-p9ucEoXi2 RmpK9vhWlRt$^RhsO#qt}&Hn%Z literal 0 HcmV?d00001 diff --git a/wp-content/themes/default/images/kubrickfooter.jpg b/wp-content/themes/default/images/kubrickfooter.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d7a4c659943978b9ef7fb58c1b0b480e98d857c8 GIT binary patch literal 2443 zcmdT_Z%kWN6hHU9*S{2ak5VlI*Rr6|jKvX>iAH%PI>P>tY?_9eEdf>xE+f`TmW{bm zYNy1^1;z)$hlOr4Mzb-?_+b4LVCx)>no#+mP%%S7w3*_zCQwRg`@HX!wy2PYUyPpn z-n-}g&hMQ2?&*2A+!Xf{(0i-*R0ARan(zQ_9+(%7n~${t0tx`0#n3%?tg6X!ujC6`L&St_M6OQ}@RDnV#f zPA;9Bqf)E$^VRC2!otELU0RS#Cd*c3YiU}$MZ;*eq#c`8I4>}AV2KEc7$6u#GKl*U zTz~|@@1GKiAdw8Al$n}oAOWPAY?X~OmL2}ID=24=`n zm6t|W!@Jd(NaCWA6wWIMgBs7%#buWo9vn0r=(bilCb%C!#b;$m2G=)Q{O#Z>b>oRB z@7rbC*uCmO1s$&rh_Z<1^%_wU>_u-~6lE!Do#zdrEGl?l|BIq5R8~`h+fPgu25|Z0 zxXMUEJaeJI;VcZ*+vh?T3t5#;kLP%W*%&} z54(KqaJ}pPlXI>+y8e?KoD8}=q45e1+Japl2JgEqAK!i`-*m8X_uK!`NoV`Q77itU zeiE_8{!iNbf!sRPJYA_bhE5wZQm;wrYta;DG}hB)zrSM}`bv_4HlZ~+`L#+Dw_@LI zf}NqbrtD{h$T-`4Edy^tdpVl$?-N3Yb(Vh^dTL~b4-Ir0U3biL+h>!@)p@U^B!cUp z6pRrKcGh{_Jy!&5M1xsZbFQ)jlVjR&sHgp<^4}664i5eJe;ge2Dk8Ohchnb4_6|PG z+2Ta%i^>?8GnvlYQ_>@HK}QvTRCVAR0S)+~cpdcETz$%UTTCdig-W{r`X{qaN*am2 zaLGDhe}nKw#Dq$JfOI4febd)n_iaS?#%j4!yxaP;z>sNjCq{hQ4H+ hbK&tnF~Dl}cU7~yC*C`f*qS`B`Cg;f_L^V>{s00+$msw8 literal 0 HcmV?d00001 diff --git a/wp-content/themes/default/images/kubrickheader.jpg b/wp-content/themes/default/images/kubrickheader.jpg new file mode 100644 index 0000000000000000000000000000000000000000..69441ee3aae0908334b77dc449b19dfbe9cd2774 GIT binary patch literal 7868 zcmeI0dr(tX9>-7K2uO^exKPblQ5FSxD7s@U5f!OCi-@QY0`gEm5DW4&T(we$x-3=R zP(Z4Hppb$BT0}ss3M>r@A!3m5SmY&d0+QtB?oCwa?hG^hu>;NyCpYJ2&fGcocYf#l z`Tc$;$Sb5BtS~!p@BqMI0dPY<0C@)}`_H+0hX4$~0{{-7LqkBx*zL>-ci>iuj$jZT zxD4<(X+wKF5s!XJ1U#NVk|PpHM53I$+%mMu$;&HB8`>{luBb?nHkFx%!4n8_BssFY zJXu9aNoi($-an8^K#>E_vF~vh3cyk@I0^=N0-^!tV?!pp@ILs9jcd~$Ppq)>#Ox`zEoaid^K}# zz(xxCFcF;-V6nIllV-la9>TAx+Do{Eq3GjO)*GKiUIRrO`UC|>0W|QgofdCmXSk6) zwYjjsxuXREk2Vf$MQ>qys+&Tg?OA-s*SK2~5>N9-5AKm{`ou32nf|AgZZuA3Z56(4 zSZkUyZblc>U*8pD{Wh*_Aa&2Vbs6r-TPRAv=EH_J7u|Gqn%TuoQ-`RvnlK4s<^3;_BSaflA$cJ39`a zpg%@{T>@n8QzRJBDdLafI_u~O4icz|{7-AbP+i!CH`n32)(CjvFra^-PJHo>t|$5B zucMwLL!FXL`_Rd?hCGQvVPRWEh=Y4c&dG`GVli!Ui-ZQT*n_FP9uUiPd>WP@;2RhL z-Io60g3j(eRB0u&NG`#5RWs!RCdI0U30F)V~rT&J39exqJHFU~3$cXCR-9AqDT z+AB5HA~n+@Ca$>6yROmi2bS6^&Nk230IjQI31#&mp}s3PT@Gs5J_f!K21bXtAuL_X z$7&C~T@Tl1TQ+2y)*c@=?C!h2PdZcby_(-to==<8-##qgDd#nsA8orMdFS3_s+RXd zZen)Fawo&WJdegry|x>=b%IjHCR*3uep+H^@!IW;yxaMYHW>ytKh0e-X~|1VT3RA* zDK34Ep;D8>Msv+~f<#t$j=M-30qUi>eVp>b>LR}QXLzhIKjz&VvB1DL@?Qz$F4!f^ zUJ@U5#U?UHK_G9=_3QU-9dU~P$DpWy=Tmqa%GB?5K>&*}It_;-zzm{ogMXxD@Q24m zUflGSTL|d=MUb?~^_BH7WZxW_3WqZRsGT8Zoq{?939tV3dsTp$484-!c zlBRYs{bCF<4fGUopmM>wUlBln7}E&2A(_@4nhcWX&-9U#{;^4Bu6v(Kw z*%f0X2`vslz$gDFOZ^{Rl%}^}u9v;22*SP=elIoOB1~%jd(`}I|K$CoIlPY_pC02h z@{hrnGOCBiYfrZJ2_75N22?Jba!~WJ^p*A7FauDYJS8?5&w+cySUclx}O(V_iTAw9O`BE;z4Q zux@osyE@}rShZDo9r}J1sU?T$v%2w^OE-TLUn~w7ZiXMomb*>5@Ksl>k~FY;7X3P2 zLCt5HOfdXrwPYihC3#LQ@y3)mjTsJ;-Ly!4PaOL}WutGoO_0eH{u%1%h@Gg*<8|pGj~i?> zUuZl|o-1EiRD7vJ-znhx%3_3th-q|x-%Z=>gNwdL;3rk;voOXXCix>uZJH=bZ{~rL zp7=^}0GG@Bh|(aMeiW}-B`-Qhr~!@$SgXS{pP+qYDL73MVmlv}%Eoqa8X5FYER~`x zZ8kADwb&q`D#4r+pDh;XHo#S~pk>|}G~I1850+N4YZUA)V2CG+k+w#B>w*;_DmA}+ z4lH$zKH@gg>VmOb) zlsI;R^AZ7!$={`6GL9>yiTIghrf~7eVu5J`v*tr)lG1d1h9-loxoV%4w3^%Y=HVTG zT2dsfC~f<~mYu!irw)w668@BiED6cL@t*;wHh!)o^bMrxL)Q^S@>JTSm75b93%(H6 z1~e>a*@?Seu_m8sD}q{MWu==8k--^6HXoU*bfbzhiUU|fR4>^n!7>a@q5eFr#(fKV zVo|y*b}km!4Lv|pEZMWc|B!P$n@(uV!P>w1wFN_UG@I1_ucwdS}@vG+6C)E}1rDy2nfgGQNmNSAPo{lz+2E|1V z_l&$hX}o|(J7$MVXIH0VRn>zqW!05}#H}u^MLaIcsoblmPW!Hq=Tq`C3`@vtc6T!^ zCUk?qXN!>BPs + +
    + + + + + +
    +

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

    Not Found

    +

    Sorry, but you are looking for something that isn't here.

    + + + + +
    + + + + diff --git a/wp-content/themes/default/links.php b/wp-content/themes/default/links.php new file mode 100644 index 00000000..2970897a --- /dev/null +++ b/wp-content/themes/default/links.php @@ -0,0 +1,18 @@ + + + + +
    + +

    Links:

    +
      + +
    + +
    + + diff --git a/wp-content/themes/default/page.php b/wp-content/themes/default/page.php new file mode 100644 index 00000000..5f914c12 --- /dev/null +++ b/wp-content/themes/default/page.php @@ -0,0 +1,21 @@ + + +
    + + +
    +

    +
    + Read the rest of this page »

    '); ?> + + Pages: ', '

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

    '); ?> +
    + + + + \ No newline at end of file diff --git a/wp-content/themes/default/screenshot.png b/wp-content/themes/default/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..e0b1d488e1e987de70e4a929786a309dc83bb216 GIT binary patch literal 10608 zcmV-$DUa5PP)dT*e~!@a<~vZ|}Iy<@1}O^?UE+3>`|!~OgE`Tqa;_VVB4?4-WueYxbq z#LItkY|F;Ov#zx7>gCJD%;M?s#L3R2o}#VL>{yn|?dITqgpBU(@5#x@eX8O3`~9ug z@kWWiPnXewvfa|p(r={F>gexkpwQsn-d>u{Y^&QxkIH1C(ma8>!r=8)n9xCjx%&P4 zqtEYEkH}!Dc1c7*RCwC#orz=8O1HoU|U+CODfvUXnpOc-}727KESYK{`Gez)a!n)^;z%rGouZY$xK3iIdjgL zC4kW04M{uGvl zF+fd&LjEbNeGa({P#{@o(l`GJESnCCcs~16hX*1Oz7Q7jy#Ak`JUH854C}%F{MXMO zSoEc^whdUGFNbx@fMvk?;_#2F!1~9}9t>Dt9_|{jt_RlbpPkj!VBP(>!>y~px@*8P zU>UHkfz_2@-TK+X6=2;kU>UH!INUa1T@$R^KYK7>8L<9xSmy?;FNbyTv$MKkz`7P# zj)NOl3+D%y;l}wVkK*lgbAAJ7yUc|Pd{F+2uRJY^PknxVT4&S) zosP$P4(H*vUj9i%dcXX%f}USi-M3X3onO zubklW2XD$Bye=L-C_0`zFFKxrx_ezLIv(lgJa~;H`~(~a53-K)^MiZEVh6YtkI&C% zm(OwJ;O=&DvGT209zP+b zUlOFr;S@Tk^BgUoPIXpx=Wa!Q{C;^qT=j0H+j(+^GEm+R<#DZ*j-8dV^NRa!WGf=qA9cV2@q-U!M& zKyMi^5Cnl3z1$3_w<0`@ncKmWg$IbmN2JpS!l9>)I%nly{!!r|DTp4;qR#2e`8C2i z{c2dj6U;$9XWJ%%I5W-Zuoj>y_a$Y_6xRy`PXWl%Ph2LTA%sfGv8!V@n z2g!m;#mbKt&M>Toi7=h{r(yyo)CIipB>@(Jk2qHEArI;hY(-s#hXQ9PnjX)hxvM|> z>xH%OyJWpu09XrWpe+`bcczbY;WZMLPoGqTxdn)-|GFL2egRz~9naiw-kEt17Lr~p z0IUOIS|0R%8cWuz)1qtn9y0BmK0UttatltR7Xisy1%vV8^vR>s8IZ^md|>YMRz?2h z^n7{Y^lMH=MR3w^<~5kZJWC z&Rjda!B+3gfV2soVEGpv)>ZH3YOrRm8Wvu&{?(b8+pPL(;TD@&Shz=sqG@^I^5}!w z>CEZ#^yayV$~N5ciHrt@~3dx(;FV?)#(Fv z`SdoF@HlqfT=IeX0zPhgpvbMFC^kBf_Jnvmb2{tC*PZoip=nNv6dnQ^81+rgUN zwa(|A=x6gyb1eL6`Gxlq7d~;)%Y2`>+S@Z+`DU&F>*37L9Txs#SPQFfrQ$s)`25bF zq+Tbi)hodIb>W+b)u(q}tU_2g1#CO3rwgY*?{pQ?Ug&A3r}*H^bO+K-^~|gKc4uLl z3Z)?b!p(&j`Yt}j>cX{zzZTZb*PZ3g+|H9<&JTB%pDrIS?<^m$&MZH^c{tZOezE-O z_;C5v)8m^r9LGCw=+5fn!^cmLAJ05qhL4+vojW_r|2n?&^zhZ{)8if3?kvAJK7PFX zXy?wg&|19$tj@2i-#VPmzWQHhr!(j59CjSX5bMl!0L|R5&bf}WGn#{hj>GY<8;;KL z_MzjKUk^J@hhy%rGwO7Hd3ZSIbc~$akYyS2AI?Fk(cGcq5YDxHbM;z6;|h}X%`Xnp z@d)l6U^(aR!5>6B4_{|HzaHXvXL;`M(CL`_*A3Xo&fS~)Ro^{!EIXE+uO8ye9f$&_ zU!OYWoB#`U{f`{W*;n9xyt)Qhf2m}xt{&e3SLo^Eh2s~GUcGwt;_>#}!=2+hH)mjP z;rQ{ZomVe*epy|3we$G+&ZAd1@$T`9$2Xted9`};#qq0E*m(q*Zr-`GaQv^EtH+NY zJ-Tz}@!Uo73=c8e4sF6Q`|SroHp=@J%x8uHq!U?DW5W;Gv%K z5dN=Di+}qsdnH&mfA(+%SpPI&8L+Me)_?!xs2)BvU|kcehd+BTU>UHkBmBpITm{yD z{OrMibv>~D^Ji!EPXpGMvoc^Au&xKze_sXGKY#XMz%pQ6OE9Y8RbWY942$^ZfBxj* z4)>+7T!Lx&m!CS!d0Z}J`%_qW8M_}f2;VN0HO=*J4a=o{(_p|dU>UFsSOzQu){hK} zyF&QcVRhv%4rb=_0DlTt9Ajg?ICMF#`(a=vKNBqZ3S~G>W@Lu>UDj~a#u>0a151n# zhf)gF5GCE&Ktj~v6k}Jt|$g#IRo)7!x!}x{V^&(pD&8MM+8$NsU5?ll%4Kfld zFMaF1@QQyWX%9#BNjg{mTFC+kmieT2o|?DzHsU+KW{$jg=a@Wnc@2&YM= z_EZYjNnt&U)`@(0es7)Xc>qupj`~3~=X-FnmHCxkWFD?T!twCB=Q^t))18<#+1#Cg za%argM1C!-$UIuNF3#^Im)6tk;evgg+Dj$vFMThgJ<5a+V{riy^Fbt=53lsX5|$c= zcOIpBxc;FP;J4xcIA=@idqX)fpG?eypa}B-%alq&3G=$NuJ#7=RPq_f@_Z7d_VV-L ztT5k6^@8hraGba*EY}wYa5O#&%2&dwO2{Un0N+FrX)$F*ktDmT?y8#^As@r?k#7q5 zLPd|n*?QX;0t8%XH0Xpy&;^X_WG>Vg6m7WJXTQlilAi$_df z47BvhroiPg$j*CEKnsB;OSn0Uczqr`_bKnoXd8YeeAb0GU|nZJdQqOVbvKG^gg|XF z914+)A}XF;$$<4CEN`=9E2$GnvmM1V@qW&O81H`H(mxug2CNTZ1qNG3iA=6hK58tg z5xOa&#UrI}IXbfSg9fY*U@(l3R@DDZGOB;cR%5)4>>2n(gclqIuRQWv-6Bb75?{UNMqIGpS4@f5X3 z_0k5cKY^9>?yc{Qsc6`e+N&6_{s>mt#x9ZMMz2uqt4GrJl&nq0#}u)GV5R z&oK44%(l{7uYPG`K+5m61O%J-ofN#QtbqlWpJ4^>`ko4YgQhHf+OkGxd~PK%9&FYd zC}p)+tV{OTSn^pbyAW4>O`Am} zY1Nmxem{$I{RJL8HFQVAG;a;LBmAJA8&Xze&o%9yKrWZ#sTkU&hGRF$4>mISF|Ulh zdxZ^moCimLu!M6DXgZgml0lR&Sa^ybL}M+=oe-}dmZsq;R_}!}_v!R+25X7Wr6Xg@ z)|jLV`{b5opI1@Doi79z$EBnFL=$JQM)>{AZoO4%2&KhD)5|L@4_a(iacDn`(9hkPR&NQal)IVW z&ppU?+R~wEMAV9oxo!WfKYPf^wd{RXIt)rqle6d;IcA?3a~(o?>EzH^tFit=;(qbI z)9>)t95v@5YjQZUg8w(xRIA;0j%tV7oB=DOhz<6{B#BIxXb_{K)M(TmG#Xj9J8Cq_ zrfpVr5+l?7S*d8i!aA$Wl|g550_Y_HZy4AJ9NyPpU&I@U6$E3-(bV`|D(}k=?)`3e zVQLpYAz0;~P_j751HvO{-NtmLHWn=WPXj??#I6U9=rKsf*su`lQpk9O{|~GWOxL?T zTHJfXmD)SKU0>esb%h=>*B4tu^F_J#z~mr6vCkE=v)Qw5t(e`;I!w+BDQn8s9CJm% zIWn2Drfri`WSk~P`^4EPnuyV8?o9YvSow6E8ZgQ;n+KuY1~hLZU%DM=RF#|u1=dKJ zR6I)xLINpA!39-!RXpy8s*wW2XgIbZDGgjQL~@F%q5z9fNEMX!uIlP;HkQ;jQq1aw zBIE2xfurRr)2%AthlCV30gh~{F7JsZce}{f6c;5#dM(h@T2d|ok`RvtKdInp>Eu3G z!`i3@U=C+%9vMCkxBZ9rF0%KX4nL#{{t=i-CsDh{s=tjo9<>Grv$ieOMqdl7x{~z8 zc$ymU9#po6D?%!5=V_Ww45A(s=X3d1i%w7`X!Ydz{J1{gV>IPP0-YPuxiM8hDCMTd zK_QyS(KJ7-)8O+XyE_72{Mu12nzR?%(4vY3h9pgoskJCHE|*FzHxKOu6sPvbK8OgZ z7`|T1EulQ^j)!yZz)BVnMy;tjoeO^&7RfX`l8G=m8bv}f6$w$EJM)ifuccA&BwK6{ zS%N5=OvR!^Y!joP1fCcxn+R!C%oYjaYiIsN+=+3Y&JX(o{PkW20T6BB2ljCz50X`< z2bL|m6>A{hAV27r;LC6E;WQHJmf^U?hnql#9*jjH!n;ceOKvL>UV|o7YaH&=(%hwn}{e zld#}M!DXMmR-)^wGADxN6C?u6pRSv9qlnFWR~TVkcCA{8y-lXOw496t^(JR6ljWGi0!IJu#HQbO-4SE8JrZz zl#e7cf~t6Ah9-b)JCgfMJX7sYj?ASX+MFn^BMAxKzQPE7h?r%@(tuPr**@#-oBJvQ zwR6{^o}9=VnNKQs3`CH%E{kcrHFARRZ`GgG{U+A1+%OeQqiknna+v(1XFq1=AGG^j z-@|n%pB&EBMt)G^ptK#q?!|ZNqFEEGW({$RBJSsdD!~Y5JZ}P(Cn%K5EZR-x3o}|| zt58ih#i|W$(gb2A2uydEYa_E5VuXq4(#%K(OXrOiN||;@E>9Q>b1`WP7RJ^_-gwAY z4J`(|+P8wmb+gdS0mW`I5p&K4L5SZ4R-AHs!vobGO;*bJBnm{`VD0RDv$7a%(y79r zH6CwJR?yICq~#0wR*8<9zMLsI# z-WaagW7uN(3h`tmKqYe)zM0Qr^A&C;TH)YQo~CHK6e;Ax78*OZ_C{o@&WGtOI$GFl z5kj7B(q*sR9`V^DUf;9p7?J+szP@iTi)Lc$4)@UD$Ek54zgNf&t$msrQ|a>e@!;u_dO0L|Io8KqTsB?aj?Tv$$i+=6 z<;#JwDl7_W=M;(oL2Ve42u!I!#(mtd-cAgrJdxe#k zd^8;VF0iWkG&r3RcN?J;FU1F5H%Zo2@W1Nhk)0poK7^QMuYm$#KG{E_!AlPmlzf=1 zvq-RPSP=?QWCC(6+38$bCi5m}^N>fmOrUO~`vnmR(J|HZ;@1!2F+?lGJvo@hqGYJRNb=p0Ye_4?5e zVEA%YAAv%&PtCE%+$LGMoolYRAd^|CP!(+J`-g2nyDqm>mJL#-=!+W%qqk{JlVtJt^UywaEtSneGs5}j-)eofVar6?b91$pu0u3SX9oJ_%u!pyOqL( z$241oc%eTg`->?PMt8J@bE6HuA1%bAZjx{AGxglieYCZfYeosUf}0+*XsJG6eFcPH zPuYMbC5uAi5^2e={ry}Aef+%(Cb)Vyq0pE6RuK+Kkiv^Jj121%Q?BV3@|y>LxM zkpTs>C~J#k+qGl^G1RKIwl1J9q5Jh7yl`?qTayTu)v~jGN4A!AUU1jnpGD`k2CczH zDw$6w3h_iZZ$*mhO~cYDch^|B~3P*m?g!6BE44=S4pw~~pE2S;RXOwwzr&7MKt#DG+kd?C1$qB4`U zDkSYfip{PD-Kv;L0L?;i#eb zW_5@fVZi!iHJrNdS)$t&yPC(-^=R;S?M~@tpPWo%`0bNvODv@7jXvyrx8G?#%6}`J z_0B}ea{22ThgTmrOj+$MDbTbR_La3tbz|5-C}H)Ixxw0|J)Ki?4Ya#v%Zc$!E|!+1 zzmql8$D@C5Nps($Asz8V>h6s&ok5XUFqFXEM}aY&r|UGm=8N%^8~K_kDxFW}>SJF0 z+rV$ifT;Rn zeQHS4aq7bScTwJYqjoQwZOi`cEP%UD2-gmabAbcQn7cAoN&;7vFHqI&!ktBd zCgVbzGVWTMbY;1#?Pkj2-vt&e$#aMPLuYNf>^$>3Mz!qRS=n$(KUoc{jMimDvEea! z%7jPubP2)e{QDzoh~EU$=SG&fujwZ>hVKnn2CSbA*0sEm@<#>!@+F~iLsrmSnysyM zUGGiD6(;SF`2t|xA1E_r4o?dDCM?z%IY18$UBVETlPBNh-}dyj1=AX zQEB`JN~>w-S%78r6>@f}RFA}<>iL@aaRmv!7)@JBxqK$!&L=;rhAw+Jy=bweh(Kl$ zq`f37{Q+Y!d)4djb-A02(3JfeZTL1urT5Iy8N=x3sWD;oF zCN`V0rlg_D*p!J)fktIjvB{+dso+^8&53QZgjcsT$1~n$8-++xvMK6jPQ|aALres8bGQ{nM& z#XW5GsGgPkE(-q5ETfOZ67#_b`a9|0IxwF~c(;@2&6J~POtSZSRH-+n#(UB6kRpds zYR%pgjn2Q1U~$!r%x0hTN`Zc)7Yji(l$C0qJW{V+XMv({RW*UBDwU9eWk_Hc5iv{T z1=4r$ALnwx5vDDO*iI?WWK_MF3S^vR@G=gtsUSVWqJ*lFCZZ*U!>iOH*-K*Gixw5d z(!k4mD@PiftGdz9b+QXFS^&&n^&;0maNW&%MFxfKa`~)Pym~AnZmJ)<4%~F&8(u=f z+y*W0f`9rHlxrW6wio)on6E`s!FV{wt0+Dk#wMv|%Ic-?@Ov8h3X!eBfFC64^spa` zgmWdZUSg5*{H*`qf;3n6 zvxd-#emW%D_h3av5(Ovg}LXG&L1l zPR-FIZQjVBMJfqd2bB=1Dy&c<>ypoHqp^)#wDeV_bfidV7xtBnai&za7BUiOr#LYDZg=x~gl`3dR1GwV1UIclStKkIDEHQ`9M*fQT9R@tRnrLJpN z0bjnH6E(DW0+EU^HCKOASc+JdM7(T+Nn{+RQPD(Tc3Hw>8VQmkxT*A2nfunT0>f~L zqQa^#JRXE$uea7JL~%sn`F@lNr~j6)@QNXt{(3!D=7RoGz0f5tV9Q)g6+F5I1)q0E z`Ph&z@Vz~Hi1LN#UK7vH&Ud^?JH-zZG3M_H>vwCYO|7Bs+H=2K!!KGT_v(|`sNTM% zWZCEW*wFxO@-4OH_72E4o+{vhjS8LEXW`sv8rVG*FNl0a>s8wZ~ z-2L{;*p)IrqJpoQwQlFkQ5<1wSoAouU<-*FUbvu0u(Fd?l#*gt!}qP>$T1qZ9G(-f zhP6WnwuXQ$s1~0c$w!k6XTZ8#i-s)|V)krQ%!(%1g2&~bc^>$9FoITTx zpVlpU^d;A(|AaEvAT*6JGX|_Ta~))kah_$*vS1CfBO+U@5srp~z_Es?I)jQbFs$J_ zvuLn2+;)r{f`etSHN20lp`+$^2ALX5ve#h^15!w3y3hy&Pu&}9gLHG2_74E-NG_XL z|CxW36&symZ95A-7I+dx!Za(G9Kl_sL`vTrR-DgUeMyT#N3AG7ES2b1a}fLibe3)n z@#M&|_GSeiW`vg>lUaSzWY^XG_SP_7@YVUSC6=d}D6&!KV_P)Y{voWP_MyF-wh^aG zJ#g34Hf&VM+`yL6aw^(2``oHcHCKKFYp8Wa=GmqF6Q;}mX`&v5HX*}kX3?;QZ|1>w z1u2^~6&pq3%ztJgOlQQIlqE(u>TE0CHCxFd86N!GH!QN*nzKguU;9VDfgyDGoujP3 z_*>0UyXZ3{sq~Gu;XCi{)V58g?6$+1Ejmn2=V;p`Wu1h-=;*Y;%d+j0lHq5)tKGpK zPG6h5@SovnrQF4ZrYA61rx`lyGvR}|%3rqlkugp3S|^5Vz8ww>y^Suuc}r)}5?tz6 zLK)=kPu(wXv%PB(0~xfqzb{Qbb62ui&piEgyDIx{11nY7bq7&kV2^==s;XpNim$m) zB)K#o!*G|IcI(Dqt27{^ndz|DX3Cw2Z4UW#DF0HXk`i7?Wjyxy-0^~lyagNGL`!zc zO%52ldm|lbs+)A?-v!nt6()IB@KJPHpXm{!>(r1%p+dDq*7ZJmTU|@JL%EFti{fq( zRTGk&;$x8*iWE?^HSAG)JT>HdRFsm0G1;Q)m3Z17EAa{)Z#DBtdu(6*cYzgABWo=} zNQG%Pu*eSwN2NSSTKuJ)AJj=1*~6arSdEM&FYkeB{QK(M%OebTsKpE;ha~Ec_!j+`BJ`xxN!Dh%+&-s__P@nlF%y=V{58GaDH51taS-|6F(=(65Y$Bf2!X zy3ZgN!+0gvvu_KF^A04u3jgJ3xu7W0cbcvI16o5A-HWv{3Ae%*HpZnEIpp2Qfc1G; zZk}?ddIKsNqx#e^VZiz?KWbA2z80dH;3gCi0sJJU>VkwtvzQM zkLY1MWq(IxRVORTtf%X_Xt17(uH(4~@dm-d&Ub;eTUwi_nzCzQ6cor2f-+It$nO~u zXIhpeJPyLd%0;p0IVlpvNQ9l*EW)$>YY*hv?Ml}<@?4D&Q?VrP4slR== zmccc_qDc#BDcLL=w1wOt1WRd6LJk(bfb&7O=B$nI4^BBp{#tR=aAxn%I-5OAqGLAe&yFDJ!^LW@304MKEYe25zrUvRL9#4Iq=ftqM>gwtV7h+vcy-Zu@9Fj&{yu6 zzF(pLSc?9;hBy`P01Z_13W6{wu7ZzUUwR5io4*%EpQzpRy_C#`s-A1Ef!1}a;Cz%sx?fz&qa*k^L`<j=8t>(M(*F~d`Ta1l z{NS*jMbju@O$-MuJ`+{>7JTwaek17{CYKU1bQM_S2W-s$C%^zX`@1Wm-v%uJ0000< KMNUMnLSTX#8&YHd literal 0 HcmV?d00001 diff --git a/wp-content/themes/default/search.php b/wp-content/themes/default/search.php new file mode 100644 index 00000000..4c6875fa --- /dev/null +++ b/wp-content/themes/default/search.php @@ -0,0 +1,42 @@ + + +
    + + + +

    Search Results

    + + + + + + +
    +

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

    No posts found. Try a different search?

    + + + + +
    + + + + \ No newline at end of file diff --git a/wp-content/themes/default/searchform.php b/wp-content/themes/default/searchform.php new file mode 100644 index 00000000..c7c73f17 --- /dev/null +++ b/wp-content/themes/default/searchform.php @@ -0,0 +1,5 @@ +
    +
    + +
    +
    diff --git a/wp-content/themes/default/sidebar.php b/wp-content/themes/default/sidebar.php new file mode 100644 index 00000000..03364b89 --- /dev/null +++ b/wp-content/themes/default/sidebar.php @@ -0,0 +1,72 @@ + + diff --git a/wp-content/themes/default/single.php b/wp-content/themes/default/single.php new file mode 100644 index 00000000..1130d2f5 --- /dev/null +++ b/wp-content/themes/default/single.php @@ -0,0 +1,65 @@ + + +
    + + + + + +
    +

    + +
    + Read the rest of this entry »

    '); ?> + + Pages: ', '

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

    Sorry, no posts matched your criteria.

    + + + +
    + + diff --git a/wp-content/themes/default/style.css b/wp-content/themes/default/style.css new file mode 100644 index 00000000..667b7a56 --- /dev/null +++ b/wp-content/themes/default/style.css @@ -0,0 +1,622 @@ +/* +Theme Name: WordPress Default +Theme URI: http://wordpress.org/ +Description: The default WordPress theme based on the famous Kubrick. +Version: 1.5 +Author: Michael Heilemann +Author URI: http://binarybonsai.com/ + + Kubrick v1.5 + http://binarybonsai.com/kubrick/ + + This theme was designed and built by Michael Heilemann, + whose blog you will find at http://binarybonsai.com/ + + The CSS, XHTML and design is released under GPL: + http://www.opensource.org/licenses/gpl-license.php + + + *** REGARDING IMAGES *** + All CSS that involves the use of images, can be found in the 'index.php' file. + This is to ease installation inside subdirectories of a server. + + Have fun, and don't be afraid to contact me if you have questions. +*/ + + + +/* Begin Typography & Colors */ +body { + font-size: 62.5%; /* Resets 1em to 10px */ + font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; + background-color: #d5d6d7; + color: #333; + text-align: center; + } + +#page { + background-color: white; + border: 1px solid #959596; + text-align: left; + } + +#header { + background-color: #73a0c5; + } + +#content { + font-size: 1.2em + } + +.widecolumn .entry p { + font-size: 1.05em; + } + +.narrowcolumn .entry, .widecolumn .entry { + line-height: 1.4em; + } + +.widecolumn { + line-height: 1.6em; + } + +.narrowcolumn .postmetadata { + text-align: center; + } + +.alt { + background-color: #f8f8f8; + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + } + +#footer { + background-color: #eee; + } + +small { + font-family: Arial, Helvetica, Sans-Serif; + font-size: 0.9em; + line-height: 1.5em; + } + +h1, h2, h3 { + font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif; + font-weight: bold; + } + +h1 { + font-size: 4em; + text-align: center; + } + +#headerimg .description { + font-size: 1.2em; + text-align: center; + } + +h2 { + font-size: 1.6em; + } + +h2.pagetitle { + font-size: 1.6em; + } + +#sidebar h2 { + font-family: 'Lucida Grande', Verdana, Sans-Serif; + font-size: 1.2em; + } + +h3 { + font-size: 1.3em; + } + +h1, h1 a, h1 a:hover, h1 a:visited, #headerimg .description { + text-decoration: none; + color: white; + } + +h2, h2 a, h2 a:visited, h3, h3 a, h3 a:visited { + color: #333; + } + +h2, h2 a, h2 a:hover, h2 a:visited, h3, h3 a, h3 a:hover, h3 a:visited, #sidebar h2, #wp-calendar caption, cite { + text-decoration: none; + } + +.entry p a:visited { + color: #b85b5a; + } + +.commentlist li, #commentform input, #commentform textarea { + font: 0.9em 'Lucida Grande', Verdana, Arial, Sans-Serif; + } + +.commentlist li { + font-weight: bold; + } + +.commentlist cite, .commentlist cite a { + font-weight: bold; + font-style: normal; + font-size: 1.1em; + } + +.commentlist p { + font-weight: normal; + line-height: 1.5em; + text-transform: none; + } + +#commentform p { + font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; + } + +.commentmetadata { + font-weight: normal; + } + +#sidebar { + font: 1em 'Lucida Grande', Verdana, Arial, Sans-Serif; + } + +small, #sidebar ul ul li, #sidebar ul ol li, .nocomments, .postmetadata, blockquote, strike { + color: #777; + } + +code { + font: 1.1em 'Courier New', Courier, Fixed; + } + +acronym, abbr, span.caps +{ + font-size: 0.9em; + letter-spacing: .07em; + } + +a, h2 a:hover, h3 a:hover { + color: #06c; + text-decoration: none; + } + +a:hover { + color: #147; + text-decoration: underline; + } + +#wp-calendar #prev a { + font-size: 9pt; + } + +#wp-calendar a { + text-decoration: none; + } + +#wp-calendar caption { + font: bold 1.3em 'Lucida Grande', Verdana, Arial, Sans-Serif; + text-align: center; + } + +#wp-calendar th { + font-style: normal; + text-transform: capitalize; + } +/* End Typography & Colors */ + + + +/* Begin Structure */ +body { + margin: 0; + padding: 0; + } + +#page { + background-color: white; + margin: 20px auto; + padding: 0; + width: 760px; + border: 1px solid #959596; + } + +#header { + padding: 0; + margin: 0 auto; + height: 200px; + width: 100%; + background-color: #73a0c5; + } + +#headerimg { + margin: 0; + height: 200px; + width: 100%; + } + +.narrowcolumn { + float: left; + padding: 0 0 20px 45px; + margin: 0px 0 0; + width: 450px; + } + +.widecolumn { + padding: 10px 0 20px 0; + margin: 5px 0 0 150px; + width: 450px; + } + +.post { + margin: 0 0 40px; + text-align: justify; + } + +.widecolumn .post { + margin: 0; + } + +.narrowcolumn .postmetadata { + padding-top: 5px; + } + +.widecolumn .postmetadata { + margin: 30px 0; + } + +.widecolumn .smallattachment { + text-align: center; + float: left; + width: 128px; + margin: 5px 5px 5px 0px; +} + +.widecolumn .attachment { + text-align: center; + margin: 5px 0px; +} + +.postmetadata { + clear: left; +} + +#footer { + padding: 0 0 0 1px; + margin: 0 auto; + width: 760px; + clear: both; + } + +#footer p { + margin: 0; + padding: 20px 0; + text-align: center; + } +/* End Structure */ + + + +/* Begin Headers */ +h1 { + padding-top: 70px; + margin: 0; + } + +h2 { + margin: 30px 0 0; + } + +h2.pagetitle { + margin-top: 30px; + text-align: center; +} + +#sidebar h2 { + margin: 5px 0 0; + padding: 0; + } + +h3 { + padding: 0; + margin: 30px 0 0; + } + +h3.comments { + padding: 0; + margin: 40px auto 20px ; + } +/* End Headers */ + + + +/* Begin Images */ +p img { + padding: 0; + max-width: 100%; + } + +/* Using 'class="alignright"' on an image will (who would've + thought?!) align the image to the right. And using 'class="centered', + will of course center the image. This is much better than using + align="center", being much more futureproof (and valid) */ + +img.centered { + display: block; + margin-left: auto; + margin-right: auto; + } + +img.alignright { + padding: 4px; + margin: 0 0 2px 7px; + display: inline; + } + +img.alignleft { + padding: 4px; + margin: 0 7px 2px 0; + display: inline; + } + +.alignright { + float: right; + } + +.alignleft { + float: left + } +/* End Images */ + + + +/* Begin Lists + + Special stylized non-IE bullets + Do not work in Internet Explorer, which merely default to normal bullets. */ + +html>body .entry ul { + margin-left: 0px; + padding: 0 0 0 30px; + list-style: none; + padding-left: 10px; + text-indent: -10px; + } + +html>body .entry li { + margin: 7px 0 8px 10px; + } + +.entry ul li:before, #sidebar ul ul li:before { + content: "\00BB \0020"; + } + +.entry ol { + padding: 0 0 0 35px; + margin: 0; + } + +.entry ol li { + margin: 0; + padding: 0; + } + +.postmetadata ul, .postmetadata li { + display: inline; + list-style-type: none; + list-style-image: none; + } + +#sidebar ul, #sidebar ul ol { + margin: 0; + padding: 0; + } + +#sidebar ul li { + list-style-type: none; + list-style-image: none; + margin-bottom: 15px; + } + +#sidebar ul p, #sidebar ul select { + margin: 5px 0 8px; + } + +#sidebar ul ul, #sidebar ul ol { + margin: 5px 0 0 10px; + } + +#sidebar ul ul ul, #sidebar ul ol { + margin: 0 0 0 10px; + } + +ol li, #sidebar ul ol li { + list-style: decimal outside; + } + +#sidebar ul ul li, #sidebar ul ol li { + margin: 3px 0 0; + padding: 0; + } +/* End Entry Lists */ + + + +/* Begin Form Elements */ +#searchform { + margin: 10px auto; + padding: 5px 3px; + text-align: center; + } + +#sidebar #searchform #s { + width: 115px; + padding: 2px; + } + +#sidebar #searchsubmit { + padding: 1px; + } + +.entry form { /* This is mainly for password protected posts, makes them look better. */ + text-align:center; + } + +select { + width: 130px; + } + +#commentform input { + width: 170px; + padding: 2px; + margin: 5px 5px 1px 0; + } + +#commentform textarea { + width: 100%; + padding: 2px; + } + +#commentform #submit { + margin: 0; + float: right; + } +/* End Form Elements */ + + + +/* Begin Comments*/ +.alt { + margin: 0; + padding: 10px; + } + +.commentlist { + padding: 0; + text-align: justify; + } + +.commentlist li { + margin: 15px 0 3px; + padding: 5px 10px 3px; + list-style: none; + } + +.commentlist p { + margin: 10px 5px 10px 0; + } + +#commentform p { + margin: 5px 0; + } + +.nocomments { + text-align: center; + margin: 0; + padding: 0; + } + +.commentmetadata { + margin: 0; + display: block; + } +/* End Comments */ + + + +/* Begin Sidebar */ +#sidebar +{ + padding: 20px 0 10px 0; + margin-left: 545px; + width: 190px; + } + +#sidebar form { + margin: 0; + } +/* End Sidebar */ + + + +/* Begin Calendar */ +#wp-calendar { + empty-cells: show; + margin: 10px auto 0; + width: 155px; + } + +#wp-calendar #next a { + padding-right: 10px; + text-align: right; + } + +#wp-calendar #prev a { + padding-left: 10px; + text-align: left; + } + +#wp-calendar a { + display: block; + } + +#wp-calendar caption { + text-align: center; + width: 100%; + } + +#wp-calendar td { + padding: 3px 0; + text-align: center; + } + +#wp-calendar td.pad:hover { /* Doesn't work in IE */ + background-color: #fff; } +/* End Calendar */ + + + +/* Begin Various Tags & Classes */ +acronym, abbr, span.caps { + cursor: help; + } + +acronym, abbr { + border-bottom: 1px dashed #999; + } + +blockquote { + margin: 15px 30px 0 10px; + padding-left: 20px; + border-left: 5px solid #ddd; + } + +blockquote cite { + margin: 5px 0 0; + display: block; + } + +.center { + text-align: center; + } + +hr { + display: none; + } + +a img { + border: none; + } + +.navigation { + display: block; + text-align: center; + margin-top: 10px; + margin-bottom: 60px; + } +/* End Various Tags & Classes*/ + + + +/* "Daisy, Daisy, give me your answer do. I'm half crazy all for the love of you. + It won't be a stylish marriage, I can't afford a carriage. + But you'll look sweet upon the seat of a bicycle built for two." */ diff --git a/wp-feed.php b/wp-feed.php new file mode 100644 index 00000000..93050771 --- /dev/null +++ b/wp-feed.php @@ -0,0 +1,37 @@ + diff --git a/wp-includes/cache.php b/wp-includes/cache.php new file mode 100644 index 00000000..4dd396d7 --- /dev/null +++ b/wp-includes/cache.php @@ -0,0 +1,427 @@ +add($key, $data, $flag, $expire); +} + +function wp_cache_close() { + global $wp_object_cache; + + return $wp_object_cache->save(); +} + +function wp_cache_delete($id, $flag = '') { + global $wp_object_cache; + + return $wp_object_cache->delete($id, $flag); +} + +function wp_cache_flush() { + global $wp_object_cache; + + return $wp_object_cache->flush(); +} + +function wp_cache_get($id, $flag = '') { + global $wp_object_cache; + + return $wp_object_cache->get($id, $flag); +} + +function wp_cache_init() { + global $wp_object_cache; + + $wp_object_cache = new WP_Object_Cache(); +} + +function wp_cache_replace($key, $data, $flag = '', $expire = 0) { + global $wp_object_cache; + + return $wp_object_cache->replace($key, $data, $flag, $expire); +} + +function wp_cache_set($key, $data, $flag = '', $expire = 0) { + global $wp_object_cache; + + return $wp_object_cache->set($key, $data, $flag, $expire); +} + +define('CACHE_SERIAL_HEADER', ""); + +class WP_Object_Cache { + var $cache_dir; + var $cache_enabled = false; + var $expiration_time = 900; + var $flock_filename = 'wp_object_cache.lock'; + var $mutex; + var $cache = array (); + var $dirty_objects = array (); + var $non_existant_objects = array (); + var $global_groups = array ('users', 'userlogins', 'usermeta'); + var $blog_id; + var $cold_cache_hits = 0; + var $warm_cache_hits = 0; + var $cache_misses = 0; + + function acquire_lock() { + // Acquire a write lock. + $this->mutex = @fopen($this->cache_dir.$this->flock_filename, 'w'); + if ( false == $this->mutex) + return false; + flock($this->mutex, LOCK_EX); + return true; + } + + function add($id, $data, $group = 'default', $expire = '') { + if (empty ($group)) + $group = 'default'; + + if (false !== $this->get($id, $group, false)) + return false; + + return $this->set($id, $data, $group, $expire); + } + + function delete($id, $group = 'default', $force = false) { + if (empty ($group)) + $group = 'default'; + + if (!$force && false === $this->get($id, $group, false)) + return false; + + unset ($this->cache[$group][$id]); + $this->non_existant_objects[$group][$id] = true; + $this->dirty_objects[$group][] = $id; + return true; + } + + function flush() { + if ( !$this->cache_enabled ) + return true; + + if ( ! $this->acquire_lock() ) + return false; + + $this->rm_cache_dir(); + $this->cache = array (); + $this->dirty_objects = array (); + $this->non_existant_objects = array (); + + $this->release_lock(); + + return true; + } + + function get($id, $group = 'default', $count_hits = true) { + if (empty ($group)) + $group = 'default'; + + if (isset ($this->cache[$group][$id])) { + if ($count_hits) + $this->warm_cache_hits += 1; + return $this->cache[$group][$id]; + } + + if (isset ($this->non_existant_objects[$group][$id])) + return false; + + // If caching is not enabled, we have to fall back to pulling from the DB. + if (!$this->cache_enabled) { + if (!isset ($this->cache[$group])) + $this->load_group_from_db($group); + + if (isset ($this->cache[$group][$id])) { + $this->cold_cache_hits += 1; + return $this->cache[$group][$id]; + } + + $this->non_existant_objects[$group][$id] = true; + $this->cache_misses += 1; + return false; + } + + $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".md5($id.DB_PASSWORD).'.php'; + if (!file_exists($cache_file)) { + $this->non_existant_objects[$group][$id] = true; + $this->cache_misses += 1; + return false; + } + + // If the object has expired, remove it from the cache and return false to force + // a refresh. + $now = time(); + if ((filemtime($cache_file) + $this->expiration_time) <= $now) { + $this->cache_misses += 1; + $this->delete($id, $group, true); + return false; + } + + $this->cache[$group][$id] = unserialize(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER))); + if (false === $this->cache[$group][$id]) + $this->cache[$group][$id] = ''; + + $this->cold_cache_hits += 1; + return $this->cache[$group][$id]; + } + + function get_group_dir($group) { + if (false !== array_search($group, $this->global_groups)) + return $group; + + return "{$this->blog_id}/$group"; + } + + function load_group_from_db($group) { + global $wpdb; + + if ('category' == $group) { + $this->cache['category'] = array (); + if ($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")) { + foreach ($dogs as $catt) + $this->cache['category'][$catt->cat_ID] = $catt; + + foreach ($this->cache['category'] as $catt) { + $curcat = $catt->cat_ID; + $fullpath = '/'.$this->cache['category'][$catt->cat_ID]->category_nicename; + while ($this->cache['category'][$curcat]->category_parent != 0) { + $curcat = $this->cache['category'][$curcat]->category_parent; + $fullpath = '/'.$this->cache['category'][$curcat]->category_nicename.$fullpath; + } + $this->cache['category'][$catt->cat_ID]->fullpath = $fullpath; + } + } + } else + if ('options' == $group) { + $wpdb->hide_errors(); + if (!$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'")) { + $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); + } + $wpdb->show_errors(); + + if ( ! $options ) + return; + + foreach ($options as $option) { + $this->cache['options'][$option->option_name] = $option->option_value; + } + } + } + + function make_group_dir($group, $perms) { + $group_dir = $this->get_group_dir($group); + $make_dir = ''; + foreach (split('/', $group_dir) as $subdir) { + $make_dir .= "$subdir/"; + if (!file_exists($this->cache_dir.$make_dir)) { + if (! @ mkdir($this->cache_dir.$make_dir)) + break; + @ chmod($this->cache_dir.$make_dir, $perms); + } + + if (!file_exists($this->cache_dir.$make_dir."index.php")) { + $file_perms = $perms & 0000666; + @ touch($this->cache_dir.$make_dir."index.php"); + @ chmod($this->cache_dir.$make_dir."index.php", $file_perms); + } + } + + return $this->cache_dir."$group_dir/"; + } + + function rm_cache_dir() { + $dir = $this->cache_dir; + $dir = rtrim($dir, DIRECTORY_SEPARATOR); + $top_dir = $dir; + $stack = array($dir); + $index = 0; + + while ($index < count($stack)) { + # Get indexed directory from stack + $dir = $stack[$index]; + + $dh = @ opendir($dir); + if (!$dh) + return false; + + while (($file = @ readdir($dh)) !== false) { + if ($file == '.' or $file == '..') + continue; + + if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file)) + $stack[] = $dir . DIRECTORY_SEPARATOR . $file; + else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file)) + @ unlink($dir . DIRECTORY_SEPARATOR . $file); + } + + $index++; + } + + $stack = array_reverse($stack); // Last added dirs are deepest + foreach($stack as $dir) { + if ( $dir != $top_dir) + @ rmdir($dir); + } + + } + + function release_lock() { + // Release write lock. + flock($this->mutex, LOCK_UN); + fclose($this->mutex); + } + + function replace($id, $data, $group = 'default', $expire = '') { + if (empty ($group)) + $group = 'default'; + + if (false === $this->get($id, $group, false)) + return false; + + return $this->set($id, $data, $group, $expire); + } + + function set($id, $data, $group = 'default', $expire = '') { + if (empty ($group)) + $group = 'default'; + + if (NULL == $data) + $data = ''; + + $this->cache[$group][$id] = $data; + unset ($this->non_existant_objects[$group][$id]); + $this->dirty_objects[$group][] = $id; + + return true; + } + + function save() { + //$this->stats(); + + if (!$this->cache_enabled) + return true; + + if (empty ($this->dirty_objects)) + return true; + + // Give the new dirs the same perms as wp-content. + $stat = stat(ABSPATH.'wp-content'); + $dir_perms = $stat['mode'] & 0007777; // Get the permission bits. + $file_perms = $dir_perms & 0000666; // Remove execute bits for files. + + // Make the base cache dir. + if (!file_exists($this->cache_dir)) { + if (! @ mkdir($this->cache_dir)) + return false; + @ chmod($this->cache_dir, $dir_perms); + } + + if (!file_exists($this->cache_dir."index.php")) { + @ touch($this->cache_dir."index.php"); + @ chmod($this->cache_dir."index.php", $file_perms); + } + + if ( ! $this->acquire_lock() ) + return false; + + // Loop over dirty objects and save them. + $errors = 0; + foreach ($this->dirty_objects as $group => $ids) { + $group_dir = $this->make_group_dir($group, $dir_perms); + + $ids = array_unique($ids); + foreach ($ids as $id) { + $cache_file = $group_dir.md5($id.DB_PASSWORD).'.php'; + + // Remove the cache file if the key is not set. + if (!isset ($this->cache[$group][$id])) { + if (file_exists($cache_file)) + @ unlink($cache_file); + continue; + } + + $temp_file = tempnam($group_dir, 'tmp'); + $serial = CACHE_SERIAL_HEADER.serialize($this->cache[$group][$id]).CACHE_SERIAL_FOOTER; + $fd = @fopen($temp_file, 'w'); + if ( false === $fd ) { + $errors++; + continue; + } + fputs($fd, $serial); + fclose($fd); + if (!@ rename($temp_file, $cache_file)) { + if (@ copy($temp_file, $cache_file)) + @ unlink($temp_file); + else + $errors++; + } + @ chmod($cache_file, $file_perms); + } + } + + $this->dirty_objects = array(); + + $this->release_lock(); + + if ( $errors ) + return false; + + return true; + } + + function stats() { + echo "

    "; + echo "Cold Cache Hits: {$this->cold_cache_hits}
    "; + echo "Warm Cache Hits: {$this->warm_cache_hits}
    "; + echo "Cache Misses: {$this->cache_misses}
    "; + echo "

    "; + + foreach ($this->cache as $group => $cache) { + echo "

    "; + echo "Group: $group
    "; + echo "Cache:"; + echo "

    ";
    +			print_r($cache);
    +			echo "
    "; + if (isset ($this->dirty_objects[$group])) { + echo "Dirty Objects:"; + echo "
    ";
    +				print_r(array_unique($this->dirty_objects[$group]));
    +				echo "
    "; + echo "

    "; + } + } + } + + function WP_Object_Cache() { + global $blog_id; + + if (defined('DISABLE_CACHE')) + return; + + // Disable the persistent cache if safe_mode is on. + if ( ini_get('safe_mode') && ! defined('ENABLE_CACHE') ) + return; + + if (defined('CACHE_PATH')) + $this->cache_dir = CACHE_PATH; + else + // Using the correct separator eliminates some cache flush errors on Windows + $this->cache_dir = ABSPATH.'wp-content'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR; + + if (is_writable($this->cache_dir) && is_dir($this->cache_dir)) { + $this->cache_enabled = true; + } else { + if (is_writable(ABSPATH.'wp-content')) { + $this->cache_enabled = true; + } + } + + if (defined('CACHE_EXPIRATION_TIME')) + $this->expiration_time = CACHE_EXPIRATION_TIME; + + $this->blog_id = md5($blog_id); + } +} +?> diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php new file mode 100644 index 00000000..b5cea726 --- /dev/null +++ b/wp-includes/capabilities.php @@ -0,0 +1,421 @@ +role_key = $table_prefix . 'user_roles'; + + $this->roles = get_option($this->role_key); + + if ( empty($this->roles) ) + return; + + foreach ($this->roles as $role => $data) { + $this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']); + $this->role_names[$role] = $this->roles[$role]['name']; + } + } + + function add_role($role, $display_name, $capabilities = '') { + if ( isset($this->roles[$role]) ) + return; + + $this->roles[$role] = array( + 'name' => $display_name, + 'capabilities' => $capabilities); + update_option($this->role_key, $this->roles); + $this->role_objects[$role] = new WP_Role($role, $capabilities); + $this->role_names[$role] = $display_name; + return $this->role_objects[$role]; + } + + function remove_role($role) { + if ( ! isset($this->role_objects[$role]) ) + return; + + unset($this->role_objects[$role]); + unset($this->role_names[$role]); + unset($this->roles[$role]); + + update_option($this->role_key, $this->roles); + } + + function add_cap($role, $cap, $grant = true) { + $this->roles[$role]['capabilities'][$cap] = $grant; + update_option($this->role_key, $this->roles); + } + + function remove_cap($role, $cap) { + unset($this->roles[$role]['capabilities'][$cap]); + update_option($this->role_key, $this->roles); + } + + function &get_role($role) { + if ( isset($this->role_objects[$role]) ) + return $this->role_objects[$role]; + else + return null; + } + + function get_names() { + return $this->role_names; + } + + function is_role($role) + { + return isset($this->role_names[$role]); + } +} + +class WP_Role { + var $name; + var $capabilities; + + function WP_Role($role, $capabilities) { + $this->name = $role; + $this->capabilities = $capabilities; + } + + function add_cap($cap, $grant = true) { + global $wp_roles; + + if ( ! isset($wp_roles) ) + $wp_roles = new WP_Roles(); + + $this->capabilities[$cap] = $grant; + $wp_roles->add_cap($this->name, $cap, $grant); + } + + function remove_cap($cap) { + global $wp_roles; + + if ( ! isset($wp_roles) ) + $wp_roles = new WP_Roles(); + + unset($this->capabilities[$cap]); + $wp_roles->remove_cap($this->name, $cap); + } + + function has_cap($cap) { + $capabilities = apply_filters('role_has_cap', $this->capabilities, $cap, $this->name); + if ( !empty($capabilities[$cap]) ) + return $capabilities[$cap]; + else + return false; + } + +} + +class WP_User { + var $data; + var $id = 0; + var $caps = array(); + var $cap_key; + var $roles = array(); + var $allcaps = array(); + + function WP_User($id, $name = '') { + global $table_prefix; + + if ( empty($id) && empty($name) ) + return; + + if ( ! is_numeric($id) ) { + $name = $id; + $id = 0; + } + + if ( ! empty($id) ) + $this->data = get_userdata($id); + else + $this->data = get_userdatabylogin($name); + + if ( empty($this->data->ID) ) + return; + + foreach (get_object_vars($this->data) as $key => $value) { + $this->{$key} = $value; + } + + $this->id = $this->ID; + $this->cap_key = $table_prefix . 'capabilities'; + $this->caps = &$this->{$this->cap_key}; + if ( ! is_array($this->caps) ) + $this->caps = array(); + $this->get_role_caps(); + } + + function get_role_caps() { + global $wp_roles; + + if ( ! isset($wp_roles) ) + $wp_roles = new WP_Roles(); + + //Filter out caps that are not role names and assign to $this->roles + if(is_array($this->caps)) + $this->roles = array_filter(array_keys($this->caps), array(&$wp_roles, 'is_role')); + + //Build $allcaps from role caps, overlay user's $caps + $this->allcaps = array(); + foreach($this->roles as $role) { + $role = $wp_roles->get_role($role); + $this->allcaps = array_merge($this->allcaps, $role->capabilities); + } + $this->allcaps = array_merge($this->allcaps, $this->caps); + } + + function add_role($role) { + $this->caps[$role] = true; + update_usermeta($this->id, $this->cap_key, $this->caps); + $this->get_role_caps(); + $this->update_user_level_from_caps(); + } + + function remove_role($role) { + if ( empty($this->roles[$role]) || (count($this->roles) <= 1) ) + return; + unset($this->caps[$role]); + update_usermeta($this->id, $this->cap_key, $this->caps); + $this->get_role_caps(); + } + + function set_role($role) { + foreach($this->roles as $oldrole) + unset($this->caps[$oldrole]); + $this->caps[$role] = true; + $this->roles = array($role => true); + update_usermeta($this->id, $this->cap_key, $this->caps); + $this->get_role_caps(); + $this->update_user_level_from_caps(); + } + + function level_reduction($max, $item) { + if(preg_match('/^level_(10|[0-9])$/i', $item, $matches)) { + $level = intval($matches[1]); + return max($max, $level); + } else { + return $max; + } + } + + function update_user_level_from_caps() { + global $table_prefix; + $this->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0); + update_usermeta($this->id, $table_prefix.'user_level', $this->user_level); + } + + function add_cap($cap, $grant = true) { + $this->caps[$cap] = $grant; + update_usermeta($this->id, $this->cap_key, $this->caps); + } + + function remove_cap($cap) { + if ( empty($this->caps[$cap]) ) return; + unset($this->caps[$cap]); + update_usermeta($this->id, $this->cap_key, $this->caps); + } + + //has_cap(capability_or_role_name) or + //has_cap('edit_post', post_id) + function has_cap($cap) { + if ( is_numeric($cap) ) + $cap = $this->translate_level_to_cap($cap); + + $args = array_slice(func_get_args(), 1); + $args = array_merge(array($cap, $this->id), $args); + $caps = call_user_func_array('map_meta_cap', $args); + // Must have ALL requested caps + $capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args); + foreach ($caps as $cap) { + //echo "Checking cap $cap
    "; + if(empty($capabilities[$cap]) || !$capabilities[$cap]) + return false; + } + + return true; + } + + function translate_level_to_cap($level) { + return 'level_' . $level; + } + +} + +// Map meta capabilities to primitive capabilities. +function map_meta_cap($cap, $user_id) { + $args = array_slice(func_get_args(), 2); + $caps = array(); + + switch ($cap) { + // edit_post breaks down to edit_posts, edit_published_posts, or + // edit_others_posts + case 'edit_post': + $author_data = get_userdata($user_id); + //echo "post ID: {$args[0]}
    "; + $post = get_post($args[0]); + $post_author_data = get_userdata($post->post_author); + //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
    "; + // If the user is the author... + if ($user_id == $post_author_data->ID) { + // If the post is published... + if ($post->post_status == 'publish') + $caps[] = 'edit_published_posts'; + else if ($post->post_status == 'static') + $caps[] = 'edit_pages'; + else + // If the post is draft... + $caps[] = 'edit_posts'; + } else { + if ($post->post_status == 'static') { + $caps[] = 'edit_pages'; + break; + } + + // The user is trying to edit someone else's post. + $caps[] = 'edit_others_posts'; + // The post is published, extra cap required. + if ($post->post_status == 'publish') + $caps[] = 'edit_published_posts'; + } + break; + case 'read_post': + $post = get_post($args[0]); + + if ( 'private' != $post->post_status ) { + $caps[] = 'read'; + break; + } + + $author_data = get_userdata($user_id); + $post_author_data = get_userdata($post->post_author); + if ($user_id == $post_author_data->ID) + $caps[] = 'read'; + else + $caps[] = 'read_private_posts'; + break; + default: + // If no meta caps match, return the original cap. + $caps[] = $cap; + } + + return $caps; +} + +// Capability checking wrapper around the global $current_user object. +function current_user_can($capability) { + global $current_user; + + $args = array_slice(func_get_args(), 1); + $args = array_merge(array($capability), $args); + + if ( empty($current_user) ) + return false; + + return call_user_func_array(array(&$current_user, 'has_cap'), $args); +} + +// Convenience wrappers around $wp_roles. +function get_role($role) { + global $wp_roles; + + if ( ! isset($wp_roles) ) + $wp_roles = new WP_Roles(); + + return $wp_roles->get_role($role); +} + +function add_role($role, $display_name, $capabilities = '') { + global $wp_roles; + + if ( ! isset($wp_roles) ) + $wp_roles = new WP_Roles(); + + return $wp_roles->add_role($role, $display_name, $capabilities); +} + +function remove_role($role) { + global $wp_roles; + + if ( ! isset($wp_roles) ) + $wp_roles = new WP_Roles(); + + return $wp_roles->remove_role($role); +} + +// +// These are deprecated. Use current_user_can(). +// + +/* returns true if $user_id can create a new post */ +function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') { + $author_data = get_userdata($user_id); + return ($author_data->user_level > 1); +} + +/* returns true if $user_id can create a new post */ +function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') { + $author_data = get_userdata($user_id); + return ($author_data->user_level >= 1); +} + +/* returns true if $user_id can edit $post_id */ +function user_can_edit_post($user_id, $post_id, $blog_id = 1) { + $author_data = get_userdata($user_id); + $post = get_post($post_id); + $post_author_data = get_userdata($post->post_author); + + if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2)) + || ($author_data->user_level > $post_author_data->user_level) + || ($author_data->user_level >= 10) ) { + return true; + } else { + return false; + } +} + +/* returns true if $user_id can delete $post_id */ +function user_can_delete_post($user_id, $post_id, $blog_id = 1) { + // right now if one can edit, one can delete + return user_can_edit_post($user_id, $post_id, $blog_id); +} + +/* returns true if $user_id can set new posts' dates on $blog_id */ +function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') { + $author_data = get_userdata($user_id); + return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id)); +} + +/* returns true if $user_id can edit $post_id's date */ +function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) { + $author_data = get_userdata($user_id); + return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id)); +} + +/* returns true if $user_id can edit $post_id's comments */ +function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) { + // right now if one can edit a post, one can edit comments made on it + return user_can_edit_post($user_id, $post_id, $blog_id); +} + +/* returns true if $user_id can delete $post_id's comments */ +function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) { + // right now if one can edit comments, one can delete comments + return user_can_edit_post_comments($user_id, $post_id, $blog_id); +} + +function user_can_edit_user($user_id, $other_user) { + $user = get_userdata($user_id); + $other = get_userdata($other_user); + if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) + return true; + else + return false; +} + +?> diff --git a/wp-includes/class-IXR.php b/wp-includes/class-IXR.php new file mode 100644 index 00000000..7851b68a --- /dev/null +++ b/wp-includes/class-IXR.php @@ -0,0 +1,815 @@ +data = $data; + if (!$type) { + $type = $this->calculateType(); + } + $this->type = $type; + if ($type == 'struct') { + /* Turn all the values in the array in to new IXR_Value objects */ + foreach ($this->data as $key => $value) { + $this->data[$key] = new IXR_Value($value); + } + } + if ($type == 'array') { + for ($i = 0, $j = count($this->data); $i < $j; $i++) { + $this->data[$i] = new IXR_Value($this->data[$i]); + } + } + } + function calculateType() { + if ($this->data === true || $this->data === false) { + return 'boolean'; + } + if (is_integer($this->data)) { + return 'int'; + } + if (is_double($this->data)) { + return 'double'; + } + // Deal with IXR object types base64 and date + if (is_object($this->data) && is_a($this->data, 'IXR_Date')) { + return 'date'; + } + if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) { + return 'base64'; + } + // If it is a normal PHP object convert it in to a struct + if (is_object($this->data)) { + + $this->data = get_object_vars($this->data); + return 'struct'; + } + if (!is_array($this->data)) { + return 'string'; + } + /* We have an array - is it an array or a struct ? */ + if ($this->isStruct($this->data)) { + return 'struct'; + } else { + return 'array'; + } + } + function getXml() { + /* Return XML for this value */ + switch ($this->type) { + case 'boolean': + return ''.(($this->data) ? '1' : '0').''; + break; + case 'int': + return ''.$this->data.''; + break; + case 'double': + return ''.$this->data.''; + break; + case 'string': + return ''.htmlspecialchars($this->data).''; + break; + case 'array': + $return = ''."\n"; + foreach ($this->data as $item) { + $return .= ' '.$item->getXml()."\n"; + } + $return .= ''; + return $return; + break; + case 'struct': + $return = ''."\n"; + foreach ($this->data as $name => $value) { + $name = htmlspecialchars($name); + $return .= " $name"; + $return .= $value->getXml()."\n"; + } + $return .= ''; + return $return; + break; + case 'date': + case 'base64': + return $this->data->getXml(); + break; + } + return false; + } + function isStruct($array) { + /* Nasty function to check if an array is a struct or not */ + $expected = 0; + foreach ($array as $key => $value) { + if ((string)$key != (string)$expected) { + return true; + } + $expected++; + } + return false; + } +} + + +class IXR_Message { + var $message; + var $messageType; // methodCall / methodResponse / fault + var $faultCode; + var $faultString; + var $methodName; + var $params; + // Current variable stacks + var $_arraystructs = array(); // The stack used to keep track of the current array/struct + var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array + var $_currentStructName = array(); // A stack as well + var $_param; + var $_value; + var $_currentTag; + var $_currentTagContents; + // The XML parser + var $_parser; + function IXR_Message ($message) { + $this->message = $message; + } + function parse() { + // first remove the XML declaration + $this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message); + if (trim($this->message) == '') { + return false; + } + $this->_parser = xml_parser_create(); + // Set XML parser to take the case of tags in to account + xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false); + // Set XML parser callback functions + xml_set_object($this->_parser, $this); + xml_set_element_handler($this->_parser, 'tag_open', 'tag_close'); + xml_set_character_data_handler($this->_parser, 'cdata'); + if (!xml_parse($this->_parser, $this->message)) { + /* die(sprintf('XML error: %s at line %d', + xml_error_string(xml_get_error_code($this->_parser)), + xml_get_current_line_number($this->_parser))); */ + return false; + } + xml_parser_free($this->_parser); + // Grab the error messages, if any + if ($this->messageType == 'fault') { + $this->faultCode = $this->params[0]['faultCode']; + $this->faultString = $this->params[0]['faultString']; + } + return true; + } + function tag_open($parser, $tag, $attr) { + $this->_currentTagContents = ''; + $this->currentTag = $tag; + switch($tag) { + case 'methodCall': + case 'methodResponse': + case 'fault': + $this->messageType = $tag; + break; + /* Deal with stacks of arrays and structs */ + case 'data': // data is to all intents and puposes more interesting than array + $this->_arraystructstypes[] = 'array'; + $this->_arraystructs[] = array(); + break; + case 'struct': + $this->_arraystructstypes[] = 'struct'; + $this->_arraystructs[] = array(); + break; + } + } + function cdata($parser, $cdata) { + $this->_currentTagContents .= $cdata; + } + function tag_close($parser, $tag) { + $valueFlag = false; + switch($tag) { + case 'int': + case 'i4': + $value = (int) trim($this->_currentTagContents); + $valueFlag = true; + break; + case 'double': + $value = (double) trim($this->_currentTagContents); + $valueFlag = true; + break; + case 'string': + $value = $this->_currentTagContents; + $valueFlag = true; + break; + case 'dateTime.iso8601': + $value = new IXR_Date(trim($this->_currentTagContents)); + // $value = $iso->getTimestamp(); + $valueFlag = true; + break; + case 'value': + // "If no type is indicated, the type is string." + if (trim($this->_currentTagContents) != '') { + $value = (string)$this->_currentTagContents; + $valueFlag = true; + } + break; + case 'boolean': + $value = (boolean) trim($this->_currentTagContents); + $valueFlag = true; + break; + case 'base64': + $value = base64_decode( trim( $this->_currentTagContents ) ); + $valueFlag = true; + break; + /* Deal with stacks of arrays and structs */ + case 'data': + case 'struct': + $value = array_pop($this->_arraystructs); + array_pop($this->_arraystructstypes); + $valueFlag = true; + break; + case 'member': + array_pop($this->_currentStructName); + break; + case 'name': + $this->_currentStructName[] = trim($this->_currentTagContents); + break; + case 'methodName': + $this->methodName = trim($this->_currentTagContents); + break; + } + if ($valueFlag) { + if (count($this->_arraystructs) > 0) { + // Add value to struct or array + if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') { + // Add to struct + $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value; + } else { + // Add to array + $this->_arraystructs[count($this->_arraystructs)-1][] = $value; + } + } else { + // Just add as a paramater + $this->params[] = $value; + } + } + $this->_currentTagContents = ''; + } +} + + +class IXR_Server { + var $data; + var $callbacks = array(); + var $message; + var $capabilities; + function IXR_Server($callbacks = false, $data = false) { + $this->setCapabilities(); + if ($callbacks) { + $this->callbacks = $callbacks; + } + $this->setCallbacks(); + $this->serve($data); + } + function serve($data = false) { + if (!$data) { + global $HTTP_RAW_POST_DATA; + if (!$HTTP_RAW_POST_DATA) { + die('XML-RPC server accepts POST requests only.'); + } + $data = $HTTP_RAW_POST_DATA; + } + $this->message = new IXR_Message($data); + if (!$this->message->parse()) { + $this->error(-32700, 'parse error. not well formed'); + } + if ($this->message->messageType != 'methodCall') { + $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall'); + } + $result = $this->call($this->message->methodName, $this->message->params); + // Is the result an error? + if (is_a($result, 'IXR_Error')) { + $this->error($result); + } + // Encode the result + $r = new IXR_Value($result); + $resultxml = $r->getXml(); + // Create the XML + $xml = << + + + + $resultxml + + + + + +EOD; + // Send it + $this->output($xml); + } + function call($methodname, $args) { + if (!$this->hasMethod($methodname)) { + return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.'); + } + $method = $this->callbacks[$methodname]; + // Perform the callback and send the response + if (count($args) == 1) { + // If only one paramater just send that instead of the whole array + $args = $args[0]; + } + // Are we dealing with a function or a method? + if (substr($method, 0, 5) == 'this:') { + // It's a class method - check it exists + $method = substr($method, 5); + if (!method_exists($this, $method)) { + return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.'); + } + // Call the method + $result = $this->$method($args); + } else { + // It's a function - does it exist? + if (is_array($method)) { + if (!method_exists($method[0], $method[1])) { + return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.'); + } + } else if (!function_exists($method)) { + return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.'); + } + // Call the function + $result = call_user_func($method, $args); + } + return $result; + } + + function error($error, $message = false) { + // Accepts either an error object or an error code and message + if ($message && !is_object($error)) { + $error = new IXR_Error($error, $message); + } + $this->output($error->getXml()); + } + function output($xml) { + $xml = ''."\n".$xml; + $length = strlen($xml); + header('Connection: close'); + header('Content-Length: '.$length); + header('Content-Type: text/xml'); + header('Date: '.date('r')); + echo $xml; + exit; + } + function hasMethod($method) { + return in_array($method, array_keys($this->callbacks)); + } + function setCapabilities() { + // Initialises capabilities array + $this->capabilities = array( + 'xmlrpc' => array( + 'specUrl' => 'http://www.xmlrpc.com/spec', + 'specVersion' => 1 + ), + 'faults_interop' => array( + 'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php', + 'specVersion' => 20010516 + ), + 'system.multicall' => array( + 'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208', + 'specVersion' => 1 + ), + ); + } + function getCapabilities($args) { + return $this->capabilities; + } + function setCallbacks() { + $this->callbacks['system.getCapabilities'] = 'this:getCapabilities'; + $this->callbacks['system.listMethods'] = 'this:listMethods'; + $this->callbacks['system.multicall'] = 'this:multiCall'; + } + function listMethods($args) { + // Returns a list of methods - uses array_reverse to ensure user defined + // methods are listed before server defined methods + return array_reverse(array_keys($this->callbacks)); + } + function multiCall($methodcalls) { + // See http://www.xmlrpc.com/discuss/msgReader$1208 + $return = array(); + foreach ($methodcalls as $call) { + $method = $call['methodName']; + $params = $call['params']; + if ($method == 'system.multicall') { + $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden'); + } else { + $result = $this->call($method, $params); + } + if (is_a($result, 'IXR_Error')) { + $return[] = array( + 'faultCode' => $result->code, + 'faultString' => $result->message + ); + } else { + $return[] = array($result); + } + } + return $return; + } +} + +class IXR_Request { + var $method; + var $args; + var $xml; + function IXR_Request($method, $args) { + $this->method = $method; + $this->args = $args; + $this->xml = << + +{$this->method} + + +EOD; + foreach ($this->args as $arg) { + $this->xml .= ''; + $v = new IXR_Value($arg); + $this->xml .= $v->getXml(); + $this->xml .= "\n"; + } + $this->xml .= ''; + } + function getLength() { + return strlen($this->xml); + } + function getXml() { + return $this->xml; + } +} + + +class IXR_Client { + var $server; + var $port; + var $path; + var $useragent; + var $response; + var $message = false; + var $debug = false; + var $timeout; + // Storage place for an error message + var $error = false; + function IXR_Client($server, $path = false, $port = 80, $timeout = false) { + if (!$path) { + // Assume we have been given a URL instead + $bits = parse_url($server); + $this->server = $bits['host']; + $this->port = isset($bits['port']) ? $bits['port'] : 80; + $this->path = isset($bits['path']) ? $bits['path'] : '/'; + // Make absolutely sure we have a path + if (!$this->path) { + $this->path = '/'; + } + } else { + $this->server = $server; + $this->path = $path; + $this->port = $port; + } + $this->useragent = 'Incutio XML-RPC'; + $this->timeout = $timeout; + } + function query() { + $args = func_get_args(); + $method = array_shift($args); + $request = new IXR_Request($method, $args); + $length = $request->getLength(); + $xml = $request->getXml(); + $r = "\r\n"; + $request = "POST {$this->path} HTTP/1.0$r"; + $request .= "Host: {$this->server}$r"; + $request .= "Content-Type: text/xml$r"; + $request .= "User-Agent: {$this->useragent}$r"; + $request .= "Content-length: {$length}$r$r"; + $request .= $xml; + // Now send the request + if ($this->debug) { + echo '
    '.htmlspecialchars($request)."\n
    \n\n"; + } + if ($this->timeout) { + $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout); + } else { + $fp = @fsockopen($this->server, $this->port, $errno, $errstr); + } + if (!$fp) { + $this->error = new IXR_Error(-32300, "transport error - could not open socket: $errno $errstr"); + return false; + } + fputs($fp, $request); + $contents = ''; + $gotFirstLine = false; + $gettingHeaders = true; + while (!feof($fp)) { + $line = fgets($fp, 4096); + if (!$gotFirstLine) { + // Check line for '200' + if (strstr($line, '200') === false) { + $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200'); + return false; + } + $gotFirstLine = true; + } + if (trim($line) == '') { + $gettingHeaders = false; + } + if (!$gettingHeaders) { + $contents .= trim($line)."\n"; + } + } + if ($this->debug) { + echo '
    '.htmlspecialchars($contents)."\n
    \n\n"; + } + // Now parse what we've got back + $this->message = new IXR_Message($contents); + if (!$this->message->parse()) { + // XML error + $this->error = new IXR_Error(-32700, 'parse error. not well formed'); + return false; + } + // Is the message a fault? + if ($this->message->messageType == 'fault') { + $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString); + return false; + } + // Message must be OK + return true; + } + function getResponse() { + // methodResponses can only have one param - return that + return $this->message->params[0]; + } + function isError() { + return (is_object($this->error)); + } + function getErrorCode() { + return $this->error->code; + } + function getErrorMessage() { + return $this->error->message; + } +} + + +class IXR_Error { + var $code; + var $message; + function IXR_Error($code, $message) { + $this->code = $code; + $this->message = $message; + } + function getXml() { + $xml = << + + + + + faultCode + {$this->code} + + + faultString + {$this->message} + + + + + + +EOD; + return $xml; + } +} + + +class IXR_Date { + var $year; + var $month; + var $day; + var $hour; + var $minute; + var $second; + function IXR_Date($time) { + // $time can be a PHP timestamp or an ISO one + if (is_numeric($time)) { + $this->parseTimestamp($time); + } else { + $this->parseIso($time); + } + } + function parseTimestamp($timestamp) { + $this->year = date('Y', $timestamp); + $this->month = date('m', $timestamp); + $this->day = date('d', $timestamp); + $this->hour = date('H', $timestamp); + $this->minute = date('i', $timestamp); + $this->second = date('s', $timestamp); + } + function parseIso($iso) { + $this->year = substr($iso, 0, 4); + $this->month = substr($iso, 4, 2); + $this->day = substr($iso, 6, 2); + $this->hour = substr($iso, 9, 2); + $this->minute = substr($iso, 12, 2); + $this->second = substr($iso, 15, 2); + $this->timezone = substr($iso, 17); + } + function getIso() { + return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone; + } + function getXml() { + return ''.$this->getIso().''; + } + function getTimestamp() { + return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year); + } +} + + +class IXR_Base64 { + var $data; + function IXR_Base64($data) { + $this->data = $data; + } + function getXml() { + return ''.base64_encode($this->data).''; + } +} + + +class IXR_IntrospectionServer extends IXR_Server { + var $signatures; + var $help; + function IXR_IntrospectionServer() { + $this->setCallbacks(); + $this->setCapabilities(); + $this->capabilities['introspection'] = array( + 'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html', + 'specVersion' => 1 + ); + $this->addCallback( + 'system.methodSignature', + 'this:methodSignature', + array('array', 'string'), + 'Returns an array describing the return type and required parameters of a method' + ); + $this->addCallback( + 'system.getCapabilities', + 'this:getCapabilities', + array('struct'), + 'Returns a struct describing the XML-RPC specifications supported by this server' + ); + $this->addCallback( + 'system.listMethods', + 'this:listMethods', + array('array'), + 'Returns an array of available methods on this server' + ); + $this->addCallback( + 'system.methodHelp', + 'this:methodHelp', + array('string', 'string'), + 'Returns a documentation string for the specified method' + ); + } + function addCallback($method, $callback, $args, $help) { + $this->callbacks[$method] = $callback; + $this->signatures[$method] = $args; + $this->help[$method] = $help; + } + function call($methodname, $args) { + // Make sure it's in an array + if ($args && !is_array($args)) { + $args = array($args); + } + // Over-rides default call method, adds signature check + if (!$this->hasMethod($methodname)) { + return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.'); + } + $method = $this->callbacks[$methodname]; + $signature = $this->signatures[$methodname]; + $returnType = array_shift($signature); + // Check the number of arguments + if (count($args) != count($signature)) { + return new IXR_Error(-32602, 'server error. wrong number of method parameters'); + } + // Check the argument types + $ok = true; + $argsbackup = $args; + for ($i = 0, $j = count($args); $i < $j; $i++) { + $arg = array_shift($args); + $type = array_shift($signature); + switch ($type) { + case 'int': + case 'i4': + if (is_array($arg) || !is_int($arg)) { + $ok = false; + } + break; + case 'base64': + case 'string': + if (!is_string($arg)) { + $ok = false; + } + break; + case 'boolean': + if ($arg !== false && $arg !== true) { + $ok = false; + } + break; + case 'float': + case 'double': + if (!is_float($arg)) { + $ok = false; + } + break; + case 'date': + case 'dateTime.iso8601': + if (!is_a($arg, 'IXR_Date')) { + $ok = false; + } + break; + } + if (!$ok) { + return new IXR_Error(-32602, 'server error. invalid method parameters'); + } + } + // It passed the test - run the "real" method call + return parent::call($methodname, $argsbackup); + } + function methodSignature($method) { + if (!$this->hasMethod($method)) { + return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.'); + } + // We should be returning an array of types + $types = $this->signatures[$method]; + $return = array(); + foreach ($types as $type) { + switch ($type) { + case 'string': + $return[] = 'string'; + break; + case 'int': + case 'i4': + $return[] = 42; + break; + case 'double': + $return[] = 3.1415; + break; + case 'dateTime.iso8601': + $return[] = new IXR_Date(time()); + break; + case 'boolean': + $return[] = true; + break; + case 'base64': + $return[] = new IXR_Base64('base64'); + break; + case 'array': + $return[] = array('array'); + break; + case 'struct': + $return[] = array('struct' => 'struct'); + break; + } + } + return $return; + } + function methodHelp($method) { + return $this->help[$method]; + } +} + + +class IXR_ClientMulticall extends IXR_Client { + var $calls = array(); + function IXR_ClientMulticall($server, $path = false, $port = 80) { + parent::IXR_Client($server, $path, $port); + $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)'; + } + function addCall() { + $args = func_get_args(); + $methodName = array_shift($args); + $struct = array( + 'methodName' => $methodName, + 'params' => $args + ); + $this->calls[] = $struct; + } + function query() { + // Prepare multicall, then call the parent::query() method + return parent::query('system.multicall', $this->calls); + } +} + +?> \ No newline at end of file diff --git a/wp-includes/class-pop3.php b/wp-includes/class-pop3.php new file mode 100644 index 00000000..468ca8bd --- /dev/null +++ b/wp-includes/class-pop3.php @@ -0,0 +1,680 @@ +BUFFER,"integer"); + if( !empty($server) ) { + // Do not allow programs to alter MAILSERVER + // if it is already specified. They can get around + // this if they -really- want to, so don't count on it. + if(empty($this->MAILSERVER)) + $this->MAILSERVER = $server; + } + if(!empty($timeout)) { + settype($timeout,"integer"); + $this->TIMEOUT = $timeout; + set_time_limit($timeout); + } + return true; + } + + function update_timer () { + set_time_limit($this->TIMEOUT); + return true; + } + + function connect ($server, $port = 110) { + // Opens a socket to the specified server. Unless overridden, + // port defaults to 110. Returns true on success, false on fail + + // If MAILSERVER is set, override $server with it's value + + if(!empty($this->MAILSERVER)) + $server = $this->MAILSERVER; + + if(empty($server)){ + $this->ERROR = _("POP3 connect:") . ' ' . _("No server specified"); + unset($this->FP); + return false; + } + + $fp = fsockopen("$server", $port, $errno, $errstr); + + if(!$fp) { + $this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$errno] [$errstr]"; + unset($this->FP); + return false; + } + + socket_set_blocking($fp,-1); + $this->update_timer(); + $reply = fgets($fp,$this->BUFFER); + $reply = $this->strip_clf($reply); + if($this->DEBUG) + error_log("POP3 SEND [connect: $server] GOT [$reply]",0); + if(!$this->is_ok($reply)) { + $this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$reply]"; + unset($this->FP); + return false; + } + $this->FP = $fp; + $this->BANNER = $this->parse_banner($reply); + $this->RFC1939 = $this->noop(); + if($this->RFC1939) { + $this->ERROR = _("POP3: premature NOOP OK, NOT an RFC 1939 Compliant server"); + $this->quit(); + return false; + } else + return true; + } + + function noop () { + + if(!isset($this->FP)) { + $this->ERROR = _("POP3 noop:") . ' ' . _("No connection to server"); + return false; + } else { + $cmd = "NOOP"; + $reply = $this->send_cmd( $cmd ); + return( $this->is_ok( $reply ) ); + } + } + + function user ($user = "") { + // Sends the USER command, returns true or false + + if( empty($user) ) { + $this->ERROR = _("POP3 user:") . ' ' . _("no login ID submitted"); + return false; + } elseif(!isset($this->FP)) { + $this->ERROR = _("POP3 user:") . ' ' . _("connection not established"); + return false; + } else { + $reply = $this->send_cmd("USER $user"); + if(!$this->is_ok($reply)) { + $this->ERROR = _("POP3 user:") . ' ' . _("Error ") . "[$reply]"; + return false; + } else + return true; + } + } + + function pass ($pass = "") { + // Sends the PASS command, returns # of msgs in mailbox, + // returns false (undef) on Auth failure + + if(empty($pass)) { + $this->ERROR = _("POP3 pass:") . ' ' . _("No password submitted"); + return false; + } elseif(!isset($this->FP)) { + $this->ERROR = _("POP3 pass:") . ' ' . _("connection not established"); + return false; + } else { + $reply = $this->send_cmd("PASS $pass"); + if(!$this->is_ok($reply)) { + $this->ERROR = _("POP3 pass:") . ' ' . _("authentication failed ") . "[$reply]"; + $this->quit(); + return false; + } else { + // Auth successful. + $count = $this->last("count"); + $this->COUNT = $count; + $this->RFC1939 = $this->noop(); + if(!$this->RFC1939) { + $this->ERROR = _("POP3 pass:") . ' ' . _("NOOP failed. Server not RFC 1939 compliant"); + $this->quit(); + return false; + } else + return $count; + } + } + } + + function apop ($login,$pass) { + // Attempts an APOP login. If this fails, it'll + // try a standard login. YOUR SERVER MUST SUPPORT + // THE USE OF THE APOP COMMAND! + // (apop is optional per rfc1939) + + if(!isset($this->FP)) { + $this->ERROR = _("POP3 apop:") . ' ' . _("No connection to server"); + return false; + } elseif(!$this->ALLOWAPOP) { + $retVal = $this->login($login,$pass); + return $retVal; + } elseif(empty($login)) { + $this->ERROR = _("POP3 apop:") . ' ' . _("No login ID submitted"); + return false; + } elseif(empty($pass)) { + $this->ERROR = _("POP3 apop:") . ' ' . _("No password submitted"); + return false; + } else { + $banner = $this->BANNER; + if( (!$banner) or (empty($banner)) ) { + $this->ERROR = _("POP3 apop:") . ' ' . _("No server banner") . ' - ' . _("abort"); + $retVal = $this->login($login,$pass); + return $retVal; + } else { + $AuthString = $banner; + $AuthString .= $pass; + $APOPString = md5($AuthString); + $cmd = "APOP $login $APOPString"; + $reply = $this->send_cmd($cmd); + if(!$this->is_ok($reply)) { + $this->ERROR = _("POP3 apop:") . ' ' . _("apop authentication failed") . ' - ' . _("abort"); + $retVal = $this->login($login,$pass); + return $retVal; + } else { + // Auth successful. + $count = $this->last("count"); + $this->COUNT = $count; + $this->RFC1939 = $this->noop(); + if(!$this->RFC1939) { + $this->ERROR = _("POP3 apop:") . ' ' . _("NOOP failed. Server not RFC 1939 compliant"); + $this->quit(); + return false; + } else + return $count; + } + } + } + } + + function login ($login = "", $pass = "") { + // Sends both user and pass. Returns # of msgs in mailbox or + // false on failure (or -1, if the error occurs while getting + // the number of messages.) + + if( !isset($this->FP) ) { + $this->ERROR = _("POP3 login:") . ' ' . _("No connection to server"); + return false; + } else { + $fp = $this->FP; + if( !$this->user( $login ) ) { + // Preserve the error generated by user() + return false; + } else { + $count = $this->pass($pass); + if( (!$count) || ($count == -1) ) { + // Preserve the error generated by last() and pass() + return false; + } else + return $count; + } + } + } + + function top ($msgNum, $numLines = "0") { + // Gets the header and first $numLines of the msg body + // returns data in an array with each returned line being + // an array element. If $numLines is empty, returns + // only the header information, and none of the body. + + if(!isset($this->FP)) { + $this->ERROR = _("POP3 top:") . ' ' . _("No connection to server"); + return false; + } + $this->update_timer(); + + $fp = $this->FP; + $buffer = $this->BUFFER; + $cmd = "TOP $msgNum $numLines"; + fwrite($fp, "TOP $msgNum $numLines\r\n"); + $reply = fgets($fp, $buffer); + $reply = $this->strip_clf($reply); + if($this->DEBUG) { + @error_log("POP3 SEND [$cmd] GOT [$reply]",0); + } + if(!$this->is_ok($reply)) + { + $this->ERROR = _("POP3 top:") . ' ' . _("Error ") . "[$reply]"; + return false; + } + + $count = 0; + $MsgArray = array(); + + $line = fgets($fp,$buffer); + while ( !ereg("^\.\r\n",$line)) + { + $MsgArray[$count] = $line; + $count++; + $line = fgets($fp,$buffer); + if(empty($line)) { break; } + } + + return $MsgArray; + } + + function pop_list ($msgNum = "") { + // If called with an argument, returns that msgs' size in octets + // No argument returns an associative array of undeleted + // msg numbers and their sizes in octets + + if(!isset($this->FP)) + { + $this->ERROR = _("POP3 pop_list:") . ' ' . _("No connection to server"); + return false; + } + $fp = $this->FP; + $Total = $this->COUNT; + if( (!$Total) or ($Total == -1) ) + { + return false; + } + if($Total == 0) + { + return array("0","0"); + // return -1; // mailbox empty + } + + $this->update_timer(); + + if(!empty($msgNum)) + { + $cmd = "LIST $msgNum"; + fwrite($fp,"$cmd\r\n"); + $reply = fgets($fp,$this->BUFFER); + $reply = $this->strip_clf($reply); + if($this->DEBUG) { + @error_log("POP3 SEND [$cmd] GOT [$reply]",0); + } + if(!$this->is_ok($reply)) + { + $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]"; + return false; + } + list($junk,$num,$size) = explode(" ",$reply); + return $size; + } + $cmd = "LIST"; + $reply = $this->send_cmd($cmd); + if(!$this->is_ok($reply)) + { + $reply = $this->strip_clf($reply); + $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]"; + return false; + } + $MsgArray = array(); + $MsgArray[0] = $Total; + for($msgC=1;$msgC <= $Total; $msgC++) + { + if($msgC > $Total) { break; } + $line = fgets($fp,$this->BUFFER); + $line = $this->strip_clf($line); + if(ereg("^\.",$line)) + { + $this->ERROR = _("POP3 pop_list:") . ' ' . _("Premature end of list"); + return false; + } + list($thisMsg,$msgSize) = explode(" ",$line); + settype($thisMsg,"integer"); + if($thisMsg != $msgC) + { + $MsgArray[$msgC] = "deleted"; + } + else + { + $MsgArray[$msgC] = $msgSize; + } + } + return $MsgArray; + } + + function get ($msgNum) { + // Retrieve the specified msg number. Returns an array + // where each line of the msg is an array element. + + if(!isset($this->FP)) + { + $this->ERROR = _("POP3 get:") . ' ' . _("No connection to server"); + return false; + } + + $this->update_timer(); + + $fp = $this->FP; + $buffer = $this->BUFFER; + $cmd = "RETR $msgNum"; + $reply = $this->send_cmd($cmd); + + if(!$this->is_ok($reply)) + { + $this->ERROR = _("POP3 get:") . ' ' . _("Error ") . "[$reply]"; + return false; + } + + $count = 0; + $MsgArray = array(); + + $line = fgets($fp,$buffer); + while ( !ereg("^\.\r\n",$line)) + { + $MsgArray[$count] = $line; + $count++; + $line = fgets($fp,$buffer); + if(empty($line)) { break; } + } + return $MsgArray; + } + + function last ( $type = "count" ) { + // Returns the highest msg number in the mailbox. + // returns -1 on error, 0+ on success, if type != count + // results in a popstat() call (2 element array returned) + + $last = -1; + if(!isset($this->FP)) + { + $this->ERROR = _("POP3 last:") . ' ' . _("No connection to server"); + return $last; + } + + $reply = $this->send_cmd("STAT"); + if(!$this->is_ok($reply)) + { + $this->ERROR = _("POP3 last:") . ' ' . _("Error ") . "[$reply]"; + return $last; + } + + $Vars = explode(" ",$reply); + $count = $Vars[1]; + $size = $Vars[2]; + settype($count,"integer"); + settype($size,"integer"); + if($type != "count") + { + return array($count,$size); + } + return $count; + } + + function reset () { + // Resets the status of the remote server. This includes + // resetting the status of ALL msgs to not be deleted. + // This method automatically closes the connection to the server. + + if(!isset($this->FP)) + { + $this->ERROR = _("POP3 reset:") . ' ' . _("No connection to server"); + return false; + } + $reply = $this->send_cmd("RSET"); + if(!$this->is_ok($reply)) + { + // The POP3 RSET command -never- gives a -ERR + // response - if it ever does, something truely + // wild is going on. + + $this->ERROR = _("POP3 reset:") . ' ' . _("Error ") . "[$reply]"; + @error_log("POP3 reset: ERROR [$reply]",0); + } + $this->quit(); + return true; + } + + function send_cmd ( $cmd = "" ) + { + // Sends a user defined command string to the + // POP server and returns the results. Useful for + // non-compliant or custom POP servers. + // Do NOT includ the \r\n as part of your command + // string - it will be appended automatically. + + // The return value is a standard fgets() call, which + // will read up to $this->BUFFER bytes of data, until it + // encounters a new line, or EOF, whichever happens first. + + // This method works best if $cmd responds with only + // one line of data. + + if(!isset($this->FP)) + { + $this->ERROR = _("POP3 send_cmd:") . ' ' . _("No connection to server"); + return false; + } + + if(empty($cmd)) + { + $this->ERROR = _("POP3 send_cmd:") . ' ' . _("Empty command string"); + return ""; + } + + $fp = $this->FP; + $buffer = $this->BUFFER; + $this->update_timer(); + fwrite($fp,"$cmd\r\n"); + $reply = fgets($fp,$buffer); + $reply = $this->strip_clf($reply); + if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } + return $reply; + } + + function quit() { + // Closes the connection to the POP3 server, deleting + // any msgs marked as deleted. + + if(!isset($this->FP)) + { + $this->ERROR = _("POP3 quit:") . ' ' . _("connection does not exist"); + return false; + } + $fp = $this->FP; + $cmd = "QUIT"; + fwrite($fp,"$cmd\r\n"); + $reply = fgets($fp,$this->BUFFER); + $reply = $this->strip_clf($reply); + if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } + fclose($fp); + unset($this->FP); + return true; + } + + function popstat () { + // Returns an array of 2 elements. The number of undeleted + // msgs in the mailbox, and the size of the mbox in octets. + + $PopArray = $this->last("array"); + + if($PopArray == -1) { return false; } + + if( (!$PopArray) or (empty($PopArray)) ) + { + return false; + } + return $PopArray; + } + + function uidl ($msgNum = "") + { + // Returns the UIDL of the msg specified. If called with + // no arguments, returns an associative array where each + // undeleted msg num is a key, and the msg's uidl is the element + // Array element 0 will contain the total number of msgs + + if(!isset($this->FP)) { + $this->ERROR = _("POP3 uidl:") . ' ' . _("No connection to server"); + return false; + } + + $fp = $this->FP; + $buffer = $this->BUFFER; + + if(!empty($msgNum)) { + $cmd = "UIDL $msgNum"; + $reply = $this->send_cmd($cmd); + if(!$this->is_ok($reply)) + { + $this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]"; + return false; + } + list ($ok,$num,$myUidl) = explode(" ",$reply); + return $myUidl; + } else { + $this->update_timer(); + + $UIDLArray = array(); + $Total = $this->COUNT; + $UIDLArray[0] = $Total; + + if ($Total < 1) + { + return $UIDLArray; + } + $cmd = "UIDL"; + fwrite($fp, "UIDL\r\n"); + $reply = fgets($fp, $buffer); + $reply = $this->strip_clf($reply); + if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } + if(!$this->is_ok($reply)) + { + $this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]"; + return false; + } + + $line = ""; + $count = 1; + $line = fgets($fp,$buffer); + while ( !ereg("^\.\r\n",$line)) { + if(ereg("^\.\r\n",$line)) { + break; + } + list ($msg,$msgUidl) = explode(" ",$line); + $msgUidl = $this->strip_clf($msgUidl); + if($count == $msg) { + $UIDLArray[$msg] = $msgUidl; + } + else + { + $UIDLArray[$count] = 'deleted'; + } + $count++; + $line = fgets($fp,$buffer); + } + } + return $UIDLArray; + } + + function delete ($msgNum = "") { + // Flags a specified msg as deleted. The msg will not + // be deleted until a quit() method is called. + + if(!isset($this->FP)) + { + $this->ERROR = _("POP3 delete:") . ' ' . _("No connection to server"); + return false; + } + if(empty($msgNum)) + { + $this->ERROR = _("POP3 delete:") . ' ' . _("No msg number submitted"); + return false; + } + $reply = $this->send_cmd("DELE $msgNum"); + if(!$this->is_ok($reply)) + { + $this->ERROR = _("POP3 delete:") . ' ' . _("Command failed ") . "[$reply]"; + return false; + } + return true; + } + + // ********************************************************* + + // The following methods are internal to the class. + + function is_ok ($cmd = "") { + // Return true or false on +OK or -ERR + + if( empty($cmd) ) + return false; + else + return( ereg ("^\+OK", $cmd ) ); + } + + function strip_clf ($text = "") { + // Strips \r\n from server responses + + if(empty($text)) + return $text; + else { + $stripped = str_replace("\r",'',$text); + $stripped = str_replace("\n",'',$stripped); + return $stripped; + } + } + + function parse_banner ( $server_text ) { + $outside = true; + $banner = ""; + $length = strlen($server_text); + for($count =0; $count < $length; $count++) + { + $digit = substr($server_text, $count, 1); + if ( false !== $digit ) { + if( (!$outside) && ($digit != '<') && ($digit != '>') ) + { + $banner .= $digit; + } + if ($digit == '<') + { + $outside = false; + } + if($digit == '>') + { + $outside = true; + } + } + } + $banner = $this->strip_clf($banner); // Just in case + return "<$banner>"; + } + +} // End class + +?> diff --git a/wp-includes/class-snoopy.php b/wp-includes/class-snoopy.php new file mode 100644 index 00000000..9711a28d --- /dev/null +++ b/wp-includes/class-snoopy.php @@ -0,0 +1,1259 @@ + +Copyright (c): 1999-2000 ispi, all rights reserved +Version: 1.01 + + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +You may contact the author of Snoopy by e-mail at: +monte@ispi.net + +Or, write to: +Monte Ohrt +CTO, ispi +237 S. 70th suite 220 +Lincoln, NE 68510 + +The latest version of Snoopy can be obtained from: +http://snoopy.sourceforge.net/ + +*************************************************/ + +if ( !in_array('Snoopy', get_declared_classes() ) ) : +class Snoopy +{ + /**** Public variables ****/ + + /* user definable vars */ + + var $host = "www.php.net"; // host name we are connecting to + var $port = 80; // port we are connecting to + var $proxy_host = ""; // proxy host to use + var $proxy_port = ""; // proxy port to use + var $proxy_user = ""; // proxy user to use + var $proxy_pass = ""; // proxy password to use + + var $agent = "Snoopy v1.2.3"; // agent we masquerade as + var $referer = ""; // referer info to pass + var $cookies = array(); // array of cookies to pass + // $cookies["username"]="joe"; + var $rawheaders = array(); // array of raw headers to send + // $rawheaders["Content-type"]="text/html"; + + var $maxredirs = 5; // http redirection depth maximum. 0 = disallow + var $lastredirectaddr = ""; // contains address of last redirected address + var $offsiteok = true; // allows redirection off-site + var $maxframes = 0; // frame content depth maximum. 0 = disallow + var $expandlinks = true; // expand links to fully qualified URLs. + // this only applies to fetchlinks() + // submitlinks(), and submittext() + var $passcookies = true; // pass set cookies back through redirects + // NOTE: this currently does not respect + // dates, domains or paths. + + var $user = ""; // user for http authentication + var $pass = ""; // password for http authentication + + // http accept types + var $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; + + var $results = ""; // where the content is put + + var $error = ""; // error messages sent here + var $response_code = ""; // response code returned from server + var $headers = array(); // headers returned from server sent here + var $maxlength = 500000; // max return data length (body) + var $read_timeout = 0; // timeout on read operations, in seconds + // supported only since PHP 4 Beta 4 + // set to 0 to disallow timeouts + var $timed_out = false; // if a read operation timed out + var $status = 0; // http request status + + var $temp_dir = "/tmp"; // temporary directory that the webserver + // has permission to write to. + // under Windows, this should be C:\temp + + var $curl_path = "/usr/local/bin/curl"; + // Snoopy will use cURL for fetching + // SSL content if a full system path to + // the cURL binary is supplied here. + // set to false if you do not have + // cURL installed. See http://curl.haxx.se + // for details on installing cURL. + // Snoopy does *not* use the cURL + // library functions built into php, + // as these functions are not stable + // as of this Snoopy release. + + /**** Private variables ****/ + + var $_maxlinelen = 4096; // max line length (headers) + + var $_httpmethod = "GET"; // default http request method + var $_httpversion = "HTTP/1.0"; // default http request version + var $_submit_method = "POST"; // default submit method + var $_submit_type = "application/x-www-form-urlencoded"; // default submit type + var $_mime_boundary = ""; // MIME boundary for multipart/form-data submit type + var $_redirectaddr = false; // will be set if page fetched is a redirect + var $_redirectdepth = 0; // increments on an http redirect + var $_frameurls = array(); // frame src urls + var $_framedepth = 0; // increments on frame depth + + var $_isproxy = false; // set if using a proxy server + var $_fp_timeout = 30; // timeout for socket connection + +/*======================================================================*\ + Function: fetch + Purpose: fetch the contents of a web page + (and possibly other protocols in the + future like ftp, nntp, gopher, etc.) + Input: $URI the location of the page to fetch + Output: $this->results the output text from the fetch +\*======================================================================*/ + + function fetch($URI) + { + + //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS); + $URI_PARTS = parse_url($URI); + if (!empty($URI_PARTS["user"])) + $this->user = $URI_PARTS["user"]; + if (!empty($URI_PARTS["pass"])) + $this->pass = $URI_PARTS["pass"]; + if (empty($URI_PARTS["query"])) + $URI_PARTS["query"] = ''; + if (empty($URI_PARTS["path"])) + $URI_PARTS["path"] = ''; + + switch(strtolower($URI_PARTS["scheme"])) + { + case "http": + $this->host = $URI_PARTS["host"]; + if(!empty($URI_PARTS["port"])) + $this->port = $URI_PARTS["port"]; + if($this->_connect($fp)) + { + if($this->_isproxy) + { + // using proxy, send entire URI + $this->_httprequest($URI,$fp,$URI,$this->_httpmethod); + } + else + { + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); + // no proxy, send only the path + $this->_httprequest($path, $fp, $URI, $this->_httpmethod); + } + + $this->_disconnect($fp); + + if($this->_redirectaddr) + { + /* url was redirected, check if we've hit the max depth */ + if($this->maxredirs > $this->_redirectdepth) + { + // only follow redirect if it's on this site, or offsiteok is true + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) + { + /* follow the redirect */ + $this->_redirectdepth++; + $this->lastredirectaddr=$this->_redirectaddr; + $this->fetch($this->_redirectaddr); + } + } + } + + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) + { + $frameurls = $this->_frameurls; + $this->_frameurls = array(); + + while(list(,$frameurl) = each($frameurls)) + { + if($this->_framedepth < $this->maxframes) + { + $this->fetch($frameurl); + $this->_framedepth++; + } + else + break; + } + } + } + else + { + return false; + } + return true; + break; + case "https": + if(!$this->curl_path) + return false; + if(function_exists("is_executable")) + if (!is_executable($this->curl_path)) + return false; + $this->host = $URI_PARTS["host"]; + if(!empty($URI_PARTS["port"])) + $this->port = $URI_PARTS["port"]; + if($this->_isproxy) + { + // using proxy, send entire URI + $this->_httpsrequest($URI,$URI,$this->_httpmethod); + } + else + { + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); + // no proxy, send only the path + $this->_httpsrequest($path, $URI, $this->_httpmethod); + } + + if($this->_redirectaddr) + { + /* url was redirected, check if we've hit the max depth */ + if($this->maxredirs > $this->_redirectdepth) + { + // only follow redirect if it's on this site, or offsiteok is true + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) + { + /* follow the redirect */ + $this->_redirectdepth++; + $this->lastredirectaddr=$this->_redirectaddr; + $this->fetch($this->_redirectaddr); + } + } + } + + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) + { + $frameurls = $this->_frameurls; + $this->_frameurls = array(); + + while(list(,$frameurl) = each($frameurls)) + { + if($this->_framedepth < $this->maxframes) + { + $this->fetch($frameurl); + $this->_framedepth++; + } + else + break; + } + } + return true; + break; + default: + // not a valid protocol + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; + return false; + break; + } + return true; + } + +/*======================================================================*\ + Function: submit + Purpose: submit an http form + Input: $URI the location to post the data + $formvars the formvars to use. + format: $formvars["var"] = "val"; + $formfiles an array of files to submit + format: $formfiles["var"] = "/dir/filename.ext"; + Output: $this->results the text output from the post +\*======================================================================*/ + + function submit($URI, $formvars="", $formfiles="") + { + unset($postdata); + + $postdata = $this->_prepare_post_body($formvars, $formfiles); + + $URI_PARTS = parse_url($URI); + if (!empty($URI_PARTS["user"])) + $this->user = $URI_PARTS["user"]; + if (!empty($URI_PARTS["pass"])) + $this->pass = $URI_PARTS["pass"]; + if (empty($URI_PARTS["query"])) + $URI_PARTS["query"] = ''; + if (empty($URI_PARTS["path"])) + $URI_PARTS["path"] = ''; + + switch(strtolower($URI_PARTS["scheme"])) + { + case "http": + $this->host = $URI_PARTS["host"]; + if(!empty($URI_PARTS["port"])) + $this->port = $URI_PARTS["port"]; + if($this->_connect($fp)) + { + if($this->_isproxy) + { + // using proxy, send entire URI + $this->_httprequest($URI,$fp,$URI,$this->_submit_method,$this->_submit_type,$postdata); + } + else + { + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); + // no proxy, send only the path + $this->_httprequest($path, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata); + } + + $this->_disconnect($fp); + + if($this->_redirectaddr) + { + /* url was redirected, check if we've hit the max depth */ + if($this->maxredirs > $this->_redirectdepth) + { + if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]); + + // only follow redirect if it's on this site, or offsiteok is true + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) + { + /* follow the redirect */ + $this->_redirectdepth++; + $this->lastredirectaddr=$this->_redirectaddr; + if( strpos( $this->_redirectaddr, "?" ) > 0 ) + $this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get + else + $this->submit($this->_redirectaddr,$formvars, $formfiles); + } + } + } + + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) + { + $frameurls = $this->_frameurls; + $this->_frameurls = array(); + + while(list(,$frameurl) = each($frameurls)) + { + if($this->_framedepth < $this->maxframes) + { + $this->fetch($frameurl); + $this->_framedepth++; + } + else + break; + } + } + + } + else + { + return false; + } + return true; + break; + case "https": + if(!$this->curl_path) + return false; + if(function_exists("is_executable")) + if (!is_executable($this->curl_path)) + return false; + $this->host = $URI_PARTS["host"]; + if(!empty($URI_PARTS["port"])) + $this->port = $URI_PARTS["port"]; + if($this->_isproxy) + { + // using proxy, send entire URI + $this->_httpsrequest($URI, $URI, $this->_submit_method, $this->_submit_type, $postdata); + } + else + { + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); + // no proxy, send only the path + $this->_httpsrequest($path, $URI, $this->_submit_method, $this->_submit_type, $postdata); + } + + if($this->_redirectaddr) + { + /* url was redirected, check if we've hit the max depth */ + if($this->maxredirs > $this->_redirectdepth) + { + if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]); + + // only follow redirect if it's on this site, or offsiteok is true + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) + { + /* follow the redirect */ + $this->_redirectdepth++; + $this->lastredirectaddr=$this->_redirectaddr; + if( strpos( $this->_redirectaddr, "?" ) > 0 ) + $this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get + else + $this->submit($this->_redirectaddr,$formvars, $formfiles); + } + } + } + + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) + { + $frameurls = $this->_frameurls; + $this->_frameurls = array(); + + while(list(,$frameurl) = each($frameurls)) + { + if($this->_framedepth < $this->maxframes) + { + $this->fetch($frameurl); + $this->_framedepth++; + } + else + break; + } + } + return true; + break; + + default: + // not a valid protocol + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; + return false; + break; + } + return true; + } + +/*======================================================================*\ + Function: fetchlinks + Purpose: fetch the links from a web page + Input: $URI where you are fetching from + Output: $this->results an array of the URLs +\*======================================================================*/ + + function fetchlinks($URI) + { + if ($this->fetch($URI)) + { + if($this->lastredirectaddr) + $URI = $this->lastredirectaddr; + if(is_array($this->results)) + { + for($x=0;$xresults);$x++) + $this->results[$x] = $this->_striplinks($this->results[$x]); + } + else + $this->results = $this->_striplinks($this->results); + + if($this->expandlinks) + $this->results = $this->_expandlinks($this->results, $URI); + return true; + } + else + return false; + } + +/*======================================================================*\ + Function: fetchform + Purpose: fetch the form elements from a web page + Input: $URI where you are fetching from + Output: $this->results the resulting html form +\*======================================================================*/ + + function fetchform($URI) + { + + if ($this->fetch($URI)) + { + + if(is_array($this->results)) + { + for($x=0;$xresults);$x++) + $this->results[$x] = $this->_stripform($this->results[$x]); + } + else + $this->results = $this->_stripform($this->results); + + return true; + } + else + return false; + } + + +/*======================================================================*\ + Function: fetchtext + Purpose: fetch the text from a web page, stripping the links + Input: $URI where you are fetching from + Output: $this->results the text from the web page +\*======================================================================*/ + + function fetchtext($URI) + { + if($this->fetch($URI)) + { + if(is_array($this->results)) + { + for($x=0;$xresults);$x++) + $this->results[$x] = $this->_striptext($this->results[$x]); + } + else + $this->results = $this->_striptext($this->results); + return true; + } + else + return false; + } + +/*======================================================================*\ + Function: submitlinks + Purpose: grab links from a form submission + Input: $URI where you are submitting from + Output: $this->results an array of the links from the post +\*======================================================================*/ + + function submitlinks($URI, $formvars="", $formfiles="") + { + if($this->submit($URI,$formvars, $formfiles)) + { + if($this->lastredirectaddr) + $URI = $this->lastredirectaddr; + if(is_array($this->results)) + { + for($x=0;$xresults);$x++) + { + $this->results[$x] = $this->_striplinks($this->results[$x]); + if($this->expandlinks) + $this->results[$x] = $this->_expandlinks($this->results[$x],$URI); + } + } + else + { + $this->results = $this->_striplinks($this->results); + if($this->expandlinks) + $this->results = $this->_expandlinks($this->results,$URI); + } + return true; + } + else + return false; + } + +/*======================================================================*\ + Function: submittext + Purpose: grab text from a form submission + Input: $URI where you are submitting from + Output: $this->results the text from the web page +\*======================================================================*/ + + function submittext($URI, $formvars = "", $formfiles = "") + { + if($this->submit($URI,$formvars, $formfiles)) + { + if($this->lastredirectaddr) + $URI = $this->lastredirectaddr; + if(is_array($this->results)) + { + for($x=0;$xresults);$x++) + { + $this->results[$x] = $this->_striptext($this->results[$x]); + if($this->expandlinks) + $this->results[$x] = $this->_expandlinks($this->results[$x],$URI); + } + } + else + { + $this->results = $this->_striptext($this->results); + if($this->expandlinks) + $this->results = $this->_expandlinks($this->results,$URI); + } + return true; + } + else + return false; + } + + + +/*======================================================================*\ + Function: set_submit_multipart + Purpose: Set the form submission content type to + multipart/form-data +\*======================================================================*/ + function set_submit_multipart() + { + $this->_submit_type = "multipart/form-data"; + } + + +/*======================================================================*\ + Function: set_submit_normal + Purpose: Set the form submission content type to + application/x-www-form-urlencoded +\*======================================================================*/ + function set_submit_normal() + { + $this->_submit_type = "application/x-www-form-urlencoded"; + } + + + + +/*======================================================================*\ + Private functions +\*======================================================================*/ + + +/*======================================================================*\ + Function: _striplinks + Purpose: strip the hyperlinks from an html document + Input: $document document to strip. + Output: $match an array of the links +\*======================================================================*/ + + function _striplinks($document) + { + preg_match_all("'<\s*a\s.*?href\s*=\s* # find ]+)) # if quote found, match up to next matching + # quote, otherwise match up to next space + 'isx",$document,$links); + + + // catenate the non-empty matches from the conditional subpattern + + while(list($key,$val) = each($links[2])) + { + if(!empty($val)) + $match[] = $val; + } + + while(list($key,$val) = each($links[3])) + { + if(!empty($val)) + $match[] = $val; + } + + // return the links + return $match; + } + +/*======================================================================*\ + Function: _stripform + Purpose: strip the form elements from an html document + Input: $document document to strip. + Output: $match an array of the links +\*======================================================================*/ + + function _stripform($document) + { + preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements); + + // catenate the matches + $match = implode("\r\n",$elements[0]); + + // return the links + return $match; + } + + + +/*======================================================================*\ + Function: _striptext + Purpose: strip the text from an html document + Input: $document document to strip. + Output: $text the resulting text +\*======================================================================*/ + + function _striptext($document) + { + + // I didn't use preg eval (//e) since that is only available in PHP 4.0. + // so, list your entities one by one here. I included some of the + // more common ones. + + $search = array("']*?>.*?'si", // strip out javascript + "'<[\/\!]*?[^<>]*?>'si", // strip out html tags + "'([\r\n])[\s]+'", // strip out white space + "'&(quot|#34|#034|#x22);'i", // replace html entities + "'&(amp|#38|#038|#x26);'i", // added hexadecimal values + "'&(lt|#60|#060|#x3c);'i", + "'&(gt|#62|#062|#x3e);'i", + "'&(nbsp|#160|#xa0);'i", + "'&(iexcl|#161);'i", + "'&(cent|#162);'i", + "'&(pound|#163);'i", + "'&(copy|#169);'i", + "'&(reg|#174);'i", + "'&(deg|#176);'i", + "'&(#39|#039|#x27);'", + "'&(euro|#8364);'i", // europe + "'&a(uml|UML);'", // german + "'&o(uml|UML);'", + "'&u(uml|UML);'", + "'&A(uml|UML);'", + "'&O(uml|UML);'", + "'&U(uml|UML);'", + "'ß'i", + ); + $replace = array( "", + "", + "\\1", + "\"", + "&", + "<", + ">", + " ", + chr(161), + chr(162), + chr(163), + chr(169), + chr(174), + chr(176), + chr(39), + chr(128), + "ä", + "ö", + "ü", + "Ä", + "Ö", + "Ãœ", + "ß", + ); + + $text = preg_replace($search,$replace,$document); + + return $text; + } + +/*======================================================================*\ + Function: _expandlinks + Purpose: expand each link into a fully qualified URL + Input: $links the links to qualify + $URI the full URI to get the base from + Output: $expandedLinks the expanded links +\*======================================================================*/ + + function _expandlinks($links,$URI) + { + + preg_match("/^[^\?]+/",$URI,$match); + + $match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]); + $match = preg_replace("|/$|","",$match); + $match_part = parse_url($match); + $match_root = + $match_part["scheme"]."://".$match_part["host"]; + + $search = array( "|^http://".preg_quote($this->host)."|i", + "|^(\/)|i", + "|^(?!http://)(?!mailto:)|i", + "|/\./|", + "|/[^\/]+/\.\./|" + ); + + $replace = array( "", + $match_root."/", + $match."/", + "/", + "/" + ); + + $expandedLinks = preg_replace($search,$replace,$links); + + return $expandedLinks; + } + +/*======================================================================*\ + Function: _httprequest + Purpose: go get the http data from the server + Input: $url the url to fetch + $fp the current open file pointer + $URI the full URI + $body body contents to send if any (POST) + Output: +\*======================================================================*/ + + function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="") + { + $cookie_headers = ''; + if($this->passcookies && $this->_redirectaddr) + $this->setcookies(); + + $URI_PARTS = parse_url($URI); + if(empty($url)) + $url = "/"; + $headers = $http_method." ".$url." ".$this->_httpversion."\r\n"; + if(!empty($this->agent)) + $headers .= "User-Agent: ".$this->agent."\r\n"; + if(!empty($this->host) && !isset($this->rawheaders['Host'])) { + $headers .= "Host: ".$this->host; + if(!empty($this->port)) + $headers .= ":".$this->port; + $headers .= "\r\n"; + } + if(!empty($this->accept)) + $headers .= "Accept: ".$this->accept."\r\n"; + if(!empty($this->referer)) + $headers .= "Referer: ".$this->referer."\r\n"; + if(!empty($this->cookies)) + { + if(!is_array($this->cookies)) + $this->cookies = (array)$this->cookies; + + reset($this->cookies); + if ( count($this->cookies) > 0 ) { + $cookie_headers .= 'Cookie: '; + foreach ( $this->cookies as $cookieKey => $cookieVal ) { + $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; "; + } + $headers .= substr($cookie_headers,0,-2) . "\r\n"; + } + } + if(!empty($this->rawheaders)) + { + if(!is_array($this->rawheaders)) + $this->rawheaders = (array)$this->rawheaders; + while(list($headerKey,$headerVal) = each($this->rawheaders)) + $headers .= $headerKey.": ".$headerVal."\r\n"; + } + if(!empty($content_type)) { + $headers .= "Content-type: $content_type"; + if ($content_type == "multipart/form-data") + $headers .= "; boundary=".$this->_mime_boundary; + $headers .= "\r\n"; + } + if(!empty($body)) + $headers .= "Content-length: ".strlen($body)."\r\n"; + if(!empty($this->user) || !empty($this->pass)) + $headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n"; + + //add proxy auth headers + if(!empty($this->proxy_user)) + $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass)."\r\n"; + + + $headers .= "\r\n"; + + // set the read timeout if needed + if ($this->read_timeout > 0) + socket_set_timeout($fp, $this->read_timeout); + $this->timed_out = false; + + fwrite($fp,$headers.$body,strlen($headers.$body)); + + $this->_redirectaddr = false; + unset($this->headers); + + while($currentHeader = fgets($fp,$this->_maxlinelen)) + { + if ($this->read_timeout > 0 && $this->_check_timeout($fp)) + { + $this->status=-100; + return false; + } + + if($currentHeader == "\r\n") + break; + + // if a header begins with Location: or URI:, set the redirect + if(preg_match("/^(Location:|URI:)/i",$currentHeader)) + { + // get URL portion of the redirect + preg_match("/^(Location:|URI:)[ ]+(.*)/i",chop($currentHeader),$matches); + // look for :// in the Location header to see if hostname is included + if(!preg_match("|\:\/\/|",$matches[2])) + { + // no host in the path, so prepend + $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; + // eliminate double slash + if(!preg_match("|^/|",$matches[2])) + $this->_redirectaddr .= "/".$matches[2]; + else + $this->_redirectaddr .= $matches[2]; + } + else + $this->_redirectaddr = $matches[2]; + } + + if(preg_match("|^HTTP/|",$currentHeader)) + { + if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status)) + { + $this->status= $status[1]; + } + $this->response_code = $currentHeader; + } + + $this->headers[] = $currentHeader; + } + + $results = ''; + do { + $_data = fread($fp, $this->maxlength); + if (strlen($_data) == 0) { + break; + } + $results .= $_data; + } while(true); + + if ($this->read_timeout > 0 && $this->_check_timeout($fp)) + { + $this->status=-100; + return false; + } + + // check if there is a a redirect meta tag + + if(preg_match("']*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) + + { + $this->_redirectaddr = $this->_expandlinks($match[1],$URI); + } + + // have we hit our frame depth and is there frame src to fetch? + if(($this->_framedepth < $this->maxframes) && preg_match_all("']+)'i",$results,$match)) + { + $this->results[] = $results; + for($x=0; $x_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); + } + // have we already fetched framed content? + elseif(is_array($this->results)) + $this->results[] = $results; + // no framed content + else + $this->results = $results; + + return true; + } + +/*======================================================================*\ + Function: _httpsrequest + Purpose: go get the https data from the server using curl + Input: $url the url to fetch + $URI the full URI + $body body contents to send if any (POST) + Output: +\*======================================================================*/ + + function _httpsrequest($url,$URI,$http_method,$content_type="",$body="") + { + if($this->passcookies && $this->_redirectaddr) + $this->setcookies(); + + $headers = array(); + + $URI_PARTS = parse_url($URI); + if(empty($url)) + $url = "/"; + // GET ... header not needed for curl + //$headers[] = $http_method." ".$url." ".$this->_httpversion; + if(!empty($this->agent)) + $headers[] = "User-Agent: ".$this->agent; + if(!empty($this->host)) + if(!empty($this->port)) + $headers[] = "Host: ".$this->host.":".$this->port; + else + $headers[] = "Host: ".$this->host; + if(!empty($this->accept)) + $headers[] = "Accept: ".$this->accept; + if(!empty($this->referer)) + $headers[] = "Referer: ".$this->referer; + if(!empty($this->cookies)) + { + if(!is_array($this->cookies)) + $this->cookies = (array)$this->cookies; + + reset($this->cookies); + if ( count($this->cookies) > 0 ) { + $cookie_str = 'Cookie: '; + foreach ( $this->cookies as $cookieKey => $cookieVal ) { + $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; "; + } + $headers[] = substr($cookie_str,0,-2); + } + } + if(!empty($this->rawheaders)) + { + if(!is_array($this->rawheaders)) + $this->rawheaders = (array)$this->rawheaders; + while(list($headerKey,$headerVal) = each($this->rawheaders)) + $headers[] = $headerKey.": ".$headerVal; + } + if(!empty($content_type)) { + if ($content_type == "multipart/form-data") + $headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary; + else + $headers[] = "Content-type: $content_type"; + } + if(!empty($body)) + $headers[] = "Content-length: ".strlen($body); + if(!empty($this->user) || !empty($this->pass)) + $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); + + for($curr_header = 0; $curr_header < count($headers); $curr_header++) { + $safer_header = strtr( $headers[$curr_header], "\"", " " ); + $cmdline_params .= " -H \"".$safer_header."\""; + } + + if(!empty($body)) + $cmdline_params .= " -d \"$body\""; + + if($this->read_timeout > 0) + $cmdline_params .= " -m ".$this->read_timeout; + + $headerfile = tempnam($temp_dir, "sno"); + + $safer_URI = strtr( $URI, "\"", " " ); // strip quotes from the URI to avoid shell access + exec(escapeshellcmd($this->curl_path." -D \"$headerfile\"".$cmdline_params." \"".$safer_URI."\""),$results,$return); + + if($return) + { + $this->error = "Error: cURL could not retrieve the document, error $return."; + return false; + } + + + $results = implode("\r\n",$results); + + $result_headers = file("$headerfile"); + + $this->_redirectaddr = false; + unset($this->headers); + + for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++) + { + + // if a header begins with Location: or URI:, set the redirect + if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader])) + { + // get URL portion of the redirect + preg_match("/^(Location: |URI:)\s+(.*)/",chop($result_headers[$currentHeader]),$matches); + // look for :// in the Location header to see if hostname is included + if(!preg_match("|\:\/\/|",$matches[2])) + { + // no host in the path, so prepend + $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; + // eliminate double slash + if(!preg_match("|^/|",$matches[2])) + $this->_redirectaddr .= "/".$matches[2]; + else + $this->_redirectaddr .= $matches[2]; + } + else + $this->_redirectaddr = $matches[2]; + } + + if(preg_match("|^HTTP/|",$result_headers[$currentHeader])) + $this->response_code = $result_headers[$currentHeader]; + + $this->headers[] = $result_headers[$currentHeader]; + } + + // check if there is a a redirect meta tag + + if(preg_match("']*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) + { + $this->_redirectaddr = $this->_expandlinks($match[1],$URI); + } + + // have we hit our frame depth and is there frame src to fetch? + if(($this->_framedepth < $this->maxframes) && preg_match_all("']+)'i",$results,$match)) + { + $this->results[] = $results; + for($x=0; $x_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); + } + // have we already fetched framed content? + elseif(is_array($this->results)) + $this->results[] = $results; + // no framed content + else + $this->results = $results; + + unlink("$headerfile"); + + return true; + } + +/*======================================================================*\ + Function: setcookies() + Purpose: set cookies for a redirection +\*======================================================================*/ + + function setcookies() + { + for($x=0; $xheaders); $x++) + { + if(preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x],$match)) + $this->cookies[$match[1]] = urldecode($match[2]); + } + } + + +/*======================================================================*\ + Function: _check_timeout + Purpose: checks whether timeout has occurred + Input: $fp file pointer +\*======================================================================*/ + + function _check_timeout($fp) + { + if ($this->read_timeout > 0) { + $fp_status = socket_get_status($fp); + if ($fp_status["timed_out"]) { + $this->timed_out = true; + return true; + } + } + return false; + } + +/*======================================================================*\ + Function: _connect + Purpose: make a socket connection + Input: $fp file pointer +\*======================================================================*/ + + function _connect(&$fp) + { + if(!empty($this->proxy_host) && !empty($this->proxy_port)) + { + $this->_isproxy = true; + + $host = $this->proxy_host; + $port = $this->proxy_port; + } + else + { + $host = $this->host; + $port = $this->port; + } + + $this->status = 0; + + if($fp = fsockopen( + $host, + $port, + $errno, + $errstr, + $this->_fp_timeout + )) + { + // socket connection succeeded + + return true; + } + else + { + // socket connection failed + $this->status = $errno; + switch($errno) + { + case -3: + $this->error="socket creation failed (-3)"; + case -4: + $this->error="dns lookup failure (-4)"; + case -5: + $this->error="connection refused or timed out (-5)"; + default: + $this->error="connection failed (".$errno.")"; + } + return false; + } + } +/*======================================================================*\ + Function: _disconnect + Purpose: disconnect a socket connection + Input: $fp file pointer +\*======================================================================*/ + + function _disconnect($fp) + { + return(fclose($fp)); + } + + +/*======================================================================*\ + Function: _prepare_post_body + Purpose: Prepare post body according to encoding type + Input: $formvars - form variables + $formfiles - form upload files + Output: post body +\*======================================================================*/ + + function _prepare_post_body($formvars, $formfiles) + { + settype($formvars, "array"); + settype($formfiles, "array"); + $postdata = ''; + + if (count($formvars) == 0 && count($formfiles) == 0) + return; + + switch ($this->_submit_type) { + case "application/x-www-form-urlencoded": + reset($formvars); + while(list($key,$val) = each($formvars)) { + if (is_array($val) || is_object($val)) { + while (list($cur_key, $cur_val) = each($val)) { + $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&"; + } + } else + $postdata .= urlencode($key)."=".urlencode($val)."&"; + } + break; + + case "multipart/form-data": + $this->_mime_boundary = "Snoopy".md5(uniqid(microtime())); + + reset($formvars); + while(list($key,$val) = each($formvars)) { + if (is_array($val) || is_object($val)) { + while (list($cur_key, $cur_val) = each($val)) { + $postdata .= "--".$this->_mime_boundary."\r\n"; + $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n"; + $postdata .= "$cur_val\r\n"; + } + } else { + $postdata .= "--".$this->_mime_boundary."\r\n"; + $postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n"; + $postdata .= "$val\r\n"; + } + } + + reset($formfiles); + while (list($field_name, $file_names) = each($formfiles)) { + settype($file_names, "array"); + while (list(, $file_name) = each($file_names)) { + if (!is_readable($file_name)) continue; + + $fp = fopen($file_name, "r"); + $file_content = fread($fp, filesize($file_name)); + fclose($fp); + $base_name = basename($file_name); + + $postdata .= "--".$this->_mime_boundary."\r\n"; + $postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n"; + $postdata .= "$file_content\r\n"; + } + } + $postdata .= "--".$this->_mime_boundary."--\r\n"; + break; + } + + return $postdata; + } +} +endif; + +?> diff --git a/wp-includes/classes.php b/wp-includes/classes.php new file mode 100644 index 00000000..4834fae0 --- /dev/null +++ b/wp-includes/classes.php @@ -0,0 +1,1720 @@ +is_single = false; + $this->is_page = false; + $this->is_archive = false; + $this->is_date = false; + $this->is_year = false; + $this->is_month = false; + $this->is_day = false; + $this->is_time = false; + $this->is_author = false; + $this->is_category = false; + $this->is_search = false; + $this->is_feed = false; + $this->is_trackback = false; + $this->is_home = false; + $this->is_404 = false; + $this->is_paged = false; + $this->is_admin = false; + $this->is_attachment = false; + } + + function init () { + unset($this->posts); + unset($this->query); + unset($this->query_vars); + unset($this->queried_object); + unset($this->queried_object_id); + $this->post_count = 0; + $this->current_post = -1; + $this->in_the_loop = false; + + $this->init_query_flags(); + } + + // Reparse the query vars. + function parse_query_vars() { + $this->parse_query(''); + } + + // Parse a query string and set query type booleans. + function parse_query ($query) { + if ( !empty($query) || !isset($this->query) ) { + $this->init(); + parse_str($query, $qv); + $this->query = $query; + $this->query_vars = $qv; + } + + if ('404' == $qv['error']) { + $this->is_404 = true; + if ( !empty($query) ) { + do_action('parse_query', array(&$this)); + } + return; + } + + $qv['m'] = (int) $qv['m']; + $qv['p'] = (int) $qv['p']; + + // Compat. Map subpost to attachment. + if ( '' != $qv['subpost'] ) + $qv['attachment'] = $qv['subpost']; + if ( '' != $qv['subpost_id'] ) + $qv['attachment_id'] = $qv['subpost_id']; + + if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) { + $this->is_single = true; + $this->is_attachment = true; + } elseif ('' != $qv['name']) { + $this->is_single = true; + } elseif ( $qv['p'] ) { + $this->is_single = true; + } elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) { + // If year, month, day, hour, minute, and second are set, a single + // post is being queried. + $this->is_single = true; + } elseif ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) { + $this->is_page = true; + $this->is_single = false; + } elseif (!empty($qv['s'])) { + $this->is_search = true; + switch ($qv['show_post_type']) { + case 'page' : + $this->is_page = true; + break; + case 'attachment' : + $this->is_attachment = true; + break; + } + } else { + // Look for archive queries. Dates, categories, authors. + + if ( (int) $qv['second']) { + $this->is_time = true; + $this->is_date = true; + } + + if ( (int) $qv['minute']) { + $this->is_time = true; + $this->is_date = true; + } + + if ( (int) $qv['hour']) { + $this->is_time = true; + $this->is_date = true; + } + + if ( (int) $qv['day']) { + if (! $this->is_date) { + $this->is_day = true; + $this->is_date = true; + } + } + + if ( (int) $qv['monthnum']) { + if (! $this->is_date) { + $this->is_month = true; + $this->is_date = true; + } + } + + if ( (int) $qv['year']) { + if (! $this->is_date) { + $this->is_year = true; + $this->is_date = true; + } + } + + if ( (int) $qv['m']) { + $this->is_date = true; + if (strlen($qv['m']) > 9) { + $this->is_time = true; + } else if (strlen($qv['m']) > 7) { + $this->is_day = true; + } else if (strlen($qv['m']) > 5) { + $this->is_month = true; + } else { + $this->is_year = true; + } + } + + if ('' != $qv['w']) { + $this->is_date = true; + } + + if (empty($qv['cat']) || ($qv['cat'] == '0')) { + $this->is_category = false; + } else { + if (stristr($qv['cat'],'-')) { + $this->is_category = false; + } else { + $this->is_category = true; + } + } + + if ('' != $qv['category_name']) { + $this->is_category = true; + } + + if ((empty($qv['author'])) || ($qv['author'] == '0')) { + $this->is_author = false; + } else { + $this->is_author = true; + } + + if ('' != $qv['author_name']) { + $this->is_author = true; + } + + if ( ($this->is_date || $this->is_author || $this->is_category)) { + $this->is_archive = true; + } + + if ( 'attachment' == $qv['show_post_type'] ) { + $this->is_attachment = true; + } + } + + if ('' != $qv['feed']) { + $this->is_feed = true; + } + + if ('' != $qv['tb']) { + $this->is_trackback = true; + } + + if ('' != $qv['paged']) { + $this->is_paged = true; + } + + if ('' != $qv['comments_popup']) { + $this->is_comments_popup = true; + } + + //if we're previewing inside the write screen + if ('' != $qv['preview']) { + $this->is_preview = true; + } + + if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) { + $this->is_admin = true; + } + + if ( ! ($this->is_attachment || $this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) { + $this->is_home = true; + } + + if ( !empty($query) ) { + do_action('parse_query', array(&$this)); + } + } + + function set_404() { + $this->init_query_flags(); + $this->is_404 = true; + } + + function get($query_var) { + if (isset($this->query_vars[$query_var])) { + return $this->query_vars[$query_var]; + } + + return ''; + } + + function set($query_var, $value) { + $this->query_vars[$query_var] = $value; + } + + function &get_posts() { + global $wpdb, $pagenow, $user_ID; + + do_action('pre_get_posts', array(&$this)); + + // Shorthand. + $q = $this->query_vars; + + // First let's clear some variables + $whichcat = ''; + $whichauthor = ''; + $whichpage = ''; + $result = ''; + $where = ''; + $limits = ''; + $distinct = ''; + $join = ''; + + if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 ) + $q['posts_per_page'] = get_settings('posts_per_page'); + if ( !isset($q['what_to_show']) ) + $q['what_to_show'] = get_settings('what_to_show'); + if ( isset($q['showposts']) && $q['showposts'] ) { + $q['showposts'] = (int) $q['showposts']; + $q['posts_per_page'] = $q['showposts']; + } + if ( (isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search) ) + $q['posts_per_page'] = $q['posts_per_archive_page']; + if ( !isset($q['nopaging']) ) { + if ($q['posts_per_page'] == -1) { + $q['nopaging'] = true; + } else { + $q['nopaging'] = false; + } + } + if ( $this->is_feed ) { + $q['posts_per_page'] = get_settings('posts_per_rss'); + $q['what_to_show'] = 'posts'; + } + + if (isset($q['page'])) { + $q['page'] = trim($q['page'], '/'); + $q['page'] = (int) $q['page']; + } + + $add_hours = intval(get_settings('gmt_offset')); + $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours)); + $wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"; + + // If a month is specified in the querystring, load that month + if ( (int) $q['m'] ) { + $q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']); + $where .= ' AND YEAR(post_date)=' . substr($q['m'], 0, 4); + if (strlen($q['m'])>5) + $where .= ' AND MONTH(post_date)=' . substr($q['m'], 4, 2); + if (strlen($q['m'])>7) + $where .= ' AND DAYOFMONTH(post_date)=' . substr($q['m'], 6, 2); + if (strlen($q['m'])>9) + $where .= ' AND HOUR(post_date)=' . substr($q['m'], 8, 2); + if (strlen($q['m'])>11) + $where .= ' AND MINUTE(post_date)=' . substr($q['m'], 10, 2); + if (strlen($q['m'])>13) + $where .= ' AND SECOND(post_date)=' . substr($q['m'], 12, 2); + } + + if ( (int) $q['hour'] ) { + $q['hour'] = '' . intval($q['hour']); + $where .= " AND HOUR(post_date)='" . $q['hour'] . "'"; + } + + if ( (int) $q['minute'] ) { + $q['minute'] = '' . intval($q['minute']); + $where .= " AND MINUTE(post_date)='" . $q['minute'] . "'"; + } + + if ( (int) $q['second'] ) { + $q['second'] = '' . intval($q['second']); + $where .= " AND SECOND(post_date)='" . $q['second'] . "'"; + } + + if ( (int) $q['year'] ) { + $q['year'] = '' . intval($q['year']); + $where .= " AND YEAR(post_date)='" . $q['year'] . "'"; + } + + if ( (int) $q['monthnum'] ) { + $q['monthnum'] = '' . intval($q['monthnum']); + $where .= " AND MONTH(post_date)='" . $q['monthnum'] . "'"; + } + + if ( (int) $q['day'] ) { + $q['day'] = '' . intval($q['day']); + $where .= " AND DAYOFMONTH(post_date)='" . $q['day'] . "'"; + } + + // Compat. Map subpost to attachment. + if ( '' != $q['subpost'] ) + $q['attachment'] = $q['subpost']; + if ( '' != $q['subpost_id'] ) + $q['attachment_id'] = $q['subpost_id']; + + if ('' != $q['name']) { + $q['name'] = sanitize_title($q['name']); + $where .= " AND post_name = '" . $q['name'] . "'"; + } else if ('' != $q['pagename']) { + $q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename']))); + $page_paths = '/' . trim($q['pagename'], '/'); + $q['pagename'] = sanitize_title(basename($page_paths)); + $q['name'] = $q['pagename']; + $page_paths = explode('/', $page_paths); + foreach($page_paths as $pathdir) + $page_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); + + $all_page_ids = get_all_page_ids(); + $reqpage = 0; + if (is_array($all_page_ids)) { foreach ( $all_page_ids as $page_id ) { + $page = get_page($page_id); + if ( $page->fullpath == $page_path ) { + $reqpage = $page_id; + break; + } + } } + + $where .= " AND (ID = '$reqpage')"; + } elseif ('' != $q['attachment']) { + $q['attachment'] = str_replace('%2F', '/', urlencode(urldecode($q['attachment']))); + $attach_paths = '/' . trim($q['attachment'], '/'); + $q['attachment'] = sanitize_title(basename($attach_paths)); + $q['name'] = $q['attachment']; + $where .= " AND post_name = '" . $q['attachment'] . "'"; + } + + if ( (int) $q['w'] ) { + $q['w'] = ''.intval($q['w']); + $where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'"; + } + + if ( intval($q['comments_popup']) ) + $q['p'] = intval($q['comments_popup']); + + // If a attachment is requested by number, let it supercede any post number. + if ( ($q['attachment_id'] != '') && (intval($q['attachment_id']) != 0) ) + $q['p'] = (int) $q['attachment_id']; + + // If a post number is specified, load that post + if (($q['p'] != '') && intval($q['p']) != 0) { + $q['p'] = (int) $q['p']; + $where = ' AND ID = ' . $q['p']; + } + + if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) { + $q['page_id'] = intval($q['page_id']); + $q['p'] = $q['page_id']; + $where = ' AND ID = '.$q['page_id']; + } + + // If a search pattern is specified, load the posts that match + if (!empty($q['s'])) { + $q['s'] = addslashes_gpc($q['s']); + $search = ' AND ('; + $q['s'] = preg_replace('/, +/', ' ', $q['s']); + $q['s'] = str_replace(',', ' ', $q['s']); + $q['s'] = str_replace('"', ' ', $q['s']); + $q['s'] = trim($q['s']); + if ($q['exact']) { + $n = ''; + } else { + $n = '%'; + } + if (!$q['sentence']) { + $s_array = explode(' ',$q['s']); + $q['search_terms'] = $s_array; + $search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))'; + for ( $i = 1; $i < count($s_array); $i = $i + 1) { + $search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))'; + } + $search .= ' OR (post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\')'; + $search .= ')'; + } else { + $search = ' AND ((post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\'))'; + } + } + + // Category stuff + + if ((empty($q['cat'])) || ($q['cat'] == '0') || + // Bypass cat checks if fetching specific posts + ( $this->is_single || $this->is_page )) { + $whichcat=''; + } else { + $q['cat'] = ''.urldecode($q['cat']).''; + $q['cat'] = addslashes_gpc($q['cat']); + if (stristr($q['cat'],'-')) { + // Note: if we have a negative, we ignore all the positives. It must + // always mean 'everything /except/ this one'. We should be able to do + // multiple negatives but we don't :-( + $eq = '!='; + $andor = 'AND'; + $q['cat'] = explode('-',$q['cat']); + $q['cat'] = intval($q['cat'][1]); + } else { + $eq = '='; + $andor = 'OR'; + } + $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) "; + $cat_array = preg_split('/[,\s]+/', $q['cat']); + $whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]); + $whichcat .= get_category_children($cat_array[0], ' '.$andor.' category_id '.$eq.' '); + for ($i = 1; $i < (count($cat_array)); $i = $i + 1) { + $whichcat .= ' '.$andor.' category_id '.$eq.' '.intval($cat_array[$i]); + $whichcat .= get_category_children($cat_array[$i], ' '.$andor.' category_id '.$eq.' '); + } + $whichcat .= ')'; + if ($eq == '!=') { + $q['cat'] = '-'.$q['cat']; // Put back the knowledge that we are excluding a category. + } + } + + // Category stuff for nice URIs + + global $cache_categories; + if ('' != $q['category_name']) { + $cat_paths = '/' . trim(urldecode($q['category_name']), '/'); + $q['category_name'] = sanitize_title(basename($cat_paths)); + $cat_paths = explode('/', $cat_paths); + foreach($cat_paths as $pathdir) + $cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); + + $all_cat_ids = get_all_category_ids(); + $q['cat'] = 0; $partial_match = 0; + foreach ( $all_cat_ids as $cat_id ) { + $cat = get_category($cat_id); + if ( $cat->fullpath == $cat_path ) { + $q['cat'] = $cat_id; + break; + } elseif ( $cat->category_nicename == $q['category_name'] ) { + $partial_match = $cat_id; + } + } + + //if we don't match the entire hierarchy fallback on just matching the nicename + if (!$q['cat'] && $partial_match) { + $q['cat'] = $partial_match; + } + + $tables = ", $wpdb->post2cat, $wpdb->categories"; + $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) "; + $whichcat = " AND (category_id = '" . $q['cat'] . "'"; + $whichcat .= get_category_children($q['cat'], " OR category_id = "); + $whichcat .= ")"; + } + + // Author/user stuff + + if ((empty($q['author'])) || ($q['author'] == '0')) { + $whichauthor=''; + } else { + $q['author'] = ''.urldecode($q['author']).''; + $q['author'] = addslashes_gpc($q['author']); + if (stristr($q['author'], '-')) { + $eq = '!='; + $andor = 'AND'; + $q['author'] = explode('-', $q['author']); + $q['author'] = ''.intval($q['author'][1]); + } else { + $eq = '='; + $andor = 'OR'; + } + $author_array = preg_split('/[,\s]+/', $q['author']); + $whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]); + for ($i = 1; $i < (count($author_array)); $i = $i + 1) { + $whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]); + } + $whichauthor .= ')'; + } + + // Author stuff for nice URIs + + if ('' != $q['author_name']) { + if (stristr($q['author_name'],'/')) { + $q['author_name'] = explode('/',$q['author_name']); + if ($q['author_name'][count($q['author_name'])-1]) { + $q['author_name'] = $q['author_name'][count($q['author_name'])-1];#no trailing slash + } else { + $q['author_name'] = $q['author_name'][count($q['author_name'])-2];#there was a trailling slash + } + } + $q['author_name'] = sanitize_title($q['author_name']); + $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'"); + $whichauthor .= ' AND (post_author = '.intval($q['author']).')'; + } + + $where .= $search.$whichcat.$whichauthor; + + if ((empty($q['order'])) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC'))) { + $q['order']='DESC'; + } + + // Order by + if (empty($q['orderby'])) { + $q['orderby']='date '.$q['order']; + } else { + // Used to filter values + $allowed_keys = array('author', 'date', 'category', 'title', 'modified'); + $q['orderby'] = urldecode($q['orderby']); + $q['orderby'] = addslashes_gpc($q['orderby']); + $orderby_array = explode(' ',$q['orderby']); + if (!in_array($orderby_array[0],$allowed_keys)) { + $orderby_array[0] = 'date'; + } + $q['orderby'] = $orderby_array[0].' '.$q['order']; + if (count($orderby_array)>1) { + for ($i = 1; $i < (count($orderby_array)); $i = $i + 1) { + // Only allow certain values for safety + if (in_array($orderby_array[$i],$allowed_keys)) { + $q['orderby'] .= ',post_'.$orderby_array[$i].' '.$q['order']; + } + } + } + } + + $now = gmdate('Y-m-d H:i:59'); + + //only select past-dated posts, except if a logged in user is viewing a single: then, if they + //can edit the post, we let them through + if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) { + $where .= " AND post_date_gmt <= '$now'"; + $distinct = 'DISTINCT'; + } + + if ( $this->is_attachment ) { + $where .= ' AND (post_status = "attachment")'; + } elseif ($this->is_page) { + $where .= ' AND (post_status = "static")'; + } elseif ($this->is_single) { + $where .= ' AND (post_status != "static")'; + } else { + $where .= ' AND (post_status = "publish"'; + + if (isset($user_ID) && ('' != intval($user_ID))) + $where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')"; + else + $where .= ')'; + } + + if (! $this->is_attachment ) + $where .= ' AND post_status != "attachment"'; + + // Apply filters on where and join prior to paging so that any + // manipulations to them are reflected in the paging by day queries. + $where = apply_filters('posts_where', $where); + $join = apply_filters('posts_join', $join); + + // Paging + if (empty($q['nopaging']) && ! $this->is_single) { + $page = $q['paged']; + if (empty($page)) { + $page = 1; + } + + if (($q['what_to_show'] == 'posts')) { + $pgstrt = ''; + $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', '; + $limits = 'LIMIT '.$pgstrt.$q['posts_per_page']; + } elseif ($q['what_to_show'] == 'days') { + $startrow = $q['posts_per_page'] * (intval($page)-1); + $start_date = $wpdb->get_var("SELECT max(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $startrow,1"); + $endrow = $startrow + $q['posts_per_page'] - 1; + $end_date = $wpdb->get_var("SELECT min(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $endrow,1"); + + if ($page > 1) { + $where .= " AND post_date >= '$end_date' AND post_date <= '$start_date'"; + } else { + $where .= " AND post_date >= '$end_date'"; + } + } + } + + // Apply post-paging filters on where and join. Only plugins that + // manipulate paging queries should use these hooks. + $where = apply_filters('posts_where_paged', $where); + $groupby = " $wpdb->posts.ID "; + $groupby = apply_filters('posts_groupby', $groupby); + $join = apply_filters('posts_join_paged', $join); + $orderby = "post_" . $q['orderby']; + $orderby = apply_filters('posts_orderby', $orderby); + $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1" . $where . " GROUP BY " . $groupby . " ORDER BY " . $orderby . " $limits"; + $this->request = apply_filters('posts_request', $request); + + $this->posts = $wpdb->get_results($this->request); + + // Check post status to determine if post should be displayed. + if ( !empty($this->posts) && $this->is_single ) { + $status = get_post_status($this->posts[0]); + if ( ('publish' != $status) && ('static' != $status) ) { + if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) { + // User must be logged in to view unpublished posts. + $this->posts = array(); + } else { + if ('draft' == $status) { + // User must have edit permissions on the draft to preview. + if (! current_user_can('edit_post', $this->posts[0]->ID)) { + $this->posts = array(); + } else { + $this->is_preview = true; + $this->posts[0]->post_date = current_time('mysql'); + } + } else { + if (! current_user_can('read_post', $this->posts[0]->ID)) + $this->posts = array(); + } + } + } else { + if (mysql2date('U', $this->posts[0]->post_date_gmt) > mysql2date('U', $now)) { //it's future dated + $this->is_preview = true; + if (!current_user_can('edit_post', $this->posts[0]->ID)) { + $this->posts = array ( ); + } + } + } + } + + update_post_caches($this->posts); + + $this->posts = apply_filters('the_posts', $this->posts); + $this->post_count = count($this->posts); + if ($this->post_count > 0) { + $this->post = $this->posts[0]; + } + + // Save any changes made to the query vars. + $this->query_vars = $q; + return $this->posts; + } + + function next_post() { + + $this->current_post++; + + $this->post = $this->posts[$this->current_post]; + return $this->post; + } + + function the_post() { + global $post; + $this->in_the_loop = true; + $post = $this->next_post(); + setup_postdata($post); + + if ( $this->current_post == 0 ) // loop has just started + do_action('loop_start'); + } + + function have_posts() { + if ($this->current_post + 1 < $this->post_count) { + return true; + } elseif ($this->current_post + 1 == $this->post_count) { + do_action('loop_end'); + // Do some cleaning up after the loop + $this->rewind_posts(); + } + + $this->in_the_loop = false; + return false; + } + + function rewind_posts() { + $this->current_post = -1; + if ($this->post_count > 0) { + $this->post = $this->posts[0]; + } + } + + function &query($query) { + $this->parse_query($query); + return $this->get_posts(); + } + + function get_queried_object() { + if (isset($this->queried_object)) { + return $this->queried_object; + } + + $this->queried_object = NULL; + $this->queried_object_id = 0; + + if ($this->is_category) { + $cat = $this->get('cat'); + $category = &get_category($cat); + $this->queried_object = &$category; + $this->queried_object_id = $cat; + } else if ($this->is_single) { + $this->queried_object = $this->post; + $this->queried_object_id = $this->post->ID; + } else if ($this->is_page) { + $this->queried_object = $this->post; + $this->queried_object_id = $this->post->ID; + } else if ($this->is_author) { + $author_id = $this->get('author'); + $author = get_userdata($author_id); + $this->queried_object = $author; + $this->queried_object_id = $author_id; + } + + return $this->queried_object; + } + + function get_queried_object_id() { + $this->get_queried_object(); + + if (isset($this->queried_object_id)) { + return $this->queried_object_id; + } + + return 0; + } + + function WP_Query ($query = '') { + if (! empty($query)) { + $this->query($query); + } + } +} + +class retrospam_mgr { + var $spam_words; + var $comments_list; + var $found_comments; + + function retrospam_mgr() { + global $wpdb; + + $list = explode("\n", get_settings('moderation_keys') ); + $list = array_unique( $list ); + $this->spam_words = $list; + + $this->comment_list = $wpdb->get_results("SELECT comment_ID AS ID, comment_content AS text, comment_approved AS approved, comment_author_url AS url, comment_author_ip AS ip, comment_author_email AS email FROM $wpdb->comments ORDER BY comment_ID ASC"); + } // End of class constructor + + function move_spam( $id_list ) { + global $wpdb; + $cnt = 0; + $id_list = explode( ',', $id_list ); + + foreach ( $id_list as $comment ) { + if ( $wpdb->query("update $wpdb->comments set comment_approved = '0' where comment_ID = '$comment'") ) { + $cnt++; + } + } + echo "

    $cnt comment"; + if ($cnt != 1 ) echo "s"; + echo " moved to the moderation queue.

    \n"; + } // End function move_spam + + function find_spam() { + $in_queue = 0; + + foreach( $this->comment_list as $comment ) { + if( $comment->approved == 1 ) { + foreach( $this->spam_words as $word ) { + $word = trim($word); + if ( empty( $word ) ) + continue; + $fulltext = strtolower($comment->email.' '.$comment->url.' '.$comment->ip.' '.$comment->text); + if( strpos( $fulltext, strtolower($word) ) != FALSE ) { + $this->found_comments[] = $comment->ID; + break; + } + } + } else { + $in_queue++; + } + } + return array( 'found' => $this->found_comments, 'in_queue' => $in_queue ); + } // End function find_spam + + function display_edit_form( $counters ) { + $numfound = count($counters[found]); + $numqueue = $counters[in_queue]; + + $body = '

    ' . sprintf(__('Suspected spam comments: %s'), $numfound) . '

    '; + + if ( count($counters[found]) > 0 ) { + $id_list = implode( ',', $counters[found] ); + $body .= '

    '. __('Move suspect comments to moderation queue »') . '

    '; + + } + $head = '

    ' . __('Check Comments Results:') . '

    '; + + $foot .= '

    ' . __('« Return to Discussion Options page.') . '

    '; + + return $head . $body . $foot; + } // End function display_edit_form + +} + +class WP_Rewrite { + var $permalink_structure; + var $category_base; + var $category_structure; + var $author_base = 'author'; + var $author_structure; + var $date_structure; + var $page_structure; + var $search_base = 'search'; + var $search_structure; + var $comments_base = 'comments'; + var $feed_base = 'feed'; + var $comments_feed_structure; + var $feed_structure; + var $front; + var $root = ''; + var $index = 'index.php'; + var $matches = ''; + var $rules; + var $use_verbose_rules = false; + var $rewritecode = + array( + '%year%', + '%monthnum%', + '%day%', + '%hour%', + '%minute%', + '%second%', + '%postname%', + '%post_id%', + '%category%', + '%author%', + '%pagename%', + '%search%' + ); + + var $rewritereplace = + array( + '([0-9]{4})', + '([0-9]{1,2})', + '([0-9]{1,2})', + '([0-9]{1,2})', + '([0-9]{1,2})', + '([0-9]{1,2})', + '([^/]+)', + '([0-9]+)', + '(.+?)', + '([^/]+)', + '([^/]+)', + '(.+)' + ); + + var $queryreplace = + array ( + 'year=', + 'monthnum=', + 'day=', + 'hour=', + 'minute=', + 'second=', + 'name=', + 'p=', + 'category_name=', + 'author_name=', + 'pagename=', + 's=' + ); + + var $feeds = array ('feed', 'rdf', 'rss', 'rss2', 'atom'); + + function using_permalinks() { + if (empty($this->permalink_structure)) + return false; + else + return true; + } + + function using_index_permalinks() { + if (empty($this->permalink_structure)) { + return false; + } + + // If the index is not in the permalink, we're using mod_rewrite. + if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) { + return true; + } + + return false; + } + + function using_mod_rewrite_permalinks() { + if ( $this->using_permalinks() && ! $this->using_index_permalinks()) + return true; + else + return false; + } + + function preg_index($number) { + $match_prefix = '$'; + $match_suffix = ''; + + if (! empty($this->matches)) { + $match_prefix = '$' . $this->matches . '['; + $match_suffix = ']'; + } + + return "$match_prefix$number$match_suffix"; + } + + function page_rewrite_rules() { + $uris = get_settings('page_uris'); + $attachment_uris = get_settings('page_attachment_uris'); + + $rewrite_rules = array(); + $page_structure = $this->get_page_permastruct(); + if( is_array( $attachment_uris ) ) { + foreach ($attachment_uris as $uri => $pagename) { + $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment='); + $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure)); + } + } + if( is_array( $uris ) ) { + foreach ($uris as $uri => $pagename) { + $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename='); + $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure)); + } + } + + return $rewrite_rules; + } + + function get_date_permastruct() { + if (isset($this->date_structure)) { + return $this->date_structure; + } + + if (empty($this->permalink_structure)) { + $this->date_structure = ''; + return false; + } + + // The date permalink must have year, month, and day separated by slashes. + $endians = array('%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%'); + + $this->date_structure = ''; + $date_endian = ''; + + foreach ($endians as $endian) { + if (false !== strpos($this->permalink_structure, $endian)) { + $date_endian= $endian; + break; + } + } + + if ( empty($date_endian) ) + $date_endian = '%year%/%monthnum%/%day%'; + + // Do not allow the date tags and %post_id% to overlap in the permalink + // structure. If they do, move the date tags to $front/date/. + $front = $this->front; + preg_match_all('/%.+?%/', $this->permalink_structure, $tokens); + $tok_index = 1; + foreach ($tokens[0] as $token) { + if ( ($token == '%post_id%') && ($tok_index <= 3) ) { + $front = $front . 'date/'; + break; + } + } + + $this->date_structure = $front . $date_endian; + + return $this->date_structure; + } + + function get_year_permastruct() { + $structure = $this->get_date_permastruct($this->permalink_structure); + + if (empty($structure)) { + return false; + } + + $structure = str_replace('%monthnum%', '', $structure); + $structure = str_replace('%day%', '', $structure); + + $structure = preg_replace('#/+#', '/', $structure); + + return $structure; + } + + function get_month_permastruct() { + $structure = $this->get_date_permastruct($this->permalink_structure); + + if (empty($structure)) { + return false; + } + + $structure = str_replace('%day%', '', $structure); + + $structure = preg_replace('#/+#', '/', $structure); + + return $structure; + } + + function get_day_permastruct() { + return $this->get_date_permastruct($this->permalink_structure); + } + + function get_category_permastruct() { + if (isset($this->category_structure)) { + return $this->category_structure; + } + + if (empty($this->permalink_structure)) { + $this->category_structure = ''; + return false; + } + + if (empty($this->category_base)) + $this->category_structure = $this->front . 'category/'; + else + $this->category_structure = $this->category_base . '/'; + + $this->category_structure .= '%category%'; + + return $this->category_structure; + } + + function get_author_permastruct() { + if (isset($this->author_structure)) { + return $this->author_structure; + } + + if (empty($this->permalink_structure)) { + $this->author_structure = ''; + return false; + } + + $this->author_structure = $this->front . $this->author_base . '/%author%'; + + return $this->author_structure; + } + + function get_search_permastruct() { + if (isset($this->search_structure)) { + return $this->search_structure; + } + + if (empty($this->permalink_structure)) { + $this->search_structure = ''; + return false; + } + + $this->search_structure = $this->root . $this->search_base . '/%search%'; + + return $this->search_structure; + } + + function get_page_permastruct() { + if (isset($this->page_structure)) { + return $this->page_structure; + } + + if (empty($this->permalink_structure)) { + $this->page_structure = ''; + return false; + } + + $this->page_structure = $this->root . '%pagename%'; + + return $this->page_structure; + } + + function get_feed_permastruct() { + if (isset($this->feed_structure)) { + return $this->feed_structure; + } + + if (empty($this->permalink_structure)) { + $this->feed_structure = ''; + return false; + } + + $this->feed_structure = $this->root . $this->feed_base . '/%feed%'; + + return $this->feed_structure; + } + + function get_comment_feed_permastruct() { + if (isset($this->comment_feed_structure)) { + return $this->comment_feed_structure; + } + + if (empty($this->permalink_structure)) { + $this->comment_feed_structure = ''; + return false; + } + + $this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%'; + + return $this->comment_feed_structure; + } + + function add_rewrite_tag($tag, $pattern, $query) { + // If the tag already exists, replace the existing pattern and query for + // that tag, otherwise add the new tag, pattern, and query to the end of + // the arrays. + $position = array_search($tag, $this->rewritecode); + if (FALSE !== $position && NULL !== $position) { + $this->rewritereplace[$position] = $pattern; + $this->queryreplace[$position] = $query; + } else { + $this->rewritecode[] = $tag; + $this->rewritereplace[] = $pattern; + $this->queryreplace[] = $query; + } + } + + function generate_rewrite_rules($permalink_structure, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true) { + $feedregex2 = ''; + foreach ($this->feeds as $feed_name) { + $feedregex2 .= $feed_name . '|'; + } + $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$'; + $feedregex = $this->feed_base . '/' . $feedregex2; + + $trackbackregex = 'trackback/?$'; + $pageregex = 'page/?([0-9]{1,})/?$'; + + $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); + preg_match_all('/%.+?%/', $permalink_structure, $tokens); + + $num_tokens = count($tokens[0]); + + $index = $this->index; + $feedindex = $index; + $trackbackindex = $index; + for ($i = 0; $i < $num_tokens; ++$i) { + if (0 < $i) { + $queries[$i] = $queries[$i - 1] . '&'; + } + + $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1); + $queries[$i] .= $query_token; + } + + $structure = $permalink_structure; + if ($front != '/') { + $structure = str_replace($front, '', $structure); + } + $structure = trim($structure, '/'); + if ($walk_dirs) { + $dirs = explode('/', $structure); + } else { + $dirs[] = $structure; + } + $num_dirs = count($dirs); + + $front = preg_replace('|^/+|', '', $front); + + $post_rewrite = array(); + $struct = $front; + for ($j = 0; $j < $num_dirs; ++$j) { + $struct .= $dirs[$j] . '/'; + $struct = ltrim($struct, '/'); + $match = str_replace($this->rewritecode, $this->rewritereplace, $struct); + $num_toks = preg_match_all('/%.+?%/', $struct, $toks); + $query = $queries[$num_toks - 1]; + + $pagematch = $match . $pageregex; + $pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1); + + $feedmatch = $match . $feedregex; + $feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1); + + $feedmatch2 = $match . $feedregex2; + $feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1); + + if ($forcomments) { + $feedquery .= '&withcomments=1'; + $feedquery2 .= '&withcomments=1'; + } + + $rewrite = array(); + if ($feed) + $rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2); + if ($paged) + $rewrite = array_merge($rewrite, array($pagematch => $pagequery)); + + if ($num_toks) { + $post = false; + $page = false; + if (strstr($struct, '%postname%') || strstr($struct, '%post_id%') + || strstr($struct, '%pagename%') + || (strstr($struct, '%year%') && strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) { + $post = true; + if ( strstr($struct, '%pagename%') ) + $page = true; + $trackbackmatch = $match . $trackbackregex; + $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; + $match = rtrim($match, '/'); + $submatchbase = str_replace(array('(',')'),'',$match); + $sub1 = $submatchbase . '/([^/]+)/'; + $sub1tb = $sub1 . $trackbackregex; + $sub1feed = $sub1 . $feedregex; + $sub1feed2 = $sub1 . $feedregex2; + $sub1 .= '?$'; + $sub2 = $submatchbase . '/attachment/([^/]+)/'; + $sub2tb = $sub2 . $trackbackregex; + $sub2feed = $sub2 . $feedregex; + $sub2feed2 = $sub2 . $feedregex2; + $sub2 .= '?$'; + $subquery = $index . '?attachment=' . $this->preg_index(1); + $subtbquery = $subquery . '&tb=1'; + $subfeedquery = $subquery . '&feed=' . $this->preg_index(2); + $match = $match . '(/[0-9]+)?/?$'; + $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1); + } else { + $match .= '?$'; + $query = $index . '?' . $query; + } + + $rewrite = array_merge($rewrite, array($match => $query)); + + if ($post) { + $rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite); + if ( ! $page ) + $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery)); + $rewrite = array_merge($rewrite, array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery)); + } + } + $post_rewrite = array_merge($rewrite, $post_rewrite); + } + return $post_rewrite; + } + + function generate_rewrite_rule($permalink_structure, $walk_dirs = false) { + return $this->generate_rewrite_rules($permalink_structure, false, false, false, $walk_dirs); + } + + /* rewrite_rules + * Construct rewrite matches and queries from permalink structure. + * Returns an associate array of matches and queries. + */ + function rewrite_rules() { + $rewrite = array(); + + if (empty($this->permalink_structure)) { + return $rewrite; + } + + // Post + $post_rewrite = $this->generate_rewrite_rules($this->permalink_structure); + $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite); + + // Date + $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct()); + $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite); + + // Root + $root_rewrite = $this->generate_rewrite_rules($this->root . '/'); + $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite); + + // Comments + $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, true, true, true, false); + $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite); + + // Search + $search_structure = $this->get_search_permastruct(); + $search_rewrite = $this->generate_rewrite_rules($search_structure); + $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite); + + // Categories + $category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct()); + $category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite); + + // Authors + $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct()); + $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite); + + // Pages + $page_rewrite = $this->page_rewrite_rules(); + $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite); + + // Put them together. + $this->rules = array_merge($page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite); + + do_action('generate_rewrite_rules', array(&$this)); + $this->rules = apply_filters('rewrite_rules_array', $this->rules); + + return $this->rules; + } + + function wp_rewrite_rules() { + $this->rules = get_option('rewrite_rules'); + if ( empty($this->rules) ) { + $this->matches = 'matches'; + $this->rewrite_rules(); + update_option('rewrite_rules', $this->rules); + } + + return $this->rules; + } + + function mod_rewrite_rules() { + if ( ! $this->using_permalinks()) { + return ''; + } + + $site_root = parse_url(get_settings('siteurl')); + $site_root = trailingslashit($site_root['path']); + + $home_root = parse_url(get_settings('home')); + $home_root = trailingslashit($home_root['path']); + + $rules = "\n"; + $rules .= "RewriteEngine On\n"; + $rules .= "RewriteBase $home_root\n"; + + if ($this->use_verbose_rules) { + $this->matches = ''; + $rewrite = $this->rewrite_rules(); + $num_rules = count($rewrite); + $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" . + "RewriteCond %{REQUEST_FILENAME} -d\n" . + "RewriteRule ^.*$ - [S=$num_rules]\n"; + + foreach ($rewrite as $match => $query) { + // Apache 1.3 does not support the reluctant (non-greedy) modifier. + $match = str_replace('.+?', '.+', $match); + + // If the match is unanchored and greedy, prepend rewrite conditions + // to avoid infinite redirects and eclipsing of real files. + if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) { + //nada. + } + + if (strstr($query, $this->index)) { + $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; + } else { + $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n"; + } + } + } else { + $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" . + "RewriteCond %{REQUEST_FILENAME} !-d\n" . + "RewriteRule . {$home_root}{$this->index} [L]\n"; + } + + $rules .= "\n"; + + $rules = apply_filters('mod_rewrite_rules', $rules); + $rules = apply_filters('rewrite_rules', $rules); // Deprecated + + return $rules; + } + + function flush_rules() { + generate_page_rewrite_rules(); + delete_option('rewrite_rules'); + $this->wp_rewrite_rules(); + if ( function_exists('save_mod_rewrite_rules') ) + save_mod_rewrite_rules(); + } + + function init() { + $this->permalink_structure = get_settings('permalink_structure'); + $this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%')); + $this->root = ''; + if ($this->using_index_permalinks()) { + $this->root = $this->index . '/'; + } + $this->category_base = get_settings('category_base'); + unset($this->category_structure); + unset($this->author_structure); + unset($this->date_structure); + unset($this->page_structure); + unset($this->search_structure); + unset($this->feed_structure); + unset($this->comment_feed_structure); + } + + function set_permalink_structure($permalink_structure) { + if ($permalink_structure != $this->permalink_structure) { + update_option('permalink_structure', $permalink_structure); + $this->init(); + } + } + + function set_category_base($category_base) { + if ($category_base != $this->category_base) { + update_option('category_base', $category_base); + $this->init(); + } + } + + function WP_Rewrite() { + $this->init(); + } +} + +class WP { + var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview'); + + var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'show_post_type'); + + var $query_vars; + var $query_string; + var $request; + var $matched_rule; + var $matched_query; + var $did_permalink = false; + + function parse_request($extra_query_vars = '') { + global $wp_rewrite; + + $this->query_vars = array(); + + if (! empty($extra_query_vars)) + parse_str($extra_query_vars, $extra_query_vars); + else + $extra_query_vars = array(); + + // Process PATH_INFO, REQUEST_URI, and 404 for permalinks. + + // Fetch the rewrite rules. + $rewrite = $wp_rewrite->wp_rewrite_rules(); + + if (! empty($rewrite)) { + // If we match a rewrite rule, this will be cleared. + $error = '404'; + $this->did_permalink = true; + + $pathinfo = $_SERVER['PATH_INFO']; + $pathinfo_array = explode('?', $pathinfo); + $pathinfo = $pathinfo_array[0]; + $req_uri = $_SERVER['REQUEST_URI']; + $req_uri_array = explode('?', $req_uri); + $req_uri = $req_uri_array[0]; + $self = $_SERVER['PHP_SELF']; + $home_path = parse_url(get_settings('home')); + $home_path = $home_path['path']; + $home_path = trim($home_path, '/'); + + // Trim path info from the end and the leading home path from the + // front. For path info requests, this leaves us with the requesting + // filename, if any. For 404 requests, this leaves us with the + // requested permalink. + $req_uri = str_replace($pathinfo, '', $req_uri); + $req_uri = trim($req_uri, '/'); + $req_uri = preg_replace("|^$home_path|", '', $req_uri); + $req_uri = trim($req_uri, '/'); + $pathinfo = trim($pathinfo, '/'); + $pathinfo = preg_replace("|^$home_path|", '', $pathinfo); + $pathinfo = trim($pathinfo, '/'); + $self = trim($self, '/'); + $self = preg_replace("|^$home_path|", '', $self); + $self = str_replace($home_path, '', $self); + $self = trim($self, '/'); + + // The requested permalink is in $pathinfo for path info requests and + // $req_uri for other requests. + if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) { + $request = $pathinfo; + } else { + // If the request uri is the index, blank it out so that we don't try to match it against a rule. + if ( $req_uri == $wp_rewrite->index ) + $req_uri = ''; + $request = $req_uri; + } + + $this->request = $request; + + // Look for matches. + $request_match = $request; + foreach ($rewrite as $match => $query) { + // If the requesting file is the anchor of the match, prepend it + // to the path info. + if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) { + $request_match = $req_uri . '/' . $request; + } + + if (preg_match("!^$match!", $request_match, $matches) || + preg_match("!^$match!", urldecode($request_match), $matches)) { + // Got a match. + $this->matched_rule = $match; + + // Trim the query of everything up to the '?'. + $query = preg_replace("!^.+\?!", '', $query); + + // Substitute the substring matches into the query. + eval("\$query = \"$query\";"); + $this->matched_query = $query; + + // Parse the query. + parse_str($query, $query_vars); + + // If we're processing a 404 request, clear the error var + // since we found something. + if (isset($_GET['error'])) + unset($_GET['error']); + + if (isset($error)) + unset($error); + + break; + } + } + + // If req_uri is empty or if it is a request for ourself, unset error. + if ( empty($request) || $req_uri == $self || strstr($_SERVER['PHP_SELF'], 'wp-admin/') ) { + if (isset($_GET['error'])) + unset($_GET['error']); + + if (isset($error)) + unset($error); + + if ( isset($query_vars) && strstr($_SERVER['PHP_SELF'], 'wp-admin/') ) + unset($query_vars); + + $this->did_permalink = false; + } + } + + $this->public_query_vars = apply_filters('query_vars', $this->public_query_vars); + + for ($i=0; $ipublic_query_vars); $i += 1) { + $wpvar = $this->public_query_vars[$i]; + if (isset($extra_query_vars[$wpvar])) + $this->query_vars[$wpvar] = $extra_query_vars[$wpvar]; + elseif (isset($GLOBALS[$wpvar])) + $this->query_vars[$wpvar] = $GLOBALS[$wpvar]; + elseif (!empty($_POST[$wpvar])) + $this->query_vars[$wpvar] = $_POST[$wpvar]; + elseif (!empty($_GET[$wpvar])) + $this->query_vars[$wpvar] = $_GET[$wpvar]; + elseif (!empty($query_vars[$wpvar])) + $this->query_vars[$wpvar] = $query_vars[$wpvar]; + else + $this->query_vars[$wpvar] = ''; + } + + if ( isset($error) ) + $this->query_vars['error'] = $error; + } + + function send_headers() { + global $current_user; + @header('X-Pingback: '. get_bloginfo('pingback_url')); + if ( is_user_logged_in() ) + nocache_headers(); + if ( !empty($this->query_vars['error']) && '404' == $this->query_vars['error'] ) { + status_header( 404 ); + } else if ( empty($this->query_vars['feed']) ) { + @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); + } else { + // We're showing a feed, so WP is indeed the only thing that last changed + if ( $this->query_vars['withcomments'] ) + $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; + else + $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; + $wp_etag = '"' . md5($wp_last_modified) . '"'; + @header("Last-Modified: $wp_last_modified"); + @header("ETag: $wp_etag"); + + // Support for Conditional GET + if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); + else $client_etag = false; + + $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']); + // If string is empty, return 0. If not, attempt to parse into a timestamp + $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0; + + // Make a timestamp for our most recent modification... + $wp_modified_timestamp = strtotime($wp_last_modified); + + if ( ($client_last_modified && $client_etag) ? + (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : + (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) { + status_header( 304 ); + exit; + } + } + } + + function build_query_string() { + $this->query_string = ''; + + foreach ($this->public_query_vars as $wpvar) { + if (isset($this->query_vars[$wpvar]) && '' != $this->query_vars[$wpvar]) { + $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; + $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]); + } + } + + foreach ($this->private_query_vars as $wpvar) { + if (isset($GLOBALS[$wpvar]) && '' != $GLOBALS[$wpvar]) { + $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; + $this->query_string .= $wpvar . '=' . rawurlencode($GLOBALS[$wpvar]); + } + } + + $this->query_string = apply_filters('query_string', $this->query_string); + } + + function register_globals() { + global $wp_query; + // Extract updated query vars back into global namespace. + foreach ($wp_query->query_vars as $key => $value) { + $GLOBALS[$key] = $value; + } + + $GLOBALS['query_string'] = & $this->query_string; + $GLOBALS['posts'] = & $wp_query->posts; + $GLOBALS['post'] = & $wp_query->post; + $GLOBALS['request'] = & $wp_query->request; + + if ( is_single() || is_page() ) { + $GLOBALS['more'] = 1; + $GLOBALS['single'] = 1; + } + } + + function init() { + get_currentuserinfo(); + } + + function query_posts() { + $this->build_query_string(); + query_posts($this->query_string); + } + + function handle_404() { + global $wp_query; + // Issue a 404 if a permalink request doesn't match any posts. Don't + // issue a 404 if one was already issued, if the request was a search, + // or if the request was a regular query string request rather than a + // permalink request. + if ( (0 == count($wp_query->posts)) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) { + $wp_query->set_404(); + status_header( 404 ); + } elseif( is_404() != true ) { + status_header( 200 ); + } + } + + function main($query_args = '') { + $this->init(); + $this->parse_request($query_args); + $this->send_headers(); + $this->query_posts(); + $this->handle_404(); + $this->register_globals(); + } + + function WP() { + // Empty. + } +} + +?> diff --git a/wp-includes/comment-functions.php b/wp-includes/comment-functions.php new file mode 100644 index 00000000..eed5a611 --- /dev/null +++ b/wp-includes/comment-functions.php @@ -0,0 +1,906 @@ +get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date"); + } else { + $author_db = $wpdb->escape($comment_author); + $email_db = $wpdb->escape($comment_author_email); + $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date"); + } + + get_currentuserinfo(); + + define('COMMENTS_TEMPLATE', true); + $include = apply_filters('comments_template', TEMPLATEPATH . $file ); + if ( file_exists( $include ) ) + require( $include ); + else + require( ABSPATH . 'wp-content/themes/default/comments.php'); + + endif; +} + +function wp_new_comment( $commentdata ) { + $commentdata = apply_filters('preprocess_comment', $commentdata); + + $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; + $commentdata['user_ID'] = (int) $commentdata['user_ID']; + + $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR']; + $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT']; + + $commentdata['comment_date'] = current_time('mysql'); + $commentdata['comment_date_gmt'] = current_time('mysql', 1); + + + $commentdata = wp_filter_comment($commentdata); + + $commentdata['comment_approved'] = wp_allow_comment($commentdata); + + $comment_ID = wp_insert_comment($commentdata); + + do_action('comment_post', $comment_ID, $commentdata['comment_approved']); + + if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching + if ( '0' == $commentdata['comment_approved'] ) + wp_notify_moderator($comment_ID); + + $post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment + + if ( get_settings('comments_notify') && $commentdata['comment_approved'] && $post->post_author != $commentdata['user_ID'] ) + wp_notify_postauthor($comment_ID, $commentdata['comment_type']); + } + + return $comment_ID; +} + +function wp_insert_comment($commentdata) { + global $wpdb; + extract($commentdata); + + if ( ! isset($comment_author_IP) ) + $comment_author_IP = $_SERVER['REMOTE_ADDR']; + if ( ! isset($comment_date) ) + $comment_date = current_time('mysql'); + if ( ! isset($comment_date_gmt) ) + $comment_date_gmt = gmdate('Y-m-d H:i:s', strtotime($comment_date) ); + if ( ! isset($comment_parent) ) + $comment_parent = 0; + if ( ! isset($comment_approved) ) + $comment_approved = 1; + + $result = $wpdb->query("INSERT INTO $wpdb->comments + (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id) + VALUES + ('$comment_post_ID', '$comment_author', '$comment_author_email', '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content', '$comment_approved', '$comment_agent', '$comment_type', '$comment_parent', '$user_id') + "); + + $id = $wpdb->insert_id; + + if ( $comment_approved == 1) { + $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'"); + $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$comment_post_ID'" ); + } + return $id; +} + +function wp_filter_comment($commentdata) { + $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']); + $commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', $commentdata['comment_agent']); + $commentdata['comment_author'] = apply_filters('pre_comment_author_name', $commentdata['comment_author']); + $commentdata['comment_content'] = apply_filters('pre_comment_content', $commentdata['comment_content']); + $commentdata['comment_author_IP'] = apply_filters('pre_comment_user_ip', $commentdata['comment_author_IP']); + $commentdata['comment_author_url'] = apply_filters('pre_comment_author_url', $commentdata['comment_author_url']); + $commentdata['comment_author_email'] = apply_filters('pre_comment_author_email', $commentdata['comment_author_email']); + $commentdata['filtered'] = true; + return $commentdata; +} + +function wp_allow_comment($commentdata) { + global $wpdb; + extract($commentdata); + + $comment_user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($comment_author_IP) ); + + // Simple duplicate check + $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$comment_author' "; + if ( $comment_author_email ) + $dupe .= "OR comment_author_email = '$comment_author_email' "; + $dupe .= ") AND comment_content = '$comment_content' LIMIT 1"; + if ( $wpdb->get_var($dupe) ) + die( __('Duplicate comment detected; it looks as though you\'ve already said that!') ); + + // Simple flood-protection + if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$comment_author_IP' OR comment_author_email = '$comment_author_email' ORDER BY comment_date DESC LIMIT 1") ) { + $time_lastcomment = mysql2date('U', $lasttime); + $time_newcomment = mysql2date('U', $comment_date_gmt); + if ( ($time_newcomment - $time_lastcomment) < 15 ) { + do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); + die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') ); + } + } + + if ( $user_id ) { + $userdata = get_userdata($user_id); + $user = new WP_User($user_id); + $post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1"); + } + + // The author and the admins get respect. + if ( $userdata && ( $user_id == $post_author || $user->has_cap('level_9') ) ) { + $approved = 1; + } + + // Everyone else's comments will be checked. + else { + if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) ) + $approved = 1; + else + $approved = 0; + if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) ) + $approved = 'spam'; + } + + $approved = apply_filters('pre_comment_approved', $approved); + return $approved; +} + + +function wp_update_comment($commentarr) { + global $wpdb; + + // First, get all of the original fields + $comment = get_comment($commentarr['comment_ID'], ARRAY_A); + + // Escape data pulled from DB. + foreach ($comment as $key => $value) + $comment[$key] = $wpdb->escape($value); + + // Merge old and new fields with new fields overwriting old ones. + $commentarr = array_merge($comment, $commentarr); + + // Now extract the merged array. + extract($commentarr); + + $comment_content = apply_filters('comment_save_pre', $comment_content); + + $result = $wpdb->query( + "UPDATE $wpdb->comments SET + comment_content = '$comment_content', + comment_author = '$comment_author', + comment_author_email = '$comment_author_email', + comment_approved = '$comment_approved', + comment_author_url = '$comment_author_url', + comment_date = '$comment_date' + WHERE comment_ID = $comment_ID" ); + + $rval = $wpdb->rows_affected; + + $c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" ); + if( is_object( $c ) ) + $wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" ); + + do_action('edit_comment', $comment_ID); + + return $rval; +} + +function wp_delete_comment($comment_id) { + global $wpdb; + do_action('delete_comment', $comment_id); + + $comment = get_comment($comment_id); + + if ( ! $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1") ) + return false; + + $post_id = $comment->comment_post_ID; + if ( $post_id && $comment->comment_approved == 1 ) + $wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count - 1 WHERE ID = '$post_id'" ); + + do_action('wp_set_comment_status', $comment_id, 'delete'); + return true; +} + +function clean_url( $url ) { + if ('' == $url) return $url; + $url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $url); + $url = str_replace(';//', '://', $url); + $url = (!strstr($url, '://')) ? 'http://'.$url : $url; + $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); + return $url; +} + +function get_comments_number( $post_id = 0 ) { + global $wpdb, $comment_count_cache, $id; + $post_id = (int) $post_id; + + if ( !$post_id ) + $post_id = $id; + + if ( !isset($comment_count_cache[$post_id]) ) + $comment_count_cache[$id] = $wpdb->get_var("SELECT comment_count FROM $wpdb->posts WHERE ID = '$post_id'"); + + return apply_filters('get_comments_number', $comment_count_cache[$post_id]); +} + +function comments_number( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $number = '' ) { + global $id, $comment; + $number = get_comments_number( $id ); + if ($number == 0) { + $blah = $zero; + } elseif ($number == 1) { + $blah = $one; + } elseif ($number > 1) { + $blah = str_replace('%', $number, $more); + } + echo apply_filters('comments_number', $blah); +} + +function get_comments_link() { + return get_permalink() . '#comments'; +} + +function get_comment_link() { + global $comment; + return get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID; +} + +function comments_link( $file = '', $echo = true ) { + echo get_comments_link(); +} + +function comments_popup_script($width=400, $height=400, $file='') { + global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript; + + if (empty ($file)) { + $wpcommentspopupfile = ''; // Use the index. + } else { + $wpcommentspopupfile = $file; + } + + $wpcommentsjavascript = 1; + $javascript = "\n"; + echo $javascript; +} + +function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { + global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb; + global $comment_count_cache; + + if (! is_single() && ! is_page()) { + if ( !isset($comment_count_cache[$id]) ) + $comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';"); + + $number = $comment_count_cache[$id]; + + if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) { + echo $none; + return; + } else { + if (!empty($post->post_password)) { // if there's a password + if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie + echo(__('Enter your password to view comments')); + return; + } + } + echo ''; + comments_number($zero, $one, $more, $number); + echo ''; + } + } +} + +function get_comment_ID() { + global $comment; + return apply_filters('get_comment_ID', $comment->comment_ID); +} + +function comment_ID() { + echo get_comment_ID(); +} + +function get_comment_author() { + global $comment; + if ( empty($comment->comment_author) ) + $author = __('Anonymous'); + else + $author = $comment->comment_author; + return apply_filters('get_comment_author', $author); +} + +function comment_author() { + $author = apply_filters('comment_author', get_comment_author() ); + echo $author; +} + +function get_comment_author_email() { + global $comment; + return apply_filters('get_comment_author_email', $comment->comment_author_email); +} + +function comment_author_email() { + echo apply_filters('author_email', get_comment_author_email() ); +} + +function get_comment_author_link() { + global $comment; + $url = get_comment_author_url(); + $author = get_comment_author(); + + if ( empty( $url ) || 'http://' == $url ) + $return = $author; + else + $return = "$author"; + return apply_filters('get_comment_author_link', $return); +} + +function comment_author_link() { + echo get_comment_author_link(); +} + +function get_comment_type() { + global $comment; + + if ( '' == $comment->comment_type ) + $comment->comment_type = 'comment'; + + return apply_filters('get_comment_type', $comment->comment_type); +} + +function comment_type($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') { + $type = get_comment_type(); + switch( $type ) { + case 'trackback' : + echo $trackbacktxt; + break; + case 'pingback' : + echo $pingbacktxt; + break; + default : + echo $commenttxt; + } +} + +function get_comment_author_url() { + global $comment; + return apply_filters('get_comment_author_url', $comment->comment_author_url); +} + +function comment_author_url() { + echo apply_filters('comment_url', get_comment_author_url()); +} + +function comment_author_email_link($linktext='', $before='', $after='') { + global $comment; + $email = apply_filters('comment_email', $comment->comment_author_email); + if ((!empty($email)) && ($email != '@')) { + $display = ($linktext != '') ? $linktext : $email; + echo $before; + echo "$display"; + echo $after; + } +} + +function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) { + global $comment; + $url = get_comment_author_url(); + $display = ($linktext != '') ? $linktext : $url; + $return = "$before$display$after"; + return apply_filters('get_comment_author_url_link', $return); +} + +function comment_author_url_link( $linktext = '', $before = '', $after = '' ) { + echo get_comment_author_url_link( $linktext, $before, $after ); +} + +function get_comment_author_IP() { + global $comment; + return apply_filters('get_comment_author_IP', $comment->comment_author_IP); +} + +function comment_author_IP() { + echo get_comment_author_IP(); +} + +function get_comment_text() { + global $comment; + return apply_filters('get_comment_text', $comment->comment_content); +} + +function comment_text() { + echo apply_filters('comment_text', get_comment_text() ); +} + +function get_comment_excerpt() { + global $comment; + $comment_text = strip_tags($comment->comment_content); + $blah = explode(' ', $comment_text); + if (count($blah) > 20) { + $k = 20; + $use_dotdotdot = 1; + } else { + $k = count($blah); + $use_dotdotdot = 0; + } + $excerpt = ''; + for ($i=0; $i<$k; $i++) { + $excerpt .= $blah[$i] . ' '; + } + $excerpt .= ($use_dotdotdot) ? '...' : ''; + return apply_filters('get_comment_excerpt', $excerpt); +} + +function comment_excerpt() { + echo apply_filters('comment_excerpt', get_comment_excerpt() ); +} + +function get_comment_date( $d = '' ) { + global $comment; + if ( '' == $d ) + $date = mysql2date( get_settings('date_format'), $comment->comment_date); + else + $date = mysql2date($d, $comment->comment_date); + return apply_filters('get_comment_date', $date); +} + +function comment_date( $d = '' ) { + echo get_comment_date( $d ); +} + +function get_comment_time( $d = '', $gmt = false ) { + global $comment; + $comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date; + if ( '' == $d ) + $date = mysql2date(get_settings('time_format'), $comment_date); + else + $date = mysql2date($d, $comment_date); + return apply_filters('get_comment_time', $date); +} + +function comment_time( $d = '' ) { + echo get_comment_time($d); +} + +function get_trackback_url() { + global $id; + $tb_url = get_settings('siteurl') . '/wp-trackback.php?p=' . $id; + + if ( '' != get_settings('permalink_structure') ) + $tb_url = trailingslashit(get_permalink()) . 'trackback/'; + + return $tb_url; +} +function trackback_url( $display = true ) { + if ( $display) + echo get_trackback_url(); + else + return get_trackback_url(); +} + +function trackback_rdf($timezone = 0) { + global $id; + if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) { + echo ' + \n"; + echo ''; + } +} + +function comments_open() { + global $post; + if ( 'open' == $post->comment_status ) + return true; + else + return false; +} + +function pings_open() { + global $post; + if ( 'open' == $post->ping_status ) + return true; + else + return false; +} + +// Non-template functions + +function get_lastcommentmodified($timezone = 'server') { + global $cache_lastcommentmodified, $pagenow, $wpdb; + $add_seconds_blog = get_settings('gmt_offset') * 3600; + $add_seconds_server = date('Z'); + $now = current_time('mysql', 1); + if ( !isset($cache_lastcommentmodified[$timezone]) ) { + switch(strtolower($timezone)) { + case 'gmt': + $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); + break; + case 'blog': + $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); + break; + case 'server': + $lastcommentmodified = $wpdb->get_var("SELECT DATE_ADD(comment_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); + break; + } + $cache_lastcommentmodified[$timezone] = $lastcommentmodified; + } else { + $lastcommentmodified = $cache_lastcommentmodified[$timezone]; + } + return $lastcommentmodified; +} + +function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { // less flexible, but saves DB queries + global $postc, $id, $commentdata, $wpdb; + if ($no_cache) { + $query = "SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_ID'"; + if (false == $include_unapproved) { + $query .= " AND comment_approved = '1'"; + } + $myrow = $wpdb->get_row($query, ARRAY_A); + } else { + $myrow['comment_ID'] = $postc->comment_ID; + $myrow['comment_post_ID'] = $postc->comment_post_ID; + $myrow['comment_author'] = $postc->comment_author; + $myrow['comment_author_email'] = $postc->comment_author_email; + $myrow['comment_author_url'] = $postc->comment_author_url; + $myrow['comment_author_IP'] = $postc->comment_author_IP; + $myrow['comment_date'] = $postc->comment_date; + $myrow['comment_content'] = $postc->comment_content; + $myrow['comment_karma'] = $postc->comment_karma; + $myrow['comment_approved'] = $postc->comment_approved; + $myrow['comment_type'] = $postc->comment_type; + } + return $myrow; +} + +function pingback($content, $post_ID) { + global $wp_version, $wpdb; + include_once (ABSPATH . WPINC . '/class-IXR.php'); + + // original code by Mort (http://mort.mine.nu:8080) + $log = debug_fopen(ABSPATH . '/pingback.log', 'a'); + $post_links = array(); + debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n"); + + $pung = get_pung($post_ID); + + // Variables + $ltrs = '\w'; + $gunk = '/#~:.?+=&%@!\-'; + $punc = '.:?\-'; + $any = $ltrs . $gunk . $punc; + + // Step 1 + // Parsing the post, external links (if any) are stored in the $post_links array + // This regexp comes straight from phpfreaks.com + // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php + preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp); + + // Debug + debug_fwrite($log, 'Post contents:'); + debug_fwrite($log, $content."\n"); + + // Step 2. + // Walking thru the links array + // first we get rid of links pointing to sites, not to specific files + // Example: + // http://dummy-weblog.org + // http://dummy-weblog.org/ + // http://dummy-weblog.org/post.php + // We don't wanna ping first and second types, even if they have a valid + + foreach($post_links_temp[0] as $link_test) : + if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself + && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. + $test = parse_url($link_test); + if (isset($test['query'])) + $post_links[] = $link_test; + elseif(($test['path'] != '/') && ($test['path'] != '')) + $post_links[] = $link_test; + endif; + endforeach; + + do_action('pre_ping', array(&$post_links, &$pung)); + + foreach ($post_links as $pagelinkedto){ + debug_fwrite($log, "Processing -- $pagelinkedto\n"); + $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048); + + if ($pingback_server_url) { + @ set_time_limit( 60 ); + // Now, the RPC call + debug_fwrite($log, "Page Linked To: $pagelinkedto \n"); + debug_fwrite($log, 'Page Linked From: '); + $pagelinkedfrom = get_permalink($post_ID); + debug_fwrite($log, $pagelinkedfrom."\n"); + + // using a timeout of 3 seconds should be enough to cover slow servers + $client = new IXR_Client($pingback_server_url); + $client->timeout = 3; + $client->useragent .= ' -- WordPress/' . $wp_version; + + // when set to true, this outputs debug messages by itself + $client->debug = false; + + if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto ) ) + add_ping( $post_ID, $pagelinkedto ); + else + debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n"); + } + } + + debug_fwrite($log, "\nEND: ".time()."\n****************************\n"); + debug_fclose($log); +} + +function discover_pingback_server_uri($url, $timeout_bytes = 2048) { + global $wp_version; + + $byte_count = 0; + $contents = ''; + $headers = ''; + $pingback_str_dquote = 'rel="pingback"'; + $pingback_str_squote = 'rel=\'pingback\''; + $x_pingback_str = 'x-pingback: '; + $pingback_href_original_pos = 27; + + extract(parse_url($url)); + + if (!isset($host)) { + // Not an URL. This should never happen. + return false; + } + + $path = (!isset($path)) ? '/' : $path; + $path .= (isset($query)) ? '?'.$query : ''; + $port = (isset($port)) ? $port : 80; + + // Try to connect to the server at $host + $fp = @fsockopen($host, $port, $errno, $errstr, 2); + if (!$fp) { + // Couldn't open a connection to $host; + return false; + } + + // Send the GET request + $request = "GET $path HTTP/1.1\r\nHost: $host\r\nUser-Agent: WordPress/$wp_version \r\n\r\n"; +// ob_end_flush(); + fputs($fp, $request); + + // Let's check for an X-Pingback header first + while (!feof($fp)) { + $line = fgets($fp, 512); + if (trim($line) == '') { + break; + } + $headers .= trim($line)."\n"; + $x_pingback_header_offset = strpos(strtolower($headers), $x_pingback_str); + if ($x_pingback_header_offset) { + // We got it! + preg_match('#x-pingback: (.+)#is', $headers, $matches); + $pingback_server_url = trim($matches[1]); + return $pingback_server_url; + } + if(strpos(strtolower($headers), 'content-type: ')) { + preg_match('#content-type: (.+)#is', $headers, $matches); + $content_type = trim($matches[1]); + } + } + + if (preg_match('#(image|audio|video|model)/#is', $content_type)) { + // Not an (x)html, sgml, or xml page, no use going further + return false; + } + + while (!feof($fp)) { + $line = fgets($fp, 1024); + $contents .= trim($line); + $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote); + $pingback_link_offset_squote = strpos($contents, $pingback_str_squote); + if ($pingback_link_offset_dquote || $pingback_link_offset_squote) { + $quote = ($pingback_link_offset_dquote) ? '"' : '\''; + $pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote; + $pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset); + $pingback_href_start = $pingback_href_pos+6; + $pingback_href_end = @strpos($contents, $quote, $pingback_href_start); + $pingback_server_url_len = $pingback_href_end - $pingback_href_start; + $pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len); + // We may find rel="pingback" but an incomplete pingback URI + if ($pingback_server_url_len > 0) { + // We got it! + return $pingback_server_url; + } + } + $byte_count += strlen($line); + if ($byte_count > $timeout_bytes) { + // It's no use going further, there probably isn't any pingback + // server to find in this file. (Prevents loading large files.) + return false; + } + } + + // We didn't find anything. + return false; +} + +function is_local_attachment($url) { + if ( !strstr($url, get_bloginfo('home') ) ) + return false; + if ( strstr($url, get_bloginfo('home') . '/?attachment_id=') ) + return true; + if ( $id = url_to_postid($url) ) { + $post = & get_post($id); + if ( 'attachment' == $post->post_status ) + return true; + } + return false; +} + +function wp_set_comment_status($comment_id, $comment_status) { + global $wpdb; + + switch($comment_status) { + case 'hold': + $query = "UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1"; + break; + case 'approve': + $query = "UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1"; + break; + case 'spam': + $query = "UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID='$comment_id' LIMIT 1"; + break; + case 'delete': + return wp_delete_comment($comment_id); + break; + default: + return false; + } + + if ($wpdb->query($query)) { + do_action('wp_set_comment_status', $comment_id, $comment_status); + + $comment = get_comment($comment_id); + $comment_post_ID = $comment->comment_post_ID; + $c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" ); + if( is_object( $c ) ) + $wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" ); + return true; + } else { + return false; + } +} + +function wp_get_comment_status($comment_id) { + global $wpdb; + + $result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); + if ($result == NULL) { + return 'deleted'; + } else if ($result == '1') { + return 'approved'; + } else if ($result == '0') { + return 'unapproved'; + } else if ($result == 'spam') { + return 'spam'; + } else { + return false; + } +} + +function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) { + global $wpdb; + + if (1 == get_settings('comment_moderation')) return false; // If moderation is set to manual + + if ( (count(explode('http:', $comment)) - 1) >= get_settings('comment_max_links') ) + return false; // Check # of external links + + $mod_keys = trim( get_settings('moderation_keys') ); + if ( !empty($mod_keys) ) { + $words = explode("\n", $mod_keys ); + + foreach ($words as $word) { + $word = trim($word); + + // Skip empty lines + if (empty($word)) { continue; } + + // Do some escaping magic so that '#' chars in the + // spam words don't break things: + $word = preg_quote($word, '#'); + + $pattern = "#$word#i"; + if ( preg_match($pattern, $author) ) return false; + if ( preg_match($pattern, $email) ) return false; + if ( preg_match($pattern, $url) ) return false; + if ( preg_match($pattern, $comment) ) return false; + if ( preg_match($pattern, $user_ip) ) return false; + if ( preg_match($pattern, $user_agent) ) return false; + } + } + + // Comment whitelisting: + if ( 1 == get_settings('comment_whitelist')) { + if ( 'trackback' == $comment_type || 'pingback' == $comment_type ) { // check if domain is in blogroll + $uri = parse_url($url); + $domain = $uri['host']; + $uri = parse_url( get_option('home') ); + $home_domain = $uri['host']; + if ( $wpdb->get_var("SELECT link_id FROM $wpdb->links WHERE link_url LIKE ('%$domain%') LIMIT 1") || $domain == $home_domain ) + return true; + else + return false; + } elseif( $author != '' && $email != '' ) { + $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1"); + if ( ( 1 == $ok_to_comment ) && + ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) ) + return true; + else + return false; + } else { + return false; + } + } + + return true; +} + +function get_approved_comments($post_id) { + global $wpdb; + return $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post_id AND comment_approved = '1' ORDER BY comment_date"); +} + +?> diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php new file mode 100644 index 00000000..03a14ff4 --- /dev/null +++ b/wp-includes/default-filters.php @@ -0,0 +1,88 @@ + \ No newline at end of file diff --git a/wp-includes/feed-functions.php b/wp-includes/feed-functions.php new file mode 100644 index 00000000..0b377bc3 --- /dev/null +++ b/wp-includes/feed-functions.php @@ -0,0 +1,164 @@ + $cut) { + $k = $cut; + $use_dotdotdot = 1; + } else { + $k = count($blah); + $use_dotdotdot = 0; + } + for ($i=0; $i<$k; $i++) { + $excerpt .= $blah[$i].' '; + } + $excerpt .= ($use_dotdotdot) ? '...' : ''; + $content = $excerpt; + } + $content = str_replace(']]>', ']]>', $content); + echo $content; +} + +function the_excerpt_rss() { + $output = get_the_excerpt(true); + echo apply_filters('the_excerpt_rss', $output); +} + +function permalink_single_rss($file = '') { + echo get_permalink(); +} + +function comment_link() { + echo get_comment_link(); +} + +function get_comment_author_rss() { + return apply_filters('comment_author_rss', get_comment_author() ); +} +function comment_author_rss() { + echo get_comment_author_rss(); +} + +function comment_text_rss() { + $comment_text = get_comment_text(); + $comment_text = apply_filters('comment_text_rss', $comment_text); + echo $comment_text; +} + +function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = '') { + $url = comments_rss($commentsrssfilename); + echo "$link_text"; +} + +function comments_rss($commentsrssfilename = '') { + global $id; + + if ('' != get_settings('permalink_structure')) + $url = trailingslashit( get_permalink() ) . 'feed/'; + else + $url = get_settings('home') . "/$commentsrssfilename?feed=rss2&p=$id"; + + return apply_filters('post_comments_feed_link', $url); +} + +function get_author_rss_link($echo = false, $author_id, $author_nicename) { + $auth_ID = $author_id; + $permalink_structure = get_settings('permalink_structure'); + + if ('' == $permalink_structure) { + $link = get_settings('home') . '?feed=rss2&author=' . $author_id; + } else { + $link = get_author_link(0, $author_id, $author_nicename); + $link = $link . "feed/"; + } + + $link = apply_filters('author_feed_link', $link); + + if ($echo) echo $link; + return $link; +} + +function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { + $permalink_structure = get_settings('permalink_structure'); + + if ('' == $permalink_structure) { + $link = get_settings('home') . '?feed=rss2&cat=' . $cat_ID; + } else { + $link = get_category_link($cat_ID); + $link = $link . "feed/"; + } + + $link = apply_filters('category_feed_link', $link); + + if ($echo) echo $link; + return $link; +} + +function the_category_rss($type = 'rss') { + $categories = get_the_category(); + $the_list = ''; + foreach ($categories as $category) { + $category->cat_name = convert_chars($category->cat_name); + if ('rdf' == $type) { + $the_list .= "\n\t$category->cat_name"; + } else { + $the_list .= "\n\t$category->cat_name"; + } + } + echo apply_filters('the_category_rss', $the_list, $type); +} + +function rss_enclosure() { + global $id, $post; + if (!empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password)) return; + + $custom_fields = get_post_custom(); + if( is_array( $custom_fields ) ) { + while( list( $key, $val ) = each( $custom_fields ) ) { + if( $key == 'enclosure' ) { + if (is_array($val)) { + foreach($val as $enc) { + $enclosure = split( "\n", $enc ); + print "\n"; + } + } + } + } + } +} + +?> \ No newline at end of file diff --git a/wp-includes/functions-compat.php b/wp-includes/functions-compat.php new file mode 100644 index 00000000..b6d706ce --- /dev/null +++ b/wp-includes/functions-compat.php @@ -0,0 +1,100 @@ + + if (get_class($object) == strtolower($class)) { + return true; + } else { + return is_subclass_of($object, $class); + } + } +} + +if (!function_exists('ob_clean')) { + function ob_clean() { + // by Aidan Lister + if (@ob_end_clean()) { + return ob_start(); + } + return false; + } +} + + +/* Added in PHP 4.3.0 */ + +function printr($var, $do_not_echo = false) { + // from php.net/print_r user contributed notes + ob_start(); + print_r($var); + $code = htmlentities(ob_get_contents()); + ob_clean(); + if (!$do_not_echo) { + echo "
    $code
    "; + } + return $code; +} + +/* compatibility with PHP versions older than 4.3 */ +if ( !function_exists('file_get_contents') ) { + function file_get_contents( $file ) { + $file = file($file); + return !$file ? false : implode('', $file); + } +} + +if (!defined('CASE_LOWER')) { + define('CASE_LOWER', 0); +} + +if (!defined('CASE_UPPER')) { + define('CASE_UPPER', 1); +} + + +/** + * Replace array_change_key_case() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.array_change_key_case + * @author Stephan Schmidt + * @author Aidan Lister + * @version $Revision: 3471 $ + * @since PHP 4.2.0 + * @require PHP 4.0.0 (user_error) + */ +if (!function_exists('array_change_key_case')) { + function array_change_key_case($input, $case = CASE_LOWER) + { + if (!is_array($input)) { + user_error('array_change_key_case(): The argument should be an array', + E_USER_WARNING); + return false; + } + + $output = array (); + $keys = array_keys($input); + $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper'; + + foreach ($keys as $key) { + $output[$casefunc($key)] = $input[$key]; + } + + return $output; + } +} + +?> diff --git a/wp-includes/functions-formatting.php b/wp-includes/functions-formatting.php new file mode 100644 index 00000000..6f955e8b --- /dev/null +++ b/wp-includes/functions-formatting.php @@ -0,0 +1,1021 @@ +)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE); + $stop = count($textarr); $next = true; // loop stuff + for ($i = 0; $i < $stop; $i++) { + $curl = $textarr[$i]; + + if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag + $curl = str_replace('---', '—', $curl); + $curl = str_replace(' -- ', ' — ', $curl); + $curl = str_replace('--', '–', $curl); + $curl = str_replace('xn–', 'xn--', $curl); + $curl = str_replace('...', '…', $curl); + $curl = str_replace('``', '“', $curl); + + // This is a hack, look at this more later. It works pretty well though. + $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause"); + $cockneyreplace = array("’tain’t","’twere","’twas","’tis","’twill","’til","’bout","’nuff","’round","’cause"); + $curl = str_replace($cockney, $cockneyreplace, $curl); + + $curl = preg_replace("/'s/", '’s', $curl); + $curl = preg_replace("/'(\d\d(?:’|')?s)/", "’$1", $curl); + $curl = preg_replace('/(\s|\A|")\'/', '$1‘', $curl); + $curl = preg_replace('/(\d+)"/', '$1″', $curl); + $curl = preg_replace("/(\d+)'/", '$1′', $curl); + $curl = preg_replace("/(\S)'([^'\s])/", "$1’$2", $curl); + $curl = preg_replace('/(\s|\A)"(?!\s)/', '$1“$2', $curl); + $curl = preg_replace('/"(\s|\S|\Z)/', '”$1', $curl); + $curl = preg_replace("/'([\s.]|\Z)/", '’$1', $curl); + $curl = preg_replace("/ \(tm\)/i", ' ™', $curl); + $curl = str_replace("''", '”', $curl); + + $curl = preg_replace('/(\d+)x(\d+)/', "$1×$2", $curl); + + } elseif (strstr($curl, '', '', $text); + $text = str_replace('

    ', "\n", $text); + $text = str_replace('

    ', '', $text); + return $text; +} + +function wpautop($pee, $br = 1) { + $pee = $pee . "\n"; // just to make things a little easier, pad the end + $pee = preg_replace('|
    \s*
    |', "\n\n", $pee); + // Space things out a little + $pee = preg_replace('!(<(?: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])[^>]*>)!', "\n$1", $pee); + $pee = preg_replace('!()!', "$1\n\n", $pee); + $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines + $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates + $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "

    $1

    \n", $pee); // make paragraphs, including one at the end + $pee = preg_replace('|

    \s*?

    |', '', $pee); // under certain strange conditions it could create a P of entirely whitespace + $pee = preg_replace('!

    \s*(]*>)\s*

    !', "$1", $pee); // don't pee all over a tag + $pee = preg_replace("|

    (|", "$1", $pee); // problem with nested lists + $pee = preg_replace('|

    ]*)>|i', "

    ", $pee); + $pee = str_replace('

    ', '

    ', $pee); + $pee = preg_replace('!

    \s*(]*>)!', "$1", $pee); + $pee = preg_replace('!(]*>)\s*

    !', "$1", $pee); + if ($br) $pee = preg_replace('|(?)\s*\n|', "
    \n", $pee); // optionally make line breaks + $pee = preg_replace('!(]*>)\s*
    !', "$1", $pee); + $pee = preg_replace('!
    (\s*)!', '$1', $pee); + $pee = preg_replace('!()(.*?)
    !ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '' ", $pee); + + return $pee; +} + + +function seems_utf8($Str) { # by bmorel at ssi dot fr + for ($i=0; $i', '>', $text); + if ( $quotes ) { + $text = str_replace('"', '"', $text); + $text = str_replace("'", ''', $text); + } + return $text; +} + +function utf8_uri_encode( $utf8_string ) { + $unicode = ''; + $values = array(); + $num_octets = 1; + + for ($i = 0; $i < strlen( $utf8_string ); $i++ ) { + + $value = ord( $utf8_string[ $i ] ); + + if ( $value < 128 ) { + $unicode .= chr($value); + } else { + if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3; + + $values[] = $value; + + if ( count( $values ) == $num_octets ) { + if ($num_octets == 3) { + $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]); + } else { + $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]); + } + + $values = array(); + $num_octets = 1; + } + } + } + + return $unicode; +} + +function remove_accents($string) { + if (seems_utf8($string)) { + $chars = array( + // Decompositions for Latin-1 Supplement + chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', + chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', + chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', + chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', + chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', + chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', + chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', + chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', + chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', + chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', + chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', + chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', + chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', + chr(195).chr(159) => 's', chr(195).chr(160) => 'a', + chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', + chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', + chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', + chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', + chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', + chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', + chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', + chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', + chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', + chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', + chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', + chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', + chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', + chr(195).chr(191) => 'y', + // Decompositions for Latin Extended-A + chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', + chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', + chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', + chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', + chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', + chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', + chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', + chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', + chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', + chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', + chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', + chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', + chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', + chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', + chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', + chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', + chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', + chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', + chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', + chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', + chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', + chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', + chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', + chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', + chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', + chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', + chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', + chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', + chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', + chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', + chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', + chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', + chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', + chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', + chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', + chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', + chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', + chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', + chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', + chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', + chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', + chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', + chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', + chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', + chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', + chr(197).chr(154) => 'S',chr(197).chr(155) => 's', + chr(197).chr(156) => 'S',chr(197).chr(157) => 's', + chr(197).chr(158) => 'S',chr(197).chr(159) => 's', + chr(197).chr(160) => 'S', chr(197).chr(161) => 's', + chr(197).chr(162) => 'T', chr(197).chr(163) => 't', + chr(197).chr(164) => 'T', chr(197).chr(165) => 't', + chr(197).chr(166) => 'T', chr(197).chr(167) => 't', + chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', + chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', + chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', + chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', + chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', + chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', + chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', + chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', + chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', + chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', + chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', + chr(197).chr(190) => 'z', chr(197).chr(191) => 's', + // Euro Sign + chr(226).chr(130).chr(172) => 'E'); + + $string = strtr($string, $chars); + } else { + // Assume ISO-8859-1 if not UTF-8 + $chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158) + .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194) + .chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202) + .chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210) + .chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218) + .chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227) + .chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235) + .chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243) + .chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251) + .chr(252).chr(253).chr(255); + + $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy"; + + $string = strtr($string, $chars['in'], $chars['out']); + $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254)); + $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th'); + $string = str_replace($double_chars['in'], $double_chars['out'], $string); + } + + return $string; +} + +function sanitize_user( $username, $strict = false ) { + $raw_username = $username; + $username = strip_tags($username); + // Kill octets + $username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $username); + $username = preg_replace('/&.+?;/', '', $username); // Kill entities + + // If strict, reduce to ASCII for max portability. + if ( $strict ) + $username = preg_replace('|[^a-z0-9 _.-@]|i', '', $username); + + return apply_filters('sanitize_user', $username, $raw_username, $strict); +} + +function sanitize_title($title, $fallback_title = '') { + $title = strip_tags($title); + $title = apply_filters('sanitize_title', $title); + + if (empty($title)) { + $title = $fallback_title; + } + + return $title; +} + +function sanitize_title_with_dashes($title) { + $title = strip_tags($title); + // Preserve escaped octets. + $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title); + // Remove percent signs that are not part of an octet. + $title = str_replace('%', '', $title); + // Restore octets. + $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title); + + $title = remove_accents($title); + if (seems_utf8($title)) { + if (function_exists('mb_strtolower')) { + $title = mb_strtolower($title, 'UTF-8'); + } + $title = utf8_uri_encode($title); + } + + $title = strtolower($title); + $title = preg_replace('/&.+?;/', '', $title); // kill entities + $title = preg_replace('/[^%a-z0-9 _-]/', '', $title); + $title = preg_replace('/\s+/', '-', $title); + $title = preg_replace('|-+|', '-', $title); + $title = trim($title, '-'); + + return $title; +} + +function convert_chars($content, $flag = 'obsolete') { + // Translation of invalid Unicode references range to valid range + $wp_htmltranswinuni = array( + '€' => '€', // the Euro sign + '' => '', + '‚' => '‚', // these are Windows CP1252 specific characters + 'ƒ' => 'ƒ', // they would look weird on non-Windows browsers + '„' => '„', + '…' => '…', + '†' => '†', + '‡' => '‡', + 'ˆ' => 'ˆ', + '‰' => '‰', + 'Š' => 'Š', + '‹' => '‹', + 'Œ' => 'Œ', + '' => '', + 'Ž' => 'ž', + '' => '', + '' => '', + '‘' => '‘', + '’' => '’', + '“' => '“', + '”' => '”', + '•' => '•', + '–' => '–', + '—' => '—', + '˜' => '˜', + '™' => '™', + 'š' => 'š', + '›' => '›', + 'œ' => 'œ', + '' => '', + 'ž' => '', + 'Ÿ' => 'Ÿ' + ); + + // Remove metadata tags + $content = preg_replace('/(.+?)<\/title>/','',$content); + $content = preg_replace('/<category>(.+?)<\/category>/','',$content); + + // Converts lone & characters into & (a.k.a. &) + $content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content); + + // Fix Word pasting + $content = strtr($content, $wp_htmltranswinuni); + + // Just a little XHTML help + $content = str_replace('<br>', '<br />', $content); + $content = str_replace('<hr>', '<hr />', $content); + + return $content; +} + +function funky_javascript_fix($text) { + // Fixes for browsers' javascript bugs + global $is_macIE, $is_winIE; + + if ( $is_winIE || $is_macIE ) + $text = preg_replace("/\%u([0-9A-F]{4,4})/e", "'&#'.base_convert('\\1',16,10).';'", $text); + + return $text; +} + +/* + balanceTags + + Balances Tags of string using a modified stack. + + @param text Text to be balanced + @return Returns balanced text + @author Leonard Lin (leonard@acm.org) + @version v1.1 + @date November 4, 2001 + @license GPL v2.0 + @notes + @changelog + --- Modified by Scott Reilly (coffee2code) 02 Aug 2004 + 1.2 ***TODO*** Make better - change loop condition to $text + 1.1 Fixed handling of append/stack pop order of end text + Added Cleaning Hooks + 1.0 First Version +*/ +function balanceTags($text, $is_comment = 0) { + + if ( get_option('use_balanceTags') == 0) + return $text; + + $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = ''; + + # WP bug fix for comments - in case you REALLY meant to type '< !--' + $text = str_replace('< !--', '< !--', $text); + # WP bug fix for LOVE <3 (and other situations with '<' before a number) + $text = preg_replace('#<([0-9]{1})#', '<$1', $text); + + while (preg_match("/<(\/?\w*)\s*([^>]*)>/",$text,$regex)) { + $newtext .= $tagqueue; + + $i = strpos($text,$regex[0]); + $l = strlen($regex[0]); + + // clear the shifter + $tagqueue = ''; + // Pop or Push + if ($regex[1][0] == "/") { // End Tag + $tag = strtolower(substr($regex[1],1)); + // if too many closing tags + if($stacksize <= 0) { + $tag = ''; + //or close to be safe $tag = '/' . $tag; + } + // if stacktop value = tag close value then pop + else if ($tagstack[$stacksize - 1] == $tag) { // found closing tag + $tag = '</' . $tag . '>'; // Close Tag + // Pop + array_pop ($tagstack); + $stacksize--; + } else { // closing tag not at top, search for it + for ($j=$stacksize-1;$j>=0;$j--) { + if ($tagstack[$j] == $tag) { + // add tag to tagqueue + for ($k=$stacksize-1;$k>=$j;$k--){ + $tagqueue .= '</' . array_pop ($tagstack) . '>'; + $stacksize--; + } + break; + } + } + $tag = ''; + } + } else { // Begin Tag + $tag = strtolower($regex[1]); + + // Tag Cleaning + + // If self-closing or '', don't do anything. + if((substr($regex[2],-1) == '/') || ($tag == '')) { + } + // ElseIf it's a known single-entity tag but it doesn't close itself, do so + elseif ($tag == 'br' || $tag == 'img' || $tag == 'hr' || $tag == 'input') { + $regex[2] .= '/'; + } else { // Push the tag onto the stack + // If the top of the stack is the same as the tag we want to push, close previous tag + if (($stacksize > 0) && ($tag != 'div') && ($tagstack[$stacksize - 1] == $tag)) { + $tagqueue = '</' . array_pop ($tagstack) . '>'; + $stacksize--; + } + $stacksize = array_push ($tagstack, $tag); + } + + // Attributes + $attributes = $regex[2]; + if($attributes) { + $attributes = ' '.$attributes; + } + $tag = '<'.$tag.$attributes.'>'; + //If already queuing a close tag, then put this tag on, too + if ($tagqueue) { + $tagqueue .= $tag; + $tag = ''; + } + } + $newtext .= substr($text,0,$i) . $tag; + $text = substr($text,$i+$l); + } + + // Clear Tag Queue + $newtext .= $tagqueue; + + // Add Remaining text + $newtext .= $text; + + // Empty Stack + while($x = array_pop($tagstack)) { + $newtext .= '</' . $x . '>'; // Add remaining tags to close + } + + // WP fix for the bug with HTML comments + $newtext = str_replace("< !--","<!--",$newtext); + $newtext = str_replace("< !--","< !--",$newtext); + + return $newtext; +} + + +function format_to_edit($content, $richedit = false) { + $content = apply_filters('format_to_edit', $content); + if (! $richedit ) + $content = htmlspecialchars($content); + return $content; +} + +function format_to_post($content) { + global $wpdb; + $content = apply_filters('format_to_post', $content); + return $content; +} + +function zeroise($number,$threshold) { // function to add leading zeros when necessary + return sprintf('%0'.$threshold.'s', $number); + } + + +function backslashit($string) { + $string = preg_replace('/([a-z])/i', '\\\\\1', $string); + return $string; +} + +function trailingslashit($string) { + if ( '/' != substr($string, -1)) { + $string .= '/'; + } + return $string; +} + +function addslashes_gpc($gpc) { + global $wpdb; + + if (get_magic_quotes_gpc()) { + $gpc = stripslashes($gpc); + } + + return $wpdb->escape($gpc); +} + + +function stripslashes_deep($value) +{ + $value = is_array($value) ? + array_map('stripslashes_deep', $value) : + stripslashes($value); + + return $value; +} + +function antispambot($emailaddy, $mailto=0) { + $emailNOSPAMaddy = ''; + srand ((float) microtime() * 1000000); + for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) { + $j = floor(rand(0, 1+$mailto)); + if ($j==0) { + $emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';'; + } elseif ($j==1) { + $emailNOSPAMaddy .= substr($emailaddy,$i,1); + } elseif ($j==2) { + $emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2); + } + } + $emailNOSPAMaddy = str_replace('@','@',$emailNOSPAMaddy); + return $emailNOSPAMaddy; +} + +function make_clickable($ret) { + $ret = ' ' . $ret . ' '; + $ret = preg_replace("#([\s>])(https?)://([^\s<>{}()]+[^\s.,<>{}()])#i", "$1<a href='$2://$3' rel='nofollow'>$2://$3</a>", $ret); + $ret = preg_replace("#(\s)www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^ <>{}()\n\r]*[^., <>{}()\n\r]?)?)#i", "$1<a href='http://www.$2.$3$4' rel='nofollow'>www.$2.$3$4</a>", $ret); + $ret = preg_replace("#(\s)([a-z0-9\-_.]+)@([a-z0-9\-_.]+)\.([^,< \n\r]+)#i", "$1<a href=\"mailto:$2@$3.$4\">$2@$3.$4</a>", $ret); + $ret = trim($ret); + return $ret; +} + +function wp_rel_nofollow( $text ) { + $text = preg_replace('|<a (.+?)>|i', '<a $1 rel="nofollow">', $text); + return $text; +} + +function convert_smilies($text) { + global $wp_smiliessearch, $wp_smiliesreplace; + $output = ''; + if (get_settings('use_smilies')) { + // HTML loop taken from texturize function, could possible be consolidated + $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between + $stop = count($textarr);// loop stuff + for ($i = 0; $i < $stop; $i++) { + $content = $textarr[$i]; + if ((strlen($content) > 0) && ('<' != $content{0})) { // If it's not a tag + $content = str_replace($wp_smiliessearch, $wp_smiliesreplace, $content); + } + $output .= $content; + } + } else { + // return default text. + $output = $text; + } + return $output; +} + + +function is_email($user_email) { + $chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i"; + if(strstr($user_email, '@') && strstr($user_email, '.')) { + if (preg_match($chars, $user_email)) { + return true; + } else { + return false; + } + } else { + return false; + } +} + +// used by wp-mail to handle charsets in email subjects +function wp_iso_descrambler($string) { + /* this may only work with iso-8859-1, I'm afraid */ + if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) { + return $string; + } else { + $subject = str_replace('_', ' ', $matches[2]); + $subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject); + return $subject; + } +} + + +// give it a date, it will give you the same date as GMT +function get_gmt_from_date($string) { + // note: this only substracts $time_difference from the given date + preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches); + $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); + $string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_settings('gmt_offset') * 3600); + return $string_gmt; +} + +// give it a GMT date, it will give you the same date with $time_difference added +function get_date_from_gmt($string) { + // note: this only adds $time_difference to the given date + preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches); + $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); + $string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_settings('gmt_offset')*3600); + return $string_localtime; +} + +// computes an offset in seconds from an iso8601 timezone +function iso8601_timezone_to_offset($timezone) { + // $timezone is either 'Z' or '[+|-]hhmm' + if ($timezone == 'Z') { + $offset = 0; + } else { + $sign = (substr($timezone, 0, 1) == '+') ? 1 : -1; + $hours = intval(substr($timezone, 1, 2)); + $minutes = intval(substr($timezone, 3, 4)) / 60; + $offset = $sign * 3600 * ($hours + $minutes); + } + return $offset; +} + +// converts an iso8601 date to MySQL DateTime format used by post_date[_gmt] +function iso8601_to_datetime($date_string, $timezone = USER) { + if ($timezone == GMT) { + preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits); + if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset + $offset = iso8601_timezone_to_offset($date_bits[7]); + } else { // we don't have a timezone, so we assume user local timezone (not server's!) + $offset = 3600 * get_settings('gmt_offset'); + } + $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]); + $timestamp -= $offset; + return gmdate('Y-m-d H:i:s', $timestamp); + } elseif ($timezone == USER) { + return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string); + } +} + +function popuplinks($text) { + // Comment text in popup windows should be filtered through this. + // Right now it's a moderately dumb function, ideally it would detect whether + // a target or rel attribute was already there and adjust its actions accordingly. + $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text); + return $text; +} + +function sanitize_email($email) { + return preg_replace('/[^a-z0-9+_.@-]/i', '', $email); +} + +function human_time_diff( $from, $to = '' ) { + if ( empty($to) ) + $to = time(); + $diff = (int) abs($to - $from); + if ($diff <= 3600) { + $mins = round($diff / 60); + if ($mins <= 1) + $since = __('1 min'); + else + $since = sprintf( __('%s mins'), $mins); + } else if (($diff <= 86400) && ($diff > 3600)) { + $hours = round($diff / 3600); + if ($hours <= 1) + $since = __('1 hour'); + else + $since = sprintf( __('%s hours'), $hours ); + } elseif ($diff >= 86400) { + $days = round($diff / 86400); + if ($days <= 1) + $since = __('1 day'); + else + $since = sprintf( __('%s days'), $days ); + } + return $since; +} + +function wp_trim_excerpt($text) { // Fakes an excerpt if needed + global $post; + if ( '' == $text ) { + $text = $post->post_content; + $text = apply_filters('the_content', $text); + $text = str_replace(']]>', ']]>', $text); + $text = strip_tags($text); + $excerpt_length = 55; + $words = explode(' ', $text, $excerpt_length + 1); + if (count($words) > $excerpt_length) { + array_pop($words); + array_push($words, '[...]'); + $text = implode(' ', $words); + } + } + return $text; +} + +function ent2ncr($text) { + $to_ncr = array( + '"' => '"', + '&' => '&', + '⁄' => '/', + '<' => '<', + '>' => '>', + '|' => '|', + ' ' => ' ', + '¡' => '¡', + '¢' => '¢', + '£' => '£', + '¤' => '¤', + '¥' => '¥', + '¦' => '¦', + '&brkbar;' => '¦', + '§' => '§', + '¨' => '¨', + '¨' => '¨', + '©' => '©', + 'ª' => 'ª', + '«' => '«', + '¬' => '¬', + '­' => '­', + '®' => '®', + '¯' => '¯', + '&hibar;' => '¯', + '°' => '°', + '±' => '±', + '²' => '²', + '³' => '³', + '´' => '´', + 'µ' => 'µ', + '¶' => '¶', + '·' => '·', + '¸' => '¸', + '¹' => '¹', + 'º' => 'º', + '»' => '»', + '¼' => '¼', + '½' => '½', + '¾' => '¾', + '¿' => '¿', + 'À' => 'À', + 'Á' => 'Á', + 'Â' => 'Â', + 'Ã' => 'Ã', + 'Ä' => 'Ä', + 'Å' => 'Å', + 'Æ' => 'Æ', + 'Ç' => 'Ç', + 'È' => 'È', + 'É' => 'É', + 'Ê' => 'Ê', + 'Ë' => 'Ë', + 'Ì' => 'Ì', + 'Í' => 'Í', + 'Î' => 'Î', + 'Ï' => 'Ï', + 'Ð' => 'Ð', + 'Ñ' => 'Ñ', + 'Ò' => 'Ò', + 'Ó' => 'Ó', + 'Ô' => 'Ô', + 'Õ' => 'Õ', + 'Ö' => 'Ö', + '×' => '×', + 'Ø' => 'Ø', + 'Ù' => 'Ù', + 'Ú' => 'Ú', + 'Û' => 'Û', + 'Ü' => 'Ü', + 'Ý' => 'Ý', + 'Þ' => 'Þ', + 'ß' => 'ß', + 'à' => 'à', + 'á' => 'á', + 'â' => 'â', + 'ã' => 'ã', + 'ä' => 'ä', + 'å' => 'å', + 'æ' => 'æ', + 'ç' => 'ç', + 'è' => 'è', + 'é' => 'é', + 'ê' => 'ê', + 'ë' => 'ë', + 'ì' => 'ì', + 'í' => 'í', + 'î' => 'î', + 'ï' => 'ï', + 'ð' => 'ð', + 'ñ' => 'ñ', + 'ò' => 'ò', + 'ó' => 'ó', + 'ô' => 'ô', + 'õ' => 'õ', + 'ö' => 'ö', + '÷' => '÷', + 'ø' => 'ø', + 'ù' => 'ù', + 'ú' => 'ú', + 'û' => 'û', + 'ü' => 'ü', + 'ý' => 'ý', + 'þ' => 'þ', + 'ÿ' => 'ÿ', + 'Œ' => 'Œ', + 'œ' => 'œ', + 'Š' => 'Š', + 'š' => 'š', + 'Ÿ' => 'Ÿ', + 'ƒ' => 'ƒ', + 'ˆ' => 'ˆ', + '˜' => '˜', + 'Α' => 'Α', + 'Β' => 'Β', + 'Γ' => 'Γ', + 'Δ' => 'Δ', + 'Ε' => 'Ε', + 'Ζ' => 'Ζ', + 'Η' => 'Η', + 'Θ' => 'Θ', + 'Ι' => 'Ι', + 'Κ' => 'Κ', + 'Λ' => 'Λ', + 'Μ' => 'Μ', + 'Ν' => 'Ν', + 'Ξ' => 'Ξ', + 'Ο' => 'Ο', + 'Π' => 'Π', + 'Ρ' => 'Ρ', + 'Σ' => 'Σ', + 'Τ' => 'Τ', + 'Υ' => 'Υ', + 'Φ' => 'Φ', + 'Χ' => 'Χ', + 'Ψ' => 'Ψ', + 'Ω' => 'Ω', + 'α' => 'α', + 'β' => 'β', + 'γ' => 'γ', + 'δ' => 'δ', + 'ε' => 'ε', + 'ζ' => 'ζ', + 'η' => 'η', + 'θ' => 'θ', + 'ι' => 'ι', + 'κ' => 'κ', + 'λ' => 'λ', + 'μ' => 'μ', + 'ν' => 'ν', + 'ξ' => 'ξ', + 'ο' => 'ο', + 'π' => 'π', + 'ρ' => 'ρ', + 'ς' => 'ς', + 'σ' => 'σ', + 'τ' => 'τ', + 'υ' => 'υ', + 'φ' => 'φ', + 'χ' => 'χ', + 'ψ' => 'ψ', + 'ω' => 'ω', + 'ϑ' => 'ϑ', + 'ϒ' => 'ϒ', + 'ϖ' => 'ϖ', + ' ' => ' ', + ' ' => ' ', + ' ' => ' ', + '‌' => '‌', + '‍' => '‍', + '‎' => '‎', + '‏' => '‏', + '–' => '–', + '—' => '—', + '‘' => '‘', + '’' => '’', + '‚' => '‚', + '“' => '“', + '”' => '”', + '„' => '„', + '†' => '†', + '‡' => '‡', + '•' => '•', + '…' => '…', + '‰' => '‰', + '′' => '′', + '″' => '″', + '‹' => '‹', + '›' => '›', + '‾' => '‾', + '⁄' => '⁄', + '€' => '€', + 'ℑ' => 'ℑ', + '℘' => '℘', + 'ℜ' => 'ℜ', + '™' => '™', + 'ℵ' => 'ℵ', + '↵' => '↵', + '⇐' => '⇐', + '⇑' => '⇑', + '⇒' => '⇒', + '⇓' => '⇓', + '⇔' => '⇔', + '∀' => '∀', + '∂' => '∂', + '∃' => '∃', + '∅' => '∅', + '∇' => '∇', + '∈' => '∈', + '∉' => '∉', + '∋' => '∋', + '∏' => '∏', + '∑' => '∑', + '−' => '−', + '∗' => '∗', + '√' => '√', + '∝' => '∝', + '∞' => '∞', + '∠' => '∠', + '∧' => '∧', + '∨' => '∨', + '∩' => '∩', + '∪' => '∪', + '∫' => '∫', + '∴' => '∴', + '∼' => '∼', + '≅' => '≅', + '≈' => '≈', + '≠' => '≠', + '≡' => '≡', + '≤' => '≤', + '≥' => '≥', + '⊂' => '⊂', + '⊃' => '⊃', + '⊄' => '⊄', + '⊆' => '⊆', + '⊇' => '⊇', + '⊕' => '⊕', + '⊗' => '⊗', + '⊥' => '⊥', + '⋅' => '⋅', + '⌈' => '⌈', + '⌉' => '⌉', + '⌊' => '⌊', + '⌋' => '⌋', + '⟨' => '〈', + '⟩' => '〉', + '←' => '←', + '↑' => '↑', + '→' => '→', + '↓' => '↓', + '↔' => '↔', + '◊' => '◊', + '♠' => '♠', + '♣' => '♣', + '♥' => '♥', + '♦' => '♦' + ); + + foreach ($to_ncr as $entity => $ncr) { + $text = str_replace($entity, $ncr, $text); + } + return $text; +} + +function wp_richedit_pre($text) { + // Filtering a blank results in an annoying <br />\n + if ( empty($text) ) return apply_filters('richedit_pre', ''); + + $output = $text; + $output = convert_chars($output); + $output = wpautop($output); + + // These must be double-escaped or planets will collide. + $output = str_replace('<', '&lt;', $output); + $output = str_replace('>', '&gt;', $output); + + return apply_filters('richedit_pre', $output); +} + +?> diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php new file mode 100644 index 00000000..842980f6 --- /dev/null +++ b/wp-includes/functions-post.php @@ -0,0 +1,964 @@ +<?php + +/**** DB Functions ****/ + +/* + * generic function for inserting data into the posts table. + */ +function wp_insert_post($postarr = array()) { + global $wpdb, $wp_rewrite, $allowedtags, $user_ID; + + if ( is_object($postarr) ) + $postarr = get_object_vars($postarr); + + // export array as variables + extract($postarr); + + // Are we updating or creating? + $update = false; + if ( !empty($ID) ) { + $update = true; + $post = & get_post($ID); + $previous_status = $post->post_status; + } + + // Get the basics. + $post_content = apply_filters('content_save_pre', $post_content); + $post_excerpt = apply_filters('excerpt_save_pre', $post_excerpt); + $post_title = apply_filters('title_save_pre', $post_title); + $post_category = apply_filters('category_save_pre', $post_category); + $post_status = apply_filters('status_save_pre', $post_status); + $post_name = apply_filters('name_save_pre', $post_name); + $comment_status = apply_filters('comment_status_pre', $comment_status); + $ping_status = apply_filters('ping_status_pre', $ping_status); + + // Make sure we set a valid category + if (0 == count($post_category) || !is_array($post_category)) { + $post_category = array(get_option('default_category')); + } + $post_cat = $post_category[0]; + + if ( empty($post_author) ) + $post_author = $user_ID; + + if ( empty($post_status) ) + $post_status = 'draft'; + + // Get the post ID. + if ( $update ) + $post_ID = $ID; + + // Create a valid post name. Drafts are allowed to have an empty + // post name. + if ( empty($post_name) ) { + if ( 'draft' != $post_status ) + $post_name = sanitize_title($post_title); + } else { + $post_name = sanitize_title($post_name); + } + + + // If the post date is empty (due to having been new or a draft) and status is not 'draft', set date to now + if (empty($post_date)) { + if ( 'draft' != $post_status ) + $post_date = current_time('mysql'); + } + + if (empty($post_date_gmt)) { + if ( 'draft' != $post_status ) + $post_date_gmt = get_gmt_from_date($post_date); + } + + if ( empty($comment_status) ) { + if ( $update ) + $comment_status = 'closed'; + else + $comment_status = get_settings('default_comment_status'); + } + if ( empty($ping_status) ) + $ping_status = get_settings('default_ping_status'); + if ( empty($post_pingback) ) + $post_pingback = get_option('default_pingback_flag'); + + if ( isset($to_ping) ) + $to_ping = preg_replace('|\s+|', "\n", $to_ping); + else + $to_ping = ''; + + if ( ! isset($pinged) ) + $pinged = ''; + + if ( isset($post_parent) ) + $post_parent = (int) $post_parent; + else + $post_parent = 0; + + if ( isset($menu_order) ) + $menu_order = (int) $menu_order; + else + $menu_order = 0; + + if ( !isset($post_password) ) + $post_password = ''; + + if ( ('publish' == $post_status) || ('static' == $post_status) ) { + $post_name_check = ('publish' == $post_status) + ? $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'publish' AND ID != '$post_ID' LIMIT 1") + : $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'static' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1"); + + if ($post_name_check) { + $suffix = 2; + while ($post_name_check) { + $alt_post_name = $post_name . "-$suffix"; + $post_name_check = ('publish' == $post_status) + ? $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'publish' AND ID != '$post_ID' LIMIT 1") + : $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'static' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1"); + $suffix++; + } + $post_name = $alt_post_name; + } + } + + if ($update) { + $wpdb->query( + "UPDATE IGNORE $wpdb->posts SET + post_author = '$post_author', + post_date = '$post_date', + post_date_gmt = '$post_date_gmt', + post_content = '$post_content', + post_content_filtered = '$post_content_filtered', + post_title = '$post_title', + post_excerpt = '$post_excerpt', + post_status = '$post_status', + comment_status = '$comment_status', + ping_status = '$ping_status', + post_password = '$post_password', + post_name = '$post_name', + to_ping = '$to_ping', + pinged = '$pinged', + post_modified = '".current_time('mysql')."', + post_modified_gmt = '".current_time('mysql',1)."', + post_parent = '$post_parent', + menu_order = '$menu_order' + WHERE ID = $post_ID"); + } else { + $wpdb->query( + "INSERT IGNORE INTO $wpdb->posts + (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type) + VALUES + ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type')"); + $post_ID = $wpdb->insert_id; + } + + if ( empty($post_name) && 'draft' != $post_status ) { + $post_name = sanitize_title($post_title, $post_ID); + $wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" ); + } + + wp_set_post_cats('', $post_ID, $post_category); + + if ( 'static' == $post_status ) { + clean_page_cache($post_ID); + wp_cache_delete($post_ID, 'pages'); + } else { + clean_post_cache($post_ID); + } + + // Set GUID + if ( ! $update ) + $wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'"); + + if ( $update) { + if ($previous_status != 'publish' && $post_status == 'publish') { + // Reset GUID if transitioning to publish. + $wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'"); + do_action('private_to_published', $post_ID); + } + + do_action('edit_post', $post_ID); + } + + if ($post_status == 'publish') { + do_action('publish_post', $post_ID); + + if ( !defined('WP_IMPORTING') ) { + if ( $post_pingback ) + $result = $wpdb->query(" + INSERT INTO $wpdb->postmeta + (post_id,meta_key,meta_value) + VALUES ('$post_ID','_pingme','1') + "); + $result = $wpdb->query(" + INSERT INTO $wpdb->postmeta + (post_id,meta_key,meta_value) + VALUES ('$post_ID','_encloseme','1') + "); + spawn_pinger(); + } + } else if ($post_status == 'static') { + wp_cache_delete('all_page_ids', 'pages'); + $wp_rewrite->flush_rules(); + + if ( !empty($page_template) ) + if ( ! update_post_meta($post_ID, '_wp_page_template', $page_template)) + add_post_meta($post_ID, '_wp_page_template', $page_template, true); + } + + do_action('save_post', $post_ID); + do_action('wp_insert_post', $post_ID); + + return $post_ID; +} + +function wp_insert_attachment($object, $file = false, $post_parent = 0) { + global $wpdb, $user_ID; + + if ( is_object($object) ) + $object = get_object_vars($object); + + // Export array as variables + extract($object); + + // Get the basics. + $post_content = apply_filters('content_save_pre', $post_content); + $post_excerpt = apply_filters('excerpt_save_pre', $post_excerpt); + $post_title = apply_filters('title_save_pre', $post_title); + $post_category = apply_filters('category_save_pre', $post_category); + $post_name = apply_filters('name_save_pre', $post_name); + $comment_status = apply_filters('comment_status_pre', $comment_status); + $ping_status = apply_filters('ping_status_pre', $ping_status); + $post_mime_type = apply_filters('post_mime_type_pre', $post_mime_type); + + // Make sure we set a valid category + if (0 == count($post_category) || !is_array($post_category)) { + $post_category = array(get_option('default_category')); + } + $post_cat = $post_category[0]; + + if ( empty($post_author) ) + $post_author = $user_ID; + + $post_status = 'attachment'; + + // Are we updating or creating? + $update = false; + if ( !empty($ID) ) { + $update = true; + $post_ID = $ID; + } + + // Create a valid post name. + if ( empty($post_name) ) + $post_name = sanitize_title($post_title); + else + $post_name = sanitize_title($post_name); + + if (empty($post_date)) + $post_date = current_time('mysql'); + if (empty($post_date_gmt)) + $post_date_gmt = current_time('mysql', 1); + + if ( empty($comment_status) ) { + if ( $update ) + $comment_status = 'closed'; + else + $comment_status = get_settings('default_comment_status'); + } + if ( empty($ping_status) ) + $ping_status = get_settings('default_ping_status'); + if ( empty($post_pingback) ) + $post_pingback = get_option('default_pingback_flag'); + + if ( isset($to_ping) ) + $to_ping = preg_replace('|\s+|', "\n", $to_ping); + else + $to_ping = ''; + + if ( isset($post_parent) ) + $post_parent = (int) $post_parent; + else + $post_parent = 0; + + if ( isset($menu_order) ) + $menu_order = (int) $menu_order; + else + $menu_order = 0; + + if ( !isset($post_password) ) + $post_password = ''; + + if ( isset($to_ping) ) + $to_ping = preg_replace('|\s+|', "\n", $to_ping); + else + $to_ping = ''; + + if ( ! isset($pinged) ) + $pinged = ''; + + if ($update) { + $wpdb->query( + "UPDATE $wpdb->posts SET + post_author = '$post_author', + post_date = '$post_date', + post_date_gmt = '$post_date_gmt', + post_content = '$post_content', + post_title = '$post_title', + post_excerpt = '$post_excerpt', + post_status = '$post_status', + comment_status = '$comment_status', + ping_status = '$ping_status', + post_password = '$post_password', + post_name = '$post_name', + to_ping = '$to_ping', + pinged = '$pinged', + post_modified = '".current_time('mysql')."', + post_modified_gmt = '".current_time('mysql',1)."', + post_parent = '$post_parent', + menu_order = '$menu_order', + post_mime_type = '$post_mime_type', + guid = '$guid' + WHERE ID = $post_ID"); + } else { + $wpdb->query( + "INSERT INTO $wpdb->posts + (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid) + VALUES + ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type', '$guid')"); + $post_ID = $wpdb->insert_id; + } + + if ( empty($post_name) ) { + $post_name = sanitize_title($post_title, $post_ID); + $wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" ); + } + + wp_set_post_cats('', $post_ID, $post_category); + + if ( $file ) + add_post_meta($post_ID, '_wp_attached_file', $file); + + clean_post_cache($post_ID); + + if ( $update) { + do_action('edit_attachment', $post_ID); + } else { + do_action('add_attachment', $post_ID); + } + + return $post_ID; +} + +function wp_delete_attachment($postid) { + global $wpdb; + $postid = (int) $postid; + + if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") ) + return $post; + + if ( 'attachment' != $post->post_status ) + return false; + + $meta = get_post_meta($postid, '_wp_attachment_metadata', true); + $file = get_post_meta($postid, '_wp_attached_file', true); + + $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid"); + + $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = $postid"); + + $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = $postid"); + + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid"); + + if ( ! empty($meta['thumb']) ) { + // Don't delete the thumb if another attachment uses it + if (! $foo = $wpdb->get_row("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%".$wpdb->escape($meta['thumb'])."%' AND post_id <> $postid")) + @ unlink(str_replace(basename($file), $meta['thumb'], $file)); + } + + if ( ! empty($file) ) + @ unlink($file); + + do_action('delete_attachment', $postid); + + return $post; +} + +function wp_get_single_post($postid = 0, $mode = OBJECT) { + global $wpdb; + + $post = get_post($postid, $mode); + + // Set categories + if($mode == OBJECT) { + $post->post_category = wp_get_post_cats('',$postid); + } + else { + $post['post_category'] = wp_get_post_cats('',$postid); + } + + return $post; +} + +function wp_get_recent_posts($num = 10) { + global $wpdb; + + // Set the limit clause, if we got a limit + if ($num) { + $limit = "LIMIT $num"; + } + + $sql = "SELECT * FROM $wpdb->posts WHERE post_status IN ('publish', 'draft', 'private') ORDER BY post_date DESC $limit"; + $result = $wpdb->get_results($sql,ARRAY_A); + + return $result?$result:array(); +} + +function wp_update_post($postarr = array()) { + global $wpdb; + + if ( is_object($postarr) ) + $postarr = get_object_vars($postarr); + + // First, get all of the original fields + $post = wp_get_single_post($postarr['ID'], ARRAY_A); + + // Escape data pulled from DB. + $post = add_magic_quotes($post); + + // Passed post category list overwrites existing category list if not empty. + if ( isset($postarr['post_category']) && is_array($postarr['post_category']) + && 0 != count($postarr['post_category']) ) + $post_cats = $postarr['post_category']; + else + $post_cats = $post['post_category']; + + // Drafts shouldn't be assigned a date unless explicitly done so by the user + if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) && + ('0000-00-00 00:00:00' == $post['post_date']) ) + $clear_date = true; + else + $clear_date = false; + + // Merge old and new fields with new fields overwriting old ones. + $postarr = array_merge($post, $postarr); + $postarr['post_category'] = $post_cats; + if ( $clear_date ) { + $postarr['post_date'] = ''; + $postarr['post_date_gmt'] = ''; + } + + if ($postarr['post_status'] == 'attachment') + return wp_insert_attachment($postarr); + + return wp_insert_post($postarr); +} + +function wp_get_post_cats($blogid = '1', $post_ID = 0) { + global $wpdb; + + $sql = "SELECT category_id + FROM $wpdb->post2cat + WHERE post_id = $post_ID + ORDER BY category_id"; + + $result = $wpdb->get_col($sql); + + if ( !$result ) + $result = array(); + + return array_unique($result); +} + +function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) { + global $wpdb; + // If $post_categories isn't already an array, make it one: + if (!is_array($post_categories) || 0 == count($post_categories)) + $post_categories = array(get_option('default_category')); + + $post_categories = array_unique($post_categories); + + // First the old categories + $old_categories = $wpdb->get_col(" + SELECT category_id + FROM $wpdb->post2cat + WHERE post_id = $post_ID"); + + if (!$old_categories) { + $old_categories = array(); + } else { + $old_categories = array_unique($old_categories); + } + + // Delete any? + $delete_cats = array_diff($old_categories,$post_categories); + + if ($delete_cats) { + foreach ($delete_cats as $del) { + $wpdb->query(" + DELETE FROM $wpdb->post2cat + WHERE category_id = $del + AND post_id = $post_ID + "); + } + } + + // Add any? + $add_cats = array_diff($post_categories, $old_categories); + + if ($add_cats) { + foreach ($add_cats as $new_cat) { + $wpdb->query(" + INSERT INTO $wpdb->post2cat (post_id, category_id) + VALUES ($post_ID, $new_cat)"); + } + } + + // Update category counts. + $all_affected_cats = array_unique(array_merge($post_categories, $old_categories)); + foreach ( $all_affected_cats as $cat_id ) { + $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status='publish' AND category_id = '$cat_id'"); + $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'"); + wp_cache_delete($cat_id, 'category'); + } +} // wp_set_post_cats() + +function wp_delete_post($postid = 0) { + global $wpdb, $wp_rewrite; + $postid = (int) $postid; + + if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") ) + return $post; + + if ( 'attachment' == $post->post_status ) + return wp_delete_attachment($postid); + + do_action('delete_post', $postid); + + if ( 'publish' == $post->post_status) { + $categories = wp_get_post_cats('', $post->ID); + if( is_array( $categories ) ) { + foreach ( $categories as $cat_id ) { + $wpdb->query("UPDATE $wpdb->categories SET category_count = category_count - 1 WHERE cat_ID = '$cat_id'"); + wp_cache_delete($cat_id, 'category'); + } + } + } + + if ( 'static' == $post->post_status ) + $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_status = 'static'"); + + $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid"); + + $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = $postid"); + + $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = $postid"); + + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid"); + + if ( 'static' == $post->post_status ) { + wp_cache_delete('all_page_ids', 'pages'); + $wp_rewrite->flush_rules(); + } + + return $post; +} + +/**** /DB Functions ****/ + +/**** Misc ****/ + +// get permalink from post ID +function post_permalink($post_id = 0, $mode = '') { // $mode legacy + return get_permalink($post_id); +} + +// Get the name of a category from its ID +function get_cat_name($cat_id) { + global $wpdb; + + $cat_id -= 0; // force numeric + $name = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID=$cat_id"); + + return $name; +} + +// Get the ID of a category from its name +function get_cat_ID($cat_name='General') { + global $wpdb; + + $cid = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'"); + + return $cid?$cid:1; // default to cat 1 +} + +// Get author's preferred display name +function get_author_name( $auth_id ) { + $authordata = get_userdata( $auth_id ); + + return $authordata->display_name; +} + +// get extended entry info (<!--more-->) +function get_extended($post) { + list($main,$extended) = explode('<!--more-->', $post, 2); + + // Strip leading and trailing whitespace + $main = preg_replace('/^[\s]*(.*)[\s]*$/','\\1',$main); + $extended = preg_replace('/^[\s]*(.*)[\s]*$/','\\1',$extended); + + return array('main' => $main, 'extended' => $extended); +} + +// do trackbacks for a list of urls +// borrowed from edit.php +// accepts a comma-separated list of trackback urls and a post id +function trackback_url_list($tb_list, $post_id) { + if (!empty($tb_list)) { + // get post data + $postdata = wp_get_single_post($post_id, ARRAY_A); + + // import postdata as variables + extract($postdata); + + // form an excerpt + $excerpt = strip_tags($post_excerpt?$post_excerpt:$post_content); + + if (strlen($excerpt) > 255) { + $excerpt = substr($excerpt,0,252) . '...'; + } + + $trackback_urls = explode(',', $tb_list); + foreach($trackback_urls as $tb_url) { + $tb_url = trim($tb_url); + trackback($tb_url, stripslashes($post_title), $excerpt, $post_id); + } + } +} + +function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) { + global $wpdb; + + do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent); + + if ( preg_match_all('/&#(\d+);/', $comment . $author . $url, $chars) ) { + foreach ($chars[1] as $char) { + // If it's an encoded char in the normal ASCII set, reject + if ($char < 128) + return true; + } + } + + $mod_keys = trim( get_settings('blacklist_keys') ); + if ('' == $mod_keys ) + return false; // If moderation keys are empty + $words = explode("\n", $mod_keys ); + + foreach ($words as $word) { + $word = trim($word); + + // Skip empty lines + if ( empty($word) ) { continue; } + + // Do some escaping magic so that '#' chars in the + // spam words don't break things: + $word = preg_quote($word, '#'); + + $pattern = "#$word#i"; + if ( preg_match($pattern, $author ) ) return true; + if ( preg_match($pattern, $email ) ) return true; + if ( preg_match($pattern, $url ) ) return true; + if ( preg_match($pattern, $comment ) ) return true; + if ( preg_match($pattern, $user_ip ) ) return true; + if ( preg_match($pattern, $user_agent) ) return true; + } + + if ( isset($_SERVER['REMOTE_ADDR']) ) { + if ( wp_proxy_check($_SERVER['REMOTE_ADDR']) ) return true; + } + + return false; +} + +function wp_proxy_check($ipnum) { + if ( get_option('open_proxy_check') && isset($ipnum) ) { + $rev_ip = implode( '.', array_reverse( explode( '.', $ipnum ) ) ); + $lookup = $rev_ip . '.opm.blitzed.org.'; + if ( $lookup != gethostbyname( $lookup ) ) + return true; + } + + return false; +} + +function do_trackbacks($post_id) { + global $wpdb; + + $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $post_id"); + $to_ping = get_to_ping($post_id); + $pinged = get_pung($post_id); + if ( empty($to_ping) ) { + $wpdb->query("UPDATE $wpdb->posts SET to_ping = '' WHERE ID = '$post_id'"); + return; + } + + if (empty($post->post_excerpt)) + $excerpt = apply_filters('the_content', $post->post_content); + else + $excerpt = apply_filters('the_excerpt', $post->post_excerpt); + $excerpt = str_replace(']]>', ']]>', $excerpt); + $excerpt = strip_tags($excerpt); + if ( function_exists('mb_strcut') ) // For international trackbacks + $excerpt = mb_strcut($excerpt, 0, 252, get_settings('blog_charset')) . '...'; + else + $excerpt = substr($excerpt, 0, 252) . '...'; + + $post_title = apply_filters('the_title', $post->post_title); + $post_title = strip_tags($post_title); + + if ($to_ping) : foreach ($to_ping as $tb_ping) : + $tb_ping = trim($tb_ping); + if ( !in_array($tb_ping, $pinged) ) { + trackback($tb_ping, $post_title, $excerpt, $post_id); + $pinged[] = $tb_ping; + } else { + $wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_ping', '')) WHERE ID = '$post_id'"); + } + endforeach; endif; +} + +function get_pung($post_id) { // Get URIs already pung for a post + global $wpdb; + $pung = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_id"); + $pung = trim($pung); + $pung = preg_split('/\s/', $pung); + $pung = apply_filters('get_pung', $pung); + return $pung; +} + +function get_enclosed($post_id) { // Get enclosures already enclosed for a post + global $wpdb; + $custom_fields = get_post_custom( $post_id ); + $pung = array(); + if ( !is_array( $custom_fields ) ) + return $pung; + + foreach ( $custom_fields as $key => $val ) { + if ( 'enclosure' != $key || !is_array( $val ) ) + continue; + foreach( $val as $enc ) { + $enclosure = split( "\n", $enc ); + $pung[] = trim( $enclosure[ 0 ] ); + } + } + $pung = apply_filters('get_enclosed', $pung); + return $pung; +} + +function get_to_ping($post_id) { // Get any URIs in the todo list + global $wpdb; + $to_ping = $wpdb->get_var("SELECT to_ping FROM $wpdb->posts WHERE ID = $post_id"); + $to_ping = trim($to_ping); + $to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY); + $to_ping = apply_filters('get_to_ping', $to_ping); + return $to_ping; +} + +function add_ping($post_id, $uri) { // Add a URI to those already pung + global $wpdb; + $pung = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_id"); + $pung = trim($pung); + $pung = preg_split('/\s/', $pung); + $pung[] = $uri; + $new = implode("\n", $pung); + $new = apply_filters('add_ping', $new); + return $wpdb->query("UPDATE $wpdb->posts SET pinged = '$new' WHERE ID = $post_id"); +} + +//fetches the pages returned as a FLAT list, but arranged in order of their hierarchy, i.e., child parents +//immediately follow their parents +function get_page_hierarchy($posts, $parent = 0) { + $result = array ( ); + if ($posts) { foreach ($posts as $post) { + if ($post->post_parent == $parent) { + $result[$post->ID] = $post->post_name; + $children = get_page_hierarchy($posts, $post->ID); + $result += $children; //append $children to $result + } + } } + return $result; +} + +function generate_page_rewrite_rules() { + global $wpdb; + + //get pages in order of hierarchy, i.e. children after parents + $posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_status = 'static'")); + //now reverse it, because we need parents after children for rewrite rules to work properly + $posts = array_reverse($posts, true); + + $page_rewrite_rules = array(); + $page_attachment_rewrite_rules = array(); + + if ($posts) { + + foreach ($posts as $id => $post) { + + // URI => page name + $uri = get_page_uri($id); + $attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_status = 'attachment' AND post_parent = '$id'"); + if ( $attachments ) { + foreach ( $attachments as $attachment ) { + $attach_uri = get_page_uri($attachment->ID); + $page_attachment_rewrite_rules[$attach_uri] = $attachment->post_name; + } + } + + $page_rewrite_rules[$uri] = $post; + } + + update_option('page_uris', $page_rewrite_rules); + + if ( $page_attachment_rewrite_rules ) + update_option('page_attachment_uris', $page_attachment_rewrite_rules); + } +} + +function get_post_status($ID = '') { + $post = get_post($ID); + + if ( is_object($post) ) { + if ( ('attachment' == $post->post_status) && $post->post_parent && ($post->ID != $post->post_parent) ) + return get_post_status($post->post_parent); + else + return $post->post_status; + } + + return false; +} + +// Takes a post ID, returns its mime type. +function get_post_mime_type($ID = '') { + $post = & get_post($ID); + + if ( is_object($post) ) + return $post->post_mime_type; + + return false; +} + +function get_attached_file($attachment_id) { + return get_post_meta($attachment_id, '_wp_attached_file', true); +} + +function wp_mkdir_p($target) { + // from php.net/mkdir user contributed notes + if (file_exists($target)) { + if (! @ is_dir($target)) + return false; + else + return true; + } + + // Attempting to create the directory may clutter up our display. + if (@ mkdir($target)) { + $stat = @ stat(dirname($target)); + $dir_perms = $stat['mode'] & 0007777; // Get the permission bits. + @ chmod($target, $dir_perms); + return true; + } else { + if ( is_dir(dirname($target)) ) + return false; + } + + // If the above failed, attempt to create the parent node, then try again. + if (wp_mkdir_p(dirname($target))) + return wp_mkdir_p($target); + + return false; +} + +// Returns an array containing the current upload directory's path and url, or an error message. +function wp_upload_dir() { + $siteurl = get_settings('siteurl'); + //prepend ABSPATH to $dir and $siteurl to $url if they're not already there + $path = str_replace(ABSPATH, '', trim(get_settings('upload_path'))); + $dir = ABSPATH . $path; + $url = trailingslashit($siteurl) . $path; + + if ( $dir == ABSPATH ) { //the option was empty + $dir = ABSPATH . 'wp-content/uploads'; + } + + if ( defined('UPLOADS') ) { + $dir = ABSPATH . UPLOADS; + $url = trailingslashit($siteurl) . UPLOADS; + } + + if ( get_settings('uploads_use_yearmonth_folders')) { + // Generate the yearly and monthly dirs + $time = current_time( 'mysql' ); + $y = substr( $time, 0, 4 ); + $m = substr( $time, 5, 2 ); + $dir = $dir . "/$y/$m"; + $url = $url . "/$y/$m"; + } + + // Make sure we have an uploads dir + if ( ! wp_mkdir_p( $dir ) ) { + $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), $dir); + return array('error' => $message); + } + + $uploads = array('path' => $dir, 'url' => $url, 'error' => false); + return apply_filters('upload_dir', $uploads); +} + +function wp_upload_bits($name, $type, $bits) { + if ( empty($name) ) + return array('error' => "Empty filename"); + + $upload = wp_upload_dir(); + + if ( $upload['error'] !== false ) + return $upload; + + $number = ''; + $filename = $name; + $path_parts = pathinfo($filename); + $ext = $path_parts['extension']; + if ( empty($ext) ) + $ext = ''; + else + $ext = ".$ext"; + while ( file_exists($upload['path'] . "/$filename") ) { + if ( '' == "$number$ext" ) + $filename = $filename . ++$number . $ext; + else + $filename = str_replace("$number$ext", ++$number . $ext, $filename); + } + + $new_file = $upload['path'] . "/$filename"; + if ( ! wp_mkdir_p( dirname($new_file) ) ) { + $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), dirname($new_file)); + return array('error' => $message); + } + + $ifp = @ fopen($new_file, 'wb'); + if ( ! $ifp ) + return array('error' => "Could not write file $new_file."); + + $success = @ fwrite($ifp, $bits); + fclose($ifp); + // Set correct file permissions + $stat = @ stat(dirname($new_file)); + $perms = $stat['mode'] & 0007777; + $perms = $perms & 0000666; + @ chmod($new_file, $perms); + + // Compute the URL + $url = $upload['url'] . "/$filename"; + + return array('file' => $new_file, 'url' => $url, 'error' => false); +} + +?> diff --git a/wp-includes/functions.php b/wp-includes/functions.php new file mode 100644 index 00000000..c6f6ea7a --- /dev/null +++ b/wp-includes/functions.php @@ -0,0 +1,2290 @@ +<?php + +require_once(dirname(__FILE__).'/functions-compat.php'); + +if ( !function_exists('_') ) { + function _($string) { + return $string; + } +} + +function get_profile($field, $user = false) { + global $wpdb; + if ( !$user ) + $user = $wpdb->escape($_COOKIE[USER_COOKIE]); + return $wpdb->get_var("SELECT $field FROM $wpdb->users WHERE user_login = '$user'"); +} + +function mysql2date($dateformatstring, $mysqlstring, $translate = true) { + global $month, $weekday, $month_abbrev, $weekday_abbrev; + $m = $mysqlstring; + if ( empty($m) ) { + return false; + } + $i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4)); + + if ( -1 == $i || false == $i ) + $i = 0; + + if ( !empty($month) && !empty($weekday) && $translate ) { + $datemonth = $month[date('m', $i)]; + $datemonth_abbrev = $month_abbrev[$datemonth]; + $dateweekday = $weekday[date('w', $i)]; + $dateweekday_abbrev = $weekday_abbrev[$dateweekday]; + $dateformatstring = ' '.$dateformatstring; + $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring); + $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring); + $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring); + $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring); + + $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1); + } + $j = @date($dateformatstring, $i); + if ( !$j ) { + // for debug purposes + // echo $i." ".$mysqlstring; + } + return $j; +} + +function current_time($type, $gmt = 0) { + switch ($type) { + case 'mysql': + if ( $gmt ) $d = gmdate('Y-m-d H:i:s'); + else $d = gmdate('Y-m-d H:i:s', (time() + (get_settings('gmt_offset') * 3600))); + return $d; + break; + case 'timestamp': + if ( $gmt ) $d = time(); + else $d = time() + (get_settings('gmt_offset') * 3600); + return $d; + break; + } +} + +function date_i18n($dateformatstring, $unixtimestamp) { + global $month, $weekday, $month_abbrev, $weekday_abbrev; + $i = $unixtimestamp; + if ( (!empty($month)) && (!empty($weekday)) ) { + $datemonth = $month[date('m', $i)]; + $datemonth_abbrev = $month_abbrev[$datemonth]; + $dateweekday = $weekday[date('w', $i)]; + $dateweekday_abbrev = $weekday_abbrev[$dateweekday]; + $dateformatstring = ' '.$dateformatstring; + $dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring); + $dateformatstring = preg_replace("/([^\\\])F/", "\${1}".backslashit($datemonth), $dateformatstring); + $dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring); + $dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring); + $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1); + } + $j = @date($dateformatstring, $i); + return $j; + } + +function get_weekstartend($mysqlstring, $start_of_week) { + $my = substr($mysqlstring,0,4); + $mm = substr($mysqlstring,8,2); + $md = substr($mysqlstring,5,2); + $day = mktime(0,0,0, $md, $mm, $my); + $weekday = date('w',$day); + $i = 86400; + + if ( $weekday < get_settings('start_of_week') ) + $weekday = 7 - (get_settings('start_of_week') - $weekday); + + while ($weekday > get_settings('start_of_week')) { + $weekday = date('w',$day); + if ( $weekday < get_settings('start_of_week') ) + $weekday = 7 - (get_settings('start_of_week') - $weekday); + + $day = $day - 86400; + $i = 0; + } + $week['start'] = $day + 86400 - $i; + // $week['end'] = $day - $i + 691199; + $week['end'] = $week['start'] + 604799; + return $week; +} + +function get_lastpostdate($timezone = 'server') { + global $cache_lastpostdate, $pagenow, $wpdb; + $add_seconds_blog = get_settings('gmt_offset') * 3600; + $add_seconds_server = date('Z'); + $now = current_time('mysql', 1); + if ( !isset($cache_lastpostdate[$timezone]) ) { + switch(strtolower($timezone)) { + case 'gmt': + $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); + break; + case 'blog': + $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); + break; + case 'server': + $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); + break; + } + $cache_lastpostdate[$timezone] = $lastpostdate; + } else { + $lastpostdate = $cache_lastpostdate[$timezone]; + } + return $lastpostdate; +} + +function get_lastpostmodified($timezone = 'server') { + global $cache_lastpostmodified, $pagenow, $wpdb; + $add_seconds_blog = get_settings('gmt_offset') * 3600; + $add_seconds_server = date('Z'); + $now = current_time('mysql', 1); + if ( !isset($cache_lastpostmodified[$timezone]) ) { + switch(strtolower($timezone)) { + case 'gmt': + $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); + break; + case 'blog': + $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); + break; + case 'server': + $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); + break; + } + $lastpostdate = get_lastpostdate($timezone); + if ( $lastpostdate > $lastpostmodified ) { + $lastpostmodified = $lastpostdate; + } + $cache_lastpostmodified[$timezone] = $lastpostmodified; + } else { + $lastpostmodified = $cache_lastpostmodified[$timezone]; + } + return $lastpostmodified; +} + +function user_pass_ok($user_login,$user_pass) { + global $cache_userdata; + if ( empty($cache_userdata[$user_login]) ) { + $userdata = get_userdatabylogin($user_login); + } else { + $userdata = $cache_userdata[$user_login]; + } + return (md5($user_pass) == $userdata->user_pass); +} + + +function get_usernumposts($userid) { + global $wpdb; + return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_status = 'publish'"); +} + + +// examine a url (supposedly from this blog) and try to +// determine the post ID it represents. +function url_to_postid($url) { + global $wp_rewrite; + + // First, check to see if there is a 'p=N' or 'page_id=N' to match against + preg_match('#[?&](p|page_id)=(\d+)#', $url, $values); + $id = intval($values[2]); + if ( $id ) return $id; + + // Check to see if we are using rewrite rules + $rewrite = $wp_rewrite->wp_rewrite_rules(); + + // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options + if ( empty($rewrite) ) + return 0; + + // $url cleanup by Mark Jaquith + // This fixes things like #anchors, ?query=strings, missing 'www.', + // added 'www.', or added 'index.php/' that will mess up our WP_Query + // and return a false negative + + // Get rid of the #anchor + $url_split = explode('#', $url); + $url = $url_split[0]; + + // Get rid of URI ?query=string + $url_split = explode('?', $url); + $url = $url_split[0]; + + // Add 'www.' if it is absent and should be there + if ( false !== strpos(get_settings('home'), '://www.') && false === strpos($url, '://www.') ) + $url = str_replace('://', '://www.', $url); + + // Strip 'www.' if it is present and shouldn't be + if ( false === strpos(get_settings('home'), '://www.') ) + $url = str_replace('://www.', '://', $url); + + // Strip 'index.php/' if we're not using path info permalinks + if ( false === strpos($rewrite, 'index.php/') ) + $url = str_replace('index.php/', '', $url); + + if ( false !== strpos($url, get_settings('home')) ) { + // Chop off http://domain.com + $url = str_replace(get_settings('home'), '', $url); + } else { + // Chop off /path/to/blog + $home_path = parse_url(get_settings('home')); + $home_path = $home_path['path']; + $url = str_replace($home_path, '', $url); + } + + // Trim leading and lagging slashes + $url = trim($url, '/'); + + $request = $url; + + // Done with cleanup + + // Look for matches. + $request_match = $request; + foreach ($rewrite as $match => $query) { + // If the requesting file is the anchor of the match, prepend it + // to the path info. + if ( (! empty($url)) && (strpos($match, $url) === 0) ) { + $request_match = $url . '/' . $request; + } + + if ( preg_match("!^$match!", $request_match, $matches) ) { + // Got a match. + // Trim the query of everything up to the '?'. + $query = preg_replace("!^.+\?!", '', $query); + + // Substitute the substring matches into the query. + eval("\$query = \"$query\";"); + $query = new WP_Query($query); + if ( $query->is_single || $query->is_page ) + return $query->post->ID; + else + return 0; + } + } + return 0; +} + + +function maybe_unserialize($original) { + if ( false !== $gm = @ unserialize($original) ) + return $gm; + else + return $original; +} + +/* Options functions */ + +function get_settings($setting) { + global $wpdb; + + $value = wp_cache_get($setting, 'options'); + + if ( false === $value ) { + if ( defined('WP_INSTALLING') ) + $wpdb->hide_errors(); + $row = $wpdb->get_row("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1"); + if ( defined('WP_INSTALLING') ) + $wpdb->show_errors(); + + if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values + $value = $row->option_value; + wp_cache_set($setting, $value, 'options'); + } else { + return false; + } + } + + // If home is not set use siteurl. + if ( 'home' == $setting && '' == $value ) + return get_settings('siteurl'); + + if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting ) + $value = preg_replace('|/+$|', '', $value); + + return apply_filters( 'option_' . $setting, maybe_unserialize($value) ); +} + +function get_option($option) { + return get_settings($option); +} + +function get_user_option( $option, $user = 0 ) { + global $wpdb, $current_user; + + if ( empty($user) ) + $user = $current_user; + else + $user = get_userdata($user); + + if ( isset( $user->{$wpdb->prefix . $option} ) ) // Blog specific + return $user->{$wpdb->prefix . $option}; + elseif ( isset( $user->{$option} ) ) // User specific and cross-blog + return $user->{$option}; + else // Blog global + return get_option( $option ); +} + +function form_option($option) { + echo htmlspecialchars( get_option($option), ENT_QUOTES ); +} + +function get_alloptions() { + global $wpdb, $wp_queries; + $wpdb->hide_errors(); + if ( !$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'") ) { + $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); + } + $wpdb->show_errors(); + + foreach ($options as $option) { + // "When trying to design a foolproof system, + // never underestimate the ingenuity of the fools :)" -- Dougal + if ( 'siteurl' == $option->option_name ) + $option->option_value = preg_replace('|/+$|', '', $option->option_value); + if ( 'home' == $option->option_name ) + $option->option_value = preg_replace('|/+$|', '', $option->option_value); + if ( 'category_base' == $option->option_name ) + $option->option_value = preg_replace('|/+$|', '', $option->option_value); + $value = maybe_unserialize($option->option_value); + $all_options->{$option->option_name} = apply_filters('pre_option_' . $option->option_name, $value); + } + return apply_filters('all_options', $all_options); +} + +function update_option($option_name, $newvalue) { + global $wpdb; + + if ( is_string($newvalue) ) + $newvalue = trim($newvalue); + + // If the new and old values are the same, no need to update. + $oldvalue = get_option($option_name); + if ( $newvalue == $oldvalue ) { + return false; + } + + if ( false === $oldvalue ) { + add_option($option_name, $newvalue); + return true; + } + + if ( is_array($newvalue) || is_object($newvalue) ) + $newvalue = serialize($newvalue); + + wp_cache_set($option_name, $newvalue, 'options'); + + $newvalue = $wpdb->escape($newvalue); + $option_name = $wpdb->escape($option_name); + $wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'"); + if ( $wpdb->rows_affected == 1 ) { + do_action("update_option_{$option_name}", $oldvalue, $newvalue); + return true; + } + return false; +} + +function update_user_option( $user_id, $option_name, $newvalue, $global = false ) { + global $wpdb; + if ( !$global ) + $option_name = $wpdb->prefix . $option_name; + return update_usermeta( $user_id, $option_name, $newvalue ); +} + +// thx Alex Stapleton, http://alex.vort-x.net/blog/ +function add_option($name, $value = '', $description = '', $autoload = 'yes') { + global $wpdb; + + // Make sure the option doesn't already exist + if ( false !== get_option($name) ) + return; + + if ( is_array($value) || is_object($value) ) + $value = serialize($value); + + wp_cache_set($name, $value, 'options'); + + $name = $wpdb->escape($name); + $value = $wpdb->escape($value); + $description = $wpdb->escape($description); + $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, option_description, autoload) VALUES ('$name', '$value', '$description', '$autoload')"); + + return; +} + +function delete_option($name) { + global $wpdb; + // Get the ID, if no ID then return + $option_id = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = '$name'"); + if ( !$option_id ) return false; + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name = '$name'"); + wp_cache_delete($name, 'options'); + return true; +} + +function add_post_meta($post_id, $key, $value, $unique = false) { + global $wpdb, $post_meta_cache; + + if ( $unique ) { + if ( $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key += '$key' AND post_id = '$post_id'") ) { + return false; + } + } + + $original = $value; + if ( is_array($value) || is_object($value) ) + $value = $wpdb->escape(serialize($value)); + + $wpdb->query("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value) VALUES ('$post_id','$key','$value')"); + + $post_meta_cache['$post_id'][$key][] = $original; + + return true; +} + +function delete_post_meta($post_id, $key, $value = '') { + global $wpdb, $post_meta_cache; + + if ( empty($value) ) { + $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE +post_id = '$post_id' AND meta_key = '$key'"); + } else { + $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE +post_id = '$post_id' AND meta_key = '$key' AND meta_value = '$value'"); + } + + if ( !$meta_id ) + return false; + + if ( empty($value) ) { + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id' +AND meta_key = '$key'"); + unset($post_meta_cache['$post_id'][$key]); + } else { + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id' +AND meta_key = '$key' AND meta_value = '$value'"); + $cache_key = $post_meta_cache['$post_id'][$key]; + if ($cache_key) foreach ( $cache_key as $index => $data ) + if ( $data == $value ) + unset($post_meta_cache['$post_id'][$key][$index]); + } + + unset($post_meta_cache['$post_id'][$key]); + + return true; +} + +function get_post_meta($post_id, $key, $single = false) { + global $wpdb, $post_meta_cache; + + if ( isset($post_meta_cache[$post_id][$key]) ) { + if ( $single ) { + return maybe_unserialize( $post_meta_cache[$post_id][$key][0] ); + } else { + return maybe_unserialize( $post_meta_cache[$post_id][$key] ); + } + } + + $metalist = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = '$post_id' AND meta_key = '$key'", ARRAY_N); + + $values = array(); + if ( $metalist ) { + foreach ($metalist as $metarow) { + $values[] = $metarow[0]; + } + } + + if ( $single ) { + if ( count($values) ) { + $return = maybe_unserialize( $values[0] ); + } else { + return ''; + } + } else { + $return = $values; + } + + return maybe_unserialize($return); +} + +function update_post_meta($post_id, $key, $value, $prev_value = '') { + global $wpdb, $post_meta_cache; + + $original_value = $value; + if ( is_array($value) || is_object($value) ) + $value = $wpdb->escape(serialize($value)); + + $original_prev = $prev_value; + if ( is_array($prev_value) || is_object($prev_value) ) + $prev_value = $wpdb->escape(serialize($prev_value)); + + if (! $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key += '$key' AND post_id = '$post_id'") ) { + return false; + } + + if ( empty($prev_value) ) { + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE +meta_key = '$key' AND post_id = '$post_id'"); + $cache_key = $post_meta_cache['$post_id'][$key]; + if ( !empty($cache_key) ) + foreach ($cache_key as $index => $data) + $post_meta_cache['$post_id'][$key][$index] = $original_value; + } else { + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE +meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'"); + $cache_key = $post_meta_cache['$post_id'][$key]; + if ( !empty($cache_key) ) + foreach ($cache_key as $index => $data) + if ( $data == $original_prev ) + $post_meta_cache['$post_id'][$key][$index] = $original_value; + } + + return true; +} + +// Deprecated. Use get_post(). +function get_postdata($postid) { + $post = &get_post($postid); + + $postdata = array ( + 'ID' => $post->ID, + 'Author_ID' => $post->post_author, + 'Date' => $post->post_date, + 'Content' => $post->post_content, + 'Excerpt' => $post->post_excerpt, + 'Title' => $post->post_title, + 'Category' => $post->post_category, + 'post_status' => $post->post_status, + 'comment_status' => $post->comment_status, + 'ping_status' => $post->ping_status, + 'post_password' => $post->post_password, + 'to_ping' => $post->to_ping, + 'pinged' => $post->pinged, + 'post_name' => $post->post_name + ); + + return $postdata; +} + +// Retrieves post data given a post ID or post object. +// Handles post caching. +function &get_post(&$post, $output = OBJECT) { + global $post_cache, $wpdb; + + if ( empty($post) ) { + if ( isset($GLOBALS['post']) ) + $_post = & $GLOBALS['post']; + else + $_post = null; + } elseif ( is_object($post) ) { + if ( 'static' == $post->post_status ) + return get_page($post, $output); + if ( !isset($post_cache[$post->ID]) ) + $post_cache[$post->ID] = &$post; + $_post = & $post_cache[$post->ID]; + } else { + if ( $_post = wp_cache_get($post, 'pages') ) + return get_page($_post, $output); + elseif ( isset($post_cache[$post]) ) + $_post = & $post_cache[$post]; + else { + $query = "SELECT * FROM $wpdb->posts WHERE ID = '$post' LIMIT 1"; + $_post = & $wpdb->get_row($query); + if ( 'static' == $_post->post_status ) + return get_page($_post, $output); + $post_cache[$post] = & $_post; + } + } + + if ( defined(WP_IMPORTING) ) + unset($post_cache); + + if ( $output == OBJECT ) { + return $_post; + } elseif ( $output == ARRAY_A ) { + return get_object_vars($_post); + } elseif ( $output == ARRAY_N ) { + return array_values(get_object_vars($_post)); + } else { + return $_post; + } +} + +function &get_children($post = 0, $output = OBJECT) { + global $post_cache, $wpdb; + + if ( empty($post) ) { + if ( isset($GLOBALS['post']) ) + $post_parent = & $GLOBALS['post']->post_parent; + else + return false; + } elseif ( is_object($post) ) { + $post_parent = $post->post_parent; + } else { + $post_parent = $post; + } + + $post_parent = (int) $post_parent; + + $query = "SELECT * FROM $wpdb->posts WHERE post_parent = $post_parent"; + + $children = $wpdb->get_results($query); + + if ( $children ) { + foreach ( $children as $key => $child ) { + $post_cache[$child->ID] =& $children[$key]; + $kids[$child->ID] =& $children[$key]; + } + } else { + return false; + } + + if ( $output == OBJECT ) { + return $kids; + } elseif ( $output == ARRAY_A ) { + foreach ( $kids as $kid ) + $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]); + return $weeuns; + } elseif ( $output == ARRAY_N ) { + foreach ( $kids as $kid ) + $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID])); + return $babes; + } else { + return $kids; + } +} + +function set_page_path($page) { + $page->fullpath = '/' . $page->post_name; + $path = $page->fullpath; + $curpage = $page; + while ($curpage->post_parent != 0) { + $curpage = get_page($curpage->post_parent); + $path = '/' . $curpage->post_name . $path; + } + + $page->fullpath = $path; + + return $page; +} + +// Retrieves page data given a page ID or page object. +// Handles page caching. +function &get_page(&$page, $output = OBJECT) { + global $wpdb; + + if ( empty($page) ) { + if ( isset($GLOBALS['page']) ) { + $_page = & $GLOBALS['page']; + wp_cache_add($_page->ID, $_page, 'pages'); + } else { + $_page = null; + } + } elseif ( is_object($page) ) { + if ( 'static' != $page->post_status ) + return get_post($page, $output); + wp_cache_add($page->ID, $page, 'pages'); + $_page = $page; + } else { + if ( isset($GLOBALS['page']) && ($page == $GLOBALS['page']->ID) ) { + $_page = & $GLOBALS['page']; + wp_cache_add($_page->ID, $_page, 'pages'); + } elseif ( $_page = $GLOBALS['post_cache'][$page] ) { + return get_post($page, $output); + } elseif ( $_page = wp_cache_get($page, 'pages') ) { + // Got it. + } else { + $query = "SELECT * FROM $wpdb->posts WHERE ID= '$page' LIMIT 1"; + $_page = & $wpdb->get_row($query); + if ( 'static' != $_page->post_status ) + return get_post($_page, $output); + wp_cache_add($_page->ID, $_page, 'pages'); + } + } + + if (!isset($_page->fullpath)) { + $_page = set_page_path($_page); + wp_cache_replace($_page->cat_ID, $_page, 'pages'); + } + + if ( $output == OBJECT ) { + return $_page; + } elseif ( $output == ARRAY_A ) { + return get_object_vars($_page); + } elseif ( $output == ARRAY_N ) { + return array_values(get_object_vars($_page)); + } else { + return $_page; + } +} + +function set_category_path($cat) { + $cat->fullpath = '/' . $cat->category_nicename; + $path = $cat->fullpath; + $curcat = $cat; + while ($curcat->category_parent != 0) { + $curcat = get_category($curcat->category_parent); + $path = '/' . $curcat->category_nicename . $path; + } + + $cat->fullpath = $path; + + return $cat; +} + +// Retrieves category data given a category ID or category object. +// Handles category caching. +function &get_category(&$category, $output = OBJECT) { + global $wpdb; + + if ( empty($category) ) + return null; + + if ( is_object($category) ) { + wp_cache_add($category->cat_ID, $category, 'category'); + $_category = $category; + } else { + if ( ! $_category = wp_cache_get($category, 'category') ) { + $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1"); + wp_cache_add($category, $_category, 'category'); + } + } + + if ( !isset($_category->fullpath) ) { + $_category = set_category_path($_category); + wp_cache_replace($_category->cat_ID, $_category, 'category'); + } + + if ( $output == OBJECT ) { + return $_category; + } elseif ( $output == ARRAY_A ) { + return get_object_vars($_category); + } elseif ( $output == ARRAY_N ) { + return array_values(get_object_vars($_category)); + } else { + return $_category; + } +} + +// Retrieves comment data given a comment ID or comment object. +// Handles comment caching. +function &get_comment(&$comment, $output = OBJECT) { + global $comment_cache, $wpdb; + + if ( empty($comment) ) + return null; + + if ( is_object($comment) ) { + if ( !isset($comment_cache[$comment->comment_ID]) ) + $comment_cache[$comment->comment_ID] = &$comment; + $_comment = & $comment_cache[$comment->comment_ID]; + } else { + if ( !isset($comment_cache[$comment]) ) { + $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1"); + $comment_cache[$comment->comment_ID] = & $_comment; + } else { + $_comment = & $comment_cache[$comment]; + } + } + + if ( $output == OBJECT ) { + return $_comment; + } elseif ( $output == ARRAY_A ) { + return get_object_vars($_comment); + } elseif ( $output == ARRAY_N ) { + return array_values(get_object_vars($_comment)); + } else { + return $_comment; + } +} + +function get_catname($cat_ID) { + $category = &get_category($cat_ID); + return $category->cat_name; +} + +function get_all_category_ids() { + global $wpdb; + + if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) { + $cat_ids = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories"); + wp_cache_add('all_category_ids', $cat_ids, 'category'); + } + + return $cat_ids; +} + +function get_all_page_ids() { + global $wpdb; + + if ( ! $page_ids = wp_cache_get('all_page_ids', 'pages') ) { + $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status='static'"); + wp_cache_add('all_page_ids', $page_ids, 'pages'); + } + + return $page_ids; +} + +function gzip_compression() { + if ( !get_settings('gzipcompression') ) return false; + + if ( extension_loaded('zlib') ) { + ob_start('ob_gzhandler'); + } +} + + +// functions to count the page generation time (from phpBB2) +// ( or just any time between timer_start() and timer_stop() ) + +function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal + global $timestart, $timeend; + $mtime = microtime(); + $mtime = explode(' ',$mtime); + $mtime = $mtime[1] + $mtime[0]; + $timeend = $mtime; + $timetotal = $timeend-$timestart; + if ( $display ) + echo number_format($timetotal,$precision); + return $timetotal; +} + +function weblog_ping($server = '', $path = '') { + global $wp_version; + include_once (ABSPATH . WPINC . '/class-IXR.php'); + + // using a timeout of 3 seconds should be enough to cover slow servers + $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path)); + $client->timeout = 3; + $client->useragent .= ' -- WordPress/'.$wp_version; + + // when set to true, this outputs debug messages by itself + $client->debug = false; + $home = trailingslashit( get_option('home') ); + if ( !$client->query('weblogUpdates.extendedPing', get_settings('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping + $client->query('weblogUpdates.ping', get_settings('blogname'), $home); +} + +function generic_ping($post_id = 0) { + $services = get_settings('ping_sites'); + $services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines + $services = trim($services); + if ( '' != $services ) { + $services = explode("\n", $services); + foreach ($services as $service) { + weblog_ping($service); + } + } + + return $post_id; +} + +// Send a Trackback +function trackback($trackback_url, $title, $excerpt, $ID) { + global $wpdb, $wp_version; + + if ( empty($trackback_url) ) + return; + + $title = urlencode($title); + $excerpt = urlencode($excerpt); + $blog_name = urlencode(get_settings('blogname')); + $tb_url = $trackback_url; + $url = urlencode(get_permalink($ID)); + $query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt"; + $trackback_url = parse_url($trackback_url); + $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'.$trackback_url['query'] : '') . " HTTP/1.0\r\n"; + $http_request .= 'Host: '.$trackback_url['host']."\r\n"; + $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n"; + $http_request .= 'Content-Length: '.strlen($query_string)."\r\n"; + $http_request .= "User-Agent: WordPress/" . $wp_version; + $http_request .= "\r\n\r\n"; + $http_request .= $query_string; + if ( '' == $trackback_url['port'] ) + $trackback_url['port'] = 80; + $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4); + @fputs($fs, $http_request); +/* + $debug_file = 'trackback.log'; + $fp = fopen($debug_file, 'a'); + fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"); + while(!@feof($fs)) { + fwrite($fp, @fgets($fs, 4096)); + } + fwrite($fp, "\n\n"); + fclose($fp); +*/ + @fclose($fs); + + $tb_url = addslashes( $tb_url ); + $wpdb->query("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'"); + return $wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_url', '')) WHERE ID = '$ID'"); +} + +function make_url_footnote($content) { + preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches); + $j = 0; + for ($i=0; $i<count($matches[0]); $i++) { + $links_summary = (!$j) ? "\n" : $links_summary; + $j++; + $link_match = $matches[0][$i]; + $link_number = '['.($i+1).']'; + $link_url = $matches[2][$i]; + $link_text = $matches[4][$i]; + $content = str_replace($link_match, $link_text.' '.$link_number, $content); + $link_url = ((strtolower(substr($link_url,0,7)) != 'http://') && (strtolower(substr($link_url,0,8)) != 'https://')) ? get_settings('home') . $link_url : $link_url; + $links_summary .= "\n".$link_number.' '.$link_url; + } + $content = strip_tags($content); + $content .= $links_summary; + return $content; +} + + +function xmlrpc_getposttitle($content) { + global $post_default_title; + if ( preg_match('/<title>(.+?)<\/title>/is', $content, $matchtitle) ) { + $post_title = $matchtitle[0]; + $post_title = preg_replace('/<title>/si', '', $post_title); + $post_title = preg_replace('/<\/title>/si', '', $post_title); + } else { + $post_title = $post_default_title; + } + return $post_title; +} + +function xmlrpc_getpostcategory($content) { + global $post_default_category; + if ( preg_match('/<category>(.+?)<\/category>/is', $content, $matchcat) ) { + $post_category = trim($matchcat[1], ','); + $post_category = explode(',', $post_category); + } else { + $post_category = $post_default_category; + } + return $post_category; +} + +function xmlrpc_removepostdata($content) { + $content = preg_replace('/<title>(.+?)<\/title>/si', '', $content); + $content = preg_replace('/<category>(.+?)<\/category>/si', '', $content); + $content = trim($content); + return $content; +} + +function debug_fopen($filename, $mode) { + global $debug; + if ( $debug == 1 ) { + $fp = fopen($filename, $mode); + return $fp; + } else { + return false; + } +} + +function debug_fwrite($fp, $string) { + global $debug; + if ( $debug == 1 ) { + fwrite($fp, $string); + } +} + +function debug_fclose($fp) { + global $debug; + if ( $debug == 1 ) { + fclose($fp); + } +} + +function spawn_pinger() { + global $wpdb; + $doping = false; + if ( $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' LIMIT 1") ) + $doping = true; + + if ( $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_pingme' OR meta_key = '_encloseme' LIMIT 1") ) + $doping = true; + + if ( substr(php_sapi_name(), 0, 3) == 'cgi' ) + return $doping; + + if ( $doping ) { + $ping_url = get_settings('siteurl') .'/wp-admin/execute-pings.php'; + $parts = parse_url($ping_url); + $argyle = @ fsockopen($parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01); + if ( $argyle ) + fputs($argyle, "GET {$parts['path']}?time=".time()." HTTP/1.0\r\nHost: {$_SERVER['HTTP_HOST']}\r\n\r\n"); + } +} + +function do_enclose( $content, $post_ID ) { + global $wp_version, $wpdb; + include_once (ABSPATH . WPINC . '/class-IXR.php'); + + $log = debug_fopen(ABSPATH . '/enclosures.log', 'a'); + $post_links = array(); + debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n"); + + $pung = get_enclosed( $post_ID ); + + $ltrs = '\w'; + $gunk = '/#~:.?+=&%@!\-'; + $punc = '.:?\-'; + $any = $ltrs . $gunk . $punc; + + preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp); + + debug_fwrite($log, 'Post contents:'); + debug_fwrite($log, $content."\n"); + + foreach($post_links_temp[0] as $link_test) : + if ( !in_array($link_test, $pung) ) : // If we haven't pung it already + $test = parse_url($link_test); + if ( isset($test['query']) ) + $post_links[] = $link_test; + elseif (($test['path'] != '/') && ($test['path'] != '')) + $post_links[] = $link_test; + endif; + endforeach; + + foreach ($post_links as $url) : + if ( $url != '' && !$wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE post_id = '$post_ID' AND meta_key = 'enclosure' AND meta_value LIKE ('$url%')") ) { + if ( $headers = wp_get_http_headers( $url) ) { + $len = (int) $headers['content-length']; + $type = $wpdb->escape( $headers['content-type'] ); + $allowed_types = array( 'video', 'audio' ); + if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) { + $meta_value = "$url\n$len\n$type\n"; + $wpdb->query( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` ) + VALUES ( '$post_ID', 'enclosure' , '$meta_value')" ); + } + } + } + endforeach; +} + +function wp_get_http_headers( $url, $red = 1 ) { + global $wp_version; + @set_time_limit( 60 ); + + if ( $red > 5 ) + return false; + + $parts = parse_url( $url ); + $file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : ''); + $host = $parts['host']; + if ( !isset( $parts['port'] ) ) + $parts['port'] = 80; + + $head = "HEAD $file HTTP/1.1\r\nHOST: $host\r\nUser-Agent: WordPress/" . $wp_version . "\r\n\r\n"; + + $fp = @fsockopen($host, $parts['port'], $err_num, $err_msg, 3); + if ( !$fp ) + return false; + + $response = ''; + fputs( $fp, $head ); + while ( !feof( $fp ) && strpos( $response, "\r\n\r\n" ) == false ) + $response .= fgets( $fp, 2048 ); + fclose( $fp ); + preg_match_all('/(.*?): (.*)\r/', $response, $matches); + $count = count($matches[1]); + for ( $i = 0; $i < $count; $i++) { + $key = strtolower($matches[1][$i]); + $headers["$key"] = $matches[2][$i]; + } + + $code = preg_replace('/.*?(\d{3}).*/i', '$1', $response); + + $headers['status_code'] = $code; + + if ( '302' == $code || '301' == $code ) + return wp_get_http_headers( $url, ++$red ); + + preg_match('/.*([0-9]{3}).*/', $response, $return); + $headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404 + return $headers; +} + +// Deprecated. Use the new post loop. +function start_wp() { + global $wp_query, $post; + + // Since the old style loop is being used, advance the query iterator here. + $wp_query->next_post(); + + setup_postdata($post); +} + +// Setup global post data. +function setup_postdata($post) { + global $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages, $wp_query; + global $pagenow; + + $id = $post->ID; + + $authordata = get_userdata($post->post_author); + + $day = mysql2date('d.m.y', $post->post_date); + $currentmonth = mysql2date('m', $post->post_date); + $numpages = 1; + $page = get_query_var('page'); + if ( !$page ) + $page = 1; + if ( is_single() || is_page() ) + $more = 1; + $content = $post->post_content; + if ( preg_match('/<!--nextpage-->/', $content) ) { + if ( $page > 1 ) + $more = 1; + $multipage = 1; + $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content); + $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content); + $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content); + $pages = explode('<!--nextpage-->', $content); + $numpages = count($pages); + } else { + $pages[0] = $post->post_content; + $multipage = 0; + } + return true; +} + +function is_new_day() { + global $day, $previousday; + if ( $day != $previousday ) { + return(1); + } else { + return(0); + } +} + +// Filters: these are the core of WP's plugin architecture + +function merge_filters($tag) { + global $wp_filter; + if ( isset($wp_filter['all']) ) { + foreach ($wp_filter['all'] as $priority => $functions) { + if ( isset($wp_filter[$tag][$priority]) ) + $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]); + else + $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], array()); + $wp_filter[$tag][$priority] = array_unique($wp_filter[$tag][$priority]); + } + } + + if ( isset($wp_filter[$tag]) ) + ksort( $wp_filter[$tag] ); +} + +function apply_filters($tag, $string) { + global $wp_filter; + + $args = array_slice(func_get_args(), 2); + + merge_filters($tag); + + if ( !isset($wp_filter[$tag]) ) { + return $string; + } + foreach ($wp_filter[$tag] as $priority => $functions) { + if ( !is_null($functions) ) { + foreach($functions as $function) { + + $all_args = array_merge(array($string), $args); + $function_name = $function['function']; + $accepted_args = $function['accepted_args']; + + if ( $accepted_args == 1 ) + $the_args = array($string); + elseif ( $accepted_args > 1 ) + $the_args = array_slice($all_args, 0, $accepted_args); + elseif ( $accepted_args == 0 ) + $the_args = NULL; + else + $the_args = $all_args; + + $string = call_user_func_array($function_name, $the_args); + } + } + } + return $string; +} + +function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { + global $wp_filter; + + // check that we don't already have the same filter at the same priority + if ( isset($wp_filter[$tag]["$priority"]) ) { + foreach($wp_filter[$tag]["$priority"] as $filter) { + // uncomment if we want to match function AND accepted_args + // if ( $filter == array($function, $accepted_args) ) { + if ( $filter['function'] == $function_to_add ) { + return true; + } + } + } + + // So the format is wp_filter['tag']['array of priorities']['array of ['array (functions, accepted_args)]'] + $wp_filter[$tag]["$priority"][] = array('function'=>$function_to_add, 'accepted_args'=>$accepted_args); + return true; +} + +function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { + global $wp_filter; + + // rebuild the list of filters + if ( isset($wp_filter[$tag]["$priority"]) ) { + foreach($wp_filter[$tag]["$priority"] as $filter) { + if ( $filter['function'] != $function_to_remove ) { + $new_function_list[] = $filter; + } + } + $wp_filter[$tag]["$priority"] = $new_function_list; + } + return true; +} + +// The *_action functions are just aliases for the *_filter functions, they take special strings instead of generic content + +function do_action($tag, $arg = '') { + global $wp_filter; + $extra_args = array_slice(func_get_args(), 2); + if ( is_array($arg) ) + $args = array_merge($arg, $extra_args); + else + $args = array_merge(array($arg), $extra_args); + + merge_filters($tag); + + if ( !isset($wp_filter[$tag]) ) { + return; + } + foreach ($wp_filter[$tag] as $priority => $functions) { + if ( !is_null($functions) ) { + foreach($functions as $function) { + + $function_name = $function['function']; + $accepted_args = $function['accepted_args']; + + if ( $accepted_args == 1 ) { + if ( is_array($arg) ) + $the_args = $arg; + else + $the_args = array($arg); + } elseif ( $accepted_args > 1 ) { + $the_args = array_slice($args, 0, $accepted_args); + } elseif ( $accepted_args == 0 ) { + $the_args = NULL; + } else { + $the_args = $args; + } + + $string = call_user_func_array($function_name, $the_args); + } + } + } +} + +function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { + add_filter($tag, $function_to_add, $priority, $accepted_args); +} + +function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { + remove_filter($tag, $function_to_remove, $priority, $accepted_args); +} + +function get_page_uri($page_id) { + $page = get_page($page_id); + $uri = urldecode($page->post_name); + + // A page cannot be it's own parent. + if ( $page->post_parent == $page->ID ) + return $uri; + + while ($page->post_parent != 0) { + $page = get_page($page->post_parent); + $uri = urldecode($page->post_name) . "/" . $uri; + } + + return $uri; +} + +function get_posts($args) { + global $wpdb; + parse_str($args, $r); + if ( !isset($r['numberposts']) ) + $r['numberposts'] = 5; + if ( !isset($r['offset']) ) + $r['offset'] = 0; + if ( !isset($r['category']) ) + $r['category'] = ''; + if ( !isset($r['orderby']) ) + $r['orderby'] = 'post_date'; + if ( !isset($r['order']) ) + $r['order'] = 'DESC'; + + $now = current_time('mysql'); + + $posts = $wpdb->get_results( + "SELECT DISTINCT * FROM $wpdb->posts " . + ( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) . + " WHERE post_date <= '$now' AND (post_status = 'publish') ". + ( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) . + " GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] ); + + update_post_caches($posts); + + return $posts; +} + +function &query_posts($query) { + global $wp_query; + return $wp_query->query($query); +} + +function update_post_cache(&$posts) { + global $post_cache; + + if ( !$posts ) + return; + + for ($i = 0; $i < count($posts); $i++) { + $post_cache[$posts[$i]->ID] = &$posts[$i]; + } +} + +function clean_post_cache($id) { + global $post_cache; + + if ( isset( $post_cache[$id] ) ) + unset( $post_cache[$id] ); +} + +function update_page_cache(&$pages) { + global $page_cache; + + if ( !$pages ) + return; + + for ($i = 0; $i < count($pages); $i++) { + $page_cache[$pages[$i]->ID] = &$pages[$i]; + wp_cache_add($pages[$i]->ID, $pages[$i], 'pages'); + } +} + + +function clean_page_cache($id) { + global $page_cache; + + if ( isset( $page_cache[$id] ) ) + unset( $page_cache[$id] ); +} + +function update_post_category_cache($post_ids) { + global $wpdb, $category_cache; + + if ( empty($post_ids) ) + return; + + if ( is_array($post_ids) ) + $post_ids = implode(',', $post_ids); + + $dogs = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id IN ($post_ids)"); + + if ( empty($dogs) ) + return; + + foreach ($dogs as $catt) + $category_cache[$catt->post_id][$catt->category_id] = &get_category($catt->category_id); +} + +function update_post_caches(&$posts) { + global $post_cache, $category_cache, $comment_count_cache, $post_meta_cache; + global $wpdb; + + // No point in doing all this work if we didn't match any posts. + if ( !$posts ) + return; + + // Get the categories for all the posts + for ($i = 0; $i < count($posts); $i++) { + $post_id_array[] = $posts[$i]->ID; + $post_cache[$posts[$i]->ID] = &$posts[$i]; + $comment_count_cache[$posts[$i]->ID] = $posts[$i]->comment_count; + } + + $post_id_list = implode(',', $post_id_array); + + update_post_category_cache($post_id_list); + + // Get post-meta info + if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) { + // Change from flat structure to hierarchical: + $post_meta_cache = array(); + foreach ($meta_list as $metarow) { + $mpid = $metarow['post_id']; + $mkey = $metarow['meta_key']; + $mval = $metarow['meta_value']; + + // Force subkeys to be array type: + if ( !isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]) ) + $post_meta_cache[$mpid] = array(); + if ( !isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]) ) + $post_meta_cache[$mpid]["$mkey"] = array(); + + // Add a value to the current pid/key: + $post_meta_cache[$mpid][$mkey][] = $mval; + } + } +} + +function update_category_cache() { + return true; +} + +function wp_head() { + do_action('wp_head'); +} + +function wp_footer() { + do_action('wp_footer'); +} + +function is_single ($post = '') { + global $wp_query; + + if ( !$wp_query->is_single ) + return false; + + if ( empty( $post) ) + return true; + + $post_obj = $wp_query->get_queried_object(); + + if ( $post == $post_obj->ID ) + return true; + elseif ( $post == $post_obj->post_title ) + return true; + elseif ( $post == $post_obj->post_name ) + return true; + + return false; +} + +function is_page ($page = '') { + global $wp_query; + + if ( !$wp_query->is_page ) + return false; + + if ( empty($page) ) + return true; + + $page_obj = $wp_query->get_queried_object(); + + if ( $page == $page_obj->ID ) + return true; + elseif ( $page == $page_obj->post_title ) + return true; + else if ( $page == $page_obj->post_name ) + return true; + + return false; +} + +function is_attachment () { + global $wp_query; + + return $wp_query->is_attachment; +} + +function is_preview() { + global $wp_query; + + return $wp_query->is_preview; +} + +function is_archive () { + global $wp_query; + + return $wp_query->is_archive; +} + +function is_date () { + global $wp_query; + + return $wp_query->is_date; +} + +function is_year () { + global $wp_query; + + return $wp_query->is_year; +} + +function is_month () { + global $wp_query; + + return $wp_query->is_month; +} + +function is_day () { + global $wp_query; + + return $wp_query->is_day; +} + +function is_time () { + global $wp_query; + + return $wp_query->is_time; +} + +function is_author ($author = '') { + global $wp_query; + + if ( !$wp_query->is_author ) + return false; + + if ( empty($author) ) + return true; + + $author_obj = $wp_query->get_queried_object(); + + if ( $author == $author_obj->ID ) + return true; + elseif ( $author == $author_obj->nickname ) + return true; + elseif ( $author == $author_obj->user_nicename ) + return true; + + return false; +} + +function is_category ($category = '') { + global $wp_query; + + if ( !$wp_query->is_category ) + return false; + + if ( empty($category) ) + return true; + + $cat_obj = $wp_query->get_queried_object(); + + if ( $category == $cat_obj->cat_ID ) + return true; + else if ( $category == $cat_obj->cat_name ) + return true; + elseif ( $category == $cat_obj->category_nicename ) + return true; + + return false; +} + +function is_search () { + global $wp_query; + + return $wp_query->is_search; +} + +function is_feed () { + global $wp_query; + + return $wp_query->is_feed; +} + +function is_trackback () { + global $wp_query; + + return $wp_query->is_trackback; +} + +function is_admin () { + global $wp_query; + + return ( $wp_query->is_admin || strstr($_SERVER['REQUEST_URI'], 'wp-admin/') ); +} + +function is_home () { + global $wp_query; + + return $wp_query->is_home; +} + +function is_404 () { + global $wp_query; + + return $wp_query->is_404; +} + +function is_comments_popup () { + global $wp_query; + + return $wp_query->is_comments_popup; +} + +function is_paged () { + global $wp_query; + + return $wp_query->is_paged; +} + +function in_the_loop() { + global $wp_query; + + return $wp_query->in_the_loop; +} + +function get_query_var($var) { + global $wp_query; + + return $wp_query->get($var); +} + +function have_posts() { + global $wp_query; + + return $wp_query->have_posts(); +} + +function rewind_posts() { + global $wp_query; + + return $wp_query->rewind_posts(); +} + +function the_post() { + global $wp_query; + + $wp_query->the_post(); +} + +function get_theme_root() { + return apply_filters('theme_root', ABSPATH . "wp-content/themes"); +} + +function get_theme_root_uri() { + return apply_filters('theme_root_uri', get_settings('siteurl') . "/wp-content/themes", get_settings('siteurl')); +} + +function get_stylesheet() { + return apply_filters('stylesheet', get_settings('stylesheet')); +} + +function get_stylesheet_directory() { + $stylesheet = get_stylesheet(); + $stylesheet_dir = get_theme_root() . "/$stylesheet"; + return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet); +} + +function get_stylesheet_directory_uri() { + $stylesheet = rawurlencode( get_stylesheet() ); + $stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet"; + return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet); +} + +function get_stylesheet_uri() { + $stylesheet_dir_uri = get_stylesheet_directory_uri(); + $stylesheet_uri = $stylesheet_dir_uri . "/style.css"; + return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri); +} + +function get_template() { + $template = get_settings('template'); + if (!file_exists(get_theme_root() . "/$template")) { //works for dirs too + update_option('template', 'default'); + update_option('stylesheet', 'default'); + } + return apply_filters('template', get_settings('template')); +} + +function get_template_directory() { + $template = get_template(); + $template_dir = get_theme_root() . "/$template"; + return apply_filters('template_directory', $template_dir, $template); +} + +function get_template_directory_uri() { + $template = get_template(); + $template_dir_uri = get_theme_root_uri() . "/$template"; + return apply_filters('template_directory_uri', $template_dir_uri, $template); +} + +function get_theme_data($theme_file) { + $theme_data = implode('', file($theme_file)); + preg_match("|Theme Name:(.*)|i", $theme_data, $theme_name); + preg_match("|Theme URI:(.*)|i", $theme_data, $theme_uri); + preg_match("|Description:(.*)|i", $theme_data, $description); + preg_match("|Author:(.*)|i", $theme_data, $author_name); + preg_match("|Author URI:(.*)|i", $theme_data, $author_uri); + preg_match("|Template:(.*)|i", $theme_data, $template); + if ( preg_match("|Version:(.*)|i", $theme_data, $version) ) + $version = $version[1]; + else + $version =''; + if ( preg_match("|Status:(.*)|i", $theme_data, $status) ) + $status = $status[1]; + else + $status ='publish'; + + $description = wptexturize($description[1]); + + $name = $theme_name[1]; + $name = trim($name); + $theme = $name; + + if ( '' == $author_uri[1] ) { + $author = $author_name[1]; + } else { + $author = '<a href="' . $author_uri[1] . '" title="' . __('Visit author homepage') . '">' . $author_name[1] . '</a>'; + } + + return array('Name' => $name, 'Title' => $theme, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1], 'Status' => $status); +} + +function get_themes() { + global $wp_themes; + global $wp_broken_themes; + + if ( isset($wp_themes) ) + return $wp_themes; + + $themes = array(); + $wp_broken_themes = array(); + $theme_root = get_theme_root(); + $theme_loc = str_replace(ABSPATH, '', $theme_root); + + // Files in wp-content/themes directory + $themes_dir = @ dir($theme_root); + if ( $themes_dir ) { + while(($theme_dir = $themes_dir->read()) !== false) { + if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) { + if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) { + continue; + } + $stylish_dir = @ dir($theme_root . '/' . $theme_dir); + $found_stylesheet = false; + while (($theme_file = $stylish_dir->read()) !== false) { + if ( $theme_file == 'style.css' ) { + $theme_files[] = $theme_dir . '/' . $theme_file; + $found_stylesheet = true; + break; + } + } + if ( !$found_stylesheet ) { + $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.')); + } + } + } + } + + if ( !$themes_dir || !$theme_files ) { + return $themes; + } + + sort($theme_files); + + foreach($theme_files as $theme_file) { + if ( ! is_readable("$theme_root/$theme_file") ) { + $wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.')); + continue; + } + + $theme_data = get_theme_data("$theme_root/$theme_file"); + + $name = $theme_data['Name']; + $title = $theme_data['Title']; + $description = wptexturize($theme_data['Description']); + $version = $theme_data['Version']; + $author = $theme_data['Author']; + $template = $theme_data['Template']; + $stylesheet = dirname($theme_file); + + foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext) { + if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) { + $screenshot = "screenshot.$ext"; + break; + } + } + + if ( empty($name) ) { + $name = dirname($theme_file); + $title = $name; + } + + if ( empty($template) ) { + if ( file_exists(dirname("$theme_root/$theme_file/index.php")) ) { + $template = dirname($theme_file); + } else { + continue; + } + } + + $template = trim($template); + + if ( !file_exists("$theme_root/$template/index.php") ) { + $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.')); + continue; + } + + $stylesheet_files = array(); + $stylesheet_dir = @ dir("$theme_root/$stylesheet"); + if ( $stylesheet_dir ) { + while(($file = $stylesheet_dir->read()) !== false) { + if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) ) + $stylesheet_files[] = "$theme_loc/$stylesheet/$file"; + } + } + + $template_files = array(); + $template_dir = @ dir("$theme_root/$template"); + if ( $template_dir ) { + while(($file = $template_dir->read()) !== false) { + if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) ) + $template_files[] = "$theme_loc/$template/$file"; + } + } + + $template_dir = dirname($template_files[0]); + $stylesheet_dir = dirname($stylesheet_files[0]); + + if ( empty($template_dir) ) + $template_dir = '/'; + if ( empty($stylesheet_dir) ) + $stylesheet_dir = '/'; + + // Check for theme name collision. This occurs if a theme is copied to + // a new theme directory and the theme header is not updated. Whichever + // theme is first keeps the name. Subsequent themes get a suffix applied. + // The Default and Classic themes always trump their pretenders. + if ( isset($themes[$name]) ) { + if ( ('WordPress Default' == $name || 'WordPress Classic' == $name) && + ('default' == $stylesheet || 'classic' == $stylesheet) ) { + // If another theme has claimed to be one of our default themes, move + // them aside. + $suffix = $themes[$name]['Stylesheet']; + $new_name = "$name/$suffix"; + $themes[$new_name] = $themes[$name]; + $themes[$new_name]['Name'] = $new_name; + } else { + $name = "$name/$stylesheet"; + } + } + + $themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Stylesheet' => $stylesheet, 'Template Files' => $template_files, 'Stylesheet Files' => $stylesheet_files, 'Template Dir' => $template_dir, 'Stylesheet Dir' => $stylesheet_dir, 'Status' => $theme_data['Status'], 'Screenshot' => $screenshot); + } + + // Resolve theme dependencies. + $theme_names = array_keys($themes); + + foreach ($theme_names as $theme_name) { + $themes[$theme_name]['Parent Theme'] = ''; + if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) { + foreach ($theme_names as $parent_theme_name) { + if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) { + $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name']; + break; + } + } + } + } + + $wp_themes = $themes; + + return $themes; +} + +function get_theme($theme) { + $themes = get_themes(); + + if ( array_key_exists($theme, $themes) ) + return $themes[$theme]; + + return NULL; +} + +function get_current_theme() { + $themes = get_themes(); + $theme_names = array_keys($themes); + $current_template = get_settings('template'); + $current_stylesheet = get_settings('stylesheet'); + $current_theme = 'WordPress Default'; + + if ( $themes ) { + foreach ($theme_names as $theme_name) { + if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet && + $themes[$theme_name]['Template'] == $current_template ) { + $current_theme = $themes[$theme_name]['Name']; + break; + } + } + } + + return $current_theme; +} + +function get_query_template($type) { + $template = ''; + if ( file_exists(TEMPLATEPATH . "/{$type}.php") ) + $template = TEMPLATEPATH . "/{$type}.php"; + + return apply_filters("{$type}_template", $template); +} + +function get_404_template() { + return get_query_template('404'); +} + +function get_archive_template() { + return get_query_template('archive'); +} + +function get_author_template() { + return get_query_template('author'); +} + +function get_category_template() { + $template = ''; + if ( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') ) + $template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php'; + else if ( file_exists(TEMPLATEPATH . "/category.php") ) + $template = TEMPLATEPATH . "/category.php"; + + return apply_filters('category_template', $template); +} + +function get_date_template() { + return get_query_template('date'); +} + +function get_home_template() { + $template = ''; + + if ( file_exists(TEMPLATEPATH . "/home.php") ) + $template = TEMPLATEPATH . "/home.php"; + else if ( file_exists(TEMPLATEPATH . "/index.php") ) + $template = TEMPLATEPATH . "/index.php"; + + return apply_filters('home_template', $template); +} + +function get_page_template() { + global $wp_query; + + $id = $wp_query->post->ID; + $template = get_post_meta($id, '_wp_page_template', true); + + if ( 'default' == $template ) + $template = ''; + + if ( ! empty($template) && file_exists(TEMPLATEPATH . "/$template") ) + $template = TEMPLATEPATH . "/$template"; + else if ( file_exists(TEMPLATEPATH . "/page.php") ) + $template = TEMPLATEPATH . "/page.php"; + else + $template = ''; + + return apply_filters('page_template', $template); +} + +function get_paged_template() { + return get_query_template('paged'); +} + +function get_search_template() { + return get_query_template('search'); +} + +function get_single_template() { + return get_query_template('single'); +} + +function get_attachment_template() { + global $posts; + $type = explode('/', $posts[0]->post_mime_type); + if ( $template = get_query_template($type[0]) ) + return $template; + elseif ( $template = get_query_template($type[1]) ) + return $template; + elseif ( $template = get_query_template("$type[0]_$type[1]") ) + return $template; + else + return get_query_template('attachment'); +} + +function get_comments_popup_template() { + if ( file_exists( TEMPLATEPATH . '/comments-popup.php') ) + $template = TEMPLATEPATH . '/comments-popup.php'; + else + $template = get_theme_root() . '/default/comments-popup.php'; + + return apply_filters('comments_popup_template', $template); +} + +// Borrowed from the PHP Manual user notes. Convert entities, while +// preserving already-encoded entities: +function htmlentities2($myHTML) { + $translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES); + $translation_table[chr(38)] = '&'; + return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($myHTML, $translation_table)); +} + + +function is_plugin_page() { + global $plugin_page; + + if ( isset($plugin_page) ) + return true; + + return false; +} + +/* +add_query_arg: Returns a modified querystring by adding +a single key & value or an associative array. +Setting a key value to emptystring removes the key. +Omitting oldquery_or_uri uses the $_SERVER value. + +Parameters: +add_query_arg(newkey, newvalue, oldquery_or_uri) or +add_query_arg(associative_array, oldquery_or_uri) +*/ +function add_query_arg() { + $ret = ''; + if ( is_array(func_get_arg(0)) ) { + if ( @func_num_args() < 2 ) + $uri = $_SERVER['REQUEST_URI']; + else + $uri = @func_get_arg(1); + } else { + if ( @func_num_args() < 3 ) + $uri = $_SERVER['REQUEST_URI']; + else + $uri = @func_get_arg(2); + } + + if ( strstr($uri, '?') ) { + $parts = explode('?', $uri, 2); + if ( 1 == count($parts) ) { + $base = '?'; + $query = $parts[0]; + } else { + $base = $parts[0] . '?'; + $query = $parts[1]; + } + } + else if ( strstr($uri, '/') ) { + $base = $uri . '?'; + $query = ''; + } else { + $base = ''; + $query = $uri; + } + + parse_str($query, $qs); + if ( is_array(func_get_arg(0)) ) { + $kayvees = func_get_arg(0); + $qs = array_merge($qs, $kayvees); + } else { + $qs[func_get_arg(0)] = func_get_arg(1); + } + + foreach($qs as $k => $v) { + if ( $v != '' ) { + if ( $ret != '' ) + $ret .= '&'; + $ret .= "$k=$v"; + } + } + $ret = $base . $ret; + return trim($ret, '?'); +} + +function remove_query_arg($key, $query) { + return add_query_arg($key, '', $query); +} + +function load_template($file) { + global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, + $wp_rewrite, $wpdb; + + extract($wp_query->query_vars); + + require_once($file); +} + +function add_magic_quotes($array) { + global $wpdb; + + foreach ($array as $k => $v) { + if ( is_array($v) ) { + $array[$k] = add_magic_quotes($v); + } else { + $array[$k] = $wpdb->escape($v); + } + } + return $array; +} + +function wp_remote_fopen( $uri ) { + if ( ini_get('allow_url_fopen') ) { + $fp = fopen( $uri, 'r' ); + if ( !$fp ) + return false; + $linea = ''; + while( $remote_read = fread($fp, 4096) ) + $linea .= $remote_read; + fclose($fp); + return $linea; + } else if ( function_exists('curl_init') ) { + $handle = curl_init(); + curl_setopt ($handle, CURLOPT_URL, $uri); + curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1); + curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1); + $buffer = curl_exec($handle); + curl_close($handle); + return $buffer; + } else { + return false; + } +} + +function wp($query_vars = '') { + global $wp; + + $wp->main($query_vars); +} + +function status_header( $header ) { + if ( 200 == $header ) + $text = 'OK'; + elseif ( 301 == $header ) + $text = 'Moved Permanently'; + elseif ( 302 == $header ) + $text = 'Moved Temporarily'; + elseif ( 304 == $header ) + $text = 'Not Modified'; + elseif ( 404 == $header ) + $text = 'Not Found'; + elseif ( 410 == $header ) + $text = 'Gone'; + + @header("HTTP/1.1 $header $text"); + @header("Status: $header $text"); +} + +function nocache_headers() { + @ header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); + @ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + @ header('Cache-Control: no-cache, must-revalidate, max-age=0'); + @ header('Pragma: no-cache'); +} + +function get_usermeta( $user_id, $meta_key = '') { + global $wpdb; + $user_id = (int) $user_id; + + if ( !empty($meta_key) ) { + $meta_key = preg_replace('|a-z0-9_|i', '', $meta_key); + $metas = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'"); + } else { + $metas = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'"); + } + + if ( empty($metas) ) { + if ( empty($meta_key) ) + return array(); + else + return ''; + } + + foreach ($metas as $index => $meta) { + @ $value = unserialize($meta->meta_value); + if ( $value === FALSE ) + $value = $meta->meta_value; + + $values[] = $value; + } + + if ( count($values) == 1 ) + return $values[0]; + else + return $values; +} + +function update_usermeta( $user_id, $meta_key, $meta_value ) { + global $wpdb; + if ( !is_numeric( $user_id ) ) + return false; + $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); + + if ( is_array($meta_value) || is_object($meta_value) ) + $meta_value = serialize($meta_value); + $meta_value = trim( $meta_value ); + + if (empty($meta_value)) { + delete_usermeta($user_id, $meta_key); + } + + $cur = $wpdb->get_row("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'"); + if ( !$cur ) { + $wpdb->query("INSERT INTO $wpdb->usermeta ( user_id, meta_key, meta_value ) + VALUES + ( '$user_id', '$meta_key', '$meta_value' )"); + } else if ( $cur->meta_value != $meta_value ) { + $wpdb->query("UPDATE $wpdb->usermeta SET meta_value = '$meta_value' WHERE user_id = '$user_id' AND meta_key = '$meta_key'"); + } else { + return false; + } + + $user = get_userdata($user_id); + wp_cache_delete($user_id, 'users'); + wp_cache_delete($user->user_login, 'userlogins'); + + return true; +} + +function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { + global $wpdb; + if ( !is_numeric( $user_id ) ) + return false; + $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); + + if ( is_array($meta_value) || is_object($meta_value) ) + $meta_value = serialize($meta_value); + $meta_value = trim( $meta_value ); + + if ( ! empty($meta_value) ) + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key' AND meta_value = '$meta_value'"); + else + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'"); + + $user = get_userdata($user_id); + wp_cache_delete($user_id, 'users'); + wp_cache_delete($user->user_login, 'userlogins'); + + return true; +} + +function register_activation_hook($file, $function) { + $file = plugin_basename($file); + + add_action('activate_' . $file, $function); +} + +function register_deactivation_hook($file, $function) { + $file = plugin_basename($file); + + add_action('deactivate_' . $file, $function); +} + +function plugin_basename($file) { + $file = preg_replace('|\\\\+|', '\\\\', $file); + $file = preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file); + return $file; +} + +function get_num_queries() { + global $wpdb; + return $wpdb->num_queries; +} + +?> diff --git a/wp-includes/gettext.php b/wp-includes/gettext.php new file mode 100644 index 00000000..ad605cfd --- /dev/null +++ b/wp-includes/gettext.php @@ -0,0 +1,361 @@ +<?php +/* + Copyright (c) 2003 Danilo Segan <danilo@kvota.net>. + Copyright (c) 2005 Nico Kaiser <nico@siriux.net> + + This file is part of PHP-gettext. + + PHP-gettext is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PHP-gettext is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PHP-gettext; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +/** + * Provides a simple gettext replacement that works independently from + * the system's gettext abilities. + * It can read MO files and use them for translating strings. + * The files are passed to gettext_reader as a Stream (see streams.php) + * + * This version has the ability to cache all strings and translations to + * speed up the string lookup. + * While the cache is enabled by default, it can be switched off with the + * second parameter in the constructor (e.g. whenusing very large MO files + * that you don't want to keep in memory) + */ +class gettext_reader { + //public: + var $error = 0; // public variable that holds error code (0 if no error) + + //private: + var $BYTEORDER = 0; // 0: low endian, 1: big endian + var $STREAM = NULL; + var $short_circuit = false; + var $enable_cache = false; + var $originals = NULL; // offset of original table + var $translations = NULL; // offset of translation table + var $pluralheader = NULL; // cache header field for plural forms + var $total = 0; // total string count + var $table_originals = NULL; // table for original strings (offsets) + var $table_translations = NULL; // table for translated strings (offsets) + var $cache_translations = NULL; // original -> translation mapping + + + /* Methods */ + + + /** + * Reads a 32bit Integer from the Stream + * + * @access private + * @return Integer from the Stream + */ + function readint() { + $stream = $this->STREAM->read(4); + if ($this->BYTEORDER == 0) { + // low endian + $unpacked = unpack('V',$stream); + return array_shift($unpacked); + } else { + // big endian + $unpacked = unpack('N',$stream); + return array_shift($unpacked); + } + } + + /** + * Reads an array of Integers from the Stream + * + * @param int count How many elements should be read + * @return Array of Integers + */ + function readintarray($count) { + if ($this->BYTEORDER == 0) { + // low endian + return unpack('V'.$count, $this->STREAM->read(4 * $count)); + } else { + // big endian + return unpack('N'.$count, $this->STREAM->read(4 * $count)); + } + } + + /** + * Constructor + * + * @param object Reader the StreamReader object + * @param boolean enable_cache Enable or disable caching of strings (default on) + */ + function gettext_reader($Reader, $enable_cache = true) { + // If there isn't a StreamReader, turn on short circuit mode. + if (! $Reader) { + $this->short_circuit = true; + return; + } + + // Caching can be turned off + $this->enable_cache = $enable_cache; + + // $MAGIC1 = (int)0x950412de; //bug in PHP 5 + $MAGIC1 = (int) - 1794895138; + // $MAGIC2 = (int)0xde120495; //bug + $MAGIC2 = (int) - 569244523; + + $this->STREAM = $Reader; + $magic = $this->readint(); + if ($magic == $MAGIC1) { + $this->BYTEORDER = 0; + } elseif ($magic == $MAGIC2) { + $this->BYTEORDER = 1; + } else { + $this->error = 1; // not MO file + return false; + } + + // FIXME: Do we care about revision? We should. + $revision = $this->readint(); + + $this->total = $this->readint(); + $this->originals = $this->readint(); + $this->translations = $this->readint(); + } + + /** + * Loads the translation tables from the MO file into the cache + * If caching is enabled, also loads all strings into a cache + * to speed up translation lookups + * + * @access private + */ + function load_tables() { + if (is_array($this->cache_translations) && + is_array($this->table_originals) && + is_array($this->table_translations)) + return; + + /* get original and translations tables */ + $this->STREAM->seekto($this->originals); + $this->table_originals = $this->readintarray($this->total * 2); + $this->STREAM->seekto($this->translations); + $this->table_translations = $this->readintarray($this->total * 2); + + if ($this->enable_cache) { + $this->cache_translations = array (); + /* read all strings in the cache */ + for ($i = 0; $i < $this->total; $i++) { + $this->STREAM->seekto($this->table_originals[$i * 2 + 2]); + $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]); + $this->STREAM->seekto($this->table_translations[$i * 2 + 2]); + $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]); + $this->cache_translations[$original] = $translation; + } + } + } + + /** + * Returns a string from the "originals" table + * + * @access private + * @param int num Offset number of original string + * @return string Requested string if found, otherwise '' + */ + function get_original_string($num) { + $length = $this->table_originals[$num * 2 + 1]; + $offset = $this->table_originals[$num * 2 + 2]; + if (! $length) + return ''; + $this->STREAM->seekto($offset); + $data = $this->STREAM->read($length); + return (string)$data; + } + + /** + * Returns a string from the "translations" table + * + * @access private + * @param int num Offset number of original string + * @return string Requested string if found, otherwise '' + */ + function get_translation_string($num) { + $length = $this->table_translations[$num * 2 + 1]; + $offset = $this->table_translations[$num * 2 + 2]; + if (! $length) + return ''; + $this->STREAM->seekto($offset); + $data = $this->STREAM->read($length); + return (string)$data; + } + + /** + * Binary search for string + * + * @access private + * @param string string + * @param int start (internally used in recursive function) + * @param int end (internally used in recursive function) + * @return int string number (offset in originals table) + */ + function find_string($string, $start = -1, $end = -1) { + if (($start == -1) or ($end == -1)) { + // find_string is called with only one parameter, set start end end + $start = 0; + $end = $this->total; + } + if (abs($start - $end) <= 1) { + // We're done, now we either found the string, or it doesn't exist + $txt = $this->get_original_string($start); + if ($string == $txt) + return $start; + else + return -1; + } else if ($start > $end) { + // start > end -> turn around and start over + return $this->find_string($string, $end, $start); + } else { + // Divide table in two parts + $half = (int)(($start + $end) / 2); + $cmp = strcmp($string, $this->get_original_string($half)); + if ($cmp == 0) + // string is exactly in the middle => return it + return $half; + else if ($cmp < 0) + // The string is in the upper half + return $this->find_string($string, $start, $half); + else + // The string is in the lower half + return $this->find_string($string, $half, $end); + } + } + + /** + * Translates a string + * + * @access public + * @param string string to be translated + * @return string translated string (or original, if not found) + */ + function translate($string) { + if ($this->short_circuit) + return $string; + $this->load_tables(); + + if ($this->enable_cache) { + // Caching enabled, get translated string from cache + if (array_key_exists($string, $this->cache_translations)) + return $this->cache_translations[$string]; + else + return $string; + } else { + // Caching not enabled, try to find string + $num = $this->find_string($string); + if ($num == -1) + return $string; + else + return $this->get_translation_string($num); + } + } + + /** + * Get possible plural forms from MO header + * + * @access private + * @return string plural form header + */ + function get_plural_forms() { + // lets assume message number 0 is header + // this is true, right? + $this->load_tables(); + + // cache header field for plural forms + if (! is_string($this->pluralheader)) { + if ($this->enable_cache) { + $header = $this->cache_translations[""]; + } else { + $header = $this->get_translation_string(0); + } + if (eregi("plural-forms: (.*)\n", $header, $regs)) + $expr = $regs[1]; + else + $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; + $this->pluralheader = $expr; + } + return $this->pluralheader; + } + + /** + * Detects which plural form to take + * + * @access private + * @param n count + * @return int array index of the right plural form + */ + function select_string($n) { + $string = $this->get_plural_forms(); + $string = str_replace('nplurals',"\$total",$string); + $string = str_replace("n",$n,$string); + $string = str_replace('plural',"\$plural",$string); + + $total = 0; + $plural = 0; + + eval("$string"); + if ($plural >= $total) $plural = 0; + return $plural; + } + + /** + * Plural version of gettext + * + * @access public + * @param string single + * @param string plural + * @param string number + * @return translated plural form + */ + function ngettext($single, $plural, $number) { + if ($this->short_circuit) { + if ($number != 1) + return $plural; + else + return $single; + } + + // find out the appropriate form + $select = $this->select_string($number); + + // this should contains all strings separated by NULLs + $key = $single.chr(0).$plural; + + + if ($this->enable_cache) { + if (! array_key_exists($key, $this->cache_translations)) { + return ($number != 1) ? $plural : $single; + } else { + $result = $this->cache_translations[$key]; + $list = explode(chr(0), $result); + return $list[$select]; + } + } else { + $num = $this->find_string($key); + if ($num == -1) { + return ($number != 1) ? $plural : $single; + } else { + $result = $this->get_translation_string($num); + $list = explode(chr(0), $result); + return $list[$select]; + } + } + } + +} + +?> diff --git a/wp-includes/images/smilies/icon_arrow.gif b/wp-includes/images/smilies/icon_arrow.gif new file mode 100644 index 0000000000000000000000000000000000000000..2880055cc0f11c60f5688ade044df280856df9a7 GIT binary patch literal 170 zcmZ?wbhEHb<Y(Y#*v!N5{}qF)t1ANo!~b&(|4%af|111&F2nyV4FCU4{{R2@|ECQ9 z|Gx&x!hzyX7DfgJ9tItd2*?ZumhcIll38<ST%9T)B`#Lr$~dQ4(8n=-Ucs)c6Wkn5 zd$xV+oX--vpzN?@af>tSLu;wYQ>TAs=jBP*FkflM?zCbCrVb+sjSbO~t9>%IUtM${ Pu}&Z@V%kj=CI)K&O7cC% literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_biggrin.gif b/wp-includes/images/smilies/icon_biggrin.gif new file mode 100644 index 0000000000000000000000000000000000000000..d3527723c6d8a0ddfa7ca0bfe1ab8fce0055918c GIT binary patch literal 172 zcmZ?wbhEHb<Y(Y#*v!k|>gxLc6$23b2ZD19|4%af-@@>3F2nzSlmGt}{{R2@|NpQ5 zKLsg(0L7myj0_CC3_2h#$P5OS$PJ#HS#x(>T`Hg?&Q{<lH0KDTk3;&rf?Zi1ng_}m zvQEur-`T{~@Z(@Xn^)k09IMF;w-dZ%Ik*CtHhAq_WfH~seHXK^gx{y>P6{IT@*|fe Qt&nb$oR(_V$-rO@0AZ~_>i_@% literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_confused.gif b/wp-includes/images/smilies/icon_confused.gif new file mode 100644 index 0000000000000000000000000000000000000000..0c49e06983f1fff4bc0834b4d86ce39b8a36a914 GIT binary patch literal 171 zcmZ?wbhEHb<Y(Y#*v!N5{}qF)t1ANo!~b&(|4%afo6GQj3&a0^lmGt}{{R2@|ECQ9 z|Gx&x!hzyX7DfgJ9tItd2*?ZumWT<Sl38<ST%CGOQe3QngK3VlppT<Ehx&(QtIK8- z@?~-I&9`sTDqud=)OJeoIE%m}#+c7v*6=J-Z!Hkr@h?UHke{)HMx23eZ>ZXiyV-#U P9L#x)b-Z(h7#XYqI2k)k literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_cool.gif b/wp-includes/images/smilies/icon_cool.gif new file mode 100644 index 0000000000000000000000000000000000000000..cead0306c0e38e57bdb0cc85a407b995dcbdc656 GIT binary patch literal 172 zcmZ?wbhEHb<Y(Y#*v!lD{}qF)t1ANo!~b&(|4%afo6GQj3&a0^lmGt}{{R2@e;|0u z@c;j7paKX`{K>+|z`)C(1LA_rU|@;d;3=6kcSq>7bCTj>1sqIsoCSRx)8`fJ$~w+{ zJX`yX^?~=R4m2(o_)+HS{ItMiUIk0)fwE>-?dDgxjscmQ{AM&TEaGA7z8`VSO88#> SHjRW8(oK@nQq4LU7_0%kd_$xF literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_cry.gif b/wp-includes/images/smilies/icon_cry.gif new file mode 100644 index 0000000000000000000000000000000000000000..7d54b1f994bb20c2a17c6e9e53edb39e0444b380 GIT binary patch literal 498 zcmZ?wbhEHb<Y(Y#I3mFC{}qF)t1ANo!~b&(|4%afo6GQj3&a0^lmGt}{tp7j|Nnpe z|0x4Q&yB|2*W%*hfGSA>ivPL&TtkAL9RpmA^bD98ftnS6varfA2r%e?3<5cWfi*@! zrOPq0Pa{O{R3VSL)CLZwJI;bVj@ow|9P^f2{b_KV;g#sD#JTIhK{X4eRSZoFOA4&E zE?xGWjgRM;Ia^8kzR>%TOS23r6eRl<`~6;g|7yg@*31^DX`|+%tO&MH1Y{u#11keN z5Hhd|DyTR-@tBu#X^wBxK7*WjP8?uWTo6?pKs7*@va%&Sa#%9C1z8HDof#;_rJ&H~ zFsWx*ry9h3B%L5>ZUqL1B|!6=oIFuX25Dyj%JU{%Vn~@hA!8Mj(`_aU6Ueh0<To~; W+58GDAirgB%~0xA%M@Z_um%8Cb$0>) literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_eek.gif b/wp-includes/images/smilies/icon_eek.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d3978106a2da37441ed17c9d05383b367570d46 GIT binary patch literal 170 zcmZ?wbhEHb<Y(Y#*v!lD|Nnmm28REy7+hUl|DR*{f0E(<7KVRw8U8<I`2Sb<|G&xq z|G)nK|2R+$1StMwVPs(7WzYd}L1r+pgm3V)%$mF7>d`4m;$l6XN^_D8SRJJ2FugV_ z;@-1W`~Ak%x7W!T7_8VEVD?C1V$(vmHm-x7t|ENQXTMbHG-$9e9m-TqP;V|s+-sI@ SDB66dp*Gz_Y_|#%gEasOPe3vN literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_evil.gif b/wp-includes/images/smilies/icon_evil.gif new file mode 100644 index 0000000000000000000000000000000000000000..ab1aa8e123fe263608d06126ce08c560ad419f97 GIT binary patch literal 236 zcmZ?wbhEHb<Y(Y#I3mE{>gxLc6$23bKgaO@B*VYC4FCTM|KGy!A1Lx~^8f$G|7kJ& z%VnN6ZQB2*4FCVX1}P;4DE?$&WMB|r&;e-z*~!3~slec{BxBNqoiq9;sWfXDwJwx! zTfpypu*1~B&z<E91Fyp&1%+3$Ha^i+$grE;(v+d;5VA6s@!^K0N&-hV&(PT;v_JXc s0nhRj_hZ?j(%K)_Sn)BrYq&A9bab?6Xfm+(vqvfSw5m<kP-L(M0372-oB#j- literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_exclaim.gif b/wp-includes/images/smilies/icon_exclaim.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e50e2eecdb54d2ee3a14c39547a6b454524f98d GIT binary patch literal 236 zcmZ?wbhEHb<Y(Y#I3mmN{}qF)tLy)B4F69u{QoQbe+$FExeWjRP5%G?czr3u|ECN< zuzx+n|NpO#Ze`Qg*S~a-_49p}!u;@}f{6Va7`)syH!fmgW@gUK4i*s+d3l}f_j86| ze>IRcFi`x-!pOiN%b)||f$U^p%}h}5a*XWD2sb-X$e}K^frar-lVFcywmLVPpS#r! z1_#Bw>()y8Q=}6Xa7!$m)>9ItA-k>bRM`by3r4<kJ9KX3DFm@jy}8d*Zt`sgHz5uY f1}O=_B1`L9Cg!fLHceI539O--Hfrt4iVW5O`=(HQ literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_idea.gif b/wp-includes/images/smilies/icon_idea.gif new file mode 100644 index 0000000000000000000000000000000000000000..a40ae0d7e8c870d3675c8975e3a6bb0a059f11ff GIT binary patch literal 176 zcmZ?wbhEHb<Y(Y#*v!k|>gxLc6$23b2ZD19|4%af-@@?!ukgRQ4FCU4{{R2@|EEBy z*B}*Op!k!8k%57iK?lSGnZdvkyTOw)YwnKFWkE{fYz4;!=ddvOIHYqKtO`15eTQk+ zwr{=ctfC9V1Rm6}I;$2M@y*$pa`Z}#oqrI+!z(?kVh8VTo6X#$!E$I32lMi<45x(( UGxi&cHs4b?vq7goSdhUQ00}uk)&Kwi literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_lol.gif b/wp-includes/images/smilies/icon_lol.gif new file mode 100644 index 0000000000000000000000000000000000000000..374ba150fb238d6a33605bb26e86d4449625a46c GIT binary patch literal 336 zcmZ?wbhEHb<Y(Y#*v!k|>gxLc6$23b2ZD19|4%af-@@>3F2n!7!vFtG{{R2@|NpQ5 zKLsg(0LA~@ey$<G&W-`DMtTO!j6hMvpDe5*47?0FAQd2E8Caq=cyeaV-Ennkkdio? zPE!MmV<m&|f*Bce)`b*t8Ok-xDtfIMlgPT^WFM=uDx=M^DGV-|Ub>E)D;vwK1$ZJE z)->GK{b0hvv^Z;7;HB1zIS=v}c`BF<leecRA*^F!U}E5AU<X<!yuni?dWFU7v#Vds x|B$%Igy-f>7qB`mkh55UYFL448CX~YJS?+%vC0^DXyTAT=mC2Y$ux)_YXI57TebiI literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_mad.gif b/wp-includes/images/smilies/icon_mad.gif new file mode 100644 index 0000000000000000000000000000000000000000..1f6c3c2fb401596ec44f4a1189bde2cbc45364aa GIT binary patch literal 174 zcmZ?wbhEHb<Y(Y#*v!lD{}qF)t1ANo!~b&(|4%af-@@>3F2nzSlmGt}{tp7j|Nnpe z|0z%&3KV~`FfuUkGU$N#ATt<PqBnR-X3gDkb?G@taj^mpra8@mK91^hHcVJ|D{-GX zUsf0Ae}*Ql1ZIwcW8w<~ERW1{Ogq5dqO09}<0D4`M|k5J1xGb*4(qcC8*<M_WH-h9 S6JzE2ame8CrVDC<4Aua~|3YH` literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_mrgreen.gif b/wp-includes/images/smilies/icon_mrgreen.gif new file mode 100644 index 0000000000000000000000000000000000000000..b54cd0f9469ae025d7b709f03432eebc30a615b8 GIT binary patch literal 349 zcmZ?wbhEHb<Y(Y#xXJ(m|NsAI_;i@z-F}8Q`xsvBVR*8g;n6mR2U{5KY-G5#p5ewi zhHGmWF0EuZw~XP`B8C$S8IH|oI5Ll6-%N%*(;0S5Vc0T}VN*ZDx*mpAoeV458J4v& zENEnyQ_C=`hGAMILtha?S3W~q4ntEWLtQFEO$tLr0?0-x0mYvzj0_Cw3_2k5Kz?Fi zt2!__fI~y9{X}pfQ>F%wyNW~cLKD&UCI$nR5;ND%<UpC6PC15UOce}5><o?E47C=L z+^UZfR0P-p7!=)FTRB~o7#JD5d-@o7U6m*F^!5w5s!r|i7cNoh?wiga9^<99aIvej c)bbUp+~j1}yD+FKD=8`jdU~~bIx<)T0FW16NdN!< literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_neutral.gif b/wp-includes/images/smilies/icon_neutral.gif new file mode 100644 index 0000000000000000000000000000000000000000..4f311567ed0bde877c5a1291a5853fd84b3fe951 GIT binary patch literal 171 zcmZ?wbhEHb<Y(Y#*v!N5{}qF)t1ANo!~b&(|4%afo6GQj3&a0^lmGt}{{R2@|ECQ9 z|Gx&x!hzyX7DfgJ9tItd2*?ZumWT<Sl38<ST%CGOQe3QngK3VlppT>aoaG8jR+sH5 z;LGade6U~GQPko`gGJNAq7#;kr@G#2#;~znnVhs^*T0km#>C~4JR&=FdsEeR+|3R= Q;9xFbtmB<4#K>R`0GZ1@LjV8( literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_question.gif b/wp-includes/images/smilies/icon_question.gif new file mode 100644 index 0000000000000000000000000000000000000000..9d072265bb9d7d5d4eeaaa9aadb44a49a60e5fe3 GIT binary patch literal 248 zcmZ?wbhEHb<Y(Y#I3mU1>gxLc6~q5?4F69u{F}@0e+$F^zrz3jO@4oyp}v#>2=1R{ z`2YX-`F#xhd<^^7GyH$bps&p^e-cpewY&^Nd^p4X4Gi!1Fzlbske>!pj|LQfvM@3* zNHOSu#6fm4u$C@R>vD+fTM_1WrjSFOYeSph9VW&ehisimT`Ynp-iEL<A9C~z5b1uj zF5TOK`Ls{M0%nzsz0uASZ-{xd&))U0Lx4TK!B;jz_^c}9--Q)-6k>v_k~jmS4OEzz h1Q^5k8{BNVn8hT-nI{@Cu+CwP)wEG_S5{=O1_1NkQKJ9= literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_razz.gif b/wp-includes/images/smilies/icon_razz.gif new file mode 100644 index 0000000000000000000000000000000000000000..29da2a2fccc79981bc54db7513ca6d2374592f9d GIT binary patch literal 176 zcmZ?wbhEHb<Y(Y#*v!Z9{}qF)t1ANo!~b&(|AFL5hW}d_{>^3h|5y0`zsdjqAOHXV zwXw1B|EEADAfWh@g^_`Qk3k2-0hz(T5_`c@GHdRQt4o8V#Kj6YnC2W7^l?<@Q2(%O z^|Tp<d|6z4^Y=Gt6)+!bYV%S$<32QFt+Df{ixw&FtNx>zE=L6K%vq%4Qv0AgI88 ZPHWn(3w4)`M4Rs!oY|mbDlEug4FCb$KH>lX literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_redface.gif b/wp-includes/images/smilies/icon_redface.gif new file mode 100644 index 0000000000000000000000000000000000000000..ad7628320c3d15756c84794c8c0523f1072da640 GIT binary patch literal 650 zcmZ?wbhEHb<Y(Y#I3myRYcs>&Qw$Gs7{2#K|NnmWcSgp)ZKdDmF#NyN{%1+%|LxoV z&6x4L*vr+`_5YJ6|9^e`f9A~pR}4QI8vg%z`Rh8vzsC$emo5AMNBH0A=KudDKaP*T z>0!pe!0`X+%wGqqfegj}+<vYh!Oo5Wu10zW%#0wRpDe5*4Dt**KsL}3{0t1NX%E!9 zd?Wi_g!{QnV^zPk;kxMEgBN>zPv3R$%UgcxPlMx(u7qxxxfZd?$&YQ;PGndxWo3ZY ziH`8-T?`B&DNk$k=JGRs=w-6FQO@h2ko&aap$ji#VOF!1O><{wyHRCMkfx2Ai?Slv zYA%q~j0}tnyg<mn8u&oH?!1e@F^g%j?R$<H%(|alztQ8$x4C|LEdCtQ0x^rC&rVRN z;F%%!Xr_k(8_(*q&9WhqvmMVfq@7@6?hk13tZ-$^;1`~L@bQmbULk95xk79)Lbb&M z=s~}oJu8?Uy>^Qv|J?fJ`y}Jo`B}5IcZU0i%+^)m>vp{!Bqu6#)+xQyYu&8=mRY(7 z)}5aCNL5gG*%{+AHF>K87ridk<zmF<g#e)8!j2NjR;99!qz*^a<^4UV<apg|*DmWL zd~O+?IVR3c4-6A3I?|LHB@9-W_Lmx@*09+$PZyNtv2hYqJ18nS$L5Unv%1^QH7}NU ziMK+c2unB#PfR^%G3~nO-h+nVaGG)T+gzb_9R3{EDZp^jWjGPQG&SzY$sQS&2DztI i3=Awy&iV{?Cm7hf0zw>_T^KXg3qiu^$yZP~SpxtUz5smy literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_rolleyes.gif b/wp-includes/images/smilies/icon_rolleyes.gif new file mode 100644 index 0000000000000000000000000000000000000000..d7f5f2f4b18f8a141c7a5dd1e09ff106a2f9fa1e GIT binary patch literal 485 zcmZ?wbhEHb<Y(Y#*v!k|>gxLc6$23bKgaO@B*Xvz|NqTp_`ikW|G&xq{~!PVSNQ)^ zpx|qe3NTRo&+X?L671|4;A*62z|05~RQ$=p%EiFTpaW6>GM0fQZi6Rh*4!PT(*&f% z*$TRZ<}@?<IH+@^e^|D<jl-4kvDFIIJuv~xneLSANcj}tcp}bPqmk3VHhKMlEk+%c z{@hJom;cV=u=|w2*uZol`BZ|#itCv(PbJoCq(z9C3JW5vWMN=s;9y_|TFJGcBl5|f zup0}~S&*e!7}yzDfYRI>I^CYG*?eW$Pd$isBan+(fO1gn0b6dW=x%w~q}~tKE&`I~ zWZ+_80zw8BmJOU2m9Ux1yJ3o3D&v+$ZG#t4ZLVMy3?Qu_ZQMY+8CYaDcq&S-H42Fh z{c)CE%Sn@EnS+n-#i)qLlhWcv5Vs)dU<2w9+u*4hy}}}Vq4ah~j;>ScENX^v3nduQ d4TmZP8gAjeG<t?pM(dOSkJip<Pc+;ZtO5Mnhg<*v literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_sad.gif b/wp-includes/images/smilies/icon_sad.gif new file mode 100644 index 0000000000000000000000000000000000000000..d2ac78c04bd1f50059ce9c1fa9534dcee2195579 GIT binary patch literal 171 zcmZ?wbhEHb<Y(Y#*v!N5{}qF)t1ANo!~b&(|4%afo6GQj3&a0^lmGt}{{R2@|ECQ9 z|Gx&x!hzyX7DfgJ9tItd2*?ZumWT<Sl38<ST%CGOQe3QngK3VlppT>aoDCD!-THXQ zaD}Q`!Ef~@t%4VS^H`jpHe@qRnmW&T1rN_M_11z^Th4v=m-`t@{9)jl*%hj`<L+jk QqYmag#yZ@&LW~U70P4p+OaK4? literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_smile.gif b/wp-includes/images/smilies/icon_smile.gif new file mode 100644 index 0000000000000000000000000000000000000000..7b1f6d30449c976f49a4ff4f55558156a7084732 GIT binary patch literal 174 zcmZ?wbhEHb<Y(Y#*v!Z9{}qF)t1ANo!~b&(|4%af-@@>3F2nzSlmGt}{tp7jjg5`} z|9}1eDNqRrDE?$&WMJT9&;fBkW-zcsU+|R7ntLO3**QsZu>uaJIn9DTj_MrhAC|2y zn^DM@#l<(@zDcWq`B+oyDaGR~0+SdoFXD`_(PqAxy<2o0Q>0^(jhH~$tb+><nqH2` VYKr+M#>(~Mkip?iSJVU<tO2KmLF51c literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_surprised.gif b/wp-includes/images/smilies/icon_surprised.gif new file mode 100644 index 0000000000000000000000000000000000000000..cb21424319829487d477e5f17262891c1be03e8c GIT binary patch literal 174 zcmZ?wbhEHb<Y(Y#*v!lD{}qF)t1ANo!+#(+$MF9o!@s!<|F<yw|2O&nU*Z4%kN<xP zlzI(R00D|WSr{1@co}p+T#y+IEYTZ0C9~%42wf(iBraCq$uy@$(8p1oL;b_D)on8h z`Lek9=I?LPDqud=)Xt@JoJC|3<D55Nt!%Yf9wh7*)oEGn5O(0LSeX=4qNCa6h*wNs T*PIIB`*GOd@TMzjf(+IGZsI~j literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_twisted.gif b/wp-includes/images/smilies/icon_twisted.gif new file mode 100644 index 0000000000000000000000000000000000000000..502fe247e811741d6fa2cd4f45d1db7deff32501 GIT binary patch literal 238 zcmZ?wbhEHb<Y(Y#I3md4>gxLc6$23bKgaNIF2n!7!vD80{0DM@;NRr`CxMLP|FjsU zO`B$HZ2T{m`TzgdAk{<z#h)yU3=Dz{Iv^b&I~iEB6&PHWWK5cPa>j*8D$QDUE*nK$ z7w|KG>@aokb7%R&!0WI`LE+V`jZbtHGVEq^HDzd8gshBhJhWk{9N&@6Gj#R{?N7d_ u@Ss3Q_U6Qmr`{j;vSH$AZf0`Va5JoNi_%bKV4KJmrQFw{HdRBB!5RP#AxjVd literal 0 HcmV?d00001 diff --git a/wp-includes/images/smilies/icon_wink.gif b/wp-includes/images/smilies/icon_wink.gif new file mode 100644 index 0000000000000000000000000000000000000000..d1482880421dde677d3302940aa875ff22a11b06 GIT binary patch literal 170 zcmZ?wbhEHb<Y(Y#*v!N5{}qF)t1ANo!~b&(|4%afo6GQj3&a0^lmGt}{{R2@|ECQ9 z|Gx&x!hzyX7DfgJ9tItd2*?ZumhcIll38<ST%CGOQe3QngK3VlppT>a9D@n#Zhbsv zutHU>;J1F0R>6zE2`tV}8xE^#?@bGklrZsUYAp!;dbG*vY{CM88Jk-qvwbqQUtQFY Pm?x1IA$CiJiNP8Goi0B( literal 0 HcmV?d00001 diff --git a/wp-includes/js/colorpicker.js b/wp-includes/js/colorpicker.js new file mode 100644 index 00000000..2f0438ed --- /dev/null +++ b/wp-includes/js/colorpicker.js @@ -0,0 +1,707 @@ +// =================================================================== +// Author: Matt Kruse <matt@mattkruse.com> +// WWW: http://www.mattkruse.com/ +// +// NOTICE: You may use this code for any purpose, commercial or +// private, without any further permission from the author. You may +// remove this notice from your final code if you wish, however it is +// appreciated by the author if at least my web site address is kept. +// +// You may *NOT* re-distribute this code in any way except through its +// use. That means, you can include it in your product, or your web +// site, or any other form where the code is actually being used. You +// may not put the plain javascript up on your site for download or +// include it in your javascript libraries for download. +// If you wish to share this code with others, please just point them +// to the URL instead. +// Please DO NOT link directly to my .js files from your site. Copy +// the files to your server and use them there. Thank you. +// =================================================================== + + +/* SOURCE FILE: AnchorPosition.js */ + +/* +AnchorPosition.js +Author: Matt Kruse +Last modified: 10/11/02 + +DESCRIPTION: These functions find the position of an <A> tag in a document, +so other elements can be positioned relative to it. + +COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small +positioning errors - usually with Window positioning - occur on the +Macintosh platform. + +FUNCTIONS: +getAnchorPosition(anchorname) + Returns an Object() having .x and .y properties of the pixel coordinates + of the upper-left corner of the anchor. Position is relative to the PAGE. + +getAnchorWindowPosition(anchorname) + Returns an Object() having .x and .y properties of the pixel coordinates + of the upper-left corner of the anchor, relative to the WHOLE SCREEN. + +NOTES: + +1) For popping up separate browser windows, use getAnchorWindowPosition. + Otherwise, use getAnchorPosition + +2) Your anchor tag MUST contain both NAME and ID attributes which are the + same. For example: + <A NAME="test" ID="test"> </A> + +3) There must be at least a space between <A> </A> for IE5.5 to see the + anchor tag correctly. Do not do <A></A> with no space. +*/ + +// getAnchorPosition(anchorname) +// This function returns an object having .x and .y properties which are the coordinates +// of the named anchor, relative to the page. +function getAnchorPosition(anchorname) { + // This function will return an Object with x and y properties + var useWindow=false; + var coordinates=new Object(); + var x=0,y=0; + // Browser capability sniffing + var use_gebi=false, use_css=false, use_layers=false; + if (document.getElementById) { use_gebi=true; } + else if (document.all) { use_css=true; } + else if (document.layers) { use_layers=true; } + // Logic to find position + if (use_gebi && document.all) { + x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); + y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); + } + else if (use_gebi) { + var o=document.getElementById(anchorname); + x=AnchorPosition_getPageOffsetLeft(o); + y=AnchorPosition_getPageOffsetTop(o); + } + else if (use_css) { + x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); + y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); + } + else if (use_layers) { + var found=0; + for (var i=0; i<document.anchors.length; i++) { + if (document.anchors[i].name==anchorname) { found=1; break; } + } + if (found==0) { + coordinates.x=0; coordinates.y=0; return coordinates; + } + x=document.anchors[i].x; + y=document.anchors[i].y; + } + else { + coordinates.x=0; coordinates.y=0; return coordinates; + } + coordinates.x=x; + coordinates.y=y; + return coordinates; + } + +// getAnchorWindowPosition(anchorname) +// This function returns an object having .x and .y properties which are the coordinates +// of the named anchor, relative to the window +function getAnchorWindowPosition(anchorname) { + var coordinates=getAnchorPosition(anchorname); + var x=0; + var y=0; + if (document.getElementById) { + if (isNaN(window.screenX)) { + x=coordinates.x-document.body.scrollLeft+window.screenLeft; + y=coordinates.y-document.body.scrollTop+window.screenTop; + } + else { + x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset; + y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset; + } + } + else if (document.all) { + x=coordinates.x-document.body.scrollLeft+window.screenLeft; + y=coordinates.y-document.body.scrollTop+window.screenTop; + } + else if (document.layers) { + x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset; + y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset; + } + coordinates.x=x; + coordinates.y=y; + return coordinates; + } + +// Functions for IE to get position of an object +function AnchorPosition_getPageOffsetLeft (el) { + var ol=el.offsetLeft; + while ((el=el.offsetParent) != null) { ol += el.offsetLeft; } + return ol; + } +function AnchorPosition_getWindowOffsetLeft (el) { + return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft; + } +function AnchorPosition_getPageOffsetTop (el) { + var ot=el.offsetTop; + while((el=el.offsetParent) != null) { ot += el.offsetTop; } + return ot; + } +function AnchorPosition_getWindowOffsetTop (el) { + return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop; + } + +/* SOURCE FILE: PopupWindow.js */ + +/* +PopupWindow.js +Author: Matt Kruse +Last modified: 02/16/04 + +DESCRIPTION: This object allows you to easily and quickly popup a window +in a certain place. The window can either be a DIV or a separate browser +window. + +COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small +positioning errors - usually with Window positioning - occur on the +Macintosh platform. Due to bugs in Netscape 4.x, populating the popup +window with <STYLE> tags may cause errors. + +USAGE: +// Create an object for a WINDOW popup +var win = new PopupWindow(); + +// Create an object for a DIV window using the DIV named 'mydiv' +var win = new PopupWindow('mydiv'); + +// Set the window to automatically hide itself when the user clicks +// anywhere else on the page except the popup +win.autoHide(); + +// Show the window relative to the anchor name passed in +win.showPopup(anchorname); + +// Hide the popup +win.hidePopup(); + +// Set the size of the popup window (only applies to WINDOW popups +win.setSize(width,height); + +// Populate the contents of the popup window that will be shown. If you +// change the contents while it is displayed, you will need to refresh() +win.populate(string); + +// set the URL of the window, rather than populating its contents +// manually +win.setUrl("http://www.site.com/"); + +// Refresh the contents of the popup +win.refresh(); + +// Specify how many pixels to the right of the anchor the popup will appear +win.offsetX = 50; + +// Specify how many pixels below the anchor the popup will appear +win.offsetY = 100; + +NOTES: +1) Requires the functions in AnchorPosition.js + +2) Your anchor tag MUST contain both NAME and ID attributes which are the + same. For example: + <A NAME="test" ID="test"> </A> + +3) There must be at least a space between <A> </A> for IE5.5 to see the + anchor tag correctly. Do not do <A></A> with no space. + +4) When a PopupWindow object is created, a handler for 'onmouseup' is + attached to any event handler you may have already defined. Do NOT define + an event handler for 'onmouseup' after you define a PopupWindow object or + the autoHide() will not work correctly. +*/ + +// Set the position of the popup window based on the anchor +function PopupWindow_getXYPosition(anchorname) { + var coordinates; + if (this.type == "WINDOW") { + coordinates = getAnchorWindowPosition(anchorname); + } + else { + coordinates = getAnchorPosition(anchorname); + } + this.x = coordinates.x; + this.y = coordinates.y; + } +// Set width/height of DIV/popup window +function PopupWindow_setSize(width,height) { + this.width = width; + this.height = height; + } +// Fill the window with contents +function PopupWindow_populate(contents) { + this.contents = contents; + this.populated = false; + } +// Set the URL to go to +function PopupWindow_setUrl(url) { + this.url = url; + } +// Set the window popup properties +function PopupWindow_setWindowProperties(props) { + this.windowProperties = props; + } +// Refresh the displayed contents of the popup +function PopupWindow_refresh() { + if (this.divName != null) { + // refresh the DIV object + if (this.use_gebi) { + document.getElementById(this.divName).innerHTML = this.contents; + } + else if (this.use_css) { + document.all[this.divName].innerHTML = this.contents; + } + else if (this.use_layers) { + var d = document.layers[this.divName]; + d.document.open(); + d.document.writeln(this.contents); + d.document.close(); + } + } + else { + if (this.popupWindow != null && !this.popupWindow.closed) { + if (this.url!="") { + this.popupWindow.location.href=this.url; + } + else { + this.popupWindow.document.open(); + this.popupWindow.document.writeln(this.contents); + this.popupWindow.document.close(); + } + this.popupWindow.focus(); + } + } + } +// Position and show the popup, relative to an anchor object +function PopupWindow_showPopup(anchorname) { + this.getXYPosition(anchorname); + this.x += this.offsetX; + this.y += this.offsetY; + if (!this.populated && (this.contents != "")) { + this.populated = true; + this.refresh(); + } + if (this.divName != null) { + // Show the DIV object + if (this.use_gebi) { + document.getElementById(this.divName).style.left = this.x + "px"; + document.getElementById(this.divName).style.top = this.y; + document.getElementById(this.divName).style.visibility = "visible"; + } + else if (this.use_css) { + document.all[this.divName].style.left = this.x; + document.all[this.divName].style.top = this.y; + document.all[this.divName].style.visibility = "visible"; + } + else if (this.use_layers) { + document.layers[this.divName].left = this.x; + document.layers[this.divName].top = this.y; + document.layers[this.divName].visibility = "visible"; + } + } + else { + if (this.popupWindow == null || this.popupWindow.closed) { + // If the popup window will go off-screen, move it so it doesn't + if (this.x<0) { this.x=0; } + if (this.y<0) { this.y=0; } + if (screen && screen.availHeight) { + if ((this.y + this.height) > screen.availHeight) { + this.y = screen.availHeight - this.height; + } + } + if (screen && screen.availWidth) { + if ((this.x + this.width) > screen.availWidth) { + this.x = screen.availWidth - this.width; + } + } + var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ); + this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+""); + } + this.refresh(); + } + } +// Hide the popup +function PopupWindow_hidePopup() { + if (this.divName != null) { + if (this.use_gebi) { + document.getElementById(this.divName).style.visibility = "hidden"; + } + else if (this.use_css) { + document.all[this.divName].style.visibility = "hidden"; + } + else if (this.use_layers) { + document.layers[this.divName].visibility = "hidden"; + } + } + else { + if (this.popupWindow && !this.popupWindow.closed) { + this.popupWindow.close(); + this.popupWindow = null; + } + } + } +// Pass an event and return whether or not it was the popup DIV that was clicked +function PopupWindow_isClicked(e) { + if (this.divName != null) { + if (this.use_layers) { + var clickX = e.pageX; + var clickY = e.pageY; + var t = document.layers[this.divName]; + if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) { + return true; + } + else { return false; } + } + else if (document.all) { // Need to hard-code this to trap IE for error-handling + var t = window.event.srcElement; + while (t.parentElement != null) { + if (t.id==this.divName) { + return true; + } + t = t.parentElement; + } + return false; + } + else if (this.use_gebi && e) { + var t = e.originalTarget; + while (t.parentNode != null) { + if (t.id==this.divName) { + return true; + } + t = t.parentNode; + } + return false; + } + return false; + } + return false; + } + +// Check an onMouseDown event to see if we should hide +function PopupWindow_hideIfNotClicked(e) { + if (this.autoHideEnabled && !this.isClicked(e)) { + this.hidePopup(); + } + } +// Call this to make the DIV disable automatically when mouse is clicked outside it +function PopupWindow_autoHide() { + this.autoHideEnabled = true; + } +// This global function checks all PopupWindow objects onmouseup to see if they should be hidden +function PopupWindow_hidePopupWindows(e) { + for (var i=0; i<popupWindowObjects.length; i++) { + if (popupWindowObjects[i] != null) { + var p = popupWindowObjects[i]; + p.hideIfNotClicked(e); + } + } + } +// Run this immediately to attach the event listener +function PopupWindow_attachListener() { + if (document.layers) { + document.captureEvents(Event.MOUSEUP); + } + window.popupWindowOldEventListener = document.onmouseup; + if (window.popupWindowOldEventListener != null) { + document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();"); + } + else { + document.onmouseup = PopupWindow_hidePopupWindows; + } + } +// CONSTRUCTOR for the PopupWindow object +// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup +function PopupWindow() { + if (!window.popupWindowIndex) { window.popupWindowIndex = 0; } + if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); } + if (!window.listenerAttached) { + window.listenerAttached = true; + PopupWindow_attachListener(); + } + this.index = popupWindowIndex++; + popupWindowObjects[this.index] = this; + this.divName = null; + this.popupWindow = null; + this.width=0; + this.height=0; + this.populated = false; + this.visible = false; + this.autoHideEnabled = false; + + this.contents = ""; + this.url=""; + this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no"; + if (arguments.length>0) { + this.type="DIV"; + this.divName = arguments[0]; + } + else { + this.type="WINDOW"; + } + this.use_gebi = false; + this.use_css = false; + this.use_layers = false; + if (document.getElementById) { this.use_gebi = true; } + else if (document.all) { this.use_css = true; } + else if (document.layers) { this.use_layers = true; } + else { this.type = "WINDOW"; } + this.offsetX = 0; + this.offsetY = 0; + // Method mappings + this.getXYPosition = PopupWindow_getXYPosition; + this.populate = PopupWindow_populate; + this.setUrl = PopupWindow_setUrl; + this.setWindowProperties = PopupWindow_setWindowProperties; + this.refresh = PopupWindow_refresh; + this.showPopup = PopupWindow_showPopup; + this.hidePopup = PopupWindow_hidePopup; + this.setSize = PopupWindow_setSize; + this.isClicked = PopupWindow_isClicked; + this.autoHide = PopupWindow_autoHide; + this.hideIfNotClicked = PopupWindow_hideIfNotClicked; + } + +/* SOURCE FILE: ColorPicker2.js */ + +/* +Last modified: 02/24/2003 + +DESCRIPTION: This widget is used to select a color, in hexadecimal #RRGGBB +form. It uses a color "swatch" to display the standard 216-color web-safe +palette. The user can then click on a color to select it. + +COMPATABILITY: See notes in AnchorPosition.js and PopupWindow.js. +Only the latest DHTML-capable browsers will show the color and hex values +at the bottom as your mouse goes over them. + +USAGE: +// Create a new ColorPicker object using DHTML popup +var cp = new ColorPicker(); + +// Create a new ColorPicker object using Window Popup +var cp = new ColorPicker('window'); + +// Add a link in your page to trigger the popup. For example: +<A HREF="#" onClick="cp.show('pick');return false;" NAME="pick" ID="pick">Pick</A> + +// Or use the built-in "select" function to do the dirty work for you: +<A HREF="#" onClick="cp.select(document.forms[0].color,'pick');return false;" NAME="pick" ID="pick">Pick</A> + +// If using DHTML popup, write out the required DIV tag near the bottom +// of your page. +<SCRIPT LANGUAGE="JavaScript">cp.writeDiv()</SCRIPT> + +// Write the 'pickColor' function that will be called when the user clicks +// a color and do something with the value. This is only required if you +// want to do something other than simply populate a form field, which is +// what the 'select' function will give you. +function pickColor(color) { + field.value = color; + } + +NOTES: +1) Requires the functions in AnchorPosition.js and PopupWindow.js + +2) Your anchor tag MUST contain both NAME and ID attributes which are the + same. For example: + <A NAME="test" ID="test"> </A> + +3) There must be at least a space between <A> </A> for IE5.5 to see the + anchor tag correctly. Do not do <A></A> with no space. + +4) When a ColorPicker object is created, a handler for 'onmouseup' is + attached to any event handler you may have already defined. Do NOT define + an event handler for 'onmouseup' after you define a ColorPicker object or + the color picker will not hide itself correctly. +*/ +ColorPicker_targetInput = null; +function ColorPicker_writeDiv() { + document.writeln("<DIV ID=\"colorPickerDiv\" STYLE=\"position:absolute;visibility:hidden;\"> </DIV>"); + } + +function ColorPicker_show(anchorname) { + this.showPopup(anchorname); + } + +function ColorPicker_pickColor(color,obj) { + obj.hidePopup(); + pickColor(color); + } + +// A Default "pickColor" function to accept the color passed back from popup. +// User can over-ride this with their own function. +function pickColor(color) { + if (ColorPicker_targetInput==null) { + alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickColor' function to handle the picked color!"); + return; + } + ColorPicker_targetInput.value = color; + } + +// This function is the easiest way to popup the window, select a color, and +// have the value populate a form field, which is what most people want to do. +function ColorPicker_select(inputobj,linkname) { + if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { + alert("colorpicker.select: Input object passed is not a valid form input object"); + window.ColorPicker_targetInput=null; + return; + } + window.ColorPicker_targetInput = inputobj; + this.show(linkname); + } + +// This function runs when you move your mouse over a color block, if you have a newer browser +function ColorPicker_highlightColor(c) { + var thedoc = (arguments.length>1)?arguments[1]:window.document; + var d = thedoc.getElementById("colorPickerSelectedColor"); + d.style.backgroundColor = c; + d = thedoc.getElementById("colorPickerSelectedColorValue"); + d.innerHTML = c; + } + +function ColorPicker() { + var windowMode = false; + // Create a new PopupWindow object + if (arguments.length==0) { + var divname = "colorPickerDiv"; + } + else if (arguments[0] == "window") { + var divname = ''; + windowMode = true; + } + else { + var divname = arguments[0]; + } + + if (divname != "") { + var cp = new PopupWindow(divname); + } + else { + var cp = new PopupWindow(); + cp.setSize(225,250); + } + + // Object variables + cp.currentValue = "#FFFFFF"; + + // Method Mappings + cp.writeDiv = ColorPicker_writeDiv; + cp.highlightColor = ColorPicker_highlightColor; + cp.show = ColorPicker_show; + cp.select = ColorPicker_select; + + // Code to populate color picker window + var colors = new Array( "#4180B6","#69AEE7","#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","#7FFFFF","#7FFFFF","#7FF7F7","#7FEFEF","#7FE7E7","#7FDFDF","#7FD7D7","#7FCFCF","#7FC7C7","#7FBFBF", + "#7FB7B7","#7FAFAF","#7FA7A7","#7F9F9F","#7F9797","#7F8F8F","#7F8787","#7F7F7F","#7F7777","#7F6F6F","#7F6767","#7F5F5F", + "#7F5757","#7F4F4F","#7F4747","#7F3F3F","#7F3737","#7F2F2F","#7F2727","#7F1F1F","#7F1717","#7F0F0F","#7F0707","#7F0000", + + "#4180B6","#69AEE7","#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","#FF7FFF","#FF7FFF","#F77FF7","#EF7FEF","#E77FE7","#DF7FDF","#D77FD7","#CF7FCF","#C77FC7","#BF7FBF", + "#B77FB7","#AF7FAF","#A77FA7","#9F7F9F","#977F97","#8F7F8F","#877F87","#7F7F7F","#777F77","#6F7F6F","#677F67","#5F7F5F", + "#577F57","#4F7F4F","#477F47","#3F7F3F","#377F37","#2F7F2F","#277F27","#1F7F1F","#177F17","#0F7F0F","#077F07","#007F00", + + "#4180B6","#69AEE7","#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","#FFFF7F","#FFFF7F","#F7F77F","#EFEF7F","#E7E77F","#DFDF7F","#D7D77F","#CFCF7F","#C7C77F","#BFBF7F", + "#B7B77F","#AFAF7F","#A7A77F","#9F9F7F","#97977F","#8F8F7F","#87877F","#7F7F7F","#77777F","#6F6F7F","#67677F","#5F5F7F", + "#57577F","#4F4F7F","#47477F","#3F3F7F","#37377F","#2F2F7F","#27277F","#1F1F7F","#17177F","#0F0F7F","#07077F","#00007F", + + "#4180B6","#69AEE7","#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","#3FFFFF","#3FFFFF","#3FF7F7","#3FEFEF","#3FE7E7","#3FDFDF","#3FD7D7","#3FCFCF","#3FC7C7","#3FBFBF", + "#3FB7B7","#3FAFAF","#3FA7A7","#3F9F9F","#3F9797","#3F8F8F","#3F8787","#3F7F7F","#3F7777","#3F6F6F","#3F6767","#3F5F5F", + "#3F5757","#3F4F4F","#3F4747","#3F3F3F","#3F3737","#3F2F2F","#3F2727","#3F1F1F","#3F1717","#3F0F0F","#3F0707","#3F0000", + + "#4180B6","#69AEE7","#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","#FF3FFF","#FF3FFF","#F73FF7","#EF3FEF","#E73FE7","#DF3FDF","#D73FD7","#CF3FCF","#C73FC7","#BF3FBF", + "#B73FB7","#AF3FAF","#A73FA7","#9F3F9F","#973F97","#8F3F8F","#873F87","#7F3F7F","#773F77","#6F3F6F","#673F67","#5F3F5F", + "#573F57","#4F3F4F","#473F47","#3F3F3F","#373F37","#2F3F2F","#273F27","#1F3F1F","#173F17","#0F3F0F","#073F07","#003F00", + + "#4180B6","#69AEE7","#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","#FFFF3F","#FFFF3F","#F7F73F","#EFEF3F","#E7E73F","#DFDF3F","#D7D73F","#CFCF3F","#C7C73F","#BFBF3F", + "#B7B73F","#AFAF3F","#A7A73F","#9F9F3F","#97973F","#8F8F3F","#87873F","#7F7F3F","#77773F","#6F6F3F","#67673F","#5F5F3F", + "#57573F","#4F4F3F","#47473F","#3F3F3F","#37373F","#2F2F3F","#27273F","#1F1F3F","#17173F","#0F0F3F","#07073F","#00003F", + + "#4180B6","#69AEE7","#FFFFFF","#FFEEEE","#FFDDDD","#FFCCCC","#FFBBBB","#FFAAAA","#FF9999","#FF8888","#FF7777","#FF6666", + "#FF5555","#FF4444","#FF3333","#FF2222","#FF1111","#FF0000","#FF0000","#FF0000","#FF0000","#EE0000","#DD0000","#CC0000", + "#BB0000","#AA0000","#990000","#880000","#770000","#660000","#550000","#440000","#330000","#220000","#110000","#000000", + "#000000","#000000","#000000","#001111","#002222","#003333","#004444","#005555","#006666","#007777","#008888","#009999", + "#00AAAA","#00BBBB","#00CCCC","#00DDDD","#00EEEE","#00FFFF","#00FFFF","#00FFFF","#00FFFF","#11FFFF","#22FFFF","#33FFFF", + "#44FFFF","#55FFFF","#66FFFF","#77FFFF","#88FFFF","#99FFFF","#AAFFFF","#BBFFFF","#CCFFFF","#DDFFFF","#EEFFFF","#FFFFFF", + + "#4180B6","#69AEE7","#FFFFFF","#EEFFEE","#DDFFDD","#CCFFCC","#BBFFBB","#AAFFAA","#99FF99","#88FF88","#77FF77","#66FF66", + "#55FF55","#44FF44","#33FF33","#22FF22","#11FF11","#00FF00","#00FF00","#00FF00","#00FF00","#00EE00","#00DD00","#00CC00", + "#00BB00","#00AA00","#009900","#008800","#007700","#006600","#005500","#004400","#003300","#002200","#001100","#000000", + "#000000","#000000","#000000","#110011","#220022","#330033","#440044","#550055","#660066","#770077","#880088","#990099", + "#AA00AA","#BB00BB","#CC00CC","#DD00DD","#EE00EE","#FF00FF","#FF00FF","#FF00FF","#FF00FF","#FF11FF","#FF22FF","#FF33FF", + "#FF44FF","#FF55FF","#FF66FF","#FF77FF","#FF88FF","#FF99FF","#FFAAFF","#FFBBFF","#FFCCFF","#FFDDFF","#FFEEFF","#FFFFFF", + + "#4180B6","#69AEE7","#FFFFFF","#EEEEFF","#DDDDFF","#CCCCFF","#BBBBFF","#AAAAFF","#9999FF","#8888FF","#7777FF","#6666FF", + "#5555FF","#4444FF","#3333FF","#2222FF","#1111FF","#0000FF","#0000FF","#0000FF","#0000FF","#0000EE","#0000DD","#0000CC", + "#0000BB","#0000AA","#000099","#000088","#000077","#000066","#000055","#000044","#000033","#000022","#000011","#000000", + "#000000","#000000","#000000","#111100","#222200","#333300","#444400","#555500","#666600","#777700","#888800","#999900", + "#AAAA00","#BBBB00","#CCCC00","#DDDD00","#EEEE00","#FFFF00","#FFFF00","#FFFF00","#FFFF00","#FFFF11","#FFFF22","#FFFF33", + "#FFFF44","#FFFF55","#FFFF66","#FFFF77","#FFFF88","#FFFF99","#FFFFAA","#FFFFBB","#FFFFCC","#FFFFDD","#FFFFEE","#FFFFFF", + + "#4180B6","#69AEE7","#FFFFFF","#FFFFFF","#FBFBFB","#F7F7F7","#F3F3F3","#EFEFEF","#EBEBEB","#E7E7E7","#E3E3E3","#DFDFDF", + "#DBDBDB","#D7D7D7","#D3D3D3","#CFCFCF","#CBCBCB","#C7C7C7","#C3C3C3","#BFBFBF","#BBBBBB","#B7B7B7","#B3B3B3","#AFAFAF", + "#ABABAB","#A7A7A7","#A3A3A3","#9F9F9F","#9B9B9B","#979797","#939393","#8F8F8F","#8B8B8B","#878787","#838383","#7F7F7F", + "#7B7B7B","#777777","#737373","#6F6F6F","#6B6B6B","#676767","#636363","#5F5F5F","#5B5B5B","#575757","#535353","#4F4F4F", + "#4B4B4B","#474747","#434343","#3F3F3F","#3B3B3B","#373737","#333333","#2F2F2F","#2B2B2B","#272727","#232323","#1F1F1F", + "#1B1B1B","#171717","#131313","#0F0F0F","#0B0B0B","#070707","#030303","#000000","#000000","#000000","#000000","#000000"); + var total = colors.length; + var width = 72; + var cp_contents = ""; + var windowRef = (windowMode)?"window.opener.":""; + if (windowMode) { + cp_contents += "<html><head><title>Select Color"; + cp_contents += "
    "; + } + cp_contents += ""; + var use_highlight = (document.getElementById || document.all)?true:false; + for (var i=0; i '; + if ( ((i+1)>=total) || (((i+1) % width) == 0)) { + cp_contents += ""; + } + } + // If the browser supports dynamically changing TD cells, add the fancy stuff + if (document.getElementById) { + var width1 = Math.floor(width/2); + var width2 = width = width1; + cp_contents += ""; + } + cp_contents += "
     #FFFFFF
    "; + if (windowMode) { + cp_contents += "
    "; + } + // end populate code + + // Write the contents to the popup object + cp.populate(cp_contents+"\n"); + // Move the table down a bit so you can see it + cp.offsetY = 25; + cp.autoHide(); + return cp; + } diff --git a/wp-includes/js/dbx-key.js b/wp-includes/js/dbx-key.js new file mode 100644 index 00000000..f7155de8 --- /dev/null +++ b/wp-includes/js/dbx-key.js @@ -0,0 +1,39 @@ + +//initialisation function +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'] + 'open', // word for "open", as in "open this box" + 'close', // word for "close", as in "close this box" + 'click-down and drag to move this box', // sentence for "move this box" by mouse + 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse + 'use the arrow keys to move this box', // sentence for "move this box" by keyboard + ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard + '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts + ); + + var advanced = new dbxGroup( + 'advancedstuff', // container ID [/-_a-zA-Z0-9/] + 'vertical', // orientation ['vertical'|'horizontal'] + '10', // drag threshold ['n' pixels] + 'yes', // 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'] + 'open', // word for "open", as in "open this box" + 'close', // word for "close", as in "close this box" + 'click-down and drag to move this box', // sentence for "move this box" by mouse + 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse + 'use the arrow keys to move this box', // sentence for "move this box" by keyboard + ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard + '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts + ); +}); diff --git a/wp-includes/js/dbx.js b/wp-includes/js/dbx.js new file mode 100644 index 00000000..8bf5b463 --- /dev/null +++ b/wp-includes/js/dbx.js @@ -0,0 +1,6 @@ +// DBX2.01 :: 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');if(typeof this.onstatechange == 'undefined' || this.onstatechange()){document.cookie = 'dbx-' + this.sid + '='+ this.state+ '; 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('&');for(var i in this.cookie){if(typeof this.cookie[i]!='function'){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; i' +,'' +,'b' +); + +edButtons[edButtons.length] = +new edButton('ed_em' +,'i' +,'' +,'' +,'i' +); + +edButtons[edButtons.length] = +new edButton('ed_link' +,'link' +,'' +,'' +,'a' +); // special case + +edButtons[edButtons.length] = +new edButton('ed_block' +,'b-quote' +,'\n\n
    ' +,'
    \n\n' +,'q' +); + + +edButtons[edButtons.length] = +new edButton('ed_del' +,'del' +,'' +,'' +,'d' +); + +edButtons[edButtons.length] = +new edButton('ed_ins' +,'ins' +,'' +,'' +,'s' +); + +edButtons[edButtons.length] = +new edButton('ed_img' +,'img' +,'' +,'' +,'m' +,-1 +); // special case + +edButtons[edButtons.length] = +new edButton('ed_ul' +,'ul' +,'
      \n' +,'
    \n\n' +,'u' +); + +edButtons[edButtons.length] = +new edButton('ed_ol' +,'ol' +,'
      \n' +,'
    \n\n' +,'o' +); + +edButtons[edButtons.length] = +new edButton('ed_li' +,'li' +,'\t
  • ' +,'
  • \n' +,'l' +); + +edButtons[edButtons.length] = +new edButton('ed_code' +,'code' +,'' +,'' +,'c' +); + +edButtons[edButtons.length] = +new edButton('ed_more' +,'more' +,'' +,'' +,'t' +,-1 +); +/* +edButtons[edButtons.length] = +new edButton('ed_next' +,'page' +,'' +,'' +,'p' +,-1 +); +*/ +function edLink() { + this.display = ''; + this.URL = ''; + this.newWin = 0; +} + +edLinks[edLinks.length] = new edLink('WordPress' + ,'http://wordpress.org/' + ); + +edLinks[edLinks.length] = new edLink('alexking.org' + ,'http://www.alexking.org/' + ); + +function edShowButton(button, i) { + if (button.id == 'ed_img') { + document.write(''); + } + else if (button.id == 'ed_link') { + document.write(''); + } + else { + document.write(''); + } +} + +function edShowLinks() { + var tempStr = ''; + document.write(tempStr); +} + +function edAddTag(button) { + if (edButtons[button].tagEnd != '') { + edOpenTags[edOpenTags.length] = button; + document.getElementById(edButtons[button].id).value = '/' + document.getElementById(edButtons[button].id).value; + } +} + +function edRemoveTag(button) { + for (i = 0; i < edOpenTags.length; i++) { + if (edOpenTags[i] == button) { + edOpenTags.splice(i, 1); + document.getElementById(edButtons[button].id).value = document.getElementById(edButtons[button].id).value.replace('/', ''); + } + } +} + +function edCheckOpenTags(button) { + var tag = 0; + for (i = 0; i < edOpenTags.length; i++) { + if (edOpenTags[i] == button) { + tag++; + } + } + if (tag > 0) { + return true; // tag found + } + else { + return false; // tag not found + } +} + +function edCloseAllTags() { + var count = edOpenTags.length; + for (o = 0; o < count; o++) { + edInsertTag(edCanvas, edOpenTags[edOpenTags.length - 1]); + } +} + +function edQuickLink(i, thisSelect) { + if (i > -1) { + var newWin = ''; + if (edLinks[i].newWin == 1) { + newWin = ' target="_blank"'; + } + var tempStr = '' + + edLinks[i].display + + ''; + thisSelect.selectedIndex = 0; + edInsertContent(edCanvas, tempStr); + } + else { + thisSelect.selectedIndex = 0; + } +} + +function edSpell(myField) { + var word = ''; + if (document.selection) { + myField.focus(); + var sel = document.selection.createRange(); + if (sel.text.length > 0) { + word = sel.text; + } + } + else if (myField.selectionStart || myField.selectionStart == '0') { + var startPos = myField.selectionStart; + var endPos = myField.selectionEnd; + if (startPos != endPos) { + word = myField.value.substring(startPos, endPos); + } + } + if (word == '') { + word = prompt('Enter a word to look up:', ''); + } + if (word !== null && /^\w[\w ]*$/.test(word)) { + window.open('http://www.answers.com/' + escape(word)); + } +} + +function edToolbar() { + document.write('
    '); + for (i = 0; i < edButtons.length; i++) { + edShowButton(edButtons[i], i); + } + document.write(''); + document.write(''); +// edShowLinks(); // disabled by default + document.write('
    '); +} + +// insertion code + +function edInsertTag(myField, i) { + //IE support + if (document.selection) { + myField.focus(); + sel = document.selection.createRange(); + if (sel.text.length > 0) { + sel.text = edButtons[i].tagStart + sel.text + edButtons[i].tagEnd; + } + else { + if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') { + sel.text = edButtons[i].tagStart; + edAddTag(i); + } + else { + sel.text = edButtons[i].tagEnd; + edRemoveTag(i); + } + } + myField.focus(); + } + //MOZILLA/NETSCAPE support + else if (myField.selectionStart || myField.selectionStart == '0') { + var startPos = myField.selectionStart; + var endPos = myField.selectionEnd; + var cursorPos = endPos; + var scrollTop = myField.scrollTop; + + if (startPos != endPos) { + myField.value = myField.value.substring(0, startPos) + + edButtons[i].tagStart + + myField.value.substring(startPos, endPos) + + edButtons[i].tagEnd + + myField.value.substring(endPos, myField.value.length); + cursorPos += edButtons[i].tagStart.length + edButtons[i].tagEnd.length; + } + else { + if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') { + myField.value = myField.value.substring(0, startPos) + + edButtons[i].tagStart + + myField.value.substring(endPos, myField.value.length); + edAddTag(i); + cursorPos = startPos + edButtons[i].tagStart.length; + } + else { + myField.value = myField.value.substring(0, startPos) + + edButtons[i].tagEnd + + myField.value.substring(endPos, myField.value.length); + edRemoveTag(i); + cursorPos = startPos + edButtons[i].tagEnd.length; + } + } + myField.focus(); + myField.selectionStart = cursorPos; + myField.selectionEnd = cursorPos; + myField.scrollTop = scrollTop; + } + else { + if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') { + myField.value += edButtons[i].tagStart; + edAddTag(i); + } + else { + myField.value += edButtons[i].tagEnd; + edRemoveTag(i); + } + myField.focus(); + } +} + +function edInsertContent(myField, myValue) { + //IE support + if (document.selection) { + myField.focus(); + sel = document.selection.createRange(); + sel.text = myValue; + myField.focus(); + } + //MOZILLA/NETSCAPE support + else if (myField.selectionStart || myField.selectionStart == '0') { + var startPos = myField.selectionStart; + var endPos = myField.selectionEnd; + myField.value = myField.value.substring(0, startPos) + + myValue + + myField.value.substring(endPos, myField.value.length); + myField.focus(); + myField.selectionStart = startPos + myValue.length; + myField.selectionEnd = startPos + myValue.length; + } else { + myField.value += myValue; + myField.focus(); + } +} + +function edInsertLink(myField, i, defaultValue) { + if (!defaultValue) { + defaultValue = 'http://'; + } + if (!edCheckOpenTags(i)) { + var URL = prompt('Enter the URL' ,defaultValue); + if (URL) { + edButtons[i].tagStart = ''; + edInsertTag(myField, i); + } + } + else { + edInsertTag(myField, i); + } +} + +function edInsertImage(myField) { + var myValue = prompt('Enter the URL of the image', 'http://'); + if (myValue) { + myValue = '' + prompt('Enter a description of the image', '') 
+				+ ''; + edInsertContent(myField, myValue); + } +} diff --git a/wp-includes/js/tinymce/blank.htm b/wp-includes/js/tinymce/blank.htm new file mode 100644 index 00000000..c1ff8352 --- /dev/null +++ b/wp-includes/js/tinymce/blank.htm @@ -0,0 +1,9 @@ + + + blank_page + + + + + + diff --git a/wp-includes/js/tinymce/langs/en.js b/wp-includes/js/tinymce/langs/en.js new file mode 100644 index 00000000..f6ffe127 --- /dev/null +++ b/wp-includes/js/tinymce/langs/en.js @@ -0,0 +1,47 @@ +// UK lang variables + +if (navigator.userAgent.indexOf('Mac OS') != -1) { +// Mac OS browsers use Ctrl to hit accesskeys + var metaKey = 'Ctrl'; +} +else { + var metaKey = 'Alt'; +} + +tinyMCELang['lang_bold_desc'] = 'Bold (' + metaKey + '+b)'; +tinyMCELang['lang_italic_desc'] = 'Italic (' + metaKey + '+i)'; +tinyMCELang['lang_underline_desc'] = 'Underline'; +tinyMCELang['lang_striketrough_desc'] = 'Striketrough (' + metaKey + '-d)'; +tinyMCELang['lang_justifyleft_desc'] = 'Align left (' + metaKey + '-f)'; +tinyMCELang['lang_justifycenter_desc'] = 'Align center (' + metaKey + '-c)'; +tinyMCELang['lang_justifyright_desc'] = 'Align right (' + metaKey + '-r)'; +tinyMCELang['lang_justifyfull_desc'] = 'Align full'; +tinyMCELang['lang_bullist_desc'] = 'Unordered list (' + metaKey + '-l)'; +tinyMCELang['lang_numlist_desc'] = 'Ordered list (' + metaKey + '-o)'; +tinyMCELang['lang_outdent_desc'] = 'Outdent (' + metaKey + '-w)'; +tinyMCELang['lang_indent_desc'] = 'Indent/Blockquote (' + metaKey + '-q)'; +tinyMCELang['lang_undo_desc'] = 'Undo (' + metaKey + '-u)'; +tinyMCELang['lang_redo_desc'] = 'Redo (' + metaKey + '-y)'; +tinyMCELang['lang_link_desc'] = 'Insert/edit link (' + metaKey + '-a)'; +tinyMCELang['lang_unlink_desc'] = 'Unlink (' + metaKey + '-s)'; +tinyMCELang['lang_image_desc'] = 'Insert/edit image (' + metaKey + '-m)'; +tinyMCELang['lang_cleanup_desc'] = 'Cleanup messy code'; +tinyMCELang['lang_focus_alert'] = 'A editor instance must be focused before using this command.'; +tinyMCELang['lang_edit_confirm'] = 'Do you want to use the WYSIWYG mode for this textarea?'; +tinyMCELang['lang_insert_link_title'] = 'Insert/edit link'; +tinyMCELang['lang_insert'] = 'Insert'; +tinyMCELang['lang_update'] = 'Update'; +tinyMCELang['lang_cancel'] = 'Cancel'; +tinyMCELang['lang_insert_link_url'] = 'Link URL'; +tinyMCELang['lang_insert_link_target'] = 'Target'; +tinyMCELang['lang_insert_link_target_same'] = 'Open link in the same window'; +tinyMCELang['lang_insert_link_target_blank'] = 'Open link in a new window'; +tinyMCELang['lang_insert_image_title'] = 'Insert/edit image'; +tinyMCELang['lang_insert_image_src'] = 'Image URL'; +tinyMCELang['lang_insert_image_alt'] = 'Image description'; +tinyMCELang['lang_help_desc'] = 'Help'; +tinyMCELang['lang_bold_img'] = "bold.gif"; +tinyMCELang['lang_italic_img'] = "italic.gif"; +tinyMCELang['lang_underline_img'] = "underline.gif"; +tinyMCELang['lang_clipboard_msg'] = 'Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?'; +tinyMCELang['lang_popup_blocked'] = 'Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.'; diff --git a/wp-includes/js/tinymce/license.html b/wp-includes/js/tinymce/license.html new file mode 100644 index 00000000..c0c9c9ad --- /dev/null +++ b/wp-includes/js/tinymce/license.html @@ -0,0 +1,465 @@ + + + +TinyMCE License (LGPL) + + + + +
    +

    TinyMCE License (LGPL)

    +
    + +
    +

    +Visit the FAQ for general answers surrounding TinyMCE. Or visit http://www.fsf.org for more information about Open-Source licenses. +

    +
    +		  GNU LIBRARY GENERAL PUBLIC LICENSE
    +		       Version 2, June 1991
    +
    + Copyright (C) 1991 Free Software Foundation, Inc.
    + 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    + Everyone is permitted to copy and distribute verbatim copies
    + of this license document, but changing it is not allowed.
    +
    +[This is the first released version of the library GPL.  It is
    + numbered 2 because it goes with version 2 of the ordinary GPL.]
    +
    +			    Preamble
    +
    +  The licenses for most software are designed to take away your
    +freedom to share and change it.  By contrast, the GNU General Public
    +Licenses are intended to guarantee your freedom to share and change
    +free software--to make sure the software is free for all its users.
    +
    +  This license, the Library General Public License, applies to some
    +specially designated Free Software Foundation software, and to any
    +other libraries whose authors decide to use it.  You can use it for
    +your libraries, too.
    +
    +  When we speak of free software, we are referring to freedom, not
    +price.  Our General Public Licenses are designed to make sure that you
    +have the freedom to distribute copies of free software (and charge for
    +this service if you wish), that you receive source code or can get it
    +if you want it, that you can change the software or use pieces of it
    +in new free programs; and that you know you can do these things.
    +
    +  To protect your rights, we need to make restrictions that forbid
    +anyone to deny you these rights or to ask you to surrender the rights.
    +These restrictions translate to certain responsibilities for you if
    +you distribute copies of the library, or if you modify it.
    +
    +  For example, if you distribute copies of the library, whether gratis
    +or for a fee, you must give the recipients all the rights that we gave
    +you.  You must make sure that they, too, receive or can get the source
    +code.  If you link a program with the library, you must provide
    +complete object files to the recipients so that they can relink them
    +with the library, after making changes to the library and recompiling
    +it.  And you must show them these terms so they know their rights.
    +
    +  Our method of protecting your rights has two steps: (1) copyright
    +the library, and (2) offer you this license which gives you legal
    +permission to copy, distribute and/or modify the library.
    +
    +  Also, for each distributor's protection, we want to make certain
    +that everyone understands that there is no warranty for this free
    +library.  If the library is modified by someone else and passed on, we
    +want its recipients to know that what they have is not the original
    +version, so that any problems introduced by others will not reflect on
    +the original authors' reputations.
    +.
    +  Finally, any free program is threatened constantly by software
    +patents.  We wish to avoid the danger that companies distributing free
    +software will individually obtain patent licenses, thus in effect
    +transforming the program into proprietary software.  To prevent this,
    +we have made it clear that any patent must be licensed for everyone's
    +free use or not licensed at all.
    +
    +  Most GNU software, including some libraries, is covered by the ordinary
    +GNU General Public License, which was designed for utility programs.  This
    +license, the GNU Library General Public License, applies to certain
    +designated libraries.  This license is quite different from the ordinary
    +one; be sure to read it in full, and don't assume that anything in it is
    +the same as in the ordinary license.
    +
    +  The reason we have a separate public license for some libraries is that
    +they blur the distinction we usually make between modifying or adding to a
    +program and simply using it.  Linking a program with a library, without
    +changing the library, is in some sense simply using the library, and is
    +analogous to running a utility program or application program.  However, in
    +a textual and legal sense, the linked executable is a combined work, a
    +derivative of the original library, and the ordinary General Public License
    +treats it as such.
    +
    +  Because of this blurred distinction, using the ordinary General
    +Public License for libraries did not effectively promote software
    +sharing, because most developers did not use the libraries.  We
    +concluded that weaker conditions might promote sharing better.
    +
    +  However, unrestricted linking of non-free programs would deprive the
    +users of those programs of all benefit from the free status of the
    +libraries themselves.  This Library General Public License is intended to
    +permit developers of non-free programs to use free libraries, while
    +preserving your freedom as a user of such programs to change the free
    +libraries that are incorporated in them.  (We have not seen how to achieve
    +this as regards changes in header files, but we have achieved it as regards
    +changes in the actual functions of the Library.)  The hope is that this
    +will lead to faster development of free libraries.
    +
    +  The precise terms and conditions for copying, distribution and
    +modification follow.  Pay close attention to the difference between a
    +"work based on the library" and a "work that uses the library".  The
    +former contains code derived from the library, while the latter only
    +works together with the library.
    +
    +  Note that it is possible for a library to be covered by the ordinary
    +General Public License rather than by this special one.
    +.
    +		  GNU LIBRARY GENERAL PUBLIC LICENSE
    +   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
    +
    +  0. This License Agreement applies to any software library which
    +contains a notice placed by the copyright holder or other authorized
    +party saying it may be distributed under the terms of this Library
    +General Public License (also called "this License").  Each licensee is
    +addressed as "you".
    +
    +  A "library" means a collection of software functions and/or data
    +prepared so as to be conveniently linked with application programs
    +(which use some of those functions and data) to form executables.
    +
    +  The "Library", below, refers to any such software library or work
    +which has been distributed under these terms.  A "work based on the
    +Library" means either the Library or any derivative work under
    +copyright law: that is to say, a work containing the Library or a
    +portion of it, either verbatim or with modifications and/or translated
    +straightforwardly into another language.  (Hereinafter, translation is
    +included without limitation in the term "modification".)
    +
    +  "Source code" for a work means the preferred form of the work for
    +making modifications to it.  For a library, complete source code means
    +all the source code for all modules it contains, plus any associated
    +interface definition files, plus the scripts used to control compilation
    +and installation of the library.
    +
    +  Activities other than copying, distribution and modification are not
    +covered by this License; they are outside its scope.  The act of
    +running a program using the Library is not restricted, and output from
    +such a program is covered only if its contents constitute a work based
    +on the Library (independent of the use of the Library in a tool for
    +writing it).  Whether that is true depends on what the Library does
    +and what the program that uses the Library does.
    +  
    +  1. You may copy and distribute verbatim copies of the Library's
    +complete source code as you receive it, in any medium, provided that
    +you conspicuously and appropriately publish on each copy an
    +appropriate copyright notice and disclaimer of warranty; keep intact
    +all the notices that refer to this License and to the absence of any
    +warranty; and distribute a copy of this License along with the
    +Library.
    +
    +  You may charge a fee for the physical act of transferring a copy,
    +and you may at your option offer warranty protection in exchange for a
    +fee.
    +.
    +  2. You may modify your copy or copies of the Library or any portion
    +of it, thus forming a work based on the Library, and copy and
    +distribute such modifications or work under the terms of Section 1
    +above, provided that you also meet all of these conditions:
    +
    +    a) The modified work must itself be a software library.
    +
    +    b) You must cause the files modified to carry prominent notices
    +    stating that you changed the files and the date of any change.
    +
    +    c) You must cause the whole of the work to be licensed at no
    +    charge to all third parties under the terms of this License.
    +
    +    d) If a facility in the modified Library refers to a function or a
    +    table of data to be supplied by an application program that uses
    +    the facility, other than as an argument passed when the facility
    +    is invoked, then you must make a good faith effort to ensure that,
    +    in the event an application does not supply such function or
    +    table, the facility still operates, and performs whatever part of
    +    its purpose remains meaningful.
    +
    +    (For example, a function in a library to compute square roots has
    +    a purpose that is entirely well-defined independent of the
    +    application.  Therefore, Subsection 2d requires that any
    +    application-supplied function or table used by this function must
    +    be optional: if the application does not supply it, the square
    +    root function must still compute square roots.)
    +
    +These requirements apply to the modified work as a whole.  If
    +identifiable sections of that work are not derived from the Library,
    +and can be reasonably considered independent and separate works in
    +themselves, then this License, and its terms, do not apply to those
    +sections when you distribute them as separate works.  But when you
    +distribute the same sections as part of a whole which is a work based
    +on the Library, the distribution of the whole must be on the terms of
    +this License, whose permissions for other licensees extend to the
    +entire whole, and thus to each and every part regardless of who wrote
    +it.
    +
    +Thus, it is not the intent of this section to claim rights or contest
    +your rights to work written entirely by you; rather, the intent is to
    +exercise the right to control the distribution of derivative or
    +collective works based on the Library.
    +
    +In addition, mere aggregation of another work not based on the Library
    +with the Library (or with a work based on the Library) on a volume of
    +a storage or distribution medium does not bring the other work under
    +the scope of this License.
    +
    +  3. You may opt to apply the terms of the ordinary GNU General Public
    +License instead of this License to a given copy of the Library.  To do
    +this, you must alter all the notices that refer to this License, so
    +that they refer to the ordinary GNU General Public License, version 2,
    +instead of to this License.  (If a newer version than version 2 of the
    +ordinary GNU General Public License has appeared, then you can specify
    +that version instead if you wish.)  Do not make any other change in
    +these notices.
    +.
    +  Once this change is made in a given copy, it is irreversible for
    +that copy, so the ordinary GNU General Public License applies to all
    +subsequent copies and derivative works made from that copy.
    +
    +  This option is useful when you wish to copy part of the code of
    +the Library into a program that is not a library.
    +
    +  4. You may copy and distribute the Library (or a portion or
    +derivative of it, under Section 2) in object code or executable form
    +under the terms of Sections 1 and 2 above provided that you accompany
    +it with the complete corresponding machine-readable source code, which
    +must be distributed under the terms of Sections 1 and 2 above on a
    +medium customarily used for software interchange.
    +
    +  If distribution of object code is made by offering access to copy
    +from a designated place, then offering equivalent access to copy the
    +source code from the same place satisfies the requirement to
    +distribute the source code, even though third parties are not
    +compelled to copy the source along with the object code.
    +
    +  5. A program that contains no derivative of any portion of the
    +Library, but is designed to work with the Library by being compiled or
    +linked with it, is called a "work that uses the Library".  Such a
    +work, in isolation, is not a derivative work of the Library, and
    +therefore falls outside the scope of this License.
    +
    +  However, linking a "work that uses the Library" with the Library
    +creates an executable that is a derivative of the Library (because it
    +contains portions of the Library), rather than a "work that uses the
    +library".  The executable is therefore covered by this License.
    +Section 6 states terms for distribution of such executables.
    +
    +  When a "work that uses the Library" uses material from a header file
    +that is part of the Library, the object code for the work may be a
    +derivative work of the Library even though the source code is not.
    +Whether this is true is especially significant if the work can be
    +linked without the Library, or if the work is itself a library.  The
    +threshold for this to be true is not precisely defined by law.
    +
    +  If such an object file uses only numerical parameters, data
    +structure layouts and accessors, and small macros and small inline
    +functions (ten lines or less in length), then the use of the object
    +file is unrestricted, regardless of whether it is legally a derivative
    +work.  (Executables containing this object code plus portions of the
    +Library will still fall under Section 6.)
    +
    +  Otherwise, if the work is a derivative of the Library, you may
    +distribute the object code for the work under the terms of Section 6.
    +Any executables containing that work also fall under Section 6,
    +whether or not they are linked directly with the Library itself.
    +.
    +  6. As an exception to the Sections above, you may also compile or
    +link a "work that uses the Library" with the Library to produce a
    +work containing portions of the Library, and distribute that work
    +under terms of your choice, provided that the terms permit
    +modification of the work for the customer's own use and reverse
    +engineering for debugging such modifications.
    +
    +  You must give prominent notice with each copy of the work that the
    +Library is used in it and that the Library and its use are covered by
    +this License.  You must supply a copy of this License.  If the work
    +during execution displays copyright notices, you must include the
    +copyright notice for the Library among them, as well as a reference
    +directing the user to the copy of this License.  Also, you must do one
    +of these things:
    +
    +    a) Accompany the work with the complete corresponding
    +    machine-readable source code for the Library including whatever
    +    changes were used in the work (which must be distributed under
    +    Sections 1 and 2 above); and, if the work is an executable linked
    +    with the Library, with the complete machine-readable "work that
    +    uses the Library", as object code and/or source code, so that the
    +    user can modify the Library and then relink to produce a modified
    +    executable containing the modified Library.  (It is understood
    +    that the user who changes the contents of definitions files in the
    +    Library will not necessarily be able to recompile the application
    +    to use the modified definitions.)
    +
    +    b) Accompany the work with a written offer, valid for at
    +    least three years, to give the same user the materials
    +    specified in Subsection 6a, above, for a charge no more
    +    than the cost of performing this distribution.
    +
    +    c) If distribution of the work is made by offering access to copy
    +    from a designated place, offer equivalent access to copy the above
    +    specified materials from the same place.
    +
    +    d) Verify that the user has already received a copy of these
    +    materials or that you have already sent this user a copy.
    +
    +  For an executable, the required form of the "work that uses the
    +Library" must include any data and utility programs needed for
    +reproducing the executable from it.  However, as a special exception,
    +the source code distributed need not include anything that is normally
    +distributed (in either source or binary form) with the major
    +components (compiler, kernel, and so on) of the operating system on
    +which the executable runs, unless that component itself accompanies
    +the executable.
    +
    +  It may happen that this requirement contradicts the license
    +restrictions of other proprietary libraries that do not normally
    +accompany the operating system.  Such a contradiction means you cannot
    +use both them and the Library together in an executable that you
    +distribute.
    +.
    +  7. You may place library facilities that are a work based on the
    +Library side-by-side in a single library together with other library
    +facilities not covered by this License, and distribute such a combined
    +library, provided that the separate distribution of the work based on
    +the Library and of the other library facilities is otherwise
    +permitted, and provided that you do these two things:
    +
    +    a) Accompany the combined library with a copy of the same work
    +    based on the Library, uncombined with any other library
    +    facilities.  This must be distributed under the terms of the
    +    Sections above.
    +
    +    b) Give prominent notice with the combined library of the fact
    +    that part of it is a work based on the Library, and explaining
    +    where to find the accompanying uncombined form of the same work.
    +
    +  8. You may not copy, modify, sublicense, link with, or distribute
    +the Library except as expressly provided under this License.  Any
    +attempt otherwise to copy, modify, sublicense, link with, or
    +distribute the Library is void, and will automatically terminate your
    +rights under this License.  However, parties who have received copies,
    +or rights, from you under this License will not have their licenses
    +terminated so long as such parties remain in full compliance.
    +
    +  9. You are not required to accept this License, since you have not
    +signed it.  However, nothing else grants you permission to modify or
    +distribute the Library or its derivative works.  These actions are
    +prohibited by law if you do not accept this License.  Therefore, by
    +modifying or distributing the Library (or any work based on the
    +Library), you indicate your acceptance of this License to do so, and
    +all its terms and conditions for copying, distributing or modifying
    +the Library or works based on it.
    +
    +  10. Each time you redistribute the Library (or any work based on the
    +Library), the recipient automatically receives a license from the
    +original licensor to copy, distribute, link with or modify the Library
    +subject to these terms and conditions.  You may not impose any further
    +restrictions on the recipients' exercise of the rights granted herein.
    +You are not responsible for enforcing compliance by third parties to
    +this License.
    +.
    +  11. If, as a consequence of a court judgment or allegation of patent
    +infringement or for any other reason (not limited to patent issues),
    +conditions are imposed on you (whether by court order, agreement or
    +otherwise) that contradict the conditions of this License, they do not
    +excuse you from the conditions of this License.  If you cannot
    +distribute so as to satisfy simultaneously your obligations under this
    +License and any other pertinent obligations, then as a consequence you
    +may not distribute the Library at all.  For example, if a patent
    +license would not permit royalty-free redistribution of the Library by
    +all those who receive copies directly or indirectly through you, then
    +the only way you could satisfy both it and this License would be to
    +refrain entirely from distribution of the Library.
    +
    +If any portion of this section is held invalid or unenforceable under any
    +particular circumstance, the balance of the section is intended to apply,
    +and the section as a whole is intended to apply in other circumstances.
    +
    +It is not the purpose of this section to induce you to infringe any
    +patents or other property right claims or to contest validity of any
    +such claims; this section has the sole purpose of protecting the
    +integrity of the free software distribution system which is
    +implemented by public license practices.  Many people have made
    +generous contributions to the wide range of software distributed
    +through that system in reliance on consistent application of that
    +system; it is up to the author/donor to decide if he or she is willing
    +to distribute software through any other system and a licensee cannot
    +impose that choice.
    +
    +This section is intended to make thoroughly clear what is believed to
    +be a consequence of the rest of this License.
    +
    +  12. If the distribution and/or use of the Library is restricted in
    +certain countries either by patents or by copyrighted interfaces, the
    +original copyright holder who places the Library under this License may add
    +an explicit geographical distribution limitation excluding those countries,
    +so that distribution is permitted only in or among countries not thus
    +excluded.  In such case, this License incorporates the limitation as if
    +written in the body of this License.
    +
    +  13. The Free Software Foundation may publish revised and/or new
    +versions of the Library General Public License from time to time.
    +Such new versions will be similar in spirit to the present version,
    +but may differ in detail to address new problems or concerns.
    +
    +Each version is given a distinguishing version number.  If the Library
    +specifies a version number of this License which applies to it and
    +"any later version", you have the option of following the terms and
    +conditions either of that version or of any later version published by
    +the Free Software Foundation.  If the Library does not specify a
    +license version number, you may choose any version ever published by
    +the Free Software Foundation.
    +.
    +  14. If you wish to incorporate parts of the Library into other free
    +programs whose distribution conditions are incompatible with these,
    +write to the author to ask for permission.  For software which is
    +copyrighted by the Free Software Foundation, write to the Free
    +Software Foundation; we sometimes make exceptions for this.  Our
    +decision will be guided by the two goals of preserving the free status
    +of all derivatives of our free software and of promoting the sharing
    +and reuse of software generally.
    +
    +			    NO WARRANTY
    +
    +  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
    +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
    +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
    +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
    +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
    +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    +PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
    +LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
    +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
    +
    +  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
    +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
    +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
    +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
    +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
    +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
    +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
    +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
    +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
    +DAMAGES.
    +
    +		     END OF TERMS AND CONDITIONS
    +
    +
    + + + + + diff --git a/wp-includes/js/tinymce/license.txt b/wp-includes/js/tinymce/license.txt new file mode 100644 index 00000000..3b0396a2 --- /dev/null +++ b/wp-includes/js/tinymce/license.txt @@ -0,0 +1,437 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. +. + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. +. + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. +. + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. +. + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. +. + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. +. + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. +. + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. +. + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js new file mode 100644 index 00000000..28d7ae76 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js @@ -0,0 +1,2 @@ +/* Import plugin specific language pack */ + tinyMCE.importPluginLanguagePack('autosave','en,sv,cs,he,no,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,fi,cy,es,is,pl');function TinyMCE_autosave_getInfo(){return{longname:'Auto save',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};};function TinyMCE_autosave_beforeUnloadHandler(){var msg=tinyMCE.getLang("lang_autosave_unload_msg");var anyDirty=false;for(var n in tinyMCE.instances){var inst=tinyMCE.instances[n];if(!tinyMCE.isInstance(inst))continue;if(inst.isDirty())return msg;}return;}window.onbeforeunload=TinyMCE_autosave_beforeUnloadHandler; \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js new file mode 100644 index 00000000..102d69b4 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js @@ -0,0 +1,30 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('autosave', 'en,sv,cs,he,no,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,fi,cy,es,is,pl'); + +function TinyMCE_autosave_getInfo() { + return { + longname : 'Auto save', + author : 'Moxiecode Systems', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html', + version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion + }; +}; + +function TinyMCE_autosave_beforeUnloadHandler() { + var msg = tinyMCE.getLang("lang_autosave_unload_msg"); + + var anyDirty = false; + for (var n in tinyMCE.instances) { + var inst = tinyMCE.instances[n]; + if (!tinyMCE.isInstance(inst)) + continue; + + if (inst.isDirty()) + return msg; + } + + return; +} + +window.onbeforeunload = TinyMCE_autosave_beforeUnloadHandler; diff --git a/wp-includes/js/tinymce/plugins/autosave/langs/cs.js b/wp-includes/js/tinymce/plugins/autosave/langs/cs.js new file mode 100644 index 00000000..e69de29b diff --git a/wp-includes/js/tinymce/plugins/autosave/langs/en.js b/wp-includes/js/tinymce/plugins/autosave/langs/en.js new file mode 100644 index 00000000..01951332 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/autosave/langs/en.js @@ -0,0 +1,5 @@ +// EN lang variables + +tinyMCE.addToLang('',{ +autosave_unload_msg : 'The changes you made will be lost if you navigate away from this page.' +}); diff --git a/wp-includes/js/tinymce/plugins/autosave/langs/sv.js b/wp-includes/js/tinymce/plugins/autosave/langs/sv.js new file mode 100644 index 00000000..e69de29b diff --git a/wp-includes/js/tinymce/plugins/autosave/readme.txt b/wp-includes/js/tinymce/plugins/autosave/readme.txt new file mode 100644 index 00000000..4fdb78ae --- /dev/null +++ b/wp-includes/js/tinymce/plugins/autosave/readme.txt @@ -0,0 +1 @@ +Check the TinyMCE documentation for details on this plugin. diff --git a/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js new file mode 100644 index 00000000..c866b53d --- /dev/null +++ b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js @@ -0,0 +1,83 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('directionality', 'en,sv,fr_ca,zh_cn,cs,da,he,no,de,hu,ru,ru_KOI8-R,ru_UTF-8,es,cy,is,pl'); + +function TinyMCE_directionality_getInfo() { + return { + longname : 'Directionality', + author : 'Moxiecode Systems', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html', + version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion + }; +}; + +function TinyMCE_directionality_getControlHTML(control_name) { + switch (control_name) { + case "ltr": + var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionLTR\');return false;'; + return '' + + '
    '; + + case "rtl": + var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionRTL\');return false;'; + return '' + + '
    '; + } + + return ""; +} + +function TinyMCE_directionality_execCommand(editor_id, element, command, user_interface, value) { + // Handle commands + switch (command) { + case "mceDirectionLTR": + var inst = tinyMCE.getInstanceById(editor_id); + var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); + + if (elm) + elm.setAttribute("dir", "ltr"); + + tinyMCE.triggerNodeChange(false); + return true; + + case "mceDirectionRTL": + var inst = tinyMCE.getInstanceById(editor_id); + var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); + + if (elm) + elm.setAttribute("dir", "rtl"); + + tinyMCE.triggerNodeChange(false); + return true; + } + + // Pass to next handler in chain + return false; +} + +function TinyMCE_directionality_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { + function getAttrib(elm, name) { + return elm.getAttribute(name) ? elm.getAttribute(name) : ""; + } + + tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonNormal', false); + tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonNormal', false); + + if (node == null) + return; + + var elm = tinyMCE.getParentElement(node, "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); + if (!elm) { + tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonDisabled', true); + return; + } + + var dir = getAttrib(elm, "dir"); + if (dir == "ltr" || dir == "") + tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonSelected', false); + else + tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonSelected', false); + + return true; +} diff --git a/wp-includes/js/tinymce/plugins/directionality/images/ltr.gif b/wp-includes/js/tinymce/plugins/directionality/images/ltr.gif new file mode 100644 index 0000000000000000000000000000000000000000..ac8f30c1208e044ac5ed8f4f82c2e513c56c9f4b GIT binary patch literal 155 zcmV;M0A&A1Nk%w1VH5xq0K*0V6B83EOqQXfrM$epT3%aDeA>#+*g!o%lCtD@cz8l? zx@C{wCodDf2?TZ&Ww46PQZJ;6HbgF) J&uDZ606X)4Hvs?u literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/plugins/directionality/images/rtl.gif b/wp-includes/js/tinymce/plugins/directionality/images/rtl.gif new file mode 100644 index 0000000000000000000000000000000000000000..0348f9965669dd9cfba3c69d71d20ea3928e46fe GIT binary patch literal 153 zcmV;K0A~M3Nk%w1VH5xq0K*Lc6&4jPQl5&6in_+zPfbr=jNa1D%1Uy=K0H3Nv#n}w zX?>#YH($5z?CQtO-2eapA^8LW000jFEC2ui02BZe000C=@X1N5y*TU5yU$K@847`% z$mA5FC73`GOG9yB3IYHR|EvoJCQ;(~3X4J@W03VE4#r`rF-`^yYR0P4Vz}3jcuX#v H%@F`Q*OWXP literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/plugins/directionality/langs/en.js b/wp-includes/js/tinymce/plugins/directionality/langs/en.js new file mode 100644 index 00000000..5b392fe1 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/directionality/langs/en.js @@ -0,0 +1,6 @@ +// UK lang variables + +tinyMCE.addToLang('',{ +directionality_ltr_desc : 'Direction left to right (Alt-.)', +directionality_rtl_desc : 'Direction right to left (Alt-,)' +}); diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css b/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css new file mode 100644 index 00000000..e69de29b diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js new file mode 100644 index 00000000..e69de29b diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js new file mode 100644 index 00000000..e69de29b diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/spacer.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/spacer.gif new file mode 100644 index 0000000000000000000000000000000000000000..fc2560981ee1caca400e225e48d282106f907f2d GIT binary patch literal 43 ucmZ?wbhEHbWMp7uXkcLY|NlP&1B2pE7Df>utpmhBaYhCPCMFj~25SJyItL8^ literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_close.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/window_close.gif new file mode 100644 index 0000000000000000000000000000000000000000..3469e5aea1d1594aded9b9fe41dbf66f7db66e5d GIT binary patch literal 110 zcmZ?wbhEHb6ky8EpFaMT6=+Em0o-!%GKPcq}sebpyqLVpV!VJ~` DxTYg8 literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_minimize.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/window_minimize.gif new file mode 100644 index 0000000000000000000000000000000000000000..94f167a4dd150485a7530bdf5d2c9e4dd42f109a GIT binary patch literal 112 zcmZ?wbhEHb6ky'; + // Add this to the buttons var to put the Page button into the toolbar. + // ''; + return buttons; + } + + return ''; +} + +function TinyMCE_wordpress_parseAttributes(attribute_string) { + var attributeName = ""; + var attributeValue = ""; + var withInName; + var withInValue; + var attributes = new Array(); + var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g'); + var titleText = tinyMCE.getLang('lang_wordpress_more'); + var titleTextPage = tinyMCE.getLang('lang_wordpress_page'); + + if (attribute_string == null || attribute_string.length < 2) + return null; + + withInName = withInValue = false; + + for (var i=0; i'; + tinyMCE.execCommand("mceInsertContent",true,html); + tinyMCE.selectedInstance.repaint(); + return true; + case "mcewordpresspage": + var flag = ""; + var template = new Array(); + var altPage = tinyMCE.getLang('lang_wordpress_more_alt'); + + // Is selection a image + if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { + flag = getAttrib(focusElm, 'name'); + + if (flag != 'mce_plugin_wordpress_page') // Not a wordpress + return true; + + action = "update"; + } + + html = '' + + ''; + tinyMCE.execCommand("mceInsertContent",true,html); + tinyMCE.selectedInstance.repaint(); + return true; + } + + // Pass to next handler in chain + return false; +} + +function TinyMCE_wordpress_cleanup(type, content) { + switch (type) { + + case "insert_to_editor": + var startPos = 0; + var altMore = tinyMCE.getLang('lang_wordpress_more_alt'); + var altPage = tinyMCE.getLang('lang_wordpress_page_alt'); + + // Parse all tags and replace them with images + while ((startPos = content.indexOf('', startPos)) != -1) { + // Insert image + var contentAfter = content.substring(startPos + 11); + content = content.substring(0, startPos); + content += ''; + content += contentAfter; + + startPos++; + } + var startPos = 0; + + // Parse all tags and replace them with images + while ((startPos = content.indexOf('', startPos)) != -1) { + // Insert image + var contentAfter = content.substring(startPos + 15); + content = content.substring(0, startPos); + content += ''; + content += contentAfter; + + startPos++; + } + + // It's supposed to be WYSIWYG, right? + content = content.replace(new RegExp('&', 'g'), '&'); + + break; + + case "get_from_editor": + // Parse all img tags and replace them with + var startPos = -1; + while ((startPos = content.indexOf('', startPos); + var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos)); + + if (attribs['class'] == "mce_plugin_wordpress_more") { + endPos += 2; + + var embedHTML = ''; + + // Insert embed/object chunk + chunkBefore = content.substring(0, startPos); + chunkAfter = content.substring(endPos); + content = chunkBefore + embedHTML + chunkAfter; + } + if (attribs['class'] == "mce_plugin_wordpress_page") { + endPos += 2; + + var embedHTML = ''; + + // Insert embed/object chunk + chunkBefore = content.substring(0, startPos); + chunkAfter = content.substring(endPos); + content = chunkBefore + embedHTML + chunkAfter; + } + } + + // If it says & in the WYSIWYG editor, it should say & in the html. + content = content.replace(new RegExp('&', 'g'), '&'); + content = content.replace(new RegExp('&nbsp;', 'g'), ' '); + + // Remove anonymous, empty paragraphs. + content = content.replace(new RegExp('

    (\\s| )*

    ', 'mg'), ''); + + // Handle table badness. + content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>'); + content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>'); + content = content.replace(new RegExp('.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '<$2>'); + content = content.replace(new RegExp('.*?<(tr|/table)>', 'mg'), '<$1>'); + content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(
    )*)*', 'g'), '<$1>'); + + // Pretty it up for the source editor. + var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p'; + content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); + content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>\\s*', 'mg'), '\n<$1>'); + content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>'); + content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>'); + content = content.replace(new RegExp('\\s*
    \\s*', 'mg'), '
    \n'); + content = content.replace(new RegExp('^\\s*', ''), ''); + content = content.replace(new RegExp('\\s*$', ''), ''); + + break; + } + + // Pass through to next handler in chain + return content; +} + +function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { + function getAttrib(elm, name) { + return elm.getAttribute(name) ? elm.getAttribute(name) : ""; + } + + tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonNormal'); + + if (node == null) + return; + + do { + if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0) + tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected'); + if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0) + tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected'); + } while ((node = node.parentNode)); + + return true; +} + +function wp_save_callback(el, content, body) { + // We have a TON of cleanup to do. + + // Mark

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

    ', 'mg'), '$1'); + + // Decode the ampersands of time. + content = content.replace(new RegExp('&', 'g'), '&'); + + // Get it ready for wpautop. + content = content.replace(new RegExp('[\\s]*

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

    [\\s]*', 'mgi'), '\n\n'); + content = content.replace(new RegExp('\\n\\s*\\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
  • '); + + // Unmark special paragraph closing tags + content = content.replace(new RegExp('', 'g'), '

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

    )', 'mg'), '\n$1'); + + // Trim any whitespace + content = content.replace(new RegExp('^\\s*', ''), ''); + content = content.replace(new RegExp('\\s*$', ''), ''); + + // Hope. + return content; + +} diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/help.gif b/wp-includes/js/tinymce/plugins/wordpress/images/help.gif new file mode 100644 index 0000000000000000000000000000000000000000..933d853a6fd49135e3a3c3b3afd4714e1247735c GIT binary patch literal 92 zcmZ?wbhEHb6k!lyn8?78mX`Ma|No|?CxE2lPZmZ724)5w1|R^*Gcf7S>0inDcJCQy u{!1rguHE*kDQy1{8kpf0x@z44%S|61oSoi#dx75J?0?LYincK^SOWk>#U^0@ literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/more.gif b/wp-includes/js/tinymce/plugins/wordpress/images/more.gif new file mode 100644 index 0000000000000000000000000000000000000000..4ff564d5896823d5a6d9378781ddfb5e1b1d6f65 GIT binary patch literal 108 zcmZ?wbhEHb6k!lyn8?78mX`Ma|No|?CxE2lPZm}Y24)5w1|R^*GceiC>0inGmY$|5$M0 zt?teHoPP1QDTOjRB;>8S*7=URUZrZ;>)5Ry&wbv^x#dQa!qmTeBx%IiC| x%Jg81-FAytUstD0Yf)F{jnZS^^Wa-vTX*rDFY_MsoqzrPPwij+A3+QZ)&OEJL(2dF literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/page.gif b/wp-includes/js/tinymce/plugins/wordpress/images/page.gif new file mode 100644 index 0000000000000000000000000000000000000000..1cea78ac2ba02c5e429b4128c2cdf0ecc4058b20 GIT binary patch literal 108 zcmZ?wbhEHb6k!lyn8?78mX`Ma|No|?CxE2lPZm}Y24)5w1|R^*GceiS5m>o9p>2lG zyQ3$yjs(fivz1>_A)d+f>eRMJ+{c>?&J^c9{x18yfV(8pL-itOic(O|DTkn+DsF*3 KD;6>^SOWl#7%CV5 literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif b/wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif new file mode 100644 index 0000000000000000000000000000000000000000..9ea3565692f721dea7425f0050d27e299e869be9 GIT binary patch literal 180 zcmV;l089TzNk%w1VTAw+0FeLy0002r=<&?V%>V!YA^8La6aWJNEC2ui0EGYw0007o zoR6u??Ja_wwAzcazT){0hDf9VlDS#Hil$p9#&S$%YtY&in!6Z03knxC%&o;r;%*b= zlE-9efWxY=crit#Ox%v5Zi( literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js new file mode 100644 index 00000000..c9daa5b8 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js @@ -0,0 +1,16 @@ +// EN lang variables + +if (navigator.userAgent.indexOf('Mac OS') != -1) { +// Mac OS browsers use Ctrl to hit accesskeys + var metaKey = 'Ctrl'; +} +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_more_alt : 'More...', +wordpress_page_alt : '...page...' +}); diff --git a/wp-includes/js/tinymce/plugins/wordpress/wordpress.css b/wp-includes/js/tinymce/plugins/wordpress/wordpress.css new file mode 100644 index 00000000..b51a0984 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wordpress/wordpress.css @@ -0,0 +1,21 @@ +.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; +} diff --git a/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js b/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js new file mode 100644 index 00000000..204e4471 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js @@ -0,0 +1,57 @@ +/* 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 new file mode 100644 index 0000000000000000000000000000000000000000..51a1ee42073402ce787b60d151219ef7ce367615 GIT binary patch literal 295 zcmV+?0oeXWNk%w1VH5xq0Mrfu6i>3FyW3udp6K!Ub&;kbTH+f8tqUysbN$lQ^w;v!hW z!pq(wXY{hj_W%F@A^8LW0018VEC2ui02BZe000G~;3tk`X`X1Ru1KI+h83(|W>rq^ zR7RF&f!#zRnN$X{6T;$HBo?`WVllvQOo2)zp>TL49!J8HVVDe#NumhpbS0R9z=Ux~ zAoz}Cx7j!jCJ$n5dR`j + + {$lang_about_title} + + + + + + + + +
    +
    +

    {$lang_about_title}

    +

    Version: {$tinymce_version} ({$tinymce_releasedate})

    +

    TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL + by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.

    +

    Copyright © 2005, Moxiecode Systems AB, All rights reserved.

    +

    For more information about this software visit the TinyMCE website.

    + +
    +
    + +
    +
    +

    {$lang_loaded_plugins}

    + +
    +
    + +

     

    +
    +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    + + diff --git a/wp-includes/js/tinymce/themes/advanced/anchor.htm b/wp-includes/js/tinymce/themes/advanced/anchor.htm new file mode 100644 index 00000000..48ba245f --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/anchor.htm @@ -0,0 +1,32 @@ + + + {$lang_insert_anchor_title} + + + + +
    + + + + + + + + + +
    {$lang_insert_anchor_title}
    {$lang_insert_anchor_name}:
    + +
    +
    + +
    + +
    + +
    +
    + +
    + + diff --git a/wp-includes/js/tinymce/themes/advanced/charmap.htm b/wp-includes/js/tinymce/themes/advanced/charmap.htm new file mode 100644 index 00000000..bcebff24 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/charmap.htm @@ -0,0 +1,52 @@ + + + {$lang_theme_charmap_title} + + + + + + + + + + + + + + + + +
    {$lang_theme_charmap_title}
    + + + + + + + + + +
     
     
    +
    + + + + + + + + + + + + + + + + +
    HTML-Code
     
     
    NUM-Code
     
    +
    + + + diff --git a/wp-includes/js/tinymce/themes/advanced/color_picker.htm b/wp-includes/js/tinymce/themes/advanced/color_picker.htm new file mode 100644 index 00000000..e35d711e --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/color_picker.htm @@ -0,0 +1,12 @@ + + + {$lang_theme_colorpicker_title} + + + + +
    + +
    + + diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_content.css b/wp-includes/js/tinymce/themes/advanced/css/editor_content.css new file mode 100644 index 00000000..7dbe1feb --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/css/editor_content.css @@ -0,0 +1,49 @@ +/* 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-color: #FFFFFF; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 0.9em; + line-height: 1.2em; + padding: .3em; +} + +td { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; +} + +pre { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; +} + +.mceVisualAid { + border: 1px dashed #BBBBBB !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; +} +*/ diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css new file mode 100644 index 00000000..14f83221 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css @@ -0,0 +1,319 @@ +/* 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: 0px solid #808080; +} + +#insert { + font-weight: bold; + width: 90px; + height: 21px; + border: 0px; + background-image: url('../images/insert_button_bg.gif'); + cursor: pointer; +} + +#cancel { + font-weight: bold; + width: 90px; + height: 21px; + border: 0px; + 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: arrow; +} + +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: arrow; +} + +.mceButtonOver { + border: 1px solid #0A246A; + cursor: arrow; + background-color: #B6BDD2; +} + +.mceButtonDown { + cursor: arrow; + 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: arrow; +} + +.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: 0px 0px 0; + list-style: none; +} + +.tabs li { + float: left; + background: url("../images/xp/tab_bg.gif") no-repeat left top; + margin: 0; + margin-left: 0px; + 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 0px 0px; +} + +.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: 0px; + margin: 0px; + 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: 0px; + padding: 0px; + padding-top: 5px; +} + +h3 { + font-size: 14px; +} + +/* 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; +} +*/ diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css new file mode 100644 index 00000000..f2f5effe --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css @@ -0,0 +1,181 @@ +/* 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: 0px; margin: 0px; padding: 0px; background: transparent; +} + +.mceButtonNormal, .mceButtonOver, .mceButtonDown, .mceSeparator, .mceSeparatorLine, .mceButtonDisabled, .mceButtonSelected { + border: 0px; margin: 0px; padding: 0px; background: transparent; + margin-top: 1px; + margin-left: 1px; +} + +.mceButtonNormal { + border-top: 1px solid; + border-left: 1px solid; + border-bottom: 1px solid; + border-right: 1px solid; + border-color: #F0F0EE; + cursor: arrow; +} + +.mceButtonOver { + border: 1px solid #0A246A; + cursor: arrow; + background-color: #B6BDD2; +} + +.mceButtonDown { + cursor: arrow; + border: 1px solid #0A246A; + background-color: #8592B5; +} + +.mceButtonSelected { + border: 1px solid; + border-color: #C0C0BB; + cursor: arrow; +} + +.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: arrow; +} + +.mceSeparator { + border-top: 1px solid buttonhighlight; + border-left: 1px solid buttonhighlight; + border-bottom: 1px solid buttonshadow; + border-right: 1px solid buttonshadow; + margin-right: 2px; + margin-left: 2px; +} + +.mceSeparatorLine { + margin:2px; + margin-left: 4px; + background-color: #F0F0EE; + border-top: 1px solid buttonshadow; + border-left: 1px solid buttonshadow; + border-bottom: 1px solid buttonhighlight; + border-right: 1px solid buttonhighlight; + width: 0px; + height: 15px; +} + +.mceSelectList { + font-family: "MS Sans Serif"; + font-size: 7pt; + font-weight: normal; + margin-top: 3px; + padding: 0px; + 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: 0px; + margin: 0px; +} + +.mceEditorArea { + font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; + background: #FFFFFF; + padding: 0px; + margin: 0px; +} + +.mceToolbarTop, .mceToolbarBottom { + background: #F0F0EE; + line-height: 1px; + font-size: 1px; +} + +.mceToolbarTop { + border-bottom: 1px solid #cccccc; +} + +.mceToolbarBottom { + border-top: 1px solid #cccccc; +} + +.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: 0px; + padding: 0px; +} diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template.js b/wp-includes/js/tinymce/themes/advanced/editor_template.js new file mode 100644 index 00000000..0dd4074f --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/editor_template.js @@ -0,0 +1,13 @@ +/* Import theme specific language pack */ + tinyMCE.importThemeLanguagePack('advanced');var TinyMCE_advanced_autoImportCSSClasses=true;var TinyMCE_advanced_resizer=new Object();var TinyMCE_advanced_buttons=[['bold','{$lang_bold_img}','{$lang_bold_desc}','Bold'],['italic','{$lang_italic_img}','{$lang_italic_desc}','Italic'],['underline','{$lang_underline_img}','{$lang_underline_desc}','Underline'],['strikethrough','strikethrough.gif','{$lang_striketrough_desc}','Strikethrough'],['justifyleft','left.gif','{$lang_justifyleft_desc}','JustifyLeft'],['justifycenter','center.gif','{$lang_justifycenter_desc}','JustifyCenter'],['justifyright','right.gif','{$lang_justifyright_desc}','JustifyRight'],['justifyfull','full.gif','{$lang_justifyfull_desc}','JustifyFull'],['bullist','bullist.gif','{$lang_bullist_desc}','InsertUnorderedList'],['numlist','numlist.gif','{$lang_numlist_desc}','InsertOrderedList'],['outdent','outdent.gif','{$lang_outdent_desc}','Outdent'],['indent','indent.gif','{$lang_indent_desc}','Indent'],['cut','cut.gif','{$lang_cut_desc}','Cut'],['copy','copy.gif','{$lang_copy_desc}','Copy'],['paste','paste.gif','{$lang_paste_desc}','Paste'],['undo','undo.gif','{$lang_undo_desc}','Undo'],['redo','redo.gif','{$lang_redo_desc}','Redo'],['link','link.gif','{$lang_link_desc}','mceLink',true],['unlink','unlink.gif','{$lang_unlink_desc}','unlink'],['image','image.gif','{$lang_image_desc}','mceImage',true],['cleanup','cleanup.gif','{$lang_cleanup_desc}','mceCleanup'],['help','help.gif','{$lang_help_desc}','mceHelp'],['code','code.gif','{$lang_theme_code_desc}','mceCodeEditor'],['hr','hr.gif','{$lang_theme_hr_desc}','inserthorizontalrule'],['removeformat','removeformat.gif','{$lang_theme_removeformat_desc}','removeformat'],['sub','sub.gif','{$lang_theme_sub_desc}','subscript'],['sup','sup.gif','{$lang_theme_sup_desc}','superscript'],['forecolor','forecolor.gif','{$lang_theme_forecolor_desc}','mceForeColor',true],['backcolor','backcolor.gif','{$lang_theme_backcolor_desc}','mceBackColor',true],['charmap','charmap.gif','{$lang_theme_charmap_desc}','mceCharMap'],['visualaid','visualaid.gif','{$lang_theme_visualaid_desc}','mceToggleVisualAid'],['anchor','anchor.gif','{$lang_theme_anchor_desc}','mceInsertAnchor'],['newdocument','newdocument.gif','{$lang_newdocument_desc}','mceNewDocument']];function TinyMCE_advanced_getControlHTML(button_name){var buttonTileMap=new Array('anchor.gif','backcolor.gif','bullist.gif','center.gif','charmap.gif','cleanup.gif','code.gif','copy.gif','custom_1.gif','cut.gif','forecolor.gif','full.gif','help.gif','hr.gif','image.gif','indent.gif','left.gif','link.gif','numlist.gif','outdent.gif','paste.gif','redo.gif','removeformat.gif','right.gif','strikethrough.gif','sub.gif','sup.gif','undo.gif','unlink.gif','visualaid.gif');for(var i=0;i4?but[4]:false)+(but.length>5?',\''+but[5]+'\'':'')+')';return '';}}}var cmd='tinyMCE.execInstanceCommand(\'{$editor_id}\',\''+but[3]+'\','+(but.length>4?but[4]:false)+(but.length>5?',\''+but[5]+'\'':'')+')';return '';}}switch(button_name){case "formatselect":var html='';return html;case "styleselect":return '';case "fontselect":var fontHTML='';return fontHTML;case "fontsizeselect":return '';case "|":case "separator":return '';case "spacer":return '';case "rowseparator":return '
    ';}return "";}function TinyMCE_advanced_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mceForeColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=tinyMCE.getAttrib(elm,"color");if(inputColor=='')inputColor=elm.style.color;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"forecolor",input_color:inputColor});return true;case "mceBackColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=elm.style.backgroundColor;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;template['width']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"HiliteColor",input_color:inputColor});return true;case "mceColorPicker":if(user_interface){var template=new Array();var inputColor=value['document'].getElementById(value['element_id']).value;template['file']='color_picker.htm';template['width']=220;template['height']=190;template['close_previous']="no";template['width']+=tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height',0);if(typeof(value['store_selection'])=="undefined")value['store_selection']=true;tinyMCE.lastColorPickerValue=value;tinyMCE.openWindow(template,{editor_id:editor_id,mce_store_selection:value['store_selection'],inline:"yes",command:"mceColorPicker",input_color:inputColor});}else{var savedVal=tinyMCE.lastColorPickerValue;var elm=savedVal['document'].getElementById(savedVal['element_id']);elm.value=value;eval('elm.onchange();');}return true;case "mceCodeEditor":var template=new Array();template['file']='source_editor.htm';template['width']=parseInt(tinyMCE.getParam("theme_advanced_source_editor_width",500));template['height']=parseInt(tinyMCE.getParam("theme_advanced_source_editor_height",400));tinyMCE.openWindow(template,{editor_id:editor_id,resizable:"yes",scrollbars:"no",inline:"yes"});return true;case "mceCharMap":var template=new Array();template['file']='charmap.htm';template['width']=550+(tinyMCE.isOpera?40:0);template['height']=250;template['width']+=tinyMCE.getLang('lang_theme_advanced_charmap_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_charmap_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});return true;case "mceInsertAnchor":var template=new Array();template['file']='anchor.htm';template['width']=320;template['height']=90+(tinyMCE.isNS7?30:0);template['width']+=tinyMCE.getLang('lang_theme_advanced_anchor_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_anchor_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});return true;case "mceNewDocument":if(confirm(tinyMCE.getLang('lang_newdocument')))tinyMCE.execInstanceCommand(editor_id,'mceSetContent',false,'');return true;}return false;}function TinyMCE_advanced_getEditorTemplate(settings,editorId){function removeFromArray(in_array,remove_array){var outArray=new Array();for(var i=0;i 

    ';var layoutManager=tinyMCE.getParam("theme_advanced_layout_manager","SimpleLayout");var styleSelectHTML='';if(settings['theme_advanced_styles']){var stylesAr=settings['theme_advanced_styles'].split(';');for(var i=0;i'+key+'';}TinyMCE_advanced_autoImportCSSClasses=false;}switch(layoutManager){case "SimpleLayout":var toolbarHTML="";var toolbarLocation=tinyMCE.getParam("theme_advanced_toolbar_location","bottom");var toolbarAlign=tinyMCE.getParam("theme_advanced_toolbar_align","center");var pathLocation=tinyMCE.getParam("theme_advanced_path_location","none");var statusbarLocation=tinyMCE.getParam("theme_advanced_statusbar_location",pathLocation);var defVals={theme_advanced_buttons1:"bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect",theme_advanced_buttons2:"bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",theme_advanced_buttons3:"hr,removeformat,visualaid,separator,sub,sup,separator,charmap"};/*toolbarHTML+='';*/for(var i=1;i<100;i++){var def=defVals["theme_advanced_buttons"+i];var buttons=tinyMCE.getParam("theme_advanced_buttons"+i,def==null?'':def,true,',');if(buttons.length==0)break;buttons=removeFromArray(buttons,tinyMCE.getParam("theme_advanced_disable","",true,','));buttons=addToArray(buttons,tinyMCE.getParam("theme_advanced_buttons"+i+"_add","",true,','));buttons=addToArray(tinyMCE.getParam("theme_advanced_buttons"+i+"_add_before","",true,','),buttons);for(var b=0;b0){toolbarHTML+="
    ";deltaHeight-=23;}}toolbarHTML+='';template['html']='';if(toolbarLocation=="top"){template['html']+='';}if(statusbarLocation=="top"){template['html']+='';deltaHeight-=23;}template['html']+='';if(toolbarLocation=="bottom"){template['html']+='';}if(toolbarLocation=="external"){var bod=document.body;var elm=document.createElement("div");toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCE.settings);toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCELang);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,'style_select_options',styleSelectHTML);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,"editor_id",editorId);toolbarHTML=tinyMCE.applyTemplate(toolbarHTML);elm.className="mceToolbarExternal";elm.id=editorId+"_toolbar";elm.innerHTML='
    '+toolbarHTML+'
    '+statusbarHTML+'
    '+toolbarHTML+'
    '+toolbarHTML+'
    ';bod.appendChild(elm);deltaHeight=0;tinyMCE.getInstanceById(editorId).toolbarElement=elm;}else{tinyMCE.getInstanceById(editorId).toolbarElement=null;}if(statusbarLocation=="bottom"){template['html']+=''+statusbarHTML+'';deltaHeight-=23;}template['html']+='';break;case "RowLayout":template['html']='';var containers=tinyMCE.getParam("theme_advanced_containers","",true,",");var defaultContainerCSS=tinyMCE.getParam("theme_advanced_containers_default_class","container");var defaultContainerAlign=tinyMCE.getParam("theme_advanced_containers_default_align","center");for(var i=0;i';}else if(containers[i]=="mceElementpath"||containers[i]=="mceStatusbar"){var pathClass="mceStatusbar";if(i==containers.length-1){pathClass="mceStatusbarBottom";}else if(i==0){pathClass="mceStatusbar";}else{deltaHeight-=2;}template['html']+='';deltaHeight-=22;}else{var curContainer=tinyMCE.getParam("theme_advanced_container_"+containers[i],"",true,',');var curContainerHTML="";var curAlign=tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align",defaultContainerAlign);var curCSS=tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class",defaultContainerCSS);for(var j=0;j0){curContainerHTML+="
    ";deltaHeight-=23;}template['html']+='
    ';}}template['html']+='
    \ + \ +
    '+statusbarHTML+'
    '+curContainerHTML+'
    ';break;case "BorderLayout":break;case "CustomLayout":var customLayout=tinyMCE.getParam("theme_advanced_custom_layout","");if(customLayout!=""&&eval("typeof("+customLayout+")")!="undefined"){template=eval(customLayout+"(template);");}break;default:alert('UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!');break;}template['html']+='
    ';template['html']=tinyMCE.replaceVar(template['html'],'style_select_options',styleSelectHTML);template['delta_width']=0;template['delta_height']=deltaHeight;return template;}function TinyMCE_advanced_setResizing(e,editor_id,state){e=typeof(e)=="undefined"?window.event:e;var resizer=TinyMCE_advanced_resizer;var editorContainer=document.getElementById(editor_id+'_parent');var editorArea=document.getElementById(editor_id+'_parent').firstChild;var resizeBox=document.getElementById(editor_id+'_resize_box');var inst=tinyMCE.getInstanceById(editor_id);if(state){var width=editorArea.clientWidth;var height=editorArea.clientHeight;resizeBox.style.width=width+"px";resizeBox.style.height=height+"px";resizer.iframeWidth=inst.iframeElement.clientWidth;resizer.iframeHeight=inst.iframeElement.clientHeight;editorArea.style.display="none";resizeBox.style.display="block";if(!resizer.eventHandlers){if(tinyMCE.isMSIE)tinyMCE.addEvent(document,"mousemove",TinyMCE_advanced_resizeEventHandler);else tinyMCE.addEvent(window,"mousemove",TinyMCE_advanced_resizeEventHandler);tinyMCE.addEvent(document,"mouseup",TinyMCE_advanced_resizeEventHandler);resizer.eventHandlers=true;}resizer.resizing=true;resizer.downX=e.screenX;resizer.downY=e.screenY;resizer.width=parseInt(resizeBox.style.width);resizer.height=parseInt(resizeBox.style.height);resizer.editorId=editor_id;resizer.resizeBox=resizeBox;resizer.horizontal=tinyMCE.getParam("theme_advanced_resize_horizontal",true);}else{resizer.resizing=false;resizeBox.style.display="none";editorArea.style.display=tinyMCE.isMSIE?"block":"table";tinyMCE.execCommand('mceResetDesignMode');}}function TinyMCE_advanced_initInstance(inst){if(tinyMCE.getParam("theme_advanced_resizing",false)){if(tinyMCE.getParam("theme_advanced_resizing_use_cookie",true)){var w=TinyMCE_advanced_getCookie("TinyMCE_"+inst.editorId+"_width");var h=TinyMCE_advanced_getCookie("TinyMCE_"+inst.editorId+"_height");TinyMCE_advanced_resizeTo(inst,w,h,tinyMCE.getParam("theme_advanced_resize_horizontal",true));}}}function TinyMCE_advanced_setCookie(name,value,expires,path,domain,secure){var curCookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+escape(path):"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":"");document.cookie=curCookie;}function TinyMCE_advanced_getCookie(name){var dc=document.cookie;var prefix=name+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0)return null;}else begin+=2;var end=document.cookie.indexOf(";",begin);if(end==-1)end=dc.length;return unescape(dc.substring(begin+prefix.length,end));}function TinyMCE_advanced_resizeTo(inst,w,h,set_w){var editorContainer=document.getElementById(inst.editorId+'_parent');var tableElm=editorContainer.firstChild;var iframe=inst.iframeElement;if(w==null||w=="null"){set_w=false;w=0;}if(h==null||h=="null")return;w=parseInt(w);h=parseInt(h);if(tinyMCE.isGecko){w+=2;h+=2;}var dx=w-tableElm.clientWidth;var dy=h-tableElm.clientHeight;if(set_w)tableElm.style.width=w+"px";tableElm.style.height=h+"px";iw=iframe.clientWidth+dx;ih=iframe.clientHeight+dy;if(tinyMCE.isGecko){iw-=2;ih-=2;}if(set_w)iframe.style.width=iw+"px";iframe.style.height=ih+"px";if(set_w){var tableBodyElm=tableElm.firstChild;var minIframeWidth=tableBodyElm.scrollWidth;if(inst.iframeElement.clientWidth=0;i--){var nodeName=path[i].nodeName.toLowerCase();var nodeData="";if(nodeName=="b"){nodeName="strong";}if(nodeName=="i"){nodeName="em";}if(nodeName=="span"){var cn=tinyMCE.getAttrib(path[i],"class");if(cn!=""&&cn.indexOf('mceItem')==-1)nodeData+="class: "+cn+" ";var st=tinyMCE.getAttrib(path[i],"style");if(st!=""){st=tinyMCE.serializeStyle(tinyMCE.parseStyle(st));nodeData+="style: "+st+" ";}}if(nodeName=="font"){if(tinyMCE.getParam("convert_fonts_to_spans"))nodeName="span";var face=tinyMCE.getAttrib(path[i],"face");if(face!="")nodeData+="font: "+face+" ";var size=tinyMCE.getAttrib(path[i],"size");if(size!="")nodeData+="size: "+size+" ";var color=tinyMCE.getAttrib(path[i],"color");if(color!="")nodeData+="color: "+color+" ";}if(getAttrib(path[i],'id')!=""){nodeData+="id: "+path[i].getAttribute('id')+" ";}var className=tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i],"class"),false);if(className!=""&&className.indexOf('mceItem')==-1)nodeData+="class: "+className+" ";if(getAttrib(path[i],'src')!=""){nodeData+="src: "+path[i].getAttribute('src')+" ";}if(getAttrib(path[i],'href')!=""){nodeData+="href: "+path[i].getAttribute('href')+" ";}if(nodeName=="img"&&tinyMCE.getAttrib(path[i],"class").indexOf('mceItemFlash')!=-1){nodeName="flash";nodeData="src: "+path[i].getAttribute('title');}if(nodeName=="a"&&(anchor=tinyMCE.getAttrib(path[i],"name"))!=""){nodeName="a";nodeName+="#"+anchor;nodeData="";}if(getAttrib(path[i],'name').indexOf("mce_")!=0){var className=tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i],"class"),false);if(className!=""&&className.indexOf('mceItem')==-1){nodeName+="."+className;}}var cmd='tinyMCE.execInstanceCommand(\''+editor_id+'\',\'mceSelectNodeDepth\',false,\''+i+'\');';html+=''+nodeName+'';if(i>0){html+=" » ";}}pathElm.innerHTML=''+tinyMCE.getLang('lang_theme_path')+": "+html+' ';}tinyMCE.switchClassSticky(editor_id+'_justifyleft','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyright','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyfull','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bold','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_italic','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_underline','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_strikethrough','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bullist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_numlist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sub','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sup','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_link','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_unlink','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_image','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_hr','mceButtonNormal');if(node.nodeName=="A"&&tinyMCE.getAttrib(node,"class").indexOf('mceItemAnchor')!=-1)tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonSelected');var anchorLink=tinyMCE.getParentElement(node,"a","href");if(anchorLink||any_selection){tinyMCE.switchClassSticky(editor_id+'_link',anchorLink?'mceButtonSelected':'mceButtonNormal',false);tinyMCE.switchClassSticky(editor_id+'_unlink',anchorLink?'mceButtonSelected':'mceButtonNormal',false);}tinyMCE.switchClassSticky(editor_id+'_visualaid',visual_aid?'mceButtonSelected':'mceButtonNormal',false);if(undo_levels!=-1){tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonDisabled',true);}if(tinyMCE.getParentElement(node,"li,blockquote")){tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonNormal',false);}if(undo_index!=-1&&(undo_index0)){tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonNormal',false);}if(undo_index!=-1&&(undo_index>0&&undo_levels>0)){tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonNormal',false);}var selectElm=document.getElementById(editor_id+"_styleSelect");if(selectElm){TinyMCE_advanced_setupCSSClasses(editor_id);classNode=node;breakOut=false;var index=0;do{if(classNode&&classNode.className){for(var i=0;i");}else{selectByValue(selectElm,"");}}var selectElm=document.getElementById(editor_id+"_fontNameSelect");if(selectElm){if(!tinyMCE.isSafari&&!(tinyMCE.isMSIE&&!tinyMCE.isOpera)){var face=doc.queryCommandValue('FontName');face=face==null||face==""?"":face;selectByValue(selectElm,face,face!="");}else{var elm=tinyMCE.getParentElement(node,"font","face");if(elm){var family=tinyMCE.getAttrib(elm,"face");if(family=='')family=''+elm.style.fontFamily;if(!selectByValue(selectElm,family,family!=""))selectByValue(selectElm,"");}else selectByValue(selectElm,"");}}var selectElm=document.getElementById(editor_id+"_fontSizeSelect");if(selectElm){if(!tinyMCE.isSafari&&!tinyMCE.isOpera){var size=doc.queryCommandValue('FontSize');selectByValue(selectElm,size==null||size==""?"0":size);}else{var elm=tinyMCE.getParentElement(node,"font","size");if(elm){var size=tinyMCE.getAttrib(elm,"size");if(size==''){var sizes=new Array('','8px','10px','12px','14px','18px','24px','36px');size=''+elm.style.fontSize;for(var i=0;i0){selectElm.setAttribute('cssImported','true');}}}; diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template_src.js b/wp-includes/js/tinymce/themes/advanced/editor_template_src.js new file mode 100644 index 00000000..e69de29b diff --git a/wp-includes/js/tinymce/themes/advanced/image.htm b/wp-includes/js/tinymce/themes/advanced/image.htm new file mode 100644 index 00000000..0b5c7db6 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/image.htm @@ -0,0 +1,112 @@ + + + {$lang_insert_image_title} + + + + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    {$lang_insert_image_title}
    {$lang_insert_image_src}: + + + + +
     
    {$lang_insert_image_alt}:
    {$lang_insert_image_align}:
    +
    +
    + + diff --git a/wp-includes/js/tinymce/themes/advanced/images/anchor.gif b/wp-includes/js/tinymce/themes/advanced/images/anchor.gif new file mode 100644 index 0000000000000000000000000000000000000000..34ab71534b74e1f8eb01a822d2073cde4cd878cb GIT binary patch literal 171 zcmV;c095}+Nk%w1VH5xq0K*0VDLrY1lc!y3io(UtI8lV8tiaOK*3t6qtjy*E#3&d$!w&zD+OKB~ULl7eEw((m;2 z^kQ<7@$qtYhNk=Uwg3PCA^8LW000jFEC2ui02BZe000DA@X1N5y*TU5`(_{rgp5Wq zV<-tiQw0DJpz-{)hcHm#IKm8pA~9I(Ca@SvR8S0cm6VSWFgTt^N>UaxG!szEiFzP_ cvz1f8Q5b|bYX=qJK_CnUx@XVt`!Nv!J5VM>-~a#s literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold.gif b/wp-includes/js/tinymce/themes/advanced/images/bold.gif new file mode 100644 index 0000000000000000000000000000000000000000..d6a9cc2cd4117526156fa29c06156ba5971823c4 GIT binary patch literal 76 zcmZ?wbhEHb6k!lyn83&Y1dNP~ia%L^OhyJB5FaGNz@*&Mzw-23{>3a?E=Bm(Rqw7V Z4AWqey4jFcx$b3$*C(Ir-+DzDtN~+a79aos literal 0 HcmV?d00001 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 new file mode 100644 index 0000000000000000000000000000000000000000..9b129de25e916946792c89f08a7b30b2f9dc8b72 GIT binary patch literal 73 zcmZ?wbhEHb6k!lyn83&Y1dNP~ia%L^OhyJB5FaGNz@*UAzw-23e#sdnZdC`i8W!&j Xl@)6cxH+8$Fz@Ye(g^_`QkwFK@28xR?Ffgg~^shYqmVYseNeI`y fv!S2m6KACKPM+Zyy|O9RI8W2_`nTTOtPIuwq8S!> literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/browse.gif b/wp-includes/js/tinymce/themes/advanced/images/browse.gif new file mode 100644 index 0000000000000000000000000000000000000000..c786d0b2050a1a59fe6d729497bdd58329011509 GIT binary patch literal 113 zcmZ?wbhEHb6k!lzSjfnr=Th|l|Nq&XoD2*Mia%Kx85o!ubbxFIkURsE)13a5r@8nS zvv9CjKVG}@Iz!tc57{sUjwG+Tj8*&Ir1h0WNImEIwB=qiYx>TEFU_>xB^?a&6>B~^ R#bfrS$(b43?=Ue~0{~-MC*lAA literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/bullist.gif b/wp-includes/js/tinymce/themes/advanced/images/bullist.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e19467c70e337bbfb2a3fe3eff1bc3acab0eaec GIT binary patch literal 108 zcmZ?wbhEHb6k!ly*u>1h#Kfdz)l@%W&!*iMf|{-?85Jc}En;9`Q2fcl$iTqPpaWzB zRf;e$FdJ6vy7SNAl;>@M#YT=zObHxz&I%bBUa^s_ M6r5P1!pL9^0IPo@`~Uy| literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/buttons.gif b/wp-includes/js/tinymce/themes/advanced/images/buttons.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d5e08b5e6c88ac89d270bdcb9b052d22b9116a9 GIT binary patch literal 3286 zcmWlWdpy$%=lY-!@~b1p`D*lH9Uw98*aWkwzj5}-cT|RixNdr=-OKIuUcF2yr}A$^4XleqhE7d zXZf|+e>svaK3qPbU0Ov3b?rx$C&Qnvya;z3|^}i|q?flS`_ljrC7cYL{h=jehlu zHy+*Somf7cebq7fTY1;Vu(;f?6j{&xr~3N(sps3zWe5_-V!ILf(WDA_kUFkC_C}l!k)Zrm2~4a(qKon zPpqXHj4;87Od?8f-ib4b39=lDapYOL&L!)`zqNmt0jAJF>!7UV747)hGAT#CL-GlblmTwDtCi& zCLQ#$pa;eN@c=a3;MbqTYzyzFTZ=mcZ4QZhcIVu!`^LN_K5y>57-7OGAR>&3je$xk zi(P^t6TBZddYk+Ktk~+6#TV7vM}9bxR=sOu zBb6{$6aK&=HbOqpEGUEbl`hZ4xeWe}w+diG5tAC`tPq#wAn5<1c)@zE&JdSe@j zB1+C)X6qEV{^fPg*Obn#d`F(L5cl=|{FeDrH}sm%`;p+Qdp}IwF;bQ@(GB6gt@f@=VZKI~j&L@p? zYG~P6*DLL(&l3;fPd5ni4Sdl&3Z1)sroi~1d|=vgpA+jTwus*vdPa{H z%5HjW8Bxb6vT?|wS<%wavn=!E11|3kh%1@s3&#p;Mq$V92deTmh-h36f&x+-M5BTc zy4R`(h9{bqe6Wo5(fFH!tyPXm1xX4xPCN%g=$MW2l|cGXfa+*ou+iY1yi-kGck_}s z=(5e~y+WOpMY~$N{nE-*qe*N1a6%xN>xa2H&tv27$KFurYHr6J4b&17s2xjCzv=4D!pjvqGB-X|UR!3AnMiL)n`F#14O(*)K z4VtB9rNPj{yVL^uqRSZ#R_|201Hc%|c-ETV%@tzq)By^h?C9NNZI@1`LGOr?n5pKb zr_=-Z)CR@ERi_F?flIcJdiil4M==Q3)lyg84WcGkI(pVoAa;OWm_{q{colVhH#`8M zZ(^T|sot$0_rUO&dE808B8C6~NpMyGq~lyk!7FaX2J{^lH2vj&{$n)Gf4&JV--XK9 z;yOeqlZKj^Zg9{KR|L+fp(qqQO$1<$jAZ*3uDA$|JbZ{KbDqz4(K^zM-5D6RnDzC* zNZjbNm z&lw4PH6eNFb$Z514+ZqTj=ej8#VR>e>`f^yeQb&vt?**@Lryx@<0OSK2>0c-F%VzX+LI1Ta7&f*9$MC#;2Xz@S{%% z_eP1d9h_j-@gxL<#iZC$heawI=!o^CUza`T)6e`_zv_SiPYOqZm8gYM+?_tRi(hr= zj%T#KG#^Hx0VpSMx_uYO-51OWR4hzwWtnIPP9pR(^Uc}(GoPT`_IC)=z5(5wc67j2 zA!;KCp~Ptm2dtGi|8==TWIYvc&W{az?Z!5aF9^CS*gzIXpo|1CdK#wY#@8a!R8ejSjZMKyUL#m@gq@Phq!tde z?I9Bnf&jYE108WM^_)n{CA)A655&*t5LV@mFHR11{gr@Ea zRNX(}nZnkW#-wwe50?2=D8mBlAE!fnFH8CO z78bb4d8V}xJhspUEw_q*U~DyJch*+JnaNbS4S9g}Uv-fVPL3mKVc`ZYKK}gz7*+$U z>rzJro>P8+m;Ja&L%7Hm-c)_bTwtn^!Yqbj5m=CCyhTy4hcu%X2*&F-R-C~7&q7bz-&Jf(a@(4sHIn+zR_-o^bBL?4M7Sm(2Ov*1(i2STIt^6X0$J^U?`fQML$m8 z;NCB~>PDFHi?4#wjhUFkQA+)35Oh?#qjs*=(B)d>#0KTt0tsL;#1)OC?8m(ig6qf_ z$IY|OlBBrLcatQi{kqRSN#6U}vN02ek6PC|t%uszikeNiu%hQf$f9Tt1*;JhiOs`i zOxh=Nw=G9>CP?dBzx%v37pg%Nz0GBZ%Sw?TqR zsDzg3`|YXW*Yi*2Ot|E#iYong-d7`Z)uKI7X-1i>Lau0!6dogiY}OvBLZ8_Jhkj9_ zCnOLP=j@dQ#r8dN~{IES>T5kWt0 zy6cYoK97x3XP$*3IRF;p49U;{xGKc+SH*Gy@~9U!y&Lf&s_Z35>6$I=<+=FE(dz)g zaIZLz;RcJ_S3Yllda|y3p|8AE3U+a~*pnSTcvY-KRea8>Sgou0)>rX;qGD~e0x*$4 LuapS@VB7x#nmUU0 literal 0 HcmV?d00001 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 new file mode 100644 index 0000000000000000000000000000000000000000..4b4aeefcbbba8ed33383d99e3ad38a2b9683044e GIT binary patch literal 677 zcmV;W0$Tk?Nk%w1VOjtc0K@)fLs#+_}=< z+2GjQ)C|ia%M}g|2-*$|4jAv++6)X8?f3NB2<-a^7%Bu**N)yjcm?$#=+|zcKYj)I zIjF!OVTE%a3KYO_;R1$_A3cH`Nit-~lPFRDiUhfmW6G2Q3W(6yv1UzC}*s)i?z8nAt58I(vAO9Tu2JqX_n^*5Vy?OEB-=jZ2zyA2} z=ksr%;9UfV@9G68;D7`cXyAbe9{8UkfB!Y;;DZoGDB*+@R%juG3|^?=h8%WSVGAIJ LDB_4Bh5!IN$Y@?j literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/center.gif b/wp-includes/js/tinymce/themes/advanced/images/center.gif new file mode 100644 index 0000000000000000000000000000000000000000..42d609a991f51b029ef83a1d4a5a978b0cbb4ec8 GIT binary patch literal 70 zcmZ?wbhEHb6k!lyn83&Y1dNP~ia%L^OhyJB5FaGNz$Dw#zw-23e&HEgu5~nTwS324 TB4E+Ue{v@8s%`JM#Tl#t;~Nqj literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/charmap.gif b/wp-includes/js/tinymce/themes/advanced/images/charmap.gif new file mode 100644 index 0000000000000000000000000000000000000000..3cdc4ac9134258a9a1a83b6afd5c7055bebbcbf9 GIT binary patch literal 245 zcmVJ7UM8qsvB8x<;Dr zSg7=Nn%Hi7)&KwiA^8LW0018VEC2ui02BZe000GY;3tk`X`X1RuI#x~)x&X5LaDKL zBuP+gmjjC8P!LL;h9PruTqdW2VQ_jhm?kOJM8RlI0sywOkQfrBgdlP}Q6Q310n$b# v>y*a!grF>@BLxiv8314c77P(14Hy;xh9(V(3=AWV77>droSmMZC?Nnljc8>f literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/cleanup.gif b/wp-includes/js/tinymce/themes/advanced/images/cleanup.gif new file mode 100644 index 0000000000000000000000000000000000000000..16491f6cfcf3e1123f08352c895f8010f791c469 GIT binary patch literal 256 zcmV+b0ssC-Nk%w1VH5xq0MrlwMm#2xdP3^ge4>(aXJcF2&#c0@g7@*TXJyAiI+Bx- z!osRT%E{EUw6tz+enw7G^6K)^$d=yS-J+Ue{{6y&f`-z%VxXFs!L^y{+>(HFVv>^L zOipLAk}~7mu>b%7A^8LW0018VEC2ui02BZe000Gj;3tk`X`X1RuBfCa3_CK)hB&I! z?6jS5DV>BNxhN371`1>FG$6!^gQF}JB8CHn;<-pFjYq{)@NCbANaf;iJjfX><#5Od z41@~dZSq94bpiqw6C4j!WCnJE77HB!h$k2WjE(>oEEpP%kC-wT1Ob;aBcK|jsHv(a GApkq`d~Wvu literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/close.gif b/wp-includes/js/tinymce/themes/advanced/images/close.gif new file mode 100644 index 0000000000000000000000000000000000000000..679ca2aa47644793fc7096142233af6d18cfc9ac GIT binary patch literal 102 zcmZ?wbhEHb6ky1B=+vSZwA88iSX|!)1|*>PlZBCifrUW_BnDE;z-;WX>&`!e zQ=Y5$?qJ;7tnMTs#JpKBeE~;8w4TG9b-KTcEEZl{H}m}(h0KD}68$HZ6lMA_FjxZs D>4hO7 literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/color.gif b/wp-includes/js/tinymce/themes/advanced/images/color.gif new file mode 100644 index 0000000000000000000000000000000000000000..1ecd5743b64464068d80fe0c306375bc0f36a3f9 GIT binary patch literal 125 zcmZ?wbhEHb6k!lxSi}GV|NsBLa^b|RS+g7*9Dr=F7=z+Z7DfgJRt6mq7o?Vf*~wzp z9Utctp08V)UYxZ)DHzz35?MDRW1X_prZuwmzXRH=pKYwZWOr?gDO&r}E WQznT77&6ApIg)ei@KZGg25SKIc`;M~ literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/copy.gif b/wp-includes/js/tinymce/themes/advanced/images/copy.gif new file mode 100644 index 0000000000000000000000000000000000000000..dc146865c5952aa48b82fc54677db621322465b9 GIT binary patch literal 263 zcmV+i0r>t$Nk%w1VH5xq0MrKnGD>2SrMb<|)0(p4GF`Q=%=coD-uwLia-!n0ztXb8 z>SB7D(cbRC&Eb``_99D}N_N7cveI&z@*+Zl!qxWT>hhwp!g8A0g0kXLg3_YG@}jE3 za+1=5r|rPV)BpegA^8LW0018VEC2ui02BZe000Gq;3tk`X`X1Rt}Ll2NgN5Sa@>ct z&})Jp0ne^?pcEK^!b{_DFiw_VrSR(z8m7&Gi9u+7k^;d~3fw9c#^BIo7zl(%`OrmN z*0>5KA}5&{3=It(2OS6o85w+K0F8|tI1CgD7JVrO2Z)Io8#2N9wc8v&jt5O5Ex Ns}n7+u(2f}06RB$bN>JU literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/custom_1.gif b/wp-includes/js/tinymce/themes/advanced/images/custom_1.gif new file mode 100644 index 0000000000000000000000000000000000000000..4cbccdadf60dfccaf532fd56a567c47b131f80a8 GIT binary patch literal 76 zcmZ?wbhEHb6k!lySjfQ8(7@2Zz`(%B2qYALvH&S21|1+9C@TVF%TDQEdHOB?;yGKQ b7!RD8^=Ve+T!9>q%7xRawyuk2V6X-NXyp|c literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/cut.gif b/wp-includes/js/tinymce/themes/advanced/images/cut.gif new file mode 100644 index 0000000000000000000000000000000000000000..4e9a70b6e297cfa0744d581c42868b35b0a7a204 GIT binary patch literal 187 zcmV;s07U;sNk%w1VH5xq0K*3W0z;>dm7`y6hp@H0TzRe{O`Us&m(k6|m7uZ$S-vl0 zv81W9YJ#%8z`z1cvH$=8A^8LW000jFEC2ui02BZe000DN@X1N5y*RH`2hYzS9F#DC z&mja;FrrU@G*7b_@UslKvE>g#z<@B2axx(c_%I2W2u49rARu4_N5ZktItZW!fI&z+ p0E8?Jvj7|jibsJV{#*tC#rVODXii?U706WgML@)pV literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif b/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif new file mode 100644 index 0000000000000000000000000000000000000000..d5e381425fe0f58a146d8d68141686aa517c3391 GIT binary patch literal 272 zcmV+r0q_1tNk%w1VH5xq0MrHmVgdq!0s^>+A(FDP-mWX|+>7q%%Knm4;nJw;$6E00 zq5^UP@!4qj@34~ELeii*Vv@1~0%EdyB3-fv0%8IZO0wc20s(+4wP$kLBD|J7 zDvko>y+!`AasU7TA^8LW0018VEC2ui02BZe000Gz;3tk`X`X1Rsz$-QOtXFlqcphk z8fksw4TYkR;GGIL&%qNEW(vkqtZ}da8Ux6n@PL|Z4NSmNfK(!kj37En{Dy_fq91iUI{G1P_oC3mgd#5-J3RFrN~4DUKZp W2^|}!GYA_35_SkPxVgGBApkpwVP<>) literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/full.gif b/wp-includes/js/tinymce/themes/advanced/images/full.gif new file mode 100644 index 0000000000000000000000000000000000000000..c8504f626fec70376fc768c92f04f666cea5993c GIT binary patch literal 71 zcmZ?wbhEHb6k!lyn83&Y1dNP~ia%L^OhyJB5FaGNz$Dkxzw-23e&HEgu1Tz2Ch_jB V?R+t-#i3@;r*3=4EzQbc4FLT|66XK_ literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/hr.gif b/wp-includes/js/tinymce/themes/advanced/images/hr.gif new file mode 100644 index 0000000000000000000000000000000000000000..1a1ba2a015d87362d3cebddf002a788def9d558d GIT binary patch literal 63 zcmZ?wbhEHb6k!lyn83&Y1dNP~ia%L^OhyJB5FaGNz$Dhwzw-23{>5{)+~RJ$w}+Xh M?UBc{1V#pH0B+0Sa+3=zxSlW-zei2b}a=z4u4c+1=|M6#AZUG%OY1V6F^WxI(BULHv>RQKq-j zt7NjCDogO`gJ_lySi|J(sDATCUOUsGgu4xU7+ORVU(d1bXgSWKeMyMJ iI-K#xts6OY)eP+JZLJ;d&BZ;{lKm4VP7)Gium%8};6e`o literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/indent.gif b/wp-includes/js/tinymce/themes/advanced/images/indent.gif new file mode 100644 index 0000000000000000000000000000000000000000..acd315bb16c47c2f1679bdf440b511497f9d633b GIT binary patch literal 112 zcmV-$0FVDiNk%w1VH5xq0I~!C0s;a%TAPZd(ouxs%G2Opda$m#$^ZZWA^8LW000L7 zEC2ui02BZe0009uc)HyFFv__Ay%A`;yT;Qn5S6zzgeZ{axrjp`gM=IyhY1x0spz0f SC)ctBGpEmS`C~dK2>?4to+ugs literal 0 HcmV?d00001 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 new file mode 100644 index 0000000000000000000000000000000000000000..69c131ce2992df593b0f4299bca3b823819bfafa GIT binary patch literal 703 zcmV;w0zmyoNk%w1VOjtc0K@s=_xSkz{{8#>`}z9$_xShz{{8*^{QUg;`}_L%`1kks_WJqx{r&y?{QUd-`}+F& z`T6KpoHUDH@N+q;kn@I-kkc5K66DuS_Z6KrDKY7RyI09*;fWvU%-gtB;niQErU0 zm*isj!{r@5Xn}%*gn@BrfQ5mHij9PfUyfe}2OBRWtq`cJq8+WUnh>9$sjjjey0H)tuAaQc9f1|Fwgs1#2OS*J)Y8+b*w@wD)!H1| z*x};Wufcfgl`*#qaLw)i7 z zoH>KW+zFGYhMgLD9zY-h0fGes24t9!p{j-j6DCB>;GpUR4OAyM=(>QbRjLa#3_uGO z>HrN@Gf0g)AZ^&Gar5dmTXybOr%e$Eh>L-6)xsGhB#tWqL*v4b9V>pE7=z`>iZc|> ztl2VQ$DKVp7OfcZVa0#}IK>dbvVaB+6ueeo*>VKfu`$SQfI)y|-o6|7?%lifYXPr$ z!>-Mob%f^%8bpZhntE^Fvsq(UkUGIr1<%7n7f-%?_yFe9t6xtZ{rU9?5{QT&pnm=7 z5zyOrUtfX!=lcb?pMU?kmmhlI6)505fd}4aAAtcXfPj1e&?n%97-p#9h8%WyVSMw& lC*p`CmT2OMD5j|5iYbQ3;)^iGD5Huk)M(?4INlfn06R=DYYYGY literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic.gif b/wp-includes/js/tinymce/themes/advanced/images/italic.gif new file mode 100644 index 0000000000000000000000000000000000000000..8bb330bd0bbf61fdb5ce86388ecbeae16465bc17 GIT binary patch literal 79 zcmZ?wbhEHb6k!lySjfl#1T8Hs)z#IEjEssuS%3n}3_2iDkURsE!kqq_+b+wcJF`+8$Fz@Ye(g^_`QkwFK@28xR?Ffgh1^shYqmVdFy0;Z@$ hzTc5`u943p7fMVz+n$-ed(#4|tKWK`2QxBQ0|3J`7vul{ literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/left.gif b/wp-includes/js/tinymce/themes/advanced/images/left.gif new file mode 100644 index 0000000000000000000000000000000000000000..e8f7e42769cbfd7a7416aac8faf77f5d8daed320 GIT binary patch literal 71 zcmZ?wbhEHb6k!lyn83&Y1dNP~ia%L^OhyJB5FaGNz$Dkxzw-23e&HEgu1TytYV(4> UgwLW=vT`Q(s%`JMrCAxQ0qpY;qW}N^ literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/link.gif b/wp-includes/js/tinymce/themes/advanced/images/link.gif new file mode 100644 index 0000000000000000000000000000000000000000..1accf426260eabe2f3113bab599ee26991407576 GIT binary patch literal 175 zcmV;g08sx&Nk%w1VH5xq0K)|U7cWe7jH1WO&q7mgq_fHP{QhovkA|48(BJg3yUmlM zwNqn#%+lYo$Ksc#!~g&QA^8LW000jFEC2ui02BZe000DB@X1N5y*TU5yZ;lDIEo`Y zBB>;nh!jN=5Xl<{ELAJRLi`OvPeCwL9EE`(0V^O727v-Gs1O*6fC9h;473EtqJph4 d4hzK!aZXzV=z)RofG^|2SqO#J~;-aN z((?HJ(%tf+t-`|0-T(jqA^8LW000jFEC2ui02BZe000D6@X1N5y*TTfdRNNeY>8o> z4KQZPc^-wzx@G{}*+AEJzAuCxrm-U+gcqV~fj9y(hozB$v;>w-LA7!<0TB$xmeMs$ Y1>z^>8fd%Q>Wl40uW#=7ygmW|J7pwMu>b%7 literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/numlist.gif b/wp-includes/js/tinymce/themes/advanced/images/numlist.gif new file mode 100644 index 0000000000000000000000000000000000000000..a2683522f4fbca7c59cdce63c7ac20211e006f49 GIT binary patch literal 111 zcmV-#0FeJjNk%w1VH5xq0I~%D0s;a&S(>c5(MoQ;hMLOK*yvJx*8l(jA^8LW000L7 zEC2ui02BZe0009tc)HyFFv>|=F}0bofd8LU3_`XHL13V($?Eohv$~E=l}o!A^8LW000L7 zEC2ui02BZe0009sc)HyFFv__Ay%A`;yT+FxC|=hX#Xykdw-jk0V}u~DM=9B?30|g_ Q>jw#1h)7a$IY|HjJN(2Zp#T5? literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/paste.gif b/wp-includes/js/tinymce/themes/advanced/images/paste.gif new file mode 100644 index 0000000000000000000000000000000000000000..1b45000a0140b8f9e04c933154c915f4322d7533 GIT binary patch literal 286 zcmV+(0pb2fNk%w1VH5xq0Mr}+LNg;3tk`X`X1Rt{>*It?NM0VL6(E zVp#@75XZ#A7$__!UdC~NbOwn>K!P;!f|hLd!H_&o5ubBI-bl_Ku=A;)xD5t@Ks^{# z+MN7ifk2od9Tj&Q6dVnQ7YGCeB^rSW3L6F-dlv)<1qEp%4jqtY1`CG`6a;PnBn}E^ kX95eB1O$f^sHqkY9smLtZoQ`}2mr#v!!X9j$Rr^EJMbBDr~m)} literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/redo.gif b/wp-includes/js/tinymce/themes/advanced/images/redo.gif new file mode 100644 index 0000000000000000000000000000000000000000..3af90697f0b74d0b6b07b585614a6dc67ff87f1d GIT binary patch literal 169 zcmV;a09OA;Nk%w1VH5xq0K*FaEl-kjqwqa)*O$8QUUsNeit)O{)H!9gj;!cSf8=SD z@4U+CH(H=qeZQ%{>Hq)$A^8LW000jFEC2ui02BZe000D5@X1N5y*TU5@mkK(Nsfb@ zh`52taWqPx3Yb$cP21Nib_4)BqDn)z literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/removeformat.gif b/wp-includes/js/tinymce/themes/advanced/images/removeformat.gif new file mode 100644 index 0000000000000000000000000000000000000000..0fa3cb79734b6ddadaded7a30dbbab4cdf7ee11a GIT binary patch literal 168 zcmV;Z09XG3d^!9RvqL!@E;^*>mjX*~6o0ZXGB7YP=m6OaAbAERg(>|jPrv0~%%#ha d_MXKm)lqT2YSDtso)?w9Z@gz^T^C`n1_07v8bkm9 literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/strikethrough.gif b/wp-includes/js/tinymce/themes/advanced/images/strikethrough.gif new file mode 100644 index 0000000000000000000000000000000000000000..3264635918e2237257811a745f3a7e31b4369432 GIT binary patch literal 83 zcmZ?wbhEHb6k!lyn83&Y1dNP~ia%L^OhyJB5FaGNz@*jFzw-23{>5`RB^ury^=8j) h^eUTr??>*V8C&%_D;C}?e9svC>)iK$`!yICtN}048)X0h literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/sub.gif b/wp-includes/js/tinymce/themes/advanced/images/sub.gif new file mode 100644 index 0000000000000000000000000000000000000000..4d7ce30ff9147412d24dafd5ebeef67479edfa58 GIT binary patch literal 148 zcmV;F0Biq8Nk%w1VH5xq0K*9Y0|NsxQi79`kcOJVNJU7aqM%ZC%4un5GBq-gVG=Kt8X#(^7ugLSm;_S64DJ zGIDZqhMK}68X{71!TeAXEkg0%mX10Jt7ez-i0vdcUU#06Sc5 BF?Rp} literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/table.gif b/wp-includes/js/tinymce/themes/advanced/images/table.gif new file mode 100644 index 0000000000000000000000000000000000000000..2911830c3cd9cfb588114b40205ac316ded37716 GIT binary patch literal 287 zcmV+)0pR{eNk%w1VH5xq0Mr-&4-XG=a&q$Gl8~UV)yls!N@Iej^5Wv+vYk|?#{7~x zGT6sxlB&Y;^7(>_g2~h3+KzIM(yqDEw{v33+VWCfYLcq*{{H^LvU=X>{iCqL z#mds6qN19*_y7O^A^8LW0018VEC2ui02BZe000G?;3tk`X`X1B5)?(KB@00mJQCSN zE9B*0hM>X2$p{t>MWmN#dOXbs;)npedOjg>x~OhU6O8zQIdH3l0a%P7cOqTD;bAdt z9{7i*gQ;>J6LlpUY-9lzat#_A1ttt^9EFODjU@vQ92^px5)&Jr43#7UY!VHM8yXcA lp(dna6O$XO2?L@dmz|!U8w?Bswyp)k#Kpum$jK!k06V*Ud_@2N literal 0 HcmV?d00001 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 new file mode 100644 index 0000000000000000000000000000000000000000..91f53af02aacbe33b04f782efb164560887d3bfe GIT binary patch literal 163 zcmV;U09^k^Nk%w1VH5xq0K*Fa0s;azZ{ony{xV8pTyKn*qO$Jn>V2Z^b%c^$j^>)S z^85Syjgq3Ovcf`IasU7TA^8LW000jFEC2ui02BZe000C~@X1N5y*TU5Yg=F;j03m~ z*9S7AQZ5E+6`;WiE*xJ4;S4OrVLD zq^HC5lAo_~pYs0x{r~^~A^8LW000jFEC2ui02BZe000D7@X1N5y*TU5>G|Nna879^ z3V9~RxRnWO7y-xJIHT+-78`=#Vo@mc9)Jo^FeDZl1O#9@r7(*PC}E43Bq@Wics$6M ZU5s;*CQxUf_d3_{csz*D~813(lGjTD@2z{n9^mxAJO7)Ys5OF}UnY`dU@qbmky T#N$E3kp`{PZ$%b~i~s;TfG0;) literal 0 HcmV?d00001 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 new file mode 100644 index 0000000000000000000000000000000000000000..b9c14466138007454958671320914d9a7d8a6db5 GIT binary patch literal 163 zcmV;U09^k^Nk%w1VH5xq0K*Od0s;b3hwZ}J{xV8pU2lbto3eVM^5XCQa(@5FN<(eWPqQV3Ig1XGua#QiUNM~QhRb*u41x>)iK!0SpY*0G3P}*Z=?k literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_fr.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_fr.gif new file mode 100644 index 0000000000000000000000000000000000000000..551d9148d302c5f58b3b20d2c6a642450889a7ef GIT binary patch literal 79 zcmZ?wbhEHb6k!lyn83&Y1dNP~ia%L^OhyJB5FaGNz@*mGzw-23e(4zsAr}6}u9vvi dPIT?{=$xyxd19dGtWDy_KKDM~70ke34FHj_7K8u* literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_ru.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_ru.gif new file mode 100644 index 0000000000000000000000000000000000000000..b78e2a498fb9406ef378d7c543756db552d87cba GIT binary patch literal 77 zcmZ?wbhEHb6k!lyn83i`>+8$Fz@Ye(g^_`QkwFK@28xR?Ffgg~^shYqmVYseNK2Ny ft@O9qnGc`Wq;$3l?I>E+zBOCw^tWDnRt9STq^=gR literal 0 HcmV?d00001 diff --git a/wp-includes/js/tinymce/themes/advanced/images/undo.gif b/wp-includes/js/tinymce/themes/advanced/images/undo.gif new file mode 100644 index 0000000000000000000000000000000000000000..520796d69defa118055d191eec33cc67f7551710 GIT binary patch literal 175 zcmV;g08sx&Nk%w1VH5xq0K*FaI$fTWtk6Go+_}Zyr?=K#e#T#ZwX4DHa-Hu#XSz{; z-OtzKVv^{Tv+z=g@&Et;A^8LW000jFEC2ui02BZe000DB@X1N5y*TU5^*Z3vJx60U zVAe<_A|#2DUTDd{g#kDRhWrRvKmt&#E(`|)VHiweM~gz>Krlp-Snncu!2ps)!r>e} d2m*##Qg9H=3xcDt9yk2euEN*a>RflBvc=VMi?aIs{*Scsi=V=*#PZ+j z{;astf|jzv(Biz+@&Et;A^8LW000jFEC2ui02BZe000Dg@X1N5y*TU5Y5N}`E=ypZ zo?#$r>naM6uI>xVQ-d%k;xmkbaDbB#Q~{NMWoQ&&iQ?mEND2guCgGWgQWh%TE;t;R zrC?g~sYnb2jsrT}bhh1bIVEWT3JYd|XL~9PPy-4A2LldqQhZ!)ii>%V0GF7VnjM^- Io)i%PJHdZeUH||9 literal 0 HcmV?d00001 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 new file mode 100644 index 0000000000000000000000000000000000000000..897a01f2baea1ae5f61f642f508c27f356b35260 GIT binary patch literal 694 zcmV;n0!jTxNk%w1VUPh50K@Fo9O z^8Eb#`uh6u@89F;?DO;Q@$v2O@aq2l{`U6r`uh3s@ay>a_VV)W^z`ua^X~Tc^Y!)d z@$u}Dr?mh7{{R30A^8LV00000EC2ui0FVI^000I5U_%&PX`X1Ru59bRa4gSsZQppV z?|kpu1Vq9^EE3jl(HgoTEOh>41ejE#aB*8r|OC z;Njxq>Ry;kxw7TUm@{kM z%(=7Y&!9t#9!C>oFt6t5TbcX>0AjqCgySDAyxO3~?&AYen-@t=y!-i+yC*K5ef#nAwj*aBzkGe++J%)n_rHGi z_~ZNgpFh5P|L(<$r}sa8c>VI(gJ+NLe*5z2!~0iHAKiNQ_Sx$f58u3gI&t|H25dm_ zCkt3u2SkGGWMEZW;Gomm$lxyIF~cPBOsnm+7=M9lPo_41opD-0LNQ51q(`+gvyFkl F8UVy~RVDxc literal 0 HcmV?d00001 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 new file mode 100644 index 0000000000000000000000000000000000000000..9dc8abe1a4f20643367ea9548fa2d93be7f0fb0b GIT binary patch literal 428 zcmV;d0aN}*Nk%w1VJrbC0J8u9k(-?1#*X>8IO~@#-Jw(NpE2?8-}$*X|HwS%i!A@g zJpcdy{QUj^0000000000A^8LV00000EC2ui04xD0000F4(1ekyy*TU5yZ>M)j$~<` zXsV(?aUgIk&vb3yc&_h!@BhG{a7Zi;2?B+3$!t2G(5Q4uty-_xtai)odcR%(V@xia z&uH^v&2GEj@VIuMl4*~XmY0~BntqX! zo@AS$qNAjxdYzx1rmL*2u8ydwlCQM2wzqGwvV^$3zQ3WmyOhAi#>ard!)M6N&d+hm z%Vp5j*2mJ*W7pi>w%OX=;^U>@)8y#sm*(2-?(gvN^7Hid)9m*7`uqI-{{IZ{0USuM zpuvOl1R`9>u%W|(3Li?GNU@@fG5cC(oZi'; + html += '' + tinyMCE.getLang('lang_author') + ''; + html += '' + tinyMCE.getLang('lang_version') + ''; + html += ''; + html += ''; + html += ''; + + for (var i=0; i' + info.longname + ''; + else + html += '' + info.longname + ''; + + if (info.authorurl != null && info.authorurl != '') + html += '' + info.author + ''; + else + html += '' + info.author + ''; + + html += '' + info.version + ''; + html += ''; + } + + html += ''; + html += ''; + + tcont.innerHTML = html; +} + +function getPluginInfo(name) { + var fn = eval('tinyMCEPopup.windowOpener.TinyMCE_' + name + '_getInfo'); + + if (typeof(fn) != 'undefined') + return fn(); + + 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 new file mode 100644 index 00000000..a89f9729 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js @@ -0,0 +1,59 @@ +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; + + 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, '&gr;'); + + html = ''; + + tinyMCEPopup.execCommand("mceInsertContent", false, html); + 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 new file mode 100644 index 00000000..2f758cfa --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js @@ -0,0 +1,324 @@ +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(); +} + +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 new file mode 100644 index 00000000..1d585aa3 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js @@ -0,0 +1,107 @@ +function init() { + if (tinyMCE.isMSIE) + tinyMCEPopup.resizeToInnerSize(); +} + +function selectColor() { + var color = document.getElementById("selectedColorBox").value; + + tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color); + tinyMCEPopup.close(); +} + +function showColor(color) { + document.getElementById("selectedColor").style.backgroundColor = color; + document.getElementById("selectedColorBox").value = color; +} + +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" +); + +function convertRGBToHex(col) { + var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi"); + + 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 "rgb(" + r + "," + g + "," + b + ")"; + } + + return col; +} + +function renderColorMap() { + var html = ""; + var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color')); + + html += '' + + ''; + for (var i=0; i' + + '' + + '' + colors[i] +  ''; + if ((i+1) % 18 == 0) + html += ''; + } + html += '' + + '
    ' + + '' + + '' + + '
    ' + + '' + + '' + + '' + + '
    ' + + '' + + '
    '; + + document.write(html); +} \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/image.js b/wp-includes/js/tinymce/themes/advanced/jscripts/image.js new file mode 100644 index 00000000..752e421d --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/image.js @@ -0,0 +1,82 @@ +var url = tinyMCE.getParam("external_image_list_url"); +if (url != null) { + // Fix relative + if (url.charAt(0) != '/' && url.indexOf('://') == -1) + url = tinyMCE.documentBasePath + "/" + url; + + document.write(''); +} + +function insertImage() { + if (window.opener) { + 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; + + window.opener.tinyMCE.insertImage(src, alt, border, hspace, vspace, width, height, align); + top.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'); + + var formObj = document.forms[0]; + + for (var i=0; i 0) { + var formObj = document.forms[0]; + + for (var i=0; i', 'gi'),'\n'); + html = tinyMCE.regexpReplace(html, '
    ','
    \n','gi'); + html = tinyMCE.regexpReplace(html, '\n\n','\n','gi'); + return html; +} + +function onLoadInit() { + tinyMCEPopup.resizeToInnerSize(); + + document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id'))); + resizeInputs(); + setWrap('off'); +} + +function setWrap(val) { + // hard soft off + document.forms[0].htmlSource.wrap = val; +} + +function toggleWordWrap(elm) { + if (elm.checked) + setWrap('soft'); + else + setWrap('off'); +} + +var wHeight=0, wWidth=0, owHeight=0, owWidth=0; + +function resizeInputs() { + if (!tinyMCE.isMSIE) { + wHeight = self.innerHeight-80; + wWidth = self.innerWidth-16; + } else { + wHeight = document.body.clientHeight - 80; + wWidth = document.body.clientWidth - 16; + } + + document.forms[0].htmlSource.style.height = Math.abs(wHeight) + 'px'; + document.forms[0].htmlSource.style.width = Math.abs(wWidth) + 'px'; +} + +function renderWordWrap() { + if (tinyMCE.isMSIE) + document.write(''); +} diff --git a/wp-includes/js/tinymce/themes/advanced/langs/en.js b/wp-includes/js/tinymce/themes/advanced/langs/en.js new file mode 100644 index 00000000..14657ba5 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/langs/en.js @@ -0,0 +1,76 @@ +// UK lang variables + +tinyMCE.addToLang('',{ +theme_style_select : '-- Styles --', +theme_code_desc : 'Edit HTML Source (Alt+e)', +theme_code_title : 'HTML Source Editor', +theme_code_wordwrap : 'Word wrap', +theme_sub_desc : 'Subscript', +theme_sup_desc : 'Superscript', +theme_hr_desc : 'Insert horizontal ruler', +theme_removeformat_desc : 'Remove formatting', +theme_custom1_desc : 'Your custom description here', +insert_image_border : 'Border', +insert_image_dimensions : 'Dimensions', +insert_image_vspace : 'Vertical space', +insert_image_hspace : 'Horizontal space', +insert_image_align : 'Alignment', +insert_image_align_default : '-- Not set --', +insert_image_align_baseline : 'Baseline', +insert_image_align_top : 'Top', +insert_image_align_middle : 'Middle', +insert_image_align_bottom : 'Bottom', +insert_image_align_texttop : 'TextTop', +insert_image_align_absmiddle : 'Absolute Middle', +insert_image_align_absbottom : 'Absolute Bottom', +insert_image_align_left : 'Left', +insert_image_align_right : 'Right', +theme_font_size : '-- Font size --', +theme_fontdefault : '-- Font family --', +theme_block : '-- Format --', +theme_paragraph : 'Paragraph', +theme_div : 'Div', +theme_address : 'Address', +theme_pre : 'Preformatted', +theme_h1 : 'Heading 1', +theme_h2 : 'Heading 2', +theme_h3 : 'Heading 3', +theme_h4 : 'Heading 4', +theme_h5 : 'Heading 5', +theme_h6 : 'Heading 6', +theme_colorpicker_title : 'Select a color', +theme_colorpicker_apply : 'Apply', +theme_forecolor_desc : 'Select text color', +theme_backcolor_desc : 'Select background color', +theme_charmap_title : 'Select custom character', +theme_charmap_desc : 'Insert custom character', +theme_visualaid_desc : 'Toggle guidelines/invisible elements', +insert_anchor_title : 'Insert/edit anchor', +insert_anchor_name : 'Anchor name', +theme_anchor_desc : 'Insert/edit anchor', +theme_insert_link_titlefield : 'Title', +theme_clipboard_msg : 'Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?', +theme_path : 'Path', +cut_desc : 'Cut', +copy_desc : 'Copy', +paste_desc : 'Paste', +link_list : 'Link list', +image_list : 'Image list', +browse : 'Browse', +image_props_desc : 'Image properties', +newdocument_desc : 'New document', +class_name : 'Class', +newdocument : 'Are you sure you want clear all contents?', +about_title : 'About TinyMCE', +about : 'About', +license : 'License', +plugins : 'Plugins', +plugin : 'Plugin', +author : 'Author', +version : 'Version', +loaded_plugins : 'Loaded plugins', +help : 'Help', +not_set : '-- Not set --', +close : 'Close', +toolbar_focus : 'Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X' +}); diff --git a/wp-includes/js/tinymce/themes/advanced/link.htm b/wp-includes/js/tinymce/themes/advanced/link.htm new file mode 100644 index 00000000..4b866fa0 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/link.htm @@ -0,0 +1,113 @@ + + + {$lang_insert_link_title} + + + + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    {$lang_insert_link_title}
    {$lang_insert_link_url}: + + + + +
     
    {$lang_insert_link_target}:
    {$lang_theme_insert_link_titlefield}:
    +
    +
    + + diff --git a/wp-includes/js/tinymce/themes/advanced/source_editor.htm b/wp-includes/js/tinymce/themes/advanced/source_editor.htm new file mode 100644 index 00000000..d8329ad5 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/source_editor.htm @@ -0,0 +1,51 @@ + + + + {$lang_theme_code_title} + + + + + +
    +
    {$lang_theme_code_title}
    + +
    + +
    + + + +
    +
    + +
    + +
    + +
    +
    +
    + + diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js new file mode 100644 index 00000000..3f6c6bf3 --- /dev/null +++ b/wp-includes/js/tinymce/tiny_mce.js @@ -0,0 +1,6081 @@ +/** + * $RCSfile: tiny_mce_src.js,v $ + * $Revision: 1.281 $ + * $Date: 2005/12/02 08:12:07 $ + * + * @author Moxiecode + * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved. + */ + +function TinyMCE() { + this.majorVersion = "2"; + this.minorVersion = "0"; + this.releaseDate = "2005-12-01"; + + this.instances = new Array(); + this.stickyClassesLookup = new Array(); + this.windowArgs = new Array(); + this.loadedFiles = new Array(); + this.configs = new Array(); + this.currentConfig = 0; + this.eventHandlers = new Array(); + + // Browser check + var ua = navigator.userAgent; + this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); + this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1); + this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1); + this.isGecko = ua.indexOf('Gecko') != -1; + this.isSafari = ua.indexOf('Safari') != -1; + this.isOpera = ua.indexOf('Opera') != -1; + this.isMac = ua.indexOf('Mac') != -1; + this.isNS7 = ua.indexOf('Netscape/7') != -1; + this.isNS71 = ua.indexOf('Netscape/7.1') != -1; + this.dialogCounter = 0; + + // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those + if (this.isOpera) { + this.isMSIE = true; + this.isGecko = false; + this.isSafari = false; + } + + // TinyMCE editor id instance counter + this.idCounter = 0; +}; + +TinyMCE.prototype.defParam = function(key, def_val) { + this.settings[key] = tinyMCE.getParam(key, def_val); +}; + +TinyMCE.prototype.init = function(settings) { + var theme; + + this.settings = settings; + + // Check if valid browser has execcommand support + if (typeof(document.execCommand) == 'undefined') + return; + + // Get script base path + if (!tinyMCE.baseURL) { + var elements = document.getElementsByTagName('script'); + + for (var i=0; i'); + this.defParam("font_size_classes", ''); + this.defParam("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large'); + this.defParam("event_elements", 'a,img'); + this.defParam("convert_urls", true); + this.defParam("table_inline_editing", false); + this.defParam("object_resizing", true); + + // Browser check IE + if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1) + return; + + // Browser check Gecko + if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1) + return; + + // Browser check Safari + if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1) + return; + + // Browser check Opera + if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1) + return; + + // If not super absolute make it so + var baseHREF = tinyMCE.settings['document_base_url']; + var h = document.location.href; + var p = h.indexOf('://'); + if (p > 0 && document.location.protocol != "file:") { + p = h.indexOf('/', p + 3); + h = h.substring(0, p); + + if (baseHREF.indexOf('://') == -1) + baseHREF = h + baseHREF; + + tinyMCE.settings['document_base_url'] = baseHREF; + tinyMCE.settings['document_base_prefix'] = h; + } + + // Trim away query part + if (baseHREF.indexOf('?') != -1) + baseHREF = baseHREF.substring(0, baseHREF.indexOf('?')); + + this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/"; + + theme = this.settings['theme']; + this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dir|fieldset|form|noscript|noframes|menu|isindex)$", "i"); + this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40); + this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL + this.uniqueTag = ''; + + // Theme url + this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme; + + if (!tinyMCE.isMSIE) + this.settings['force_br_newlines'] = false; + + if (tinyMCE.getParam("content_css", false)) { + var cssPath = tinyMCE.getParam("content_css", ""); + + // Is relative + if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') + this.settings['content_css'] = this.documentBasePath + "/" + cssPath; + else + this.settings['content_css'] = cssPath; + } else + this.settings['content_css'] = ''; + + if (tinyMCE.getParam("popups_css", false)) { + var cssPath = tinyMCE.getParam("popups_css", ""); + + // Is relative + if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') + this.settings['popups_css'] = this.documentBasePath + "/" + cssPath; + else + this.settings['popups_css'] = cssPath; + } else + this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css"; + + if (tinyMCE.getParam("editor_css", false)) { + var cssPath = tinyMCE.getParam("editor_css", ""); + + // Is relative + if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') + this.settings['editor_css'] = this.documentBasePath + "/" + cssPath; + else + this.settings['editor_css'] = cssPath; + } else + this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css"; + + if (tinyMCE.settings['debug']) { + var msg = "Debug: \n"; + + msg += "baseURL: " + this.baseURL + "\n"; + msg += "documentBasePath: " + this.documentBasePath + "\n"; + msg += "content_css: " + this.settings['content_css'] + "\n"; + msg += "popups_css: " + this.settings['popups_css'] + "\n"; + msg += "editor_css: " + this.settings['editor_css'] + "\n"; + + alert(msg); + } + + // Init HTML cleanup + this._initCleanup(); + + // Only do this once + if (this.configs.length == 0) { + // Is Safari enabled + if (this.isSafari && this.getParam('safari_warning', true)) + alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false"); + + tinyMCE.addEvent(window, "load", TinyMCE.prototype.onLoad); + + if (tinyMCE.isMSIE) { + if (tinyMCE.settings['add_unload_trigger']) { + tinyMCE.addEvent(window, "unload", TinyMCE.prototype.unloadHandler); + tinyMCE.addEvent(window.document, "beforeunload", TinyMCE.prototype.unloadHandler); + } + } else { + if (tinyMCE.settings['add_unload_trigger']) + tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);}); + } + } + + this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js'); + this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] + '.js'); + this.loadCSS(this.settings['editor_css']); + + // Add plugins + var themePlugins = tinyMCE.getParam('plugins', '', true, ','); + if (this.settings['plugins'] != '') { + for (var i=0; i'); + + this.loadedFiles[this.loadedFiles.length] = url; +}; + +TinyMCE.prototype.loadCSS = function(url) { + for (var i=0; i'); + + this.loadedFiles[this.loadedFiles.length] = url; +}; + +TinyMCE.prototype.importCSS = function(doc, css_file) { + if (css_file == '') + return; + + if (typeof(doc.createStyleSheet) == "undefined") { + var elm = doc.createElement("link"); + + elm.rel = "stylesheet"; + elm.href = css_file; + + if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0) + headArr[0].appendChild(elm); + } else + var styleSheet = doc.createStyleSheet(css_file); +}; + +TinyMCE.prototype.confirmAdd = function(e, settings) { + var elm = tinyMCE.isMSIE ? event.srcElement : e.target; + var elementId = elm.name ? elm.name : elm.id; + + tinyMCE.settings = settings; + + if (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm'])) + tinyMCE.addMCEControl(elm, elementId); + + elm.setAttribute('mce_noask', 'true'); +}; + +TinyMCE.prototype.updateContent = function(form_element_name) { + // Find MCE instance linked to given form element and copy it's value + var formElement = document.getElementById(form_element_name); + for (var n in tinyMCE.instances) { + var inst = tinyMCE.instances[n]; + if (!tinyMCE.isInstance(inst)) + continue; + + inst.switchSettings(); + + if (inst.formElement == formElement) { + var doc = inst.getDoc(); + + tinyMCE._setHTML(doc, inst.formElement.value); + + if (!tinyMCE.isMSIE) + doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid); + } + } +}; + +TinyMCE.prototype.addMCEControl = function(replace_element, form_element_name, target_document) { + var id = "mce_editor_" + tinyMCE.idCounter++; + var inst = new TinyMCEControl(tinyMCE.settings); + + inst.editorId = id; + this.instances[id] = inst; + + inst.onAdd(replace_element, form_element_name, target_document); +}; + +TinyMCE.prototype.triggerSave = function(skip_cleanup, skip_callback) { + // Cleanup and set all form fields + for (var n in tinyMCE.instances) { + var inst = tinyMCE.instances[n]; + if (!tinyMCE.isInstance(inst)) + continue; + + inst.switchSettings(); + + tinyMCE.settings['preformatted'] = false; + + // Default to false + if (typeof(skip_cleanup) == "undefined") + skip_cleanup = false; + + // Default to false + if (typeof(skip_callback) == "undefined") + skip_callback = false; + + tinyMCE._setHTML(inst.getDoc(), inst.getBody().innerHTML); + + // Remove visual aids when cleanup is disabled + if (inst.settings['cleanup'] == false) { + tinyMCE.handleVisualAid(inst.getBody(), true, false, inst); + tinyMCE._setEventsEnabled(inst.getBody(), true); + } + + tinyMCE._customCleanup(inst, "submit_content_dom", inst.contentWindow.document.body); + var htm = skip_cleanup ? inst.getBody().innerHTML : tinyMCE._cleanupHTML(inst, inst.getDoc(), this.settings, inst.getBody(), this.visualAid, true); + htm = tinyMCE._customCleanup(inst, "submit_content", htm); + + if (tinyMCE.settings["encoding"] == "xml" || tinyMCE.settings["encoding"] == "html") + htm = tinyMCE.convertStringToXML(htm); + + if (!skip_callback && tinyMCE.settings['save_callback'] != "") + var content = eval(tinyMCE.settings['save_callback'] + "(inst.formTargetElementId,htm,inst.getBody());"); + + // Use callback content if available + if ((typeof(content) != "undefined") && content != null) + htm = content; + + // Replace some weird entities (Bug: #1056343) + htm = tinyMCE.regexpReplace(htm, "(", "(", "gi"); + htm = tinyMCE.regexpReplace(htm, ")", ")", "gi"); + htm = tinyMCE.regexpReplace(htm, ";", ";", "gi"); + htm = tinyMCE.regexpReplace(htm, """, """, "gi"); + htm = tinyMCE.regexpReplace(htm, "^", "^", "gi"); + + if (inst.formElement) + inst.formElement.value = htm; + } +}; + +TinyMCE.prototype._setEventsEnabled = function(node, state) { + var events = new Array('onfocus','onblur','onclick','ondblclick', + 'onmousedown','onmouseup','onmouseover','onmousemove', + 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup'); + + var evs = tinyMCE.settings['event_elements'].split(','); + for (var y=0; y", "gi"); + content = tinyMCE.regexpReplace(content, "\r", "
    ", "gi"); + content = tinyMCE.regexpReplace(content, "\n", "
    ", "gi"); + } + + // Open closed anchors +// content = content.replace(new RegExp('', 'gi'), ''); + + // Call custom cleanup code + content = tinyMCE.storeAwayURLs(content); + content = tinyMCE._customCleanup(inst, "insert_to_editor", content); + + if (tinyMCE.isMSIE) { + // Ugly!!! + window.setInterval('try{tinyMCE.getCSSClasses(document.frames["' + editor_id + '"].document, "' + editor_id + '");}catch(e){}', 500); + + if (tinyMCE.settings["force_br_newlines"]) + document.frames[editor_id].document.styleSheets[0].addRule("p", "margin: 0px;"); + + var body = document.frames[editor_id].document.body; + + tinyMCE.addEvent(body, "beforepaste", TinyMCE.prototype.eventPatch); + tinyMCE.addEvent(body, "beforecut", TinyMCE.prototype.eventPatch); + + body.editorId = editor_id; + } + + content = tinyMCE.cleanupHTMLCode(content); + + // Fix for bug #958637 + if (!tinyMCE.isMSIE) { + var contentElement = inst.getDoc().createElement("body"); + var doc = inst.getDoc(); + + contentElement.innerHTML = content; + + // Remove weridness! + if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) + content = content.replace(new RegExp('<>', 'g'), ""); + + if (tinyMCE.settings['cleanup_on_startup']) + tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement)); + else { + // Convert all strong/em to b/i + content = tinyMCE.regexpReplace(content, "", "", "gi"); + content = tinyMCE.regexpReplace(content, "", "", "gi"); + content = tinyMCE.regexpReplace(content, "", "", "gi"); + tinyMCE.setInnerHTML(inst.getBody(), content); + } + + inst.convertAllRelativeURLs(); + } else { + if (tinyMCE.settings['cleanup_on_startup']) { + tinyMCE._setHTML(inst.getDoc(), content); + + // Produces permission denied error in MSIE 5.5 + eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));} catch(e) {}'); + } else + tinyMCE._setHTML(inst.getDoc(), content); + } + + // Fix for bug #957681 + //inst.getDoc().designMode = inst.getDoc().designMode; + + // Setup element references + var parentElm = document.getElementById(inst.editorId + '_parent'); + if (parentElm.lastChild.nodeName == "INPUT") + inst.formElement = tinyMCE.isGecko ? parentElm.firstChild : parentElm.lastChild; + else + inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling; + + tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst); + tinyMCE.executeCallback('setupcontent_callback', '_setupContent', 0, editor_id, inst.getBody(), inst.getDoc()); + + // Re-add design mode on mozilla + if (!tinyMCE.isMSIE) + TinyMCE.prototype.addEventHandlers(editor_id); + + // Add blur handler + if (tinyMCE.isMSIE) + tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE.prototype.eventPatch); + + // Trigger node change, this call locks buttons for tables and so forth + tinyMCE.selectedInstance = inst; + tinyMCE.selectedElement = inst.contentWindow.document.body; + + if (!inst.isHidden()) + tinyMCE.triggerNodeChange(false, true); + + // Call custom DOM cleanup + tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody()); + tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody()); + tinyMCE._setEventsEnabled(inst.getBody(), false); + tinyMCE.cleanupAnchors(inst.getDoc()); + + if (tinyMCE.getParam("convert_fonts_to_spans")) + tinyMCE.convertSpansToFonts(inst.getDoc()); + + inst.startContent = tinyMCE.trim(inst.getBody().innerHTML); + inst.undoLevels[inst.undoLevels.length] = inst.startContent; + + tinyMCE.operaOpacityCounter = -1; +}; + +TinyMCE.prototype.cleanupHTMLCode = function(s) { + s = s.replace(/

    /gi, '

     

    '); + s = s.replace(/

    \s*<\/p>/gi, '

     

    '); + + // Open closed tags like to +// tinyMCE.debug("f:" + s); + s = s.replace(/<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\|>]*?)\/>/gi, '<$1$2$3>'); +// tinyMCE.debug("e:" + s); + + // Remove trailing space to + s = s.replace(new RegExp('\\s+> to + s = s.replace(/<(img|br|hr)(.*?)><\/(img|br|hr)>/gi, '<$1$2 />'); + + // Weird MSIE bug,


    breaks runtime? + if (tinyMCE.isMSIE) + s = s.replace(/


    <\/p>/gi, "
    "); + + // Convert relative anchors to absolute URLs ex: #something to file.htm#something + s = s.replace(new RegExp('(href=\"?)(\\s*?#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#"); + + return s; +}; + +TinyMCE.prototype.storeAwayURLs = function(s) { + // Remove all mce_src, mce_href and replace them with new ones + s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); + s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); + s = s.replace(new RegExp('src\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'src="$1" mce_src="$1"'); + s = s.replace(new RegExp('href\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'href="$1" mce_href="$1"'); + + return s; +}; + +TinyMCE.prototype.cancelEvent = function(e) { + if (tinyMCE.isMSIE) { + e.returnValue = false; + e.cancelBubble = true; + } else + e.preventDefault(); +}; + +TinyMCE.prototype.removeTinyMCEFormElements = function(form_obj) { + // Check if form is valid + if (typeof(form_obj) == "undefined" || form_obj == null) + return; + + // If not a form, find the form + if (form_obj.nodeName != "FORM") { + if (form_obj.form) + form_obj = form_obj.form; + else + form_obj = tinyMCE.getParentElement(form_obj, "form"); + } + + // Still nothing + if (form_obj == null) + return; + + // Disable all UI form elements that TinyMCE created + for (var i=0; i'); + } + } + + // Return key pressed + if (tinyMCE.isMSIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) { + if (e.target.editorId) + tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId]; + + if (tinyMCE.selectedInstance) { + var sel = tinyMCE.selectedInstance.getDoc().selection; + var rng = sel.createRange(); + + if (tinyMCE.getParentElement(rng.parentElement(), "li") != null) + return false; + + // Cancel event + e.returnValue = false; + e.cancelBubble = true; + + // Insert BR element + rng.pasteHTML("
    "); + rng.collapse(false); + rng.select(); + + tinyMCE.execCommand("mceAddUndoLevel"); + tinyMCE.triggerNodeChange(false); + return false; + } + } + + // Backspace or delete + if (e.keyCode == 8 || e.keyCode == 46) { + tinyMCE.selectedElement = e.target; + tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a"); + tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img"); + tinyMCE.triggerNodeChange(false); + } + + return false; + break; + + case "keyup": + case "keydown": + if (e.target.editorId) + tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId]; + else + return; + + if (tinyMCE.selectedInstance) + tinyMCE.selectedInstance.switchSettings(); + + var inst = tinyMCE.selectedInstance; + + // Handle backspace + if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) { + // Insert P element instead of BR + if (tinyMCE.selectedInstance._handleBackSpace(e.type)) { + // Cancel event + tinyMCE.execCommand("mceAddUndoLevel"); + e.preventDefault(); + return false; + } + } + + tinyMCE.selectedElement = null; + tinyMCE.selectedNode = null; + var elm = tinyMCE.selectedInstance.getFocusElement(); + tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a"); + tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img"); + tinyMCE.selectedElement = elm; + + // Update visualaids on tabs + if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9) + tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings['visual'], tinyMCE.selectedInstance); + + // Fix empty elements on return/enter, check where enter occured + if (tinyMCE.isMSIE && e.type == "keydown" && e.keyCode == 13) + tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement(); + + // Fix empty elements on return/enter + if (tinyMCE.isMSIE && e.type == "keyup" && e.keyCode == 13) { + var elm = tinyMCE.enterKeyElement; + if (elm) { + var re = new RegExp('^HR|IMG|BR$','g'); // Skip these + var dre = new RegExp('^H[1-6]$','g'); // Add double on these + + if (!elm.hasChildNodes() && !re.test(elm.nodeName)) { + if (dre.test(elm.nodeName)) + elm.innerHTML = "  "; + else + elm.innerHTML = " "; + } + } + } + + // Check if it's a position key + var keys = tinyMCE.posKeyCodes; + var posKey = false; + for (var i=0; i -1) + suffix = '?rnd=' + this.operaOpacityCounter++; + + element.src = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/images/opacity.png" + suffix; + element.style.backgroundImage = "url('" + element.mceOldSrc + "')"; + } else { + if (element.mceOldSrc) { + element.src = element.mceOldSrc; + element.parentNode.style.backgroundImage = ""; + element.mceOldSrc = null; + } + } + } + } +}; + +TinyMCE.prototype.restoreClass = function(element) { + if (element != null && element.oldClassName && !element.classLock) { + element.className = element.oldClassName; + element.oldClassName = null; + } +}; + +TinyMCE.prototype.setClassLock = function(element, lock_state) { + if (element != null) + element.classLock = lock_state; +}; + +TinyMCE.prototype.addEvent = function(obj, name, handler) { + if (tinyMCE.isMSIE) { + obj.attachEvent("on" + name, handler); + } else + obj.addEventListener(name, handler, false); +}; + +TinyMCE.prototype.submitPatch = function() { + tinyMCE.removeTinyMCEFormElements(this); + tinyMCE.triggerSave(); + this.mceOldSubmit(); + tinyMCE.isNotDirty = true; +}; + +TinyMCE.prototype.onLoad = function() { + for (var c=0; c 0) + return; + + if (val.indexOf('%') == -1) + val += 'px'; + break; + + case "vspace": + case "hspace": + elm.style.marginTop = val + "px"; + elm.style.marginBottom = val + "px"; + elm.removeAttribute(attrib); + return; + + case "align": + if (elm.nodeName == "IMG") { + if (tinyMCE.isMSIE) + elm.style.styleFloat = val; + else + elm.style.cssFloat = val; + } else + elm.style.textAlign = val; + + elm.removeAttribute(attrib); + return; + } + + if (val != '') { + eval('elm.style.' + style + ' = val;'); + elm.removeAttribute(attrib); + } + } + } else { + if (style == '') + return; + + var val = eval('elm.style.' + style) == '' ? tinyMCE.getAttrib(elm, attrib) : eval('elm.style.' + style); + val = val == null ? '' : '' + val; + + switch (attrib) { + // Always move background to style + case "background": + if (val.indexOf('url') == -1 && val != '') + val = "url('" + val + "');"; + + if (val != '') { + elm.style.backgroundImage = val; + elm.removeAttribute(attrib); + } + return; + + case "border": + case "width": + case "height": + val = val.replace('px', ''); + break; + + case "align": + if (tinyMCE.getAttrib(elm, 'align') == '') { + if (elm.nodeName == "IMG") { + if (tinyMCE.isMSIE && elm.style.styleFloat != '') { + val = elm.style.styleFloat; + style = 'styleFloat'; + } else if (tinyMCE.isGecko && elm.style.cssFloat != '') { + val = elm.style.cssFloat; + style = 'cssFloat'; + } + } + } + break; + } + + if (val != '') { + elm.removeAttribute(attrib); + elm.setAttribute(attrib, val); + eval('elm.style.' + style + ' = "";'); + } + } +}; + +TinyMCE.prototype._cleanupAttribute = function(valid_attributes, element_name, attribute_node, element_node) { + var attribName = attribute_node.nodeName.toLowerCase(); + var attribValue = attribute_node.nodeValue; + var attribMustBeValue = null; + var verified = false; + + // Mozilla attibute, remove them + if (attribName.indexOf('moz_') != -1) + return null; + + if (!tinyMCE.cleanup_on_save && (attribName == "mce_href" || attribName == "mce_src")) + return {name : attribName, value : attribValue}; + + // Verify attrib + if (tinyMCE.cleanup_verify_html && !verified) { + for (var i=1; i 1) + val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')"; + } + + // Force HEX colors + if (tinyMCE.getParam("force_hex_style_colors")) + val = tinyMCE.convertRGBToHex(val, true); + + if (val != "url('')") + str += key.toLowerCase() + ": " + val + "; "; + } + } + + if (new RegExp('; $').test(str)) + str = str.substring(0, str.length - 2); + + return str; +}; + +TinyMCE.prototype.convertRGBToHex = function(s, k) { + if (s.toLowerCase().indexOf('rgb') != -1) { + var re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi"); + var rgb = s.replace(re, "$1,$2,$3,$4,$5").split(','); + if (rgb.length == 5) { + r = parseInt(rgb[1]).toString(16); + g = parseInt(rgb[2]).toString(16); + b = parseInt(rgb[3]).toString(16); + + r = r.length == 1 ? '0' + r : r; + g = g.length == 1 ? '0' + g : g; + b = b.length == 1 ? '0' + b : b; + + s = "#" + r + g + b; + + if (k) + s = rgb[0] + s + rgb[4]; + } + } + + return s; +}; + +TinyMCE.prototype.convertHexToRGB = function(s) { + if (s.indexOf('#') != -1) { + s = s.replace(new RegExp('[^0-9A-F]', 'gi'), ''); + return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")"; + } + + return s; +}; + +TinyMCE.prototype._verifyClass = function(node) { + // Sometimes the class gets set to null, weird Gecko bug? + if (tinyMCE.isGecko) { + var className = node.getAttribute('class'); + if (!className) + return false; + } + + // Trim CSS class + if (tinyMCE.isMSIE) + var className = node.getAttribute('className'); + + if (tinyMCE.cleanup_verify_css_classes && tinyMCE.cleanup_on_save) { + var csses = tinyMCE.getCSSClasses(); + nonDefinedCSS = true; + for (var c=0; c' + output; + } + } + + // Remove deprecated attributes + var re = new RegExp("^(TABLE|TD|TR)$"); + if (re.test(node.nodeName)) { + // Move attrib to style + if ((node.nodeName != "TABLE" || tinyMCE.cleanup_inline_styles) && (width = tinyMCE.getAttrib(node, "width")) != '') { + node.style.width = width.indexOf('%') != -1 ? width : width.replace(/[^0-9]/gi, '') + "px"; + node.removeAttribute("width"); + } + + // Is table and not inline + if ((node.nodeName == "TABLE" && !tinyMCE.cleanup_inline_styles) && node.style.width != '') { + tinyMCE.setAttrib(node, "width", node.style.width.replace('px','')); + node.style.width = ''; + } + + // Move attrib to style + if ((height = tinyMCE.getAttrib(node, "height")) != '') { + height = "" + height; // Force string + node.style.height = height.indexOf('%') != -1 ? height : height.replace(/[^0-9]/gi, '') + "px"; + node.removeAttribute("height"); + } + } + + // Handle inline/outline styles + if (tinyMCE.cleanup_inline_styles) { + var re = new RegExp("^(TABLE|TD|TR|IMG|HR)$"); + if (re.test(node.nodeName) && tinyMCE.getAttrib(node, "class").indexOf('mceItem') == -1) { + tinyMCE._moveStyle(node, 'width', 'width'); + tinyMCE._moveStyle(node, 'height', 'height'); + tinyMCE._moveStyle(node, 'borderWidth', 'border'); + tinyMCE._moveStyle(node, '', 'vspace'); + tinyMCE._moveStyle(node, '', 'hspace'); + tinyMCE._moveStyle(node, 'textAlign', 'align'); + tinyMCE._moveStyle(node, 'backgroundColor', 'bgColor'); + tinyMCE._moveStyle(node, 'borderColor', 'borderColor'); + tinyMCE._moveStyle(node, 'backgroundImage', 'background'); + + // Refresh element in old MSIE + if (tinyMCE.isMSIE5) + node.outerHTML = node.outerHTML; + } else if (tinyMCE.isBlockElement(node)) + tinyMCE._moveStyle(node, 'textAlign', 'align'); + + if (node.nodeName == "FONT") + tinyMCE._moveStyle(node, 'color', 'color'); + } + + // Set attrib data + if (elementValidAttribs) { + for (var a=1; a" + node.innerHTML + ""; + + // Remove empty tables + if (elementName == "table" && !node.hasChildNodes()) + return ""; + + // Handle element attributes + if (node.attributes.length > 0) { + var lastAttrib = ""; + + for (var i=0; i" + this.convertStringToXML(String.fromCharCode(160)) + ""; + + // Is MSIE script element + if (tinyMCE.isMSIE && elementName == "script") + return "<" + elementName + elementAttribs + ">" + node.text + ""; + + // Clean up children + if (node.hasChildNodes()) { + // If not empty span + if (!(elementName == "span" && elementAttribs == "" && tinyMCE.getParam("trim_span_elements"))) { + // Force BR + if (elementName == "p" && tinyMCE.cleanup_force_br_newlines) + output += ""; + else + output += "<" + elementName + elementAttribs + ">"; + } + + for (var i=0; i"; + } + } else { + if (!nonEmptyTag) { + if (openTag) + output += "<" + elementName + elementAttribs + ">"; + else + output += "<" + elementName + elementAttribs + " />"; + } + } + + return output; + + case 3: // Text + // Do not convert script elements + if (node.parentNode.nodeName == "SCRIPT" || node.parentNode.nodeName == "NOSCRIPT" || node.parentNode.nodeName == "STYLE") + return node.nodeValue; + + return this.convertStringToXML(node.nodeValue); + + case 8: // Comment + return ""; + + default: // Unknown + return "[UNKNOWN NODETYPE " + node.nodeType + "]"; + } +}; + +TinyMCE.prototype.convertStringToXML = function(html_data) { + var output = ""; + + for (var i=0; i 127) + output += '&#' + chr + ";"; + else + output += String.fromCharCode(chr); + + continue; + } + + // Raw entities + if (tinyMCE.settings['entity_encoding'] == "raw") { + output += String.fromCharCode(chr); + continue; + } + + // Named entities + if (typeof(tinyMCE.settings['cleanup_entities']["c" + chr]) != 'undefined' && tinyMCE.settings['cleanup_entities']["c" + chr] != '') + output += '&' + tinyMCE.settings['cleanup_entities']["c" + chr] + ';'; + else + output += '' + String.fromCharCode(chr); + } + + return output; +}; + +TinyMCE.prototype._getCleanupElementName = function(chunk) { + var pos; + + if (chunk.charAt(0) == '+') + chunk = chunk.substring(1); + + if (chunk.charAt(0) == '-') + chunk = chunk.substring(1); + + if ((pos = chunk.indexOf('/')) != -1) + chunk = chunk.substring(0, pos); + + if ((pos = chunk.indexOf('[')) != -1) + chunk = chunk.substring(0, pos); + + return chunk; +}; + +TinyMCE.prototype._initCleanup = function() { + // Parse valid elements and attributes + var validElements = tinyMCE.settings["valid_elements"]; + validElements = validElements.split(','); + + // Handle extended valid elements + var extendedValidElements = tinyMCE.settings["extended_valid_elements"]; + extendedValidElements = extendedValidElements.split(','); + for (var i=0; i/gi, '>'); + + return html; + } + + if (on_save && tinyMCE.getParam("convert_fonts_to_spans")) + tinyMCE.convertFontsToSpans(doc); + + // Call custom cleanup code + tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body); + + // Move bgcolor to style + var n = doc.getElementsByTagName("font"); + for (var i=0; i[ \n\r]*[ \n\r]*

    ', '
    ', 'gi')); + tinyMCE.setInnerHTML(element, tinyMCE.regexpReplace(element.innerHTML, '', '', 'gi')); + } + + var html = this.cleanupNode(element); + + if (tinyMCE.settings['debug']) + tinyMCE.debug("Cleanup process executed in: " + (new Date().getTime()-startTime) + " ms."); + + // Remove pesky HR paragraphs and other crap + html = tinyMCE.regexpReplace(html, '


    ', '
    '); + html = tinyMCE.regexpReplace(html, '

     


     

    ', '
    '); + html = tinyMCE.regexpReplace(html, '\\s*
    \\s*', ' '); + html = tinyMCE.regexpReplace(html, '

    \\s*
    \\s*

    ', '

     

    '); + html = tinyMCE.regexpReplace(html, '

    \\s* \\s*
    \\s* \\s*

    ', '

     

    '); + html = tinyMCE.regexpReplace(html, '

    \\s* \\s*
    \\s*

    ', '

     

    '); + html = tinyMCE.regexpReplace(html, '

    \\s*
    \\s* \\s*

    ', '

     

    '); + + // Remove empty anchors + html = html.replace(new RegExp('(.*?)', 'gi'), '$1'); + + // Remove some mozilla crap + if (!tinyMCE.isMSIE) + html = html.replace(new RegExp('', 'g'), ""); + + if (tinyMCE.settings['remove_linebreaks']) + html = html.replace(new RegExp('\r|\n', 'g'), ' '); + + if (tinyMCE.getParam('apply_source_formatting')) { + html = html.replace(new RegExp('<(p|div)([^>]*)>', 'g'), "\n<$1$2>\n"); + html = html.replace(new RegExp('<\/(p|div)([^>]*)>', 'g'), "\n\n"); + html = html.replace(new RegExp('
    ', 'g'), "
    \n"); + } + + if (tinyMCE.settings['force_br_newlines']) { + var re = new RegExp('

     

    ', 'g'); + html = html.replace(re, "
    "); + } + + if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) { + // Remove weridness! + var re = new RegExp('<>', 'g'); + html = html.replace(re, ""); + } + + // Call custom cleanup code + html = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", html); + + // Emtpy node, return empty + var chk = tinyMCE.regexpReplace(html, "[ \t\r\n]", "").toLowerCase(); + if (chk == "
    " || chk == "
    " || chk == "

     

    " || chk == "

     

    " || chk == "

    ") + html = ""; + + if (tinyMCE.settings["preformatted"]) + return "
    " + html + "
    "; + + return html; +}; + +TinyMCE.prototype.insertLink = function(href, target, title, onclick, style_class) { + tinyMCE.execCommand('mceBeginUndoLevel'); + + if (this.selectedInstance && this.selectedElement && this.selectedElement.nodeName.toLowerCase() == "img") { + var doc = this.selectedInstance.getDoc(); + var linkElement = tinyMCE.getParentElement(this.selectedElement, "a"); + var newLink = false; + + if (!linkElement) { + linkElement = doc.createElement("a"); + newLink = true; + } + + var mhref = href; + var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);"); + mhref = tinyMCE.getParam('convert_urls') ? href : mhref; + + tinyMCE.setAttrib(linkElement, 'href', thref); + tinyMCE.setAttrib(linkElement, 'mce_href', mhref); + tinyMCE.setAttrib(linkElement, 'target', target); + tinyMCE.setAttrib(linkElement, 'title', title); + tinyMCE.setAttrib(linkElement, 'onclick', onclick); + tinyMCE.setAttrib(linkElement, 'class', style_class); + + if (newLink) { + linkElement.appendChild(this.selectedElement.cloneNode(true)); + this.selectedElement.parentNode.replaceChild(linkElement, this.selectedElement); + } + + return; + } + + if (!this.linkElement && this.selectedInstance) { + if (tinyMCE.isSafari) { + tinyMCE.execCommand("mceInsertContent", false, '' + this.selectedInstance.getSelectedHTML() + ''); + } else + this.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL); + + tinyMCE.linkElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); + + var elementArray = this.getElementsByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); + + for (var i=0; i'; + + tinyMCE.execCommand("mceInsertContent", false, html); + } else { + if (!this.imgElement && this.selectedInstance) { + if (tinyMCE.isSafari) + tinyMCE.execCommand("mceInsertContent", false, ''); + else + this.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL); + + tinyMCE.imgElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL); + } + } + + if (this.imgElement) { + var needsRepaint = false; + var msrc = src; + + src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);"); + + if (tinyMCE.getParam('convert_urls')) + msrc = src; + + if (onmouseover && onmouseover != "") + onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';"; + + if (onmouseout && onmouseout != "") + onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';"; + + // Use alt as title if it's undefined + if (typeof(title) == "undefined") + title = alt; + + if (width != this.imgElement.getAttribute("width") || height != this.imgElement.getAttribute("height") || align != this.imgElement.getAttribute("align")) + needsRepaint = true; + + tinyMCE.setAttrib(this.imgElement, 'src', src); + tinyMCE.setAttrib(this.imgElement, 'mce_src', msrc); + tinyMCE.setAttrib(this.imgElement, 'alt', alt); + tinyMCE.setAttrib(this.imgElement, 'title', title); + tinyMCE.setAttrib(this.imgElement, 'align', align); + tinyMCE.setAttrib(this.imgElement, 'border', border, true); + tinyMCE.setAttrib(this.imgElement, 'hspace', hspace, true); + tinyMCE.setAttrib(this.imgElement, 'vspace', vspace, true); + tinyMCE.setAttrib(this.imgElement, 'width', width, true); + tinyMCE.setAttrib(this.imgElement, 'height', height, true); + tinyMCE.setAttrib(this.imgElement, 'onmouseover', onmouseover); + tinyMCE.setAttrib(this.imgElement, 'onmouseout', onmouseout); + + // Fix for bug #989846 - Image resize bug + if (width && width != "") + this.imgElement.style.pixelWidth = width; + + if (height && height != "") + this.imgElement.style.pixelHeight = height; + + if (needsRepaint) + tinyMCE.selectedInstance.repaint(); + } + + tinyMCE.execCommand('mceEndUndoLevel'); +}; + +TinyMCE.prototype.getElementByAttributeValue = function(node, element_name, attrib, value) { + var elements = this.getElementsByAttributeValue(node, element_name, attrib, value); + if (elements.length == 0) + return null; + + return elements[0]; +}; + +TinyMCE.prototype.getElementsByAttributeValue = function(node, element_name, attrib, value) { + var elements = new Array(); + + if (node && node.nodeName.toLowerCase() == element_name) { + if (node.getAttribute(attrib) && node.getAttribute(attrib).indexOf(value) != -1) + elements[elements.length] = node; + } + + if (node && node.hasChildNodes()) { + for (var x=0, n=node.childNodes.length; x= strTok2.length) { + for (var i=0; i= strTok2.length || strTok1[i] != strTok2[i]) { + breakPoint = i + 1; + break; + } + } + } + + if (strTok1.length < strTok2.length) { + for (var i=0; i= strTok1.length || strTok1[i] != strTok2[i]) { + breakPoint = i + 1; + break; + } + } + } + + if (breakPoint == 1) + return targetURL.path; + + for (var i=0; i<(strTok1.length-(breakPoint-1)); i++) + outPath += "../"; + + for (var i=breakPoint-1; i=0; i--) { + if (baseURLParts[i].length == 0) + continue; + + newBaseURLParts[newBaseURLParts.length] = baseURLParts[i]; + } + baseURLParts = newBaseURLParts.reverse(); + + // Merge relURLParts chunks + var newRelURLParts = new Array(); + var numBack = 0; + for (var i=relURLParts.length-1; i>=0; i--) { + if (relURLParts[i].length == 0 || relURLParts[i] == ".") + continue; + + if (relURLParts[i] == '..') { + numBack++; + continue; + } + + if (numBack > 0) { + numBack--; + continue; + } + + newRelURLParts[newRelURLParts.length] = relURLParts[i]; + } + + relURLParts = newRelURLParts.reverse(); + + // Remove end from absolute path + var len = baseURLParts.length-numBack; + var absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/'); + var start = "", end = ""; + + // Build output URL + relURL.protocol = baseURL.protocol; + relURL.host = baseURL.host; + relURL.port = baseURL.port; + + // Re-add trailing slash if it's removed + if (relURL.path.charAt(relURL.path.length-1) == "/") + absPath += "/"; + + relURL.path = absPath; + + return TinyMCE.prototype.serializeURL(relURL); +}; + +TinyMCE.prototype.getParam = function(name, default_value, strip_whitespace, split_chr) { + var value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name]; + + // Fix bool values + if (value == "true" || value == "false") + return (value == "true"); + + if (strip_whitespace) + value = tinyMCE.regexpReplace(value, "[ \t\r\n]", ""); + + if (typeof(split_chr) != "undefined" && split_chr != null) { + value = value.split(split_chr); + var outArray = new Array(); + + for (var i=0; i 0); + + if (tinyMCE.settings['custom_undo_redo']) { + undoIndex = inst.undoIndex; + undoLevels = inst.undoLevels.length; + } + + tinyMCE.executeCallback('handleNodeChangeCallback', '_handleNodeChange', 0, editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content); + } + } + + if (this.selectedInstance && (typeof(focus) == "undefined" || focus)) + this.selectedInstance.contentWindow.focus(); +}; + +TinyMCE.prototype._customCleanup = function(inst, type, content) { + // Call custom cleanup + var customCleanup = tinyMCE.settings['cleanup_callback']; + if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined") + content = eval(customCleanup + "(type, content, inst);"); + + // Trigger plugin cleanups + var plugins = tinyMCE.getParam('plugins', '', true, ','); + for (var i=0; i 0) + className += " "; + + className += classNames[i]; + } + + return className; +}; + +TinyMCE.prototype.handleVisualAid = function(el, deep, state, inst) { + if (!el) + return; + + var tableElement = null; + + switch (el.nodeName) { + case "TABLE": + var oldW = el.style.width; + var oldH = el.style.height; + var bo = tinyMCE.getAttrib(el, "border"); + + bo = bo == "" || bo == "0" ? true : false; + + tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo)); + + el.style.width = oldW; + el.style.height = oldH; + + for (var y=0; y 0) { + tinyMCE.setAttrib(s[i], 'size', fSize); + s[i].style.fontSize = ''; + } + + var fFace = s[i].style.fontFamily; + if (fFace != null && fFace != "") { + tinyMCE.setAttrib(s[i], 'face', fFace); + s[i].style.fontFamily = ''; + } + + var fColor = s[i].style.color; + if (fColor != null && fColor != "") { + tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor)); + s[i].style.color = ''; + } + } +}; + +TinyMCE.prototype.convertFontsToSpans = function(doc) { + var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); + + var h = doc.body.innerHTML; + h = h.replace(/ 0 && fSize < 8) { + if (fsClasses != null) + tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]); + else + s[i].style.fontSize = sizes[fSize-1]; + } + + s[i].removeAttribute('size'); + } + + if (fFace != "") { + s[i].style.fontFamily = fFace; + s[i].removeAttribute('face'); + } + + if (fColor != "") { + s[i].style.color = fColor; + s[i].removeAttribute('color'); + } + } +}; + +/* +TinyMCE.prototype.applyClassesToFonts = function(doc, size) { + var f = doc.getElementsByTagName("font"); + for (var i=0; i=0; x--) + tinyMCE.insertAfter(cn[x], an[i]); + } + } +}; + +TinyMCE.prototype._setHTML = function(doc, html_content) { + // Force closed anchors open + //html_content = html_content.replace(new RegExp('', 'gi'), ''); + + html_content = tinyMCE.cleanupHTMLCode(html_content); + + // Try innerHTML if it fails use pasteHTML in MSIE + try { + tinyMCE.setInnerHTML(doc.body, html_content); + } catch (e) { + if (this.isMSIE) + doc.body.createTextRange().pasteHTML(html_content); + } + + // Content duplication bug fix + if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) { + // Remove P elements in P elements + var paras = doc.getElementsByTagName("P"); + for (var i=0; i<\/o:p>", "
    "); + html = tinyMCE.regexpReplace(html, " <\/o:p>", ""); + html = tinyMCE.regexpReplace(html, "", ""); + html = tinyMCE.regexpReplace(html, "

    <\/p>", ""); + html = tinyMCE.regexpReplace(html, "

    <\/p>\r\n

    <\/p>", ""); + html = tinyMCE.regexpReplace(html, "

     <\/p>", "
    "); + html = tinyMCE.regexpReplace(html, "

    \s*(

    \s*)?", "

    "); + html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "

    "); + } + + // Always set the htmlText output + tinyMCE.setInnerHTML(doc.body, html); + } + + tinyMCE.cleanupAnchors(doc); + + if (tinyMCE.getParam("convert_fonts_to_spans")) + tinyMCE.convertSpansToFonts(doc); +}; + +TinyMCE.prototype.getImageSrc = function(str) { + var pos = -1; + + if (!str) + return ""; + + if ((pos = str.indexOf('this.src=')) != -1) { + var src = str.substring(pos + 10); + + src = src.substring(0, src.indexOf('\'')); + + return src; + } + + return ""; +}; + +TinyMCE.prototype._getElementById = function(element_id) { + var elm = document.getElementById(element_id); + if (!elm) { + // Check for element in forms + for (var j=0; j 0) { + for (var x=0; x 0) + tinyMCE.cssClasses = output; + + return output; +}; + +TinyMCE.prototype.regexpReplace = function(in_str, reg_exp, replace_str, opts) { + if (in_str == null) + return in_str; + + if (typeof(opts) == "undefined") + opts = 'g'; + + var re = new RegExp(reg_exp, opts); + return in_str.replace(re, replace_str); +}; + +TinyMCE.prototype.trim = function(str) { + return str.replace(/^\s*|\s*$/g, ""); +}; + +TinyMCE.prototype.cleanupEventStr = function(str) { + str = "" + str; + str = str.replace('function anonymous()\n{\n', ''); + str = str.replace('\n}', ''); + str = str.replace(/^return true;/gi, ''); // Remove event blocker + + return str; +}; + +TinyMCE.prototype.getAbsPosition = function(node) { + var pos = new Object(); + + pos.absLeft = pos.absTop = 0; + + var parentNode = node; + while (parentNode) { + pos.absLeft += parentNode.offsetLeft; + pos.absTop += parentNode.offsetTop; + + parentNode = parentNode.offsetParent; + } + + return pos; +}; + +TinyMCE.prototype.getControlHTML = function(control_name) { + var themePlugins = tinyMCE.getParam('plugins', '', true, ','); + var templateFunction; + + // Is it defined in any plugins + for (var i=themePlugins.length; i>=0; i--) { + templateFunction = 'TinyMCE_' + themePlugins[i] + "_getControlHTML"; + if (eval("typeof(" + templateFunction + ")") != 'undefined') { + var html = eval(templateFunction + "('" + control_name + "');"); + if (html != "") + return tinyMCE.replaceVar(html, "pluginurl", tinyMCE.baseURL + "/plugins/" + themePlugins[i]); + } + } + + return eval('TinyMCE_' + tinyMCE.settings['theme'] + "_getControlHTML" + "('" + control_name + "');"); +}; + +TinyMCE.prototype._themeExecCommand = function(editor_id, element, command, user_interface, value) { + var themePlugins = tinyMCE.getParam('plugins', '', true, ','); + var templateFunction; + + // Is it defined in any plugins + for (var i=themePlugins.length; i>=0; i--) { + templateFunction = 'TinyMCE_' + themePlugins[i] + "_execCommand"; + if (eval("typeof(" + templateFunction + ")") != 'undefined') { + if (eval(templateFunction + "(editor_id, element, command, user_interface, value);")) + return true; + } + } + + // Theme funtion + templateFunction = 'TinyMCE_' + tinyMCE.settings['theme'] + "_execCommand"; + if (eval("typeof(" + templateFunction + ")") != 'undefined') + return eval(templateFunction + "(editor_id, element, command, user_interface, value);"); + + // Pass to normal + return false; +}; + +TinyMCE.prototype._getThemeFunction = function(suffix, skip_plugins) { + if (skip_plugins) + return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix; + + var themePlugins = tinyMCE.getParam('plugins', '', true, ','); + var templateFunction; + + // Is it defined in any plugins + for (var i=themePlugins.length; i>=0; i--) { + templateFunction = 'TinyMCE_' + themePlugins[i] + suffix; + if (eval("typeof(" + templateFunction + ")") != 'undefined') + return templateFunction; + } + + return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix; +}; + + +TinyMCE.prototype.isFunc = function(func_name) { + if (func_name == null || func_name == "") + return false; + + return eval("typeof(" + func_name + ")") != "undefined"; +}; + +TinyMCE.prototype.exec = function(func_name, args) { + var str = func_name + '('; + + // Add all arguments + for (var i=3; i 1 && tinyMCE.currentConfig != this.settings['index']) { + tinyMCE.settings = this.settings; + tinyMCE.currentConfig = this.settings['index']; + } +}; + +TinyMCEControl.prototype.convertAllRelativeURLs = function() { + var body = this.getBody(); + + // Convert all image URL:s to absolute URL + var elms = body.getElementsByTagName("img"); + for (var i=0; i 0) + rng.selectNodeContents(nodes[0]); + else + rng.selectNodeContents(node); + } else + rng.selectNode(node); + + if (collapse) { + // Special treatment of textnode collapse + if (!to_start && node.nodeType == 3) { + rng.setStart(node, node.nodeValue.length); + rng.setEnd(node, node.nodeValue.length); + } else + rng.collapse(to_start); + } + + sel.removeAllRanges(); + sel.addRange(rng); + } + + this.scrollToNode(node); + + // Set selected element + tinyMCE.selectedElement = null; + if (node.nodeType == 1) + tinyMCE.selectedElement = node; +}; + +TinyMCEControl.prototype.scrollToNode = function(node) { + // Scroll to node position + var pos = tinyMCE.getAbsPosition(node); + var doc = this.getDoc(); + var scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft; + var scrollY = doc.body.scrollTop + doc.documentElement.scrollTop; + var height = tinyMCE.isMSIE ? document.getElementById(this.editorId).style.pixelHeight : this.targetElement.clientHeight; + + // Only scroll if out of visible area + if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height))) + this.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25); +}; + +TinyMCEControl.prototype.getBody = function() { + return this.getDoc().body; +}; + +TinyMCEControl.prototype.getDoc = function() { + return this.contentWindow.document; +}; + +TinyMCEControl.prototype.getWin = function() { + return this.contentWindow; +}; + +TinyMCEControl.prototype.getSel = function() { + if (tinyMCE.isMSIE && !tinyMCE.isOpera) + return this.getDoc().selection; + + var sel = this.contentWindow.getSelection(); + + // Fake getRangeAt + if (tinyMCE.isSafari && !sel.getRangeAt) { + var newSel = new Object(); + var doc = this.getDoc(); + + function getRangeAt(idx) { + var rng = new Object(); + + rng.startContainer = this.focusNode; + rng.endContainer = this.anchorNode; + rng.commonAncestorContainer = this.focusNode; + rng.createContextualFragment = function (html) { + // Seems to be a tag + if (html.charAt(0) == '<') { + var elm = doc.createElement("div"); + + elm.innerHTML = html; + + return elm.firstChild; + } + + return doc.createTextNode("UNSUPPORTED, DUE TO LIMITATIONS IN SAFARI!"); + }; + + rng.deleteContents = function () { + doc.execCommand("Delete", false, ""); + }; + + return rng; + } + + // Patch selection + + newSel.focusNode = sel.baseNode; + newSel.focusOffset = sel.baseOffset; + newSel.anchorNode = sel.extentNode; + newSel.anchorOffset = sel.extentOffset; + newSel.getRangeAt = getRangeAt; + newSel.text = "" + sel; + newSel.realSelection = sel; + + newSel.toString = function () {return this.text;}; + + return newSel; + } + + return sel; +}; + +TinyMCEControl.prototype.getRng = function() { + var sel = this.getSel(); + if (sel == null) + return null; + + if (tinyMCE.isMSIE && !tinyMCE.isOpera) + return sel.createRange(); + + if (tinyMCE.isSafari) { + var rng = this.getDoc().createRange(); + var sel = this.getSel().realSelection; + + rng.setStart(sel.baseNode, sel.baseOffset); + rng.setEnd(sel.extentNode, sel.extentOffset); + + return rng; + } + + return this.getSel().getRangeAt(0); +}; + +TinyMCEControl.prototype._insertPara = function(e) { + function isEmpty(para) { + function isEmptyHTML(html) { + return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == ""; + } + + // Check for images + if (para.getElementsByTagName("img").length > 0) + return false; + + // Check for tables + if (para.getElementsByTagName("table").length > 0) + return false; + + // Check for HRs + if (para.getElementsByTagName("hr").length > 0) + return false; + + // Check all textnodes + var nodes = tinyMCE.getNodeTree(para, new Array(), 3); + for (var i=0; i <" + blockName + "> "; + paraAfter = body.childNodes[1]; + } + + this.selectNode(paraAfter, true, true); + + return true; + } + + // Place first part within new paragraph + if (startChop.nodeName == blockName) + rngBefore.setStart(startChop, 0); + else + rngBefore.setStartBefore(startChop); + + rngBefore.setEnd(startNode, startOffset); + paraBefore.appendChild(rngBefore.cloneContents()); + + // Place secound part within new paragraph + rngAfter.setEndAfter(endChop); + rngAfter.setStart(endNode, endOffset); + var contents = rngAfter.cloneContents(); + + if (contents.firstChild && contents.firstChild.nodeName == blockName) { +/* var nodes = contents.firstChild.childNodes; + for (var i=0; i 0) + rng.pasteHTML('
    ' + rng.htmlText + "
    "); + + tinyMCE.triggerNodeChange(); + return; + } + } + } + + switch (command) { + case "mceRepaint": + this.repaint(); + return true; + + case "mceStoreSelection": + this.selectionBookmark = this.getBookmark(); + return true; + + case "mceRestoreSelection": + this.moveToBookmark(this.selectionBookmark); + return true; + + case "InsertUnorderedList": + case "InsertOrderedList": + var tag = (command == "InsertUnorderedList") ? "ul" : "ol"; + + if (tinyMCE.isSafari) + this.execCommand("mceInsertContent", false, "<" + tag + ">
  •  
  • <" + tag + ">"); + else + this.getDoc().execCommand(command, user_interface, value); + + tinyMCE.triggerNodeChange(); + break; + + case "Strikethrough": + if (tinyMCE.isSafari) + this.execCommand("mceInsertContent", false, "" + this.getSelectedHTML() + ""); + else + this.getDoc().execCommand(command, user_interface, value); + + tinyMCE.triggerNodeChange(); + break; + + case "mceSelectNode": + this.selectNode(value); + tinyMCE.triggerNodeChange(); + tinyMCE.selectedNode = value; + break; + + case "FormatBlock": + if (value == null || value == "") { + var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address"); + + if (elm) + this.execCommand("mceRemoveNode", false, elm); + } else + this.getDoc().execCommand("FormatBlock", false, value); + + tinyMCE.triggerNodeChange(); + + break; + + case "mceRemoveNode": + if (!value) + value = tinyMCE.getParentElement(this.getFocusElement()); + + if (tinyMCE.isMSIE) { + value.outerHTML = value.innerHTML; + } else { + var rng = value.ownerDocument.createRange(); + rng.setStartBefore(value); + rng.setEndAfter(value); + rng.deleteContents(); + rng.insertNode(rng.createContextualFragment(value.innerHTML)); + } + + tinyMCE.triggerNodeChange(); + + break; + + case "mceSelectNodeDepth": + var parentNode = this.getFocusElement(); + for (var i=0; parentNode; i++) { + if (parentNode.nodeName.toLowerCase() == "body") + break; + + if (parentNode.nodeName.toLowerCase() == "#text") { + i--; + parentNode = parentNode.parentNode; + continue; + } + + if (i == value) { + this.selectNode(parentNode, false); + tinyMCE.triggerNodeChange(); + tinyMCE.selectedNode = parentNode; + return; + } + + parentNode = parentNode.parentNode; + } + + break; + + case "SetStyleInfo": + var rng = this.getRng(); + var sel = this.getSel(); + var scmd = value['command']; + var sname = value['name']; + var svalue = value['value'] == null ? '' : value['value']; + //var svalue = value['value'] == null ? '' : value['value']; + var wrapper = value['wrapper'] ? value['wrapper'] : "span"; + var parentElm = null; + var invalidRe = new RegExp("^BODY|HTML$", "g"); + var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null; + + // Whole element selected check + if (tinyMCE.isMSIE) { + // Control range + if (rng.item) + parentElm = rng.item(0); + else { + var pelm = rng.parentElement(); + var prng = doc.selection.createRange(); + prng.moveToElementText(pelm); + + if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) { + if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName)) + parentElm = pelm; + } + } + } else { + var felm = this.getFocusElement(); + if (sel.isCollapsed || (/td|tr|tbody|table/ig.test(felm.nodeName) && sel.anchorNode == felm.parentNode)) + parentElm = felm; + } + + // Whole element selected + if (parentElm && !invalidRe.test(parentElm.nodeName)) { + if (scmd == "setstyle") + tinyMCE.setStyleAttrib(parentElm, sname, svalue); + + if (scmd == "setattrib") + tinyMCE.setAttrib(parentElm, sname, svalue); + + if (scmd == "removeformat") { + parentElm.style.cssText = ''; + tinyMCE.setAttrib(parentElm, 'class', ''); + } + + // Remove style/attribs from all children + var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1); + for (var z=0; z=0; i--) { + var elm = nodes[i]; + var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true"; + + elm.removeAttribute("mce_new"); + + // Is only child a element + if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) { + //tinyMCE.debug("merge1" + isNew); + this._mergeElements(scmd, elm, elm.childNodes[0], isNew); + continue; + } + + // Is I the only child + if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) { + //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName); + if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName)) + this._mergeElements(scmd, elm.parentNode, elm, false); + } + } + + // Remove empty wrappers + var nodes = doc.getElementsByTagName(wrapper); + for (var i=nodes.length-1; i>=0; i--) { + var elm = nodes[i]; + var isEmpty = true; + + // Check if it has any attribs + var tmp = doc.createElement("body"); + tmp.appendChild(elm.cloneNode(false)); + + // Is empty span, remove it + tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), ''); + //tinyMCE.debug(tmp.innerHTML); + if (new RegExp('', 'gi').test(tmp.innerHTML)) { + for (var x=0; x 0) { + value = tinyMCE.replaceVar(value, "selection", selectedText); + tinyMCE.execCommand('mceInsertContent', false, value); + } + + tinyMCE.triggerNodeChange(); + break; + + case "mceSetAttribute": + if (typeof(value) == 'object') { + var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets']; + var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms); + + if (targetNode) { + targetNode.setAttribute(value['name'], value['value']); + tinyMCE.triggerNodeChange(); + } + } + break; + + case "mceSetCSSClass": + this.execCommand("SetStyleInfo", false, {command : "setattrib", name : "class", value : value}); + break; + + case "mceInsertRawHTML": + var key = 'tiny_mce_marker'; + + this.execCommand('mceBeginUndoLevel'); + + // Insert marker key + this.execCommand('mceInsertContent', false, key); + + // Store away scroll pos + var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft; + var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop; + + // Find marker and replace with RAW HTML + var html = this.getBody().innerHTML; + if ((pos = html.indexOf(key)) != -1) + tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length)); + + // Restore scoll pos + this.contentWindow.scrollTo(scrollX, scrollY); + + this.execCommand('mceEndUndoLevel'); + + break; + + case "mceInsertContent": + var insertHTMLFailed = false; + this.getWin().focus(); +/* WP + if (tinyMCE.isGecko || tinyMCE.isOpera) { + try { + // Is plain text or HTML + if (value.indexOf('<') == -1) { + var r = this.getRng(); + var n = this.getDoc().createTextNode(tinyMCE.entityDecode(value)); + var s = this.getSel(); + var r2 = r.cloneRange(); + + // Insert text at cursor position + s.removeAllRanges(); + r.deleteContents(); + r.insertNode(n); + + // Move the cursor to the end of text + r2.selectNode(n); + r2.collapse(false); + s.removeAllRanges(); + s.addRange(r2); + } else { + value = tinyMCE.fixGeckoBaseHREFBug(1, this.getDoc(), value); + this.getDoc().execCommand('inserthtml', false, value); + tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value); + } + } catch (ex) { + insertHTMLFailed = true; + } + + if (!insertHTMLFailed) { + tinyMCE.triggerNodeChange(); + return; + } + } +*/ + // Ugly hack in Opera due to non working "inserthtml" + if (tinyMCE.isOpera && insertHTMLFailed) { + this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL); + var ar = tinyMCE.getElementsByAttributeValue(this.getBody(), "img", "src", tinyMCE.uniqueURL); + ar[0].outerHTML = value; + return; + } + + if (!tinyMCE.isMSIE) { + var isHTML = value.indexOf('<') != -1; + var sel = this.getSel(); + var rng = this.getRng(); + + if (isHTML) { + if (tinyMCE.isSafari) { + var tmpRng = this.getDoc().createRange(); + + tmpRng.setStart(this.getBody(), 0); + tmpRng.setEnd(this.getBody(), 0); + + value = tmpRng.createContextualFragment(value); + } else + value = rng.createContextualFragment(value); + } else { + // Setup text node + var el = document.createElement("div"); + el.innerHTML = value; + value = el.firstChild.nodeValue; + value = doc.createTextNode(value); + } + + // Insert plain text in Safari + if (tinyMCE.isSafari && !isHTML) { + this.execCommand('InsertText', false, value.nodeValue); + tinyMCE.triggerNodeChange(); + return true; + } else if (tinyMCE.isSafari && isHTML) { + rng.deleteContents(); + rng.insertNode(value); + tinyMCE.triggerNodeChange(); + return true; + } + + rng.deleteContents(); + + // If target node is text do special treatment, (Mozilla 1.3 fix) + if (rng.startContainer.nodeType == 3) { + var node = rng.startContainer.splitText(rng.startOffset); + node.parentNode.insertBefore(value, node); + } else + rng.insertNode(value); + + if (!isHTML) { + // Removes weird selection trails + sel.selectAllChildren(doc.body); + sel.removeAllRanges(); + + // Move cursor to end of content + var rng = doc.createRange(); + + rng.selectNode(value); + rng.collapse(false); + + sel.addRange(rng); + } else + rng.collapse(false); + } else { + var rng = doc.selection.createRange(); + var c = value.indexOf('|$))|(<[^>]*(>|$)|>))%e', + "wp_kses_split2('\\1', \$allowed_html, ".'$allowed_protocols)', $string); +} # function wp_kses_split + +function wp_kses_split2($string, $allowed_html, $allowed_protocols) +############################################################################### +# This function does a lot of work. It rejects some very malformed things +# like <:::>. It returns an empty string, if the element isn't allowed (look +# ma, no strip_tags()!). Otherwise it splits the tag into an element and an +# attribute list. +############################################################################### +{ + $string = wp_kses_stripslashes($string); + + if (substr($string, 0, 1) != '<') + return '>'; + # It matched a ">" character + + if (preg_match('%^)?$%', $string, $matches)) { + $string = str_replace(array(''), '', $matches[1]); + while ( $string != $newstring = wp_kses($string, $allowed_html, $allowed_protocols) ) + $string = $newstring; + if ( $string == '' ) + return ''; + return ""; + } + # Allow HTML comments + + if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) + return ''; + # It's seriously malformed + + $slash = trim($matches[1]); + $elem = $matches[2]; + $attrlist = $matches[3]; + + if (!@ is_array($allowed_html[strtolower($elem)])) + return ''; + # They are using a not allowed HTML element + + if ($slash != '') + return "<$slash$elem>"; + # No attributes are allowed for closing elements + + return wp_kses_attr("$slash$elem", $attrlist, $allowed_html, $allowed_protocols); +} # function wp_kses_split2 + +function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) +############################################################################### +# This function removes all attributes, if none are allowed for this element. +# If some are allowed it calls wp_kses_hair() to split them further, and then it +# builds up new HTML code from the data that kses_hair() returns. It also +# removes "<" and ">" characters, if there are any left. One more thing it +# does is to check if the tag has a closing XHTML slash, and if it does, +# it puts one in the returned code as well. +############################################################################### +{ + # Is there a closing XHTML slash at the end of the attributes? + + $xhtml_slash = ''; + if (preg_match('%\s/\s*$%', $attr)) + $xhtml_slash = ' /'; + + # Are any attributes allowed at all for this element? + + if (@ count($allowed_html[strtolower($element)]) == 0) + return "<$element$xhtml_slash>"; + + # Split it + + $attrarr = wp_kses_hair($attr, $allowed_protocols); + + # Go through $attrarr, and save the allowed attributes for this element + # in $attr2 + + $attr2 = ''; + + foreach ($attrarr as $arreach) { + if (!@ isset ($allowed_html[strtolower($element)][strtolower($arreach['name'])])) + continue; # the attribute is not allowed + + $current = $allowed_html[strtolower($element)][strtolower($arreach['name'])]; + if ($current == '') + continue; # the attribute is not allowed + + if (!is_array($current)) + $attr2 .= ' '.$arreach['whole']; + # there are no checks + + else { + # there are some checks + $ok = true; + foreach ($current as $currkey => $currval) + if (!wp_kses_check_attr_val($arreach['value'], $arreach['vless'], $currkey, $currval)) { + $ok = false; + break; + } + + if ($ok) + $attr2 .= ' '.$arreach['whole']; # it passed them + } # if !is_array($current) + } # foreach + + # Remove any "<" or ">" characters + + $attr2 = preg_replace('/[<>]/', '', $attr2); + + return "<$element$attr2$xhtml_slash>"; +} # function wp_kses_attr + +function wp_kses_hair($attr, $allowed_protocols) +############################################################################### +# This function does a lot of work. It parses an attribute list into an array +# with attribute data, and tries to do the right thing even if it gets weird +# input. It will add quotes around attribute values that don't have any quotes +# or apostrophes around them, to make it easier to produce HTML code that will +# conform to W3C's HTML specification. It will also remove bad URL protocols +# from attribute values. +############################################################################### +{ + $attrarr = array (); + $mode = 0; + $attrname = ''; + + # Loop through the whole attribute list + + while (strlen($attr) != 0) { + $working = 0; # Was the last operation successful? + + switch ($mode) { + case 0 : # attribute name, href for instance + + if (preg_match('/^([-a-zA-Z]+)/', $attr, $match)) { + $attrname = $match[1]; + $working = $mode = 1; + $attr = preg_replace('/^[-a-zA-Z]+/', '', $attr); + } + + break; + + case 1 : # equals sign or valueless ("selected") + + if (preg_match('/^\s*=\s*/', $attr)) # equals sign + { + $working = 1; + $mode = 2; + $attr = preg_replace('/^\s*=\s*/', '', $attr); + break; + } + + if (preg_match('/^\s+/', $attr)) # valueless + { + $working = 1; + $mode = 0; + $attrarr[] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); + $attr = preg_replace('/^\s+/', '', $attr); + } + + break; + + case 2 : # attribute value, a URL after href= for instance + + if (preg_match('/^"([^"]*)"(\s+|$)/', $attr, $match)) + # "value" + { + $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols); + + $attrarr[] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); + $working = 1; + $mode = 0; + $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr); + break; + } + + if (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match)) + # 'value' + { + $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols); + + $attrarr[] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n'); + $working = 1; + $mode = 0; + $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr); + break; + } + + if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match)) + # value + { + $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols); + + $attrarr[] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); + # We add quotes to conform to W3C's HTML spec. + $working = 1; + $mode = 0; + $attr = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr); + } + + break; + } # switch + + if ($working == 0) # not well formed, remove and try again + { + $attr = wp_kses_html_error($attr); + $mode = 0; + } + } # while + + if ($mode == 1) + # special case, for when the attribute list ends with a valueless + # attribute like "selected" + $attrarr[] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); + + return $attrarr; +} # function wp_kses_hair + +function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) +############################################################################### +# This function performs different checks for attribute values. The currently +# implemented checks are "maxlen", "minlen", "maxval", "minval" and "valueless" +# with even more checks to come soon. +############################################################################### +{ + $ok = true; + + switch (strtolower($checkname)) { + case 'maxlen' : + # The maxlen check makes sure that the attribute value has a length not + # greater than the given value. This can be used to avoid Buffer Overflows + # in WWW clients and various Internet servers. + + if (strlen($value) > $checkvalue) + $ok = false; + break; + + case 'minlen' : + # The minlen check makes sure that the attribute value has a length not + # smaller than the given value. + + if (strlen($value) < $checkvalue) + $ok = false; + break; + + case 'maxval' : + # The maxval check does two things: it checks that the attribute value is + # an integer from 0 and up, without an excessive amount of zeroes or + # whitespace (to avoid Buffer Overflows). It also checks that the attribute + # value is not greater than the given value. + # This check can be used to avoid Denial of Service attacks. + + if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) + $ok = false; + if ($value > $checkvalue) + $ok = false; + break; + + case 'minval' : + # The minval check checks that the attribute value is a positive integer, + # and that it is not smaller than the given value. + + if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) + $ok = false; + if ($value < $checkvalue) + $ok = false; + break; + + case 'valueless' : + # The valueless check checks if the attribute has a value + # (like ) or not ('; + + if (($row->link_image != null) && $show_images) { + if (strstr($row->link_image, 'http')) + $output .= "link_image\" $alt $title />"; + else // If it's a relative path + $output .= "link_image\" $alt $title />"; + } else { + $output .= $name; + } + + $output .= ''; + + if ($show_updated && $row->recently_updated) { + $output .= get_settings('links_recently_updated_append'); + } + + if ($show_description && ($desc != '')) { + $output .= $between . $desc; + } + $output .= "$after\n"; + } // end while + + if ($echo) { + echo $output; + } else { + return $output; + } +} + + +/** function get_linkobjectsbyname() + ** Gets an array of link objects associated with category 'cat_name'. + ** Parameters: + ** cat_name (default 'noname') - The category name to use. If no + ** match is found uses all + ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', + ** 'url', 'description', or 'rating'. Or maybe owner. If you start the + ** name with an underscore the order will be reversed. + ** You can also specify 'rand' as the order which will return links in a + ** random order. + ** limit (default -1) - Limit to X entries. If not specified, all entries + ** are shown. + ** + ** Use this like: + ** $links = get_linkobjectsbyname('fred'); + ** foreach ($links as $link) { + ** echo '
  • '.$link->link_name.'
  • '; + ** } + **/ +function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { + global $wpdb; + $cat_id = -1; + $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'"); + if ($results) { + foreach ($results as $result) { + $cat_id = $result->cat_id; + } + } + return get_linkobjects($cat_id, $orderby, $limit); +} + +/** function get_linkobjects() + ** Gets an array of link objects associated with category n. + ** Parameters: + ** category (default -1) - The category to use. If no category supplied + ** uses all + ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', + ** 'url', 'description', or 'rating'. Or maybe owner. If you start the + ** name with an underscore the order will be reversed. + ** You can also specify 'rand' as the order which will return links in a + ** random order. + ** limit (default -1) - Limit to X entries. If not specified, all entries + ** are shown. + ** + ** Use this like: + ** $links = get_linkobjects(1); + ** if ($links) { + ** foreach ($links as $link) { + ** echo '
  • '.$link->link_name.'
    '.$link->link_description.'
  • '; + ** } + ** } + ** Fields are: + ** link_id + ** link_url + ** link_name + ** link_image + ** link_target + ** link_category + ** link_description + ** link_visible + ** link_owner + ** link_rating + ** link_updated + ** link_rel + ** link_notes + **/ +function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) { + global $wpdb; + + $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'"; + if ($category != -1) { + $sql .= " AND link_category = $category "; + } + if ($orderby == '') + $orderby = 'id'; + if (substr($orderby,0,1) == '_') { + $direction = ' DESC'; + $orderby = substr($orderby,1); + } + if (strcasecmp('rand',$orderby) == 0) { + $orderby = 'rand()'; + } else { + $orderby = " link_" . $orderby; + } + $sql .= ' ORDER BY ' . $orderby; + $sql .= $direction; + /* The next 2 lines implement LIMIT TO processing */ + if ($limit != -1) + $sql .= " LIMIT $limit"; + + $results = $wpdb->get_results($sql); + if ($results) { + foreach ($results as $result) { + $result->link_url = $result->link_url; + $result->link_name = $result->link_name; + $result->link_description = $result->link_description; + $result->link_notes = $result->link_notes; + $newresults[] = $result; + } + } + return $newresults; +} + +function get_linkrating($link) { + return apply_filters('link_rating', $link->link_rating); +} + + +/** function get_linksbyname_withrating() + ** Gets the links associated with category 'cat_name' and display rating stars/chars. + ** Parameters: + ** cat_name (default 'noname') - The category name to use. If no + ** match is found uses all + ** before (default '') - the html to output before the link + ** after (default '
    ') - the html to output after the link + ** between (default ' ') - the html to output between the link/image + ** and it's description. Not used if no image or show_images == true + ** show_images (default true) - whether to show images (if defined). + ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', + ** 'url' or 'description'. Or maybe owner. If you start the + ** name with an underscore the order will be reversed. + ** You can also specify 'rand' as the order which will return links in a + ** random order. + ** show_description (default true) - whether to show the description if + ** show_images=false/not defined + ** limit (default -1) - Limit to X entries. If not specified, all entries + ** are shown. + ** show_updated (default 0) - whether to show last updated timestamp + */ +function get_linksbyname_withrating($cat_name = "noname", $before = '', + $after = '
    ', $between = " ", + $show_images = true, $orderby = 'id', + $show_description = true, $limit = -1, $show_updated = 0) { + + get_linksbyname($cat_name, $before, $after, $between, $show_images, + $orderby, $show_description, true, $limit, $show_updated); +} + +/** function get_links_withrating() + ** Gets the links associated with category n and display rating stars/chars. + ** Parameters: + ** category (default -1) - The category to use. If no category supplied + ** uses all + ** before (default '') - the html to output before the link + ** after (default '
    ') - the html to output after the link + ** between (default ' ') - the html to output between the link/image + ** and it's description. Not used if no image or show_images == true + ** show_images (default true) - whether to show images (if defined). + ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', + ** 'url' or 'description'. Or maybe owner. If you start the + ** name with an underscore the order will be reversed. + ** You can also specify 'rand' as the order which will return links in a + ** random order. + ** show_description (default true) - whether to show the description if + ** show_images=false/not defined . + ** limit (default -1) - Limit to X entries. If not specified, all entries + ** are shown. + ** show_updated (default 0) - whether to show last updated timestamp + */ +function get_links_withrating($category = -1, $before = '', $after = '
    ', + $between = " ", $show_images = true, + $orderby = 'id', $show_description = true, + $limit = -1, $show_updated = 0) { + + get_links($category, $before, $after, $between, $show_images, $orderby, + $show_description, true, $limit, $show_updated); +} + +/** function get_linkcatname() + ** Gets the name of category n. + ** Parameters: id (default 0) - The category to get. If no category supplied + ** uses 0 + */ +function get_linkcatname($id = 0) { + global $wpdb; + $cat_name = ''; + if ('' != $id) { + $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->linkcategories WHERE cat_id=$id"); + } + return $cat_name; +} + +/** function get_get_autotoggle() + ** Gets the auto_toggle setting of category n. + ** Parameters: id (default 0) - The category to get. If no category supplied + ** uses 0 + */ +function get_autotoggle($id = 0) { + global $wpdb; + $auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $wpdb->linkcategories WHERE cat_id=$id"); + if ('' == $auto_toggle) + $auto_toggle = 'N'; + return $auto_toggle; +} + +/** function links_popup_script() + ** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/ + ** Show the link to the links popup and the number of links + ** Parameters: + ** text (default Links) - the text of the link + ** width (default 400) - the width of the popup window + ** height (default 400) - the height of the popup window + ** file (default linkspopup.php) - the page to open in the popup window + ** count (default true) - the number of links in the db + */ +function links_popup_script($text = 'Links', $width=400, $height=400, + $file='links.all.php', $count = true) { + if ($count == true) { + $counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links"); + } + + $javascript = ""; + $javascript .= $text; + + if ($count == true) { + $javascript .= " ($counts)"; + } + + $javascript .="\n\n"; + echo $javascript; +} + + +/* + * function get_links_list() + * + * added by Dougal + * + * Output a list of all links, listed by category, using the + * settings in $wpdb->linkcategories and output it as a nested + * HTML unordered list. + * + * Parameters: + * order (default 'name') - Sort link categories by 'name' or 'id' + * hide_if_empty (default true) - Supress listing empty link categories + */ +function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { + global $wpdb; + + $order = strtolower($order); + + // Handle link category sorting + if (substr($order,0,1) == '_') { + $direction = ' DESC'; + $order = substr($order,1); + } + + // if 'name' wasn't specified, assume 'id': + $cat_order = ('name' == $order) ? 'cat_name' : 'cat_id'; + + if (!isset($direction)) $direction = ''; + // Fetch the link category data as an array of hashesa + $cats = $wpdb->get_results(" + SELECT DISTINCT link_category, cat_name, show_images, + show_description, show_rating, show_updated, sort_order, + sort_desc, list_limit + FROM `$wpdb->links` + LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id) + WHERE link_visible = 'Y' + AND list_limit <> 0 + ORDER BY $cat_order $direction ", ARRAY_A); + + // Display each category + if ($cats) { + foreach ($cats as $cat) { + // Handle each category. + // First, fix the sort_order info + $orderby = $cat['sort_order']; + $orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby; + + // Display the category name + echo ' \n"; + } + } +} + +?> \ No newline at end of file diff --git a/wp-includes/locale.php b/wp-includes/locale.php new file mode 100644 index 00000000..7af4deac --- /dev/null +++ b/wp-includes/locale.php @@ -0,0 +1,70 @@ + $weekday_initial_) { + $weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_); +} + +// Abbreviations for each day. +$weekday_abbrev[__('Sunday')] = __('Sun'); +$weekday_abbrev[__('Monday')] = __('Mon'); +$weekday_abbrev[__('Tuesday')] = __('Tue'); +$weekday_abbrev[__('Wednesday')] = __('Wed'); +$weekday_abbrev[__('Thursday')] = __('Thu'); +$weekday_abbrev[__('Friday')] = __('Fri'); +$weekday_abbrev[__('Saturday')] = __('Sat'); + +// The Months +$month['01'] = __('January'); +$month['02'] = __('February'); +$month['03'] = __('March'); +$month['04'] = __('April'); +$month['05'] = __('May'); +$month['06'] = __('June'); +$month['07'] = __('July'); +$month['08'] = __('August'); +$month['09'] = __('September'); +$month['10'] = __('October'); +$month['11'] = __('November'); +$month['12'] = __('December'); + +// Abbreviations for each month. Uses the same hack as above to get around the +// 'May' duplication. +$month_abbrev[__('January')] = __('Jan_January_abbreviation'); +$month_abbrev[__('February')] = __('Feb_February_abbreviation'); +$month_abbrev[__('March')] = __('Mar_March_abbreviation'); +$month_abbrev[__('April')] = __('Apr_April_abbreviation'); +$month_abbrev[__('May')] = __('May_May_abbreviation'); +$month_abbrev[__('June')] = __('Jun_June_abbreviation'); +$month_abbrev[__('July')] = __('Jul_July_abbreviation'); +$month_abbrev[__('August')] = __('Aug_August_abbreviation'); +$month_abbrev[__('September')] = __('Sep_September_abbreviation'); +$month_abbrev[__('October')] = __('Oct_October_abbreviation'); +$month_abbrev[__('November')] = __('Nov_November_abbreviation'); +$month_abbrev[__('December')] = __('Dec_December_abbreviation'); + +foreach ($month_abbrev as $month_ => $month_abbrev_) { + $month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_); +} + +?> \ No newline at end of file diff --git a/wp-includes/pluggable-functions.php b/wp-includes/pluggable-functions.php new file mode 100644 index 00000000..bcaa9a88 --- /dev/null +++ b/wp-includes/pluggable-functions.php @@ -0,0 +1,432 @@ +user_login; + $user_level = $userdata->user_level; + $user_ID = $userdata->ID; + $user_email = $userdata->user_email; + $user_url = $userdata->user_url; + $user_pass_md5 = md5($userdata->user_pass); + $user_identity = $userdata->display_name; + + do_action('set_current_user'); + + return $current_user; +} +endif; + + +if ( !function_exists('get_currentuserinfo') ) : +function get_currentuserinfo() { + global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user; + + if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) + return false; + + if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) || + !wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) { + $current_user = new WP_User(0); + return false; + } + $user_login = $_COOKIE[USER_COOKIE]; + $userdata = get_userdatabylogin($user_login); + $user_level = $userdata->user_level; + $user_ID = $userdata->ID; + $user_email = $userdata->user_email; + $user_url = $userdata->user_url; + $user_pass_md5 = md5($userdata->user_pass); + $user_identity = $userdata->display_name; + + if ( empty($current_user) ) + $current_user = new WP_User($user_ID); +} +endif; + +if ( !function_exists('get_userdata') ) : +function get_userdata( $user_id ) { + global $wpdb; + $user_id = (int) $user_id; + if ( $user_id == 0 ) + return false; + + $user = wp_cache_get($user_id, 'users'); + + if ( $user ) + return $user; + + if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$user_id' LIMIT 1") ) + return false; + + $wpdb->hide_errors(); + $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'"); + $wpdb->show_errors(); + + if ($metavalues) { + foreach ( $metavalues as $meta ) { + @ $value = unserialize($meta->meta_value); + if ($value === FALSE) + $value = $meta->meta_value; + $user->{$meta->meta_key} = $value; + + // We need to set user_level from meta, not row + if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) + $user->user_level = $meta->meta_value; + } // end foreach + } //end if + + // For backwards compat. + if ( isset($user->first_name) ) + $user->user_firstname = $user->first_name; + if ( isset($user->last_name) ) + $user->user_lastname = $user->last_name; + if ( isset($user->description) ) + $user->user_description = $user->description; + + wp_cache_add($user_id, $user, 'users'); + wp_cache_add($user->user_login, $user, 'userlogins'); + + return $user; +} +endif; + +if ( !function_exists('update_user_cache') ) : +function update_user_cache() { + return true; +} +endif; + +if ( !function_exists('get_userdatabylogin') ) : +function get_userdatabylogin($user_login) { + global $wpdb; + $user_login = sanitize_user( $user_login ); + + if ( empty( $user_login ) ) + return false; + + $userdata = wp_cache_get($user_login, 'userlogins'); + if ( $userdata ) + return $userdata; + + if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") ) + return false; + + $wpdb->hide_errors(); + $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user->ID'"); + $wpdb->show_errors(); + + if ($metavalues) { + foreach ( $metavalues as $meta ) { + @ $value = unserialize($meta->meta_value); + if ($value === FALSE) + $value = $meta->meta_value; + $user->{$meta->meta_key} = $value; + + // We need to set user_level from meta, not row + if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) + $user->user_level = $meta->meta_value; + } + } + + // For backwards compat. + if ( isset($user->first_name) ) + $user->user_firstname = $user->first_name; + if ( isset($user->last_name) ) + $user->user_lastname = $user->last_name; + if ( isset($user->description) ) + $user->user_description = $user->description; + + wp_cache_add($user->ID, $user, 'users'); + wp_cache_add($user->user_login, $user, 'userlogins'); + + return $user; + +} +endif; + +if ( !function_exists('wp_mail') ) : +function wp_mail($to, $subject, $message, $headers = '') { + if( $headers == '' ) { + $headers = "MIME-Version: 1.0\n" . + "From: wordpress@" . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])) . "\n" . + "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n"; + } + + return @mail($to, $subject, $message, $headers); +} +endif; + +if ( !function_exists('wp_login') ) : +function wp_login($username, $password, $already_md5 = false) { + global $wpdb, $error; + + if ( '' == $username ) + return false; + + if ( '' == $password ) { + $error = __('Error: The password field is empty.'); + return false; + } + + $login = get_userdatabylogin($username); + //$login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'"); + + if (!$login) { + $error = __('Error: Wrong username.'); + return false; + } else { + // If the password is already_md5, it has been double hashed. + // Otherwise, it is plain text. + if ( ($already_md5 && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) { + return true; + } else { + $error = __('Error: Incorrect password.'); + $pwd = ''; + return false; + } + } +} +endif; + +if ( !function_exists('is_user_logged_in') ) : +function is_user_logged_in() { + global $current_user; + + if ( $current_user->id == 0 ) + return false; + return true; +} +endif; + +if ( !function_exists('auth_redirect') ) : +function auth_redirect() { + // Checks if a user is logged in, if not redirects them to the login page + if ( (!empty($_COOKIE[USER_COOKIE]) && + !wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) || + (empty($_COOKIE[USER_COOKIE])) ) { + nocache_headers(); + + header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])); + exit(); + } +} +endif; + +if ( !function_exists('check_admin_referer') ) : +function check_admin_referer() { + $adminurl = strtolower(get_settings('siteurl')).'/wp-admin'; + $referer = strtolower($_SERVER['HTTP_REFERER']); + if (!strstr($referer, $adminurl)) + die(__('Sorry, you need to enable sending referrers for this feature to work.')); + do_action('check_admin_referer'); +} +endif; + +// Cookie safe redirect. Works around IIS Set-Cookie bug. +// http://support.microsoft.com/kb/q176113/ +if ( !function_exists('wp_redirect') ) : +function wp_redirect($location) { + global $is_IIS; + + $location = str_replace( array("\n", "\r"), '', $location); + + if ($is_IIS) + header("Refresh: 0;url=$location"); + else + header("Location: $location"); +} +endif; + +if ( !function_exists('wp_setcookie') ) : +function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '', $remember = false) { + if ( !$already_md5 ) + $password = md5( md5($password) ); // Double hash the password in the cookie. + + if ( empty($home) ) + $cookiepath = COOKIEPATH; + else + $cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' ); + + if ( empty($siteurl) ) { + $sitecookiepath = SITECOOKIEPATH; + $cookiehash = COOKIEHASH; + } else { + $sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' ); + $cookiehash = md5($siteurl); + } + + if ( $remember ) + $expire = time() + 31536000; + else + $expire = 0; + + setcookie(USER_COOKIE, $username, $expire, $cookiepath, COOKIE_DOMAIN); + setcookie(PASS_COOKIE, $password, $expire, $cookiepath, COOKIE_DOMAIN); + + if ( $cookiepath != $sitecookiepath ) { + setcookie(USER_COOKIE, $username, $expire, $sitecookiepath, COOKIE_DOMAIN); + setcookie(PASS_COOKIE, $password, $expire, $sitecookiepath, COOKIE_DOMAIN); + } +} +endif; + +if ( !function_exists('wp_clearcookie') ) : +function wp_clearcookie() { + setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); + setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); + setcookie(USER_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); + setcookie(PASS_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); +} +endif; + +if ( ! function_exists('wp_notify_postauthor') ) : +function wp_notify_postauthor($comment_id, $comment_type='') { + global $wpdb; + + $comment = get_comment($comment_id); + $post = get_post($comment->comment_post_ID); + $user = get_userdata( $post->post_author ); + + if ('' == $user->user_email) return false; // If there's no email to send the comment to + + $comment_author_domain = gethostbyaddr($comment->comment_author_IP); + + $blogname = get_settings('blogname'); + + if ( empty( $comment_type ) ) $comment_type = 'comment'; + + if ('comment' == $comment_type) { + $notify_message = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; + $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; + $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; + $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; + $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; + $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; + $notify_message .= __('You can see all comments on this post here: ') . "\r\n"; + $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title ); + } elseif ('trackback' == $comment_type) { + $notify_message = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; + $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; + $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; + $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; + $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n"; + $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title ); + } elseif ('pingback' == $comment_type) { + $notify_message = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; + $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; + $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; + $notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n"; + $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n"; + $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title ); + } + $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n"; + $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; + + $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); + + if ( '' == $comment->comment_author ) { + $from = "From: \"$blogname\" <$wp_email>"; + if ( '' != $comment->comment_author_email ) + $reply_to = "Reply-To: $comment->comment_author_email"; + } else { + $from = "From: \"$comment->comment_author\" <$wp_email>"; + if ( '' != $comment->comment_author_email ) + $reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>"; + } + + $message_headers = "MIME-Version: 1.0\n" + . "$from\n" + . "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n"; + + if ( isset($reply_to) ) + $message_headers .= $reply_to . "\n"; + + $notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id); + $subject = apply_filters('comment_notification_subject', $subject, $comment_id); + $message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id); + + @wp_mail($user->user_email, $subject, $notify_message, $message_headers); + + return true; +} +endif; + +/* wp_notify_moderator + notifies the moderator of the blog (usually the admin) + about a new comment that waits for approval + always returns true + */ +if ( !function_exists('wp_notify_moderator') ) : +function wp_notify_moderator($comment_id) { + global $wpdb; + + if( get_settings( "moderation_notify" ) == 0 ) + return true; + + $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); + $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1"); + + $comment_author_domain = gethostbyaddr($comment->comment_author_IP); + $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); + + $notify_message = sprintf( __('A new comment on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n"; + $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; + $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; + $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; + $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; + $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; + $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; + $notify_message .= sprintf( __('To approve this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=mailapprovecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; + $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; + $notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n"; + $notify_message .= get_settings('siteurl') . "/wp-admin/moderation.php\r\n"; + + $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_settings('blogname'), $post->post_title ); + $admin_email = get_settings('admin_email'); + + $notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id); + $subject = apply_filters('comment_moderation_subject', $subject, $comment_id); + + @wp_mail($admin_email, $subject, $notify_message); + + return true; +} +endif; + +if ( !function_exists('wp_new_user_notification') ) : +function wp_new_user_notification($user_id, $plaintext_pass = '') { + $user = new WP_User($user_id); + + $user_login = stripslashes($user->user_login); + $user_email = stripslashes($user->user_email); + + $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n"; + $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; + $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; + + @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message); + + if ( empty($plaintext_pass) ) + return; + + $message = sprintf(__('Username: %s'), $user_login) . "\r\n"; + $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; + $message .= get_settings('siteurl') . "/wp-login.php\r\n"; + + wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message); + +} +endif; + +?> diff --git a/wp-includes/registration-functions.php b/wp-includes/registration-functions.php new file mode 100644 index 00000000..ff9db3d2 --- /dev/null +++ b/wp-includes/registration-functions.php @@ -0,0 +1,144 @@ +ID; + + return null; +} + +function validate_username( $username ) { + $name = sanitize_user($username, true); + $valid = true; + + if ( $name != $username ) + $valid = false; + + return apply_filters('validate_username', $valid, $username); +} + +function wp_insert_user($userdata) { + global $wpdb; + + extract($userdata); + + // Are we updating or creating? + if ( !empty($ID) ) { + $update = true; + } else { + $update = false; + // Password is not hashed when creating new user. + $user_pass = md5($user_pass); + } + + $user_login = sanitize_user($user_login, true); + + if ( empty($user_nicename) ) + $user_nicename = sanitize_title( $user_login ); + + if ( empty($display_name) ) + $display_name = $user_login; + + if ( empty($nickname) ) + $nickname = $user_login; + + if ( empty($user_registered) ) + $user_registered = gmdate('Y-m-d H:i:s'); + + if ( $update ) { + $query = "UPDATE $wpdb->users SET user_pass='$user_pass', user_email='$user_email', user_url='$user_url', user_nicename = '$user_nicename', display_name = '$display_name' WHERE ID = '$ID'"; + $query = apply_filters('update_user_query', $query); + $wpdb->query( $query ); + $user_id = $ID; + } else { + $query = "INSERT INTO $wpdb->users + (user_login, user_pass, user_email, user_url, user_registered, user_nicename, display_name) + VALUES + ('$user_login', '$user_pass', '$user_email', '$user_url', '$user_registered', '$user_nicename', '$display_name')"; + $query = apply_filters('create_user_query', $query); + $wpdb->query( $query ); + $user_id = $wpdb->insert_id; + } + + update_usermeta( $user_id, 'first_name', $first_name); + update_usermeta( $user_id, 'last_name', $last_name); + update_usermeta( $user_id, 'nickname', $nickname ); + update_usermeta( $user_id, 'description', $description ); + update_usermeta( $user_id, 'jabber', $jabber ); + update_usermeta( $user_id, 'aim', $aim ); + update_usermeta( $user_id, 'yim', $yim ); + + if ($update && !empty($role)) { + $user = new WP_User($user_id); + $user->set_role($role); + } + + if ( !$update ) { + $user = new WP_User($user_id); + $user->set_role(get_settings('default_role')); + } + + wp_cache_delete($user_id, 'users'); + wp_cache_delete($user_login, 'userlogins'); + + if ( $update ) + do_action('profile_update', $user_id); + else + do_action('user_register', $user_id); + + return $user_id; +} + +function wp_update_user($userdata) { + global $wpdb, $current_user; + + $ID = (int) $userdata['ID']; + + // First, get all of the original fields + $user = get_userdata($ID); + + // Escape data pulled from DB. + $user = add_magic_quotes(get_object_vars($user)); + + // If password is changing, hash it now. + if ( ! empty($userdata['user_pass']) ) { + $plaintext_pass = $userdata['user_pass']; + $userdata['user_pass'] = md5($userdata['user_pass']); + } + + // Merge old and new fields with new fields overwriting old ones. + $userdata = array_merge($user, $userdata); + $user_id = wp_insert_user($userdata); + + // Update the cookies if the password changed. + if( $current_user->id == $ID ) { + if ( isset($plaintext_pass) ) { + wp_clearcookie(); + wp_setcookie($userdata['user_login'], $plaintext_pass); + } + } + + return $user_id; +} + +function wp_create_user( $username, $password, $email = '') { + global $wpdb; + + $user_login = $wpdb->escape( $username ); + $user_email = $wpdb->escape( $email ); + $user_pass = $password; + + $userdata = compact('user_login', 'user_email', 'user_pass'); + return wp_insert_user($userdata); +} + + +function create_user( $username, $password, $email ) { + return wp_create_user( $username, $password, $email ); +} + + +?> diff --git a/wp-includes/rss-functions.php b/wp-includes/rss-functions.php new file mode 100644 index 00000000..df2526ec --- /dev/null +++ b/wp-includes/rss-functions.php @@ -0,0 +1,856 @@ + + * Version: 0.51 + * License: GPL + */ + +define('RSS', 'RSS'); +define('ATOM', 'Atom'); +define('MAGPIE_USER_AGENT', 'WordPress/' . $wp_version); + +class MagpieRSS { + var $parser; + var $current_item = array(); // item currently being parsed + var $items = array(); // collection of parsed items + var $channel = array(); // hash of channel fields + var $textinput = array(); + var $image = array(); + var $feed_type; + var $feed_version; + + // parser variables + var $stack = array(); // parser stack + var $inchannel = false; + var $initem = false; + var $incontent = false; // if in Atom field + var $intextinput = false; + var $inimage = false; + var $current_field = ''; + var $current_namespace = false; + + //var $ERROR = ""; + + var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright'); + + function MagpieRSS ($source) { + + # if PHP xml isn't compiled in, die + # + if ( !function_exists('xml_parser_create') ) + trigger_error( "Failed to load PHP's XML Extension. http://www.php.net/manual/en/ref.xml.php" ); + + $parser = @xml_parser_create(); + + if ( !is_resource($parser) ) + trigger_error( "Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php"); + + + $this->parser = $parser; + + # pass in parser, and a reference to this object + # setup handlers + # + xml_set_object( $this->parser, $this ); + xml_set_element_handler($this->parser, + 'feed_start_element', 'feed_end_element' ); + + xml_set_character_data_handler( $this->parser, 'feed_cdata' ); + + $status = xml_parse( $this->parser, $source ); + + if (! $status ) { + $errorcode = xml_get_error_code( $this->parser ); + if ( $errorcode != XML_ERROR_NONE ) { + $xml_error = xml_error_string( $errorcode ); + $error_line = xml_get_current_line_number($this->parser); + $error_col = xml_get_current_column_number($this->parser); + $errormsg = "$xml_error at line $error_line, column $error_col"; + + $this->error( $errormsg ); + } + } + + xml_parser_free( $this->parser ); + + $this->normalize(); + } + + function feed_start_element($p, $element, &$attrs) { + $el = $element = strtolower($element); + $attrs = array_change_key_case($attrs, CASE_LOWER); + + // check for a namespace, and split if found + $ns = false; + if ( strpos( $element, ':' ) ) { + list($ns, $el) = split( ':', $element, 2); + } + if ( $ns and $ns != 'rdf' ) { + $this->current_namespace = $ns; + } + + # if feed type isn't set, then this is first element of feed + # identify feed from root element + # + if (!isset($this->feed_type) ) { + if ( $el == 'rdf' ) { + $this->feed_type = RSS; + $this->feed_version = '1.0'; + } + elseif ( $el == 'rss' ) { + $this->feed_type = RSS; + $this->feed_version = $attrs['version']; + } + elseif ( $el == 'feed' ) { + $this->feed_type = ATOM; + $this->feed_version = $attrs['version']; + $this->inchannel = true; + } + return; + } + + if ( $el == 'channel' ) + { + $this->inchannel = true; + } + elseif ($el == 'item' or $el == 'entry' ) + { + $this->initem = true; + if ( isset($attrs['rdf:about']) ) { + $this->current_item['about'] = $attrs['rdf:about']; + } + } + + // if we're in the default namespace of an RSS feed, + // record textinput or image fields + elseif ( + $this->feed_type == RSS and + $this->current_namespace == '' and + $el == 'textinput' ) + { + $this->intextinput = true; + } + + elseif ( + $this->feed_type == RSS and + $this->current_namespace == '' and + $el == 'image' ) + { + $this->inimage = true; + } + + # handle atom content constructs + elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) + { + // avoid clashing w/ RSS mod_content + if ($el == 'content' ) { + $el = 'atom_content'; + } + + $this->incontent = $el; + + + } + + // if inside an Atom content construct (e.g. content or summary) field treat tags as text + elseif ($this->feed_type == ATOM and $this->incontent ) + { + // if tags are inlined, then flatten + $attrs_str = join(' ', + array_map('map_attrs', + array_keys($attrs), + array_values($attrs) ) ); + + $this->append_content( "<$element $attrs_str>" ); + + array_unshift( $this->stack, $el ); + } + + // Atom support many links per containging element. + // Magpie treats link elements of type rel='alternate' + // as being equivalent to RSS's simple link element. + // + elseif ($this->feed_type == ATOM and $el == 'link' ) + { + if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) + { + $link_el = 'link'; + } + else { + $link_el = 'link_' . $attrs['rel']; + } + + $this->append($link_el, $attrs['href']); + } + // set stack[0] to current element + else { + array_unshift($this->stack, $el); + } + } + + + + function feed_cdata ($p, $text) { + + if ($this->feed_type == ATOM and $this->incontent) + { + $this->append_content( $text ); + } + else { + $current_el = join('_', array_reverse($this->stack)); + $this->append($current_el, $text); + } + } + + function feed_end_element ($p, $el) { + $el = strtolower($el); + + if ( $el == 'item' or $el == 'entry' ) + { + $this->items[] = $this->current_item; + $this->current_item = array(); + $this->initem = false; + } + elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) + { + $this->intextinput = false; + } + elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) + { + $this->inimage = false; + } + elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) + { + $this->incontent = false; + } + elseif ($el == 'channel' or $el == 'feed' ) + { + $this->inchannel = false; + } + elseif ($this->feed_type == ATOM and $this->incontent ) { + // balance tags properly + // note: i don't think this is actually neccessary + if ( $this->stack[0] == $el ) + { + $this->append_content(""); + } + else { + $this->append_content("<$el />"); + } + + array_shift( $this->stack ); + } + else { + array_shift( $this->stack ); + } + + $this->current_namespace = false; + } + + function concat (&$str1, $str2="") { + if (!isset($str1) ) { + $str1=""; + } + $str1 .= $str2; + } + + function append_content($text) { + if ( $this->initem ) { + $this->concat( $this->current_item[ $this->incontent ], $text ); + } + elseif ( $this->inchannel ) { + $this->concat( $this->channel[ $this->incontent ], $text ); + } + } + + // smart append - field and namespace aware + function append($el, $text) { + if (!$el) { + return; + } + if ( $this->current_namespace ) + { + if ( $this->initem ) { + $this->concat( + $this->current_item[ $this->current_namespace ][ $el ], $text); + } + elseif ($this->inchannel) { + $this->concat( + $this->channel[ $this->current_namespace][ $el ], $text ); + } + elseif ($this->intextinput) { + $this->concat( + $this->textinput[ $this->current_namespace][ $el ], $text ); + } + elseif ($this->inimage) { + $this->concat( + $this->image[ $this->current_namespace ][ $el ], $text ); + } + } + else { + if ( $this->initem ) { + $this->concat( + $this->current_item[ $el ], $text); + } + elseif ($this->intextinput) { + $this->concat( + $this->textinput[ $el ], $text ); + } + elseif ($this->inimage) { + $this->concat( + $this->image[ $el ], $text ); + } + elseif ($this->inchannel) { + $this->concat( + $this->channel[ $el ], $text ); + } + + } + } + + function normalize () { + // if atom populate rss fields + if ( $this->is_atom() ) { + $this->channel['descripton'] = $this->channel['tagline']; + for ( $i = 0; $i < count($this->items); $i++) { + $item = $this->items[$i]; + if ( isset($item['summary']) ) + $item['description'] = $item['summary']; + if ( isset($item['atom_content'])) + $item['content']['encoded'] = $item['atom_content']; + + $this->items[$i] = $item; + } + } + elseif ( $this->is_rss() ) { + $this->channel['tagline'] = $this->channel['description']; + for ( $i = 0; $i < count($this->items); $i++) { + $item = $this->items[$i]; + if ( isset($item['description'])) + $item['summary'] = $item['description']; + if ( isset($item['content']['encoded'] ) ) + $item['atom_content'] = $item['content']['encoded']; + + $this->items[$i] = $item; + } + } + } + + function is_rss () { + if ( $this->feed_type == RSS ) { + return $this->feed_version; + } + else { + return false; + } + } + + function is_atom() { + if ( $this->feed_type == ATOM ) { + return $this->feed_version; + } + else { + return false; + } + } + + function map_attrs($k, $v) { + return "$k=\"$v\""; + } + + function error( $errormsg, $lvl = E_USER_WARNING ) { + // append PHP's error message if track_errors enabled + if ( isset($php_errormsg) ) { + $errormsg .= " ($php_errormsg)"; + } + if ( MAGPIE_DEBUG ) { + trigger_error( $errormsg, $lvl); + } else { + error_log( $errormsg, 0); + } + } + +} +require_once( dirname(__FILE__) . '/class-snoopy.php'); + +function fetch_rss ($url) { + // initialize constants + init(); + + if ( !isset($url) ) { + // error("fetch_rss called without a url"); + return false; + } + + // if cache is disabled + if ( !MAGPIE_CACHE_ON ) { + // fetch file, and parse it + $resp = _fetch_remote_file( $url ); + if ( is_success( $resp->status ) ) { + return _response_to_rss( $resp ); + } + else { + // error("Failed to fetch $url and cache is off"); + return false; + } + } + // else cache is ON + else { + // Flow + // 1. check cache + // 2. if there is a hit, make sure its fresh + // 3. if cached obj fails freshness check, fetch remote + // 4. if remote fails, return stale object, or error + + $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); + + if (MAGPIE_DEBUG and $cache->ERROR) { + debug($cache->ERROR, E_USER_WARNING); + } + + + $cache_status = 0; // response of check_cache + $request_headers = array(); // HTTP headers to send with fetch + $rss = 0; // parsed RSS object + $errormsg = 0; // errors, if any + + if (!$cache->ERROR) { + // return cache HIT, MISS, or STALE + $cache_status = $cache->check_cache( $url ); + } + + // if object cached, and cache is fresh, return cached obj + if ( $cache_status == 'HIT' ) { + $rss = $cache->get( $url ); + if ( isset($rss) and $rss ) { + $rss->from_cache = 1; + if ( MAGPIE_DEBUG > 1) { + debug("MagpieRSS: Cache HIT", E_USER_NOTICE); + } + return $rss; + } + } + + // else attempt a conditional get + + // setup headers + if ( $cache_status == 'STALE' ) { + $rss = $cache->get( $url ); + if ( $rss->etag and $rss->last_modified ) { + $request_headers['If-None-Match'] = $rss->etag; + $request_headers['If-Last-Modified'] = $rss->last_modified; + } + } + + $resp = _fetch_remote_file( $url, $request_headers ); + + if (isset($resp) and $resp) { + if ($resp->status == '304' ) { + // we have the most current copy + if ( MAGPIE_DEBUG > 1) { + debug("Got 304 for $url"); + } + // reset cache on 304 (at minutillo insistent prodding) + $cache->set($url, $rss); + return $rss; + } + elseif ( is_success( $resp->status ) ) { + $rss = _response_to_rss( $resp ); + if ( $rss ) { + if (MAGPIE_DEBUG > 1) { + debug("Fetch successful"); + } + // add object to cache + $cache->set( $url, $rss ); + return $rss; + } + } + else { + $errormsg = "Failed to fetch $url. "; + if ( $resp->error ) { + # compensate for Snoopy's annoying habbit to tacking + # on '\n' + $http_error = substr($resp->error, 0, -2); + $errormsg .= "(HTTP Error: $http_error)"; + } + else { + $errormsg .= "(HTTP Response: " . $resp->response_code .')'; + } + } + } + else { + $errormsg = "Unable to retrieve RSS file for unknown reasons."; + } + + // else fetch failed + + // attempt to return cached object + if ($rss) { + if ( MAGPIE_DEBUG ) { + debug("Returning STALE object for $url"); + } + return $rss; + } + + // else we totally failed + // error( $errormsg ); + + return false; + + } // end if ( !MAGPIE_CACHE_ON ) { +} // end fetch_rss() + +function _fetch_remote_file ($url, $headers = "" ) { + // Snoopy is an HTTP client in PHP + $client = new Snoopy(); + $client->agent = MAGPIE_USER_AGENT; + $client->read_timeout = MAGPIE_FETCH_TIME_OUT; + $client->use_gzip = MAGPIE_USE_GZIP; + if (is_array($headers) ) { + $client->rawheaders = $headers; + } + + @$client->fetch($url); + return $client; + +} + +function _response_to_rss ($resp) { + $rss = new MagpieRSS( $resp->results ); + + // if RSS parsed successfully + if ( $rss and !$rss->ERROR) { + + // find Etag, and Last-Modified + foreach($resp->headers as $h) { + // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" + if (strpos($h, ": ")) { + list($field, $val) = explode(": ", $h, 2); + } + else { + $field = $h; + $val = ""; + } + + if ( $field == 'ETag' ) { + $rss->etag = $val; + } + + if ( $field == 'Last-Modified' ) { + $rss->last_modified = $val; + } + } + + return $rss; + } // else construct error message + else { + $errormsg = "Failed to parse RSS file."; + + if ($rss) { + $errormsg .= " (" . $rss->ERROR . ")"; + } + // error($errormsg); + + return false; + } // end if ($rss and !$rss->error) +} + +/*=======================================================================*\ + Function: init + Purpose: setup constants with default values + check for user overrides +\*=======================================================================*/ +function init () { + if ( defined('MAGPIE_INITALIZED') ) { + return; + } + else { + define('MAGPIE_INITALIZED', 1); + } + + if ( !defined('MAGPIE_CACHE_ON') ) { + define('MAGPIE_CACHE_ON', 1); + } + + if ( !defined('MAGPIE_CACHE_DIR') ) { + define('MAGPIE_CACHE_DIR', './cache'); + } + + if ( !defined('MAGPIE_CACHE_AGE') ) { + define('MAGPIE_CACHE_AGE', 60*60); // one hour + } + + if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) { + define('MAGPIE_CACHE_FRESH_ONLY', 0); + } + + if ( !defined('MAGPIE_DEBUG') ) { + define('MAGPIE_DEBUG', 0); + } + + if ( !defined('MAGPIE_USER_AGENT') ) { + $ua = 'WordPress/' . $wp_version; + + if ( MAGPIE_CACHE_ON ) { + $ua = $ua . ')'; + } + else { + $ua = $ua . '; No cache)'; + } + + define('MAGPIE_USER_AGENT', $ua); + } + + if ( !defined('MAGPIE_FETCH_TIME_OUT') ) { + define('MAGPIE_FETCH_TIME_OUT', 2); // 2 second timeout + } + + // use gzip encoding to fetch rss files if supported? + if ( !defined('MAGPIE_USE_GZIP') ) { + define('MAGPIE_USE_GZIP', true); + } +} + +function is_info ($sc) { + return $sc >= 100 && $sc < 200; +} + +function is_success ($sc) { + return $sc >= 200 && $sc < 300; +} + +function is_redirect ($sc) { + return $sc >= 300 && $sc < 400; +} + +function is_error ($sc) { + return $sc >= 400 && $sc < 600; +} + +function is_client_error ($sc) { + return $sc >= 400 && $sc < 500; +} + +function is_server_error ($sc) { + return $sc >= 500 && $sc < 600; +} + +class RSSCache { + var $BASE_CACHE = 'wp-content/cache'; // where the cache files are stored + var $MAX_AGE = 43200; // when are files stale, default twelve hours + var $ERROR = ''; // accumulate error messages + + function RSSCache ($base='', $age='') { + if ( $base ) { + $this->BASE_CACHE = $base; + } + if ( $age ) { + $this->MAX_AGE = $age; + } + + } + +/*=======================================================================*\ + Function: set + Purpose: add an item to the cache, keyed on url + Input: url from wich the rss file was fetched + Output: true on sucess +\*=======================================================================*/ + function set ($url, $rss) { + global $wpdb; + $cache_option = 'rss_' . $this->file_name( $url ); + $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts'; + + if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$cache_option'") ) + add_option($cache_option, '', '', 'no'); + if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$cache_timestamp'") ) + add_option($cache_timestamp, '', '', 'no'); + + update_option($cache_option, $rss); + update_option($cache_timestamp, time() ); + + return $cache_option; + } + +/*=======================================================================*\ + Function: get + Purpose: fetch an item from the cache + Input: url from wich the rss file was fetched + Output: cached object on HIT, false on MISS +\*=======================================================================*/ + function get ($url) { + $this->ERROR = ""; + $cache_option = 'rss_' . $this->file_name( $url ); + + if ( ! get_option( $cache_option ) ) { + $this->debug( + "Cache doesn't contain: $url (cache option: $cache_option)" + ); + return 0; + } + + $rss = get_option( $cache_option ); + + return $rss; + } + +/*=======================================================================*\ + Function: check_cache + Purpose: check a url for membership in the cache + and whether the object is older then MAX_AGE (ie. STALE) + Input: url from wich the rss file was fetched + Output: cached object on HIT, false on MISS +\*=======================================================================*/ + function check_cache ( $url ) { + $this->ERROR = ""; + $cache_option = $this->file_name( $url ); + $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts'; + + if ( $mtime = get_option($cache_timestamp) ) { + // find how long ago the file was added to the cache + // and whether that is longer then MAX_AGE + $age = time() - $mtime; + if ( $this->MAX_AGE > $age ) { + // object exists and is current + return 'HIT'; + } + else { + // object exists but is old + return 'STALE'; + } + } + else { + // object does not exist + return 'MISS'; + } + } + +/*=======================================================================*\ + Function: serialize +\*=======================================================================*/ + function serialize ( $rss ) { + return serialize( $rss ); + } + +/*=======================================================================*\ + Function: unserialize +\*=======================================================================*/ + function unserialize ( $data ) { + return unserialize( $data ); + } + +/*=======================================================================*\ + Function: file_name + Purpose: map url to location in cache + Input: url from wich the rss file was fetched + Output: a file name +\*=======================================================================*/ + function file_name ($url) { + return md5( $url ); + } + +/*=======================================================================*\ + Function: error + Purpose: register error +\*=======================================================================*/ + function error ($errormsg, $lvl=E_USER_WARNING) { + // append PHP's error message if track_errors enabled + if ( isset($php_errormsg) ) { + $errormsg .= " ($php_errormsg)"; + } + $this->ERROR = $errormsg; + if ( MAGPIE_DEBUG ) { + trigger_error( $errormsg, $lvl); + } + else { + error_log( $errormsg, 0); + } + } + function debug ($debugmsg, $lvl=E_USER_NOTICE) { + if ( MAGPIE_DEBUG ) { + $this->error("MagpieRSS [debug] $debugmsg", $lvl); + } + } +} + +function parse_w3cdtf ( $date_str ) { + + # regex to match wc3dtf + $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; + + if ( preg_match( $pat, $date_str, $match ) ) { + list( $year, $month, $day, $hours, $minutes, $seconds) = + array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); + + # calc epoch for current date assuming GMT + $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year); + + $offset = 0; + if ( $match[10] == 'Z' ) { + # zulu time, aka GMT + } + else { + list( $tz_mod, $tz_hour, $tz_min ) = + array( $match[8], $match[9], $match[10]); + + # zero out the variables + if ( ! $tz_hour ) { $tz_hour = 0; } + if ( ! $tz_min ) { $tz_min = 0; } + + $offset_secs = (($tz_hour*60)+$tz_min)*60; + + # is timezone ahead of GMT? then subtract offset + # + if ( $tz_mod == '+' ) { + $offset_secs = $offset_secs * -1; + } + + $offset = $offset_secs; + } + $epoch = $epoch + $offset; + return $epoch; + } + else { + return -1; + } + } +function wp_rss ($url, $num) { + //ini_set("display_errors", false); uncomment to suppress php errors thrown if the feed is not returned. + $num_items = $num; + $rss = fetch_rss($url); + if ( $rss ) { + echo ""; + } + else { + echo "an error has occured the feed is probably down, try again later."; + } +} + +function get_rss ($uri, $num = 5) { // Like get posts, but for RSS + $rss = fetch_rss($url); + if ( $rss ) { + $rss->items = array_slice($rss->items, 0, $num_items); + foreach ($rss->items as $item ) { + echo "
  • \n"; + echo ""; + echo htmlentities($item['title']); + echo "
    \n"; + echo "
  • \n"; + } + return $posts; + } else { + return false; + } +} +?> \ No newline at end of file diff --git a/wp-includes/streams.php b/wp-includes/streams.php new file mode 100644 index 00000000..c69841ed --- /dev/null +++ b/wp-includes/streams.php @@ -0,0 +1,159 @@ +. + + This file is part of PHP-gettext. + + PHP-gettext is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PHP-gettext is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PHP-gettext; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + + +// Simple class to wrap file streams, string streams, etc. +// seek is essential, and it should be byte stream +class StreamReader { + // should return a string [FIXME: perhaps return array of bytes?] + function read($bytes) { + return false; + } + + // should return new position + function seekto($position) { + return false; + } + + // returns current position + function currentpos() { + return false; + } + + // returns length of entire stream (limit for seekto()s) + function length() { + return false; + } +} + +class StringReader { + var $_pos; + var $_str; + + function StringReader($str='') { + $this->_str = $str; + $this->_pos = 0; + } + + function read($bytes) { + $data = substr($this->_str, $this->_pos, $bytes); + $this->_pos += $bytes; + if (strlen($this->_str)<$this->_pos) + $this->_pos = strlen($this->_str); + + return $data; + } + + function seekto($pos) { + $this->_pos = $pos; + if (strlen($this->_str)<$this->_pos) + $this->_pos = strlen($this->_str); + return $this->_pos; + } + + function currentpos() { + return $this->_pos; + } + + function length() { + return strlen($this->_str); + } + +} + + +class FileReader { + var $_pos; + var $_fd; + var $_length; + + function FileReader($filename) { + if (file_exists($filename)) { + + $this->_length=filesize($filename); + $this->_pos = 0; + $this->_fd = fopen($filename,'rb'); + if (!$this->_fd) { + $this->error = 3; // Cannot read file, probably permissions + return false; + } + } else { + $this->error = 2; // File doesn't exist + return false; + } + } + + function read($bytes) { + if ($bytes) { + fseek($this->_fd, $this->_pos); + $data = fread($this->_fd, $bytes); + $this->_pos = ftell($this->_fd); + + return $data; + } else return ''; + } + + function seekto($pos) { + fseek($this->_fd, $pos); + $this->_pos = ftell($this->_fd); + return $this->_pos; + } + + function currentpos() { + return $this->_pos; + } + + function length() { + return $this->_length; + } + + function close() { + fclose($this->_fd); + } + +} + +// Preloads entire file in memory first, then creates a StringReader +// over it (it assumes knowledge of StringReader internals) +class CachedFileReader extends StringReader { + function CachedFileReader($filename) { + if (file_exists($filename)) { + + $length=filesize($filename); + $fd = fopen($filename,'rb'); + + if (!$fd) { + $this->error = 3; // Cannot read file, probably permissions + return false; + } + $this->_str = fread($fd, $length); + fclose($fd); + + } else { + $this->error = 2; // File doesn't exist + return false; + } + } +} + + +?> \ No newline at end of file diff --git a/wp-includes/template-functions-author.php b/wp-includes/template-functions-author.php new file mode 100644 index 00000000..4f443b38 --- /dev/null +++ b/wp-includes/template-functions-author.php @@ -0,0 +1,234 @@ +display_name); +} + +function the_author($idmode = '', $echo = true) { + if ( $echo ) + echo get_the_author($idmode); + return get_the_author($idmode); +} + +function get_the_author_description() { + global $authordata; + return $authordata->description; +} +function the_author_description() { + echo get_the_author_description(); +} + +function get_the_author_login() { + global $authordata; + return $authordata->user_login; +} + +function the_author_login() { + echo get_the_author_login(); +} + +function get_the_author_firstname() { + global $authordata; + return $authordata->first_name; +} +function the_author_firstname() { + echo get_the_author_firstname(); +} + +function get_the_author_lastname() { + global $authordata; + return $authordata->last_name; +} + +function the_author_lastname() { + echo get_the_author_lastname(); +} + +function get_the_author_nickname() { + global $authordata; + return $authordata->nickname; +} + +function the_author_nickname() { + echo get_the_author_nickname(); +} + +function get_the_author_ID() { + global $authordata; + return $authordata->ID; +} +function the_author_ID() { + echo get_the_author_id(); +} + +function get_the_author_email() { + global $authordata; + return $authordata->user_email; +} + +function the_author_email() { + echo apply_filters('the_author_email', get_the_author_email() ); +} + +function get_the_author_url() { + global $authordata; + return $authordata->user_url; +} + +function the_author_url() { + echo get_the_author_url(); +} + +function get_the_author_icq() { + global $authordata; + return $authordata->icq; +} + +function the_author_icq() { + echo get_the_author_icq(); +} + +function get_the_author_aim() { + global $authordata; + return str_replace(' ', '+', $authordata->aim); +} + +function the_author_aim() { + echo get_the_author_aim(); +} + +function get_the_author_yim() { + global $authordata; + return $authordata->yim; +} + +function the_author_yim() { + echo get_the_author_yim(); +} + +function get_the_author_msn() { + global $authordata; + return $authordata->msn; +} + +function the_author_msn() { + echo get_the_author_msn(); +} + +function get_the_author_posts() { + global $post; + $posts = get_usernumposts($post->post_author); + return $posts; +} + +function the_author_posts() { + echo get_the_author_posts(); +} + +/* the_author_posts_link() requires no get_, use get_author_link() */ +function the_author_posts_link($idmode='') { + global $authordata; + + echo '' . the_author($idmode, false) . ''; +} + +function get_author_link($echo = false, $author_id, $author_nicename) { + global $wpdb, $wp_rewrite, $post, $cache_userdata; + $auth_ID = $author_id; + $link = $wp_rewrite->get_author_permastruct(); + + if ( empty($link) ) { + $file = get_settings('home') . '/'; + $link = $file . '?author=' . $auth_ID; + } else { + if ( '' == $author_nicename ) + $author_nicename = $cache_userdata[$author_id]->user_nicename; + $link = str_replace('%author%', $author_nicename, $link); + $link = get_settings('home') . trailingslashit($link); + } + + $link = apply_filters('author_link', $link, $author_id, $author_nicename); + + if ( $echo ) + echo $link; + return $link; +} + +function wp_list_authors($args = '') { + parse_str($args, $r); + + if ( !isset($r['optioncount']) ) + $r['optioncount'] = false; + if ( !isset($r['exclude_admin']) ) + $r['exclude_admin'] = true; + if ( !isset($r['show_fullname']) ) + $r['show_fullname'] = false; + if ( !isset($r['hide_empty']) ) + $r['hide_empty'] = true; + if ( !isset($r['feed']) ) + $r['feed'] = ''; + if ( !isset($r['feed_image']) ) + $r['feed_image'] = ''; + + list_authors($r['optioncount'], $r['exclude_admin'], $r['show_fullname'], $r['hide_empty'], $r['feed'], $r['feed_image']); +} + +function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { + global $wpdb; + $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"; + $authors = $wpdb->get_results($query); + + foreach ( $authors as $author ) { + $author = get_userdata( $author->ID ); + $posts = get_usernumposts($author->ID); + $name = $author->nickname; + + if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) + $name = "$author->first_name $author->last_name"; + + if ( !($posts == 0 && $hide_empty) ) + echo "
  • "; + if ( $posts == 0 ) { + if ( !$hide_empty ) + $link = $name; + } else { + $link = 'display_name)) . '">' . $name . ''; + + if ( (! empty($feed_image)) || (! empty($feed)) ) { + $link .= ' '; + if (empty($feed_image)) + $link .= '('; + $link .= ''; + else + $link .= $name; + + $link .= ''; + + if ( empty($feed_image) ) + $link .= ')'; + } + + if ( $optioncount ) + $link .= ' ('. $posts . ')'; + + } + + if ( !($posts == 0 && $hide_empty) ) + echo "$link
  • "; + } +} + +?> \ No newline at end of file diff --git a/wp-includes/template-functions-category.php b/wp-includes/template-functions-category.php new file mode 100644 index 00000000..1858bec4 --- /dev/null +++ b/wp-includes/template-functions-category.php @@ -0,0 +1,415 @@ +ID; + + if ( !isset($category_cache[$id]) ) + update_post_category_cache($id); + + $categories = $category_cache[$id]; + + if ( !empty($categories) ) + sort($categories); + else + $categories = array(); + + return $categories; +} + +function get_category_link($category_id) { + global $wp_rewrite; + $catlink = $wp_rewrite->get_category_permastruct(); + + if ( empty($catlink) ) { + $file = get_settings('home') . '/'; + $catlink = $file . '?cat=' . $category_id; + } else { + $category = &get_category($category_id); + $category_nicename = $category->category_nicename; + + if ( $parent = $category->category_parent ) + $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/'; + + $catlink = str_replace('%category%', $category_nicename, $catlink); + $catlink = get_settings('home') . trailingslashit($catlink); + } + return apply_filters('category_link', $catlink, $category_id); +} + +function get_the_category_list($separator = '', $parents='') { + $categories = get_the_category(); + if (empty($categories)) + return apply_filters('the_category', __('Uncategorized'), $separator, $parents); + + $thelist = ''; + if ( '' == $separator ) { + $thelist .= ''; + } else { + $i = 0; + foreach ( $categories as $category ) { + $category->cat_name = $category->cat_name; + if ( 0 < $i ) + $thelist .= $separator . ' '; + switch ( strtolower($parents) ) { + case 'multiple': + if ( $category->category_parent ) + $thelist .= get_category_parents($category->category_parent, TRUE); + $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.''; + break; + case 'single': + $thelist .= 'cat_name) . '" rel="category tag">'; + if ( $category->category_parent ) + $thelist .= get_category_parents($category->category_parent, FALSE); + $thelist .= "$category->cat_name"; + break; + case '': + default: + $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.''; + } + ++$i; + } + } + return apply_filters('the_category', $thelist, $separator, $parents); +} + +function the_category($separator = '', $parents='') { + echo get_the_category_list($separator, $parents); +} + +function get_the_category_by_ID($cat_ID) { + $cat_ID = (int) $cat_ID; + $category = &get_category($cat_ID); + return $category->cat_name; +} + +function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){ + $chain = ''; + $parent = &get_category($id); + + if ( $nicename ) + $name = $parent->category_nicename; + else + $name = $parent->cat_name; + + if ( $parent->category_parent ) + $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename); + + if ( $link ) + $chain .= 'cat_name) . '">'.$name.'' . $separator; + else + $chain .= $name.$separator; + return $chain; +} + +function get_category_children($id, $before = '/', $after = '') { + if ( 0 == $id ) + return ''; + + $cat_ids = get_all_category_ids(); + foreach ( $cat_ids as $cat_id ) { + if ( $cat_id == $id) + continue; + + $category = get_category($cat_id); + if ( $category->category_parent == $id ) { + $chain .= $before.$category->cat_ID.$after; + $chain .= get_category_children($category->cat_ID, $before, $after); + } + } + return $chain; +} + +// Deprecated. +function the_category_ID($echo = true) { + // Grab the first cat in the list. + $categories = get_the_category(); + $cat = $categories[0]->cat_ID; + + if ( $echo ) + echo $cat; + + return $cat; +} + +// Deprecated. +function the_category_head($before='', $after='') { + global $currentcat, $previouscat; + // Grab the first cat in the list. + $categories = get_the_category(); + $currentcat = $categories[0]->category_id; + if ( $currentcat != $previouscat ) { + echo $before; + echo get_the_category_by_ID($currentcat); + echo $after; + $previouscat = $currentcat; + } +} + +function category_description($category = 0) { + global $cat; + if ( !$category ) + $category = $cat; + $category = & get_category($category); + return apply_filters('category_description', $category->category_description, $category->cat_ID); +} + +// out of the WordPress loop +function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', + $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE, + $selected=0, $hide=0) { + global $wpdb; + if ( ($file == 'blah') || ($file == '') ) + $file = get_settings('home') . '/'; + if ( !$selected ) + $selected=$cat; + $sort_column = 'cat_'.$sort_column; + + $query = " + SELECT cat_ID, cat_name, category_nicename,category_parent, + COUNT($wpdb->post2cat.post_id) AS cat_count, + DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth + FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id) + LEFT JOIN $wpdb->posts ON (ID = post_id) + WHERE cat_ID > 0 + "; + if ( $hide ) { + $query .= " AND cat_ID != $hide"; + $query .= get_category_children($hide, " AND cat_ID != "); + } + $query .=" GROUP BY cat_ID"; + if ( intval($hide_empty) == 1 ) + $query .= " HAVING cat_count > 0"; + $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; + + $categories = $wpdb->get_results($query); + echo "\n"; +} + +// out of the WordPress loop +function wp_list_cats($args = '') { + parse_str($args, $r); + if ( !isset($r['optionall'])) + $r['optionall'] = 0; + if ( !isset($r['all'])) + $r['all'] = 'All'; + if ( !isset($r['sort_column']) ) + $r['sort_column'] = 'ID'; + if ( !isset($r['sort_order']) ) + $r['sort_order'] = 'asc'; + if ( !isset($r['file']) ) + $r['file'] = ''; + if ( !isset($r['list']) ) + $r['list'] = true; + if ( !isset($r['optiondates']) ) + $r['optiondates'] = 0; + if ( !isset($r['optioncount']) ) + $r['optioncount'] = 0; + if ( !isset($r['hide_empty']) ) + $r['hide_empty'] = 1; + if ( !isset($r['use_desc_for_title']) ) + $r['use_desc_for_title'] = 1; + if ( !isset($r['children']) ) + $r['children'] = true; + if ( !isset($r['child_of']) ) + $r['child_of'] = 0; + if ( !isset($r['categories']) ) + $r['categories'] = 0; + if ( !isset($r['recurse']) ) + $r['recurse'] = 0; + if ( !isset($r['feed']) ) + $r['feed'] = ''; + if ( !isset($r['feed_image']) ) + $r['feed_image'] = ''; + if ( !isset($r['exclude']) ) + $r['exclude'] = ''; + if ( !isset($r['hierarchical']) ) + $r['hierarchical'] = true; + + return list_cats($r['optionall'], $r['all'], $r['sort_column'], $r['sort_order'], $r['file'], $r['list'], $r['optiondates'], $r['optioncount'], $r['hide_empty'], $r['use_desc_for_title'], $r['children'], $r['child_of'], $r['categories'], $r['recurse'], $r['feed'], $r['feed_image'], $r['exclude'], $r['hierarchical']); +} + +function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE) { + global $wpdb, $wp_query; + // Optiondates now works + if ( '' == $file ) + $file = get_settings('home') . '/'; + + $exclusions = ''; + if ( !empty($exclude) ) { + $excats = preg_split('/[\s,]+/',$exclude); + if ( count($excats) ) { + foreach ( $excats as $excat ) { + $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' '; + } + } + } + + $exclusions = apply_filters('list_cats_exclusions', $exclusions ); + + if ( intval($categories) == 0 ) { + $sort_column = 'cat_'.$sort_column; + + $query = " + SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, category_count + FROM $wpdb->categories + WHERE cat_ID > 0 $exclusions + ORDER BY $sort_column $sort_order"; + + $categories = $wpdb->get_results($query); + } + + if ( $optiondates ) { + $cat_dates = $wpdb->get_results(" SELECT category_id, + UNIX_TIMESTAMP( MAX(post_date) ) AS ts + FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories + WHERE post_status = 'publish' AND post_id = ID $exclusions + GROUP BY category_id"); + foreach ( $cat_dates as $cat_date ) { + $category_timestamp["$cat_date->category_id"] = $cat_date->ts; + } + } + + $num_found=0; + $thelist = ""; + + foreach ( $categories as $category ) { + if ( ( intval($hide_empty) == 0 || $category->category_count) && (!$hierarchical || $category->category_parent == $child_of) ) { + $num_found++; + $link = 'category_description) ) + $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"'; + else + $link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category)) . '"'; + $link .= '>'; + $link .= apply_filters('list_cats', $category->cat_name, $category).''; + + if ( (! empty($feed_image)) || (! empty($feed)) ) { + + $link .= ' '; + + if ( empty($feed_image) ) + $link .= '('; + + $link .= ''; + else + $link .= $name; + + $link .= ''; + + if (empty($feed_image)) + $link .= ')'; + } + + if ( intval($optioncount) == 1 ) + $link .= ' ('.intval($category->category_count).')'; + + if ( $optiondates ) { + if ( $optiondates == 1 ) + $optiondates = 'Y-m-d'; + $link .= ' ' . gmdate($optiondates, $category_timestamp["$category->cat_ID"]); + } + + if ( $list ) { + $thelist .= "\tcat_ID == $wp_query->get_queried_object_id()) && is_category()) { + $thelist .= ' class="current-cat"'; + } + $thelist .= ">$link\n"; + } else { + $thelist .= "\t$link
    \n"; + } + + if ($hierarchical && $children) + $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categories, 1, $feed, $feed_image, $exclude, $hierarchical); + if ($list) + $thelist .= "\n"; + } + } + if ( !$num_found && !$child_of ) { + if ( $list ) { + $before = '
  • '; + $after = '
  • '; + } + echo $before . __("No categories") . $after . "\n"; + return; + } + if ( $list && $child_of && $num_found && $recurse ) { + $pre = "\t\t
      "; + $post = "\t\t
    \n"; + } else { + $pre = $post = ''; + } + $thelist = $pre . $thelist . $post; + if ( $recurse ) + return $thelist; + echo apply_filters('list_cats', $thelist); +} + +function in_category($category) { // Check if the current post is in the given category + global $category_cache, $post; + + if ( isset( $category_cache[$post->ID][$category] ) ) + return true; + else + return false; +} + +?> diff --git a/wp-includes/template-functions-general.php b/wp-includes/template-functions-general.php new file mode 100644 index 00000000..b52b4167 --- /dev/null +++ b/wp-includes/template-functions-general.php @@ -0,0 +1,707 @@ +' . __('Login') . ''; + else + $link = '' . __('Logout') . ''; + + echo apply_filters('loginout', $link); +} + + +function wp_register( $before = '
  • ', $after = '
  • ' ) { + global $user_ID; + + get_currentuserinfo(); + + if ( '' == $user_ID && get_settings('users_can_register') ) + $link = $before . '' . __('Register') . '' . $after; + elseif ( '' == $user_ID && !get_settings('users_can_register') ) + $link = ''; + else + $link = $before . '' . __('Site Admin') . '' . $after; + + echo apply_filters('register', $link); +} + + +function wp_meta() { + do_action('wp_meta'); +} + + +function bloginfo($show='') { + $info = get_bloginfo($show); + if ( ! (strstr($info, 'url') || strstr($info, 'directory')) ) { + $info = apply_filters('bloginfo', $info, $show); + $info = convert_chars($info); + } + + echo $info; +} + + +function get_bloginfo($show='') { + + switch($show) { + case 'url' : + case 'home' : + case 'siteurl' : + $output = get_settings('home'); + break; + case 'wpurl' : + $output = get_settings('siteurl'); + break; + case 'description': + $output = get_settings('blogdescription'); + break; + case 'rdf_url': + $output = get_feed_link('rdf'); + break; + case 'rss_url': + $output = get_feed_link('rss'); + break; + case 'rss2_url': + $output = get_feed_link('rss2'); + break; + case 'atom_url': + $output = get_feed_link('atom'); + break; + case 'comments_rss2_url': + $output = get_feed_link('comments_rss2'); + break; + case 'pingback_url': + $output = get_settings('siteurl') .'/xmlrpc.php'; + break; + case 'stylesheet_url': + $output = get_stylesheet_uri(); + break; + case 'stylesheet_directory': + $output = get_stylesheet_directory_uri(); + break; + case 'template_directory': + case 'template_url': + $output = get_template_directory_uri(); + break; + case 'admin_email': + $output = get_settings('admin_email'); + break; + case 'charset': + $output = get_settings('blog_charset'); + if ('' == $output) $output = 'UTF-8'; + break; + case 'html_type' : + $output = get_option('html_type'); + break; + case 'version': + global $wp_version; + $output = $wp_version; + break; + case 'name': + default: + $output = get_settings('blogname'); + break; + } + return $output; +} + + +function wp_title($sep = '»', $display = true) { + global $wpdb; + global $m, $year, $monthnum, $day, $category_name, $month, $posts; + + $cat = get_query_var('cat'); + $p = get_query_var('p'); + $name = get_query_var('name'); + $category_name = get_query_var('category_name'); + $author = get_query_var('author'); + $author_name = get_query_var('author_name'); + + // If there's a category + if ( !empty($cat) ) { + // category exclusion + if ( !stristr($cat,'-') ) + $title = get_the_category_by_ID($cat); + } + if ( !empty($category_name) ) { + if ( stristr($category_name,'/') ) { + $category_name = explode('/',$category_name); + if ( $category_name[count($category_name)-1] ) + $category_name = $category_name[count($category_name)-1]; // no trailing slash + else + $category_name = $category_name[count($category_name)-2]; // there was a trailling slash + } + $title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'"); + } + + // If there's an author + if ( !empty($author) ) { + $title = get_userdata($author); + $title = $title->display_name; + } + if ( !empty($author_name) ) { + // We do a direct query here because we don't cache by nicename. + $title = $wpdb->get_var("SELECT display_name FROM $wpdb->users WHERE user_nicename = '$author_name'"); + } + + // If there's a month + if ( !empty($m) ) { + $my_year = substr($m, 0, 4); + $my_month = $month[substr($m, 4, 2)]; + $title = "$my_year $sep $my_month"; + } + + if ( !empty($year) ) { + $title = $year; + if ( !empty($monthnum) ) + $title .= " $sep ".$month[zeroise($monthnum, 2)]; + if ( !empty($day) ) + $title .= " $sep ".zeroise($day, 2); + } + + // If there is a post + if ( is_single() || is_page() ) { + $title = strip_tags($posts[0]->post_title); + $title = apply_filters('single_post_title', $title); + } + + $prefix = ''; + if ( isset($title) ) + $prefix = " $sep "; + + $title = $prefix . $title; + $title = apply_filters('wp_title', $title, $sep); + + // Send it out + if ( $display ) + echo $title; + else + return $title; +} + + +function single_post_title($prefix = '', $display = true) { + global $wpdb; + $p = get_query_var('p'); + $name = get_query_var('name'); + + if ( intval($p) || '' != $name ) { + if ( !$p ) + $p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$name'"); + $post = & get_post($p); + $title = $post->post_title; + $title = apply_filters('single_post_title', $title); + if ( $display ) + echo $prefix.strip_tags($title); + else + return strip_tags($title); + } +} + + +function single_cat_title($prefix = '', $display = true ) { + $cat = intval( get_query_var('cat') ); + if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) { + $my_cat_name = get_the_category_by_ID($cat); + if ( !empty($my_cat_name) ) { + if ( $display ) + echo $prefix.strip_tags($my_cat_name); + else + return strip_tags($my_cat_name); + } + } +} + + +function single_month_title($prefix = '', $display = true ) { + global $m, $monthnum, $month, $year; + if ( !empty($monthnum) && !empty($year) ) { + $my_year = $year; + $my_month = $month[str_pad($monthnum, 2, '0', STR_PAD_LEFT)]; + } elseif ( !empty($m) ) { + $my_year = substr($m, 0, 4); + $my_month = $month[substr($m, 4, 2)]; + } + + if ( !empty($my_month) && $display ) + echo $prefix . $my_month . $prefix . $my_year; + else + return $monthnum; +} + + +/* link navigation hack by Orien http://icecode.com/ */ +function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') { + $text = wptexturize($text); + $title_text = wp_specialchars($text, 1); + + if ('link' == $format) + return "\t\n"; + elseif ('option' == $format) + return "\t\n"; + elseif ('html' == $format) + return "\t
  • $before$text$after
  • \n"; + else // custom + return "\t$before$text$after\n"; +} + + +function wp_get_archives($args = '') { + parse_str($args, $r); + if ( !isset($r['type']) ) + $r['type'] = ''; + if ( !isset($r['limit']) ) + $r['limit'] = ''; + if ( !isset($r['format']) ) + $r['format'] = 'html'; + if ( !isset($r['before']) ) + $r['before'] = ''; + if ( !isset($r['after']) ) + $r['after'] = ''; + if ( !isset($r['show_post_count']) ) + $r['show_post_count'] = false; + + get_archives($r['type'], $r['limit'], $r['format'], $r['before'], $r['after'], $r['show_post_count']); +} + + +function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { + global $month, $wpdb; + + if ( '' == $type ) + $type = 'monthly'; + + if ( '' != $limit ) { + $limit = (int) $limit; + $limit = ' LIMIT '.$limit; + } + // this is what will separate dates on weekly archive links + $archive_week_separator = '–'; + + // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride + $archive_date_format_over_ride = 0; + + // options for daily archive (only if you over-ride the general date format) + $archive_day_date_format = 'Y/m/d'; + + // options for weekly archive (only if you over-ride the general date format) + $archive_week_start_date_format = 'Y/m/d'; + $archive_week_end_date_format = 'Y/m/d'; + + if ( !$archive_date_format_over_ride ) { + $archive_day_date_format = get_settings('date_format'); + $archive_week_start_date_format = get_settings('date_format'); + $archive_week_end_date_format = get_settings('date_format'); + } + + $add_hours = intval(get_settings('gmt_offset')); + $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours)); + + $now = current_time('mysql'); + + if ( 'monthly' == $type ) { + $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); + if ( $arcresults ) { + $afterafter = $after; + foreach ( $arcresults as $arcresult ) { + $url = get_month_link($arcresult->year, $arcresult->month); + if ( $show_post_count ) { + $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year); + $after = ' ('.$arcresult->posts.')' . $afterafter; + } else { + $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year); + } + echo get_archives_link($url, $text, $format, $before, $after); + } + } + } elseif ( 'daily' == $type ) { + $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); + if ( $arcresults ) { + foreach ( $arcresults as $arcresult ) { + $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth); + $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth); + $text = mysql2date($archive_day_date_format, $date); + echo get_archives_link($url, $text, $format, $before, $after); + } + } + } elseif ( 'weekly' == $type ) { + $start_of_week = get_settings('start_of_week'); + $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); + $arc_w_last = ''; + if ( $arcresults ) { + foreach ( $arcresults as $arcresult ) { + if ( $arcresult->week != $arc_w_last ) { + $arc_year = $arcresult->yr; + $arc_w_last = $arcresult->week; + $arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week')); + $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']); + $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']); + $url = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('home'), '', '?', '=', $arc_year, '&', '=', $arcresult->week); + $text = $arc_week_start . $archive_week_separator . $arc_week_end; + echo get_archives_link($url, $text, $format, $before, $after); + } + } + } + } elseif ( 'postbypost' == $type ) { + $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); + if ( $arcresults ) { + foreach ( $arcresults as $arcresult ) { + if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { + $url = get_permalink($arcresult); + $arc_title = $arcresult->post_title; + if ( $arc_title ) + $text = strip_tags($arc_title); + else + $text = $arcresult->ID; + echo get_archives_link($url, $text, $format, $before, $after); + } + } + } + } +} + + +// Used in get_calendar +function calendar_week_mod($num) { + $base = 7; + return ($num - $base*floor($num/$base)); +} + + +function get_calendar($daylength = 1) { + global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts; + + // Quick check. If we have no posts at all, abort! + if ( !$posts ) { + $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); + if ( !$gotsome ) + return; + } + + if ( isset($_GET['w']) ) + $w = ''.intval($_GET['w']); + + // week_begins = 0 stands for Sunday + $week_begins = intval(get_settings('start_of_week')); + $add_hours = intval(get_settings('gmt_offset')); + $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours)); + + // Let's figure out when we are + if ( !empty($monthnum) && !empty($year) ) { + $thismonth = ''.zeroise(intval($monthnum), 2); + $thisyear = ''.intval($year); + } elseif ( !empty($w) ) { + // We need to get the month from MySQL + $thisyear = ''.intval(substr($m, 0, 4)); + $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's + $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); + } elseif ( !empty($m) ) { + $calendar = substr($m, 0, 6); + $thisyear = ''.intval(substr($m, 0, 4)); + if ( strlen($m) < 6 ) + $thismonth = '01'; + else + $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2); + } else { + $thisyear = gmdate('Y', current_time('timestamp') + get_settings('gmt_offset') * 3600); + $thismonth = gmdate('m', current_time('timestamp') + get_settings('gmt_offset') * 3600); + } + + $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); + + // Get the next and previous month and year with at least one post + $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year + FROM $wpdb->posts + WHERE post_date < '$thisyear-$thismonth-01' + AND post_status = 'publish' + ORDER BY post_date DESC + LIMIT 1"); + $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year + FROM $wpdb->posts + WHERE post_date > '$thisyear-$thismonth-01' + AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) + AND post_status = 'publish' + ORDER BY post_date ASC + LIMIT 1"); + + echo ' + + + '; + + $day_abbrev = $weekday_initial; + if ( $daylength > 1 ) + $day_abbrev = $weekday_abbrev; + + $myweek = array(); + + for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { + $myweek[]=$weekday[($wdcount+$week_begins)%7]; + } + + foreach ( $myweek as $wd ) { + echo "\n\t\t'; + } + + echo ' + + + + + '; + + if ( $previous ) { + echo "\n\t\t".''; + } else { + echo "\n\t\t".''; + } + + echo "\n\t\t".''; + + if ( $next ) { + echo "\n\t\t".''; + } else { + echo "\n\t\t".''; + } + + echo ' + + + + + '; + + // Get days with posts + $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) + FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth + AND YEAR(post_date) = $thisyear + AND post_status = 'publish' + AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); + if ( $dayswithposts ) { + foreach ( $dayswithposts as $daywith ) { + $daywithpost[] = $daywith[0]; + } + } else { + $daywithpost = array(); + } + + + + if ( strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') ) + $ak_title_separator = "\n"; + else + $ak_title_separator = ', '; + + $ak_titles_for_day = array(); + $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " + ."FROM $wpdb->posts " + ."WHERE YEAR(post_date) = '$thisyear' " + ."AND MONTH(post_date) = '$thismonth' " + ."AND post_date < '".current_time('mysql')."' " + ."AND post_status = 'publish'" + ); + if ( $ak_post_titles ) { + foreach ( $ak_post_titles as $ak_post_title ) { + if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) + $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; + if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one + $ak_titles_for_day["$ak_post_title->dom"] = str_replace('"', '"', wptexturize($ak_post_title->post_title)); + else + $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . str_replace('"', '"', wptexturize($ak_post_title->post_title)); + } + } + + + // See how much we should pad in the beginning + $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); + if ( 0 != $pad ) + echo "\n\t\t".''; + + $daysinmonth = intval(date('t', $unixmonth)); + for ( $day = 1; $day <= $daysinmonth; ++$day ) { + if ( isset($newrow) && $newrow ) + echo "\n\t\n\t\n\t\t"; + $newrow = false; + + if ( $day == gmdate('j', (time() + (get_settings('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_settings('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_settings('gmt_offset') * 3600)) ) + echo ''; + + if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) + $newrow = true; + } + + $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); + if ( $pad != 0 && $pad != 7 ) + echo "\n\t\t".''; + + echo "\n\t\n\t\n\t
    ' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '
    " . $day_abbrev[$wd] . '
    « ' . $month_abbrev[$month[zeroise($previous->month, 2)]] . '  ' . $month_abbrev[$month[zeroise($next->month, 2)]] . ' » 
     
    '; + else + echo ''; + + if ( in_array($day, $daywithpost) ) // any posts today? + echo '$day"; + else + echo $day; + echo ' 
    "; +} + + +function allowed_tags() { + global $allowedtags; + $allowed = ''; + foreach ( $allowedtags as $tag => $attributes ) { + $allowed .= '<'.$tag; + if ( 0 < count($attributes) ) { + foreach ( $attributes as $attribute => $limits ) { + $allowed .= ' '.$attribute.'=""'; + } + } + $allowed .= '> '; + } + return htmlentities($allowed); +} + + +/***** Date/Time tags *****/ + + +function the_date_xml() { + global $post; + echo mysql2date('Y-m-d', $post->post_date); + //echo ""+$post->post_date; +} + + +function the_date($d='', $before='', $after='', $echo = true) { + global $id, $post, $day, $previousday, $newday; + $the_date = ''; + if ( $day != $previousday ) { + $the_date .= $before; + if ( $d=='' ) + $the_date .= mysql2date(get_settings('date_format'), $post->post_date); + else + $the_date .= mysql2date($d, $post->post_date); + $the_date .= $after; + $previousday = $day; + } + $the_date = apply_filters('the_date', $the_date, $d, $before, $after); + if ( $echo ) + echo $the_date; + else + return $the_date; +} + + +function the_time( $d = '' ) { + echo apply_filters('the_time', get_the_time( $d ), $d); +} + + +function get_the_time( $d = '' ) { + if ( '' == $d ) + $the_time = get_post_time(get_settings('time_format')); + else + $the_time = get_post_time($d); + return apply_filters('get_the_time', $the_time, $d); +} + + +function get_post_time( $d = 'U', $gmt = false ) { // returns timestamp + global $post; + if ( $gmt ) + $time = $post->post_date_gmt; + else + $time = $post->post_date; + + $time = mysql2date($d, $time); + return apply_filters('get_the_time', $time, $d, $gmt); +} + + +function the_modified_time($d = '') { + echo apply_filters('the_modified_time', get_the_modified_time($d), $d); +} + + +function get_the_modified_time($d = '') { + if ( '' == $d ) + $the_time = get_post_modified_time(get_settings('time_format')); + else + $the_time = get_post_modified_time($d); + return apply_filters('get_the_modified_time', $the_time, $d); +} + + +function get_post_modified_time( $d = 'U', $gmt = false ) { // returns timestamp + global $post; + + if ( $gmt ) + $time = $post->post_modified_gmt; + else + $time = $post->post_modified; + $time = mysql2date($d, $time); + + return apply_filters('get_the_modified_time', $time, $d, $gmt); +} + + +function the_weekday() { + global $weekday, $id, $post; + $the_weekday = $weekday[mysql2date('w', $post->post_date)]; + $the_weekday = apply_filters('the_weekday', $the_weekday); + echo $the_weekday; +} + + +function the_weekday_date($before='',$after='') { + global $weekday, $id, $post, $day, $previousweekday; + $the_weekday_date = ''; + if ( $day != $previousweekday ) { + $the_weekday_date .= $before; + $the_weekday_date .= $weekday[mysql2date('w', $post->post_date)]; + $the_weekday_date .= $after; + $previousweekday = $day; + } + $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after); + echo $the_weekday_date; +} + +function rsd_link() { + echo '\n"; +} + +?> diff --git a/wp-includes/template-functions-links.php b/wp-includes/template-functions-links.php new file mode 100644 index 00000000..9ec7b331 --- /dev/null +++ b/wp-includes/template-functions-links.php @@ -0,0 +1,526 @@ +post_title) . '-' . $id; + echo ''; + break; + case 'id': + default: + echo ''; + break; + } +} + + +function get_permalink($id = 0) { + $rewritecode = array( + '%year%', + '%monthnum%', + '%day%', + '%hour%', + '%minute%', + '%second%', + '%postname%', + '%post_id%', + '%category%', + '%author%', + '%pagename%' + ); + + $post = &get_post($id); + if ( $post->post_status == 'static' ) + return get_page_link($post->ID); + elseif ($post->post_status == 'attachment') + return get_attachment_link($post->ID); + + $permalink = get_settings('permalink_structure'); + + if ( '' != $permalink && 'draft' != $post->post_status ) { + $unixtime = strtotime($post->post_date); + + $category = ''; + if ( strstr($permalink, '%category%') ) { + $cats = get_the_category($post->ID); + $category = $cats[0]->category_nicename; + if ( $parent=$cats[0]->category_parent ) + $category = get_category_parents($parent, FALSE, '/', TRUE) . $category; + } + + $authordata = get_userdata($post->post_author); + $author = $authordata->user_nicename; + $rewritereplace = + array( + date('Y', $unixtime), + date('m', $unixtime), + date('d', $unixtime), + date('H', $unixtime), + date('i', $unixtime), + date('s', $unixtime), + $post->post_name, + $post->ID, + $category, + $author, + $post->post_name, + ); + return apply_filters('post_link', get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post); + } else { // if they're not using the fancy permalink option + $permalink = get_settings('home') . '/?p=' . $post->ID; + return apply_filters('post_link', $permalink, $post); + } +} + +function get_page_link($id = false) { + global $post, $wp_rewrite; + + if ( !$id ) + $id = $post->ID; + + $pagestruct = $wp_rewrite->get_page_permastruct(); + + if ( '' != $pagestruct ) { + $link = get_page_uri($id); + $link = str_replace('%pagename%', $link, $pagestruct); + $link = get_settings('home') . "/$link/"; + } else { + $link = get_settings('home') . "/?page_id=$id"; + } + + return apply_filters('page_link', $link, $id); +} + +function get_attachment_link($id = false) { + global $post, $wp_rewrite; + + $link = false; + + if (! $id) { + $id = $post->ID; + } + + $object = get_post($id); + if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) ) { + $parent = get_post($object->post_parent); + $parentlink = get_permalink($object->post_parent); + if (! strstr($parentlink, '?') ) + $link = trim($parentlink, '/') . '/' . $object->post_name . '/'; + } + + if (! $link ) { + $link = get_bloginfo('home') . "/?attachment_id=$id"; + } + + return apply_filters('attachment_link', $link, $id); +} + +function get_year_link($year) { + global $wp_rewrite; + if ( !$year ) + $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600)); + $yearlink = $wp_rewrite->get_year_permastruct(); + if ( !empty($yearlink) ) { + $yearlink = str_replace('%year%', $year, $yearlink); + return apply_filters('year_link', get_settings('home') . trailingslashit($yearlink), $year); + } else { + return apply_filters('year_link', get_settings('home') . '/?m=' . $year, $year); + } +} + +function get_month_link($year, $month) { + global $wp_rewrite; + if ( !$year ) + $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600)); + if ( !$month ) + $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600)); + $monthlink = $wp_rewrite->get_month_permastruct(); + if ( !empty($monthlink) ) { + $monthlink = str_replace('%year%', $year, $monthlink); + $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); + return apply_filters('month_link', get_settings('home') . trailingslashit($monthlink), $year, $month); + } else { + return apply_filters('month_link', get_settings('home') . '/?m=' . $year . zeroise($month, 2), $year, $month); + } +} + +function get_day_link($year, $month, $day) { + global $wp_rewrite; + if ( !$year ) + $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600)); + if ( !$month ) + $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600)); + if ( !$day ) + $day = gmdate('j', time()+(get_settings('gmt_offset') * 3600)); + + $daylink = $wp_rewrite->get_day_permastruct(); + if ( !empty($daylink) ) { + $daylink = str_replace('%year%', $year, $daylink); + $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); + $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); + return apply_filters('day_link', get_settings('home') . trailingslashit($daylink), $year, $month, $day); + } else { + return apply_filters('day_link', get_settings('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day); + } +} + +function get_feed_link($feed='rss2') { + global $wp_rewrite; + $do_perma = 0; + $feed_url = get_settings('siteurl'); + $comment_feed_url = $feed_url; + + $permalink = $wp_rewrite->get_feed_permastruct(); + if ( '' != $permalink ) { + if ( false !== strpos($feed, 'comments_') ) { + $feed = str_replace('comments_', '', $feed); + $permalink = $wp_rewrite->get_comment_feed_permastruct(); + } + + if ( 'rss2' == $feed ) + $feed = ''; + + $permalink = str_replace('%feed%', $feed, $permalink); + $permalink = preg_replace('#/+#', '/', "/$permalink/"); + $output = get_settings('home') . $permalink; + } else { + if ( false !== strpos($feed, 'comments_') ) + $feed = str_replace('comments_', 'comments-', $feed); + + $output = get_settings('home') . "/?feed={$feed}"; + } + + return apply_filters('feed_link', $output, $feed); +} + +function edit_post_link($link = 'Edit This', $before = '', $after = '') { + global $post; + + if ( ! current_user_can('edit_post', $post->ID) ) + return; + + if ( is_attachment() ) + return; + else + $file = 'post'; + + $location = get_settings('siteurl') . "/wp-admin/{$file}.php?action=edit&post=$post->ID"; + echo $before . "$link" . $after; +} + +function edit_comment_link($link = 'Edit This', $before = '', $after = '') { + global $post, $comment; + + if ( ! current_user_can('edit_post', $post->ID) ) + return; + + $location = get_settings('siteurl') . "/wp-admin/post.php?action=editcomment&comment=$comment->comment_ID"; + echo $before . "$link" . $after; +} + +// Navigation links + +function get_previous_post($in_same_cat = false, $excluded_categories = '') { + global $post, $wpdb; + + if( !is_single() || is_attachment() ) + return null; + + $current_post_date = $post->post_date; + + $join = ''; + if ( $in_same_cat ) { + $join = " INNER JOIN $wpdb->post2cat ON $wpdb->posts.ID= $wpdb->post2cat.post_id "; + $cat_array = get_the_category($post->ID); + $join .= ' AND (category_id = ' . intval($cat_array[0]->cat_ID); + for ( $i = 1; $i < (count($cat_array)); $i++ ) { + $join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID); + } + $join .= ')'; + } + + $sql_exclude_cats = ''; + if ( !empty($excluded_categories) ) { + $blah = explode('and', $excluded_categories); + foreach ( $blah as $category ) { + $category = intval($category); + $sql_exclude_cats .= " AND post_category != $category"; + } + } + + return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT 1"); +} + +function get_next_post($in_same_cat = false, $excluded_categories = '') { + global $post, $wpdb; + + if( !is_single() || is_attachment() ) + return null; + + $current_post_date = $post->post_date; + + $join = ''; + if ( $in_same_cat ) { + $join = " INNER JOIN $wpdb->post2cat ON $wpdb->posts.ID= $wpdb->post2cat.post_id "; + $cat_array = get_the_category($post->ID); + $join .= ' AND (category_id = ' . intval($cat_array[0]->cat_ID); + for ( $i = 1; $i < (count($cat_array)); $i++ ) { + $join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID); + } + $join .= ')'; + } + + $sql_exclude_cats = ''; + if ( !empty($excluded_categories) ) { + $blah = explode('and', $excluded_categories); + foreach ( $blah as $category ) { + $category = intval($category); + $sql_exclude_cats .= " AND post_category != $category"; + } + } + + $now = current_time('mysql'); + + return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT 1"); +} + + +function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') { + + if ( is_attachment() ) + $post = & get_post($GLOBALS['post']->post_parent); + else + $post = get_previous_post($in_same_cat, $excluded_categories); + + if ( !$post ) + return; + + $title = apply_filters('the_title', $post->post_title, $post); + $string = ''; + $link = str_replace('%title', $title, $link); + $link = $pre . $string . $link . ''; + + $format = str_replace('%link', $link, $format); + + echo $format; +} + +function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') { + $post = get_next_post($in_same_cat, $excluded_categories); + + if ( !$post ) + return; + + $title = apply_filters('the_title', $post->post_title, $post); + $string = ''; + $link = str_replace('%title', $title, $link); + $link = $string . $link . ''; + $format = str_replace('%link', $link, $format); + + echo $format; +} + + +// Deprecated. Use previous_post_link(). +function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { + + if ( empty($in_same_cat) || 'no' == $in_same_cat ) + $in_same_cat = false; + else + $in_same_cat = true; + + $post = get_previous_post($in_same_cat, $excluded_categories); + + if ( !$post ) + return; + + $string = ''.$previous; + if ( 'yes' == $title ) + $string .= apply_filters('the_title', $post->post_title, $post); + $string .= ''; + $format = str_replace('%', $string, $format); + echo $format; +} + +// Deprecated. Use next_post_link(). +function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { + + if ( empty($in_same_cat) || 'no' == $in_same_cat ) + $in_same_cat = false; + else + $in_same_cat = true; + + $post = get_next_post($in_same_cat, $excluded_categories); + + if ( !$post ) + return; + + $string = ''.$next; + if ( 'yes' == $title ) + $string .= apply_filters('the_title', $post->post_title, $nextpost); + $string .= ''; + $format = str_replace('%', $string, $format); + echo $format; +} + +function get_pagenum_link($pagenum = 1) { + global $wp_rewrite; + + $qstr = wp_specialchars($_SERVER['REQUEST_URI']); + + $page_querystring = "paged"; + $page_modstring = "page/"; + $page_modregex = "page/?"; + $permalink = 0; + + $home_root = parse_url(get_settings('home')); + $home_root = $home_root['path']; + $home_root = trailingslashit($home_root); + $qstr = preg_replace('|^'. $home_root . '|', '', $qstr); + $qstr = preg_replace('|^/+|', '', $qstr); + + $index = $_SERVER['PHP_SELF']; + $index = preg_replace('|^'. $home_root . '|', '', $index); + $index = preg_replace('|^/+|', '', $index); + + // if we already have a QUERY style page string + if ( stristr( $qstr, $page_querystring ) ) { + $replacement = "$page_querystring=$pagenum"; + $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr); + // if we already have a mod_rewrite style page string + } elseif ( preg_match( '|'.$page_modregex.'\d+|', $qstr ) ) { + $permalink = 1; + $qstr = preg_replace('|'.$page_modregex.'\d+|',"$page_modstring$pagenum",$qstr); + + // if we don't have a page string at all ... + // lets see what sort of URL we have... + } else { + // we need to know the way queries are being written + // if there's a querystring_start (a "?" usually), it's definitely not mod_rewritten + if ( stristr( $qstr, '?' ) ) { + // so append the query string (using &, since we already have ?) + $qstr .= '&' . $page_querystring . '=' . $pagenum; + // otherwise, it could be rewritten, OR just the default index ... + } elseif( '' != get_settings('permalink_structure') && ! is_admin() ) { + $permalink = 1; + $index = $wp_rewrite->index; + // If it's not a path info permalink structure, trim the index. + if ( !$wp_rewrite->using_index_permalinks() ) { + $qstr = preg_replace("#/*" . $index . "/*#", '/', $qstr); + } else { + // If using path info style permalinks, make sure the index is in + // the URI. + if ( strpos($qstr, $index) === false ) + $qstr = '/' . $index . $qstr; + } + + $qstr = trailingslashit($qstr) . $page_modstring . $pagenum; + } else { + $qstr = $index . '?' . $page_querystring . '=' . $pagenum; + } + } + + $qstr = preg_replace('|^/+|', '', $qstr); + if ( $permalink ) + $qstr = trailingslashit($qstr); + $qstr = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', trailingslashit( get_settings('home') ) . $qstr ); + + // showing /page/1/ or ?paged=1 is redundant + if ( 1 === $pagenum ) { + $qstr = str_replace('page/1/', '', $qstr); // for mod_rewrite style + $qstr = remove_query_arg('paged', $qstr); // for query style + } + return $qstr; +} + +function next_posts($max_page = 0) { // original by cfactor at cooltux.org + global $paged, $pagenow; + + if ( !is_single() ) { + if ( !$paged ) + $paged = 1; + $nextpage = intval($paged) + 1; + if ( !$max_page || $max_page >= $nextpage ) + echo get_pagenum_link($nextpage); + } +} + +function next_posts_link($label='Next Page »', $max_page=0) { + global $paged, $result, $request, $posts_per_page, $wpdb, $max_num_pages; + if ( !$max_page ) { + if ( isset($max_num_pages) ) { + $max_page = $max_num_pages; + } else { + preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); + $fromwhere = $matches[1]; + $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); + $max_page = $max_num_pages = ceil($numposts / $posts_per_page); + } + } + if ( !$paged ) + $paged = 1; + $nextpage = intval($paged) + 1; + if ( (! is_single()) && (empty($paged) || $nextpage <= $max_page) ) { + echo ''. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; + } +} + + +function previous_posts() { // original by cfactor at cooltux.org + global $paged, $pagenow; + + if ( !is_single() ) { + $nextpage = intval($paged) - 1; + if ( $nextpage < 1 ) + $nextpage = 1; + echo get_pagenum_link($nextpage); + } +} + + +function previous_posts_link($label='« Previous Page') { + global $paged; + if ( (!is_single()) && ($paged > 1) ) { + echo ''. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; + } +} + +function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') { + global $request, $posts_per_page, $wpdb, $max_num_pages; + if ( !is_single() ) { + + if ( 'posts' == get_query_var('what_to_show') ) { + if ( !isset($max_num_pages) ) { + preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); + $fromwhere = $matches[1]; + $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); + $max_num_pages = ceil($numposts / $posts_per_page); + } + } else { + $max_num_pages = 999999; + } + + if ( $max_num_pages > 1 ) { + previous_posts_link($prelabel); + echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $sep); + next_posts_link($nxtlabel, $max_page); + } + } +} + +?> diff --git a/wp-includes/template-functions-post.php b/wp-includes/template-functions-post.php new file mode 100644 index 00000000..383acb37 --- /dev/null +++ b/wp-includes/template-functions-post.php @@ -0,0 +1,567 @@ + +

    ' . __("This post is password protected. To view it please enter your password below:") . '

    +

    + + '; + return $output; +} + + +function the_ID() { + global $id; + echo $id; +} + + +function the_title($before = '', $after = '', $echo = true) { + $title = get_the_title(); + if ( strlen($title) > 0 ) { + $title = apply_filters('the_title', $before . $title . $after, $before, $after); + if ( $echo ) + echo $title; + else + return $title; + } +} + + +function get_the_title($id = 0) { + $post = &get_post($id); + + $title = $post->post_title; + if ( !empty($post->post_password) ) + $title = sprintf(__('Protected: %s'), $title); + + return $title; +} + + +function get_the_guid( $id = 0 ) { + $post = &get_post($id); + + return apply_filters('get_the_guid', $post->guid); +} + + +function the_guid( $id = 0 ) { + echo get_the_guid($id); +} + + +function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { + $content = get_the_content($more_link_text, $stripteaser, $more_file); + $content = apply_filters('the_content', $content); + $content = str_replace(']]>', ']]>', $content); + echo $content; +} + + +function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { + global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages; + global $preview; + global $pagenow; + $output = ''; + + if ( !empty($post->post_password) ) { // if there's a password + if ( stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password ) { // and it doesn't match the cookie + $output = get_the_password_form(); + return $output; + } + } + + if ( $more_file != '' ) + $file = $more_file; + else + $file = $pagenow; //$_SERVER['PHP_SELF']; + + $content = $pages[$page-1]; + $content = explode('', $content, 2); + if ( (preg_match('//', $post->post_content) && ((!$multipage) || ($page==1))) ) + $stripteaser = 1; + $teaser = $content[0]; + if ( ($more) && ($stripteaser) ) + $teaser = ''; + $output .= $teaser; + if ( count($content) > 1 ) { + if ( $more ) + $output .= ''.$content[1]; + else + $output .= ' $more_link_text"; + } + if ( $preview ) // preview fix for javascript bug with foreign languages + $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output); + + return $output; +} + + +function the_excerpt() { + echo apply_filters('the_excerpt', get_the_excerpt()); +} + + +function get_the_excerpt($fakeit = true) { + global $id, $post; + $output = ''; + $output = $post->post_excerpt; + if ( !empty($post->post_password) ) { // if there's a password + if ( $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password ) { // and it doesn't match the cookie + $output = __('There is no excerpt because this is a protected post.'); + return $output; + } + } + + return apply_filters('get_the_excerpt', $output); +} + + +function wp_link_pages($args = '') { + parse_str($args, $r); + if ( !isset($r['before']) ) + $r['before'] = '

    ' . __('Pages:'); + if ( !isset($r['after']) ) + $r['after'] = '

    '; + if ( !isset($r['next_or_number']) ) + $r['next_or_number'] = 'number'; + if ( !isset($r['nextpagelink']) ) + $r['nextpagelink'] = 'Next page'; + if ( !isset($r['previouspagelink']) ) + $r['previouspagelink'] = 'Previous page'; + if ( !isset($r['pagelink']) ) + $r['pagelink'] = '%'; + if ( !isset($r['more_file']) ) + $r['more_file'] = ''; + + link_pages($r['before'], $r['after'], $r['next_or_number'], $r['nextpagelink'], $r['previouspagelink'], $r['pagelink'], $r['more_file']); +} + + +function link_pages($before='
    ', $after='
    ', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') { + global $id, $page, $numpages, $multipage, $more, $pagenow; + if ( $more_file != '' ) + $file = $more_file; + else + $file = $pagenow; + if ( $multipage ) { + if ( 'number' == $next_or_number ) { + echo $before; + for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) { + $j = str_replace('%',"$i",$pagelink); + echo ' '; + if ( ($i != $page) || ((!$more) && ($page==1)) ) { + if ( '' == get_settings('permalink_structure') ) + echo ''; + else + echo ''; + } + echo $j; + if ( ($i != $page) || ((!$more) && ($page==1)) ) + echo ''; + } + echo $after; + } else { + if ( $more ) { + echo $before; + $i = $page - 1; + if ( $i && $more ) { + if ( '' == get_settings('permalink_structure') ) + echo ''.$previouspagelink.''; + else + echo ''.$previouspagelink.''; + } + $i = $page + 1; + if ( $i <= $numpages && $more ) { + if ( '' == get_settings('permalink_structure') ) + echo ''.$nextpagelink.''; + else + echo ''.$nextpagelink.''; + } + echo $after; + } + } + } +} + + +/* +Post-meta: Custom per-post fields. +*/ + + +function get_post_custom( $post_id = 0 ) { + global $id, $post_meta_cache, $wpdb; + + if ( ! $post_id ) + $post_id = $id; + + if ( isset($post_meta_cache[$post_id]) ) + return $post_meta_cache[$post_id]; + + if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = '$post_id' ORDER BY post_id, meta_key", ARRAY_A) ) { + // Change from flat structure to hierarchical: + $post_meta_cache = array(); + foreach ( $meta_list as $metarow ) { + $mpid = $metarow['post_id']; + $mkey = $metarow['meta_key']; + $mval = $metarow['meta_value']; + + // Force subkeys to be array type: + if ( !isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]) ) + $post_meta_cache[$mpid] = array(); + + if ( !isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]) ) + $post_meta_cache[$mpid]["$mkey"] = array(); + + // Add a value to the current pid/key: + $post_meta_cache[$mpid][$mkey][] = $mval; + } + return $post_meta_cache[$mpid]; + } +} + + +function get_post_custom_keys() { + $custom = get_post_custom(); + + if ( ! is_array($custom) ) + return; + + if ( $keys = array_keys($custom) ) + return $keys; +} + + +function get_post_custom_values( $key = '' ) { + $custom = get_post_custom(); + + return $custom[$key]; +} + + +function post_custom( $key = '' ) { + $custom = get_post_custom(); + + if ( 1 == count($custom[$key]) ) + return $custom[$key][0]; + else + return $custom[$key]; +} + + +// this will probably change at some point... +function the_meta() { + global $id, $post_meta_cache; + + if ( $keys = get_post_custom_keys() ) { + echo "\n"; + } +} + + +/* +Pages +*/ + + +function &get_page_children($page_id, $pages) { + global $page_cache; + + if ( empty($pages) ) + $pages = &$page_cache; + + $page_list = array(); + foreach ( $pages as $page ) { + if ( $page->post_parent == $page_id ) { + $page_list[] = $page; + if ( $children = get_page_children($page->ID, $pages) ) + $page_list = array_merge($page_list, $children); + } + } + return $page_list; +} + + +function &get_pages($args = '') { + global $wpdb; + + parse_str($args, $r); + + if ( !isset($r['child_of']) ) + $r['child_of'] = 0; + if ( !isset($r['sort_column']) ) + $r['sort_column'] = 'post_title'; + if ( !isset($r['sort_order']) ) + $r['sort_order'] = 'ASC'; + + $exclusions = ''; + if ( !empty($r['exclude']) ) { + $expages = preg_split('/[\s,]+/',$r['exclude']); + if ( count($expages) ) { + foreach ( $expages as $expage ) { + $exclusions .= ' AND ID <> ' . intval($expage) . ' '; + } + } + } + + $pages = $wpdb->get_results("SELECT * " . + "FROM $wpdb->posts " . + "WHERE post_status = 'static' " . + "$exclusions " . + "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']); + + if ( empty($pages) ) + return array(); + + // Update cache. + update_page_cache($pages); + + if ( $r['child_of'] ) + $pages = & get_page_children($r['child_of'], $pages); + + return $pages; +} + + +function wp_list_pages($args = '') { + parse_str($args, $r); + if ( !isset($r['depth']) ) + $r['depth'] = 0; + if ( !isset($r['show_date']) ) + $r['show_date'] = ''; + if ( !isset($r['child_of']) ) + $r['child_of'] = 0; + if ( !isset($r['title_li']) ) + $r['title_li'] = __('Pages'); + if ( !isset($r['echo']) ) + $r['echo'] = 1; + + $output = ''; + + // Query pages. + $pages = & get_pages($args); + if ( $pages ) { + + if ( $r['title_li'] ) + $output .= ''; + } + + $output = apply_filters('wp_list_pages', $output); + + if ( $r['echo'] ) + echo $output; + else + return $output; +} + + +function _page_level_out($parent, $page_tree, $args, $depth = 0, $echo = true) { + global $wp_query; + $queried_obj = $wp_query->get_queried_object(); + $output = ''; + + if ( $depth ) + $indent = str_repeat("\t", $depth); + //$indent = join('', array_fill(0,$depth,"\t")); + + if ( !is_array($page_tree[$parent]['children']) ) + return false; + + foreach ( $page_tree[$parent]['children'] as $page_id ) { + $cur_page = $page_tree[$page_id]; + $title = $cur_page['title']; + + $css_class = 'page_item'; + if ( $page_id == $queried_obj->ID ) + $css_class .= ' current_page_item'; + + $output .= $indent . '
  • ' . $title . ''; + + if ( isset($cur_page['ts']) ) { + $format = get_settings('date_format'); + if ( isset($args['date_format']) ) + $format = $args['date_format']; + $output .= " " . mysql2date($format, $cur_page['ts']); + } + + if ( isset($cur_page['children']) && is_array($cur_page['children']) ) { + $new_depth = $depth + 1; + + if ( !$args['depth'] || $depth < ($args['depth']-1) ) { + $output .= "$indent
      \n"; + $output .= _page_level_out($page_id, $page_tree, $args, $new_depth, false); + $output .= "$indent
    \n"; + } + } + $output .= "$indent
  • \n"; + } + if ( $echo ) + echo $output; + else + return $output; +} + +function the_attachment_link($id = 0, $fullsize = false, $max_dims = false) { + echo get_the_attachment_link($id, $fullsize, $max_dims); +} + +function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false) { + $id = (int) $id; + $_post = & get_post($id); + + if ( ('attachment' != $_post->post_status) || ('' == $_post->guid) ) + return __('Missing Attachment'); + + if (! empty($_post->guid) ) { + $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims); + + return "guid}\" title=\"{$_post->post_title}\" >{$innerHTML}"; + + } else { + $p .= __('Missing attachment'); + } + return $p; +} + +function get_attachment_icon($id = 0, $fullsize = false, $max_dims = false) { + $id = (int) $id; + $post = & get_post($id); + + $mime = $post->post_mime_type; + + $imagedata = get_post_meta($post->ID, '_wp_attachment_metadata', true); + + $file = get_post_meta($post->ID, '_wp_attached_file', true); + + if ( !$fullsize && !empty($imagedata['thumb']) + && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) + && file_exists($thumbfile) ) { + + // We have a thumbnail desired, specified and existing + + $src = str_replace(basename($post->guid), $imagedata['thumb'], $post->guid); + $src_file = $thumbfile; + $class = 'attachmentthumb'; + + } elseif ( substr($mime, 0, 6) == 'image/' + && file_exists($file) ) { + + // We have an image without a thumbnail + + $src = $post->guid; + $src_file = & $file; + $class = 'attachmentimage'; + } elseif (! empty($mime) ) { + + // No thumb, no image. We'll look for a mime-related icon instead. + $icon_dir = apply_filters('icon_dir', get_template_directory().'/images'); + $icon_dir_uri = apply_filters('icon_dir_uri', get_template_directory_uri().'/images'); + + $types = array(substr($mime, 0, strpos($mime, '/')), substr($mime, strpos($mime, '/') + 1), str_replace('/', '_', $mime)); + $exts = array('jpg', 'gif', 'png'); + foreach ($types as $type) { + foreach ($exts as $ext) { + $src_file = "$icon_dir/$type.$ext"; + if ( file_exists($src_file) ) { + $src = "$icon_dir_uri/$type.$ext"; + break 2; + } + } + } + } + + if (! isset($src) ) + return false; + + // Do we need to constrain the image? + if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) { + + $imagesize = getimagesize($src_file); + + if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) { + $actual_aspect = $imagesize[0] / $imagesize[1]; + $desired_aspect = $max_dims[0] / $max_dims[1]; + + if ( $actual_aspect >= $desired_aspect ) { + $height = $actual_aspect * $max_dims[0]; + $constraint = "width=\"{$max_dims[0]}\" "; + $post->iconsize = array($max_dims[0], $height); + } else { + $width = $max_dims[1] / $actual_aspect; + $constraint = "height=\"{$max_dims[1]}\" "; + $post->iconsize = array($width, $max_dims[1]); + } + } else { + $post->iconsize = array($imagesize[0], $imagesize[1]); + } + } + + $icon = "post_title}\" alt=\"{$post->post_title}\" {$constraint}/>"; + + return apply_filters('attachment_icon', $icon, $post->ID); +} + +function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { + $id = (int) $id; + + if ( $innerHTML = get_attachment_icon($id, $fullsize, $max_dims)) + return $innerHTML; + + $post = & get_post($id); + + $innerHTML = $post->post_title; + + return apply_filters('attachment_innerHTML', $innerHTML, $post->ID); +} + +function prepend_attachment($content) { + $p = '

    '; + $p .= get_the_attachment_link(false, true, array(400, 300)); + $p .= '

    '; + $p = apply_filters('prepend_attachment', $p); + + return "$p\n$content"; +} + +?> diff --git a/wp-includes/template-loader.php b/wp-includes/template-loader.php new file mode 100644 index 00000000..ac69dab0 --- /dev/null +++ b/wp-includes/template-loader.php @@ -0,0 +1,67 @@ + \ No newline at end of file diff --git a/wp-includes/vars.php b/wp-includes/vars.php new file mode 100644 index 00000000..705d8b25 --- /dev/null +++ b/wp-includes/vars.php @@ -0,0 +1,113 @@ + 'icon_smile.gif', + ' :D' => 'icon_biggrin.gif', + ' :-D' => 'icon_biggrin.gif', + ':grin:' => 'icon_biggrin.gif', + ' :)' => 'icon_smile.gif', + ' :-)' => 'icon_smile.gif', + ':smile:' => 'icon_smile.gif', + ' :(' => 'icon_sad.gif', + ' :-(' => 'icon_sad.gif', + ':sad:' => 'icon_sad.gif', + ' :o' => 'icon_surprised.gif', + ' :-o' => 'icon_surprised.gif', + ':eek:' => 'icon_surprised.gif', + ' 8O' => 'icon_eek.gif', + ' 8-O' => 'icon_eek.gif', + ':shock:' => 'icon_eek.gif', + ' :?' => 'icon_confused.gif', + ' :-?' => 'icon_confused.gif', + ' :???:' => 'icon_confused.gif', + ' 8)' => 'icon_cool.gif', + ' 8-)' => 'icon_cool.gif', + ':cool:' => 'icon_cool.gif', + ':lol:' => 'icon_lol.gif', + ' :x' => 'icon_mad.gif', + ' :-x' => 'icon_mad.gif', + ':mad:' => 'icon_mad.gif', + ' :P' => 'icon_razz.gif', + ' :-P' => 'icon_razz.gif', + ':razz:' => 'icon_razz.gif', + ':oops:' => 'icon_redface.gif', + ':cry:' => 'icon_cry.gif', + ':evil:' => 'icon_evil.gif', + ':twisted:' => 'icon_twisted.gif', + ':roll:' => 'icon_rolleyes.gif', + ':wink:' => 'icon_wink.gif', + ' ;)' => 'icon_wink.gif', + ' ;-)' => 'icon_wink.gif', + ':!:' => 'icon_exclaim.gif', + ':?:' => 'icon_question.gif', + ':idea:' => 'icon_idea.gif', + ':arrow:' => 'icon_arrow.gif', + ' :|' => 'icon_neutral.gif', + ' :-|' => 'icon_neutral.gif', + ':neutral:' => 'icon_neutral.gif', + ':mrgreen:' => 'icon_mrgreen.gif', + ); +} + +// sorts the smilies' array +if (!function_exists('smiliescmp')) { +function smiliescmp ($a, $b) { + if (strlen($a) == strlen($b)) { + return strcmp($a, $b); + } + return (strlen($a) > strlen($b)) ? -1 : 1; + } +} +uksort($wpsmiliestrans, 'smiliescmp'); + +// generates smilies' search & replace arrays +foreach($wpsmiliestrans as $smiley => $img) { + $wp_smiliessearch[] = $smiley; + $smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES); + $wp_smiliesreplace[] = " $smiley_masked "; +} + +?> diff --git a/wp-includes/version.php b/wp-includes/version.php new file mode 100644 index 00000000..3a2e5dfe --- /dev/null +++ b/wp-includes/version.php @@ -0,0 +1,8 @@ + diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php new file mode 100644 index 00000000..97238c39 --- /dev/null +++ b/wp-includes/wp-db.php @@ -0,0 +1,363 @@ +dbh = @mysql_connect($dbhost, $dbuser, $dbpassword); + if (!$this->dbh) { + $this->bail(" +

    Error establishing a database connection

    +

    This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at $dbhost. This could mean your host's database server is down.

    +
      +
    • Are you sure you have the correct username and password?
    • +
    • Are you sure that you have typed the correct hostname?
    • +
    • Are you sure that the database server is running?
    • +
    +

    If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

    +"); + } + + $this->select($dbname); + } + + // ================================================================== + // Select a DB (if another one needs to be selected) + + function select($db) { + if (!@mysql_select_db($db, $this->dbh)) { + $this->bail(" +

    Can’t select database

    +

    We were able to connect to the database server (which means your username and password is okay) but not able to select the $db database.

    +
      +
    • Are you sure it exists?
    • +
    • On some systems the name of your database is prefixed with your username, so it would be like username_wordpress. Could that be the problem?
    • +
    +

    If you don't know how to setup a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.

    "); + } + } + + // ==================================================================== + // Format a string correctly for safe insert under all PHP conditions + + function escape($string) { + return addslashes( $string ); // Disable rest for now, causing problems + if( !$this->dbh || version_compare( phpversion(), '4.3.0' ) == '-1' ) + return mysql_escape_string( $string ); + else + return mysql_real_escape_string( $string, $this->dbh ); + } + + // ================================================================== + // Print SQL/DB error. + + function print_error($str = '') { + global $EZSQL_ERROR; + if (!$str) $str = mysql_error(); + $EZSQL_ERROR[] = + array ('query' => $this->last_query, 'error_str' => $str); + + // Is error output turned on or not.. + if ( $this->show_errors ) { + // If there is an error then take note of it + print "
    +

    WordPress database error: [$str]
    + $this->last_query

    +
    "; + } else { + return false; + } + } + + // ================================================================== + // Turn error handling on or off.. + + function show_errors() { + $this->show_errors = true; + } + + function hide_errors() { + $this->show_errors = false; + } + + // ================================================================== + // Kill cached query results + + function flush() { + $this->last_result = null; + $this->col_info = null; + $this->last_query = null; + } + + // ================================================================== + // Basic Query - see docs for more detail + + function query($query) { + // initialise return + $return_val = 0; + $this->flush(); + + // Log how the function was called + $this->func_call = "\$db->query(\"$query\")"; + + // Keep track of the last query for debug.. + $this->last_query = $query; + + // Perform the query via std mysql_query function.. + if (SAVEQUERIES) + $this->timer_start(); + + $this->result = @mysql_query($query, $this->dbh); + ++$this->num_queries; + + if (SAVEQUERIES) + $this->queries[] = array( $query, $this->timer_stop() ); + + // If there is an error then take note of it.. + if ( mysql_error() ) { + $this->print_error(); + return false; + } + + if ( preg_match("/^\\s*(insert|delete|update|replace) /i",$query) ) { + $this->rows_affected = mysql_affected_rows(); + // Take note of the insert_id + if ( preg_match("/^\\s*(insert|replace) /i",$query) ) { + $this->insert_id = mysql_insert_id($this->dbh); + } + // Return number of rows affected + $return_val = $this->rows_affected; + } else { + $i = 0; + while ($i < @mysql_num_fields($this->result)) { + $this->col_info[$i] = @mysql_fetch_field($this->result); + $i++; + } + $num_rows = 0; + while ( $row = @mysql_fetch_object($this->result) ) { + $this->last_result[$num_rows] = $row; + $num_rows++; + } + + @mysql_free_result($this->result); + + // Log number of rows the query returned + $this->num_rows = $num_rows; + + // Return number of rows selected + $return_val = $this->num_rows; + } + + return $return_val; + } + + // ================================================================== + // Get one variable from the DB - see docs for more detail + + function get_var($query=null, $x = 0, $y = 0) { + $this->func_call = "\$db->get_var(\"$query\",$x,$y)"; + if ( $query ) + $this->query($query); + + // Extract var out of cached results based x,y vals + if ( $this->last_result[$y] ) { + $values = array_values(get_object_vars($this->last_result[$y])); + } + + // If there is a value return it else return null + return (isset($values[$x]) && $values[$x]!=='') ? $values[$x] : null; + } + + // ================================================================== + // Get one row from the DB - see docs for more detail + + function get_row($query = null, $output = OBJECT, $y = 0) { + $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; + if ( $query ) + $this->query($query); + + if ( $output == OBJECT ) { + return $this->last_result[$y] ? $this->last_result[$y] : null; + } elseif ( $output == ARRAY_A ) { + return $this->last_result[$y] ? get_object_vars($this->last_result[$y]) : null; + } elseif ( $output == ARRAY_N ) { + return $this->last_result[$y] ? array_values(get_object_vars($this->last_result[$y])) : null; + } else { + $this->print_error(" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"); + } + } + + // ================================================================== + // Function to get 1 column from the cached result set based in X index + // se docs for usage and info + + function get_col($query = null , $x = 0) { + if ( $query ) + $this->query($query); + + // Extract the column values + for ( $i=0; $i < count($this->last_result); $i++ ) { + $new_array[$i] = $this->get_var(null, $x, $i); + } + return $new_array; + } + + // ================================================================== + // Return the the query as a result set - see docs for more details + + function get_results($query = null, $output = OBJECT) { + $this->func_call = "\$db->get_results(\"$query\", $output)"; + + if ( $query ) + $this->query($query); + + // Send back array of objects. Each row is an object + if ( $output == OBJECT ) { + return $this->last_result; + } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { + if ( $this->last_result ) { + $i = 0; + foreach( $this->last_result as $row ) { + $new_array[$i] = (array) $row; + if ( $output == ARRAY_N ) { + $new_array[$i] = array_values($new_array[$i]); + } + $i++; + } + return $new_array; + } else { + return null; + } + } + } + + + // ================================================================== + // Function to get column meta data info pertaining to the last query + // see docs for more info and usage + + function get_col_info($info_type = 'name', $col_offset = -1) { + if ( $this->col_info ) { + if ( $col_offset == -1 ) { + $i = 0; + foreach($this->col_info as $col ) { + $new_array[$i] = $col->{$info_type}; + $i++; + } + return $new_array; + } else { + return $this->col_info[$col_offset]->{$info_type}; + } + } + } + + function timer_start() { + $mtime = microtime(); + $mtime = explode(' ', $mtime); + $this->time_start = $mtime[1] + $mtime[0]; + return true; + } + + function timer_stop($precision = 3) { + $mtime = microtime(); + $mtime = explode(' ', $mtime); + $time_end = $mtime[1] + $mtime[0]; + $time_total = $time_end - $this->time_start; + return $time_total; + } + + function bail($message) { // Just wraps errors in a nice header and footer + if ( !$this->show_errors ) + return false; + header( 'Content-Type: text/html; charset=utf-8'); + echo << + + + WordPress › Error + + + + +

    WordPress

    +HEAD; + echo $message; + echo ""; + die(); + } +} + +$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); +?> \ No newline at end of file diff --git a/wp-includes/wp-l10n.php b/wp-includes/wp-l10n.php new file mode 100644 index 00000000..21329433 --- /dev/null +++ b/wp-includes/wp-l10n.php @@ -0,0 +1,97 @@ +translate($text), $text); + else + return $text; +} + +// Echo a translated string. +function _e($text, $domain = 'default') { + global $l10n; + + if (isset($l10n[$domain])) + echo apply_filters('gettext', $l10n[$domain]->translate($text), $text); + else + echo $text; +} + +// Return the plural form. +function __ngettext($single, $plural, $number, $domain = 'default') { + global $l10n; + + if (isset($l10n[$domain])) { + return $l10n[$domain]->ngettext($single, $plural, $number); + } else { + if ($number != 1) + return $plural; + else + return $single; + } +} + +function load_textdomain($domain, $mofile) { + global $l10n; + + if (isset($l10n[$domain])) + return; + + if ( is_readable($mofile)) + $input = new CachedFileReader($mofile); + else + return; + + $l10n[$domain] = new gettext_reader($input); +} + +function load_default_textdomain() { + global $l10n; + + $locale = get_locale(); + $mofile = ABSPATH . "wp-includes/languages/$locale.mo"; + + load_textdomain('default', $mofile); +} + +function load_plugin_textdomain($domain, $path = 'wp-content/plugins') { + $locale = get_locale(); + + $mofile = ABSPATH . "$path/$domain-$locale.mo"; + load_textdomain($domain, $mofile); +} + +function load_theme_textdomain($domain) { + $locale = get_locale(); + + $mofile = get_template_directory() . "/$locale.mo"; + load_textdomain($domain, $mofile); +} + +?> \ No newline at end of file diff --git a/wp-links-opml.php b/wp-links-opml.php new file mode 100644 index 00000000..848a9986 --- /dev/null +++ b/wp-links-opml.php @@ -0,0 +1,61 @@ +links.link_category = $link_cat"; + $cat_name = $wpdb->get_var("SELECT $wpdb->linkcategories.cat_name FROM $wpdb->linkcategories WHERE $wpdb->linkcategories.cat_id = $link_cat"); + if (!empty($cat_name)) { + $cat_name = ": category $cat_name"; + } + } +} +?>\n"; ?> + + + + Links for <?php echo get_bloginfo('name').$cat_name ?> + GMT + + +links.link_url, link_rss, $wpdb->links.link_name, $wpdb->links.link_category, $wpdb->linkcategories.cat_name, link_updated +FROM $wpdb->links + JOIN $wpdb->linkcategories on $wpdb->links.link_category = $wpdb->linkcategories.cat_id + AND $wpdb->links.link_visible = 'Y' + $sql_cat + ORDER BY $wpdb->linkcategories.cat_name, $wpdb->links.link_name \n"; + //echo(""); + $prev_cat_id = 0; + $results = $wpdb->get_results($sql); + if ($results) { + foreach ($results as $result) { + if ($result->link_category != $prev_cat_id) { // new category + if ($prev_cat_id != 0) { // not first time +?> + + + +link_category; + } // end if new category +?> + + + + + + \ No newline at end of file diff --git a/wp-login.php b/wp-login.php new file mode 100644 index 00000000..0864edbd --- /dev/null +++ b/wp-login.php @@ -0,0 +1,258 @@ + + + + + WordPress » <?php _e('Lost Password') ?> + + + + + + +
    +

    WordPress

    +

    +$error
    "; +?> + +
    +

    + +

    +


    +

    +

    +
    +
      +
    • «
    • + +
    • + +
    • +
    + + + +user_login; + $user_email = $user_data->user_email; + + if (!$user_email || $user_email != $_POST['email']) + die(sprintf(__('Sorry, that user does not seem to exist in our database. Perhaps you have the wrong username or e-mail address? Try again.'), 'wp-login.php?action=lostpassword')); + +do_action('retreive_password', $user_login); // Misspelled and deprecated. +do_action('retrieve_password', $user_login); + + // Generate something random for a password... md5'ing current time with a rand salt + $key = substr( md5( uniqid( microtime() ) ), 0, 50); + // now insert the new pass md5'd into the db + $wpdb->query("UPDATE $wpdb->users SET user_activation_key = '$key' WHERE user_login = '$user_login'"); + $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n"; + $message .= get_option('siteurl') . "\r\n\r\n"; + $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; + $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n"; + $message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key=$key\r\n"; + + $m = wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_settings('blogname')), $message); + + if ($m == false) { + echo '

    ' . __('The e-mail could not be sent.') . "
    \n"; + echo __('Possible reason: your host may have disabled the mail() function...') . "

    "; + die(); + } else { + echo '

    ' . sprintf(__("The e-mail was sent successfully to %s's e-mail address."), $user_login) . '
    '; + echo "" . __('Click here to login!') . '

    '; + die(); + } + +break; + +case 'resetpass' : + + // Generate something random for a password... md5'ing current time with a rand salt + $key = preg_replace('/a-z0-9/i', '', $_GET['key']); + if ( empty($key) ) + die( __('Sorry, that key does not appear to be valid.') ); + $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_activation_key = '$key'"); + if ( !$user ) + die( __('Sorry, that key does not appear to be valid.') ); + + do_action('password_reset'); + + $new_pass = substr( md5( uniqid( microtime() ) ), 0, 7); + $wpdb->query("UPDATE $wpdb->users SET user_pass = MD5('$new_pass'), user_activation_key = '' WHERE user_login = '$user->user_login'"); + wp_cache_delete($user->ID, 'users'); + wp_cache_delete($user->user_login, 'userlogins'); + $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n"; + $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n"; + $message .= get_settings('siteurl') . "/wp-login.php\r\n"; + + $m = wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_settings('blogname')), $message); + + if ($m == false) { + echo '

    ' . __('The e-mail could not be sent.') . "
    \n"; + echo __('Possible reason: your host may have disabled the mail() function...') . '

    '; + die(); + } else { + echo '

    ' . sprintf(__('Your new password is in the mail.'), $user_login) . '
    '; + echo "" . __('Click here to login!') . '

    '; + // send a copy of password change notification to the admin + $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n"; + wp_mail(get_settings('admin_email'), sprintf(__('[%s] Password Lost/Change'), get_settings('blogname')), $message); + die(); + } +break; + +case 'login' : +default: + + $user_login = ''; + $user_pass = ''; + $using_cookie = false; + if ( !isset( $_REQUEST['redirect_to'] ) ) + $redirect_to = 'wp-admin/'; + else + $redirect_to = $_REQUEST['redirect_to']; + $redirect_to = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $redirect_to); + + if( $_POST ) { + $user_login = $_POST['log']; + $user_login = sanitize_user( $user_login ); + $user_pass = $_POST['pwd']; + $rememberme = $_POST['rememberme']; + } elseif ( !empty($_COOKIE) ) { + if ( !empty($_COOKIE[USER_COOKIE]) ) + $user_login = $_COOKIE[USER_COOKIE]; + if ( !empty($_COOKIE[PASS_COOKIE]) ) { + $user_pass = $_COOKIE[PASS_COOKIE]; + $using_cookie = true; + } + } + + do_action('wp_authenticate', array(&$user_login, &$user_pass)); + + if ( $user_login && $user_pass ) { + $user = new WP_User(0, $user_login); + + // If the user can't edit posts, send them to their profile. + if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) ) + $redirect_to = get_settings('siteurl') . '/wp-admin/profile.php'; + + if ( wp_login($user_login, $user_pass, $using_cookie) ) { + if ( !$using_cookie ) + wp_setcookie($user_login, $user_pass, false, '', '', $rememberme); + do_action('wp_login', $user_login); + wp_redirect($redirect_to); + exit; + } else { + if ( $using_cookie ) + $error = __('Your session has expired.'); + } + } +?> + + + + WordPress › <?php _e('Login') ?> + + + + + + +
    +

    WordPress

    +$error
    "; +?> + +
    +

    +

    +

    +

    +

    + + +

    +
    +
      +
    • «
    • + +
    • + +
    • +
    + + + + + diff --git a/wp-mail.php b/wp-mail.php new file mode 100644 index 00000000..6c62fbad --- /dev/null +++ b/wp-mail.php @@ -0,0 +1,166 @@ +connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) : + echo "Ooops $pop3->ERROR
    \n"; + exit; +endif; + +$count = $pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass')); +if (0 == $count) die(__('There doesn’t seem to be any new mail.')); + + +for ($i=1; $i <= $count; $i++) : + + $message = $pop3->get($i); + + $content = ''; + $content_type = ''; + $boundary = ''; + $bodysignal = 0; + $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); + foreach ($message as $line) : + if (strlen($line) < 3) $bodysignal = 1; + + if ($bodysignal) { + $content .= $line; + } else { + if (preg_match('/Content-Type: /i', $line)) { + $content_type = trim($line); + $content_type = substr($content_type, 14, strlen($content_type)-14); + $content_type = explode(';', $content_type); + $content_type = $content_type[0]; + } + if (($content_type == 'multipart/alternative') && (preg_match('/boundary="/', $line)) && ($boundary == '')) { + $boundary = trim($line); + $boundary = explode('"', $boundary); + $boundary = $boundary[1]; + } + if (preg_match('/Subject: /i', $line)) { + $subject = trim($line); + $subject = substr($subject, 9, strlen($subject)-9); + $subject = wp_iso_descrambler($subject); + // Captures any text in the subject before $phone_delim as the subject + $subject = explode($phone_delim, $subject); + $subject = $subject[0]; + } + + // Set the author using the email address (To or Reply-To, the last used) + // otherwise use the site admin + if (preg_match('/From: /', $line) | preg_match('Reply-To: /', $line)) { + $author=trim($line); + if ( ereg("([a-zA-Z0-9\_\-\.]+@[\a-zA-z0-9\_\-\.]+)", $author , $regs) ) { + $author = $regs[1]; + echo "Author = {$author}

    "; + $author = $wpdb->escape($author); + $result = $wpdb->get_row("SELECT ID FROM $wpdb->users WHERE user_email='$author' LIMIT 1"); + if (!$result) + $post_author = 1; + else + $post_author = $result->ID; + } else + $post_author = 1; + } + + if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37' + $ddate = trim($line); + $ddate = str_replace('Date: ', '', $ddate); + if (strpos($ddate, ',')) { + $ddate = trim(substr($ddate, strpos($ddate, ',')+1, strlen($ddate))); + } + $date_arr = explode(' ', $ddate); + $date_time = explode(':', $date_arr[3]); + + $ddate_H = $date_time[0]; + $ddate_i = $date_time[1]; + $ddate_s = $date_time[2]; + + $ddate_m = $date_arr[1]; + $ddate_d = $date_arr[0]; + $ddate_Y = $date_arr[2]; + for ($j=0; $j<12; $j++) { + if ($ddate_m == $dmonths[$j]) { + $ddate_m = $j+1; + } + } + + $time_zn = intval($date_arr[4]) * 36; + $ddate_U = gmmktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y); + $ddate_U = $ddate_U - $time_zn; + $post_date = gmdate('Y-m-d H:i:s', $ddate_U + $time_difference); + $post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U); + } + } + endforeach; + + $subject = trim(str_replace(get_settings('subjectprefix'), '', $subject)); + + if ($content_type == 'multipart/alternative') { + $content = explode('--'.$boundary, $content); + $content = $content[2]; + $content = explode('Content-Transfer-Encoding: quoted-printable', $content); + $content = strip_tags($content[1], '


    '); + } + $content = trim($content); + // Captures any text in the body after $phone_delim as the body + $content = explode($phone_delim, $content); + $content[1] ? $content = $content[1] : $content = $content[0]; + + echo "

    Content-type: $content_type, boundary: $boundary

    \n"; + echo "

    Raw content:

    ".$content.'

    '; + + $content = trim($content); + + $post_content = apply_filters('phone_content', $content); + + $post_title = xmlrpc_getposttitle($content); + + if ($post_title == '') $post_title = $subject; + + if (empty($post_categories)) $post_categories[] = get_settings('default_email_category'); + + $post_category = $post_categories; + + // or maybe we should leave the choice to email drafts? propose a way + $post_status = 'publish'; + + $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status'); + $post_data = add_magic_quotes($post_data); + + $post_ID = wp_insert_post($post_data); + + if (!$post_ID) { + // we couldn't post, for whatever reason. better move forward to the next email + continue; + } + + do_action('publish_phone', $post_ID); + + echo "\n

    Author: $post_author

    "; + echo "\n

    Posted title: $post_title
    "; + echo "\nPosted content:

    ".$content.'

    '; + + if(!$pop3->delete($i)) { + echo '

    Oops '.$pop3->ERROR.'

    '; + $pop3->reset(); + exit; + } else { + echo "

    Mission complete, message $i deleted.

    "; + } + +endfor; + +$pop3->quit(); + +?> \ No newline at end of file diff --git a/wp-pass.php b/wp-pass.php new file mode 100644 index 00000000..d7d23a66 --- /dev/null +++ b/wp-pass.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/wp-rdf.php b/wp-rdf.php new file mode 100644 index 00000000..a38d1ea2 --- /dev/null +++ b/wp-rdf.php @@ -0,0 +1,57 @@ + +'; ?> + + +> +"> + <?php bloginfo_rss('name') ?> + + + + + hourly + 1 + 2000-01-01T12:00+00:00 + + + + + + + + + + + + <?php the_title_rss() ?> + + post_date_gmt, false); ?> + + + + + + + ]]> + + + + + diff --git a/wp-register.php b/wp-register.php new file mode 100644 index 00000000..49798c33 --- /dev/null +++ b/wp-register.php @@ -0,0 +1,161 @@ +ERROR
    : Please enter a username.'); + + /* checking e-mail address */ + if ($user_email == '') { + $errors['user_email'] = __('ERROR: Please type your e-mail address.'); + } else if (!is_email($user_email)) { + $errors['user_email'] = __('ERROR: The email address isn’t correct.'); + $user_email = ''; + } + + if ( ! validate_username($user_login) ) { + $errors['user_login'] = __('ERROR: This username is invalid. Please enter a valid username.'); + $user_login = ''; + } + + if ( username_exists( $user_login ) ) + $errors['user_login'] = __('ERROR: This username is already registered, please choose another one.'); + + /* checking the email isn't already used by another user */ + $email_exists = $wpdb->get_row("SELECT user_email FROM $wpdb->users WHERE user_email = '$user_email'"); + if ( $email_exists) + die (__('ERROR: This email address is already registered, please supply another.')); + + if ( 0 == count($errors) ) { + $password = substr( md5( uniqid( microtime() ) ), 0, 7); + + $user_id = wp_create_user( $user_login, $password, $user_email ); + if ( !$user_id ) + $errors['user_id'] = sprintf(__('ERROR: Couldn’t register you... please contact the webmaster !'), get_settings('admin_email')); + else + wp_new_user_notification($user_id, $password); + } + + if ( 0 == count($errors) ) { + + ?> + + + + WordPress » <?php _e('Registration Complete') ?> + + + + + + +
    +

    +

    " . wp_specialchars($user_login) . "") ?>
    + ' . __('emailed to you') . '') ?>
    + " . wp_specialchars($user_email) . "") ?>

    +

    »

    +
    + + + + + + + + WordPress » <?php _e('Registration Form') ?> + + + + + + +
    +

    WordPress

    +

    + +
    +
      + $error"; + ?> +
    +
    + +
    +

    +

    +


    +

    +

    +
    + +
    + + + + + + + + WordPress » <?php _e('Registration Currently Disabled') ?> + + + + + + +
    +

    +


    + +

    +
    + + + + + diff --git a/wp-rss.php b/wp-rss.php new file mode 100644 index 00000000..aa4a6360 --- /dev/null +++ b/wp-rss.php @@ -0,0 +1,37 @@ + +'; ?> + + + + <?php bloginfo_rss('name') ?> + + + + http://backend.userland.com/rss092 + + + + + + <?php the_title_rss() ?> + + ]]> + + + + + + + + + diff --git a/wp-rss2.php b/wp-rss2.php new file mode 100644 index 00000000..8f42acaa --- /dev/null +++ b/wp-rss2.php @@ -0,0 +1,56 @@ + +'; ?> + + + +> + + + <?php bloginfo_rss('name'); ?> + + + + http://wordpress.org/?v= + + + + + <?php the_title_rss() ?> + + + + + + + + + ]]> + + ]]> + post_content ) > 0 ) : ?> + ]]> + + ]]> + + + + + + + + + diff --git a/wp-settings.php b/wp-settings.php new file mode 100644 index 00000000..312c52e1 --- /dev/null +++ b/wp-settings.php @@ -0,0 +1,226 @@ + $v ) + if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) + unset($GLOBALS[$k]); +} + +unregister_GLOBALS(); + +$HTTP_USER_AGENT = getenv('HTTP_USER_AGENT'); +unset( $wp_filter, $cache_userdata, $cache_lastcommentmodified, $cache_lastpostdate, $cache_settings, $category_cache, $cache_categories ); + +if ( ! isset($blog_id) ) + $blog_id = 1; + +// Fix for IIS, which doesn't set REQUEST_URI +if ( empty( $_SERVER['REQUEST_URI'] ) ) { + $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI? + + // Append the query string if it exists and isn't null + if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { + $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; + } +} + +// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests +if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) ) + $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; + +// Fix for Dreamhost and other PHP as CGI hosts +if ( strstr( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) ) + unset($_SERVER['PATH_INFO']); + +// Fix empty PHP_SELF +$PHP_SELF = $_SERVER['PHP_SELF']; +if ( empty($PHP_SELF) ) + $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]); + +if ( !(phpversion() >= '4.1') ) + die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' ); + +if ( !extension_loaded('mysql') ) + die( 'Your PHP installation appears to be missing the MySQL which is required for WordPress.' ); + +function timer_start() { + global $timestart; + $mtime = explode(' ', microtime() ); + $mtime = $mtime[1] + $mtime[0]; + $timestart = $mtime; + return true; +} +timer_start(); + +// Change to E_ALL for development/debugging +error_reporting(E_ALL ^ E_NOTICE); + +// For an advanced caching plugin to use, static because you would only want one +if ( defined('WP_CACHE') ) + require (ABSPATH . 'wp-content/advanced-cache.php'); + +define('WPINC', 'wp-includes'); +require_once (ABSPATH . WPINC . '/wp-db.php'); + +// Table names +$wpdb->posts = $table_prefix . 'posts'; +$wpdb->users = $table_prefix . 'users'; +$wpdb->categories = $table_prefix . 'categories'; +$wpdb->post2cat = $table_prefix . 'post2cat'; +$wpdb->comments = $table_prefix . 'comments'; +$wpdb->links = $table_prefix . 'links'; +$wpdb->linkcategories = $table_prefix . 'linkcategories'; +$wpdb->options = $table_prefix . 'options'; +$wpdb->postmeta = $table_prefix . 'postmeta'; +$wpdb->usermeta = $table_prefix . 'usermeta'; + +$wpdb->prefix = $table_prefix; + +if ( defined('CUSTOM_USER_TABLE') ) + $wpdb->users = CUSTOM_USER_TABLE; +if ( defined('CUSTOM_USER_META_TABLE') ) + $wpdb->usermeta = CUSTOM_USER_META_TABLE; + +// We're going to need to keep this around for a few months even though we're not using it internally + +$tableposts = $wpdb->posts; +$tableusers = $wpdb->users; +$tablecategories = $wpdb->categories; +$tablepost2cat = $wpdb->post2cat; +$tablecomments = $wpdb->comments; +$tablelinks = $wpdb->links; +$tablelinkcategories = $wpdb->linkcategories; +$tableoptions = $wpdb->options; +$tablepostmeta = $wpdb->postmeta; + +if ( file_exists(ABSPATH . 'wp-content/object-cache.php') ) + require (ABSPATH . 'wp-content/object-cache.php'); +else + require (ABSPATH . WPINC . '/cache.php'); + +// To disable persistant caching, add the below line to your wp-config.php file, uncommented of course. +// define('DISABLE_CACHE', true); + +wp_cache_init(); + +require (ABSPATH . WPINC . '/functions.php'); +require (ABSPATH . WPINC . '/default-filters.php'); +require_once (ABSPATH . WPINC . '/wp-l10n.php'); + +$wpdb->hide_errors(); +$db_check = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'"); +if ( !$db_check && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) { + if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) + $link = 'install.php'; + else + $link = 'wp-admin/install.php'; + die(sprintf(__("It doesn't look like you've installed WP yet. Try running install.php."), $link)); +} +$wpdb->show_errors(); + +require (ABSPATH . WPINC . '/functions-formatting.php'); +require (ABSPATH . WPINC . '/functions-post.php'); +require (ABSPATH . WPINC . '/capabilities.php'); +require (ABSPATH . WPINC . '/classes.php'); +require (ABSPATH . WPINC . '/template-functions-general.php'); +require (ABSPATH . WPINC . '/template-functions-links.php'); +require (ABSPATH . WPINC . '/template-functions-author.php'); +require (ABSPATH . WPINC . '/template-functions-post.php'); +require (ABSPATH . WPINC . '/template-functions-category.php'); +require (ABSPATH . WPINC . '/comment-functions.php'); +require (ABSPATH . WPINC . '/feed-functions.php'); +require (ABSPATH . WPINC . '/links.php'); +require (ABSPATH . WPINC . '/kses.php'); +require (ABSPATH . WPINC . '/version.php'); + +if (!strstr($_SERVER['PHP_SELF'], 'install.php')) : + // Used to guarantee unique hash cookies + $cookiehash = md5(get_settings('siteurl')); // Remove in 1.4 + define('COOKIEHASH', $cookiehash); +endif; + +if ( !defined('USER_COOKIE') ) + define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH); +if ( !defined('PASS_COOKIE') ) + define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH); +if ( !defined('COOKIEPATH') ) + define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' ) ); +if ( !defined('SITECOOKIEPATH') ) + define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('siteurl') . '/' ) ); +if ( !defined('COOKIE_DOMAIN') ) + define('COOKIE_DOMAIN', false); + +require (ABSPATH . WPINC . '/vars.php'); + +// Check for hacks file if the option is enabled +if (get_settings('hack_file')) { + if (file_exists(ABSPATH . '/my-hacks.php')) + require(ABSPATH . '/my-hacks.php'); +} + +if ( get_settings('active_plugins') ) { + $current_plugins = get_settings('active_plugins'); + if ( is_array($current_plugins) ) { + foreach ($current_plugins as $plugin) { + if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin)) + include_once(ABSPATH . 'wp-content/plugins/' . $plugin); + } + } +} + +require (ABSPATH . WPINC . '/pluggable-functions.php'); + +if ( defined('WP_CACHE') && function_exists('wp_cache_postload') ) + wp_cache_postload(); + +do_action('plugins_loaded'); + +// If already slashed, strip. +if ( get_magic_quotes_gpc() ) { + $_GET = stripslashes_deep($_GET ); + $_POST = stripslashes_deep($_POST ); + $_COOKIE = stripslashes_deep($_COOKIE); +} + +// Escape with wpdb. +$_GET = add_magic_quotes($_GET ); +$_POST = add_magic_quotes($_POST ); +$_COOKIE = add_magic_quotes($_COOKIE); +$_SERVER = add_magic_quotes($_SERVER); + +$wp_query = new WP_Query(); +$wp_rewrite = new WP_Rewrite(); +$wp = new WP(); + +define('TEMPLATEPATH', get_template_directory()); + +// Load the default text localization domain. +load_default_textdomain(); + +// Pull in locale data after loading text domain. +require_once(ABSPATH . WPINC . '/locale.php'); + +// Load functions for active theme. +if ( file_exists(TEMPLATEPATH . "/functions.php") ) + include(TEMPLATEPATH . "/functions.php"); + +function shutdown_action_hook() { + do_action('shutdown'); + wp_cache_close(); +} +register_shutdown_function('shutdown_action_hook'); + +// Everything is loaded and initialized. +do_action('init'); + +?> \ No newline at end of file diff --git a/wp-trackback.php b/wp-trackback.php new file mode 100644 index 00000000..fb7845ee --- /dev/null +++ b/wp-trackback.php @@ -0,0 +1,98 @@ +\n"; + echo "\n"; + echo "1\n"; + echo "$error_message\n"; + echo ""; + die(); + } else { + echo '\n"; + echo "\n"; + echo "0\n"; + echo ""; + } +} + +// trackback is done by a POST +$request_array = 'HTTP_POST_VARS'; + +if ( !$_GET['tb_id'] ) { + $tb_id = explode('/', $_SERVER['REQUEST_URI']); + $tb_id = intval( $tb_id[ count($tb_id) - 1 ] ); +} + +$tb_url = $_POST['url']; +$title = $_POST['title']; +$excerpt = $_POST['excerpt']; +$blog_name = $_POST['blog_name']; +$charset = $_POST['charset']; + +if ($charset) + $charset = strtoupper( trim($charset) ); +else + $charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS'; + +if ( function_exists('mb_convert_encoding') ) { // For international trackbacks + $title = mb_convert_encoding($title, get_settings('blog_charset'), $charset); + $excerpt = mb_convert_encoding($excerpt, get_settings('blog_charset'), $charset); + $blog_name = mb_convert_encoding($blog_name, get_settings('blog_charset'), $charset); +} + +if ( is_single() || is_page() ) + $tb_id = $posts[0]->ID; + +if ( !intval( $tb_id ) ) + trackback_response(1, 'I really need an ID for this to work.'); + +if (empty($title) && empty($tb_url) && empty($blog_name)) { + // If it doesn't look like a trackback at all... + header('Location: ' . get_permalink($tb_id)); + exit; +} + +if ( !empty($tb_url) && !empty($title) && !empty($tb_url) ) { + header('Content-Type: text/xml; charset=' . get_option('blog_charset') ); + + $pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id"); + + if ( 'open' != $pingstatus ) + trackback_response(1, 'Sorry, trackbacks are closed for this item.'); + + $title = wp_specialchars( strip_tags( $title ) ); + $excerpt = strip_tags($excerpt); + if ( function_exists('mb_strcut') ) { // For international trackbacks + $excerpt = mb_strcut($excerpt, 0, 252, get_settings('blog_charset')) . '...'; + $title = mb_strcut($title, 0, 250, get_settings('blog_charset')) . '...'; + } else { + $excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt; + $title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title; + } + + $comment_post_ID = $tb_id; + $comment_author = $blog_name; + $comment_author_email = ''; + $comment_author_url = $tb_url; + $comment_content = "$title\n\n$excerpt"; + $comment_type = 'trackback'; + + $dupe = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_author_url = '$comment_author_url'"); + if ( $dupe ) + trackback_response(1, 'We already have a ping from that URI for this post.'); + + $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type'); + + wp_new_comment($commentdata); + + do_action('trackback_post', $wpdb->insert_id); + trackback_response(0); +} +?> \ No newline at end of file diff --git a/xmlrpc.php b/xmlrpc.php new file mode 100644 index 00000000..045acba7 --- /dev/null +++ b/xmlrpc.php @@ -0,0 +1,1289 @@ + +'; ?> + + + WordPress + http://wordpress.org/ + + + + + + + + +methods = array( + // Blogger API + 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs', + 'blogger.getUserInfo' => 'this:blogger_getUserInfo', + 'blogger.getPost' => 'this:blogger_getPost', + 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts', + 'blogger.getTemplate' => 'this:blogger_getTemplate', + 'blogger.setTemplate' => 'this:blogger_setTemplate', + 'blogger.newPost' => 'this:blogger_newPost', + 'blogger.editPost' => 'this:blogger_editPost', + 'blogger.deletePost' => 'this:blogger_deletePost', + + // MetaWeblog API (with MT extensions to structs) + 'metaWeblog.newPost' => 'this:mw_newPost', + 'metaWeblog.editPost' => 'this:mw_editPost', + 'metaWeblog.getPost' => 'this:mw_getPost', + 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts', + 'metaWeblog.getCategories' => 'this:mw_getCategories', + 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject', + + // MetaWeblog API aliases for Blogger API + // see http://www.xmlrpc.com/stories/storyReader$2460 + 'metaWeblog.deletePost' => 'this:blogger_deletePost', + 'metaWeblog.getTemplate' => 'this:blogger_getTemplate', + 'metaWeblog.setTemplate' => 'this:blogger_setTemplate', + 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs', + + // MovableType API + 'mt.getCategoryList' => 'this:mt_getCategoryList', + 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles', + 'mt.getPostCategories' => 'this:mt_getPostCategories', + 'mt.setPostCategories' => 'this:mt_setPostCategories', + 'mt.supportedMethods' => 'this:mt_supportedMethods', + 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters', + 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings', + 'mt.publishPost' => 'this:mt_publishPost', + + // PingBack + 'pingback.ping' => 'this:pingback_ping', + 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks', + + 'demo.sayHello' => 'this:sayHello', + 'demo.addTwoNumbers' => 'this:addTwoNumbers' + ); + $this->methods = apply_filters('xmlrpc_methods', $this->methods); + $this->IXR_Server($this->methods); + } + + function sayHello($args) { + return 'Hello!'; + } + + function addTwoNumbers($args) { + $number1 = $args[0]; + $number2 = $args[1]; + return $number1 + $number2; + } + + function login_pass_ok($user_login, $user_pass) { + if (!user_pass_ok($user_login, $user_pass)) { + $this->error = new IXR_Error(403, 'Bad login/pass combination.'); + return false; + } + return true; + } + + function escape(&$array) { + global $wpdb; + + foreach ($array as $k => $v) { + if (is_array($v)) { + $this->escape($array[$k]); + } else if (is_object($v)) { + //skip + } else { + $array[$k] = $wpdb->escape($v); + } + } + } + + /* Blogger API functions + * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/ + */ + + + /* blogger.getUsersBlogs will make more sense once we support multiple blogs */ + function blogger_getUsersBlogs($args) { + + $this->escape($args); + + $user_login = $args[1]; + $user_pass = $args[2]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + set_current_user(0, $user_login); + $is_admin = current_user_can('level_8'); + + $struct = array( + 'isAdmin' => $is_admin, + 'url' => get_settings('home') . '/', + 'blogid' => '1', + 'blogName' => get_settings('blogname') + ); + + return array($struct); + } + + + /* blogger.getUsersInfo gives your client some info about you, so you don't have to */ + function blogger_getUserInfo($args) { + + $this->escape($args); + + $user_login = $args[1]; + $user_pass = $args[2]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $user_data = get_userdatabylogin($user_login); + + $struct = array( + 'nickname' => $user_data->nickname, + 'userid' => $user_data->ID, + 'url' => $user_data->user_url, + 'email' => $user_data->user_email, + 'lastname' => $user_data->last_name, + 'firstname' => $user_data->first_name + ); + + return $struct; + } + + + /* blogger.getPost ...gets a post */ + function blogger_getPost($args) { + + $this->escape($args); + + $post_ID = $args[1]; + $user_login = $args[2]; + $user_pass = $args[3]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $user_data = get_userdatabylogin($user_login); + $post_data = wp_get_single_post($post_ID, ARRAY_A); + + $categories = implode(',', wp_get_post_cats(1, $post_ID)); + + $content = ''.stripslashes($post_data['post_title']).''; + $content .= ''.$categories.''; + $content .= stripslashes($post_data['post_content']); + + $struct = array( + 'userid' => $post_data['post_author'], + 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'])), + 'content' => $content, + 'postid' => $post_data['ID'] + ); + + return $struct; + } + + + /* blogger.getRecentPosts ...gets recent posts */ + function blogger_getRecentPosts($args) { + + global $wpdb; + + $this->escape($args); + + $blog_ID = $args[1]; /* though we don't use it yet */ + $user_login = $args[2]; + $user_pass = $args[3]; + $num_posts = $args[4]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $posts_list = wp_get_recent_posts($num_posts); + + if (!$posts_list) { + $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.'); + return $this->error; + } + + foreach ($posts_list as $entry) { + + $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); + $categories = implode(',', wp_get_post_cats(1, $entry['ID'])); + + $content = ''.stripslashes($entry['post_title']).''; + $content .= ''.$categories.''; + $content .= stripslashes($entry['post_content']); + + $struct[] = array( + 'userid' => $entry['post_author'], + 'dateCreated' => new IXR_Date($post_date), + 'content' => $content, + 'postid' => $entry['ID'], + ); + + } + + $recent_posts = array(); + for ($j=0; $jescape($args); + + $blog_ID = $args[1]; + $user_login = $args[2]; + $user_pass = $args[3]; + $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + set_current_user(0, $user_login); + if ( !current_user_can('edit_themes') ) { + return new IXR_Error(401, 'Sorry, this user can not edit the template.'); + } + + /* warning: here we make the assumption that the weblog's URI is on the same server */ + $filename = get_settings('home') . '/'; + $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); + + $f = fopen($filename, 'r'); + $content = fread($f, filesize($filename)); + fclose($f); + + /* so it is actually editable with a windows/mac client */ + // FIXME: (or delete me) do we really want to cater to bad clients at the expense of good ones by BEEPing up their line breaks? commented. $content = str_replace("\n", "\r\n", $content); + + return $content; + } + + + /* blogger.setTemplate updates the content of blog_filename */ + function blogger_setTemplate($args) { + + $this->escape($args); + + $blog_ID = $args[1]; + $user_login = $args[2]; + $user_pass = $args[3]; + $content = $args[4]; + $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + set_current_user(0, $user_login); + if ( !current_user_can('edit_themes') ) { + return new IXR_Error(401, 'Sorry, this user can not edit the template.'); + } + + /* warning: here we make the assumption that the weblog's URI is on the same server */ + $filename = get_settings('home') . '/'; + $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); + + if ($f = fopen($filename, 'w+')) { + fwrite($f, $content); + fclose($f); + } else { + return new IXR_Error(500, 'Either the file is not writable, or something wrong happened. The file has not been updated.'); + } + + return true; + } + + + /* blogger.newPost ...creates a new post */ + function blogger_newPost($args) { + + global $wpdb; + + $this->escape($args); + + $blog_ID = $args[1]; /* though we don't use it yet */ + $user_login = $args[2]; + $user_pass = $args[3]; + $content = $args[4]; + $publish = $args[5]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $cap = ($publish) ? 'publish_posts' : 'edit_posts'; + $user = set_current_user(0, $user_login); + if ( !current_user_can($cap) ) + return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.'); + + $post_status = ($publish) ? 'publish' : 'draft'; + + $post_author = $user->ID; + + $post_title = xmlrpc_getposttitle($content); + $post_category = xmlrpc_getpostcategory($content); + $post_content = xmlrpc_removepostdata($content); + + $post_date = current_time('mysql'); + $post_date_gmt = current_time('mysql', 1); + + $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status'); + + $post_ID = wp_insert_post($post_data); + + if (!$post_ID) { + return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.'); + } + + logIO('O', "Posted ! ID: $post_ID"); + + return $post_ID; + } + + + /* blogger.editPost ...edits a post */ + function blogger_editPost($args) { + + global $wpdb; + + $this->escape($args); + + $post_ID = $args[1]; + $user_login = $args[2]; + $user_pass = $args[3]; + $content = $args[4]; + $publish = $args[5]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $actual_post = wp_get_single_post($post_ID,ARRAY_A); + + if (!$actual_post) { + return new IXR_Error(404, 'Sorry, no such post.'); + } + + $this->escape($actual_post); + + set_current_user(0, $user_login); + if ( !current_user_can('edit_post', $post_ID) ) + return new IXR_Error(401, 'Sorry, you do not have the right to edit this post.'); + + extract($actual_post); + + $post_title = xmlrpc_getposttitle($content); + $post_category = xmlrpc_getpostcategory($content); + $post_content = xmlrpc_removepostdata($content); + + $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); + + $result = wp_update_post($postdata); + + if (!$result) { + return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be edited.'); + } + + return true; + } + + + /* blogger.deletePost ...deletes a post */ + function blogger_deletePost($args) { + + global $wpdb; + + $this->escape($args); + + $post_ID = $args[1]; + $user_login = $args[2]; + $user_pass = $args[3]; + $publish = $args[4]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $actual_post = wp_get_single_post($post_ID,ARRAY_A); + + if (!$actual_post) { + return new IXR_Error(404, 'Sorry, no such post.'); + } + + set_current_user(0, $user_login); + if ( !current_user_can('edit_post', $post_ID) ) + return new IXR_Error(401, 'Sorry, you do not have the right to delete this post.'); + + $result = wp_delete_post($post_ID); + + if (!$result) { + return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be deleted.'); + } + + return true; + } + + + + /* MetaWeblog API functions + * specs on wherever Dave Winer wants them to be + */ + + /* metaweblog.newPost creates a post */ + function mw_newPost($args) { + + global $wpdb, $post_default_category; + + $this->escape($args); + + $blog_ID = $args[0]; // we will support this in the near future + $user_login = $args[1]; + $user_pass = $args[2]; + $content_struct = $args[3]; + $publish = $args[4]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $user = set_current_user(0, $user_login); + if ( !current_user_can('publish_posts') ) + return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.'); + + $post_author = $user->ID; + + $post_title = $content_struct['title']; + $post_content = apply_filters( 'content_save_pre', $content_struct['description'] ); + $post_status = $publish ? 'publish' : 'draft'; + + $post_excerpt = $content_struct['mt_excerpt']; + $post_more = $content_struct['mt_text_more']; + + $comment_status = (empty($content_struct['mt_allow_comments'])) ? + get_settings('default_comment_status') + : $content_struct['mt_allow_comments']; + + $ping_status = (empty($content_struct['mt_allow_pings'])) ? + get_settings('default_ping_status') + : $content_struct['mt_allow_pings']; + + if ($post_more) { + $post_content = $post_content . "\n\n" . $post_more; + } + + $to_ping = $content_struct['mt_tb_ping_urls']; + + // Do some timestamp voodoo + $dateCreatedd = $content_struct['dateCreated']; + if (!empty($dateCreatedd)) { + $dateCreated = $dateCreatedd->getIso(); + $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); + $post_date_gmt = iso8601_to_datetime($dateCreated, GMT); + } else { + $post_date = current_time('mysql'); + $post_date_gmt = current_time('mysql', 1); + } + + $catnames = $content_struct['categories']; + logIO('O', 'Post cats: ' . printr($catnames,true)); + $post_category = array(); + + if (is_array($catnames)) { + foreach ($catnames as $cat) { + $post_category[] = get_cat_ID($cat); + } + } + + // We've got all the data -- post it: + $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping'); + + $post_ID = wp_insert_post($postdata); + + if (!$post_ID) { + return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.'); + } + + logIO('O', "Posted ! ID: $post_ID"); + + return strval($post_ID); + } + + + /* metaweblog.editPost ...edits a post */ + function mw_editPost($args) { + + global $wpdb, $post_default_category; + + $this->escape($args); + + $post_ID = $args[0]; + $user_login = $args[1]; + $user_pass = $args[2]; + $content_struct = $args[3]; + $publish = $args[4]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + set_current_user(0, $user_login); + if ( !current_user_can('edit_post', $post_ID) ) + return new IXR_Error(401, 'Sorry, you can not edit this post.'); + + $postdata = wp_get_single_post($post_ID, ARRAY_A); + extract($postdata); + $this->escape($postdata); + + $post_title = $content_struct['title']; + $post_content = apply_filters( 'content_save_pre', $content_struct['description'] ); + $catnames = $content_struct['categories']; + + $post_category = array(); + + if (is_array($catnames)) { + foreach ($catnames as $cat) { + $post_category[] = get_cat_ID($cat); + } + } + + $post_excerpt = $content_struct['mt_excerpt']; + $post_more = $content_struct['mt_text_more']; + $post_status = $publish ? 'publish' : 'draft'; + + if ($post_more) { + $post_content = $post_content . "\n\n" . $post_more; + } + + $to_ping = $content_struct['mt_tb_ping_urls']; + + $comment_status = (empty($content_struct['mt_allow_comments'])) ? + get_settings('default_comment_status') + : $content_struct['mt_allow_comments']; + + $ping_status = (empty($content_struct['mt_allow_pings'])) ? + get_settings('default_ping_status') + : $content_struct['mt_allow_pings']; + + // Do some timestamp voodoo + $dateCreatedd = $content_struct['dateCreated']; + if (!empty($dateCreatedd)) { + $dateCreated = $dateCreatedd->getIso(); + $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); + $post_date_gmt = iso8601_to_datetime($dateCreated, GMT); + } else { + $post_date = $postdata['post_date']; + $post_date_gmt = $postdata['post_date_gmt']; + } + + // We've got all the data -- post it: + $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping'); + + $result = wp_update_post($newpost); + if (!$result) { + return new IXR_Error(500, 'Sorry, your entry could not be edited. Something wrong happened.'); + } + + logIO('O',"(MW) Edited ! ID: $post_ID"); + + return true; + } + + + /* metaweblog.getPost ...returns a post */ + function mw_getPost($args) { + + global $wpdb; + + $this->escape($args); + + $post_ID = $args[0]; + $user_login = $args[1]; + $user_pass = $args[2]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $postdata = wp_get_single_post($post_ID, ARRAY_A); + + if ($postdata['post_date'] != '') { + + $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']); + + $categories = array(); + $catids = wp_get_post_cats('', $post_ID); + foreach($catids as $catid) { + $categories[] = get_cat_name($catid); + } + + $post = get_extended($postdata['post_content']); + $link = post_permalink($postdata['ID']); + + $allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0; + $allow_pings = ('open' == $postdata['ping_status']) ? 1 : 0; + + $resp = array( + 'dateCreated' => new IXR_Date($post_date), + 'userid' => $postdata['post_author'], + 'postid' => $postdata['ID'], + 'description' => $post['main'], + 'title' => $postdata['post_title'], + 'link' => $link, + 'permaLink' => $link, +// commented out because no other tool seems to use this +// 'content' => $entry['post_content'], + 'categories' => $categories, + 'mt_excerpt' => $postdata['post_excerpt'], + 'mt_text_more' => $post['extended'], + 'mt_allow_comments' => $allow_comments, + 'mt_allow_pings' => $allow_pings + ); + + return $resp; + } else { + return new IXR_Error(404, 'Sorry, no such post.'); + } + } + + + /* metaweblog.getRecentPosts ...returns recent posts */ + function mw_getRecentPosts($args) { + + $this->escape($args); + + $blog_ID = $args[0]; + $user_login = $args[1]; + $user_pass = $args[2]; + $num_posts = $args[3]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $posts_list = wp_get_recent_posts($num_posts); + + if (!$posts_list) { + $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.'); + return $this->error; + } + + foreach ($posts_list as $entry) { + + $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); + $categories = array(); + $catids = wp_get_post_cats('', $entry['ID']); + foreach($catids as $catid) { + $categories[] = get_cat_name($catid); + } + + $post = get_extended($entry['post_content']); + $link = post_permalink($entry['ID']); + + $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0; + $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0; + + $struct[] = array( + 'dateCreated' => new IXR_Date($post_date), + 'userid' => $entry['post_author'], + 'postid' => $entry['ID'], + 'description' => $post['main'], + 'title' => $entry['post_title'], + 'link' => $link, + 'permaLink' => $link, +// commented out because no other tool seems to use this +// 'content' => $entry['post_content'], + 'categories' => $categories, + 'mt_excerpt' => $entry['post_excerpt'], + 'mt_text_more' => $post['extended'], + 'mt_allow_comments' => $allow_comments, + 'mt_allow_pings' => $allow_pings + ); + + } + + $recent_posts = array(); + for ($j=0; $jescape($args); + + $blog_ID = $args[0]; + $user_login = $args[1]; + $user_pass = $args[2]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $categories_struct = array(); + + // FIXME: can we avoid using direct SQL there? + if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name FROM $wpdb->categories", ARRAY_A)) { + foreach ($cats as $cat) { + $struct['categoryId'] = $cat['cat_ID']; + $struct['description'] = $cat['cat_name']; + $struct['categoryName'] = $cat['cat_name']; + $struct['htmlUrl'] = wp_specialchars(get_category_link($cat['cat_ID'])); + $struct['rssUrl'] = wp_specialchars(get_category_rss_link(false, $cat['cat_ID'], $cat['cat_name'])); + + $categories_struct[] = $struct; + } + } + + return $categories_struct; + } + + + /* metaweblog.newMediaObject uploads a file, following your settings */ + function mw_newMediaObject($args) { + // adapted from a patch by Johann Richard + // http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/ + + global $wpdb; + + $blog_ID = $wpdb->escape($args[0]); + $user_login = $wpdb->escape($args[1]); + $user_pass = $wpdb->escape($args[2]); + $data = $args[3]; + + $name = $data['name']; + $type = $data['type']; + $bits = $data['bits']; + + logIO('O', '(MW) Received '.strlen($bits).' bytes'); + + if ( !$this->login_pass_ok($user_login, $user_pass) ) + return $this->error; + + set_current_user(0, $user_login); + if ( !current_user_can('upload_files') ) { + logIO('O', '(MW) User does not have upload_files capability'); + $this->error = new IXR_Error(401, 'You are not allowed to upload files to this site.'); + return $this->error; + } + + $upload = wp_upload_bits($name, $type, $bits); + if ( ! empty($upload['error']) ) { + logIO('O', '(MW) Could not write file '.$name); + return new IXR_Error(500, 'Could not write file '.$name); + } + + return array('url' => $upload['url']); + } + + + /* MovableType API functions + * specs on http://www.movabletype.org/docs/mtmanual_programmatic.html + */ + + /* mt.getRecentPostTitles ...returns recent posts' titles */ + function mt_getRecentPostTitles($args) { + + $this->escape($args); + + $blog_ID = $args[0]; + $user_login = $args[1]; + $user_pass = $args[2]; + $num_posts = $args[3]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $posts_list = wp_get_recent_posts($num_posts); + + if (!$posts_list) { + $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.'); + return $this->error; + } + + foreach ($posts_list as $entry) { + + $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); + + $struct[] = array( + 'dateCreated' => new IXR_Date($post_date), + 'userid' => $entry['post_author'], + 'postid' => $entry['ID'], + 'title' => $entry['post_title'], + ); + + } + + $recent_posts = array(); + for ($j=0; $jescape($args); + + $blog_ID = $args[0]; + $user_login = $args[1]; + $user_pass = $args[2]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $categories_struct = array(); + + // FIXME: can we avoid using direct SQL there? + if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) { + foreach ($cats as $cat) { + $struct['categoryId'] = $cat['cat_ID']; + $struct['categoryName'] = $cat['cat_name']; + + $categories_struct[] = $struct; + } + } + + return $categories_struct; + } + + + /* mt.getPostCategories ...returns a post's categories */ + function mt_getPostCategories($args) { + + $this->escape($args); + + $post_ID = $args[0]; + $user_login = $args[1]; + $user_pass = $args[2]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + $categories = array(); + $catids = wp_get_post_cats('', intval($post_ID)); + // first listed category will be the primary category + $isPrimary = true; + foreach($catids as $catid) { + $categories[] = array( + 'categoryName' => get_cat_name($catid), + 'categoryId' => $catid, + 'isPrimary' => $isPrimary + ); + $isPrimary = false; + } + + return $categories; + } + + + /* mt.setPostCategories ...sets a post's categories */ + function mt_setPostCategories($args) { + + $this->escape($args); + + $post_ID = $args[0]; + $user_login = $args[1]; + $user_pass = $args[2]; + $categories = $args[3]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + set_current_user(0, $user_login); + if ( !current_user_can('edit_post', $post_ID) ) + return new IXR_Error(401, 'Sorry, you can not edit this post.'); + + foreach($categories as $cat) { + $catids[] = $cat['categoryId']; + } + + wp_set_post_cats('', $post_ID, $catids); + + return true; + } + + + /* mt.supportedMethods ...returns an array of methods supported by this server */ + function mt_supportedMethods($args) { + + $supported_methods = array(); + foreach($this->methods as $key=>$value) { + $supported_methods[] = $key; + } + + return $supported_methods; + } + + + /* mt.supportedTextFilters ...returns an empty array because we don't + support per-post text filters yet */ + function mt_supportedTextFilters($args) { + return array(); + } + + + /* mt.getTrackbackPings ...returns trackbacks sent to a given post */ + function mt_getTrackbackPings($args) { + + global $wpdb; + + $post_ID = intval($args); + + $actual_post = wp_get_single_post($post_ID, ARRAY_A); + + if (!$actual_post) { + return new IXR_Error(404, 'Sorry, no such post.'); + } + + $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID"); + + if (!$comments) { + return array(); + } + + $trackback_pings = array(); + foreach($comments as $comment) { + if ( 'trackback' == $comment->comment_type ) { + $content = $comment->comment_content; + $title = substr($content, 8, (strpos($content, '') - 8)); + $trackback_pings[] = array( + 'pingTitle' => $title, + 'pingURL' => $comment->comment_author_url, + 'pingIP' => $comment->comment_author_IP + ); + } + } + + return $trackback_pings; + } + + + /* mt.publishPost ...sets a post's publish status to 'publish' */ + function mt_publishPost($args) { + + $this->escape($args); + + $post_ID = $args[0]; + $user_login = $args[1]; + $user_pass = $args[2]; + + if (!$this->login_pass_ok($user_login, $user_pass)) { + return $this->error; + } + + set_current_user(0, $user_login); + if ( !current_user_can('edit_post', $post_ID) ) + return new IXR_Error(401, 'Sorry, you can not edit this post.'); + + $postdata = wp_get_single_post($post_ID,ARRAY_A); + + $postdata['post_status'] = 'publish'; + + // retain old cats + $cats = wp_get_post_cats('',$post_ID); + $postdata['post_category'] = $cats; + $this->escape($postdata); + + $result = wp_update_post($postdata); + + return $result; + } + + + + /* PingBack functions + * specs on www.hixie.ch/specs/pingback/pingback + */ + + /* pingback.ping gets a pingback and registers it */ + function pingback_ping($args) { + global $wpdb, $wp_version; + + $this->escape($args); + + $pagelinkedfrom = $args[0]; + $pagelinkedto = $args[1]; + + $title = ''; + + $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); + $pagelinkedto = preg_replace('#&([^amp\;])#is', '&$1', $pagelinkedto); + + $error_code = -1; + + // Check if the page linked to is in our site + $pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_settings('home'))); + if( !$pos1 ) + return new IXR_Error(0, 'Is there no link to us?'); + + // let's find which post is linked to + // FIXME: does url_to_postid() cover all these cases already? + // if so, then let's use it and drop the old code. + $urltest = parse_url($pagelinkedto); + if ($post_ID = url_to_postid($pagelinkedto)) { + $way = 'url_to_postid()'; + } elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) { + // the path defines the post_ID (archives/p/XXXX) + $blah = explode('/', $match[0]); + $post_ID = $blah[1]; + $way = 'from the path'; + } elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) { + // the querystring defines the post_ID (?p=XXXX) + $blah = explode('=', $match[0]); + $post_ID = $blah[1]; + $way = 'from the querystring'; + } elseif (isset($urltest['fragment'])) { + // an #anchor is there, it's either... + if (intval($urltest['fragment'])) { + // ...an integer #XXXX (simpliest case) + $post_ID = $urltest['fragment']; + $way = 'from the fragment (numeric)'; + } elseif (preg_match('/post-[0-9]+/',$urltest['fragment'])) { + // ...a post id in the form 'post-###' + $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']); + $way = 'from the fragment (post-###)'; + } elseif (is_string($urltest['fragment'])) { + // ...or a string #title, a little more complicated + $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']); + $sql = "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE '$title'"; + if (! ($post_ID = $wpdb->get_var($sql)) ) { + // returning unknown error '0' is better than die()ing + return new IXR_Error(0, ''); + } + $way = 'from the fragment (title)'; + } + } else { + // TODO: Attempt to extract a post ID from the given URL + return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.'); + } + $post_ID = (int) $post_ID; + + + logIO("O","(PB) URI='$pagelinkedto' ID='$post_ID' Found='$way'"); + + $post = get_post($post_ID); + + if ( !$post ) // Post_ID not found + return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.'); + + if ( $post_ID == url_to_postid($pagelinkedfrom) ) + return new IXR_Error(0, 'The source URI and the target URI cannot both point to the same resource.'); + + // Check if pings are on + if ( 'closed' == $post->ping_status ) + return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.'); + + // Let's check that the remote site didn't already pingback this entry + $result = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_ID' AND comment_author_url = '$pagelinkedfrom'"); + + if ( $wpdb->num_rows ) // We already have a Pingback from this URL + return new IXR_Error(48, 'The pingback has already been registered.'); + + // very stupid, but gives time to the 'from' server to publish ! + sleep(1); + + // Let's check the remote site + $linea = wp_remote_fopen( $pagelinkedfrom ); + if ( !$linea ) + return new IXR_Error(16, 'The source URI does not exist.'); + + // Work around bug in strip_tags(): + $linea = str_replace(']*>/", "\n\n", $linea ); + + preg_match('|([^<]*?)|is', $linea, $matchtitle); + $title = $matchtitle[1]; + if ( empty( $title ) ) + return new IXR_Error(32, 'We cannot find a title on that page.'); + + $linea = strip_tags( $linea, '' ); // just keep the tag we need + + $p = explode( "\n\n", $linea ); + + $sem_regexp_pb = "/(\\/|\\\|\*|\?|\+|\.|\^|\\$|\(|\)|\[|\]|\||\{|\})/"; + $sem_regexp_fix = "\\\\$1"; + $link = preg_replace( $sem_regexp_pb, $sem_regexp_fix, $pagelinkedfrom ); + + $finished = false; + foreach ( $p as $para ) { + if ( $finished ) + continue; + if ( strstr( $para, $pagelinkedto ) ) { + $context = preg_replace( "/.*]+".$link."[^>]*>([^>]+)<\/a>.*/", "$1", $para ); + $excerpt = strip_tags( $para ); + $excerpt = trim( $excerpt ); + $use = preg_quote( $context ); + $excerpt = preg_replace("|.*?\s(.{0,100}$use.{0,100})\s|s", "$1", $excerpt); + $finished = true; + } + } + + if ( empty($context) ) // URL pattern not found + return new IXR_Error(17, 'The source URI does not contain a link to the target URI, and so cannot be used as a source.'); + + $pagelinkedfrom = preg_replace('#&([^amp\;])#is', '&$1', $pagelinkedfrom); + + $context = '[...] ' . wp_specialchars( $excerpt ) . ' [...]'; + $original_pagelinkedfrom = $pagelinkedfrom; + $pagelinkedfrom = $wpdb->escape( $pagelinkedfrom ); + $original_title = $title; + + $comment_post_ID = $post_ID; + $comment_author = $title; + $comment_author_url = $pagelinkedfrom; + $comment_content = $context; + $comment_type = 'pingback'; + + $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_content', 'comment_type'); + + wp_new_comment($commentdata); + do_action('pingback_post', $wpdb->insert_id); + + return "Pingback from $pagelinkedfrom to $pagelinkedto registered. Keep the web talking! :-)"; + } + + + /* pingback.extensions.getPingbacks returns an array of URLs + that pingbacked the given URL + specs on http://www.aquarionics.com/misc/archives/blogite/0198.html */ + function pingback_extensions_getPingbacks($args) { + + global $wpdb; + + $this->escape($args); + + $url = $args; + + $post_ID = url_to_postid($url); + if (!$post_ID) { + // We aren't sure that the resource is available and/or pingback enabled + return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.'); + } + + $actual_post = wp_get_single_post($post_ID, ARRAY_A); + + if (!$actual_post) { + // No such post = resource not found + return new IXR_Error(32, 'The specified target URI does not exist.'); + } + + $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID"); + + if (!$comments) { + return array(); + } + + $pingbacks = array(); + foreach($comments as $comment) { + if ( 'pingback' == $comment->comment_type ) + $pingbacks[] = $comment->comment_author_url; + } + + return $pingbacks; + } +} + + +$wp_xmlrpc_server = new wp_xmlrpc_server(); + +?> -- 2.44.0