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_