summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-12 11:27:54 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-12 11:27:54 +0000
commit4f3bce79bfb5851cef9e7bc655c91bb3093cc401 (patch)
tree10a0991fddeb0e075d7fa46e2b40e5dbc64d1e88
downloadwordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.tar.gz
wordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.tar.xz
wordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.zip
Initial Import
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1 7be80a69-a1ef-0310-a953-fb0f7c49ff36
-rw-r--r--Changelog-old.txt1382
-rw-r--r--README.txt40
-rw-r--r--htaccess.dist131
-rw-r--r--index.php396
-rwxr-xr-xrelease.sh73
-rw-r--r--wp-inst/Config_File.class.php389
-rw-r--r--wp-inst/Smarty.class.php1934
-rw-r--r--wp-inst/Smarty_Compiler.class.php2304
-rw-r--r--wp-inst/favicon.icobin0 -> 1406 bytes
-rw-r--r--wp-inst/go.php37
-rw-r--r--wp-inst/htaccess.dist5
-rw-r--r--wp-inst/index.php5
-rw-r--r--wp-inst/internals/core.assemble_plugin_filepath.php67
-rw-r--r--wp-inst/internals/core.assign_smarty_interface.php43
-rw-r--r--wp-inst/internals/core.create_dir_structure.php79
-rw-r--r--wp-inst/internals/core.display_debug_console.php61
-rw-r--r--wp-inst/internals/core.get_include_path.php44
-rw-r--r--wp-inst/internals/core.get_microtime.php23
-rw-r--r--wp-inst/internals/core.get_php_resource.php80
-rw-r--r--wp-inst/internals/core.is_secure.php56
-rw-r--r--wp-inst/internals/core.is_trusted.php47
-rw-r--r--wp-inst/internals/core.load_plugins.php125
-rw-r--r--wp-inst/internals/core.load_resource_plugin.php74
-rw-r--r--wp-inst/internals/core.process_cached_inserts.php71
-rw-r--r--wp-inst/internals/core.process_compiled_include.php32
-rw-r--r--wp-inst/internals/core.read_cache_file.php111
-rw-r--r--wp-inst/internals/core.rm_auto.php71
-rw-r--r--wp-inst/internals/core.rmdir.php55
-rw-r--r--wp-inst/internals/core.run_insert_handler.php71
-rw-r--r--wp-inst/internals/core.smarty_include_php.php50
-rw-r--r--wp-inst/internals/core.write_cache_file.php96
-rw-r--r--wp-inst/internals/core.write_compiled_include.php91
-rw-r--r--wp-inst/internals/core.write_compiled_resource.php35
-rw-r--r--wp-inst/internals/core.write_file.php54
-rw-r--r--wp-inst/license.txt280
-rw-r--r--wp-inst/maintenance.php29
-rw-r--r--wp-inst/mm-newblog.php172
-rw-r--r--wp-inst/pages57
-rw-r--r--wp-inst/readme.html126
-rw-r--r--wp-inst/wp-admin/admin-db.php90
-rw-r--r--wp-inst/wp-admin/admin-footer.php13
-rw-r--r--wp-inst/wp-admin/admin-functions.php1398
-rw-r--r--wp-inst/wp-admin/admin-header.php104
-rw-r--r--wp-inst/wp-admin/admin.php69
-rw-r--r--wp-inst/wp-admin/bookmarklet.php108
-rw-r--r--wp-inst/wp-admin/categories.php167
-rw-r--r--wp-inst/wp-admin/dbx-key.js44
-rw-r--r--wp-inst/wp-admin/dbx.js6
-rw-r--r--wp-inst/wp-admin/edit-comments.php171
-rw-r--r--wp-inst/wp-admin/edit-form-advanced.php212
-rw-r--r--wp-inst/wp-admin/edit-form-comment.php89
-rw-r--r--wp-inst/wp-admin/edit-form.php76
-rw-r--r--wp-inst/wp-admin/edit-page-form.php160
-rw-r--r--wp-inst/wp-admin/edit-pages.php52
-rw-r--r--wp-inst/wp-admin/edit.php291
-rw-r--r--wp-inst/wp-admin/import-b2.php247
-rw-r--r--wp-inst/wp-admin/import-blogger.php207
-rw-r--r--wp-inst/wp-admin/import-greymatter.php315
-rw-r--r--wp-inst/wp-admin/import-livejournal.php124
-rw-r--r--wp-inst/wp-admin/import-mt.php418
-rw-r--r--wp-inst/wp-admin/import-rss.php191
-rw-r--r--wp-inst/wp-admin/import-textpattern.php138
-rw-r--r--wp-inst/wp-admin/index.php154
-rw-r--r--wp-inst/wp-admin/install-helper.php152
-rw-r--r--wp-inst/wp-admin/install.php218
-rw-r--r--wp-inst/wp-admin/link-add.php272
-rw-r--r--wp-inst/wp-admin/link-categories.php453
-rw-r--r--wp-inst/wp-admin/link-import.php131
-rw-r--r--wp-inst/wp-admin/link-manager.php755
-rw-r--r--wp-inst/wp-admin/link-parse-opml.php65
-rw-r--r--wp-inst/wp-admin/menu-header.php58
-rw-r--r--wp-inst/wp-admin/menu.php67
-rw-r--r--wp-inst/wp-admin/moderation.php220
-rw-r--r--wp-inst/wp-admin/options-discussion.php100
-rw-r--r--wp-inst/wp-admin/options-general.php91
-rw-r--r--wp-inst/wp-admin/options-head.php24
-rw-r--r--wp-inst/wp-admin/options-misc.php46
-rw-r--r--wp-inst/wp-admin/options-permalink.php116
-rw-r--r--wp-inst/wp-admin/options-reading.php63
-rw-r--r--wp-inst/wp-admin/options-writing.php101
-rw-r--r--wp-inst/wp-admin/options.php123
-rw-r--r--wp-inst/wp-admin/page-new.php26
-rw-r--r--wp-inst/wp-admin/plugin-editor.php124
-rw-r--r--wp-inst/wp-admin/plugins.php120
-rw-r--r--wp-inst/wp-admin/post.php410
-rw-r--r--wp-inst/wp-admin/profile.php281
-rw-r--r--wp-inst/wp-admin/quicktags.js389
-rw-r--r--wp-inst/wp-admin/referers.php431
-rw-r--r--wp-inst/wp-admin/setup-config.php156
-rw-r--r--wp-inst/wp-admin/sidebar.php81
-rw-r--r--wp-inst/wp-admin/template-chooser.php202
-rw-r--r--wp-inst/wp-admin/templates.php187
-rw-r--r--wp-inst/wp-admin/theme-editor.php157
-rw-r--r--wp-inst/wp-admin/themes.php172
-rw-r--r--wp-inst/wp-admin/toggle.pngbin0 -> 210 bytes
-rw-r--r--wp-inst/wp-admin/update-links.php44
-rw-r--r--wp-inst/wp-admin/upgrade-functions.php753
-rw-r--r--wp-inst/wp-admin/upgrade-schema.php295
-rw-r--r--wp-inst/wp-admin/upgrade.php95
-rw-r--r--wp-inst/wp-admin/upload.php235
-rw-r--r--wp-inst/wp-admin/user-edit.php216
-rw-r--r--wp-inst/wp-admin/users.php290
-rw-r--r--wp-inst/wp-admin/wp-admin.css682
-rw-r--r--wp-inst/wp-admin/wpmu-admin.php33
-rw-r--r--wp-inst/wp-admin/wpmu-blogs.php304
-rw-r--r--wp-inst/wp-admin/wpmu-edit.php102
-rw-r--r--wp-inst/wp-admin/wpmu-users.php199
-rw-r--r--wp-inst/wp-atom.php45
-rw-r--r--wp-inst/wp-blog-header.php21
-rw-r--r--wp-inst/wp-comments-post.php67
-rw-r--r--wp-inst/wp-comments.php52
-rw-r--r--wp-inst/wp-commentsrss2.php76
-rw-r--r--wp-inst/wp-config-sample.php19
-rw-r--r--wp-inst/wp-content/blogs20
-rw-r--r--wp-inst/wp-content/plugins/BAStats/BAStats.php566
-rw-r--r--wp-inst/wp-content/plugins/BAStats/BAStats_graph.php375
-rw-r--r--wp-inst/wp-content/plugins/BAStats/BAStats_logger.php310
-rw-r--r--wp-inst/wp-content/plugins/BAStats/BAStats_options.php171
-rw-r--r--wp-inst/wp-content/plugins/BAStats/BAStats_reports.php330
-rw-r--r--wp-inst/wp-content/plugins/hello.php73
-rw-r--r--wp-inst/wp-content/plugins/jb_Recent_Comments_List.php68
-rw-r--r--wp-inst/wp-content/plugins/kittens-spaminator.php529
-rw-r--r--wp-inst/wp-content/plugins/wp_ozh_clickcounter.php522
-rw-r--r--wp-inst/wp-content/plugins/wpmu-plugin.php598
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/img/bg.gifbin0 -> 202 bytes
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/img/bullet.gifbin0 -> 53 bytes
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/img/date.gifbin0 -> 4989 bytes
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/img/fg.gifbin0 -> 126 bytes
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/img/footer.gifbin0 -> 10488 bytes
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/img/header.gifbin0 -> 12049 bytes
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/img/posts.gifbin0 -> 48 bytes
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/img/today.gifbin0 -> 48 bytes
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/index.php10
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/screenshot-sm.gifbin0 -> 17574 bytes
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/screenshot.gifbin0 -> 102913 bytes
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/templates/comments.html57
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/templates/index.html127
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/templates/post.html18
-rw-r--r--wp-inst/wp-content/sitetemplates/humancondition/templates/wp-layout.css413
-rw-r--r--wp-inst/wp-content/smarty-plugins/block.textformat.php102
-rw-r--r--wp-inst/wp-content/smarty-plugins/compiler.assign.php38
-rw-r--r--wp-inst/wp-content/smarty-plugins/custom_fields.enclosure.php17
-rw-r--r--wp-inst/wp-content/smarty-plugins/custom_fields.photoblog.php14
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.assign.php30
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.assign_debug_info.php39
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.blogroll.php145
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.config_load.php140
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.cork.php157
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.counter.php79
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.custom_fields.php31
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.cycle.php102
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.debug.php35
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.eightball.php23
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.eval.php48
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.fetch.php220
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.get_recent_comments.php25
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.getcustomfield.php39
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.globalvar.php34
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.googleit.php38
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.html_checkboxes.php143
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.html_image.php139
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.html_options.php121
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.html_radios.php150
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.html_select_date.php316
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.html_select_time.php192
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.html_table.php137
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.is_aside.php42
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.lastposts.php66
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.mailto.php163
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.math.php83
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.photoblog.php102
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.pirate.php181
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.popularposts.php80
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.popup.php117
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.popup_init.php39
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.referer.php128
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.relatedstories.php85
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.todayayearago.php84
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.wp_ozh_click_comment_author_link.php27
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.wp_ozh_click_topclicks.php23
-rw-r--r--wp-inst/wp-content/smarty-plugins/insert.getreferer.php211
-rw-r--r--wp-inst/wp-content/smarty-plugins/insert.var.php21
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.capitalize.php42
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.cat.php33
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.count_characters.php31
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.count_paragraphs.php28
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.count_sentences.php28
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.count_words.php32
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.date_format.php48
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.debug_print_var.php56
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.default.php31
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.escape.php89
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.highlightsearch.php80
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.indent.php27
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.lower.php25
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.nl2br.php35
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.regex_replace.php33
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.replace.php29
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.spacify.php29
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.string_format.php28
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.strip.php33
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.strip_tags.php31
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.truncate.php43
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.upper.php25
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.wordwrap.php28
-rw-r--r--wp-inst/wp-content/smarty-plugins/outputfilter.protect_email.php16
-rw-r--r--wp-inst/wp-content/smarty-plugins/outputfilter.trimwhitespace.php75
-rw-r--r--wp-inst/wp-content/smarty-plugins/shared.escape_special_chars.php30
-rw-r--r--wp-inst/wp-content/smarty-plugins/shared.make_timestamp.php43
-rw-r--r--wp-inst/wp-content/smarty-plugins/wp_ozh_clickcounter.php504
-rw-r--r--wp-inst/wp-content/smarty-templates/blogroll.tpl3
-rw-r--r--wp-inst/wp-content/smarty-templates/noblogroll.tpl1
-rw-r--r--wp-inst/wp-content/themes/classic/comments-popup.php113
-rw-r--r--wp-inst/wp-content/themes/classic/comments.php75
-rw-r--r--wp-inst/wp-content/themes/classic/footer.php12
-rw-r--r--wp-inst/wp-content/themes/classic/header.php30
-rw-r--r--wp-inst/wp-content/themes/classic/index.php32
-rw-r--r--wp-inst/wp-content/themes/classic/sidebar.php43
-rw-r--r--wp-inst/wp-content/themes/classic/style.css313
-rw-r--r--wp-inst/wp-content/themes/default/404.php11
-rw-r--r--wp-inst/wp-content/themes/default/archive.php68
-rw-r--r--wp-inst/wp-content/themes/default/archives.php25
-rw-r--r--wp-inst/wp-content/themes/default/comments-popup.php113
-rw-r--r--wp-inst/wp-content/themes/default/comments.php104
-rw-r--r--wp-inst/wp-content/themes/default/footer.php20
-rw-r--r--wp-inst/wp-content/themes/default/header.php61
-rw-r--r--wp-inst/wp-content/themes/default/images/kubrickbg.jpgbin0 -> 1043 bytes
-rw-r--r--wp-inst/wp-content/themes/default/images/kubrickbgcolor.jpgbin0 -> 556 bytes
-rw-r--r--wp-inst/wp-content/themes/default/images/kubrickbgwide.jpgbin0 -> 1014 bytes
-rw-r--r--wp-inst/wp-content/themes/default/images/kubrickfooter.jpgbin0 -> 2443 bytes
-rw-r--r--wp-inst/wp-content/themes/default/images/kubrickheader.jpgbin0 -> 7868 bytes
-rw-r--r--wp-inst/wp-content/themes/default/index.php39
-rw-r--r--wp-inst/wp-content/themes/default/links.php18
-rw-r--r--wp-inst/wp-content/themes/default/page.php21
-rw-r--r--wp-inst/wp-content/themes/default/search.php46
-rw-r--r--wp-inst/wp-content/themes/default/searchform.php5
-rw-r--r--wp-inst/wp-content/themes/default/sidebar.php72
-rw-r--r--wp-inst/wp-content/themes/default/single.php65
-rw-r--r--wp-inst/wp-content/themes/default/style.css610
-rw-r--r--wp-inst/wp-counter.php209
-rw-r--r--wp-inst/wp-feed.php37
-rw-r--r--wp-inst/wp-images/.htaccess1
-rw-r--r--wp-inst/wp-images/fade-butt.pngbin0 -> 785 bytes
-rw-r--r--wp-inst/wp-images/get-firefox.pngbin0 -> 1735 bytes
-rw-r--r--wp-inst/wp-images/header-shadow.pngbin0 -> 1306 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_arrow.gifbin0 -> 170 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_biggrin.gifbin0 -> 172 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_confused.gifbin0 -> 171 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_cool.gifbin0 -> 172 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_cry.gifbin0 -> 498 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_eek.gifbin0 -> 170 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_evil.gifbin0 -> 236 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_exclaim.gifbin0 -> 236 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_idea.gifbin0 -> 176 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_lol.gifbin0 -> 336 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_mad.gifbin0 -> 174 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_mrgreen.gifbin0 -> 349 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_neutral.gifbin0 -> 171 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_question.gifbin0 -> 248 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_razz.gifbin0 -> 176 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_redface.gifbin0 -> 650 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_rolleyes.gifbin0 -> 485 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_sad.gifbin0 -> 171 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_smile.gifbin0 -> 174 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_surprised.gifbin0 -> 174 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_twisted.gifbin0 -> 238 bytes
-rw-r--r--wp-inst/wp-images/smilies/icon_wink.gifbin0 -> 170 bytes
-rw-r--r--wp-inst/wp-images/wordpress-mu.pngbin0 -> 3063 bytes
-rw-r--r--wp-inst/wp-images/wp-small.pngbin0 -> 1416 bytes
-rw-r--r--wp-inst/wp-images/wpminilogo.pngbin0 -> 989 bytes
-rw-r--r--wp-inst/wp-includes/capabilities.php263
-rw-r--r--wp-inst/wp-includes/class-IXR.php815
-rw-r--r--wp-inst/wp-includes/class-pop3.php680
-rw-r--r--wp-inst/wp-includes/class-smarty.php3867
-rw-r--r--wp-inst/wp-includes/class-snoopy.php901
-rw-r--r--wp-inst/wp-includes/classes.php1526
-rw-r--r--wp-inst/wp-includes/comment-functions.php678
-rwxr-xr-xwp-inst/wp-includes/create_smarty_template.php144
-rw-r--r--wp-inst/wp-includes/default-filters.php88
-rw-r--r--wp-inst/wp-includes/feed-functions.php158
-rw-r--r--wp-inst/wp-includes/functions-compat.php92
-rw-r--r--wp-inst/wp-includes/functions-formatting.php996
-rw-r--r--wp-inst/wp-includes/functions-post.php714
-rw-r--r--wp-inst/wp-includes/functions.php2000
-rw-r--r--wp-inst/wp-includes/gettext.php358
-rw-r--r--wp-inst/wp-includes/kses.php563
-rw-r--r--wp-inst/wp-includes/links.php568
-rw-r--r--wp-inst/wp-includes/locale.php70
-rw-r--r--wp-inst/wp-includes/pluggable-functions.php282
-rw-r--r--wp-inst/wp-includes/registration-functions.php32
-rw-r--r--wp-inst/wp-includes/rss-functions.php850
-rw-r--r--wp-inst/wp-includes/streams.php159
-rw-r--r--wp-inst/wp-includes/template-functions-author.php211
-rw-r--r--wp-inst/wp-includes/template-functions-category.php402
-rw-r--r--wp-inst/wp-includes/template-functions-general.php644
-rw-r--r--wp-inst/wp-includes/template-functions-links.php492
-rw-r--r--wp-inst/wp-includes/template-functions-post.php414
-rw-r--r--wp-inst/wp-includes/template-loader.php59
-rw-r--r--wp-inst/wp-includes/vars.php113
-rw-r--r--wp-inst/wp-includes/version.php7
-rw-r--r--wp-inst/wp-includes/wp-db.php362
-rw-r--r--wp-inst/wp-includes/wp-l10n.php103
-rw-r--r--wp-inst/wp-includes/wpmu-functions.php807
-rw-r--r--wp-inst/wp-links-opml.php58
-rw-r--r--wp-inst/wp-login.php248
-rw-r--r--wp-inst/wp-mail.php182
-rw-r--r--wp-inst/wp-newblog.php180
-rw-r--r--wp-inst/wp-pass.php11
-rw-r--r--wp-inst/wp-rdf.php57
-rw-r--r--wp-inst/wp-register.php154
-rw-r--r--wp-inst/wp-rss.php37
-rw-r--r--wp-inst/wp-rss2.php56
-rw-r--r--wp-inst/wp-settings.php220
-rw-r--r--wp-inst/wp-trackback.php93
-rw-r--r--wp-inst/wp.php48
-rw-r--r--wp-inst/wpmu-settings.php.dist91
-rw-r--r--wp-inst/xmlrpc.php1313
317 files changed, 56997 insertions, 0 deletions
diff --git a/Changelog-old.txt b/Changelog-old.txt
new file mode 100644
index 0000000..bfd875f
--- /dev/null
+++ b/Changelog-old.txt
@@ -0,0 +1,1382 @@
+------------------------------------------------------------------------
+r187 | donncha | 2005-07-12 12:06:55 +0100 (Tue, 12 Jul 2005) | 2 lines
+Changed paths:
+ A /trunk/wp-inst/wp-admin/themes.php
+
+Added support for allowed_themes
+
+------------------------------------------------------------------------
+r186 | donncha | 2005-07-12 11:46:11 +0100 (Tue, 12 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/wpmu-blogs.php
+
+Fix blog themes
+
+------------------------------------------------------------------------
+r185 | donncha | 2005-07-11 20:53:25 +0100 (Mon, 11 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Oops! missing hostname!
+
+------------------------------------------------------------------------
+r184 | donncha | 2005-07-11 20:40:22 +0100 (Mon, 11 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+
+Fixed file upload realpath.
+
+------------------------------------------------------------------------
+r183 | donncha | 2005-07-11 19:32:15 +0100 (Mon, 11 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Functions to switch blog identities. work in progress
+
+------------------------------------------------------------------------
+r182 | donncha | 2005-07-11 18:45:05 +0100 (Mon, 11 Jul 2005) | 2 lines
+Changed paths:
+ A /trunk/wp-inst/wp-admin/upgrade-functions.php
+
+Initial import - don't make custom theme directories.
+
+------------------------------------------------------------------------
+r181 | donncha | 2005-07-11 18:43:21 +0100 (Mon, 11 Jul 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/wpmu-blogs.php
+
+Allowed themes fixes.
+Typos fixed.
+
+------------------------------------------------------------------------
+r180 | donncha | 2005-07-11 18:42:36 +0100 (Mon, 11 Jul 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/wpmu-edit.php
+
+Fixes for allowed themes.
+Don't insert options more than once.
+
+------------------------------------------------------------------------
+r179 | donncha | 2005-07-11 10:59:40 +0100 (Mon, 11 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/index.php
+
+Always use WP Themes
+
+------------------------------------------------------------------------
+r178 | donncha | 2005-07-11 10:59:19 +0100 (Mon, 11 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-comments-post.php
+
+Changes from WP Core.
+
+------------------------------------------------------------------------
+r177 | donncha | 2005-07-11 10:58:50 +0100 (Mon, 11 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-settings.php
+
+Changes from WP Core.
+
+------------------------------------------------------------------------
+r176 | donncha | 2005-07-10 21:34:42 +0100 (Sun, 10 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/wpmu-edit.php
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Add lots of *site_settings() functions and use them!
+
+------------------------------------------------------------------------
+r175 | donncha | 2005-07-10 21:33:38 +0100 (Sun, 10 Jul 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/wpmu-blogs.php
+
+List disabled themes properly.
+Correct sql for searching blogs.
+
+------------------------------------------------------------------------
+r174 | donncha | 2005-07-08 12:54:44 +0100 (Fri, 08 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+
+Fix SQL
+
+------------------------------------------------------------------------
+r173 | donncha | 2005-07-08 12:54:31 +0100 (Fri, 08 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-settings.php
+
+Fix site fieldname
+
+------------------------------------------------------------------------
+r172 | donncha | 2005-07-08 12:54:06 +0100 (Fri, 08 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+Fix $domain
+
+------------------------------------------------------------------------
+r171 | donncha | 2005-07-08 12:53:49 +0100 (Fri, 08 Jul 2005) | 3 lines
+Changed paths:
+ M /trunk/index.php
+
+Fix domain.
+Setup admin user in sitemeta table.
+
+------------------------------------------------------------------------
+r170 | donncha | 2005-07-08 11:33:46 +0100 (Fri, 08 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Added site tables.
+
+------------------------------------------------------------------------
+r169 | donncha | 2005-07-08 11:33:25 +0100 (Fri, 08 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Stripped hostname from domain.
+
+------------------------------------------------------------------------
+r168 | donncha | 2005-07-08 11:33:04 +0100 (Fri, 08 Jul 2005) | 4 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/wpmu-blogs.php
+
+html tidy up.
+Corrected is_archived option.
+themes stuff.
+
+------------------------------------------------------------------------
+r167 | donncha | 2005-07-08 11:32:13 +0100 (Fri, 08 Jul 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/wpmu-edit.php
+
+Insert options that don't exist.
+Update themes list (WIP, may be removed again)
+
+------------------------------------------------------------------------
+r166 | donncha | 2005-07-08 11:31:03 +0100 (Fri, 08 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+
+Minor corrections to site tables.
+
+------------------------------------------------------------------------
+r165 | donncha | 2005-07-07 21:36:54 +0100 (Thu, 07 Jul 2005) | 5 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+ M /trunk/wp-inst/wp-admin/wpmu-blogs.php
+ M /trunk/wp-inst/wp-settings.php
+
+Added site and sitemeta tables.
+is_archived moved to options table.
+Make SQL creation code nicer.
+*wp-newblog.php not updated yet*
+
+------------------------------------------------------------------------
+r164 | donncha | 2005-07-06 18:28:41 +0100 (Wed, 06 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+add another hook.
+
+------------------------------------------------------------------------
+r163 | donncha | 2005-07-06 18:23:06 +0100 (Wed, 06 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/wpmu-admin.php
+ M /trunk/wp-inst/wp-admin/wpmu-edit.php
+ M /trunk/wp-inst/wp-newblog.php
+
+Added action hooks.
+
+------------------------------------------------------------------------
+r162 | donncha | 2005-07-06 12:33:04 +0100 (Wed, 06 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+Add base domain variable.
+
+------------------------------------------------------------------------
+r161 | donncha | 2005-07-06 11:45:23 +0100 (Wed, 06 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+Initial MU plugins support.
+
+------------------------------------------------------------------------
+r160 | donncha | 2005-07-05 17:11:59 +0100 (Tue, 05 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Use local variables.
+
+------------------------------------------------------------------------
+r159 | donncha | 2005-07-05 16:58:45 +0100 (Tue, 05 Jul 2005) | 2 lines
+Changed paths:
+ A /trunk/wp-inst/favicon.ico
+
+Added browser icon.
+
+------------------------------------------------------------------------
+r158 | donncha | 2005-07-05 16:46:36 +0100 (Tue, 05 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Import lots of changes from Matt's newblog script.
+
+------------------------------------------------------------------------
+r157 | donncha | 2005-07-05 15:15:59 +0100 (Tue, 05 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/htaccess.dist
+
+Add a rule for pages.
+
+------------------------------------------------------------------------
+r156 | matt | 2005-07-05 14:46:45 +0100 (Tue, 05 Jul 2005) | 1 line
+Changed paths:
+ M /trunk/htaccess.dist
+ M /trunk/index.php
+ M /trunk/release.sh
+ M /trunk/wp-inst/go.php
+ M /trunk/wp-inst/htaccess.dist
+ M /trunk/wp-inst/index.php
+ M /trunk/wp-inst/maintenance.php
+ M /trunk/wp-inst/mm-newblog.php
+ M /trunk/wp-inst/pages
+ M /trunk/wp-inst/wp-comments-post.php
+ M /trunk/wp-inst/wp-comments.php
+ M /trunk/wp-inst/wp-config-sample.php
+ M /trunk/wp-inst/wp-counter.php
+ M /trunk/wp-inst/wp-newblog.php
+ M /trunk/wp-inst/wp-settings.php
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+eol:style updates.
+------------------------------------------------------------------------
+r155 | matt | 2005-07-05 14:43:05 +0100 (Tue, 05 Jul 2005) | 1 line
+Changed paths:
+ A /trunk/wp-inst/mm-newblog.php
+ M /trunk/wp-inst/wp-includes/create_smarty_template.php
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Alternative new blog page to try out, set eol:style
+------------------------------------------------------------------------
+r154 | matt | 2005-07-05 14:00:51 +0100 (Tue, 05 Jul 2005) | 1 line
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Make it a page and not a post.
+------------------------------------------------------------------------
+r153 | donncha | 2005-07-05 13:58:35 +0100 (Tue, 05 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/wpmu-blogs.php
+ M /trunk/wp-inst/wp-admin/wpmu-edit.php
+
+Edit blogs record for blog too.
+
+------------------------------------------------------------------------
+r152 | donncha | 2005-07-05 13:58:07 +0100 (Tue, 05 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Better error reporting.
+
+------------------------------------------------------------------------
+r151 | donncha | 2005-07-05 13:57:30 +0100 (Tue, 05 Jul 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+First post is now by blog user.
+Add site admin user to user list.
+
+------------------------------------------------------------------------
+r150 | donncha | 2005-07-05 13:55:58 +0100 (Tue, 05 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+ M /trunk/wp-inst/wp-settings.php
+
+Use the "is_public" field
+
+------------------------------------------------------------------------
+r149 | donncha | 2005-07-04 17:08:10 +0100 (Mon, 04 Jul 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/wpmu-blogs.php
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Fix stats
+Fix search
+
+------------------------------------------------------------------------
+r148 | donncha | 2005-07-04 17:00:51 +0100 (Mon, 04 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Added nice header.
+
+------------------------------------------------------------------------
+r147 | donncha | 2005-07-04 16:59:08 +0100 (Mon, 04 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Add function to get admin user for a particular domain.
+
+------------------------------------------------------------------------
+r146 | donncha | 2005-07-04 16:58:34 +0100 (Mon, 04 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/wpmu-blogs.php
+
+Removed blogname, added "last updated" column.
+
+------------------------------------------------------------------------
+r145 | donncha | 2005-07-04 15:08:02 +0100 (Mon, 04 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/release.sh
+
+Use WP 1.5.1.3
+
+------------------------------------------------------------------------
+r144 | donncha | 2005-07-04 12:39:41 +0100 (Mon, 04 Jul 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Add source domain meta data to user.
+Delete perms for existing users from meta table.
+
+------------------------------------------------------------------------
+r143 | donncha | 2005-07-04 12:12:44 +0100 (Mon, 04 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Record when blogs last updated.
+
+------------------------------------------------------------------------
+r142 | donncha | 2005-07-04 11:09:37 +0100 (Mon, 04 Jul 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+If no hostname on domain, then prefix with www
+
+------------------------------------------------------------------------
+r141 | donncha | 2005-06-30 20:38:52 +0100 (Thu, 30 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+ M /trunk/wp-inst/wp-newblog.php
+
+Strip the slashes!
+
+------------------------------------------------------------------------
+r140 | donncha | 2005-06-30 20:38:33 +0100 (Thu, 30 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+
+Don't strip the domain.
+
+------------------------------------------------------------------------
+r139 | donncha | 2005-06-30 20:25:48 +0100 (Thu, 30 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+ M /trunk/wp-inst/wp-newblog.php
+ M /trunk/wp-inst/wp-settings.php
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+Got rid of blogname field in blogs table.
+
+------------------------------------------------------------------------
+r138 | donncha | 2005-06-30 19:46:36 +0100 (Thu, 30 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Only check the pw if it's set!
+
+------------------------------------------------------------------------
+r137 | donncha | 2005-06-30 17:57:21 +0100 (Thu, 30 Jun 2005) | 4 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+When creating a new domain, open wp-newblog.php and create a "main" blog.
+When you hit submit you'll be asked for the password of the admin user
+created on initial install.
+
+------------------------------------------------------------------------
+r136 | donncha | 2005-06-30 17:53:32 +0100 (Thu, 30 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+
+Make sure initial blog is owned by user "admin"
+
+------------------------------------------------------------------------
+r135 | donncha | 2005-06-30 17:53:01 +0100 (Thu, 30 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+
+blogname isn't unique by itself.
+
+------------------------------------------------------------------------
+r134 | donncha | 2005-06-30 13:25:57 +0100 (Thu, 30 Jun 2005) | 5 lines
+Changed paths:
+ M /trunk/htaccess.dist
+ M /trunk/index.php
+ M /trunk/wp-inst/htaccess.dist
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+ A /trunk/wp-inst/wp-content/blogs
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+Requests for files are now handled by a "blogs" script.
+It will have to be expanded to support other requests: themes, style sheets, etc.
+Blogs directory now uses $blog_id instead of blogname to avoid name clashes.
+
+
+------------------------------------------------------------------------
+r133 | donncha | 2005-06-30 10:28:37 +0100 (Thu, 30 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/htaccess.dist
+
+Change images to files.
+
+------------------------------------------------------------------------
+r132 | donncha | 2005-06-29 19:18:45 +0100 (Wed, 29 Jun 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/menu.php
+ M /trunk/wp-inst/wp-admin/wpmu-admin.php
+ A /trunk/wp-inst/wp-admin/wpmu-blogs.php
+ M /trunk/wp-inst/wp-admin/wpmu-edit.php
+ A /trunk/wp-inst/wp-admin/wpmu-users.php
+
+Moved blogs and users functions to their own files.
+Can now edit user and usermeta records.
+
+------------------------------------------------------------------------
+r131 | donncha | 2005-06-29 11:52:29 +0100 (Wed, 29 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Functions used by wpmu admin, but could be useful elsewhere.
+
+------------------------------------------------------------------------
+r130 | donncha | 2005-06-29 11:52:02 +0100 (Wed, 29 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-settings.php
+
+Add $base to check for blog_id
+
+------------------------------------------------------------------------
+r129 | matt | 2005-06-29 08:10:10 +0100 (Wed, 29 Jun 2005) | 1 line
+Changed paths:
+ M /trunk/README.txt
+
+Testing again
+------------------------------------------------------------------------
+r128 | matt | 2005-06-29 08:06:54 +0100 (Wed, 29 Jun 2005) | 1 line
+Changed paths:
+ M /trunk/README.txt
+
+Testing...
+------------------------------------------------------------------------
+r127 | donncha | 2005-06-28 18:21:29 +0100 (Tue, 28 Jun 2005) | 6 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/menu.php
+ M /trunk/wp-inst/wp-admin/wpmu-admin.php
+ A /trunk/wp-inst/wp-admin/wpmu-edit.php
+
+Added admin edit page for updating records.
+Fix to permissions.
+Added search for blogs and users.
+Added options page for blogs.
+Added userlist.
+
+------------------------------------------------------------------------
+r126 | donncha | 2005-06-28 08:06:20 +0100 (Tue, 28 Jun 2005) | 3 lines
+Changed paths:
+ D /trunk/wp-inst/wp-admin/install-wpmu.php
+ M /trunk/wp-inst/wp-admin/menu.php
+ A /trunk/wp-inst/wp-admin/wpmu-admin.php
+
+Added WPMU Admin page.
+Removed install file, not required any more.
+
+------------------------------------------------------------------------
+r125 | donncha | 2005-06-28 07:13:01 +0100 (Tue, 28 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Use files intead of images
+
+------------------------------------------------------------------------
+r124 | donncha | 2005-06-27 19:08:35 +0100 (Mon, 27 Jun 2005) | 3 lines
+Changed paths:
+ M /trunk/index.php
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Fixed lots of // bugs.
+Ooops. forgot to define $domain if a only a domain.tld was used to install!
+
+------------------------------------------------------------------------
+r123 | donncha | 2005-06-27 18:46:39 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Upgrade before we restore the "main" blog
+
+------------------------------------------------------------------------
+r122 | donncha | 2005-06-27 17:57:39 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+If vhost enable then change URL.
+
+------------------------------------------------------------------------
+r121 | donncha | 2005-06-27 17:57:19 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+If vhost enabled then change URL.
+
+------------------------------------------------------------------------
+r120 | donncha | 2005-06-27 17:56:47 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-config-sample.php
+
+Add virtual hosting config option.
+
+------------------------------------------------------------------------
+r119 | donncha | 2005-06-27 17:56:23 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+
+Virtual server support is now optional.
+
+------------------------------------------------------------------------
+r118 | donncha | 2005-06-27 17:55:22 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/htaccess.dist
+
+Redirect without hosts because host may not always be www.domain.com
+
+------------------------------------------------------------------------
+r117 | donncha | 2005-06-27 16:04:08 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Need to add current hostname to createBlog() call.
+
+------------------------------------------------------------------------
+r116 | donncha | 2005-06-27 16:03:41 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-settings.php
+
+Use the domain instead of hostname.
+
+------------------------------------------------------------------------
+r115 | donncha | 2005-06-27 16:03:14 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+Check for virtual host.
+
+------------------------------------------------------------------------
+r114 | donncha | 2005-06-27 16:02:47 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+
+Use a hostname instead of domain.
+
+------------------------------------------------------------------------
+r113 | donncha | 2005-06-27 16:02:18 +0100 (Mon, 27 Jun 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Remember to call upgrade_all()!
+$domain may not always resolve. Use the current hostname instead.
+
+------------------------------------------------------------------------
+r112 | donncha | 2005-06-27 13:25:08 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+blog_id can be more than 1 character.
+
+------------------------------------------------------------------------
+r111 | donncha | 2005-06-27 13:11:01 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+
+If perms on dirs aren't right then don't ask for db info.
+
+------------------------------------------------------------------------
+r110 | donncha | 2005-06-27 13:08:13 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/README.txt
+
+Added Apache docs to configure mod_rewrite.
+
+------------------------------------------------------------------------
+r109 | donncha | 2005-06-27 12:36:21 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+ M /trunk/wp-inst/wp-newblog.php
+
+Fixes to path.
+
+------------------------------------------------------------------------
+r108 | donncha | 2005-06-27 12:35:46 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/htaccess.dist
+
+Fix for paged blog on main blog
+
+------------------------------------------------------------------------
+r107 | donncha | 2005-06-27 12:35:23 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+
+No need for main blog - created by createBlog()
+
+------------------------------------------------------------------------
+r106 | donncha | 2005-06-27 12:10:09 +0100 (Mon, 27 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+
+Add db creation code.
+
+------------------------------------------------------------------------
+r105 | donncha | 2005-06-24 14:22:08 +0100 (Fri, 24 Jun 2005) | 2 lines
+Changed paths:
+ D /trunk/wp-inst/wp-blogs
+
+Not needed any more.
+
+------------------------------------------------------------------------
+r104 | donncha | 2005-06-24 14:18:55 +0100 (Fri, 24 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/menu.php
+
+Added link to WP themes page.
+
+------------------------------------------------------------------------
+r103 | donncha | 2005-06-24 14:03:09 +0100 (Fri, 24 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+
+Oops. wrong var.
+
+------------------------------------------------------------------------
+r102 | donncha | 2005-06-24 13:30:17 +0100 (Fri, 24 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+get rid of GET variables in URL.
+
+------------------------------------------------------------------------
+r101 | donncha | 2005-06-24 13:21:19 +0100 (Fri, 24 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+No need for blogname with "main" blog.
+
+------------------------------------------------------------------------
+r100 | donncha | 2005-06-23 17:29:51 +0100 (Thu, 23 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+
+Don't forget these vars!
+
+------------------------------------------------------------------------
+r99 | donncha | 2005-06-23 17:19:44 +0100 (Thu, 23 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/index.php
+
+Change installation method to 2 stage process using createBlog()
+
+------------------------------------------------------------------------
+r98 | donncha | 2005-06-23 17:19:16 +0100 (Thu, 23 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Add username to createBlog();
+
+------------------------------------------------------------------------
+r97 | donncha | 2005-06-23 17:17:22 +0100 (Thu, 23 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Use the correct var.
+
+------------------------------------------------------------------------
+r96 | donncha | 2005-06-22 17:39:36 +0100 (Wed, 22 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+Detect blog directories correctly!
+
+------------------------------------------------------------------------
+r95 | donncha | 2005-06-22 17:28:01 +0100 (Wed, 22 Jun 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+Handle calls to the "main" blog better.
+die() if an unknown blog is found. Probably should do a 404 on this too.
+
+------------------------------------------------------------------------
+r94 | donncha | 2005-06-22 17:27:15 +0100 (Wed, 22 Jun 2005) | 3 lines
+Changed paths:
+ M /trunk/htaccess.dist
+
+Added rules to handle main blog without "main" part of URL.
+Removed unused stuff.
+
+------------------------------------------------------------------------
+r93 | donncha | 2005-06-22 17:03:31 +0100 (Wed, 22 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-settings.php
+
+Domain support
+
+------------------------------------------------------------------------
+r92 | donncha | 2005-06-22 13:01:46 +0100 (Wed, 22 Jun 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+ M /trunk/wp-inst/wp-newblog.php
+
+Moved createBlog() into wpmu-functions.php and
+removed unused functions.
+
+------------------------------------------------------------------------
+r91 | donncha | 2005-06-21 19:23:56 +0100 (Tue, 21 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Never mind slashes.
+
+------------------------------------------------------------------------
+r90 | donncha | 2005-06-21 19:20:49 +0100 (Tue, 21 Jun 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Don't forget to make the home directory!
+
+
+------------------------------------------------------------------------
+r89 | donncha | 2005-06-21 19:04:59 +0100 (Tue, 21 Jun 2005) | 4 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+ M /trunk/wp-inst/wp-settings.php
+
+Move new blog creation into a function.
+This should go into a seperate file later on.
+
+
+------------------------------------------------------------------------
+r88 | donncha | 2005-06-21 19:04:25 +0100 (Tue, 21 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+
+Add domain and path.
+
+------------------------------------------------------------------------
+r87 | donncha | 2005-06-21 19:03:57 +0100 (Tue, 21 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+No need for this check if we're checking the posts table.
+
+------------------------------------------------------------------------
+r86 | donncha | 2005-06-21 16:03:31 +0100 (Tue, 21 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/release.sh
+
+Delete old wp folder first.
+
+------------------------------------------------------------------------
+r85 | donncha | 2005-06-21 11:47:28 +0100 (Tue, 21 Jun 2005) | 5 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Check for install from posts table.
+Fix setting title and email values.
+Use the usermeta table.
+Small mod to email.
+
+------------------------------------------------------------------------
+r84 | donncha | 2005-06-21 11:45:36 +0100 (Tue, 21 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/index.php
+
+If wp-content/themes directory exists then use WP themes.
+
+------------------------------------------------------------------------
+r83 | donncha | 2005-06-20 19:09:37 +0100 (Mon, 20 Jun 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+ A /trunk/wp-inst/wp-settings.php
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+Added global blogs db table.
+
+
+------------------------------------------------------------------------
+r82 | donncha | 2005-06-20 18:29:36 +0100 (Mon, 20 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/htaccess.dist
+
+Added rule to rewrite content/themes directory for WP themes.
+
+------------------------------------------------------------------------
+r81 | donncha | 2005-06-20 18:05:25 +0100 (Mon, 20 Jun 2005) | 2 lines
+Changed paths:
+ D /trunk/wp-inst/wp-admin/edit-form-advanced.php
+
+Removed.
+
+------------------------------------------------------------------------
+r80 | donncha | 2005-06-20 17:34:57 +0100 (Mon, 20 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+Use wpdb variables.
+
+------------------------------------------------------------------------
+r79 | donncha | 2005-06-20 15:37:36 +0100 (Mon, 20 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/release.sh
+
+Make stable and unstable releases.
+
+------------------------------------------------------------------------
+r78 | donncha | 2005-06-20 15:29:33 +0100 (Mon, 20 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/README.txt
+
+Fixed link to support forum
+
+------------------------------------------------------------------------
+r77 | donncha | 2005-06-20 14:57:33 +0100 (Mon, 20 Jun 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Use wpmu object's variables.
+
+------------------------------------------------------------------------
+r76 | donncha | 2005-05-28 00:12:15 +0100 (Sat, 28 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Fixed siteurl bug reported at http://mu.wordpress.org/forums/topic/52#post-308
+
+------------------------------------------------------------------------
+r75 | donncha | 2005-05-26 22:16:15 +0100 (Thu, 26 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+PHP < 4.3 doesn't have file_get_contents();
+
+------------------------------------------------------------------------
+r74 | donncha | 2005-05-26 22:09:51 +0100 (Thu, 26 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/smarty-plugins/function.popularposts.php
+
+Count popular posts in a better way.
+
+------------------------------------------------------------------------
+r73 | donncha | 2005-05-26 21:35:22 +0100 (Thu, 26 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/plugins/BAStats/BAStats.php
+ M /trunk/wp-inst/wp-content/plugins/BAStats/BAStats_graph.php
+ M /trunk/wp-inst/wp-content/plugins/BAStats/BAStats_logger.php
+ M /trunk/wp-inst/wp-content/plugins/BAStats/BAStats_options.php
+ M /trunk/wp-inst/wp-content/plugins/BAStats/BAStats_reports.php
+
+Updated BAstats to build 8.
+
+------------------------------------------------------------------------
+r72 | donncha | 2005-05-26 16:15:27 +0100 (Thu, 26 May 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Rewrote wp-newblog.php, used lots of Dasher's code.
+Page is still very basic but it's work in progress.
+
+------------------------------------------------------------------------
+r71 | donncha | 2005-05-26 14:43:12 +0100 (Thu, 26 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/sitetemplates/humancondition/templates/index.html
+
+print.css no longer exists!
+
+------------------------------------------------------------------------
+r70 | donncha | 2005-05-26 14:02:42 +0100 (Thu, 26 May 2005) | 2 lines
+Changed paths:
+ M /trunk/htaccess.dist
+
+Added new rules for wp-newblog.php
+
+------------------------------------------------------------------------
+r69 | donncha | 2005-05-26 13:09:14 +0100 (Thu, 26 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/referers.php
+
+Show all referers by default.
+
+------------------------------------------------------------------------
+r68 | donncha | 2005-05-25 16:06:13 +0100 (Wed, 25 May 2005) | 2 lines
+Changed paths:
+ M /trunk/htaccess.dist
+
+Pages now work through WordPress code.
+
+------------------------------------------------------------------------
+r67 | donncha | 2005-05-25 15:52:14 +0100 (Wed, 25 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/index.php
+
+Only display permission warnings until user refreshes page 5 times in a session.
+
+------------------------------------------------------------------------
+r66 | donncha | 2005-05-23 11:38:06 +0100 (Mon, 23 May 2005) | 2 lines
+Changed paths:
+ D /trunk/wp-inst/wp-admin/admin.php
+
+Removed - hooks in wpmu-functions.php call wpmu_clear_cache()
+
+------------------------------------------------------------------------
+r65 | donncha | 2005-05-21 09:25:47 +0100 (Sat, 21 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/plugins/wp_ozh_clickcounter.php
+
+Clean up error when remote file is not found.
+
+------------------------------------------------------------------------
+r64 | donncha | 2005-05-21 09:24:56 +0100 (Sat, 21 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/plugins/BAStats/BAStats.php
+
+Fix to get BAStats working again: Thanks Revbob - http://mu.wordpress.org/forums/topic/36#post-233
+
+------------------------------------------------------------------------
+r57 | donncha | 2005-05-09 22:24:29 +0100 (Mon, 09 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+Fixed include paths - http://mu.wordpress.org/forums/topic/30
+
+------------------------------------------------------------------------
+r56 | donncha | 2005-05-09 15:23:05 +0100 (Mon, 09 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/plugins/wpmu-plugin.php
+
+Disabled plugin until further notice. This needs to be tested more.
+
+------------------------------------------------------------------------
+r55 | donncha | 2005-05-09 08:50:41 +0100 (Mon, 09 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Minor change to new blog email.
+
+------------------------------------------------------------------------
+r54 | donncha | 2005-05-08 13:17:39 +0100 (Sun, 08 May 2005) | 2 lines
+Changed paths:
+ A /trunk/release.sh
+
+Run this script to make a WPMU release.
+
+------------------------------------------------------------------------
+r53 | donncha | 2005-05-08 13:01:47 +0100 (Sun, 08 May 2005) | 2 lines
+Changed paths:
+ M /trunk/htaccess.dist
+ M /trunk/wp-inst/pages
+
+Fixed pages support.
+
+------------------------------------------------------------------------
+r52 | donncha | 2005-05-08 12:41:51 +0100 (Sun, 08 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+This file uses "null" as false, should use false. Something to fix in the future!
+
+------------------------------------------------------------------------
+r51 | donncha | 2005-05-08 12:38:34 +0100 (Sun, 08 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/create_smarty_template.php
+
+Handle functions that return references.
+
+------------------------------------------------------------------------
+r50 | donncha | 2005-05-08 12:17:50 +0100 (Sun, 08 May 2005) | 3 lines
+Changed paths:
+ M /trunk/index.php
+
+Add mod_rewrite instructions.
+mkdir() is now quiet.
+
+------------------------------------------------------------------------
+r38 | donncha | 2005-05-02 22:46:07 +0100 (Mon, 02 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-counter.php
+
+Fixed checking of blacklisted referers
+
+------------------------------------------------------------------------
+r37 | donncha | 2005-05-02 22:45:45 +0100 (Mon, 02 May 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/referers.php
+
+Fixed blacklisting of URLs
+
+------------------------------------------------------------------------
+r36 | donncha | 2005-04-30 11:56:47 +0100 (Sat, 30 Apr 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wp-comments-post.php
+
+Core changes.
+
+
+------------------------------------------------------------------------
+r35 | donncha | 2005-04-30 11:56:22 +0100 (Sat, 30 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Check for INSTALLING constant and up the available space.
+
+------------------------------------------------------------------------
+r34 | donncha | 2005-04-30 11:55:53 +0100 (Sat, 30 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/index.php
+
+Added more bad referers.
+
+------------------------------------------------------------------------
+r33 | donncha | 2005-04-30 11:55:25 +0100 (Sat, 30 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/smarty-plugins/function.popularposts.php
+
+Clean up of old b2 code.
+
+------------------------------------------------------------------------
+r32 | donncha | 2005-04-30 11:55:04 +0100 (Sat, 30 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/smarty-plugins/function.is_aside.php
+
+Remove debug code.
+
+------------------------------------------------------------------------
+r31 | donncha | 2005-04-30 11:54:43 +0100 (Sat, 30 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/smarty-plugins/function.todayayearago.php
+
+Only print published posts
+
+------------------------------------------------------------------------
+r30 | donncha | 2005-04-30 11:54:23 +0100 (Sat, 30 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/smarty-plugins/function.referer.php
+
+Added support for infospace.com
+
+------------------------------------------------------------------------
+r29 | donncha | 2005-04-30 11:50:38 +0100 (Sat, 30 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/pages
+
+Pages live at the same url as Wordpress ones. ie. blog/pagename instead of blog/pages/pagename
+
+------------------------------------------------------------------------
+r28 | donncha | 2005-04-30 11:49:56 +0100 (Sat, 30 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/edit-form-advanced.php
+
+Core changes.
+
+------------------------------------------------------------------------
+r27 | donncha | 2005-04-30 11:49:42 +0100 (Sat, 30 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upload.php
+
+deleted a few lines.
+
+------------------------------------------------------------------------
+r26 | donncha | 2005-04-30 11:49:18 +0100 (Sat, 30 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/admin.php
+
+Core changes
+
+------------------------------------------------------------------------
+r25 | donncha | 2005-04-14 21:09:54 +0100 (Thu, 14 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/install-wpmu.php
+ M /trunk/wp-inst/wp-admin/upgrade-schema.php
+
+Remove queries from one file, into the other.
+
+------------------------------------------------------------------------
+r24 | donncha | 2005-04-14 21:09:33 +0100 (Thu, 14 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/upload.php
+
+Hardcode file upload types.
+
+------------------------------------------------------------------------
+r23 | donncha | 2005-04-14 21:09:11 +0100 (Thu, 14 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/options-misc.php
+
+Removed file upload types
+
+------------------------------------------------------------------------
+r22 | donncha | 2005-04-14 21:05:55 +0100 (Thu, 14 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/edit-form-advanced.php
+
+From WP Core
+
+------------------------------------------------------------------------
+r21 | donncha | 2005-04-14 21:05:32 +0100 (Thu, 14 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/admin.php
+
+From WP Core.
+
+------------------------------------------------------------------------
+r20 | donncha | 2005-04-14 20:47:52 +0100 (Thu, 14 Apr 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-newblog.php
+
+Untested - added db creation code, one step install. indented code.
+
+------------------------------------------------------------------------
+r19 | donncha | 2005-04-14 20:08:20 +0100 (Thu, 14 Apr 2005) | 2 lines
+Changed paths:
+ A /trunk/wp-inst/wp-newblog.php
+
+Initial import, do not use, untested!
+
+------------------------------------------------------------------------
+r18 | donncha | 2005-03-29 07:42:31 +0100 (Tue, 29 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/smarty-plugins/function.lastposts.php
+
+Added check for published posts.
+
+------------------------------------------------------------------------
+r17 | donncha | 2005-03-27 17:16:10 +0100 (Sun, 27 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/index.php
+
+Only prune the cache 1% of the time.
+
+------------------------------------------------------------------------
+r16 | donncha | 2005-03-27 16:15:40 +0100 (Sun, 27 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/index.php
+
+Don't unset when we still need it!
+
+------------------------------------------------------------------------
+r15 | donncha | 2005-03-27 15:44:20 +0100 (Sun, 27 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/index.php
+
+Delete Smarty cache files more than a day old.
+
+------------------------------------------------------------------------
+r14 | donncha | 2005-03-27 15:38:50 +0100 (Sun, 27 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/menu.php
+
+Don't need plugin editor.
+
+------------------------------------------------------------------------
+r13 | donncha | 2005-03-27 15:21:16 +0100 (Sun, 27 Mar 2005) | 3 lines
+Changed paths:
+ M /trunk/wp-inst/wpmu-settings.php.dist
+
+global vars aren't always available, from Paul Cook.
+http://blogs.linux.ie/support/topic.php?id=12&page=1#post-603
+
+------------------------------------------------------------------------
+r12 | donncha | 2005-03-27 15:18:28 +0100 (Sun, 27 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/plugins/wpmu-plugin.php
+
+Added warning message
+
+------------------------------------------------------------------------
+r11 | donncha | 2005-03-27 15:05:42 +0100 (Sun, 27 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/plugins/wp_ozh_clickcounter.php
+
+Don't display hits by default.
+
+------------------------------------------------------------------------
+r10 | donncha | 2005-03-27 15:05:17 +0100 (Sun, 27 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-comments-post.php
+
+WP Core Changes.
+
+------------------------------------------------------------------------
+r9 | donncha | 2005-03-27 15:02:14 +0100 (Sun, 27 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/edit-form-advanced.php
+
+Changes from WP core.
+
+------------------------------------------------------------------------
+r8 | donncha | 2005-03-27 15:01:36 +0100 (Sun, 27 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/index.php
+
+Added new referer spammers.
+
+------------------------------------------------------------------------
+r7 | donncha | 2005-03-24 10:24:07 +0000 (Thu, 24 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/go.php
+
+Use 301 redirects instead of 302
+
+------------------------------------------------------------------------
+r6 | donncha | 2005-03-22 23:21:08 +0000 (Tue, 22 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-content/sitetemplates/humancondition/templates/index.html
+
+Minor typo
+
+------------------------------------------------------------------------
+r5 | donncha | 2005-03-22 21:59:08 +0000 (Tue, 22 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-admin/options-misc.php
+
+Remove file upload max size option.
+
+------------------------------------------------------------------------
+r4 | donncha | 2005-03-20 13:14:46 +0000 (Sun, 20 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Print size.
+
+------------------------------------------------------------------------
+r3 | donncha | 2005-03-20 13:09:20 +0000 (Sun, 20 Mar 2005) | 2 lines
+Changed paths:
+ M /trunk/wp-inst/wp-includes/wpmu-functions.php
+
+Wrong var used in call to function.
+
+------------------------------------------------------------------------
+r2 | donncha | 2005-03-19 23:16:03 +0000 (Sat, 19 Mar 2005) | 2 lines
+Changed paths:
+ A /trunk/README.txt
+ A /trunk/htaccess.dist
+ A /trunk/index.php
+ A /trunk/wp-inst
+ A /trunk/wp-inst/go.php
+ A /trunk/wp-inst/htaccess.dist
+ A /trunk/wp-inst/index.php
+ A /trunk/wp-inst/maintenance.php
+ A /trunk/wp-inst/pages
+ A /trunk/wp-inst/wp-admin
+ A /trunk/wp-inst/wp-admin/admin.php
+ A /trunk/wp-inst/wp-admin/edit-form-advanced.php
+ A /trunk/wp-inst/wp-admin/install-wpmu.php
+ A /trunk/wp-inst/wp-admin/menu.php
+ A /trunk/wp-inst/wp-admin/options-general.php
+ A /trunk/wp-inst/wp-admin/options-misc.php
+ A /trunk/wp-inst/wp-admin/referers.php
+ A /trunk/wp-inst/wp-admin/template-chooser.php
+ A /trunk/wp-inst/wp-admin/templates.php
+ A /trunk/wp-inst/wp-admin/upgrade-schema.php
+ A /trunk/wp-inst/wp-admin/upload.php
+ A /trunk/wp-inst/wp-blogs
+ A /trunk/wp-inst/wp-blogs/DEFAULT
+ A /trunk/wp-inst/wp-blogs/DEFAULT/wp-config.php
+ A /trunk/wp-inst/wp-comments-post.php
+ A /trunk/wp-inst/wp-comments.php
+ A /trunk/wp-inst/wp-config-sample.php
+ A /trunk/wp-inst/wp-content
+ A /trunk/wp-inst/wp-content/plugins
+ A /trunk/wp-inst/wp-content/plugins/BAStats
+ A /trunk/wp-inst/wp-content/plugins/BAStats/BAStats.php
+ A /trunk/wp-inst/wp-content/plugins/BAStats/BAStats_graph.php
+ A /trunk/wp-inst/wp-content/plugins/BAStats/BAStats_logger.php
+ A /trunk/wp-inst/wp-content/plugins/BAStats/BAStats_options.php
+ A /trunk/wp-inst/wp-content/plugins/BAStats/BAStats_reports.php
+ A /trunk/wp-inst/wp-content/plugins/jb_Recent_Comments_List.php
+ A /trunk/wp-inst/wp-content/plugins/kittens-spaminator.php
+ A /trunk/wp-inst/wp-content/plugins/wp_ozh_clickcounter.php
+ A /trunk/wp-inst/wp-content/plugins/wpmu-plugin.php
+ A /trunk/wp-inst/wp-content/sitetemplates
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/img
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/img/bg.gif
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/img/bullet.gif
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/img/date.gif
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/img/fg.gif
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/img/footer.gif
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/img/header.gif
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/img/posts.gif
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/img/today.gif
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/index.php
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/screenshot-sm.gif
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/screenshot.gif
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/templates
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/templates/comments.html
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/templates/index.html
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/templates/post.html
+ A /trunk/wp-inst/wp-content/sitetemplates/humancondition/templates/wp-layout.css
+ A /trunk/wp-inst/wp-content/smarty-plugins
+ A /trunk/wp-inst/wp-content/smarty-plugins/custom_fields.enclosure.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/custom_fields.photoblog.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.assign.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.blogroll.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.cork.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.custom_fields.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.eightball.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.get_recent_comments.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.getcustomfield.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.globalvar.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.googleit.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.is_aside.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.lastposts.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.photoblog.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.pirate.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.popularposts.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.referer.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.relatedstories.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.todayayearago.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.wp_ozh_click_comment_author_link.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/function.wp_ozh_click_topclicks.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/insert.getreferer.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/insert.var.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/modifier.highlightsearch.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/outputfilter.protect_email.php
+ A /trunk/wp-inst/wp-content/smarty-plugins/wp_ozh_clickcounter.php
+ A /trunk/wp-inst/wp-content/smarty-templates
+ A /trunk/wp-inst/wp-content/smarty-templates/blogroll.tpl
+ A /trunk/wp-inst/wp-content/smarty-templates/noblogroll.tpl
+ A /trunk/wp-inst/wp-counter.php
+ A /trunk/wp-inst/wp-images
+ A /trunk/wp-inst/wp-images/.htaccess
+ A /trunk/wp-inst/wp-images/wordpress-mu.png
+ A /trunk/wp-inst/wp-includes
+ A /trunk/wp-inst/wp-includes/create_smarty_template.php
+ A /trunk/wp-inst/wp-includes/wpmu-functions.php
+ A /trunk/wp-inst/wpmu-settings.php.dist
+
+Initial Import
+
+------------------------------------------------------------------------
+r1 | matt | 2005-03-06 00:30:26 +0000 (Sun, 06 Mar 2005) | 1 line
+Changed paths:
+ A /branches
+ A /tags
+ A /trunk
+
+Setting up structure
+------------------------------------------------------------------------
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..c1cb67a
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,40 @@
+WordPress Multi User
+--------------------
+
+WordPress MU is a multi user version of WordPress.
+
+
+Install
+=======
+Unarchive into a web directory and call that directory through your
+browser and web server. Follow the instructions and links and all
+should work fine.
+
+Apache
+======
+Apache must be configured so that mod_rewrite works. Here are
+instructions for Apache 2. Apache 1.3 is very similar.
+
+1. Make sure a line like the following appears in your httpd.conf
+LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
+
+2. In the <Directory> directive of your virtual host, look for this
+line
+"AllowOverride None"
+and change it to
+"AllowOverride FileInfo"
+
+Maintenance
+===========
+If you have PEAR Cache, it'll be used to significantly speed up
+things. However, this generates cached files which have to be cleared
+from time to time.
+Uncomment the code in wp-inst/maintenance.php and make sure it's
+protected by IP checks or username/passwords. You should call this
+script at least once a day, and maybe more depending on how busy
+your server is.
+
+Support Forum:
+http://mu.wordpress.org/forums/
+
+http://mu.wordpress.org/
diff --git a/htaccess.dist b/htaccess.dist
new file mode 100644
index 0000000..cf06769
--- /dev/null
+++ b/htaccess.dist
@@ -0,0 +1,131 @@
+RewriteEngine On
+RewriteBase BASE/
+
+###
+#### main blog
+###
+
+RewriteRule ^templates/(.*) BASE/wp-inst/wp-content/blogs/main/templates/$1 [L]
+RewriteRule ^files/(.*) BASE/wp-inst/wp-content/blogs/files/$1 [L]
+RewriteRule ^wp-content/themes/(.*) BASE/wp-inst/wp-content/themes/$1 [L]
+
+# rewrite these
+RewriteRule ^category/(.*)/page/(.*)/ BASE/wp-inst/index.php?wpblog=main&category_name=$1&paged=$2 [L]
+RewriteRule ^category/(.*)/(feed|rdf|rss|rss2|atom)/?$ BASE/wp-inst/wp-feed.php?wpblog=main&category_name=$1&feed=$2 [L]
+RewriteRule ^category/?(.*) BASE/wp-inst/index.php?wpblog=main&category_name=$1 [L]
+RewriteRule ^author/(.*)/(feed|rdf|rss|rss2|atom)/?$ BASE/wp-inst/wp-feed.php?wpblog=main&author_name=$1&feed=$2 [L]
+RewriteRule ^author/?(.*) BASE/wp-inst/index.php?wpblog=main&author_name=$1 [L]
+RewriteRule ^([0-9]{4})/?([0-9]{1,2})?/?([0-9]{1,2})?/?([_0-9a-z-]+)?/?([0-9]+)?/?$ BASE/wp-inst/index.php?wpblog=main&year=$1&monthnum=$2&day=$3&name=$4&page=$5 [L]
+RewriteRule ^([0-9]{4})/?([0-9]{1,2})/([0-9]{1,2})/([_0-9a-z-]+)/(feed|rdf|rss|rss2|atom)/?$ BASE/wp-inst/wp-feed.php?wpblog=main&year=$1&monthnum=$2&day=$3&name=$4&feed=$5 [L]
+RewriteRule ^([0-9]{4})/?([0-9]{1,2})/([0-9]{1,2})/([_0-9a-z-]+)/trackback/?$ BASE/wp-inst/wp-trackback.php?wpblog=main&year=$1&monthnum=$2&day=$3&name=$4 [L]
+RewriteRule ^page/?([0-9]+)?/?$ BASE/wp-inst/index.php?wpblog=main&paged=$1 [QSA]
+RewriteRule ^feed/?([_0-9a-z-]+)?/?$ BASE/wp-inst/wp-feed.php?wpblog=main&feed=$1 [L]
+RewriteRule ^comments/feed/?([_0-9a-z-]+)?/?$ BASE/wp-inst/wp-feed.php?wpblog=main&feed=$1&withcomments=1 [L]
+RewriteRule ^archives/p/([0-9]+)/?(.*)? BASE/wp-inst/index.php?wpblog=main&redirect=yes&p=$1 [L]
+RewriteRule ^archives/cat/([0-9]+)/?(.*)? BASE/wp-inst/index.php?wpblog=main&redirect=yes&cat=$1 [L]
+RewriteRule ^archives/m/([0-9]+)\#?(.*)? BASE/wp-inst/index.php?wpblog=main&redirect=yes&m=$1 [L]
+RewriteRule ^b2rss2.php(.*)? BASE/wp-inst/wp-feed.php?wpblog=main&feed=rss2 [L]
+RewriteRule ^b2rdf.php(.*)? BASE/wp-inst/wp-feed.php?wpblog=main&feed=rdf [L]
+
+# We want to pass these files straight through
+RewriteRule ^wp-comments-post.php(.*) BASE/wp-inst/wp-comments-post.php [L]
+RewriteRule ^go.php(.*) BASE/wp-inst/go.php$1 [L]
+RewriteRule ^pages/(.*) BASE/wp-inst/pages/$1 [L]
+RewriteRule ^wp-admin/(.*) BASE/wp-inst/wp-admin/$1 [L]
+RewriteRule ^wp-atom.php(.*) BASE/wp-inst/wp-atom.php [L]
+RewriteRule ^wp-comments-popup.php(.*) BASE/wp-inst/wp-comments-popup.php [L]
+RewriteRule ^wp-comments-post.php(.*) BASE/wp-inst/wp-comments-post.php [L]
+RewriteRule ^wp-commentsrss2.php(.*) BASE/wp-inst/wp-commentsrss2.php [L]
+RewriteRule ^wp-counter.php(.+)? BASE/wp-inst/wp-counter.php [L]
+RewriteRule ^wp-feed.php(.*) BASE/wp-inst/wp-feed.php [L]
+RewriteRule ^wp-images/(.*) BASE/wp-inst/wp-images/$1 [L]
+RewriteRule ^wp-links-opml.php(.*) BASE/wp-inst/wp-links-opml.php [L]
+RewriteRule ^wp-login.php(.*) BASE/wp-inst/wp-login.php [L]
+RewriteRule ^wp-mail.php(.*) BASE/wp-inst/wp-mail.php [L]
+RewriteRule ^wp-pass.php(.*) BASE/wp-inst/wp-pass.php [L]
+RewriteRule ^wp-rdf.php(.*) BASE/wp-inst/wp-rdf.php [L]
+RewriteRule ^wp-register.php(.*) BASE/wp-inst/wp-register.php [L]
+RewriteRule ^wp-rss.php(.*) BASE/wp-inst/wp-rss.php [L]
+RewriteRule ^wp-rss2.php(.*) BASE/wp-inst/wp-rss2.php [L]
+RewriteRule ^wp-sidebar.php(.*) BASE/wp-inst/wp-sidebar.php [L]
+RewriteRule ^wp-trackback.php(.*) BASE/wp-inst/wp-trackback.php [L]
+RewriteRule ^xmlrpc.php(.*) BASE/wp-inst/xmlrpc.php [L]
+RewriteRule ^maintenance.php BASE/wp-inst/maintenance.php [L]
+RewriteRule ^favicon.ico /wp-inst/favicon.ico [L]
+RewriteRule ^robots.txt /wp-inst/robots.txt [L]
+
+RewriteRule ^wp-newblog.php BASE/wp-inst/wp-newblog.php [L]
+RewriteRule ^index.php BASE/wp-inst/index.php [L]
+
+RewriteRule ^$ BASE/wp-inst/index.php [L]
+
+###
+#### blogs
+###
+RewriteRule ^([_0-9a-z-]+)/templates/(.*) BASE/wp-inst/wp-content/blogs/$1/templates/$2 [L]
+RewriteRule ^([_0-9a-z-]+)/files/(.*) BASE/wp-inst/wp-content/blogs/$1/files/$2 [L]
+RewriteRule ^([_0-9a-z-]+)/wp-content/blogs/(.*)/files/(.*) BASE/wp-inst/wp-content/blogs/$1/files/$3 [L]
+RewriteRule ^([_0-9a-z-]+)/wp-content/themes/(.*) BASE/wp-inst/wp-content/themes/$2 [L]
+
+# rewrite these
+RewriteRule ^([_0-9a-z-]+)/category/(.*)/page/(.*)/ BASE/wp-inst/index.php?wpblog=$1&category_name=$2&paged=$3 [L]
+RewriteRule ^([_0-9a-z-]+)/category/(.*)/(feed|rdf|rss|rss2|atom)/?$ BASE/wp-inst/wp-feed.php?wpblog=$1&category_name=$2&feed=$3 [L]
+RewriteRule ^([_0-9a-z-]+)/category/?(.*) BASE/wp-inst/index.php?wpblog=$1&category_name=$2 [L]
+RewriteRule ^([_0-9a-z-]+)/author/(.*)/(feed|rdf|rss|rss2|atom)/?$ BASE/wp-inst/wp-feed.php?wpblog=$1&author_name=$2&feed=$3 [L]
+RewriteRule ^([_0-9a-z-]+)/author/?(.*) BASE/wp-inst/index.php?wpblog=$1&author_name=$2 [L]
+RewriteRule ^([_0-9a-z-]+)/([0-9]{4})/?([0-9]{1,2})?/?([0-9]{1,2})?/?([_0-9a-z-]+)?/?([0-9]+)?/?$ BASE/wp-inst/index.php?wpblog=$1&year=$2&monthnum=$3&day=$4&name=$5&page=$6 [L]
+RewriteRule ^([_0-9a-z-]+)/([0-9]{4})/?([0-9]{1,2})/([0-9]{1,2})/([_0-9a-z-]+)/(feed|rdf|rss|rss2|atom)/?$ BASE/wp-inst/wp-feed.php?wpblog=$1&year=$2&monthnum=$3&day=$4&name=$5&feed=$6 [L]
+RewriteRule ^([_0-9a-z-]+)/([0-9]{4})/?([0-9]{1,2})/([0-9]{1,2})/([_0-9a-z-]+)/trackback/?$ BASE/wp-inst/wp-trackback.php?wpblog=$1&year=$2&monthnum=$3&day=$4&name=$5 [L]
+RewriteRule ^([_0-9a-z-]+)/page/?([0-9]+)?/?$ BASE/wp-inst/index.php?paged=$2 [QSA]
+RewriteRule ^([_0-9a-z-]+)/feed/?([_0-9a-z-]+)?/?$ BASE/wp-inst/wp-feed.php?wpblog=$1&feed=$2 [L]
+RewriteRule ^([_0-9a-z-]+)/comments/feed/?([_0-9a-z-]+)?/?$ BASE/wp-inst/wp-feed.php?wpblog=$1&feed=$2&withcomments=1 [L]
+RewriteRule ^([_0-9a-z-]+)/archives/p/([0-9]+)/?(.*)? BASE/wp-inst/index.php?wpblog=$1&redirect=yes&p=$2 [L]
+RewriteRule ^([_0-9a-z-]+)/archives/cat/([0-9]+)/?(.*)? BASE/wp-inst/index.php?wpblog=$1&redirect=yes&cat=$2 [L]
+RewriteRule ^([_0-9a-z-]+)/archives/m/([0-9]+)\#?(.*)? BASE/wp-inst/index.php?wpblog=$1&redirect=yes&m=$2 [L]
+RewriteRule ^([_0-9a-z-]+)/b2rss2.php(.*)? BASE/wp-inst/wp-feed.php?wpblog=$1&feed=rss2 [L]
+RewriteRule ^([_0-9a-z-]+)/b2rdf.php(.*)? BASE/wp-inst/wp-feed.php?wpblog=$1&feed=rdf [L]
+
+# We want to pass these files straight through
+RewriteRule ^([_0-9a-z-]+)/wp-comments-post.php(.*) BASE/wp-inst/wp-comments-post.php [L]
+RewriteRule ^([_0-9a-z-]+)/go.php(.*) BASE/wp-inst/go.php$2 [L]
+RewriteRule ^([_0-9a-z-]+)/pages/(.*) BASE/wp-inst/pages/$2 [L]
+RewriteRule ^([_0-9a-z-]+)/wp-admin/(.*) BASE/wp-inst/wp-admin/$2 [L]
+RewriteRule ^([_0-9a-z-]+)/wp-atom.php(.*) BASE/wp-inst/wp-atom.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-comments-popup.php(.*) BASE/wp-inst/wp-comments-popup.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-comments-post.php(.*) BASE/wp-inst/wp-comments-post.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-commentsrss2.php(.*) BASE/wp-inst/wp-commentsrss2.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-counter.php(.+)? BASE/wp-inst/wp-counter.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-feed.php(.*) BASE/wp-inst/wp-feed.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-images/(.*) BASE/wp-inst/wp-images/$2 [L]
+RewriteRule ^([_0-9a-z-]+)/wp-links-opml.php(.*) BASE/wp-inst/wp-links-opml.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-login.php(.*) BASE/wp-inst/wp-login.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-mail.php(.*) BASE/wp-inst/wp-mail.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-pass.php(.*) BASE/wp-inst/wp-pass.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-rdf.php(.*) BASE/wp-inst/wp-rdf.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-register.php(.*) BASE/wp-inst/wp-register.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-rss.php(.*) BASE/wp-inst/wp-rss.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-rss2.php(.*) BASE/wp-inst/wp-rss2.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-sidebar.php(.*) BASE/wp-inst/wp-sidebar.php [L]
+RewriteRule ^([_0-9a-z-]+)/wp-trackback.php(.*) BASE/wp-inst/wp-trackback.php [L]
+RewriteRule ^([_0-9a-z-]+)/xmlrpc.php(.*) BASE/wp-inst/xmlrpc.php [L]
+RewriteRule ^([_0-9a-z-]+)/maintenance.php BASE/wp-inst/maintenance.php [L]
+RewriteRule ^([_0-9a-z-]+)/favicon.ico /wp-inst/favicon.ico [L]
+
+# pages
+RewriteCond REALPATH/wp-inst/wp-content/blogs/%{1} -d
+RewriteRule ^([_0-9a-z-]+)/(.*)/$ BASE/wp-inst/index.php?pagename=$2 [L]
+
+RewriteRule ^(.*)/$ BASE/wp-inst/index.php?pagename=$1 [L]
+
+# catch all rules
+RewriteCond REALPATH/wp-inst/wp-content/blogs/%{1} -d
+RewriteRule ^([_0-9a-z-]+)/ BASE/wp-inst/index.php [L]
+
+RewriteRule ^([_0-9a-z-]+)/(.+)$ BASE/wp-inst/$2 [L]
+
+RewriteCond %{REQUEST_FILENAME} -d
+RewriteRule ^(.+[^/])$ BASE/ [R,L]
+RewriteCond REALPATH/wp-inst/wp-content/blogs/%{1} -d
+RewriteRule ^(.*[^/])$ BASE/$1/ [R,L]
+
+AddType text/css .css
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..66c745e
--- /dev/null
+++ b/index.php
@@ -0,0 +1,396 @@
+<?php
+define('WP_INSTALLING', true);
+
+function printheader() {
+ print '
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>WordPress &rsaquo; Installation</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <style media="screen" type="text/css">
+ <!--
+ html {
+ background: #eee;
+ }
+ body {
+ background: #fff;
+ color: #000;
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 20%;
+ margin-right: 20%;
+ padding: .2em 2em;
+ }
+
+ h1 {
+ color: #006;
+ font-size: 18px;
+ font-weight: lighter;
+ }
+
+ h2 {
+ font-size: 16px;
+ }
+
+ p, li, dt {
+ line-height: 140%;
+ padding-bottom: 2px;
+ }
+
+ ul, ol {
+ padding: 5px 5px 5px 20px;
+ }
+ #logo {
+ margin-bottom: 2em;
+ }
+.step a, .step input {
+ font-size: 2em;
+}
+.step, th {
+ text-align: right;
+}
+#footer {
+text-align: center; border-top: 1px solid #ccc; padding-top: 1em; font-style: italic;
+}
+.fakelink {
+ color: #00a;
+ text-decoration: underline;
+}
+ -->
+ </style>
+</head>
+<body>
+
+<div align="center"><img src="wp-inst/wp-images/wordpress-mu.png"></div><br>
+Welcome to WordPress MU, the Multi User Weblog System built on WordPress.<br><br>
+';
+}
+
+function check_writeable_dir( $dir, $ret )
+{
+ if( is_writeable( $dir ) == false )
+ {
+ print $dir." : <b style='color: #f55'>FAILED</b><br>Quick Fix: <code>chmod 777 $dir</code><br>";
+ return false;
+ }
+ else
+ {
+ if( $ret == true )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
+
+function do_htaccess( $oldfilename, $newfilename, $realpath, $base, $url )
+{
+ // remove ending slash from $base and $url
+ $htaccess = '';
+ if( substr($base, -1 ) == '/') {
+ $base = substr($base, 0, -1);
+ }
+
+ if( substr($url, -1 ) == '/') {
+ $url = substr($url, 0, -1);
+ }
+ if( is_file( $oldfilename ) )
+ {
+ $fp = fopen( $oldfilename, "r" );
+ if( $fp )
+ {
+ while( !feof( $fp ) )
+ {
+ $htaccess .= fgets( $fp, 4096 );
+ }
+ fclose( $fp );
+ $htaccess = str_replace( "REALPATH", $realpath, $htaccess );
+ $htaccess = str_replace( "BASE", $base, $htaccess );
+ $htaccess = str_replace( "HOST", $url, $htaccess );
+ $fp = fopen( $newfilename, "w" );
+ fwrite( $fp, $htaccess );
+ fclose( $fp );
+ }
+ }
+}
+
+function checkdirs() {
+ $ret = true;
+ $ret = check_writeable_dir( dirname(__FILE__), $ret );
+ $ret = check_writeable_dir( dirname(__FILE__) . "/wp-inst", $ret );
+ $ret = check_writeable_dir( dirname(__FILE__) . "/wp-inst/wp-content/", $ret );
+ $ret = check_writeable_dir( dirname(__FILE__) . "/wp-inst/wp-content/smarty-templates", $ret );
+
+ if( $ret == false )
+ {
+ print "<h2>Warning!</h2>";
+ print "<div style='border: 1px solid #ccc'>";
+ print "<p style='font-weight: bold; padding-left: 10px'>One or more of the above directories must be made writeable by the webserver.<br>";
+ print "Please <code>chmod 777 <q>directory-name</q></code> or <code>chown</code> that directory to the user the web server runs as (usually nobody, apache, or www-data)<br>";
+ print "Refresh this page when you're done!<br></p>";
+ print "</div>";
+ }
+
+ return $ret;
+}
+
+function step1() {
+ print "You're probably seeing this message because you're installing WPMU!<br><br>";
+ print "If it's already installed, then <b>mod_rewrite</b> is disabled. Ask your administrator to enable that module, or look at the <a href='http://httpd.apache.org/docs/mod/mod_rewrite.html'>Apache documentation</a> or <a href='http://www.google.com/search?q=apache+mod_rewrite'>elsewhere</a> for help setting it up.<br><br>";
+ if( checkdirs() == false ) {
+ return false;
+ }
+
+ // Create default template cache dirs
+ @mkdir( dirname(__FILE__) . "/wp-inst/wp-content/smarty-cache" , 0777 );
+ @mkdir( dirname(__FILE__) . "/wp-inst/wp-content/smarty-templates_c" , 0777 );
+
+ // create plugins dir
+ @mkdir( dirname(__FILE__) . "/wp-inst/wp-content/mu-plugins" , 0777 );
+
+ // Create Blogs living area.
+ @mkdir( dirname(__FILE__) . "/wp-inst/wp-content/blogs.dir", 0777 );
+
+
+ $url = "http://".$_SERVER["SERVER_NAME"] . dirname( $_SERVER[ "SCRIPT_NAME" ] );
+ if( substr( $url, -1 ) == '/' )
+ $url = substr( $url, 0, -1 );
+ $base = dirname( $_SERVER["SCRIPT_NAME"] );
+ if( $base == "/")
+ {
+ $base = "";
+ }
+ $realpath = dirname(__FILE__);
+
+ if( is_file( dirname(__FILE__) . "./wp-inst/wpmu-settings.php" ) == false )
+ {
+ $configfile = '';
+ $fp = fopen( "./wp-inst/wpmu-settings.php.dist", "r" );
+ if( $fp )
+ {
+ while( !feof( $fp ) )
+ {
+ $configfile .= fgets( $fp, 4096 );
+ }
+ fclose( $fp );
+ }
+ $configfile = str_replace( "BASE", $base."/", $configfile );
+ $fp = fopen( "./wp-inst/wpmu-settings.php", "w" );
+ fwrite( $fp, $configfile );
+ fclose( $fp );
+ }
+ return true;
+}
+
+function printstep1form( $dbname = 'wordpress', $uname = 'username', $pwd = 'password', $dbhost = 'localhost', $prefix = 'wp_' ) {
+ print "
+ <form method='post' action='index.php'>
+ <input type='hidden' name='action' value='step2'>
+ <h1>Virtual Server Support</h1>
+ <p><strong>Do you want to enable virtual server support?&nbsp;&nbsp;&nbsp;Yes <input type='radio' name='vhost' value='yes'> No <input type='radio' name='vhost' value='no' checked></strong></p>
+ <p>If you do, your blog addresses will appear like <span class='fakelink'>http://joesblog.example.com/</span> instead of <span class='fakelink'>http://www.example.com/joesblog/</span> but you need to do a few more things to Apache and your DNS settings before it'll work.<br />
+ If this is your first time installing WPMU then leave this at <em>No</em>.</p>
+ <br />
+ <h1>Database</h1>
+<p>We need some information on the database. You will need to know the following items before proceeding.</p>
+<ol>
+ <li>Database name</li>
+ <li>Database username</li>
+ <li>Database password</li>
+ <li>Database host</li>
+ <li>Table prefix (if you want to run more than one WordPress in a single database) </li>
+</ol>
+<p><strong>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 <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p>
+
+ <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
+ <table>
+ <tr>
+ <th scope='row'>Database Name</th>
+ <td><input name='dbname' type='text' size='45' value='".$dbname."' /></td>
+ <td>The name of the database you want to run WP in. </td>
+ </tr>
+ <tr>
+ <th scope='row'>User Name</th>
+ <td><input name='uname' type='text' size='45' value='".$uname."' /></td>
+ <td>Your MySQL username</td>
+ </tr>
+ <tr>
+ <th scope='row'>Password</th>
+ <td><input name='pwd' type='text' size='45' value='".$pwd."' /></td>
+ <td>...and MySQL password.</td>
+ </tr>
+ <tr>
+ <th scope='row'>Database Host</th>
+ <td><input name='dbhost' type='text' size='45' value='".$dbhost."' /></td>
+ <td>99% chance you won't need to change this value.</td>
+ </tr>
+ <tr>
+ <th scope='row'>Table Prefix</th>
+ <td><input name='prefix' type='text' id='prefix' value='".$prefix."' size='45' /></td>
+ <td>If you want to run multiple WordPress installations in a single database, change this.</td>
+ </tr>
+ </table>
+ <input name='submit' type='submit' value='Submit' />
+</form> ";
+}
+
+function step2() {
+ $dbname = $_POST['dbname'];
+ $uname = $_POST['uname'];
+ $passwrd = $_POST['pwd'];
+ $dbhost = $_POST['dbhost'];
+ $vhost = $_POST['vhost' ];
+ $prefix = $_POST['prefix'];
+ if (empty($prefix)) $prefix = 'wp_';
+
+ // Test the db connection.
+ define('DB_NAME', $dbname);
+ define('DB_USER', $uname);
+ define('DB_PASSWORD', $passwrd);
+ define('DB_HOST', $dbhost);
+
+ if (!file_exists('wp-inst/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-inst/wp-config-sample.php');
+ // We'll fail here if the values are no good.
+ require_once('wp-inst/wp-includes/wp-db.php');
+ printheader();
+
+ print "Creating Database Config File: ";
+
+ $handle = fopen('wp-inst/wp-config.php', 'w');
+
+ foreach ($configFile as $line_num => $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 "define('VHOST', ":
+ fwrite($handle, str_replace("VHOSTSETTING", $vhost, $line));
+ break;
+ case '$table_prefix =':
+ fwrite($handle, str_replace('wp_', $prefix, $line));
+ break;
+ default:
+ fwrite($handle, $line);
+ }
+ }
+ fclose($handle);
+ chmod('wp-inst/wp-config.php', 0666);
+ print "<b style='color: #00aa00; font-weight: bold'>DONE</b><br />";
+}
+
+function printuserdetailsform( $weblog_title = 'My new Blog', $username = '', $email = '' ) {
+ print "
+ <form method='post' action='index.php'>
+ <input type='hidden' name='action' value='step3'>
+ <p>To finish setting up your blog, please fill in the folling form and click <q>Submit</q>.</p>
+ <table width='100%'>
+ <tr>
+ <th scope='row'>Weblog&nbsp;Title</th>
+ <td><input name='weblog_title' type='text' size='45' value='".$weblog_title."' /></td>
+ <td>What would you like to call your weblog? </td>
+ </tr>
+ <tr>
+ <th scope='row'>Email</th>
+ <td><input name='email' type='text' size='45' value='".$email."' /></td>
+ <td>Your email address.</td>
+ </tr>
+ </table>
+ <input name='submit' type='submit' value='Submit' />
+ </form>
+ <br />
+ You will be sent an email with your password and login links and details.";
+}
+
+function step3() {
+ global $wpdb;
+ $base = dirname( $_SERVER["SCRIPT_NAME"] );
+ $domain = $_SERVER[ 'HTTP_HOST' ];
+ if( substr_count( $_SERVER["HTTP_HOST"], '.' ) > 1 ) {
+ $domain = substr( $_SERVER["HTTP_HOST"], strpos( $_SERVER["HTTP_HOST"], '.' ) + 1 );
+ }
+
+ $hostname = $_SERVER["HTTP_HOST"];
+
+ $email = $wpdb->escape( $_POST[ 'email' ] );
+ $weblog_title = $wpdb->escape( $_POST[ 'weblog_title' ] );
+
+ // set up site tables
+ $query = "INSERT INTO wp_sitemeta (meta_id, site_id, meta_key, meta_value) VALUES (1, 1, 'admin_email', '".$email."')";
+ $wpdb->query( $query );
+ $query = "INSERT INTO wp_sitemeta (meta_id, site_id, meta_key, meta_value) VALUES (2, 1, 'admin_user_id', '1')";
+ $wpdb->query( $query );
+
+ $res = createBlog( $hostname, $domain, $base, 'main', $weblog_title, $email, 'admin' );
+ if( $res == 'ok' ) {
+ if( $base == '/' ) {
+ $url = "http://".$_SERVER["HTTP_HOST"] . '/';
+ } else {
+ $url = "http://".$_SERVER["HTTP_HOST"] . $base . '/';
+ }
+ $realpath = dirname(__FILE__);
+ do_htaccess( "htaccess.dist", ".htaccess", $realpath, $base, $url );
+ do_htaccess( "wp-inst/htaccess.dist", "wp-inst/.htaccess", $realpath, $base, $url );
+
+ print "<p>Well Done! Your blog has been set up and you have been sent details of your login and password in an email.</p>";
+ print "<p>You may view your new blog by visiting <a href='".$url."'>".$url."</a>!</p>";
+ } else {
+ if( $res == 'error: problem creating blog entry' ) {
+ print "The <q>main</q> blog has already been created. Edit your blogs table and delete the entry for this domain!";
+ } elseif( $res == 'error: username used' ) {
+ print "The username you chose is already in use, please select another one.";
+ }
+ print "<br>result: $res<br>";
+ printuserdetailsform( $_POST[ 'weblog_title' ], $_POST[ 'username' ], $_POST[ 'email' ] );
+ }
+}
+
+switch( $_POST[ 'action' ] ) {
+ case "step2":
+ // get blog username
+ // create wp-inst/wp-config.php
+ step2();
+ printuserdetailsform();
+ break;
+ case "step3":
+ // call createBlog();
+ // create .htaccess
+ // print login info and links.
+ require_once('./wp-inst/wp-config.php');
+ require_once('./wp-inst/wp-admin/upgrade-functions.php');
+ make_db_current_silent();
+ populate_options();
+ printheader();
+ step3();
+ break;
+ default:
+ // check that directories are writeable.
+ // create wp-inst/wpmu-settings.php
+ // get db auth info.
+ printheader();
+ if( step1() ) {
+ printstep1form();
+ }
+ break;
+}
+?>
+<br /><br />
+<div align='center'>
+<a href="http://mu.wordpress.org/">WPMU</a> | <a href="http://mu.wordpress.org/forums/">Support Forums</a>
+</div>
+</body>
+</html>
diff --git a/release.sh b/release.sh
new file mode 100755
index 0000000..41d6867
--- /dev/null
+++ b/release.sh
@@ -0,0 +1,73 @@
+#
+# Make a WPMU release.
+# Needs Smarty from http://smarty.php.net/
+# Copyright Donncha O Caoimh, donncha@linux.ie
+#
+
+# Create stable release
+
+export STABLEWP=2618
+export STABLEWPMU=78
+export RELEASE=1_5_1_3
+
+rm -fr wpmu-stable trunk wordpress-$RELEASE
+
+svn export http://svn.automattic.com/wordpress/tags/1.5.1.3
+mv 1.5.1.3 wordpress-$RELEASE
+
+svn export -r $STABLEWPMU http://svn.automattic.com/wordpress-smarty/trunk/
+mv trunk wpmu-stable
+
+svn co -r $STABLEWPMU http://svn.automattic.com/wordpress-smarty/trunk && cd trunk && svn -v log > ../Changelog.txt && cd ..
+rm -fr trunk
+
+export WPMUDIR=wpmu-stable-$RELEASE
+rm -fr $WPMUDIR
+
+mkdir -p $WPMUDIR/wp-inst/
+cp -r wordpress-$RELEASE/* $WPMUDIR/wp-inst/
+rm -fr $WPMUDIR/wp-inst/wp-content/themes
+cp -af wpmu-stable/* $WPMUDIR/
+rm -fr wpmu-stable
+
+cp -av ./Smarty-2.6.9/libs/internals $WPMUDIR/wp-inst/
+cp -av ./Smarty-2.6.9/libs/Smarty_Compiler.class.php $WPMUDIR/wp-inst/
+cp -av ./Smarty-2.6.9/libs/Smarty.class.php $WPMUDIR/wp-inst/
+cp -av ./Smarty-2.6.9/libs/Config_File.class.php $WPMUDIR/wp-inst/
+cp -av ./Smarty-2.6.9/libs/plugins/* $WPMUDIR/wp-inst/wp-content/smarty-plugins/
+
+cd $WPMUDIR/wp-inst/wp-includes/ && php create_smarty_template.php > class-smarty.php && cd ../../..
+mv Changelog.txt $WPMUDIR/
+
+zip -r $WPMUDIR.zip $WPMUDIR
+tar zcvf $WPMUDIR.tar.gz $WPMUDIR
+
+# Create unstable release
+rm -fr wpmu-latest wordpress-latest wordpress-smarty
+svn export http://svn.automattic.com/wordpress/trunk/
+mv trunk wordpress-latest
+svn export http://svn.automattic.com/wordpress-smarty/
+mv wordpress-smarty/trunk wpmu-latest
+svn co http://svn.automattic.com/wordpress-smarty/trunk && cd trunk && svn -v log > ../Changelog.txt && cd ..
+rm -fr trunk wordpress-smarty
+
+export WPMUDIR=wpmu-`date +%Y-%m-%d`
+rm -fr $WPMUDIR
+
+mkdir -p $WPMUDIR/wp-inst/
+mv wordpress-latest/* $WPMUDIR/wp-inst/
+rm -fr wordpress-latest
+cp -af wpmu-latest/* $WPMUDIR/
+rm -fr wpmu-latest
+
+cp -av ./Smarty-2.6.9/libs/internals $WPMUDIR/wp-inst/
+cp -av ./Smarty-2.6.9/libs/Smarty_Compiler.class.php $WPMUDIR/wp-inst/
+cp -av ./Smarty-2.6.9/libs/Smarty.class.php $WPMUDIR/wp-inst/
+cp -av ./Smarty-2.6.9/libs/Config_File.class.php $WPMUDIR/wp-inst/
+cp -av ./Smarty-2.6.9/libs/plugins/* $WPMUDIR/wp-inst/wp-content/smarty-plugins/
+
+cd $WPMUDIR/wp-inst/wp-includes/ && php create_smarty_template.php > class-smarty.php && cd ../../..
+mv Changelog.txt $WPMUDIR/
+
+zip -r $WPMUDIR.zip $WPMUDIR
+tar zcvf $WPMUDIR.tar.gz $WPMUDIR
diff --git a/wp-inst/Config_File.class.php b/wp-inst/Config_File.class.php
new file mode 100644
index 0000000..b5fdd22
--- /dev/null
+++ b/wp-inst/Config_File.class.php
@@ -0,0 +1,389 @@
+<?php
+
+/**
+ * Config_File class.
+ *
+ * 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
+ *
+ * @link http://smarty.php.net/
+ * @version 2.6.9
+ * @copyright Copyright: 2001-2005 New Digital Group, Inc.
+ * @author Andrei Zmievski <andrei@php.net>
+ * @access public
+ * @package Smarty
+ */
+
+/* $Id: Config_File.class.php,v 1.78 2005/03/22 08:45:06 messju Exp $ */
+
+/**
+ * Config file reading class
+ * @package Smarty
+ */
+class Config_File {
+ /**#@+
+ * Options
+ * @var boolean
+ */
+ /**
+ * Controls whether variables with the same name overwrite each other.
+ */
+ var $overwrite = true;
+
+ /**
+ * Controls whether config values of on/true/yes and off/false/no get
+ * converted to boolean values automatically.
+ */
+ var $booleanize = true;
+
+ /**
+ * Controls whether hidden config sections/vars are read from the file.
+ */
+ var $read_hidden = true;
+
+ /**
+ * Controls whether or not to fix mac or dos formatted newlines.
+ * If set to true, \r or \r\n will be changed to \n.
+ */
+ var $fix_newlines = true;
+ /**#@-*/
+
+ /** @access private */
+ var $_config_path = "";
+ var $_config_data = array();
+ /**#@-*/
+
+ /**
+ * Constructs a new config file class.
+ *
+ * @param string $config_path (optional) path to the config files
+ */
+ function Config_File($config_path = NULL)
+ {
+ if (isset($config_path))
+ $this->set_path($config_path);
+ }
+
+
+ /**
+ * Set the path where configuration files can be found.
+ *
+ * @param string $config_path path to the config files
+ */
+ function set_path($config_path)
+ {
+ if (!empty($config_path)) {
+ if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) {
+ $this->_trigger_error_msg("Bad config file path '$config_path'");
+ return;
+ }
+ if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
+ $config_path .= DIRECTORY_SEPARATOR;
+ }
+
+ $this->_config_path = $config_path;
+ }
+ }
+
+
+ /**
+ * Retrieves config info based on the file, section, and variable name.
+ *
+ * @param string $file_name config file to get info for
+ * @param string $section_name (optional) section to get info for
+ * @param string $var_name (optional) variable to get info for
+ * @return string|array a value or array of values
+ */
+ function &get($file_name, $section_name = NULL, $var_name = NULL)
+ {
+ if (empty($file_name)) {
+ $this->_trigger_error_msg('Empty config file name');
+ return;
+ } else {
+ $file_name = $this->_config_path . $file_name;
+ if (!isset($this->_config_data[$file_name]))
+ $this->load_file($file_name, false);
+ }
+
+ if (!empty($var_name)) {
+ if (empty($section_name)) {
+ return $this->_config_data[$file_name]["vars"][$var_name];
+ } else {
+ if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]))
+ return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name];
+ else
+ return array();
+ }
+ } else {
+ if (empty($section_name)) {
+ return (array)$this->_config_data[$file_name]["vars"];
+ } else {
+ if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"]))
+ return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"];
+ else
+ return array();
+ }
+ }
+ }
+
+
+ /**
+ * Retrieves config info based on the key.
+ *
+ * @param $file_name string config key (filename/section/var)
+ * @return string|array same as get()
+ * @uses get() retrieves information from config file and returns it
+ */
+ function &get_key($config_key)
+ {
+ list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
+ $result = &$this->get($file_name, $section_name, $var_name);
+ return $result;
+ }
+
+ /**
+ * Get all loaded config file names.
+ *
+ * @return array an array of loaded config file names
+ */
+ function get_file_names()
+ {
+ return array_keys($this->_config_data);
+ }
+
+
+ /**
+ * Get all section names from a loaded file.
+ *
+ * @param string $file_name config file to get section names from
+ * @return array an array of section names from the specified file
+ */
+ function get_section_names($file_name)
+ {
+ $file_name = $this->_config_path . $file_name;
+ if (!isset($this->_config_data[$file_name])) {
+ $this->_trigger_error_msg("Unknown config file '$file_name'");
+ return;
+ }
+
+ return array_keys($this->_config_data[$file_name]["sections"]);
+ }
+
+
+ /**
+ * Get all global or section variable names.
+ *
+ * @param string $file_name config file to get info for
+ * @param string $section_name (optional) section to get info for
+ * @return array an array of variables names from the specified file/section
+ */
+ function get_var_names($file_name, $section = NULL)
+ {
+ if (empty($file_name)) {
+ $this->_trigger_error_msg('Empty config file name');
+ return;
+ } else if (!isset($this->_config_data[$file_name])) {
+ $this->_trigger_error_msg("Unknown config file '$file_name'");
+ return;
+ }
+
+ if (empty($section))
+ return array_keys($this->_config_data[$file_name]["vars"]);
+ else
+ return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]);
+ }
+
+
+ /**
+ * Clear loaded config data for a certain file or all files.
+ *
+ * @param string $file_name file to clear config data for
+ */
+ function clear($file_name = NULL)
+ {
+ if ($file_name === NULL)
+ $this->_config_data = array();
+ else if (isset($this->_config_data[$file_name]))
+ $this->_config_data[$file_name] = array();
+ }
+
+
+ /**
+ * Load a configuration file manually.
+ *
+ * @param string $file_name file name to load
+ * @param boolean $prepend_path whether current config path should be
+ * prepended to the filename
+ */
+ function load_file($file_name, $prepend_path = true)
+ {
+ if ($prepend_path && $this->_config_path != "")
+ $config_file = $this->_config_path . $file_name;
+ else
+ $config_file = $file_name;
+
+ ini_set('track_errors', true);
+ $fp = @fopen($config_file, "r");
+ if (!is_resource($fp)) {
+ $this->_trigger_error_msg("Could not open config file '$config_file'");
+ return false;
+ }
+
+ $contents = ($size = filesize($config_file)) ? fread($fp, $size) : '';
+ fclose($fp);
+
+ $this->_config_data[$config_file] = $this->parse_contents($contents);
+ return true;
+ }
+
+ /**
+ * Store the contents of a file manually.
+ *
+ * @param string $config_file file name of the related contents
+ * @param string $contents the file-contents to parse
+ */
+ function set_file_contents($config_file, $contents)
+ {
+ $this->_config_data[$config_file] = $this->parse_contents($contents);
+ return true;
+ }
+
+ /**
+ * parse the source of a configuration file manually.
+ *
+ * @param string $contents the file-contents to parse
+ */
+ function parse_contents($contents)
+ {
+ if($this->fix_newlines) {
+ // fix mac/dos formatted newlines
+ $contents = preg_replace('!\r\n?!', "\n", $contents);
+ }
+
+ $config_data = array();
+ $config_data['sections'] = array();
+ $config_data['vars'] = array();
+
+ /* reference to fill with data */
+ $vars =& $config_data['vars'];
+
+ /* parse file line by line */
+ preg_match_all('!^.*\r?\n?!m', $contents, $match);
+ $lines = $match[0];
+ for ($i=0, $count=count($lines); $i<$count; $i++) {
+ $line = $lines[$i];
+ if (empty($line)) continue;
+
+ if ( $line{0} == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) {
+ /* section found */
+ if ($match[1]{0} == '.') {
+ /* hidden section */
+ if ($this->read_hidden) {
+ $section_name = substr($match[1], 1);
+ } else {
+ /* break reference to $vars to ignore hidden section */
+ unset($vars);
+ $vars = array();
+ continue;
+ }
+ } else {
+ $section_name = $match[1];
+ }
+ if (!isset($config_data['sections'][$section_name]))
+ $config_data['sections'][$section_name] = array('vars' => array());
+ $vars =& $config_data['sections'][$section_name]['vars'];
+ continue;
+ }
+
+ if (preg_match('/^\s*(\.?\w+)\s*=\s*(.*)/s', $line, $match)) {
+ /* variable found */
+ $var_name = rtrim($match[1]);
+ if (strpos($match[2], '"""') === 0) {
+ /* handle multiline-value */
+ $lines[$i] = substr($match[2], 3);
+ $var_value = '';
+ while ($i<$count) {
+ if (($pos = strpos($lines[$i], '"""')) === false) {
+ $var_value .= $lines[$i++];
+ } else {
+ /* end of multiline-value */
+ $var_value .= substr($lines[$i], 0, $pos);
+ break;
+ }
+ }
+ $booleanize = false;
+
+ } else {
+ /* handle simple value */
+ $var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', rtrim($match[2]));
+ $booleanize = $this->booleanize;
+
+ }
+ $this->_set_config_var($vars, $var_name, $var_value, $booleanize);
+ }
+ /* else unparsable line / means it is a comment / means ignore it */
+ }
+ return $config_data;
+ }
+
+ /**#@+ @access private */
+ /**
+ * @param array &$container
+ * @param string $var_name
+ * @param mixed $var_value
+ * @param boolean $booleanize determines whether $var_value is converted to
+ * to true/false
+ */
+ function _set_config_var(&$container, $var_name, $var_value, $booleanize)
+ {
+ if ($var_name{0} == '.') {
+ if (!$this->read_hidden)
+ return;
+ else
+ $var_name = substr($var_name, 1);
+ }
+
+ if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) {
+ $this->_trigger_error_msg("Bad variable name '$var_name'");
+ return;
+ }
+
+ if ($booleanize) {
+ if (preg_match("/^(on|true|yes)$/i", $var_value))
+ $var_value = true;
+ else if (preg_match("/^(off|false|no)$/i", $var_value))
+ $var_value = false;
+ }
+
+ if (!isset($container[$var_name]) || $this->overwrite)
+ $container[$var_name] = $var_value;
+ else {
+ settype($container[$var_name], 'array');
+ $container[$var_name][] = $var_value;
+ }
+ }
+
+ /**
+ * @uses trigger_error() creates a PHP warning/error
+ * @param string $error_msg
+ * @param integer $error_type one of
+ */
+ function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
+ {
+ trigger_error("Config_File error: $error_msg", $error_type);
+ }
+ /**#@-*/
+}
+
+?>
diff --git a/wp-inst/Smarty.class.php b/wp-inst/Smarty.class.php
new file mode 100644
index 0000000..bb51290
--- /dev/null
+++ b/wp-inst/Smarty.class.php
@@ -0,0 +1,1934 @@
+<?php
+
+/**
+ * Project: Smarty: the PHP compiling template engine
+ * File: Smarty.class.php
+ *
+ * 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
+ *
+ * For questions, help, comments, discussion, etc., please join the
+ * Smarty mailing list. Send a blank e-mail to
+ * smarty-general-subscribe@lists.php.net
+ *
+ * @link http://smarty.php.net/
+ * @copyright 2001-2005 New Digital Group, Inc.
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author Andrei Zmievski <andrei@php.net>
+ * @package Smarty
+ * @version 2.6.9
+ */
+
+/* $Id: Smarty.class.php,v 1.514 2005/03/22 08:45:06 messju Exp $ */
+
+/**
+ * DIR_SEP isn't used anymore, but third party apps might
+ */
+if(!defined('DIR_SEP')) {
+ define('DIR_SEP', DIRECTORY_SEPARATOR);
+}
+
+/**
+ * set SMARTY_DIR to absolute path to Smarty library files.
+ * if not defined, include_path will be used. Sets SMARTY_DIR only if user
+ * application has not already defined it.
+ */
+
+if (!defined('SMARTY_DIR')) {
+ define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+}
+
+if (!defined('SMARTY_CORE_DIR')) {
+ define('SMARTY_CORE_DIR', SMARTY_DIR . 'internals' . DIRECTORY_SEPARATOR);
+}
+
+define('SMARTY_PHP_PASSTHRU', 0);
+define('SMARTY_PHP_QUOTE', 1);
+define('SMARTY_PHP_REMOVE', 2);
+define('SMARTY_PHP_ALLOW', 3);
+
+/**
+ * @package Smarty
+ */
+class Smarty
+{
+ /**#@+
+ * Smarty Configuration Section
+ */
+
+ /**
+ * The name of the directory where templates are located.
+ *
+ * @var string
+ */
+ var $template_dir = 'templates';
+
+ /**
+ * The directory where compiled templates are located.
+ *
+ * @var string
+ */
+ var $compile_dir = 'templates_c';
+
+ /**
+ * The directory where config files are located.
+ *
+ * @var string
+ */
+ var $config_dir = 'configs';
+
+ /**
+ * An array of directories searched for plugins.
+ *
+ * @var array
+ */
+ var $plugins_dir = array('plugins');
+
+ /**
+ * If debugging is enabled, a debug console window will display
+ * when the page loads (make sure your browser allows unrequested
+ * popup windows)
+ *
+ * @var boolean
+ */
+ var $debugging = false;
+
+ /**
+ * When set, smarty does uses this value as error_reporting-level.
+ *
+ * @var boolean
+ */
+ var $error_reporting = null;
+
+ /**
+ * This is the path to the debug console template. If not set,
+ * the default one will be used.
+ *
+ * @var string
+ */
+ var $debug_tpl = '';
+
+ /**
+ * This determines if debugging is enable-able from the browser.
+ * <ul>
+ * <li>NONE => no debugging control allowed</li>
+ * <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li>
+ * </ul>
+ * @link http://www.foo.dom/index.php?SMARTY_DEBUG
+ * @var string
+ */
+ var $debugging_ctrl = 'NONE';
+
+ /**
+ * This tells Smarty whether to check for recompiling or not. Recompiling
+ * does not need to happen unless a template or config file is changed.
+ * Typically you enable this during development, and disable for
+ * production.
+ *
+ * @var boolean
+ */
+ var $compile_check = true;
+
+ /**
+ * This forces templates to compile every time. Useful for development
+ * or debugging.
+ *
+ * @var boolean
+ */
+ var $force_compile = false;
+
+ /**
+ * This enables template caching.
+ * <ul>
+ * <li>0 = no caching</li>
+ * <li>1 = use class cache_lifetime value</li>
+ * <li>2 = use cache_lifetime in cache file</li>
+ * </ul>
+ * @var integer
+ */
+ var $caching = 0;
+
+ /**
+ * The name of the directory for cache files.
+ *
+ * @var string
+ */
+ var $cache_dir = 'cache';
+
+ /**
+ * This is the number of seconds cached content will persist.
+ * <ul>
+ * <li>0 = always regenerate cache</li>
+ * <li>-1 = never expires</li>
+ * </ul>
+ *
+ * @var integer
+ */
+ var $cache_lifetime = 3600;
+
+ /**
+ * Only used when $caching is enabled. If true, then If-Modified-Since headers
+ * are respected with cached content, and appropriate HTTP headers are sent.
+ * This way repeated hits to a cached page do not send the entire page to the
+ * client every time.
+ *
+ * @var boolean
+ */
+ var $cache_modified_check = false;
+
+ /**
+ * This determines how Smarty handles "<?php ... ?>" tags in templates.
+ * possible values:
+ * <ul>
+ * <li>SMARTY_PHP_PASSTHRU -> print tags as plain text</li>
+ * <li>SMARTY_PHP_QUOTE -> escape tags as entities</li>
+ * <li>SMARTY_PHP_REMOVE -> remove php tags</li>
+ * <li>SMARTY_PHP_ALLOW -> execute php tags</li>
+ * </ul>
+ *
+ * @var integer
+ */
+ var $php_handling = SMARTY_PHP_PASSTHRU;
+
+ /**
+ * This enables template security. When enabled, many things are restricted
+ * in the templates that normally would go unchecked. This is useful when
+ * untrusted parties are editing templates and you want a reasonable level
+ * of security. (no direct execution of PHP in templates for example)
+ *
+ * @var boolean
+ */
+ var $security = false;
+
+ /**
+ * This is the list of template directories that are considered secure. This
+ * is used only if {@link $security} is enabled. One directory per array
+ * element. {@link $template_dir} is in this list implicitly.
+ *
+ * @var array
+ */
+ var $secure_dir = array();
+
+ /**
+ * These are the security settings for Smarty. They are used only when
+ * {@link $security} is enabled.
+ *
+ * @var array
+ */
+ var $security_settings = array(
+ 'PHP_HANDLING' => false,
+ 'IF_FUNCS' => array('array', 'list',
+ 'isset', 'empty',
+ 'count', 'sizeof',
+ 'in_array', 'is_array',
+ 'true', 'false', 'null'),
+ 'INCLUDE_ANY' => false,
+ 'PHP_TAGS' => false,
+ 'MODIFIER_FUNCS' => array('count'),
+ 'ALLOW_CONSTANTS' => false
+ );
+
+ /**
+ * This is an array of directories where trusted php scripts reside.
+ * {@link $security} is disabled during their inclusion/execution.
+ *
+ * @var array
+ */
+ var $trusted_dir = array();
+
+ /**
+ * The left delimiter used for the template tags.
+ *
+ * @var string
+ */
+ var $left_delimiter = '{';
+
+ /**
+ * The right delimiter used for the template tags.
+ *
+ * @var string
+ */
+ var $right_delimiter = '}';
+
+ /**
+ * The order in which request variables are registered, similar to
+ * variables_order in php.ini E = Environment, G = GET, P = POST,
+ * C = Cookies, S = Server
+ *
+ * @var string
+ */
+ var $request_vars_order = 'EGPCS';
+
+ /**
+ * Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false)
+ * are uses as request-vars or $_*[]-vars. note: if
+ * request_use_auto_globals is true, then $request_vars_order has
+ * no effect, but the php-ini-value "gpc_order"
+ *
+ * @var boolean
+ */
+ var $request_use_auto_globals = true;
+
+ /**
+ * Set this if you want different sets of compiled files for the same
+ * templates. This is useful for things like different languages.
+ * Instead of creating separate sets of templates per language, you
+ * set different compile_ids like 'en' and 'de'.
+ *
+ * @var string
+ */
+ var $compile_id = null;
+
+ /**
+ * This tells Smarty whether or not to use sub dirs in the cache/ and
+ * templates_c/ directories. sub directories better organized, but
+ * may not work well with PHP safe mode enabled.
+ *
+ * @var boolean
+ *
+ */
+ var $use_sub_dirs = false;
+
+ /**
+ * This is a list of the modifiers to apply to all template variables.
+ * Put each modifier in a separate array element in the order you want
+ * them applied. example: <code>array('escape:"htmlall"');</code>
+ *
+ * @var array
+ */
+ var $default_modifiers = array();
+
+ /**
+ * This is the resource type to be used when not specified
+ * at the beginning of the resource path. examples:
+ * $smarty->display('file:index.tpl');
+ * $smarty->display('db:index.tpl');
+ * $smarty->display('index.tpl'); // will use default resource type
+ * {include file="file:index.tpl"}
+ * {include file="db:index.tpl"}
+ * {include file="index.tpl"} {* will use default resource type *}
+ *
+ * @var array
+ */
+ var $default_resource_type = 'file';
+
+ /**
+ * The function used for cache file handling. If not set, built-in caching is used.
+ *
+ * @var null|string function name
+ */
+ var $cache_handler_func = null;
+
+ /**
+ * This indicates which filters are automatically loaded into Smarty.
+ *
+ * @var array array of filter names
+ */
+ var $autoload_filters = array();
+
+ /**#@+
+ * @var boolean
+ */
+ /**
+ * This tells if config file vars of the same name overwrite each other or not.
+ * if disabled, same name variables are accumulated in an array.
+ */
+ var $config_overwrite = true;
+
+ /**
+ * This tells whether or not to automatically booleanize config file variables.
+ * If enabled, then the strings "on", "true", and "yes" are treated as boolean
+ * true, and "off", "false" and "no" are treated as boolean false.
+ */
+ var $config_booleanize = true;
+
+ /**
+ * This tells whether hidden sections [.foobar] are readable from the
+ * tempalates or not. Normally you would never allow this since that is
+ * the point behind hidden sections: the application can access them, but
+ * the templates cannot.
+ */
+ var $config_read_hidden = false;
+
+ /**
+ * This tells whether or not automatically fix newlines in config files.
+ * It basically converts \r (mac) or \r\n (dos) to \n
+ */
+ var $config_fix_newlines = true;
+ /**#@-*/
+
+ /**
+ * If a template cannot be found, this PHP function will be executed.
+ * Useful for creating templates on-the-fly or other special action.
+ *
+ * @var string function name
+ */
+ var $default_template_handler_func = '';
+
+ /**
+ * The file that contains the compiler class. This can a full
+ * pathname, or relative to the php_include path.
+ *
+ * @var string
+ */
+ var $compiler_file = 'Smarty_Compiler.class.php';
+
+ /**
+ * The class used for compiling templates.
+ *
+ * @var string
+ */
+ var $compiler_class = 'Smarty_Compiler';
+
+ /**
+ * The class used to load config vars.
+ *
+ * @var string
+ */
+ var $config_class = 'Config_File';
+
+/**#@+
+ * END Smarty Configuration Section
+ * There should be no need to touch anything below this line.
+ * @access private
+ */
+ /**
+ * where assigned template vars are kept
+ *
+ * @var array
+ */
+ var $_tpl_vars = array();
+
+ /**
+ * stores run-time $smarty.* vars
+ *
+ * @var null|array
+ */
+ var $_smarty_vars = null;
+
+ /**
+ * keeps track of sections
+ *
+ * @var array
+ */
+ var $_sections = array();
+
+ /**
+ * keeps track of foreach blocks
+ *
+ * @var array
+ */
+ var $_foreach = array();
+
+ /**
+ * keeps track of tag hierarchy
+ *
+ * @var array
+ */
+ var $_tag_stack = array();
+
+ /**
+ * configuration object
+ *
+ * @var Config_file
+ */
+ var $_conf_obj = null;
+
+ /**
+ * loaded configuration settings
+ *
+ * @var array
+ */
+ var $_config = array(array('vars' => array(), 'files' => array()));
+
+ /**
+ * md5 checksum of the string 'Smarty'
+ *
+ * @var string
+ */
+ var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f';
+
+ /**
+ * Smarty version number
+ *
+ * @var string
+ */
+ var $_version = '2.6.9';
+
+ /**
+ * current template inclusion depth
+ *
+ * @var integer
+ */
+ var $_inclusion_depth = 0;
+
+ /**
+ * for different compiled templates
+ *
+ * @var string
+ */
+ var $_compile_id = null;
+
+ /**
+ * text in URL to enable debug mode
+ *
+ * @var string
+ */
+ var $_smarty_debug_id = 'SMARTY_DEBUG';
+
+ /**
+ * debugging information for debug console
+ *
+ * @var array
+ */
+ var $_smarty_debug_info = array();
+
+ /**
+ * info that makes up a cache file
+ *
+ * @var array
+ */
+ var $_cache_info = array();
+
+ /**
+ * default file permissions
+ *
+ * @var integer
+ */
+ var $_file_perms = 0644;
+
+ /**
+ * default dir permissions
+ *
+ * @var integer
+ */
+ var $_dir_perms = 0771;
+
+ /**
+ * registered objects
+ *
+ * @var array
+ */
+ var $_reg_objects = array();
+
+ /**
+ * table keeping track of plugins
+ *
+ * @var array
+ */
+ var $_plugins = array(
+ 'modifier' => array(),
+ 'function' => array(),
+ 'block' => array(),
+ 'compiler' => array(),
+ 'prefilter' => array(),
+ 'postfilter' => array(),
+ 'outputfilter' => array(),
+ 'resource' => array(),
+ 'insert' => array());
+
+
+ /**
+ * cache serials
+ *
+ * @var array
+ */
+ var $_cache_serials = array();
+
+ /**
+ * name of optional cache include file
+ *
+ * @var string
+ */
+ var $_cache_include = null;
+
+ /**
+ * indicate if the current code is used in a compiled
+ * include
+ *
+ * @var string
+ */
+ var $_cache_including = false;
+
+ /**#@-*/
+ /**
+ * The class constructor.
+ */
+ function Smarty()
+ {
+ $this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
+ : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
+ }
+
+ /**
+ * assigns values to template variables
+ *
+ * @param array|string $tpl_var the template variable name(s)
+ * @param mixed $value the value to assign
+ */
+ function assign($tpl_var, $value = null)
+ {
+ if (is_array($tpl_var)){
+ foreach ($tpl_var as $key => $val) {
+ if ($key != '') {
+ $this->_tpl_vars[$key] = $val;
+ }
+ }
+ } else {
+ if ($tpl_var != '')
+ $this->_tpl_vars[$tpl_var] = $value;
+ }
+ }
+
+ /**
+ * assigns values to template variables by reference
+ *
+ * @param string $tpl_var the template variable name
+ * @param mixed $value the referenced value to assign
+ */
+ function assign_by_ref($tpl_var, &$value)
+ {
+ if ($tpl_var != '')
+ $this->_tpl_vars[$tpl_var] = &$value;
+ }
+
+ /**
+ * appends values to template variables
+ *
+ * @param array|string $tpl_var the template variable name(s)
+ * @param mixed $value the value to append
+ */
+ function append($tpl_var, $value=null, $merge=false)
+ {
+ if (is_array($tpl_var)) {
+ // $tpl_var is an array, ignore $value
+ foreach ($tpl_var as $_key => $_val) {
+ if ($_key != '') {
+ if(!@is_array($this->_tpl_vars[$_key])) {
+ settype($this->_tpl_vars[$_key],'array');
+ }
+ if($merge && is_array($_val)) {
+ foreach($_val as $_mkey => $_mval) {
+ $this->_tpl_vars[$_key][$_mkey] = $_mval;
+ }
+ } else {
+ $this->_tpl_vars[$_key][] = $_val;
+ }
+ }
+ }
+ } else {
+ if ($tpl_var != '' && isset($value)) {
+ if(!@is_array($this->_tpl_vars[$tpl_var])) {
+ settype($this->_tpl_vars[$tpl_var],'array');
+ }
+ if($merge && is_array($value)) {
+ foreach($value as $_mkey => $_mval) {
+ $this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
+ }
+ } else {
+ $this->_tpl_vars[$tpl_var][] = $value;
+ }
+ }
+ }
+ }
+
+ /**
+ * appends values to template variables by reference
+ *
+ * @param string $tpl_var the template variable name
+ * @param mixed $value the referenced value to append
+ */
+ function append_by_ref($tpl_var, &$value, $merge=false)
+ {
+ if ($tpl_var != '' && isset($value)) {
+ if(!@is_array($this->_tpl_vars[$tpl_var])) {
+ settype($this->_tpl_vars[$tpl_var],'array');
+ }
+ if ($merge && is_array($value)) {
+ foreach($value as $_key => $_val) {
+ $this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
+ }
+ } else {
+ $this->_tpl_vars[$tpl_var][] = &$value;
+ }
+ }
+ }
+
+
+ /**
+ * clear the given assigned template variable.
+ *
+ * @param string $tpl_var the template variable to clear
+ */
+ function clear_assign($tpl_var)
+ {
+ if (is_array($tpl_var))
+ foreach ($tpl_var as $curr_var)
+ unset($this->_tpl_vars[$curr_var]);
+ else
+ unset($this->_tpl_vars[$tpl_var]);
+ }
+
+
+ /**
+ * Registers custom function to be used in templates
+ *
+ * @param string $function the name of the template function
+ * @param string $function_impl the name of the PHP function to register
+ */
+ function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
+ {
+ $this->_plugins['function'][$function] =
+ array($function_impl, null, null, false, $cacheable, $cache_attrs);
+
+ }
+
+ /**
+ * Unregisters custom function
+ *
+ * @param string $function name of template function
+ */
+ function unregister_function($function)
+ {
+ unset($this->_plugins['function'][$function]);
+ }
+
+ /**
+ * Registers object to be used in templates
+ *
+ * @param string $object name of template object
+ * @param object &$object_impl the referenced PHP object to register
+ * @param null|array $allowed list of allowed methods (empty = all)
+ * @param boolean $smarty_args smarty argument format, else traditional
+ * @param null|array $block_functs list of methods that are block format
+ */
+ function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
+ {
+ settype($allowed, 'array');
+ settype($smarty_args, 'boolean');
+ $this->_reg_objects[$object] =
+ array(&$object_impl, $allowed, $smarty_args, $block_methods);
+ }
+
+ /**
+ * Unregisters object
+ *
+ * @param string $object name of template object
+ */
+ function unregister_object($object)
+ {
+ unset($this->_reg_objects[$object]);
+ }
+
+
+ /**
+ * Registers block function to be used in templates
+ *
+ * @param string $block name of template block
+ * @param string $block_impl PHP function to register
+ */
+ function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
+ {
+ $this->_plugins['block'][$block] =
+ array($block_impl, null, null, false, $cacheable, $cache_attrs);
+ }
+
+ /**
+ * Unregisters block function
+ *
+ * @param string $block name of template function
+ */
+ function unregister_block($block)
+ {
+ unset($this->_plugins['block'][$block]);
+ }
+
+ /**
+ * Registers compiler function
+ *
+ * @param string $function name of template function
+ * @param string $function_impl name of PHP function to register
+ */
+ function register_compiler_function($function, $function_impl, $cacheable=true)
+ {
+ $this->_plugins['compiler'][$function] =
+ array($function_impl, null, null, false, $cacheable);
+ }
+
+ /**
+ * Unregisters compiler function
+ *
+ * @param string $function name of template function
+ */
+ function unregister_compiler_function($function)
+ {
+ unset($this->_plugins['compiler'][$function]);
+ }
+
+ /**
+ * Registers modifier to be used in templates
+ *
+ * @param string $modifier name of template modifier
+ * @param string $modifier_impl name of PHP function to register
+ */
+ function register_modifier($modifier, $modifier_impl)
+ {
+ $this->_plugins['modifier'][$modifier] =
+ array($modifier_impl, null, null, false);
+ }
+
+ /**
+ * Unregisters modifier
+ *
+ * @param string $modifier name of template modifier
+ */
+ function unregister_modifier($modifier)
+ {
+ unset($this->_plugins['modifier'][$modifier]);
+ }
+
+ /**
+ * Registers a resource to fetch a template
+ *
+ * @param string $type name of resource
+ * @param array $functions array of functions to handle resource
+ */
+ function register_resource($type, $functions)
+ {
+ if (count($functions)==4) {
+ $this->_plugins['resource'][$type] =
+ array($functions, false);
+
+ } elseif (count($functions)==5) {
+ $this->_plugins['resource'][$type] =
+ array(array(array(&$functions[0], $functions[1])
+ ,array(&$functions[0], $functions[2])
+ ,array(&$functions[0], $functions[3])
+ ,array(&$functions[0], $functions[4]))
+ ,false);
+
+ } else {
+ $this->trigger_error("malformed function-list for '$type' in register_resource");
+
+ }
+ }
+
+ /**
+ * Unregisters a resource
+ *
+ * @param string $type name of resource
+ */
+ function unregister_resource($type)
+ {
+ unset($this->_plugins['resource'][$type]);
+ }
+
+ /**
+ * Registers a prefilter function to apply
+ * to a template before compiling
+ *
+ * @param string $function name of PHP function to register
+ */
+ function register_prefilter($function)
+ {
+ $_name = (is_array($function)) ? $function[1] : $function;
+ $this->_plugins['prefilter'][$_name]
+ = array($function, null, null, false);
+ }
+
+ /**
+ * Unregisters a prefilter function
+ *
+ * @param string $function name of PHP function
+ */
+ function unregister_prefilter($function)
+ {
+ unset($this->_plugins['prefilter'][$function]);
+ }
+
+ /**
+ * Registers a postfilter function to apply
+ * to a compiled template after compilation
+ *
+ * @param string $function name of PHP function to register
+ */
+ function register_postfilter($function)
+ {
+ $_name = (is_array($function)) ? $function[1] : $function;
+ $this->_plugins['postfilter'][$_name]
+ = array($function, null, null, false);
+ }
+
+ /**
+ * Unregisters a postfilter function
+ *
+ * @param string $function name of PHP function
+ */
+ function unregister_postfilter($function)
+ {
+ unset($this->_plugins['postfilter'][$function]);
+ }
+
+ /**
+ * Registers an output filter function to apply
+ * to a template output
+ *
+ * @param string $function name of PHP function
+ */
+ function register_outputfilter($function)
+ {
+ $_name = (is_array($function)) ? $function[1] : $function;
+ $this->_plugins['outputfilter'][$_name]
+ = array($function, null, null, false);
+ }
+
+ /**
+ * Unregisters an outputfilter function
+ *
+ * @param string $function name of PHP function
+ */
+ function unregister_outputfilter($function)
+ {
+ unset($this->_plugins['outputfilter'][$function]);
+ }
+
+ /**
+ * load a filter of specified type and name
+ *
+ * @param string $type filter type
+ * @param string $name filter name
+ */
+ function load_filter($type, $name)
+ {
+ switch ($type) {
+ case 'output':
+ $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false)));
+ require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+ smarty_core_load_plugins($_params, $this);
+ break;
+
+ case 'pre':
+ case 'post':
+ if (!isset($this->_plugins[$type . 'filter'][$name]))
+ $this->_plugins[$type . 'filter'][$name] = false;
+ break;
+ }
+ }
+
+ /**
+ * clear cached content for the given template and cache id
+ *
+ * @param string $tpl_file name of template file
+ * @param string $cache_id name of cache_id
+ * @param string $compile_id name of compile_id
+ * @param string $exp_time expiration time
+ * @return boolean
+ */
+ function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
+ {
+
+ if (!isset($compile_id))
+ $compile_id = $this->compile_id;
+
+ if (!isset($tpl_file))
+ $compile_id = null;
+
+ $_auto_id = $this->_get_auto_id($cache_id, $compile_id);
+
+ if (!empty($this->cache_handler_func)) {
+ return call_user_func_array($this->cache_handler_func,
+ array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id, $exp_time));
+ } else {
+ $_params = array('auto_base' => $this->cache_dir,
+ 'auto_source' => $tpl_file,
+ 'auto_id' => $_auto_id,
+ 'exp_time' => $exp_time);
+ require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
+ return smarty_core_rm_auto($_params, $this);
+ }
+
+ }
+
+
+ /**
+ * clear the entire contents of cache (all templates)
+ *
+ * @param string $exp_time expire time
+ * @return boolean results of {@link smarty_core_rm_auto()}
+ */
+ function clear_all_cache($exp_time = null)
+ {
+ return $this->clear_cache(null, null, null, $exp_time);
+ }
+
+
+ /**
+ * test to see if valid cache exists for this template
+ *
+ * @param string $tpl_file name of template file
+ * @param string $cache_id
+ * @param string $compile_id
+ * @return string|false results of {@link _read_cache_file()}
+ */
+ function is_cached($tpl_file, $cache_id = null, $compile_id = null)
+ {
+ if (!$this->caching)
+ return false;
+
+ if (!isset($compile_id))
+ $compile_id = $this->compile_id;
+
+ $_params = array(
+ 'tpl_file' => $tpl_file,
+ 'cache_id' => $cache_id,
+ 'compile_id' => $compile_id
+ );
+ require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
+ return smarty_core_read_cache_file($_params, $this);
+ }
+
+
+ /**
+ * clear all the assigned template variables.
+ *
+ */
+ function clear_all_assign()
+ {
+ $this->_tpl_vars = array();
+ }
+
+ /**
+ * clears compiled version of specified template resource,
+ * or all compiled template files if one is not specified.
+ * This function is for advanced use only, not normally needed.
+ *
+ * @param string $tpl_file
+ * @param string $compile_id
+ * @param string $exp_time
+ * @return boolean results of {@link smarty_core_rm_auto()}
+ */
+ function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
+ {
+ if (!isset($compile_id)) {
+ $compile_id = $this->compile_id;
+ }
+ $_params = array('auto_base' => $this->compile_dir,
+ 'auto_source' => $tpl_file,
+ 'auto_id' => $compile_id,
+ 'exp_time' => $exp_time,
+ 'extensions' => array('.inc', '.php'));
+ require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
+ return smarty_core_rm_auto($_params, $this);
+ }
+
+ /**
+ * Checks whether requested template exists.
+ *
+ * @param string $tpl_file
+ * @return boolean
+ */
+ function template_exists($tpl_file)
+ {
+ $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false);
+ return $this->_fetch_resource_info($_params);
+ }
+
+ /**
+ * Returns an array containing template variables
+ *
+ * @param string $name
+ * @param string $type
+ * @return array
+ */
+ function &get_template_vars($name=null)
+ {
+ if(!isset($name)) {
+ return $this->_tpl_vars;
+ }
+ if(isset($this->_tpl_vars[$name])) {
+ return $this->_tpl_vars[$name];
+ }
+ }
+
+ /**
+ * Returns an array containing config variables
+ *
+ * @param string $name
+ * @param string $type
+ * @return array
+ */
+ function &get_config_vars($name=null)
+ {
+ if(!isset($name) && is_array($this->_config[0])) {
+ return $this->_config[0]['vars'];
+ } else if(isset($this->_config[0]['vars'][$name])) {
+ return $this->_config[0]['vars'][$name];
+ }
+ }
+
+ /**
+ * trigger Smarty error
+ *
+ * @param string $error_msg
+ * @param integer $error_type
+ */
+ function trigger_error($error_msg, $error_type = E_USER_WARNING)
+ {
+ trigger_error("Smarty error: $error_msg", $error_type);
+ }
+
+
+ /**
+ * executes & displays the template results
+ *
+ * @param string $resource_name
+ * @param string $cache_id
+ * @param string $compile_id
+ */
+ function display($resource_name, $cache_id = null, $compile_id = null)
+ {
+ $this->fetch($resource_name, $cache_id, $compile_id, true);
+ }
+
+ /**
+ * executes & returns or displays the template results
+ *
+ * @param string $resource_name
+ * @param string $cache_id
+ * @param string $compile_id
+ * @param boolean $display
+ */
+ function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)
+ {
+ static $_cache_info = array();
+
+ $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting)
+ ? $this->error_reporting : error_reporting() & ~E_NOTICE);
+
+ if (!$this->debugging && $this->debugging_ctrl == 'URL') {
+ $_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
+ if (@strstr($_query_string, $this->_smarty_debug_id)) {
+ if (@strstr($_query_string, $this->_smarty_debug_id . '=on')) {
+ // enable debugging for this browser session
+ @setcookie('SMARTY_DEBUG', true);
+ $this->debugging = true;
+ } elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off')) {
+ // disable debugging for this browser session
+ @setcookie('SMARTY_DEBUG', false);
+ $this->debugging = false;
+ } else {
+ // enable debugging for this page
+ $this->debugging = true;
+ }
+ } else {
+ $this->debugging = (bool)($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);
+ }
+ }
+
+ if ($this->debugging) {
+ // capture time for debugging info
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $_debug_start_time = smarty_core_get_microtime($_params, $this);
+ $this->_smarty_debug_info[] = array('type' => 'template',
+ 'filename' => $resource_name,
+ 'depth' => 0);
+ $_included_tpls_idx = count($this->_smarty_debug_info) - 1;
+ }
+
+ if (!isset($compile_id)) {
+ $compile_id = $this->compile_id;
+ }
+
+ $this->_compile_id = $compile_id;
+ $this->_inclusion_depth = 0;
+
+ if ($this->caching) {
+ // save old cache_info, initialize cache_info
+ array_push($_cache_info, $this->_cache_info);
+ $this->_cache_info = array();
+ $_params = array(
+ 'tpl_file' => $resource_name,
+ 'cache_id' => $cache_id,
+ 'compile_id' => $compile_id,
+ 'results' => null
+ );
+ require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
+ if (smarty_core_read_cache_file($_params, $this)) {
+ $_smarty_results = $_params['results'];
+ if (!empty($this->_cache_info['insert_tags'])) {
+ $_params = array('plugins' => $this->_cache_info['insert_tags']);
+ require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+ smarty_core_load_plugins($_params, $this);
+ $_params = array('results' => $_smarty_results);
+ require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
+ $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
+ }
+ if (!empty($this->_cache_info['cache_serials'])) {
+ $_params = array('results' => $_smarty_results);
+ require_once(SMARTY_CORE_DIR . 'core.process_compiled_include.php');
+ $_smarty_results = smarty_core_process_compiled_include($_params, $this);
+ }
+
+
+ if ($display) {
+ if ($this->debugging)
+ {
+ // capture time for debugging info
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
+ require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
+ $_smarty_results .= smarty_core_display_debug_console($_params, $this);
+ }
+ if ($this->cache_modified_check) {
+ $_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
+ $_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
+ $_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT';
+ if (@count($this->_cache_info['insert_tags']) == 0
+ && !$this->_cache_serials
+ && $_gmt_mtime == $_last_modified_date) {
+ if (php_sapi_name()=='cgi')
+ header('Status: 304 Not Modified');
+ else
+ header('HTTP/1.1 304 Not Modified');
+
+ } else {
+ header('Last-Modified: '.$_gmt_mtime);
+ echo $_smarty_results;
+ }
+ } else {
+ echo $_smarty_results;
+ }
+ error_reporting($_smarty_old_error_level);
+ // restore initial cache_info
+ $this->_cache_info = array_pop($_cache_info);
+ return true;
+ } else {
+ error_reporting($_smarty_old_error_level);
+ // restore initial cache_info
+ $this->_cache_info = array_pop($_cache_info);
+ return $_smarty_results;
+ }
+ } else {
+ $this->_cache_info['template'][$resource_name] = true;
+ if ($this->cache_modified_check && $display) {
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
+ }
+ }
+ }
+
+ // load filters that are marked as autoload
+ if (count($this->autoload_filters)) {
+ foreach ($this->autoload_filters as $_filter_type => $_filters) {
+ foreach ($_filters as $_filter) {
+ $this->load_filter($_filter_type, $_filter);
+ }
+ }
+ }
+
+ $_smarty_compile_path = $this->_get_compile_path($resource_name);
+
+ // if we just need to display the results, don't perform output
+ // buffering - for speed
+ $_cache_including = $this->_cache_including;
+ $this->_cache_including = false;
+ if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) {
+ if ($this->_is_compiled($resource_name, $_smarty_compile_path)
+ || $this->_compile_resource($resource_name, $_smarty_compile_path))
+ {
+ include($_smarty_compile_path);
+ }
+ } else {
+ ob_start();
+ if ($this->_is_compiled($resource_name, $_smarty_compile_path)
+ || $this->_compile_resource($resource_name, $_smarty_compile_path))
+ {
+ include($_smarty_compile_path);
+ }
+ $_smarty_results = ob_get_contents();
+ ob_end_clean();
+
+ foreach ((array)$this->_plugins['outputfilter'] as $_output_filter) {
+ $_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this));
+ }
+ }
+
+ if ($this->caching) {
+ $_params = array('tpl_file' => $resource_name,
+ 'cache_id' => $cache_id,
+ 'compile_id' => $compile_id,
+ 'results' => $_smarty_results);
+ require_once(SMARTY_CORE_DIR . 'core.write_cache_file.php');
+ smarty_core_write_cache_file($_params, $this);
+ require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
+ $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
+
+ if ($this->_cache_serials) {
+ // strip nocache-tags from output
+ $_smarty_results = preg_replace('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!s'
+ ,''
+ ,$_smarty_results);
+ }
+ // restore initial cache_info
+ $this->_cache_info = array_pop($_cache_info);
+ }
+ $this->_cache_including = $_cache_including;
+
+ if ($display) {
+ if (isset($_smarty_results)) { echo $_smarty_results; }
+ if ($this->debugging) {
+ // capture time for debugging info
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time);
+ require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
+ echo smarty_core_display_debug_console($_params, $this);
+ }
+ error_reporting($_smarty_old_error_level);
+ return;
+ } else {
+ error_reporting($_smarty_old_error_level);
+ if (isset($_smarty_results)) { return $_smarty_results; }
+ }
+ }
+
+ /**
+ * load configuration values
+ *
+ * @param string $file
+ * @param string $section
+ * @param string $scope
+ */
+ function config_load($file, $section = null, $scope = 'global')
+ {
+ require_once($this->_get_plugin_filepath('function', 'config_load'));
+ smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this);
+ }
+
+ /**
+ * return a reference to a registered object
+ *
+ * @param string $name
+ * @return object
+ */
+ function &get_registered_object($name) {
+ if (!isset($this->_reg_objects[$name]))
+ $this->_trigger_fatal_error("'$name' is not a registered object");
+
+ if (!is_object($this->_reg_objects[$name][0]))
+ $this->_trigger_fatal_error("registered '$name' is not an object");
+
+ return $this->_reg_objects[$name][0];
+ }
+
+ /**
+ * clear configuration values
+ *
+ * @param string $var
+ */
+ function clear_config($var = null)
+ {
+ if(!isset($var)) {
+ // clear all values
+ $this->_config = array(array('vars' => array(),
+ 'files' => array()));
+ } else {
+ unset($this->_config[0]['vars'][$var]);
+ }
+ }
+
+ /**
+ * get filepath of requested plugin
+ *
+ * @param string $type
+ * @param string $name
+ * @return string|false
+ */
+ function _get_plugin_filepath($type, $name)
+ {
+ $_params = array('type' => $type, 'name' => $name);
+ require_once(SMARTY_CORE_DIR . 'core.assemble_plugin_filepath.php');
+ return smarty_core_assemble_plugin_filepath($_params, $this);
+ }
+
+ /**
+ * test if resource needs compiling
+ *
+ * @param string $resource_name
+ * @param string $compile_path
+ * @return boolean
+ */
+ function _is_compiled($resource_name, $compile_path)
+ {
+ if (!$this->force_compile && file_exists($compile_path)) {
+ if (!$this->compile_check) {
+ // no need to check compiled file
+ return true;
+ } else {
+ // get file source and timestamp
+ $_params = array('resource_name' => $resource_name, 'get_source'=>false);
+ if (!$this->_fetch_resource_info($_params)) {
+ return false;
+ }
+ if ($_params['resource_timestamp'] <= filemtime($compile_path)) {
+ // template not expired, no recompile
+ return true;
+ } else {
+ // compile template
+ return false;
+ }
+ }
+ } else {
+ // compiled template does not exist, or forced compile
+ return false;
+ }
+ }
+
+ /**
+ * compile the template
+ *
+ * @param string $resource_name
+ * @param string $compile_path
+ * @return boolean
+ */
+ function _compile_resource($resource_name, $compile_path)
+ {
+
+ $_params = array('resource_name' => $resource_name);
+ if (!$this->_fetch_resource_info($_params)) {
+ return false;
+ }
+
+ $_source_content = $_params['source_content'];
+ $_cache_include = substr($compile_path, 0, -4).'.inc';
+
+ if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) {
+ // if a _cache_serial was set, we also have to write an include-file:
+ if ($this->_cache_include_info) {
+ require_once(SMARTY_CORE_DIR . 'core.write_compiled_include.php');
+ smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content, 'resource_name'=>$resource_name)), $this);
+ }
+
+ $_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content);
+ require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
+ smarty_core_write_compiled_resource($_params, $this);
+
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ /**
+ * compile the given source
+ *
+ * @param string $resource_name
+ * @param string $source_content
+ * @param string $compiled_content
+ * @return boolean
+ */
+ function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path=null)
+ {
+ if (file_exists(SMARTY_DIR . $this->compiler_file)) {
+ require_once(SMARTY_DIR . $this->compiler_file);
+ } else {
+ // use include_path
+ require_once($this->compiler_file);
+ }
+
+
+ $smarty_compiler = new $this->compiler_class;
+
+ $smarty_compiler->template_dir = $this->template_dir;
+ $smarty_compiler->compile_dir = $this->compile_dir;
+ $smarty_compiler->plugins_dir = $this->plugins_dir;
+ $smarty_compiler->config_dir = $this->config_dir;
+ $smarty_compiler->force_compile = $this->force_compile;
+ $smarty_compiler->caching = $this->caching;
+ $smarty_compiler->php_handling = $this->php_handling;
+ $smarty_compiler->left_delimiter = $this->left_delimiter;
+ $smarty_compiler->right_delimiter = $this->right_delimiter;
+ $smarty_compiler->_version = $this->_version;
+ $smarty_compiler->security = $this->security;
+ $smarty_compiler->secure_dir = $this->secure_dir;
+ $smarty_compiler->security_settings = $this->security_settings;
+ $smarty_compiler->trusted_dir = $this->trusted_dir;
+ $smarty_compiler->use_sub_dirs = $this->use_sub_dirs;
+ $smarty_compiler->_reg_objects = &$this->_reg_objects;
+ $smarty_compiler->_plugins = &$this->_plugins;
+ $smarty_compiler->_tpl_vars = &$this->_tpl_vars;
+ $smarty_compiler->default_modifiers = $this->default_modifiers;
+ $smarty_compiler->compile_id = $this->_compile_id;
+ $smarty_compiler->_config = $this->_config;
+ $smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals;
+
+ if (isset($cache_include_path) && isset($this->_cache_serials[$cache_include_path])) {
+ $smarty_compiler->_cache_serial = $this->_cache_serials[$cache_include_path];
+ }
+ $smarty_compiler->_cache_include = $cache_include_path;
+
+
+ $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
+
+ if ($smarty_compiler->_cache_serial) {
+ $this->_cache_include_info = array(
+ 'cache_serial'=>$smarty_compiler->_cache_serial
+ ,'plugins_code'=>$smarty_compiler->_plugins_code
+ ,'include_file_path' => $cache_include_path);
+
+ } else {
+ $this->_cache_include_info = null;
+
+ }
+
+ return $_results;
+ }
+
+ /**
+ * Get the compile path for this resource
+ *
+ * @param string $resource_name
+ * @return string results of {@link _get_auto_filename()}
+ */
+ function _get_compile_path($resource_name)
+ {
+ return $this->_get_auto_filename($this->compile_dir, $resource_name,
+ $this->_compile_id) . '.php';
+ }
+
+ /**
+ * fetch the template info. Gets timestamp, and source
+ * if get_source is true
+ *
+ * sets $source_content to the source of the template, and
+ * $resource_timestamp to its time stamp
+ * @param string $resource_name
+ * @param string $source_content
+ * @param integer $resource_timestamp
+ * @param boolean $get_source
+ * @param boolean $quiet
+ * @return boolean
+ */
+
+ function _fetch_resource_info(&$params)
+ {
+ if(!isset($params['get_source'])) { $params['get_source'] = true; }
+ if(!isset($params['quiet'])) { $params['quiet'] = false; }
+
+ $_return = false;
+ $_params = array('resource_name' => $params['resource_name']) ;
+ if (isset($params['resource_base_path']))
+ $_params['resource_base_path'] = $params['resource_base_path'];
+ else
+ $_params['resource_base_path'] = $this->template_dir;
+
+ if ($this->_parse_resource_name($_params)) {
+ $_resource_type = $_params['resource_type'];
+ $_resource_name = $_params['resource_name'];
+ switch ($_resource_type) {
+ case 'file':
+ if ($params['get_source']) {
+ $params['source_content'] = $this->_read_file($_resource_name);
+ }
+ $params['resource_timestamp'] = filemtime($_resource_name);
+ $_return = is_file($_resource_name);
+ break;
+
+ default:
+ // call resource functions to fetch the template source and timestamp
+ if ($params['get_source']) {
+ $_source_return = isset($this->_plugins['resource'][$_resource_type]) &&
+ call_user_func_array($this->_plugins['resource'][$_resource_type][0][0],
+ array($_resource_name, &$params['source_content'], &$this));
+ } else {
+ $_source_return = true;
+ }
+
+ $_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) &&
+ call_user_func_array($this->_plugins['resource'][$_resource_type][0][1],
+ array($_resource_name, &$params['resource_timestamp'], &$this));
+
+ $_return = $_source_return && $_timestamp_return;
+ break;
+ }
+ }
+
+ if (!$_return) {
+ // see if we can get a template with the default template handler
+ if (!empty($this->default_template_handler_func)) {
+ if (!is_callable($this->default_template_handler_func)) {
+ $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist.");
+ } else {
+ $_return = call_user_func_array(
+ $this->default_template_handler_func,
+ array($_params['resource_type'], $_params['resource_name'], &$params['source_content'], &$params['resource_timestamp'], &$this));
+ }
+ }
+ }
+
+ if (!$_return) {
+ if (!$params['quiet']) {
+ $this->trigger_error('unable to read resource: "' . $params['resource_name'] . '"');
+ }
+ } else if ($_return && $this->security) {
+ require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
+ if (!smarty_core_is_secure($_params, $this)) {
+ if (!$params['quiet'])
+ $this->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed');
+ $params['source_content'] = null;
+ $params['resource_timestamp'] = null;
+ return false;
+ }
+ }
+ return $_return;
+ }
+
+
+ /**
+ * parse out the type and name from the resource
+ *
+ * @param string $resource_base_path
+ * @param string $resource_name
+ * @param string $resource_type
+ * @param string $resource_name
+ * @return boolean
+ */
+
+ function _parse_resource_name(&$params)
+ {
+
+ // split tpl_path by the first colon
+ $_resource_name_parts = explode(':', $params['resource_name'], 2);
+
+ if (count($_resource_name_parts) == 1) {
+ // no resource type given
+ $params['resource_type'] = $this->default_resource_type;
+ $params['resource_name'] = $_resource_name_parts[0];
+ } else {
+ if(strlen($_resource_name_parts[0]) == 1) {
+ // 1 char is not resource type, but part of filepath
+ $params['resource_type'] = $this->default_resource_type;
+ $params['resource_name'] = $params['resource_name'];
+ } else {
+ $params['resource_type'] = $_resource_name_parts[0];
+ $params['resource_name'] = $_resource_name_parts[1];
+ }
+ }
+
+ if ($params['resource_type'] == 'file') {
+ if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $params['resource_name'])) {
+ // relative pathname to $params['resource_base_path']
+ // use the first directory where the file is found
+ foreach ((array)$params['resource_base_path'] as $_curr_path) {
+ $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
+ if (file_exists($_fullpath) && is_file($_fullpath)) {
+ $params['resource_name'] = $_fullpath;
+ return true;
+ }
+ // didn't find the file, try include_path
+ $_params = array('file_path' => $_fullpath);
+ require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
+ if(smarty_core_get_include_path($_params, $this)) {
+ $params['resource_name'] = $_params['new_file_path'];
+ return true;
+ }
+ }
+ return false;
+ } else {
+ /* absolute path */
+ return file_exists($params['resource_name']);
+ }
+ } elseif (empty($this->_plugins['resource'][$params['resource_type']])) {
+ $_params = array('type' => $params['resource_type']);
+ require_once(SMARTY_CORE_DIR . 'core.load_resource_plugin.php');
+ smarty_core_load_resource_plugin($_params, $this);
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Handle modifiers
+ *
+ * @param string|null $modifier_name
+ * @param array|null $map_array
+ * @return string result of modifiers
+ */
+ function _run_mod_handler()
+ {
+ $_args = func_get_args();
+ list($_modifier_name, $_map_array) = array_splice($_args, 0, 2);
+ list($_func_name, $_tpl_file, $_tpl_line) =
+ $this->_plugins['modifier'][$_modifier_name];
+
+ $_var = $_args[0];
+ foreach ($_var as $_key => $_val) {
+ $_args[0] = $_val;
+ $_var[$_key] = call_user_func_array($_func_name, $_args);
+ }
+ return $_var;
+ }
+
+ /**
+ * Remove starting and ending quotes from the string
+ *
+ * @param string $string
+ * @return string
+ */
+ function _dequote($string)
+ {
+ if (($string{0} == "'" || $string{0} == '"') &&
+ $string{strlen($string)-1} == $string{0})
+ return substr($string, 1, -1);
+ else
+ return $string;
+ }
+
+
+ /**
+ * read in a file
+ *
+ * @param string $filename
+ * @return string
+ */
+ function _read_file($filename)
+ {
+ if ( file_exists($filename) && ($fd = @fopen($filename, 'rb')) ) {
+ $contents = ($size = filesize($filename)) ? fread($fd, $size) : '';
+ fclose($fd);
+ return $contents;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * get a concrete filename for automagically created content
+ *
+ * @param string $auto_base
+ * @param string $auto_source
+ * @param string $auto_id
+ * @return string
+ * @staticvar string|null
+ * @staticvar string|null
+ */
+ function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
+ {
+ $_compile_dir_sep = $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
+ $_return = $auto_base . DIRECTORY_SEPARATOR;
+
+ if(isset($auto_id)) {
+ // make auto_id safe for directory names
+ $auto_id = str_replace('%7C',$_compile_dir_sep,(urlencode($auto_id)));
+ // split into separate directories
+ $_return .= $auto_id . $_compile_dir_sep;
+ }
+
+ if(isset($auto_source)) {
+ // make source name safe for filename
+ $_filename = urlencode(basename($auto_source));
+ $_crc32 = sprintf('%08X', crc32($auto_source));
+ // prepend %% to avoid name conflicts with
+ // with $params['auto_id'] names
+ $_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep .
+ substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32;
+ $_return .= '%%' . $_crc32 . '%%' . $_filename;
+ }
+
+ return $_return;
+ }
+
+ /**
+ * unlink a file, possibly using expiration time
+ *
+ * @param string $resource
+ * @param integer $exp_time
+ */
+ function _unlink($resource, $exp_time = null)
+ {
+ if(isset($exp_time)) {
+ if(time() - @filemtime($resource) >= $exp_time) {
+ return @unlink($resource);
+ }
+ } else {
+ return @unlink($resource);
+ }
+ }
+
+ /**
+ * returns an auto_id for auto-file-functions
+ *
+ * @param string $cache_id
+ * @param string $compile_id
+ * @return string|null
+ */
+ function _get_auto_id($cache_id=null, $compile_id=null) {
+ if (isset($cache_id))
+ return (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id;
+ elseif(isset($compile_id))
+ return $compile_id;
+ else
+ return null;
+ }
+
+ /**
+ * trigger Smarty plugin error
+ *
+ * @param string $error_msg
+ * @param string $tpl_file
+ * @param integer $tpl_line
+ * @param string $file
+ * @param integer $line
+ * @param integer $error_type
+ */
+ function _trigger_fatal_error($error_msg, $tpl_file = null, $tpl_line = null,
+ $file = null, $line = null, $error_type = E_USER_ERROR)
+ {
+ if(isset($file) && isset($line)) {
+ $info = ' ('.basename($file).", line $line)";
+ } else {
+ $info = '';
+ }
+ if (isset($tpl_line) && isset($tpl_file)) {
+ $this->trigger_error('[in ' . $tpl_file . ' line ' . $tpl_line . "]: $error_msg$info", $error_type);
+ } else {
+ $this->trigger_error($error_msg . $info, $error_type);
+ }
+ }
+
+
+ /**
+ * callback function for preg_replace, to call a non-cacheable block
+ * @return string
+ */
+ function _process_compiled_include_callback($match) {
+ $_func = '_smarty_tplfunc_'.$match[2].'_'.$match[3];
+ ob_start();
+ $_func($this);
+ $_ret = ob_get_contents();
+ ob_end_clean();
+ return $_ret;
+ }
+
+
+ /**
+ * called for included templates
+ *
+ * @param string $_smarty_include_tpl_file
+ * @param string $_smarty_include_vars
+ */
+
+ // $_smarty_include_tpl_file, $_smarty_include_vars
+
+ function _smarty_include($params)
+ {
+ if ($this->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $debug_start_time = smarty_core_get_microtime($_params, $this);
+ $this->_smarty_debug_info[] = array('type' => 'template',
+ 'filename' => $params['smarty_include_tpl_file'],
+ 'depth' => ++$this->_inclusion_depth);
+ $included_tpls_idx = count($this->_smarty_debug_info) - 1;
+ }
+
+ $this->_tpl_vars = array_merge($this->_tpl_vars, $params['smarty_include_vars']);
+
+ // config vars are treated as local, so push a copy of the
+ // current ones onto the front of the stack
+ array_unshift($this->_config, $this->_config[0]);
+
+ $_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']);
+
+
+ if ($this->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path)
+ || $this->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path))
+ {
+ include($_smarty_compile_path);
+ }
+
+ // pop the local vars off the front of the stack
+ array_shift($this->_config);
+
+ $this->_inclusion_depth--;
+
+ if ($this->debugging) {
+ // capture time for debugging info
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time;
+ }
+
+ if ($this->caching) {
+ $this->_cache_info['template'][$params['smarty_include_tpl_file']] = true;
+ }
+ }
+
+
+ /**
+ * get or set an array of cached attributes for function that is
+ * not cacheable
+ * @return array
+ */
+ function &_smarty_cache_attrs($cache_serial, $count) {
+ $_cache_attrs =& $this->_cache_info['cache_attrs'][$cache_serial][$count];
+
+ if ($this->_cache_including) {
+ /* return next set of cache_attrs */
+ $_return =& current($_cache_attrs);
+ next($_cache_attrs);
+ return $_return;
+
+ } else {
+ /* add a reference to a new set of cache_attrs */
+ $_cache_attrs[] = array();
+ return $_cache_attrs[count($_cache_attrs)-1];
+
+ }
+
+ }
+
+
+ /**
+ * wrapper for include() retaining $this
+ * @return mixed
+ */
+ function _include($filename, $once=false, $params=null)
+ {
+ if ($once) {
+ return include_once($filename);
+ } else {
+ return include($filename);
+ }
+ }
+
+
+ /**
+ * wrapper for eval() retaining $this
+ * @return mixed
+ */
+ function _eval($code, $params=null)
+ {
+ return eval($code);
+ }
+ /**#@-*/
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/Smarty_Compiler.class.php b/wp-inst/Smarty_Compiler.class.php
new file mode 100644
index 0000000..b9cb808
--- /dev/null
+++ b/wp-inst/Smarty_Compiler.class.php
@@ -0,0 +1,2304 @@
+<?php
+
+/**
+ * Project: Smarty: the PHP compiling template engine
+ * File: Smarty_Compiler.class.php
+ *
+ * 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
+ *
+ * @link http://smarty.php.net/
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author Andrei Zmievski <andrei@php.net>
+ * @version 2.6.9
+ * @copyright 2001-2005 New Digital Group, Inc.
+ * @package Smarty
+ */
+
+/* $Id: Smarty_Compiler.class.php,v 1.367 2005/03/30 16:48:41 mohrt Exp $ */
+
+/**
+ * Template compiling class
+ * @package Smarty
+ */
+class Smarty_Compiler extends Smarty {
+
+ // internal vars
+ /**#@+
+ * @access private
+ */
+ var $_folded_blocks = array(); // keeps folded template blocks
+ var $_current_file = null; // the current template being compiled
+ var $_current_line_no = 1; // line number for error messages
+ var $_capture_stack = array(); // keeps track of nested capture buffers
+ var $_plugin_info = array(); // keeps track of plugins to load
+ var $_init_smarty_vars = false;
+ var $_permitted_tokens = array('true','false','yes','no','on','off','null');
+ var $_db_qstr_regexp = null; // regexps are setup in the constructor
+ var $_si_qstr_regexp = null;
+ var $_qstr_regexp = null;
+ var $_func_regexp = null;
+ var $_reg_obj_regexp = null;
+ var $_var_bracket_regexp = null;
+ var $_num_const_regexp = null;
+ var $_dvar_guts_regexp = null;
+ var $_dvar_regexp = null;
+ var $_cvar_regexp = null;
+ var $_svar_regexp = null;
+ var $_avar_regexp = null;
+ var $_mod_regexp = null;
+ var $_var_regexp = null;
+ var $_parenth_param_regexp = null;
+ var $_func_call_regexp = null;
+ var $_obj_ext_regexp = null;
+ var $_obj_start_regexp = null;
+ var $_obj_params_regexp = null;
+ var $_obj_call_regexp = null;
+ var $_cacheable_state = 0;
+ var $_cache_attrs_count = 0;
+ var $_nocache_count = 0;
+ var $_cache_serial = null;
+ var $_cache_include = null;
+
+ var $_strip_depth = 0;
+ var $_additional_newline = "\n";
+
+ /**#@-*/
+ /**
+ * The class constructor.
+ */
+ function Smarty_Compiler()
+ {
+ // matches double quoted strings:
+ // "foobar"
+ // "foo\"bar"
+ $this->_db_qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
+
+ // matches single quoted strings:
+ // 'foobar'
+ // 'foo\'bar'
+ $this->_si_qstr_regexp = '\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
+
+ // matches single or double quoted strings
+ $this->_qstr_regexp = '(?:' . $this->_db_qstr_regexp . '|' . $this->_si_qstr_regexp . ')';
+
+ // matches bracket portion of vars
+ // [0]
+ // [foo]
+ // [$bar]
+ $this->_var_bracket_regexp = '\[\$?[\w\.]+\]';
+
+ // matches numerical constants
+ // 30
+ // -12
+ // 13.22
+ $this->_num_const_regexp = '(?:\-?\d+(?:\.\d+)?)';
+
+ // matches $ vars (not objects):
+ // $foo
+ // $foo.bar
+ // $foo.bar.foobar
+ // $foo[0]
+ // $foo[$bar]
+ // $foo[5][blah]
+ // $foo[5].bar[$foobar][4]
+ $this->_dvar_math_regexp = '(?:[\+\*\/\%]|(?:-(?!>)))';
+ $this->_dvar_math_var_regexp = '[\$\w\.\+\-\*\/\%\d\>\[\]]';
+ $this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp
+ . ')*(?:\.\$?\w+(?:' . $this->_var_bracket_regexp . ')*)*(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?';
+ $this->_dvar_regexp = '\$' . $this->_dvar_guts_regexp;
+
+ // matches config vars:
+ // #foo#
+ // #foobar123_foo#
+ $this->_cvar_regexp = '\#\w+\#';
+
+ // matches section vars:
+ // %foo.bar%
+ $this->_svar_regexp = '\%\w+\.\w+\%';
+
+ // matches all valid variables (no quotes, no modifiers)
+ $this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|'
+ . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')';
+
+ // matches valid variable syntax:
+ // $foo
+ // $foo
+ // #foo#
+ // #foo#
+ // "text"
+ // "text"
+ $this->_var_regexp = '(?:' . $this->_avar_regexp . '|' . $this->_qstr_regexp . ')';
+
+ // matches valid object call (one level of object nesting allowed in parameters):
+ // $foo->bar
+ // $foo->bar()
+ // $foo->bar("text")
+ // $foo->bar($foo, $bar, "text")
+ // $foo->bar($foo, "foo")
+ // $foo->bar->foo()
+ // $foo->bar->foo->bar()
+ // $foo->bar($foo->bar)
+ // $foo->bar($foo->bar())
+ // $foo->bar($foo->bar($blah,$foo,44,"foo",$foo[0].bar))
+ $this->_obj_ext_regexp = '\->(?:\$?' . $this->_dvar_guts_regexp . ')';
+ $this->_obj_restricted_param_regexp = '(?:'
+ . '(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')(?:' . $this->_obj_ext_regexp . '(?:\((?:(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')'
+ . '(?:\s*,\s*(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . '))*)?\))?)*)';
+ $this->_obj_single_param_regexp = '(?:\w+|' . $this->_obj_restricted_param_regexp . '(?:\s*,\s*(?:(?:\w+|'
+ . $this->_var_regexp . $this->_obj_restricted_param_regexp . ')))*)';
+ $this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp
+ . '(?:\s*,\s*' . $this->_obj_single_param_regexp . ')*)?\)';
+ $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
+ $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?)';
+
+ // matches valid modifier syntax:
+ // |foo
+ // |@foo
+ // |foo:"bar"
+ // |foo:$bar
+ // |foo:"bar":$foobar
+ // |foo|bar
+ // |foo:$foo->bar
+ $this->_mod_regexp = '(?:\|@?\w+(?::(?:\w+|' . $this->_num_const_regexp . '|'
+ . $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)';
+
+ // matches valid function name:
+ // foo123
+ // _foo_bar
+ $this->_func_regexp = '[a-zA-Z_]\w*';
+
+ // matches valid registered object:
+ // foo->bar
+ $this->_reg_obj_regexp = '[a-zA-Z_]\w*->[a-zA-Z_]\w*';
+
+ // matches valid parameter values:
+ // true
+ // $foo
+ // $foo|bar
+ // #foo#
+ // #foo#|bar
+ // "text"
+ // "text"|bar
+ // $foo->bar
+ $this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|'
+ . $this->_var_regexp . '|' . $this->_num_const_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)';
+
+ // matches valid parenthesised function parameters:
+ //
+ // "text"
+ // $foo, $bar, "text"
+ // $foo|bar, "foo"|bar, $foo->bar($foo)|bar
+ $this->_parenth_param_regexp = '(?:\((?:\w+|'
+ . $this->_param_regexp . '(?:\s*,\s*(?:(?:\w+|'
+ . $this->_param_regexp . ')))*)?\))';
+
+ // matches valid function call:
+ // foo()
+ // foo_bar($foo)
+ // _foo_bar($foo,"bar")
+ // foo123($foo,$foo->bar(),"foo")
+ $this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:'
+ . $this->_parenth_param_regexp . '))';
+ }
+
+ /**
+ * compile a resource
+ *
+ * sets $compiled_content to the compiled source
+ * @param string $resource_name
+ * @param string $source_content
+ * @param string $compiled_content
+ * @return true
+ */
+ function _compile_file($resource_name, $source_content, &$compiled_content)
+ {
+
+ if ($this->security) {
+ // do not allow php syntax to be executed unless specified
+ if ($this->php_handling == SMARTY_PHP_ALLOW &&
+ !$this->security_settings['PHP_HANDLING']) {
+ $this->php_handling = SMARTY_PHP_PASSTHRU;
+ }
+ }
+
+ $this->_load_filters();
+
+ $this->_current_file = $resource_name;
+ $this->_current_line_no = 1;
+ $ldq = preg_quote($this->left_delimiter, '~');
+ $rdq = preg_quote($this->right_delimiter, '~');
+
+ // run template source through prefilter functions
+ if (count($this->_plugins['prefilter']) > 0) {
+ foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) {
+ if ($prefilter === false) continue;
+ if ($prefilter[3] || is_callable($prefilter[0])) {
+ $source_content = call_user_func_array($prefilter[0],
+ array($source_content, &$this));
+ $this->_plugins['prefilter'][$filter_name][3] = true;
+ } else {
+ $this->_trigger_fatal_error("[plugin] prefilter '$filter_name' is not implemented");
+ }
+ }
+ }
+
+ /* fetch all special blocks */
+ $search = "~{$ldq}\*(.*?)\*{$rdq}|{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}|{$ldq}\s*php\s*{$rdq}(.*?){$ldq}\s*/php\s*{$rdq}~s";
+
+ preg_match_all($search, $source_content, $match, PREG_SET_ORDER);
+ $this->_folded_blocks = $match;
+ reset($this->_folded_blocks);
+
+ /* replace special blocks by "{php}" */
+ $source_content = preg_replace($search.'e', "'"
+ . $this->_quote_replace($this->left_delimiter) . 'php'
+ . "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
+ . $this->_quote_replace($this->right_delimiter)
+ . "'"
+ , $source_content);
+
+ /* Gather all template tags. */
+ preg_match_all("~{$ldq}\s*(.*?)\s*{$rdq}~s", $source_content, $_match);
+ $template_tags = $_match[1];
+ /* Split content by template tags to obtain non-template content. */
+ $text_blocks = preg_split("~{$ldq}.*?{$rdq}~s", $source_content);
+
+ /* loop through text blocks */
+ for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) {
+ /* match anything resembling php tags */
+ if (preg_match_all('~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?php[\"\']?)~is', $text_blocks[$curr_tb], $sp_match)) {
+ /* replace tags with placeholders to prevent recursive replacements */
+ $sp_match[1] = array_unique($sp_match[1]);
+ usort($sp_match[1], '_smarty_sort_length');
+ for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
+ $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$text_blocks[$curr_tb]);
+ }
+ /* process each one */
+ for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
+ if ($this->php_handling == SMARTY_PHP_PASSTHRU) {
+ /* echo php contents */
+ $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '<?php echo \''.str_replace("'", "\'", $sp_match[1][$curr_sp]).'\'; ?>'."\n", $text_blocks[$curr_tb]);
+ } else if ($this->php_handling == SMARTY_PHP_QUOTE) {
+ /* quote php tags */
+ $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', htmlspecialchars($sp_match[1][$curr_sp]), $text_blocks[$curr_tb]);
+ } else if ($this->php_handling == SMARTY_PHP_REMOVE) {
+ /* remove php tags */
+ $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '', $text_blocks[$curr_tb]);
+ } else {
+ /* SMARTY_PHP_ALLOW, but echo non php starting tags */
+ $sp_match[1][$curr_sp] = preg_replace('~(<\?(?!php|=|$))~i', '<?php echo \'\\1\'?>'."\n", $sp_match[1][$curr_sp]);
+ $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]);
+ }
+ }
+ }
+ }
+
+ /* Compile the template tags into PHP code. */
+ $compiled_tags = array();
+ for ($i = 0, $for_max = count($template_tags); $i < $for_max; $i++) {
+ $this->_current_line_no += substr_count($text_blocks[$i], "\n");
+ $compiled_tags[] = $this->_compile_tag($template_tags[$i]);
+ $this->_current_line_no += substr_count($template_tags[$i], "\n");
+ }
+ if (count($this->_tag_stack)>0) {
+ list($_open_tag, $_line_no) = end($this->_tag_stack);
+ $this->_syntax_error("unclosed tag \{$_open_tag} (opened line $_line_no).", E_USER_ERROR, __FILE__, __LINE__);
+ return;
+ }
+
+ /* Reformat $text_blocks between 'strip' and '/strip' tags,
+ removing spaces, tabs and newlines. */
+ $strip = false;
+ for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
+ if ($compiled_tags[$i] == '{strip}') {
+ $compiled_tags[$i] = '';
+ $strip = true;
+ /* remove leading whitespaces */
+ $text_blocks[$i + 1] = ltrim($text_blocks[$i + 1]);
+ }
+ if ($strip) {
+ /* strip all $text_blocks before the next '/strip' */
+ for ($j = $i + 1; $j < $for_max; $j++) {
+ /* remove leading and trailing whitespaces of each line */
+ $text_blocks[$j] = preg_replace('![\t ]*[\r\n]+[\t ]*!', '', $text_blocks[$j]);
+ if ($compiled_tags[$j] == '{/strip}') {
+ /* remove trailing whitespaces from the last text_block */
+ $text_blocks[$j] = rtrim($text_blocks[$j]);
+ }
+ $text_blocks[$j] = "<?php echo '" . strtr($text_blocks[$j], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>";
+ if ($compiled_tags[$j] == '{/strip}') {
+ $compiled_tags[$j] = "\n"; /* slurped by php, but necessary
+ if a newline is following the closing strip-tag */
+ $strip = false;
+ $i = $j;
+ break;
+ }
+ }
+ }
+ }
+ $compiled_content = '';
+
+ /* Interleave the compiled contents and text blocks to get the final result. */
+ for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
+ if ($compiled_tags[$i] == '') {
+ // tag result empty, remove first newline from following text block
+ $text_blocks[$i+1] = preg_replace('~^(\r\n|\r|\n)~', '', $text_blocks[$i+1]);
+ }
+ $compiled_content .= $text_blocks[$i].$compiled_tags[$i];
+ }
+ $compiled_content .= $text_blocks[$i];
+
+ // remove \n from the end of the file, if any
+ if (($_len=strlen($compiled_content)) && ($compiled_content{$_len - 1} == "\n" )) {
+ $compiled_content = substr($compiled_content, 0, -1);
+ }
+
+ if (!empty($this->_cache_serial)) {
+ $compiled_content = "<?php \$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>" . $compiled_content;
+ }
+
+ // remove unnecessary close/open tags
+ $compiled_content = preg_replace('~\?>\n?<\?php~', '', $compiled_content);
+
+ // run compiled template through postfilter functions
+ if (count($this->_plugins['postfilter']) > 0) {
+ foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) {
+ if ($postfilter === false) continue;
+ if ($postfilter[3] || is_callable($postfilter[0])) {
+ $compiled_content = call_user_func_array($postfilter[0],
+ array($compiled_content, &$this));
+ $this->_plugins['postfilter'][$filter_name][3] = true;
+ } else {
+ $this->_trigger_fatal_error("Smarty plugin error: postfilter '$filter_name' is not implemented");
+ }
+ }
+ }
+
+ // put header at the top of the compiled template
+ $template_header = "<?php /* Smarty version ".$this->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
+ $template_header .= " compiled from ".strtr(urlencode($resource_name), array('%2F'=>'/', '%3A'=>':'))." */ ?>\n";
+
+ /* Emit code to load needed plugins. */
+ $this->_plugins_code = '';
+ if (count($this->_plugin_info)) {
+ $_plugins_params = "array('plugins' => array(";
+ foreach ($this->_plugin_info as $plugin_type => $plugins) {
+ foreach ($plugins as $plugin_name => $plugin_info) {
+ $_plugins_params .= "array('$plugin_type', '$plugin_name', '" . strtr($plugin_info[0], array("'" => "\\'", "\\" => "\\\\")) . "', $plugin_info[1], ";
+ $_plugins_params .= $plugin_info[2] ? 'true),' : 'false),';
+ }
+ }
+ $_plugins_params .= '))';
+ $plugins_code = "<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n";
+ $template_header .= $plugins_code;
+ $this->_plugin_info = array();
+ $this->_plugins_code = $plugins_code;
+ }
+
+ if ($this->_init_smarty_vars) {
+ $template_header .= "<?php require_once(SMARTY_CORE_DIR . 'core.assign_smarty_interface.php');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n";
+ $this->_init_smarty_vars = false;
+ }
+
+ $compiled_content = $template_header . $compiled_content;
+ return true;
+ }
+
+ /**
+ * Compile a template tag
+ *
+ * @param string $template_tag
+ * @return string
+ */
+ function _compile_tag($template_tag)
+ {
+ /* Matched comment. */
+ if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*')
+ return '';
+
+ /* Split tag into two three parts: command, command modifiers and the arguments. */
+ if(! preg_match('~^(?:(' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp
+ . '|\/?' . $this->_reg_obj_regexp . '|\/?' . $this->_func_regexp . ')(' . $this->_mod_regexp . '*))
+ (?:\s+(.*))?$
+ ~xs', $template_tag, $match)) {
+ $this->_syntax_error("unrecognized tag: $template_tag", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ $tag_command = $match[1];
+ $tag_modifier = isset($match[2]) ? $match[2] : null;
+ $tag_args = isset($match[3]) ? $match[3] : null;
+
+ if (preg_match('~^' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '$~', $tag_command)) {
+ /* tag name is a variable or object */
+ $_return = $this->_parse_var_props($tag_command . $tag_modifier);
+ return "<?php echo $_return; ?>" . $this->_additional_newline;
+ }
+
+ /* If the tag name is a registered object, we process it. */
+ if (preg_match('~^\/?' . $this->_reg_obj_regexp . '$~', $tag_command)) {
+ return $this->_compile_registered_object_tag($tag_command, $this->_parse_attrs($tag_args), $tag_modifier);
+ }
+
+ switch ($tag_command) {
+ case 'include':
+ return $this->_compile_include_tag($tag_args);
+
+ case 'include_php':
+ return $this->_compile_include_php_tag($tag_args);
+
+ case 'if':
+ $this->_push_tag('if');
+ return $this->_compile_if_tag($tag_args);
+
+ case 'else':
+ list($_open_tag) = end($this->_tag_stack);
+ if ($_open_tag != 'if' && $_open_tag != 'elseif')
+ $this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__);
+ else
+ $this->_push_tag('else');
+ return '<?php else: ?>';
+
+ case 'elseif':
+ list($_open_tag) = end($this->_tag_stack);
+ if ($_open_tag != 'if' && $_open_tag != 'elseif')
+ $this->_syntax_error('unexpected {elseif}', E_USER_ERROR, __FILE__, __LINE__);
+ if ($_open_tag == 'if')
+ $this->_push_tag('elseif');
+ return $this->_compile_if_tag($tag_args, true);
+
+ case '/if':
+ $this->_pop_tag('if');
+ return '<?php endif; ?>';
+
+ case 'capture':
+ return $this->_compile_capture_tag(true, $tag_args);
+
+ case '/capture':
+ return $this->_compile_capture_tag(false);
+
+ case 'ldelim':
+ return $this->left_delimiter;
+
+ case 'rdelim':
+ return $this->right_delimiter;
+
+ case 'section':
+ $this->_push_tag('section');
+ return $this->_compile_section_start($tag_args);
+
+ case 'sectionelse':
+ $this->_push_tag('sectionelse');
+ return "<?php endfor; else: ?>";
+ break;
+
+ case '/section':
+ $_open_tag = $this->_pop_tag('section');
+ if ($_open_tag == 'sectionelse')
+ return "<?php endif; ?>";
+ else
+ return "<?php endfor; endif; ?>";
+
+ case 'foreach':
+ $this->_push_tag('foreach');
+ return $this->_compile_foreach_start($tag_args);
+ break;
+
+ case 'foreachelse':
+ $this->_push_tag('foreachelse');
+ return "<?php endforeach; else: ?>";
+
+ case '/foreach':
+ $_open_tag = $this->_pop_tag('foreach');
+ if ($_open_tag == 'foreachelse')
+ return "<?php endif; unset(\$_from); ?>";
+ else
+ return "<?php endforeach; endif; unset(\$_from); ?>";
+ break;
+
+ case 'strip':
+ case '/strip':
+ if ($tag_command{0}=='/') {
+ $this->_pop_tag('strip');
+ if (--$this->_strip_depth==0) { /* outermost closing {/strip} */
+ $this->_additional_newline = "\n";
+ return '{' . $tag_command . '}';
+ }
+ } else {
+ $this->_push_tag('strip');
+ if ($this->_strip_depth++==0) { /* outermost opening {strip} */
+ $this->_additional_newline = "";
+ return '{' . $tag_command . '}';
+ }
+ }
+ return '';
+
+ case 'php':
+ /* handle folded tags replaced by {php} */
+ list(, $block) = each($this->_folded_blocks);
+ $this->_current_line_no += substr_count($block[0], "\n");
+ /* the number of matched elements in the regexp in _compile_file()
+ determins the type of folded tag that was found */
+ switch (count($block)) {
+ case 2: /* comment */
+ return '';
+
+ case 3: /* literal */
+ return "<?php echo '" . strtr($block[2], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>" . $this->_additional_newline;
+
+ case 4: /* php */
+ if ($this->security && !$this->security_settings['PHP_TAGS']) {
+ $this->_syntax_error("(secure mode) php tags not permitted", E_USER_WARNING, __FILE__, __LINE__);
+ return;
+ }
+ return '<?php ' . $block[3] .' ?>';
+ }
+ break;
+
+ case 'insert':
+ return $this->_compile_insert_tag($tag_args);
+
+ default:
+ if ($this->_compile_compiler_tag($tag_command, $tag_args, $output)) {
+ return $output;
+ } else if ($this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) {
+ return $output;
+ } else if ($this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output)) {
+ return $output;
+ } else {
+ $this->_syntax_error("unrecognized tag '$tag_command'", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ }
+ }
+
+
+ /**
+ * compile the custom compiler tag
+ *
+ * sets $output to the compiled custom compiler tag
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $output
+ * @return boolean
+ */
+ function _compile_compiler_tag($tag_command, $tag_args, &$output)
+ {
+ $found = false;
+ $have_function = true;
+
+ /*
+ * First we check if the compiler function has already been registered
+ * or loaded from a plugin file.
+ */
+ if (isset($this->_plugins['compiler'][$tag_command])) {
+ $found = true;
+ $plugin_func = $this->_plugins['compiler'][$tag_command][0];
+ if (!is_callable($plugin_func)) {
+ $message = "compiler function '$tag_command' is not implemented";
+ $have_function = false;
+ }
+ }
+ /*
+ * Otherwise we need to load plugin file and look for the function
+ * inside it.
+ */
+ else if ($plugin_file = $this->_get_plugin_filepath('compiler', $tag_command)) {
+ $found = true;
+
+ include_once $plugin_file;
+
+ $plugin_func = 'smarty_compiler_' . $tag_command;
+ if (!is_callable($plugin_func)) {
+ $message = "plugin function $plugin_func() not found in $plugin_file\n";
+ $have_function = false;
+ } else {
+ $this->_plugins['compiler'][$tag_command] = array($plugin_func, null, null, null, true);
+ }
+ }
+
+ /*
+ * True return value means that we either found a plugin or a
+ * dynamically registered function. False means that we didn't and the
+ * compiler should now emit code to load custom function plugin for this
+ * tag.
+ */
+ if ($found) {
+ if ($have_function) {
+ $output = call_user_func_array($plugin_func, array($tag_args, &$this));
+ if($output != '') {
+ $output = '<?php ' . $this->_push_cacheable_state('compiler', $tag_command)
+ . $output
+ . $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>';
+ }
+ } else {
+ $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ /**
+ * compile block function tag
+ *
+ * sets $output to compiled block function tag
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $tag_modifier
+ * @param string $output
+ * @return boolean
+ */
+ function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output)
+ {
+ if ($tag_command{0} == '/') {
+ $start_tag = false;
+ $tag_command = substr($tag_command, 1);
+ } else
+ $start_tag = true;
+
+ $found = false;
+ $have_function = true;
+
+ /*
+ * First we check if the block function has already been registered
+ * or loaded from a plugin file.
+ */
+ if (isset($this->_plugins['block'][$tag_command])) {
+ $found = true;
+ $plugin_func = $this->_plugins['block'][$tag_command][0];
+ if (!is_callable($plugin_func)) {
+ $message = "block function '$tag_command' is not implemented";
+ $have_function = false;
+ }
+ }
+ /*
+ * Otherwise we need to load plugin file and look for the function
+ * inside it.
+ */
+ else if ($plugin_file = $this->_get_plugin_filepath('block', $tag_command)) {
+ $found = true;
+
+ include_once $plugin_file;
+
+ $plugin_func = 'smarty_block_' . $tag_command;
+ if (!function_exists($plugin_func)) {
+ $message = "plugin function $plugin_func() not found in $plugin_file\n";
+ $have_function = false;
+ } else {
+ $this->_plugins['block'][$tag_command] = array($plugin_func, null, null, null, true);
+
+ }
+ }
+
+ if (!$found) {
+ return false;
+ } else if (!$have_function) {
+ $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
+ return true;
+ }
+
+ /*
+ * Even though we've located the plugin function, compilation
+ * happens only once, so the plugin will still need to be loaded
+ * at runtime for future requests.
+ */
+ $this->_add_plugin('block', $tag_command);
+
+ if ($start_tag)
+ $this->_push_tag($tag_command);
+ else
+ $this->_pop_tag($tag_command);
+
+ if ($start_tag) {
+ $output = '<?php ' . $this->_push_cacheable_state('block', $tag_command);
+ $attrs = $this->_parse_attrs($tag_args);
+ $arg_list = $this->_compile_arg_list('block', $tag_command, $attrs, $_cache_attrs='');
+ $output .= "$_cache_attrs\$this->_tag_stack[] = array('$tag_command', array(".implode(',', $arg_list).')); ';
+ $output .= $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat=true);';
+ $output .= 'while ($_block_repeat) { ob_start(); ?>';
+ } else {
+ $output = '<?php $_block_content = ob_get_contents(); ob_end_clean(); ';
+ $_out_tag_text = $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat=false)';
+ if ($tag_modifier != '') {
+ $this->_parse_modifiers($_out_tag_text, $tag_modifier);
+ }
+ $output .= 'echo '.$_out_tag_text.'; } ';
+ $output .= " array_pop(\$this->_tag_stack); " . $this->_pop_cacheable_state('block', $tag_command) . '?>';
+ }
+
+ return true;
+ }
+
+
+ /**
+ * compile custom function tag
+ *
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $tag_modifier
+ * @return string
+ */
+ function _compile_custom_tag($tag_command, $tag_args, $tag_modifier, &$output)
+ {
+ $found = false;
+ $have_function = true;
+
+ /*
+ * First we check if the custom function has already been registered
+ * or loaded from a plugin file.
+ */
+ if (isset($this->_plugins['function'][$tag_command])) {
+ $found = true;
+ $plugin_func = $this->_plugins['function'][$tag_command][0];
+ if (!is_callable($plugin_func)) {
+ $message = "custom function '$tag_command' is not implemented";
+ $have_function = false;
+ }
+ }
+ /*
+ * Otherwise we need to load plugin file and look for the function
+ * inside it.
+ */
+ else if ($plugin_file = $this->_get_plugin_filepath('function', $tag_command)) {
+ $found = true;
+
+ include_once $plugin_file;
+
+ $plugin_func = 'smarty_function_' . $tag_command;
+ if (!function_exists($plugin_func)) {
+ $message = "plugin function $plugin_func() not found in $plugin_file\n";
+ $have_function = false;
+ } else {
+ $this->_plugins['function'][$tag_command] = array($plugin_func, null, null, null, true);
+
+ }
+ }
+
+ if (!$found) {
+ return false;
+ } else if (!$have_function) {
+ $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
+ return true;
+ }
+
+ /* declare plugin to be loaded on display of the template that
+ we compile right now */
+ $this->_add_plugin('function', $tag_command);
+
+ $_cacheable_state = $this->_push_cacheable_state('function', $tag_command);
+ $attrs = $this->_parse_attrs($tag_args);
+ $arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs='');
+
+ $output = $this->_compile_plugin_call('function', $tag_command).'(array('.implode(',', $arg_list)."), \$this)";
+ if($tag_modifier != '') {
+ $this->_parse_modifiers($output, $tag_modifier);
+ }
+
+ if($output != '') {
+ $output = '<?php ' . $_cacheable_state . $_cache_attrs . 'echo ' . $output . ';'
+ . $this->_pop_cacheable_state('function', $tag_command) . "?>" . $this->_additional_newline;
+ }
+
+ return true;
+ }
+
+ /**
+ * compile a registered object tag
+ *
+ * @param string $tag_command
+ * @param array $attrs
+ * @param string $tag_modifier
+ * @return string
+ */
+ function _compile_registered_object_tag($tag_command, $attrs, $tag_modifier)
+ {
+ if ($tag_command{0} == '/') {
+ $start_tag = false;
+ $tag_command = substr($tag_command, 1);
+ } else {
+ $start_tag = true;
+ }
+
+ list($object, $obj_comp) = explode('->', $tag_command);
+
+ $arg_list = array();
+ if(count($attrs)) {
+ $_assign_var = false;
+ foreach ($attrs as $arg_name => $arg_value) {
+ if($arg_name == 'assign') {
+ $_assign_var = $arg_value;
+ unset($attrs['assign']);
+ continue;
+ }
+ if (is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+ }
+
+ if($this->_reg_objects[$object][2]) {
+ // smarty object argument format
+ $args = "array(".implode(',', (array)$arg_list)."), \$this";
+ } else {
+ // traditional argument format
+ $args = implode(',', array_values($attrs));
+ if (empty($args)) {
+ $args = 'null';
+ }
+ }
+
+ $prefix = '';
+ $postfix = '';
+ $newline = '';
+ if(!is_object($this->_reg_objects[$object][0])) {
+ $this->_trigger_fatal_error("registered '$object' is not an object" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);
+ } elseif(!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) {
+ $this->_trigger_fatal_error("'$obj_comp' is not a registered component of object '$object'", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);
+ } elseif(method_exists($this->_reg_objects[$object][0], $obj_comp)) {
+ // method
+ if(in_array($obj_comp, $this->_reg_objects[$object][3])) {
+ // block method
+ if ($start_tag) {
+ $prefix = "\$this->_tag_stack[] = array('$obj_comp', $args); ";
+ $prefix .= "\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], null, \$this, \$_block_repeat=true); ";
+ $prefix .= "while (\$_block_repeat) { ob_start();";
+ $return = null;
+ $postfix = '';
+ } else {
+ $prefix = "\$_obj_block_content = ob_get_contents(); ob_end_clean(); ";
+ $return = "\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], \$_obj_block_content, \$this, \$_block_repeat=false)";
+ $postfix = "} array_pop(\$this->_tag_stack);";
+ }
+ } else {
+ // non-block method
+ $return = "\$this->_reg_objects['$object'][0]->$obj_comp($args)";
+ }
+ } else {
+ // property
+ $return = "\$this->_reg_objects['$object'][0]->$obj_comp";
+ }
+
+ if($return != null) {
+ if($tag_modifier != '') {
+ $this->_parse_modifiers($return, $tag_modifier);
+ }
+
+ if(!empty($_assign_var)) {
+ $output = "\$this->assign('" . $this->_dequote($_assign_var) ."', $return);";
+ } else {
+ $output = 'echo ' . $return . ';';
+ $newline = $this->_additional_newline;
+ }
+ } else {
+ $output = '';
+ }
+
+ return '<?php ' . $prefix . $output . $postfix . "?>" . $newline;
+ }
+
+ /**
+ * Compile {insert ...} tag
+ *
+ * @param string $tag_args
+ * @return string
+ */
+ function _compile_insert_tag($tag_args)
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+ $name = $this->_dequote($attrs['name']);
+
+ if (empty($name)) {
+ $this->_syntax_error("missing insert name", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ if (!empty($attrs['script'])) {
+ $delayed_loading = true;
+ } else {
+ $delayed_loading = false;
+ }
+
+ foreach ($attrs as $arg_name => $arg_value) {
+ if (is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+
+ $this->_add_plugin('insert', $name, $delayed_loading);
+
+ $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))";
+
+ return "<?php require_once(SMARTY_CORE_DIR . 'core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>" . $this->_additional_newline;
+ }
+
+ /**
+ * Compile {include ...} tag
+ *
+ * @param string $tag_args
+ * @return string
+ */
+ function _compile_include_tag($tag_args)
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+ $arg_list = array();
+
+ if (empty($attrs['file'])) {
+ $this->_syntax_error("missing 'file' attribute in include tag", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ foreach ($attrs as $arg_name => $arg_value) {
+ if ($arg_name == 'file') {
+ $include_file = $arg_value;
+ continue;
+ } else if ($arg_name == 'assign') {
+ $assign_var = $arg_value;
+ continue;
+ }
+ if (is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+
+ $output = '<?php ';
+
+ if (isset($assign_var)) {
+ $output .= "ob_start();\n";
+ }
+
+ $output .=
+ "\$_smarty_tpl_vars = \$this->_tpl_vars;\n";
+
+
+ $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))";
+ $output .= "\$this->_smarty_include($_params);\n" .
+ "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" .
+ "unset(\$_smarty_tpl_vars);\n";
+
+ if (isset($assign_var)) {
+ $output .= "\$this->assign(" . $assign_var . ", ob_get_contents()); ob_end_clean();\n";
+ }
+
+ $output .= ' ?>';
+
+ return $output;
+
+ }
+
+ /**
+ * Compile {include ...} tag
+ *
+ * @param string $tag_args
+ * @return string
+ */
+ function _compile_include_php_tag($tag_args)
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+
+ if (empty($attrs['file'])) {
+ $this->_syntax_error("missing 'file' attribute in include_php tag", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ $assign_var = (empty($attrs['assign'])) ? '' : $this->_dequote($attrs['assign']);
+ $once_var = (empty($attrs['once']) || $attrs['once']=='false') ? 'false' : 'true';
+
+ $arg_list = array();
+ foreach($attrs as $arg_name => $arg_value) {
+ if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') {
+ if(is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+ }
+
+ $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', $arg_list)."))";
+
+ return "<?php require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>" . $this->_additional_newline;
+ }
+
+
+ /**
+ * Compile {section ...} tag
+ *
+ * @param string $tag_args
+ * @return string
+ */
+ function _compile_section_start($tag_args)
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+ $arg_list = array();
+
+ $output = '<?php ';
+ $section_name = $attrs['name'];
+ if (empty($section_name)) {
+ $this->_syntax_error("missing section name", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ $output .= "unset(\$this->_sections[$section_name]);\n";
+ $section_props = "\$this->_sections[$section_name]";
+
+ foreach ($attrs as $attr_name => $attr_value) {
+ switch ($attr_name) {
+ case 'loop':
+ $output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n";
+ break;
+
+ case 'show':
+ if (is_bool($attr_value))
+ $show_attr_value = $attr_value ? 'true' : 'false';
+ else
+ $show_attr_value = "(bool)$attr_value";
+ $output .= "{$section_props}['show'] = $show_attr_value;\n";
+ break;
+
+ case 'name':
+ $output .= "{$section_props}['$attr_name'] = $attr_value;\n";
+ break;
+
+ case 'max':
+ case 'start':
+ $output .= "{$section_props}['$attr_name'] = (int)$attr_value;\n";
+ break;
+
+ case 'step':
+ $output .= "{$section_props}['$attr_name'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\n";
+ break;
+
+ default:
+ $this->_syntax_error("unknown section attribute - '$attr_name'", E_USER_ERROR, __FILE__, __LINE__);
+ break;
+ }
+ }
+
+ if (!isset($attrs['show']))
+ $output .= "{$section_props}['show'] = true;\n";
+
+ if (!isset($attrs['loop']))
+ $output .= "{$section_props}['loop'] = 1;\n";
+
+ if (!isset($attrs['max']))
+ $output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
+ else
+ $output .= "if ({$section_props}['max'] < 0)\n" .
+ " {$section_props}['max'] = {$section_props}['loop'];\n";
+
+ if (!isset($attrs['step']))
+ $output .= "{$section_props}['step'] = 1;\n";
+
+ if (!isset($attrs['start']))
+ $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n";
+ else {
+ $output .= "if ({$section_props}['start'] < 0)\n" .
+ " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" .
+ "else\n" .
+ " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n";
+ }
+
+ $output .= "if ({$section_props}['show']) {\n";
+ if (!isset($attrs['start']) && !isset($attrs['step']) && !isset($attrs['max'])) {
+ $output .= " {$section_props}['total'] = {$section_props}['loop'];\n";
+ } else {
+ $output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n";
+ }
+ $output .= " if ({$section_props}['total'] == 0)\n" .
+ " {$section_props}['show'] = false;\n" .
+ "} else\n" .
+ " {$section_props}['total'] = 0;\n";
+
+ $output .= "if ({$section_props}['show']):\n";
+ $output .= "
+ for ({$section_props}['index'] = {$section_props}['start'], {$section_props}['iteration'] = 1;
+ {$section_props}['iteration'] <= {$section_props}['total'];
+ {$section_props}['index'] += {$section_props}['step'], {$section_props}['iteration']++):\n";
+ $output .= "{$section_props}['rownum'] = {$section_props}['iteration'];\n";
+ $output .= "{$section_props}['index_prev'] = {$section_props}['index'] - {$section_props}['step'];\n";
+ $output .= "{$section_props}['index_next'] = {$section_props}['index'] + {$section_props}['step'];\n";
+ $output .= "{$section_props}['first'] = ({$section_props}['iteration'] == 1);\n";
+ $output .= "{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n";
+
+ $output .= "?>";
+
+ return $output;
+ }
+
+
+ /**
+ * Compile {foreach ...} tag.
+ *
+ * @param string $tag_args
+ * @return string
+ */
+ function _compile_foreach_start($tag_args)
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+ $arg_list = array();
+
+ if (empty($attrs['from'])) {
+ return $this->_syntax_error("foreach: missing 'from' attribute", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ $from = $attrs['from'];
+
+ if (empty($attrs['item'])) {
+ return $this->_syntax_error("foreach: missing 'item' attribute", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ $item = $this->_dequote($attrs['item']);
+ if (!preg_match('~^\w+$~', $item)) {
+ return $this->_syntax_error("'foreach: item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ if (isset($attrs['key'])) {
+ $key = $this->_dequote($attrs['key']);
+ if (!preg_match('~^\w+$~', $key)) {
+ return $this->_syntax_error("foreach: 'key' must to be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ $key_part = "\$this->_tpl_vars['$key'] => ";
+ } else {
+ $key = null;
+ $key_part = '';
+ }
+
+ if (isset($attrs['name'])) {
+ $name = $attrs['name'];
+ } else {
+ $name = null;
+ }
+
+ $output = '<?php ';
+ $output .= "\$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array'); }";
+ if (isset($name)) {
+ $foreach_props = "\$this->_foreach[$name]";
+ $output .= "{$foreach_props} = array('total' => count(\$_from), 'iteration' => 0);\n";
+ $output .= "if ({$foreach_props}['total'] > 0):\n";
+ $output .= " foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n";
+ $output .= " {$foreach_props}['iteration']++;\n";
+ } else {
+ $output .= "if (count(\$_from)):\n";
+ $output .= " foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n";
+ }
+ $output .= '?>';
+
+ return $output;
+ }
+
+
+ /**
+ * Compile {capture} .. {/capture} tags
+ *
+ * @param boolean $start true if this is the {capture} tag
+ * @param string $tag_args
+ * @return string
+ */
+
+ function _compile_capture_tag($start, $tag_args = '')
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+
+ if ($start) {
+ if (isset($attrs['name']))
+ $buffer = $attrs['name'];
+ else
+ $buffer = "'default'";
+
+ if (isset($attrs['assign']))
+ $assign = $attrs['assign'];
+ else
+ $assign = null;
+ $output = "<?php ob_start(); ?>";
+ $this->_capture_stack[] = array($buffer, $assign);
+ } else {
+ list($buffer, $assign) = array_pop($this->_capture_stack);
+ $output = "<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); ";
+ if (isset($assign)) {
+ $output .= " \$this->assign($assign, ob_get_contents());";
+ }
+ $output .= "ob_end_clean(); ?>";
+ }
+
+ return $output;
+ }
+
+ /**
+ * Compile {if ...} tag
+ *
+ * @param string $tag_args
+ * @param boolean $elseif if true, uses elseif instead of if
+ * @return string
+ */
+ function _compile_if_tag($tag_args, $elseif = false)
+ {
+
+ /* Tokenize args for 'if' tag. */
+ preg_match_all('~(?>
+ ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*)? | # valid object call
+ ' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)? | # var or quoted string
+ \-?0[xX][0-9a-fA-F]+|\-?\d+(?:\.\d+)?|\.\d+|!==|===|==|!=|<>|<<|>>|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token
+ \b\w+\b | # valid word token
+ \S+ # anything else
+ )~x', $tag_args, $match);
+
+ $tokens = $match[0];
+
+ // make sure we have balanced parenthesis
+ $token_count = array_count_values($tokens);
+ if(isset($token_count['(']) && $token_count['('] != $token_count[')']) {
+ $this->_syntax_error("unbalanced parenthesis in if statement", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ $is_arg_stack = array();
+
+ for ($i = 0; $i < count($tokens); $i++) {
+
+ $token = &$tokens[$i];
+
+ switch (strtolower($token)) {
+ case '!':
+ case '%':
+ case '!==':
+ case '==':
+ case '===':
+ case '>':
+ case '<':
+ case '!=':
+ case '<>':
+ case '<<':
+ case '>>':
+ case '<=':
+ case '>=':
+ case '&&':
+ case '||':
+ case '|':
+ case '^':
+ case '&':
+ case '~':
+ case ')':
+ case ',':
+ case '+':
+ case '-':
+ case '*':
+ case '/':
+ case '@':
+ break;
+
+ case 'eq':
+ $token = '==';
+ break;
+
+ case 'ne':
+ case 'neq':
+ $token = '!=';
+ break;
+
+ case 'lt':
+ $token = '<';
+ break;
+
+ case 'le':
+ case 'lte':
+ $token = '<=';
+ break;
+
+ case 'gt':
+ $token = '>';
+ break;
+
+ case 'ge':
+ case 'gte':
+ $token = '>=';
+ break;
+
+ case 'and':
+ $token = '&&';
+ break;
+
+ case 'or':
+ $token = '||';
+ break;
+
+ case 'not':
+ $token = '!';
+ break;
+
+ case 'mod':
+ $token = '%';
+ break;
+
+ case '(':
+ array_push($is_arg_stack, $i);
+ break;
+
+ case 'is':
+ /* If last token was a ')', we operate on the parenthesized
+ expression. The start of the expression is on the stack.
+ Otherwise, we operate on the last encountered token. */
+ if ($tokens[$i-1] == ')')
+ $is_arg_start = array_pop($is_arg_stack);
+ else
+ $is_arg_start = $i-1;
+ /* Construct the argument for 'is' expression, so it knows
+ what to operate on. */
+ $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
+
+ /* Pass all tokens from next one until the end to the
+ 'is' expression parsing function. The function will
+ return modified tokens, where the first one is the result
+ of the 'is' expression and the rest are the tokens it
+ didn't touch. */
+ $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));
+
+ /* Replace the old tokens with the new ones. */
+ array_splice($tokens, $is_arg_start, count($tokens), $new_tokens);
+
+ /* Adjust argument start so that it won't change from the
+ current position for the next iteration. */
+ $i = $is_arg_start;
+ break;
+
+ default:
+ if(preg_match('~^' . $this->_func_regexp . '$~', $token) ) {
+ // function call
+ if($this->security &&
+ !in_array($token, $this->security_settings['IF_FUNCS'])) {
+ $this->_syntax_error("(secure mode) '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ } elseif(preg_match('~^' . $this->_var_regexp . '$~', $token) && isset($tokens[$i+1]) && $tokens[$i+1] == '(') {
+ // variable function call
+ $this->_syntax_error("variable function call '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__);
+ } elseif(preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)$~', $token)) {
+ // object or variable
+ $token = $this->_parse_var_props($token);
+ } elseif(is_numeric($token)) {
+ // number, skip it
+ } else {
+ $this->_syntax_error("unidentified token '$token'", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ break;
+ }
+ }
+
+ if ($elseif)
+ return '<?php elseif ('.implode(' ', $tokens).'): ?>';
+ else
+ return '<?php if ('.implode(' ', $tokens).'): ?>';
+ }
+
+
+ function _compile_arg_list($type, $name, $attrs, &$cache_code) {
+ $arg_list = array();
+
+ if (isset($type) && isset($name)
+ && isset($this->_plugins[$type])
+ && isset($this->_plugins[$type][$name])
+ && empty($this->_plugins[$type][$name][4])
+ && is_array($this->_plugins[$type][$name][5])
+ ) {
+ /* we have a list of parameters that should be cached */
+ $_cache_attrs = $this->_plugins[$type][$name][5];
+ $_count = $this->_cache_attrs_count++;
+ $cache_code = "\$_cache_attrs =& \$this->_smarty_cache_attrs('$this->_cache_serial','$_count');";
+
+ } else {
+ /* no parameters are cached */
+ $_cache_attrs = null;
+ }
+
+ foreach ($attrs as $arg_name => $arg_value) {
+ if (is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ if (is_null($arg_value))
+ $arg_value = 'null';
+ if ($_cache_attrs && in_array($arg_name, $_cache_attrs)) {
+ $arg_list[] = "'$arg_name' => (\$this->_cache_including) ? \$_cache_attrs['$arg_name'] : (\$_cache_attrs['$arg_name']=$arg_value)";
+ } else {
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+ }
+ return $arg_list;
+ }
+
+ /**
+ * Parse is expression
+ *
+ * @param string $is_arg
+ * @param array $tokens
+ * @return array
+ */
+ function _parse_is_expr($is_arg, $tokens)
+ {
+ $expr_end = 0;
+ $negate_expr = false;
+
+ if (($first_token = array_shift($tokens)) == 'not') {
+ $negate_expr = true;
+ $expr_type = array_shift($tokens);
+ } else
+ $expr_type = $first_token;
+
+ switch ($expr_type) {
+ case 'even':
+ if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') {
+ $expr_end++;
+ $expr_arg = $tokens[$expr_end++];
+ $expr = "!(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))";
+ } else
+ $expr = "!(1 & $is_arg)";
+ break;
+
+ case 'odd':
+ if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') {
+ $expr_end++;
+ $expr_arg = $tokens[$expr_end++];
+ $expr = "(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))";
+ } else
+ $expr = "(1 & $is_arg)";
+ break;
+
+ case 'div':
+ if (@$tokens[$expr_end] == 'by') {
+ $expr_end++;
+ $expr_arg = $tokens[$expr_end++];
+ $expr = "!($is_arg % " . $this->_parse_var_props($expr_arg) . ")";
+ } else {
+ $this->_syntax_error("expecting 'by' after 'div'", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ break;
+
+ default:
+ $this->_syntax_error("unknown 'is' expression - '$expr_type'", E_USER_ERROR, __FILE__, __LINE__);
+ break;
+ }
+
+ if ($negate_expr) {
+ $expr = "!($expr)";
+ }
+
+ array_splice($tokens, 0, $expr_end, $expr);
+
+ return $tokens;
+ }
+
+
+ /**
+ * Parse attribute string
+ *
+ * @param string $tag_args
+ * @return array
+ */
+ function _parse_attrs($tag_args)
+ {
+
+ /* Tokenize tag attributes. */
+ preg_match_all('~(?:' . $this->_obj_call_regexp . '|' . $this->_qstr_regexp . ' | (?>[^"\'=\s]+)
+ )+ |
+ [=]
+ ~x', $tag_args, $match);
+ $tokens = $match[0];
+
+ $attrs = array();
+ /* Parse state:
+ 0 - expecting attribute name
+ 1 - expecting '='
+ 2 - expecting attribute value (not '=') */
+ $state = 0;
+
+ foreach ($tokens as $token) {
+ switch ($state) {
+ case 0:
+ /* If the token is a valid identifier, we set attribute name
+ and go to state 1. */
+ if (preg_match('~^\w+$~', $token)) {
+ $attr_name = $token;
+ $state = 1;
+ } else
+ $this->_syntax_error("invalid attribute name: '$token'", E_USER_ERROR, __FILE__, __LINE__);
+ break;
+
+ case 1:
+ /* If the token is '=', then we go to state 2. */
+ if ($token == '=') {
+ $state = 2;
+ } else
+ $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
+ break;
+
+ case 2:
+ /* If token is not '=', we set the attribute value and go to
+ state 0. */
+ if ($token != '=') {
+ /* We booleanize the token if it's a non-quoted possible
+ boolean value. */
+ if (preg_match('~^(on|yes|true)$~', $token)) {
+ $token = 'true';
+ } else if (preg_match('~^(off|no|false)$~', $token)) {
+ $token = 'false';
+ } else if ($token == 'null') {
+ $token = 'null';
+ } else if (preg_match('~^' . $this->_num_const_regexp . '|0[xX][0-9a-fA-F]+$~', $token)) {
+ /* treat integer literally */
+ } else if (!preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')*$~', $token)) {
+ /* treat as a string, double-quote it escaping quotes */
+ $token = '"'.addslashes($token).'"';
+ }
+
+ $attrs[$attr_name] = $token;
+ $state = 0;
+ } else
+ $this->_syntax_error("'=' cannot be an attribute value", E_USER_ERROR, __FILE__, __LINE__);
+ break;
+ }
+ $last_token = $token;
+ }
+
+ if($state != 0) {
+ if($state == 1) {
+ $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
+ } else {
+ $this->_syntax_error("missing attribute value", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ }
+
+ $this->_parse_vars_props($attrs);
+
+ return $attrs;
+ }
+
+ /**
+ * compile multiple variables and section properties tokens into
+ * PHP code
+ *
+ * @param array $tokens
+ */
+ function _parse_vars_props(&$tokens)
+ {
+ foreach($tokens as $key => $val) {
+ $tokens[$key] = $this->_parse_var_props($val);
+ }
+ }
+
+ /**
+ * compile single variable and section properties token into
+ * PHP code
+ *
+ * @param string $val
+ * @param string $tag_attrs
+ * @return string
+ */
+ function _parse_var_props($val)
+ {
+ $val = trim($val);
+
+ if(preg_match('~^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(' . $this->_mod_regexp . '*)$~', $val, $match)) {
+ // $ variable or object
+ $return = $this->_parse_var($match[1]);
+ $modifiers = $match[2];
+ if (!empty($this->default_modifiers) && !preg_match('~(^|\|)smarty:nodefaults($|\|)~',$modifiers)) {
+ $_default_mod_string = implode('|',(array)$this->default_modifiers);
+ $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers;
+ }
+ $this->_parse_modifiers($return, $modifiers);
+ return $return;
+ } elseif (preg_match('~^' . $this->_db_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
+ // double quoted text
+ preg_match('~^(' . $this->_db_qstr_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match);
+ $return = $this->_expand_quoted_text($match[1]);
+ if($match[2] != '') {
+ $this->_parse_modifiers($return, $match[2]);
+ }
+ return $return;
+ }
+ elseif(preg_match('~^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
+ // numerical constant
+ preg_match('~^(' . $this->_num_const_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match);
+ if($match[2] != '') {
+ $this->_parse_modifiers($match[1], $match[2]);
+ return $match[1];
+ }
+ }
+ elseif(preg_match('~^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
+ // single quoted text
+ preg_match('~^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match);
+ if($match[2] != '') {
+ $this->_parse_modifiers($match[1], $match[2]);
+ return $match[1];
+ }
+ }
+ elseif(preg_match('~^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
+ // config var
+ return $this->_parse_conf_var($val);
+ }
+ elseif(preg_match('~^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
+ // section var
+ return $this->_parse_section_prop($val);
+ }
+ elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
+ // literal string
+ return $this->_expand_quoted_text('"' . $val .'"');
+ }
+ return $val;
+ }
+
+ /**
+ * expand quoted text with embedded variables
+ *
+ * @param string $var_expr
+ * @return string
+ */
+ function _expand_quoted_text($var_expr)
+ {
+ // if contains unescaped $, expand it
+ if(preg_match_all('~(?:\`(?<!\\\\)\$' . $this->_dvar_guts_regexp . '(?:' . $this->_obj_ext_regexp . ')*\`)|(?:(?<!\\\\)\$\w+(\[[a-zA-Z0-9]+\])*)~', $var_expr, $_match)) {
+ $_match = $_match[0];
+ rsort($_match);
+ reset($_match);
+ foreach($_match as $_var) {
+ $var_expr = str_replace ($_var, '".(' . $this->_parse_var(str_replace('`','',$_var)) . ')."', $var_expr);
+ }
+ $_return = preg_replace('~\.""|(?<!\\\\)""\.~', '', $var_expr);
+ } else {
+ $_return = $var_expr;
+ }
+ // replace double quoted literal string with single quotes
+ $_return = preg_replace('~^"([\s\w]+)"$~',"'\\1'",$_return);
+ return $_return;
+ }
+
+ /**
+ * parse variable expression into PHP code
+ *
+ * @param string $var_expr
+ * @param string $output
+ * @return string
+ */
+ function _parse_var($var_expr)
+ {
+ $_has_math = false;
+ $_math_vars = preg_split('~('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE);
+
+ if(count($_math_vars) > 1) {
+ $_first_var = "";
+ $_complete_var = "";
+ $_output = "";
+ // simple check if there is any math, to stop recursion (due to modifiers with "xx % yy" as parameter)
+ foreach($_math_vars as $_k => $_math_var) {
+ $_math_var = $_math_vars[$_k];
+
+ if(!empty($_math_var) || is_numeric($_math_var)) {
+ // hit a math operator, so process the stuff which came before it
+ if(preg_match('~^' . $this->_dvar_math_regexp . '$~', $_math_var)) {
+ $_has_math = true;
+ if(!empty($_complete_var) || is_numeric($_complete_var)) {
+ $_output .= $this->_parse_var($_complete_var);
+ }
+
+ // just output the math operator to php
+ $_output .= $_math_var;
+
+ if(empty($_first_var))
+ $_first_var = $_complete_var;
+
+ $_complete_var = "";
+ } else {
+ $_complete_var .= $_math_var;
+ }
+ }
+ }
+ if($_has_math) {
+ if(!empty($_complete_var) || is_numeric($_complete_var))
+ $_output .= $this->_parse_var($_complete_var);
+
+ // get the modifiers working (only the last var from math + modifier is left)
+ $var_expr = $_complete_var;
+ }
+ }
+
+ // prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit)
+ if(is_numeric($var_expr{0}))
+ $_var_ref = $var_expr;
+ else
+ $_var_ref = substr($var_expr, 1);
+
+ if(!$_has_math) {
+
+ // get [foo] and .foo and ->foo and (...) pieces
+ preg_match_all('~(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\$?\w+|\.\$?\w+|\S+~', $_var_ref, $match);
+
+ $_indexes = $match[0];
+ $_var_name = array_shift($_indexes);
+
+ /* Handle $smarty.* variable references as a special case. */
+ if ($_var_name == 'smarty') {
+ /*
+ * If the reference could be compiled, use the compiled output;
+ * otherwise, fall back on the $smarty variable generated at
+ * run-time.
+ */
+ if (($smarty_ref = $this->_compile_smarty_ref($_indexes)) !== null) {
+ $_output = $smarty_ref;
+ } else {
+ $_var_name = substr(array_shift($_indexes), 1);
+ $_output = "\$this->_smarty_vars['$_var_name']";
+ }
+ } elseif(is_numeric($_var_name) && is_numeric($var_expr{0})) {
+ // because . is the operator for accessing arrays thru inidizes we need to put it together again for floating point numbers
+ if(count($_indexes) > 0)
+ {
+ $_var_name .= implode("", $_indexes);
+ $_indexes = array();
+ }
+ $_output = $_var_name;
+ } else {
+ $_output = "\$this->_tpl_vars['$_var_name']";
+ }
+
+ foreach ($_indexes as $_index) {
+ if ($_index{0} == '[') {
+ $_index = substr($_index, 1, -1);
+ if (is_numeric($_index)) {
+ $_output .= "[$_index]";
+ } elseif ($_index{0} == '$') {
+ if (strpos($_index, '.') !== false) {
+ $_output .= '[' . $this->_parse_var($_index) . ']';
+ } else {
+ $_output .= "[\$this->_tpl_vars['" . substr($_index, 1) . "']]";
+ }
+ } else {
+ $_var_parts = explode('.', $_index);
+ $_var_section = $_var_parts[0];
+ $_var_section_prop = isset($_var_parts[1]) ? $_var_parts[1] : 'index';
+ $_output .= "[\$this->_sections['$_var_section']['$_var_section_prop']]";
+ }
+ } else if ($_index{0} == '.') {
+ if ($_index{1} == '$')
+ $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]";
+ else
+ $_output .= "['" . substr($_index, 1) . "']";
+ } else if (substr($_index,0,2) == '->') {
+ if(substr($_index,2,2) == '__') {
+ $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__);
+ } elseif($this->security && substr($_index, 2, 1) == '_') {
+ $this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
+ } elseif ($_index{2} == '$') {
+ if ($this->security) {
+ $this->_syntax_error('(secure) call to dynamic object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
+ } else {
+ $_output .= '->{(($_var=$this->_tpl_vars[\''.substr($_index,3).'\']) && substr($_var,0,2)!=\'__\') ? $_var : $this->trigger_error("cannot access property \\"$_var\\"")}';
+ }
+ } else {
+ $_output .= $_index;
+ }
+ } elseif ($_index{0} == '(') {
+ $_index = $this->_parse_parenth_args($_index);
+ $_output .= $_index;
+ } else {
+ $_output .= $_index;
+ }
+ }
+ }
+
+ return $_output;
+ }
+
+ /**
+ * parse arguments in function call parenthesis
+ *
+ * @param string $parenth_args
+ * @return string
+ */
+ function _parse_parenth_args($parenth_args)
+ {
+ preg_match_all('~' . $this->_param_regexp . '~',$parenth_args, $match);
+ $orig_vals = $match = $match[0];
+ $this->_parse_vars_props($match);
+ $replace = array();
+ for ($i = 0, $count = count($match); $i < $count; $i++) {
+ $replace[$orig_vals[$i]] = $match[$i];
+ }
+ return strtr($parenth_args, $replace);
+ }
+
+ /**
+ * parse configuration variable expression into PHP code
+ *
+ * @param string $conf_var_expr
+ */
+ function _parse_conf_var($conf_var_expr)
+ {
+ $parts = explode('|', $conf_var_expr, 2);
+ $var_ref = $parts[0];
+ $modifiers = isset($parts[1]) ? $parts[1] : '';
+
+ $var_name = substr($var_ref, 1, -1);
+
+ $output = "\$this->_config[0]['vars']['$var_name']";
+
+ $this->_parse_modifiers($output, $modifiers);
+
+ return $output;
+ }
+
+ /**
+ * parse section property expression into PHP code
+ *
+ * @param string $section_prop_expr
+ * @return string
+ */
+ function _parse_section_prop($section_prop_expr)
+ {
+ $parts = explode('|', $section_prop_expr, 2);
+ $var_ref = $parts[0];
+ $modifiers = isset($parts[1]) ? $parts[1] : '';
+
+ preg_match('!%(\w+)\.(\w+)%!', $var_ref, $match);
+ $section_name = $match[1];
+ $prop_name = $match[2];
+
+ $output = "\$this->_sections['$section_name']['$prop_name']";
+
+ $this->_parse_modifiers($output, $modifiers);
+
+ return $output;
+ }
+
+
+ /**
+ * parse modifier chain into PHP code
+ *
+ * sets $output to parsed modified chain
+ * @param string $output
+ * @param string $modifier_string
+ */
+ function _parse_modifiers(&$output, $modifier_string)
+ {
+ preg_match_all('~\|(@?\w+)((?>:(?:'. $this->_qstr_regexp . '|[^|]+))*)~', '|' . $modifier_string, $_match);
+ list(, $_modifiers, $modifier_arg_strings) = $_match;
+
+ for ($_i = 0, $_for_max = count($_modifiers); $_i < $_for_max; $_i++) {
+ $_modifier_name = $_modifiers[$_i];
+
+ if($_modifier_name == 'smarty') {
+ // skip smarty modifier
+ continue;
+ }
+
+ preg_match_all('~:(' . $this->_qstr_regexp . '|[^:]+)~', $modifier_arg_strings[$_i], $_match);
+ $_modifier_args = $_match[1];
+
+ if ($_modifier_name{0} == '@') {
+ $_map_array = false;
+ $_modifier_name = substr($_modifier_name, 1);
+ } else {
+ $_map_array = true;
+ }
+
+ if (empty($this->_plugins['modifier'][$_modifier_name])
+ && !$this->_get_plugin_filepath('modifier', $_modifier_name)
+ && function_exists($_modifier_name)) {
+ if ($this->security && !in_array($_modifier_name, $this->security_settings['MODIFIER_FUNCS'])) {
+ $this->_trigger_fatal_error("[plugin] (secure mode) modifier '$_modifier_name' is not allowed" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);
+ } else {
+ $this->_plugins['modifier'][$_modifier_name] = array($_modifier_name, null, null, false);
+ }
+ }
+ $this->_add_plugin('modifier', $_modifier_name);
+
+ $this->_parse_vars_props($_modifier_args);
+
+ if($_modifier_name == 'default') {
+ // supress notifications of default modifier vars and args
+ if($output{0} == '$') {
+ $output = '@' . $output;
+ }
+ if(isset($_modifier_args[0]) && $_modifier_args[0]{0} == '$') {
+ $_modifier_args[0] = '@' . $_modifier_args[0];
+ }
+ }
+ if (count($_modifier_args) > 0)
+ $_modifier_args = ', '.implode(', ', $_modifier_args);
+ else
+ $_modifier_args = '';
+
+ if ($_map_array) {
+ $output = "((is_array(\$_tmp=$output)) ? \$this->_run_mod_handler('$_modifier_name', true, \$_tmp$_modifier_args) : " . $this->_compile_plugin_call('modifier', $_modifier_name) . "(\$_tmp$_modifier_args))";
+
+ } else {
+
+ $output = $this->_compile_plugin_call('modifier', $_modifier_name)."($output$_modifier_args)";
+
+ }
+ }
+ }
+
+
+ /**
+ * add plugin
+ *
+ * @param string $type
+ * @param string $name
+ * @param boolean? $delayed_loading
+ */
+ function _add_plugin($type, $name, $delayed_loading = null)
+ {
+ if (!isset($this->_plugin_info[$type])) {
+ $this->_plugin_info[$type] = array();
+ }
+ if (!isset($this->_plugin_info[$type][$name])) {
+ $this->_plugin_info[$type][$name] = array($this->_current_file,
+ $this->_current_line_no,
+ $delayed_loading);
+ }
+ }
+
+
+ /**
+ * Compiles references of type $smarty.foo
+ *
+ * @param string $indexes
+ * @return string
+ */
+ function _compile_smarty_ref(&$indexes)
+ {
+ /* Extract the reference name. */
+ $_ref = substr($indexes[0], 1);
+ foreach($indexes as $_index_no=>$_index) {
+ if ($_index{0} != '.' && $_index_no<2 || !preg_match('~^(\.|\[|->)~', $_index)) {
+ $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__);
+ }
+ }
+
+ switch ($_ref) {
+ case 'now':
+ $compiled_ref = 'time()';
+ $_max_index = 1;
+ break;
+
+ case 'foreach':
+ array_shift($indexes);
+ $_var = $this->_parse_var_props(substr($indexes[0], 1));
+ $_propname = substr($indexes[1], 1);
+ $_max_index = 1;
+ switch ($_propname) {
+ case 'index':
+ array_shift($indexes);
+ $compiled_ref = "(\$this->_foreach[$_var]['iteration']-1)";
+ break;
+
+ case 'first':
+ array_shift($indexes);
+ $compiled_ref = "(\$this->_foreach[$_var]['iteration'] <= 1)";
+ break;
+
+ case 'last':
+ array_shift($indexes);
+ $compiled_ref = "(\$this->_foreach[$_var]['iteration'] == \$this->_foreach[$_var]['total'])";
+ break;
+
+ case 'show':
+ array_shift($indexes);
+ $compiled_ref = "(\$this->_foreach[$_var]['total'] > 0)";
+ break;
+
+ default:
+ unset($_max_index);
+ $compiled_ref = "\$this->_foreach[$_var]";
+ }
+ break;
+
+ case 'section':
+ array_shift($indexes);
+ $_var = $this->_parse_var_props(substr($indexes[0], 1));
+ $compiled_ref = "\$this->_sections[$_var]";
+ break;
+
+ case 'get':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_GET' : "\$GLOBALS['HTTP_GET_VARS']";
+ break;
+
+ case 'post':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_POST' : "\$GLOBALS['HTTP_POST_VARS']";
+ break;
+
+ case 'cookies':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_COOKIE' : "\$GLOBALS['HTTP_COOKIE_VARS']";
+ break;
+
+ case 'env':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_ENV' : "\$GLOBALS['HTTP_ENV_VARS']";
+ break;
+
+ case 'server':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_SERVER' : "\$GLOBALS['HTTP_SERVER_VARS']";
+ break;
+
+ case 'session':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_SESSION' : "\$GLOBALS['HTTP_SESSION_VARS']";
+ break;
+
+ /*
+ * These cases are handled either at run-time or elsewhere in the
+ * compiler.
+ */
+ case 'request':
+ if ($this->request_use_auto_globals) {
+ $compiled_ref = '$_REQUEST';
+ break;
+ } else {
+ $this->_init_smarty_vars = true;
+ }
+ return null;
+
+ case 'capture':
+ return null;
+
+ case 'template':
+ $compiled_ref = "'$this->_current_file'";
+ $_max_index = 1;
+ break;
+
+ case 'version':
+ $compiled_ref = "'$this->_version'";
+ $_max_index = 1;
+ break;
+
+ case 'const':
+ if ($this->security && !$this->security_settings['ALLOW_CONSTANTS']) {
+ $this->_syntax_error("(secure mode) constants not permitted",
+ E_USER_WARNING, __FILE__, __LINE__);
+ return;
+ }
+ array_shift($indexes);
+ if (preg_match('!^\.\w+$!', $indexes[0])) {
+ $compiled_ref = '@' . substr($indexes[0], 1);
+ } else {
+ $_val = $this->_parse_var_props(substr($indexes[0], 1));
+ $compiled_ref = '@constant(' . $_val . ')';
+ }
+ $_max_index = 1;
+ break;
+
+ case 'config':
+ $compiled_ref = "\$this->_config[0]['vars']";
+ $_max_index = 3;
+ break;
+
+ case 'ldelim':
+ $compiled_ref = "'$this->left_delimiter'";
+ break;
+
+ case 'rdelim':
+ $compiled_ref = "'$this->right_delimiter'";
+ break;
+
+ default:
+ $this->_syntax_error('$smarty.' . $_ref . ' is an unknown reference', E_USER_ERROR, __FILE__, __LINE__);
+ break;
+ }
+
+ if (isset($_max_index) && count($indexes) > $_max_index) {
+ $this->_syntax_error('$smarty' . implode('', $indexes) .' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ array_shift($indexes);
+ return $compiled_ref;
+ }
+
+ /**
+ * compiles call to plugin of type $type with name $name
+ * returns a string containing the function-name or method call
+ * without the paramter-list that would have follow to make the
+ * call valid php-syntax
+ *
+ * @param string $type
+ * @param string $name
+ * @return string
+ */
+ function _compile_plugin_call($type, $name) {
+ if (isset($this->_plugins[$type][$name])) {
+ /* plugin loaded */
+ if (is_array($this->_plugins[$type][$name][0])) {
+ return ((is_object($this->_plugins[$type][$name][0][0])) ?
+ "\$this->_plugins['$type']['$name'][0][0]->" /* method callback */
+ : (string)($this->_plugins[$type][$name][0][0]).'::' /* class callback */
+ ). $this->_plugins[$type][$name][0][1];
+
+ } else {
+ /* function callback */
+ return $this->_plugins[$type][$name][0];
+
+ }
+ } else {
+ /* plugin not loaded -> auto-loadable-plugin */
+ return 'smarty_'.$type.'_'.$name;
+
+ }
+ }
+
+ /**
+ * load pre- and post-filters
+ */
+ function _load_filters()
+ {
+ if (count($this->_plugins['prefilter']) > 0) {
+ foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) {
+ if ($prefilter === false) {
+ unset($this->_plugins['prefilter'][$filter_name]);
+ $_params = array('plugins' => array(array('prefilter', $filter_name, null, null, false)));
+ require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+ smarty_core_load_plugins($_params, $this);
+ }
+ }
+ }
+ if (count($this->_plugins['postfilter']) > 0) {
+ foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) {
+ if ($postfilter === false) {
+ unset($this->_plugins['postfilter'][$filter_name]);
+ $_params = array('plugins' => array(array('postfilter', $filter_name, null, null, false)));
+ require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+ smarty_core_load_plugins($_params, $this);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Quote subpattern references
+ *
+ * @param string $string
+ * @return string
+ */
+ function _quote_replace($string)
+ {
+ return strtr($string, array('\\' => '\\\\', '$' => '\\$'));
+ }
+
+ /**
+ * display Smarty syntax error
+ *
+ * @param string $error_msg
+ * @param integer $error_type
+ * @param string $file
+ * @param integer $line
+ */
+ function _syntax_error($error_msg, $error_type = E_USER_ERROR, $file=null, $line=null)
+ {
+ $this->_trigger_fatal_error("syntax error: $error_msg", $this->_current_file, $this->_current_line_no, $file, $line, $error_type);
+ }
+
+
+ /**
+ * check if the compilation changes from cacheable to
+ * non-cacheable state with the beginning of the current
+ * plugin. return php-code to reflect the transition.
+ * @return string
+ */
+ function _push_cacheable_state($type, $name) {
+ $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
+ if ($_cacheable
+ || 0<$this->_cacheable_state++) return '';
+ if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty'));
+ $_ret = 'if ($this->caching && !$this->_cache_including) { echo \'{nocache:'
+ . $this->_cache_serial . '#' . $this->_nocache_count
+ . '}\';}';
+ return $_ret;
+ }
+
+
+ /**
+ * check if the compilation changes from non-cacheable to
+ * cacheable state with the end of the current plugin return
+ * php-code to reflect the transition.
+ * @return string
+ */
+ function _pop_cacheable_state($type, $name) {
+ $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
+ if ($_cacheable
+ || --$this->_cacheable_state>0) return '';
+ return 'if ($this->caching && !$this->_cache_including) { echo \'{/nocache:'
+ . $this->_cache_serial . '#' . ($this->_nocache_count++)
+ . '}\';}';
+ }
+
+
+ /**
+ * push opening tag-name, file-name and line-number on the tag-stack
+ * @param string the opening tag's name
+ */
+ function _push_tag($open_tag)
+ {
+ array_push($this->_tag_stack, array($open_tag, $this->_current_line_no));
+ }
+
+ /**
+ * pop closing tag-name
+ * raise an error if this stack-top doesn't match with the closing tag
+ * @param string the closing tag's name
+ * @return string the opening tag's name
+ */
+ function _pop_tag($close_tag)
+ {
+ $message = '';
+ if (count($this->_tag_stack)>0) {
+ list($_open_tag, $_line_no) = array_pop($this->_tag_stack);
+ if ($close_tag == $_open_tag) {
+ return $_open_tag;
+ }
+ if ($close_tag == 'if' && ($_open_tag == 'else' || $_open_tag == 'elseif' )) {
+ return $this->_pop_tag($close_tag);
+ }
+ if ($close_tag == 'section' && $_open_tag == 'sectionelse') {
+ $this->_pop_tag($close_tag);
+ return $_open_tag;
+ }
+ if ($close_tag == 'foreach' && $_open_tag == 'foreachelse') {
+ $this->_pop_tag($close_tag);
+ return $_open_tag;
+ }
+ if ($_open_tag == 'else' || $_open_tag == 'elseif') {
+ $_open_tag = 'if';
+ } elseif ($_open_tag == 'sectionelse') {
+ $_open_tag = 'section';
+ } elseif ($_open_tag == 'foreachelse') {
+ $_open_tag = 'foreach';
+ }
+ $message = " expected {/$_open_tag} (opened line $_line_no).";
+ }
+ $this->_syntax_error("mismatched tag {/$close_tag}.$message",
+ E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+}
+
+/**
+ * compare to values by their string length
+ *
+ * @access private
+ * @param string $a
+ * @param string $b
+ * @return 0|-1|1
+ */
+function _smarty_sort_length($a, $b)
+{
+ if($a == $b)
+ return 0;
+
+ if(strlen($a) == strlen($b))
+ return ($a > $b) ? -1 : 1;
+
+ return (strlen($a) > strlen($b)) ? -1 : 1;
+}
+
+
+/* vim: set et: */
+
+?>
diff --git a/wp-inst/favicon.ico b/wp-inst/favicon.ico
new file mode 100644
index 0000000..4b87ffb
--- /dev/null
+++ b/wp-inst/favicon.ico
Binary files differ
diff --git a/wp-inst/go.php b/wp-inst/go.php
new file mode 100644
index 0000000..c132a02
--- /dev/null
+++ b/wp-inst/go.php
@@ -0,0 +1,37 @@
+<?php
+
+/* $Id: go.php,v 1.3 2005/03/10 09:02:49 donncha Exp $ */
+
+require('./wp-blog-header.php');
+// IMPORTANT :
+// if you don't put this file in your blog root (where your index.php is)
+// then modify the path to wp-blog-header.php above
+
+header('Expires: Mon, 23 Mar 1972 07:00:00 GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache');
+
+if ($_SERVER["QUERY_STRING"]) {
+ $url = $_SERVER["QUERY_STRING"];
+ $url = wp_ozh_click_getrealpath("$url");
+ if( $_SERVER["HTTP_USER_AGENT"] != "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" && $_SERVER["HTTP_USER_AGENT"] != "Googlebot/2.1 (+http://www.google.com/bot.html)" )
+ {
+ $test= wp_ozh_click_increment($url);
+ }
+
+
+ if ($is_IIS) {
+ header("Refresh: 0;url=$url");
+ } else {
+ if( $_SERVER["HTTP_USER_AGENT"] != "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" )
+ {
+ header("HTTP/1.1 301 Moved Permanently");
+ header("Location: $url");
+ }
+ print "<html><head><title>Redirecting to $url</title></head><body>Redirecting to <a href='$url'>$url</a></body></html>";
+ exit;
+ }
+
+} else {
+ echo "Hmmm ? ";
+ echo "<a href=\"" . get_settings('siteurl') . "\">Back to Blog</a> !";
+}
+?>
diff --git a/wp-inst/htaccess.dist b/wp-inst/htaccess.dist
new file mode 100644
index 0000000..9eaaecb
--- /dev/null
+++ b/wp-inst/htaccess.dist
@@ -0,0 +1,5 @@
+RewriteEngine Off
+
+<Files wp-content/blogs>
+ForceType application/x-httpd-php
+</Files>
diff --git a/wp-inst/index.php b/wp-inst/index.php
new file mode 100644
index 0000000..6199abc
--- /dev/null
+++ b/wp-inst/index.php
@@ -0,0 +1,5 @@
+<?php
+/* Short and sweet */
+define('WP_USE_THEMES', true);
+require('./wp-blog-header.php');
+?>
diff --git a/wp-inst/internals/core.assemble_plugin_filepath.php b/wp-inst/internals/core.assemble_plugin_filepath.php
new file mode 100644
index 0000000..690d3dd
--- /dev/null
+++ b/wp-inst/internals/core.assemble_plugin_filepath.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * assemble filepath of requested plugin
+ *
+ * @param string $type
+ * @param string $name
+ * @return string|false
+ */
+function smarty_core_assemble_plugin_filepath($params, &$smarty)
+{
+ static $_filepaths_cache = array();
+
+ $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
+ if (isset($_filepaths_cache[$_plugin_filename])) {
+ return $_filepaths_cache[$_plugin_filename];
+ }
+ $_return = false;
+
+ foreach ((array)$smarty->plugins_dir as $_plugin_dir) {
+
+ $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
+
+ // see if path is relative
+ if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) {
+ $_relative_paths[] = $_plugin_dir;
+ // relative path, see if it is in the SMARTY_DIR
+ if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
+ $_return = SMARTY_DIR . $_plugin_filepath;
+ break;
+ }
+ }
+ // try relative to cwd (or absolute)
+ if (@is_readable($_plugin_filepath)) {
+ $_return = $_plugin_filepath;
+ break;
+ }
+ }
+
+ if($_return === false) {
+ // still not found, try PHP include_path
+ if(isset($_relative_paths)) {
+ foreach ((array)$_relative_paths as $_plugin_dir) {
+
+ $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
+
+ $_params = array('file_path' => $_plugin_filepath);
+ require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
+ if(smarty_core_get_include_path($_params, $smarty)) {
+ $_return = $_params['new_file_path'];
+ break;
+ }
+ }
+ }
+ }
+ $_filepaths_cache[$_plugin_filename] = $_return;
+ return $_return;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.assign_smarty_interface.php b/wp-inst/internals/core.assign_smarty_interface.php
new file mode 100644
index 0000000..7e65a73
--- /dev/null
+++ b/wp-inst/internals/core.assign_smarty_interface.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty assign_smarty_interface core plugin
+ *
+ * Type: core<br>
+ * Name: assign_smarty_interface<br>
+ * Purpose: assign the $smarty interface variable
+ * @param array Format: null
+ * @param Smarty
+ */
+function smarty_core_assign_smarty_interface($params, &$smarty)
+{
+ if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) {
+ return;
+ }
+
+ $_globals_map = array('g' => 'HTTP_GET_VARS',
+ 'p' => 'HTTP_POST_VARS',
+ 'c' => 'HTTP_COOKIE_VARS',
+ 's' => 'HTTP_SERVER_VARS',
+ 'e' => 'HTTP_ENV_VARS');
+
+ $_smarty_vars_request = array();
+
+ foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) {
+ if (isset($_globals_map[$_c])) {
+ $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]);
+ }
+ }
+ $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']);
+
+ $smarty->_smarty_vars['request'] = $_smarty_vars_request;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.create_dir_structure.php b/wp-inst/internals/core.create_dir_structure.php
new file mode 100644
index 0000000..999cf59
--- /dev/null
+++ b/wp-inst/internals/core.create_dir_structure.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * create full directory structure
+ *
+ * @param string $dir
+ */
+
+// $dir
+
+function smarty_core_create_dir_structure($params, &$smarty)
+{
+ if (!file_exists($params['dir'])) {
+ $_open_basedir_ini = ini_get('open_basedir');
+
+ if (DIRECTORY_SEPARATOR=='/') {
+ /* unix-style paths */
+ $_dir = $params['dir'];
+ $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
+ $_new_dir = ($_dir{0}=='/') ? '/' : getcwd().'/';
+ if($_use_open_basedir = !empty($_open_basedir_ini)) {
+ $_open_basedirs = explode(':', $_open_basedir_ini);
+ }
+
+ } else {
+ /* other-style paths */
+ $_dir = str_replace('\\','/', $params['dir']);
+ $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
+ if (preg_match('!^((//)|([a-zA-Z]:/))!', $_dir, $_root_dir)) {
+ /* leading "//" for network volume, or "[letter]:/" for full path */
+ $_new_dir = $_root_dir[1];
+ /* remove drive-letter from _dir_parts */
+ if (isset($_root_dir[3])) array_shift($_dir_parts);
+
+ } else {
+ $_new_dir = str_replace('\\', '/', getcwd()).'/';
+
+ }
+
+ if($_use_open_basedir = !empty($_open_basedir_ini)) {
+ $_open_basedirs = explode(';', str_replace('\\', '/', $_open_basedir_ini));
+ }
+
+ }
+
+ /* all paths use "/" only from here */
+ foreach ($_dir_parts as $_dir_part) {
+ $_new_dir .= $_dir_part;
+
+ if ($_use_open_basedir) {
+ // do not attempt to test or make directories outside of open_basedir
+ $_make_new_dir = false;
+ foreach ($_open_basedirs as $_open_basedir) {
+ if (substr($_new_dir, 0, strlen($_open_basedir)) == $_open_basedir) {
+ $_make_new_dir = true;
+ break;
+ }
+ }
+ } else {
+ $_make_new_dir = true;
+ }
+
+ if ($_make_new_dir && !file_exists($_new_dir) && !@mkdir($_new_dir, $smarty->_dir_perms) && !is_dir($_new_dir)) {
+ $smarty->trigger_error("problem creating directory '" . $_new_dir . "'");
+ return false;
+ }
+ $_new_dir .= '/';
+ }
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.display_debug_console.php b/wp-inst/internals/core.display_debug_console.php
new file mode 100644
index 0000000..a5d7291
--- /dev/null
+++ b/wp-inst/internals/core.display_debug_console.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty debug_console function plugin
+ *
+ * Type: core<br>
+ * Name: display_debug_console<br>
+ * Purpose: display the javascript debug console window
+ * @param array Format: null
+ * @param Smarty
+ */
+function smarty_core_display_debug_console($params, &$smarty)
+{
+ // we must force compile the debug template in case the environment
+ // changed between separate applications.
+
+ if(empty($smarty->debug_tpl)) {
+ // set path to debug template from SMARTY_DIR
+ $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
+ if($smarty->security && is_file($smarty->debug_tpl)) {
+ $smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl));
+ }
+ $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl';
+ }
+
+ $_ldelim_orig = $smarty->left_delimiter;
+ $_rdelim_orig = $smarty->right_delimiter;
+
+ $smarty->left_delimiter = '{';
+ $smarty->right_delimiter = '}';
+
+ $_compile_id_orig = $smarty->_compile_id;
+ $smarty->_compile_id = null;
+
+ $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
+ if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path))
+ {
+ ob_start();
+ $smarty->_include($_compile_path);
+ $_results = ob_get_contents();
+ ob_end_clean();
+ } else {
+ $_results = '';
+ }
+
+ $smarty->_compile_id = $_compile_id_orig;
+
+ $smarty->left_delimiter = $_ldelim_orig;
+ $smarty->right_delimiter = $_rdelim_orig;
+
+ return $_results;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.get_include_path.php b/wp-inst/internals/core.get_include_path.php
new file mode 100644
index 0000000..4343241
--- /dev/null
+++ b/wp-inst/internals/core.get_include_path.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Get path to file from include_path
+ *
+ * @param string $file_path
+ * @param string $new_file_path
+ * @return boolean
+ * @staticvar array|null
+ */
+
+// $file_path, &$new_file_path
+
+function smarty_core_get_include_path(&$params, &$smarty)
+{
+ static $_path_array = null;
+
+ if(!isset($_path_array)) {
+ $_ini_include_path = ini_get('include_path');
+
+ if(strstr($_ini_include_path,';')) {
+ // windows pathnames
+ $_path_array = explode(';',$_ini_include_path);
+ } else {
+ $_path_array = explode(':',$_ini_include_path);
+ }
+ }
+ foreach ($_path_array as $_include_path) {
+ if (@is_readable($_include_path . DIRECTORY_SEPARATOR . $params['file_path'])) {
+ $params['new_file_path'] = $_include_path . DIRECTORY_SEPARATOR . $params['file_path'];
+ return true;
+ }
+ }
+ return false;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.get_microtime.php b/wp-inst/internals/core.get_microtime.php
new file mode 100644
index 0000000..f1a28e0
--- /dev/null
+++ b/wp-inst/internals/core.get_microtime.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Get seconds and microseconds
+ * @return double
+ */
+function smarty_core_get_microtime($params, &$smarty)
+{
+ $mtime = microtime();
+ $mtime = explode(" ", $mtime);
+ $mtime = (double)($mtime[1]) + (double)($mtime[0]);
+ return ($mtime);
+}
+
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.get_php_resource.php b/wp-inst/internals/core.get_php_resource.php
new file mode 100644
index 0000000..786d4e7
--- /dev/null
+++ b/wp-inst/internals/core.get_php_resource.php
@@ -0,0 +1,80 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Retrieves PHP script resource
+ *
+ * sets $php_resource to the returned resource
+ * @param string $resource
+ * @param string $resource_type
+ * @param $php_resource
+ * @return boolean
+ */
+
+function smarty_core_get_php_resource(&$params, &$smarty)
+{
+
+ $params['resource_base_path'] = $smarty->trusted_dir;
+ $smarty->_parse_resource_name($params, $smarty);
+
+ /*
+ * Find out if the resource exists.
+ */
+
+ if ($params['resource_type'] == 'file') {
+ $_readable = false;
+ if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
+ $_readable = true;
+ } else {
+ // test for file in include_path
+ $_params = array('file_path' => $params['resource_name']);
+ require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
+ if(smarty_core_get_include_path($_params, $smarty)) {
+ $_include_path = $_params['new_file_path'];
+ $_readable = true;
+ }
+ }
+ } else if ($params['resource_type'] != 'file') {
+ $_template_source = null;
+ $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
+ && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
+ array($params['resource_name'], &$_template_source, &$smarty));
+ }
+
+ /*
+ * Set the error function, depending on which class calls us.
+ */
+ if (method_exists($smarty, '_syntax_error')) {
+ $_error_funcc = '_syntax_error';
+ } else {
+ $_error_funcc = 'trigger_error';
+ }
+
+ if ($_readable) {
+ if ($smarty->security) {
+ require_once(SMARTY_CORE_DIR . 'core.is_trusted.php');
+ if (!smarty_core_is_trusted($params, $smarty)) {
+ $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted');
+ return false;
+ }
+ }
+ } else {
+ $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable');
+ return false;
+ }
+
+ if ($params['resource_type'] == 'file') {
+ $params['php_resource'] = $params['resource_name'];
+ } else {
+ $params['php_resource'] = $_template_source;
+ }
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.is_secure.php b/wp-inst/internals/core.is_secure.php
new file mode 100644
index 0000000..342f3af
--- /dev/null
+++ b/wp-inst/internals/core.is_secure.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * determines if a resource is secure or not.
+ *
+ * @param string $resource_type
+ * @param string $resource_name
+ * @return boolean
+ */
+
+// $resource_type, $resource_name
+
+function smarty_core_is_secure($params, &$smarty)
+{
+ if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) {
+ return true;
+ }
+
+ if ($params['resource_type'] == 'file') {
+ $_rp = realpath($params['resource_name']);
+ if (isset($params['resource_base_path'])) {
+ foreach ((array)$params['resource_base_path'] as $curr_dir) {
+ if ( ($_cd = realpath($curr_dir)) !== false &&
+ strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
+ $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
+ return true;
+ }
+ }
+ }
+ if (!empty($smarty->secure_dir)) {
+ foreach ((array)$smarty->secure_dir as $curr_dir) {
+ if ( ($_cd = realpath($curr_dir)) !== false &&
+ strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
+ $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
+ return true;
+ }
+ }
+ }
+ } else {
+ // resource is not on local file system
+ return call_user_func_array(
+ $smarty->_plugins['resource'][$params['resource_type']][0][2],
+ array($params['resource_name'], &$smarty));
+ }
+
+ return false;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.is_trusted.php b/wp-inst/internals/core.is_trusted.php
new file mode 100644
index 0000000..f0bd2fb
--- /dev/null
+++ b/wp-inst/internals/core.is_trusted.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * determines if a resource is trusted or not
+ *
+ * @param string $resource_type
+ * @param string $resource_name
+ * @return boolean
+ */
+
+ // $resource_type, $resource_name
+
+function smarty_core_is_trusted($params, &$smarty)
+{
+ $_smarty_trusted = false;
+ if ($params['resource_type'] == 'file') {
+ if (!empty($smarty->trusted_dir)) {
+ $_rp = realpath($params['resource_name']);
+ foreach ((array)$smarty->trusted_dir as $curr_dir) {
+ if (!empty($curr_dir) && is_readable ($curr_dir)) {
+ $_cd = realpath($curr_dir);
+ if (strncmp($_rp, $_cd, strlen($_cd)) == 0
+ && $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
+ $_smarty_trusted = true;
+ break;
+ }
+ }
+ }
+ }
+
+ } else {
+ // resource is not on local file system
+ $_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3],
+ array($params['resource_name'], $smarty));
+ }
+
+ return $_smarty_trusted;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.load_plugins.php b/wp-inst/internals/core.load_plugins.php
new file mode 100644
index 0000000..6db1dc5
--- /dev/null
+++ b/wp-inst/internals/core.load_plugins.php
@@ -0,0 +1,125 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Load requested plugins
+ *
+ * @param array $plugins
+ */
+
+// $plugins
+
+function smarty_core_load_plugins($params, &$smarty)
+{
+
+ foreach ($params['plugins'] as $_plugin_info) {
+ list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info;
+ $_plugin = &$smarty->_plugins[$_type][$_name];
+
+ /*
+ * We do not load plugin more than once for each instance of Smarty.
+ * The following code checks for that. The plugin can also be
+ * registered dynamically at runtime, in which case template file
+ * and line number will be unknown, so we fill them in.
+ *
+ * The final element of the info array is a flag that indicates
+ * whether the dynamically registered plugin function has been
+ * checked for existence yet or not.
+ */
+ if (isset($_plugin)) {
+ if (empty($_plugin[3])) {
+ if (!is_callable($_plugin[0])) {
+ $smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
+ } else {
+ $_plugin[1] = $_tpl_file;
+ $_plugin[2] = $_tpl_line;
+ $_plugin[3] = true;
+ if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */
+ }
+ }
+ continue;
+ } else if ($_type == 'insert') {
+ /*
+ * For backwards compatibility, we check for insert functions in
+ * the symbol table before trying to load them as a plugin.
+ */
+ $_plugin_func = 'insert_' . $_name;
+ if (function_exists($_plugin_func)) {
+ $_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false);
+ continue;
+ }
+ }
+
+ $_plugin_file = $smarty->_get_plugin_filepath($_type, $_name);
+
+ if (! $_found = ($_plugin_file != false)) {
+ $_message = "could not load plugin file '$_type.$_name.php'\n";
+ }
+
+ /*
+ * If plugin file is found, it -must- provide the properly named
+ * plugin function. In case it doesn't, simply output the error and
+ * do not fall back on any other method.
+ */
+ if ($_found) {
+ include_once $_plugin_file;
+
+ $_plugin_func = 'smarty_' . $_type . '_' . $_name;
+ if (!function_exists($_plugin_func)) {
+ $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
+ continue;
+ }
+ }
+ /*
+ * In case of insert plugins, their code may be loaded later via
+ * 'script' attribute.
+ */
+ else if ($_type == 'insert' && $_delayed_loading) {
+ $_plugin_func = 'smarty_' . $_type . '_' . $_name;
+ $_found = true;
+ }
+
+ /*
+ * Plugin specific processing and error checking.
+ */
+ if (!$_found) {
+ if ($_type == 'modifier') {
+ /*
+ * In case modifier falls back on using PHP functions
+ * directly, we only allow those specified in the security
+ * context.
+ */
+ if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) {
+ $_message = "(secure mode) modifier '$_name' is not allowed";
+ } else {
+ if (!function_exists($_name)) {
+ $_message = "modifier '$_name' is not implemented";
+ } else {
+ $_plugin_func = $_name;
+ $_found = true;
+ }
+ }
+ } else if ($_type == 'function') {
+ /*
+ * This is a catch-all situation.
+ */
+ $_message = "unknown tag - '$_name'";
+ }
+ }
+
+ if ($_found) {
+ $smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true);
+ } else {
+ // output error
+ $smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__);
+ }
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.load_resource_plugin.php b/wp-inst/internals/core.load_resource_plugin.php
new file mode 100644
index 0000000..a7d37d1
--- /dev/null
+++ b/wp-inst/internals/core.load_resource_plugin.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * load a resource plugin
+ *
+ * @param string $type
+ */
+
+// $type
+
+function smarty_core_load_resource_plugin($params, &$smarty)
+{
+ /*
+ * Resource plugins are not quite like the other ones, so they are
+ * handled differently. The first element of plugin info is the array of
+ * functions provided by the plugin, the second one indicates whether
+ * all of them exist or not.
+ */
+
+ $_plugin = &$smarty->_plugins['resource'][$params['type']];
+ if (isset($_plugin)) {
+ if (!$_plugin[1] && count($_plugin[0])) {
+ $_plugin[1] = true;
+ foreach ($_plugin[0] as $_plugin_func) {
+ if (!is_callable($_plugin_func)) {
+ $_plugin[1] = false;
+ break;
+ }
+ }
+ }
+
+ if (!$_plugin[1]) {
+ $smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__);
+ }
+
+ return;
+ }
+
+ $_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']);
+ $_found = ($_plugin_file != false);
+
+ if ($_found) { /*
+ * If the plugin file is found, it -must- provide the properly named
+ * plugin functions.
+ */
+ include_once($_plugin_file);
+
+ /*
+ * Locate functions that we require the plugin to provide.
+ */
+ $_resource_ops = array('source', 'timestamp', 'secure', 'trusted');
+ $_resource_funcs = array();
+ foreach ($_resource_ops as $_op) {
+ $_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op;
+ if (!function_exists($_plugin_func)) {
+ $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__);
+ return;
+ } else {
+ $_resource_funcs[] = $_plugin_func;
+ }
+ }
+
+ $smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true);
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.process_cached_inserts.php b/wp-inst/internals/core.process_cached_inserts.php
new file mode 100644
index 0000000..29cb007
--- /dev/null
+++ b/wp-inst/internals/core.process_cached_inserts.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Replace cached inserts with the actual results
+ *
+ * @param string $results
+ * @return string
+ */
+function smarty_core_process_cached_inserts($params, &$smarty)
+{
+ preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
+ $params['results'], $match);
+ list($cached_inserts, $insert_args) = $match;
+
+ for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $debug_start_time = smarty_core_get_microtime($_params, $smarty);
+ }
+
+ $args = unserialize($insert_args[$i]);
+ $name = $args['name'];
+
+ if (isset($args['script'])) {
+ $_params = array('resource_name' => $smarty->_dequote($args['script']));
+ require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
+ if(!smarty_core_get_php_resource($_params, $smarty)) {
+ return false;
+ }
+ $resource_type = $_params['resource_type'];
+ $php_resource = $_params['php_resource'];
+
+
+ if ($resource_type == 'file') {
+ $smarty->_include($php_resource, true);
+ } else {
+ $smarty->_eval($php_resource);
+ }
+ }
+
+ $function_name = $smarty->_plugins['insert'][$name][0];
+ if (empty($args['assign'])) {
+ $replace = $function_name($args, $smarty);
+ } else {
+ $smarty->assign($args['assign'], $function_name($args, $smarty));
+ $replace = '';
+ }
+
+ $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']);
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $smarty->_smarty_debug_info[] = array('type' => 'insert',
+ 'filename' => 'insert_'.$name,
+ 'depth' => $smarty->_inclusion_depth,
+ 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time);
+ }
+ }
+
+ return $params['results'];
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.process_compiled_include.php b/wp-inst/internals/core.process_compiled_include.php
new file mode 100644
index 0000000..3e1d4c1
--- /dev/null
+++ b/wp-inst/internals/core.process_compiled_include.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Replace nocache-tags by results of the corresponding non-cacheable
+ * functions and return it
+ *
+ * @param string $compiled_tpl
+ * @param string $cached_source
+ * @return string
+ */
+
+function smarty_core_process_compiled_include($params, &$smarty)
+{
+ $_cache_including = $smarty->_cache_including;
+ $smarty->_cache_including = true;
+
+ $_return = $params['results'];
+ foreach ($smarty->_cache_serials as $_include_file_path=>$_cache_serial) {
+ $_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s',
+ array(&$smarty, '_process_compiled_include_callback'),
+ $_return);
+ }
+ $smarty->_cache_including = $_cache_including;
+ return $_return;
+}
+
+?>
diff --git a/wp-inst/internals/core.read_cache_file.php b/wp-inst/internals/core.read_cache_file.php
new file mode 100644
index 0000000..ecb1470
--- /dev/null
+++ b/wp-inst/internals/core.read_cache_file.php
@@ -0,0 +1,111 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * read a cache file, determine if it needs to be
+ * regenerated or not
+ *
+ * @param string $tpl_file
+ * @param string $cache_id
+ * @param string $compile_id
+ * @param string $results
+ * @return boolean
+ */
+
+// $tpl_file, $cache_id, $compile_id, &$results
+
+function smarty_core_read_cache_file(&$params, &$smarty)
+{
+ static $content_cache = array();
+
+ if ($smarty->force_compile) {
+ // force compile enabled, always regenerate
+ return false;
+ }
+
+ if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) {
+ list($params['results'], $smarty->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']];
+ return true;
+ }
+
+ if (!empty($smarty->cache_handler_func)) {
+ // use cache_handler function
+ call_user_func_array($smarty->cache_handler_func,
+ array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
+ } else {
+ // use local cache file
+ $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
+ $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);
+ $params['results'] = $smarty->_read_file($_cache_file);
+ }
+
+ if (empty($params['results'])) {
+ // nothing to parse (error?), regenerate cache
+ return false;
+ }
+
+ $_contents = $params['results'];
+ $_info_start = strpos($_contents, "\n") + 1;
+ $_info_len = (int)substr($_contents, 0, $_info_start - 1);
+ $_cache_info = unserialize(substr($_contents, $_info_start, $_info_len));
+ $params['results'] = substr($_contents, $_info_start + $_info_len);
+
+ if ($smarty->caching == 2 && isset ($_cache_info['expires'])){
+ // caching by expiration time
+ if ($_cache_info['expires'] > -1 && (time() > $_cache_info['expires'])) {
+ // cache expired, regenerate
+ return false;
+ }
+ } else {
+ // caching by lifetime
+ if ($smarty->cache_lifetime > -1 && (time() - $_cache_info['timestamp'] > $smarty->cache_lifetime)) {
+ // cache expired, regenerate
+ return false;
+ }
+ }
+
+ if ($smarty->compile_check) {
+ $_params = array('get_source' => false, 'quiet'=>true);
+ foreach (array_keys($_cache_info['template']) as $_template_dep) {
+ $_params['resource_name'] = $_template_dep;
+ if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
+ // template file has changed, regenerate cache
+ return false;
+ }
+ }
+
+ if (isset($_cache_info['config'])) {
+ $_params = array('resource_base_path' => $smarty->config_dir, 'get_source' => false, 'quiet'=>true);
+ foreach (array_keys($_cache_info['config']) as $_config_dep) {
+ $_params['resource_name'] = $_config_dep;
+ if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
+ // config file has changed, regenerate cache
+ return false;
+ }
+ }
+ }
+ }
+
+ foreach ($_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) {
+ if (empty($smarty->_cache_serials[$_include_file_path])) {
+ $smarty->_include($_include_file_path, true);
+ }
+
+ if ($smarty->_cache_serials[$_include_file_path] != $_cache_serial) {
+ /* regenerate */
+ return false;
+ }
+ }
+ $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info);
+
+ $smarty->_cache_info = $_cache_info;
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.rm_auto.php b/wp-inst/internals/core.rm_auto.php
new file mode 100644
index 0000000..b251f64
--- /dev/null
+++ b/wp-inst/internals/core.rm_auto.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * delete an automagically created file by name and id
+ *
+ * @param string $auto_base
+ * @param string $auto_source
+ * @param string $auto_id
+ * @param integer $exp_time
+ * @return boolean
+ */
+
+// $auto_base, $auto_source = null, $auto_id = null, $exp_time = null
+
+function smarty_core_rm_auto($params, &$smarty)
+{
+ if (!@is_dir($params['auto_base']))
+ return false;
+
+ if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
+ $_params = array(
+ 'dirname' => $params['auto_base'],
+ 'level' => 0,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
+ $_res = smarty_core_rmdir($_params, $smarty);
+ } else {
+ $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);
+
+ if(isset($params['auto_source'])) {
+ if (isset($params['extensions'])) {
+ $_res = false;
+ foreach ((array)$params['extensions'] as $_extension)
+ $_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']);
+ } else {
+ $_res = $smarty->_unlink($_tname, $params['exp_time']);
+ }
+ } elseif ($smarty->use_sub_dirs) {
+ $_params = array(
+ 'dirname' => $_tname,
+ 'level' => 1,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
+ $_res = smarty_core_rmdir($_params, $smarty);
+ } else {
+ // remove matching file names
+ $_handle = opendir($params['auto_base']);
+ $_res = true;
+ while (false !== ($_filename = readdir($_handle))) {
+ if($_filename == '.' || $_filename == '..') {
+ continue;
+ } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
+ $_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
+ }
+ }
+ }
+ }
+
+ return $_res;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.rmdir.php b/wp-inst/internals/core.rmdir.php
new file mode 100644
index 0000000..4fdbccc
--- /dev/null
+++ b/wp-inst/internals/core.rmdir.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * delete a dir recursively (level=0 -> keep root)
+ * WARNING: no tests, it will try to remove what you tell it!
+ *
+ * @param string $dirname
+ * @param integer $level
+ * @param integer $exp_time
+ * @return boolean
+ */
+
+// $dirname, $level = 1, $exp_time = null
+
+function smarty_core_rmdir($params, &$smarty)
+{
+ if(!isset($params['level'])) { $params['level'] = 1; }
+ if(!isset($params['exp_time'])) { $params['exp_time'] = null; }
+
+ if($_handle = @opendir($params['dirname'])) {
+
+ while (false !== ($_entry = readdir($_handle))) {
+ if ($_entry != '.' && $_entry != '..') {
+ if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) {
+ $_params = array(
+ 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry,
+ 'level' => $params['level'] + 1,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
+ smarty_core_rmdir($_params, $smarty);
+ }
+ else {
+ $smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']);
+ }
+ }
+ }
+ closedir($_handle);
+ }
+
+ if ($params['level']) {
+ return @rmdir($params['dirname']);
+ }
+ return (bool)$_handle;
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.run_insert_handler.php b/wp-inst/internals/core.run_insert_handler.php
new file mode 100644
index 0000000..71c3845
--- /dev/null
+++ b/wp-inst/internals/core.run_insert_handler.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Handle insert tags
+ *
+ * @param array $args
+ * @return string
+ */
+function smarty_core_run_insert_handler($params, &$smarty)
+{
+
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ if ($smarty->debugging) {
+ $_params = array();
+ $_debug_start_time = smarty_core_get_microtime($_params, $smarty);
+ }
+
+ if ($smarty->caching) {
+ $_arg_string = serialize($params['args']);
+ $_name = $params['args']['name'];
+ if (!isset($smarty->_cache_info['insert_tags'][$_name])) {
+ $smarty->_cache_info['insert_tags'][$_name] = array('insert',
+ $_name,
+ $smarty->_plugins['insert'][$_name][1],
+ $smarty->_plugins['insert'][$_name][2],
+ !empty($params['args']['script']) ? true : false);
+ }
+ return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5;
+ } else {
+ if (isset($params['args']['script'])) {
+ $_params = array('resource_name' => $smarty->_dequote($params['args']['script']));
+ require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
+ if(!smarty_core_get_php_resource($_params, $smarty)) {
+ return false;
+ }
+
+ if ($_params['resource_type'] == 'file') {
+ $smarty->_include($_params['php_resource'], true);
+ } else {
+ $smarty->_eval($_params['php_resource']);
+ }
+ unset($params['args']['script']);
+ }
+
+ $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0];
+ $_content = $_funcname($params['args'], $smarty);
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $smarty->_smarty_debug_info[] = array('type' => 'insert',
+ 'filename' => 'insert_'.$params['args']['name'],
+ 'depth' => $smarty->_inclusion_depth,
+ 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
+ }
+
+ if (!empty($params['args']["assign"])) {
+ $smarty->assign($params['args']["assign"], $_content);
+ } else {
+ return $_content;
+ }
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.smarty_include_php.php b/wp-inst/internals/core.smarty_include_php.php
new file mode 100644
index 0000000..30c6e76
--- /dev/null
+++ b/wp-inst/internals/core.smarty_include_php.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * called for included php files within templates
+ *
+ * @param string $smarty_file
+ * @param string $smarty_assign variable to assign the included template's
+ * output into
+ * @param boolean $smarty_once uses include_once if this is true
+ * @param array $smarty_include_vars associative array of vars from
+ * {include file="blah" var=$var}
+ */
+
+// $file, $assign, $once, $_smarty_include_vars
+
+function smarty_core_smarty_include_php($params, &$smarty)
+{
+ $_params = array('resource_name' => $params['smarty_file']);
+ require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
+ smarty_core_get_php_resource($_params, $smarty);
+ $_smarty_resource_type = $_params['resource_type'];
+ $_smarty_php_resource = $_params['php_resource'];
+
+ if (!empty($params['smarty_assign'])) {
+ ob_start();
+ if ($_smarty_resource_type == 'file') {
+ $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
+ } else {
+ $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
+ }
+ $smarty->assign($params['smarty_assign'], ob_get_contents());
+ ob_end_clean();
+ } else {
+ if ($_smarty_resource_type == 'file') {
+ $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
+ } else {
+ $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
+ }
+ }
+}
+
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.write_cache_file.php b/wp-inst/internals/core.write_cache_file.php
new file mode 100644
index 0000000..72f785b
--- /dev/null
+++ b/wp-inst/internals/core.write_cache_file.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Prepend the cache information to the cache file
+ * and write it
+ *
+ * @param string $tpl_file
+ * @param string $cache_id
+ * @param string $compile_id
+ * @param string $results
+ * @return true|null
+ */
+
+ // $tpl_file, $cache_id, $compile_id, $results
+
+function smarty_core_write_cache_file($params, &$smarty)
+{
+
+ // put timestamp in cache header
+ $smarty->_cache_info['timestamp'] = time();
+ if ($smarty->cache_lifetime > -1){
+ // expiration set
+ $smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime;
+ } else {
+ // cache will never expire
+ $smarty->_cache_info['expires'] = -1;
+ }
+
+ // collapse nocache.../nocache-tags
+ if (preg_match_all('!\{(/?)nocache\:[0-9a-f]{32}#\d+\}!', $params['results'], $match, PREG_PATTERN_ORDER)) {
+ // remove everything between every pair of outermost noache.../nocache-tags
+ // and replace it by a single nocache-tag
+ // this new nocache-tag will be replaced by dynamic contents in
+ // smarty_core_process_compiled_includes() on a cache-read
+
+ $match_count = count($match[0]);
+ $results = preg_split('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!', $params['results'], -1, PREG_SPLIT_DELIM_CAPTURE);
+
+ $level = 0;
+ $j = 0;
+ for ($i=0, $results_count = count($results); $i < $results_count && $j < $match_count; $i++) {
+ if ($results[$i] == $match[0][$j]) {
+ // nocache tag
+ if ($match[1][$j]) { // closing tag
+ $level--;
+ unset($results[$i]);
+ } else { // opening tag
+ if ($level++ > 0) unset($results[$i]);
+ }
+ $j++;
+ } elseif ($level > 0) {
+ unset($results[$i]);
+ }
+ }
+ $params['results'] = implode('', $results);
+ }
+ $smarty->_cache_info['cache_serials'] = $smarty->_cache_serials;
+
+ // prepend the cache header info into cache file
+ $_cache_info = serialize($smarty->_cache_info);
+ $params['results'] = strlen($_cache_info) . "\n" . $_cache_info . $params['results'];
+
+ if (!empty($smarty->cache_handler_func)) {
+ // use cache_handler function
+ call_user_func_array($smarty->cache_handler_func,
+ array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
+ } else {
+ // use local cache file
+
+ if(!@is_writable($smarty->cache_dir)) {
+ // cache_dir not writable, see if it exists
+ if(!@is_dir($smarty->cache_dir)) {
+ $smarty->trigger_error('the $cache_dir \'' . $smarty->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
+ return false;
+ }
+ $smarty->trigger_error('unable to write to $cache_dir \'' . realpath($smarty->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR);
+ return false;
+ }
+
+ $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
+ $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);
+ $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true);
+ require_once(SMARTY_CORE_DIR . 'core.write_file.php');
+ smarty_core_write_file($_params, $smarty);
+ return true;
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.write_compiled_include.php b/wp-inst/internals/core.write_compiled_include.php
new file mode 100644
index 0000000..5e0b2e0
--- /dev/null
+++ b/wp-inst/internals/core.write_compiled_include.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Extract non-cacheable parts out of compiled template and write it
+ *
+ * @param string $compile_path
+ * @param string $template_compiled
+ * @return boolean
+ */
+
+function smarty_core_write_compiled_include($params, &$smarty)
+{
+ $_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
+ $_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
+
+ preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
+ $params['compiled_content'], $_match_source, PREG_SET_ORDER);
+
+ // no nocache-parts found: done
+ if (count($_match_source)==0) return;
+
+ // convert the matched php-code to functions
+ $_include_compiled = "<?php /* Smarty version ".$smarty->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
+ $_include_compiled .= " compiled from " . strtr(urlencode($params['resource_name']), array('%2F'=>'/', '%3A'=>':')) . " */\n\n";
+
+ $_compile_path = $params['include_file_path'];
+
+ $smarty->_cache_serials[$_compile_path] = $params['cache_serial'];
+ $_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>";
+
+ $_include_compiled .= $params['plugins_code'];
+ $_include_compiled .= "<?php";
+
+ $this_varname = ((double)phpversion() >= 5.0) ? '_smarty' : 'this';
+ for ($_i = 0, $_for_max = count($_match_source); $_i < $_for_max; $_i++) {
+ $_match =& $_match_source[$_i];
+ $source = $_match[4];
+ if ($this_varname == '_smarty') {
+ /* rename $this to $_smarty in the sourcecode */
+ $tokens = token_get_all('<?php ' . $_match[4]);
+
+ /* remove trailing <?php */
+ $open_tag = '';
+ while ($tokens) {
+ $token = array_shift($tokens);
+ if (is_array($token)) {
+ $open_tag .= $token[1];
+ } else {
+ $open_tag .= $token;
+ }
+ if ($open_tag == '<?php ') break;
+ }
+
+ for ($i=0, $count = count($tokens); $i < $count; $i++) {
+ if (is_array($tokens[$i])) {
+ if ($tokens[$i][0] == T_VARIABLE && $tokens[$i][1] == '$this') {
+ $tokens[$i] = '$' . $this_varname;
+ } else {
+ $tokens[$i] = $tokens[$i][1];
+ }
+ }
+ }
+ $source = implode('', $tokens);
+ }
+
+ /* add function to compiled include */
+ $_include_compiled .= "
+function _smarty_tplfunc_$_match[2]_$_match[3](&\$$this_varname)
+{
+$source
+}
+
+";
+ }
+ $_include_compiled .= "\n\n?>\n";
+
+ $_params = array('filename' => $_compile_path,
+ 'contents' => $_include_compiled, 'create_dirs' => true);
+
+ require_once(SMARTY_CORE_DIR . 'core.write_file.php');
+ smarty_core_write_file($_params, $smarty);
+ return true;
+}
+
+
+?>
diff --git a/wp-inst/internals/core.write_compiled_resource.php b/wp-inst/internals/core.write_compiled_resource.php
new file mode 100644
index 0000000..b902eff
--- /dev/null
+++ b/wp-inst/internals/core.write_compiled_resource.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * write the compiled resource
+ *
+ * @param string $compile_path
+ * @param string $compiled_content
+ * @return true
+ */
+function smarty_core_write_compiled_resource($params, &$smarty)
+{
+ if(!@is_writable($smarty->compile_dir)) {
+ // compile_dir not writable, see if it exists
+ if(!@is_dir($smarty->compile_dir)) {
+ $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
+ return false;
+ }
+ $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR);
+ return false;
+ }
+
+ $_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true);
+ require_once(SMARTY_CORE_DIR . 'core.write_file.php');
+ smarty_core_write_file($_params, $smarty);
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/internals/core.write_file.php b/wp-inst/internals/core.write_file.php
new file mode 100644
index 0000000..09e1698
--- /dev/null
+++ b/wp-inst/internals/core.write_file.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * write out a file to disk
+ *
+ * @param string $filename
+ * @param string $contents
+ * @param boolean $create_dirs
+ * @return boolean
+ */
+function smarty_core_write_file($params, &$smarty)
+{
+ $_dirname = dirname($params['filename']);
+
+ if ($params['create_dirs']) {
+ $_params = array('dir' => $_dirname);
+ require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php');
+ smarty_core_create_dir_structure($_params, $smarty);
+ }
+
+ // write to tmp file, then rename it to avoid
+ // file locking race condition
+ $_tmp_file = tempnam($_dirname, 'wrt');
+
+ if (!($fd = @fopen($_tmp_file, 'wb'))) {
+ $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
+ if (!($fd = @fopen($_tmp_file, 'wb'))) {
+ $smarty->trigger_error("problem writing temporary file '$_tmp_file'");
+ return false;
+ }
+ }
+
+ fwrite($fd, $params['contents']);
+ fclose($fd);
+
+ // Delete the file if it allready exists (this is needed on Win,
+ // because it cannot overwrite files with rename()
+ if (file_exists($params['filename'])) {
+ @unlink($params['filename']);
+ }
+ @rename($_tmp_file, $params['filename']);
+ @chmod($params['filename'], $smarty->_file_perms);
+
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/license.txt b/wp-inst/license.txt
new file mode 100644
index 0000000..8882205
--- /dev/null
+++ b/wp-inst/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/wp-inst/maintenance.php b/wp-inst/maintenance.php
new file mode 100644
index 0000000..faef3f7
--- /dev/null
+++ b/wp-inst/maintenance.php
@@ -0,0 +1,29 @@
+<?php
+/*
+Call this file in a secure manner. You could set up a cron job to do it:
+0 2,7,12,16,20 * * * (/usr/bin/lynx --dump http://localhost/maintenance.php) 2> /dev/null
+
+You don't want others deleting your cache!
+*/
+die( 'You must delete line 2 of '.$_SERVER[ 'PHP_SELF' ].' for it to work!' ); // delete this line when you've secured this file.
+
+if( $_SERVER[ 'REMOTE_ADDR' ] == '127.0.0.1' )
+{
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*0" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*1" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*2" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*3" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*4" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*5" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*6" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*7" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*8" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*9" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*a" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*b" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*c" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*d" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*e" );
+ exec( "rm -f ./wp-content/smarty-cache/function_cache/*f" );
+}
+?>
diff --git a/wp-inst/mm-newblog.php b/wp-inst/mm-newblog.php
new file mode 100644
index 0000000..5fcd2f6
--- /dev/null
+++ b/wp-inst/mm-newblog.php
@@ -0,0 +1,172 @@
+<?php
+require('wp-config.php');
+
+get_header();
+?>
+<div id="content" class="widecolumn">
+<style type="text/css">
+form { margin-top: 2em; }
+td input {
+ width: 90%;
+ font-size: 24px;
+}
+.error {
+ background-color: #FF6666;
+}
+</style>
+<?php
+
+if ($_POST) {
+
+$username = $_POST['username'];
+$email = $_POST['email' ];
+$blogname = stripslashes($_POST['blogname']);
+
+$username = sanitize_title($username);
+
+$user_error = $email_error = $blog_error = false;
+
+if ( empty( $username ) )
+ $user_error = true;
+if ( $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$username'") )
+ $user_error = true;
+
+if ( !is_email($email ) )
+ $email_error = true;
+
+if ( empty( $blogname ) )
+ $blog_error = true;
+
+if ( $user_error || $email_error || $blog_error ) {
+?>
+<h2>There was an error</h2>
+<form method="post" action="">
+<?php if ( !$user_error || !$email_error || !$blog_error ) : ?>
+<p>This info was fine:</p>
+<ul>
+<?php if ( !$user_error ) : ?>
+ <li><strong>Username:</strong> <?php echo $username; ?><input name="username" type="hidden" id="username" value="<?php echo $username; ?>" /></li>
+<?php endif; ?>
+<?php if ( !$blog_error ) : ?>
+ <li><strong>Blog Name:</strong> <?php echo $blogname; ?><input name="blogname" type="hidden" id="blogname" value="<?php echo wp_specialchars($blogname, 1); ?>" /></li>
+<?php endif; ?>
+<?php if ( !$email_error ) : ?>
+ <li><strong>Email Address:</strong>
+ <?php echo $email; ?><input name="email" type="hidden" value="<?php echo wp_specialchars($email, 1); ?>" /></li>
+<?php endif; ?>
+</ul>
+<?php endif; ?>
+
+<p>There was a problem with the following, please correct it below and try again.</p>
+
+ <table width="100%" >
+<?php if ( $user_error ) : ?>
+ <tr class="error">
+ <th valign="top" scope="row">Username: </th>
+ <td>
+ <input name="username" type="text" id="username" value="<?php echo $username; ?>" maxlength="50" />
+ <br />
+ (This will also be your blog address. Letters and numbers only, please.)
+ </td>
+ </tr>
+<?php endif; ?>
+
+<?php if ( $blog_error ) : ?>
+ <tr class="error">
+ <th valign="top" scope="row">Blog Name: </th>
+ <td><input name="blogname" type="text" id="blogname" value="<?php echo wp_specialchars($blogname, 1); ?>" />
+ <br>
+ (Don't worry, you can change it later.) </td>
+ </tr>
+<?php endif; ?>
+
+<?php if ( $email_error ) : ?>
+ <tr class="error">
+ <th valign="top" scope="row">Email Address: </th>
+ <td><p>
+ <input name="email" type="text" maxlength="200" value="<?php echo wp_specialchars($email, 1); ?>" />
+ <br />
+ (Did you type in your address wrong?)
+ </p>
+ </td>
+ </tr>
+<?php endif; ?>
+ <tr>
+ <th scope="row">&nbsp;</th>
+ <td><input type="submit" class="submit" name="Submit" value="Try Again &raquo;" /></td>
+ </tr>
+ </table>
+</form>
+<?php
+} else {
+
+$main_host = $_SERVER['HTTP_HOST'];
+$main_host = str_replace('www.', '', $main_host);
+
+$base_path = dirname( $_SERVER['SCRIPT_NAME'] );
+$base_path = str_replace('wp-inst', '',$result);
+if( strlen( $base_path > 1 ) && substr($base_path, -1 ) == '/')
+ $base_path = substr($base_path, 0, -1);
+
+define( 'WP_INSTALLING', true );
+require_once('./wp-config.php');
+$setup = true;
+
+if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ $host = $username . '.' . $main_host;
+ $path = '/';
+} else {
+ $host = $main_host;
+ $path = $base_path . '/' . $username;
+}
+
+
+$err = createBlog( $_SERVER[ 'HTTP_HOST' ], $host, $path, $username, $blogname, $email, $username );
+
+?>
+<h2>You've got a new blog</h2>
+<h3>Your new address is <a href="http://<?php echo $domain . $path; ?>"><?php echo $domain . $path; ?></a></h3>
+<p>You should receive an email with the login details shortly.</p>
+<?php
+} // if error
+} else {
+?>
+
+<h2>Get your own blog</h2>
+
+<form method="post" action="">
+ <table width="100%" >
+ <tr>
+ <th valign="top" scope="row">Username: </th>
+ <td>
+ <input name="username" type="text" id="username" maxlength="50" />
+ <br />
+ (This will also be your blog address. Letters and numbers only, please.)
+ </td>
+ </tr>
+ <tr>
+ <th valign="top" scope="row">Blog Name: </th>
+ <td><input name="blogname" type="text" id="blogname">
+ <br>
+ (Don't worry, you can change it later.) </td>
+ </tr>
+ <tr>
+ <th valign="top" scope="row">Email Address: </th>
+ <td><p>
+ <input name="email" type="text" maxlength="200" />
+ <br />
+ (We'll send a password to this address, so double-check it.)
+ </p>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row">&nbsp;</th>
+ <td><input type="submit" name="Submit" class="submit" value="Sign Up &raquo;" /></td>
+ </tr>
+ </table>
+</form>
+<?php
+} // if post
+?>
+</div>
+<?php get_footer(); ?> \ No newline at end of file
diff --git a/wp-inst/pages b/wp-inst/pages
new file mode 100644
index 0000000..500ecc5
--- /dev/null
+++ b/wp-inst/pages
@@ -0,0 +1,57 @@
+<?php /* Don't remove these lines, they call the b2 function files ! */
+
+/* $Id: pages,v 1.1.1.1 2004/10/14 12:07:23 donncha Exp $ */
+
+$blog = 1;
+if( is_file( "wp-config.php" ) == false )
+{
+ $nosetup = true;
+ include( "../index.php" );
+ die();
+}
+require_once('wp-blog-header.php');
+// not on by default: require_once(ABSPATH.'wp-links/links.weblogs.com.php');
+
+define( 'NODISPLAY', false );
+
+$siteurl = get_settings( 'siteurl' );
+$wpsmarty->assign( 'siteurl', $siteurl );
+$wpsmarty->assign( 'wp_version', $wp_version );
+$wpsmarty->assign( 'wpblog', $wpblog );
+
+get_currentuserinfo();
+
+// Required for caching single posts - useful to put it here anyway
+// as this code would be run multiple times including each wp-comments.php
+$comment_author = (isset($_COOKIE['comment_author_'.$cookiehash])) ? trim($_COOKIE['comment_author_'.$cookiehash]) : '';
+$comment_author_email = (isset($_COOKIE['comment_author_email_'.$cookiehash])) ? trim($_COOKIE['comment_author_email_'.$cookiehash]) : '';
+$comment_author_url = (isset($_COOKIE['comment_author_url_'.$cookiehash])) ? trim($_COOKIE['comment_author_url_'.$cookiehash]) : '';
+
+if( count( $posts ) == 1 )
+{
+ $smartyKey = md5( $comment_author_url.$comment_author.$comment_author_email.$user_login.$_SERVER[ 'REQUEST_URI' ] );
+}
+else
+{
+ $smartyKey = md5( $user_login.$_SERVER[ 'REQUEST_URI' ] );
+}
+
+if( $wpsmarty->is_cached( "index.html", $smartyKey ) == false )
+{
+ $uri = split( '/', $_SERVER[ 'REQUEST_URI' ] );
+ $tpl = $uri[ count( $uri ) - 2 ];
+ $results = $wpdb->get_results( "select * from ".$wpdb->posts." where post_name='".$tpl."'", ARRAY_A );
+ if( is_array( $results ) )
+ {
+ $content = $results[0]['post_content'];
+ }
+ else
+ {
+ $content = "Page Does Not Exist.";
+ }
+ $wpsmarty->assign( 'content', $content );
+}
+
+$wpsmarty->display( 'index.html', $smartyKey );
+
+?>
diff --git a/wp-inst/readme.html b/wp-inst/readme.html
new file mode 100644
index 0000000..88feb37
--- /dev/null
+++ b/wp-inst/readme.html
@@ -0,0 +1,126 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>WordPress &rsaquo; ReadMe</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style type="text/css" media="screen">
+ <!--
+ html {
+ background: #eee;
+ }
+ body {
+ background: #fff;
+ color: #000;
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 25%;
+ margin-right: 25%;
+ padding: .2em 2em;
+ }
+
+ h1 {
+ color: #006;
+ font-size: 18px;
+ font-weight: lighter;
+ }
+
+ h2 {
+ font-size: 16px;
+ }
+
+ p, li, dt {
+ line-height: 140%;
+ padding-bottom: 2px;
+ }
+
+ ul, ol {
+ padding: 5px 5px 5px 20px;
+ }
+ -->
+ </style>
+</head>
+<body>
+<h1 style="text-align: center"><img alt="WordPress" src="http://wordpress.org/images/wordpress.gif" /> <br />
+ Version 1.5</h1>
+<p style="text-align: center"> Semantic Personal Publishing Platform </p>
+<h1>First Things First</h1>
+<p>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.</p>
+<p style="text-align: right;">&#8212; Matt Mullenweg </p>
+
+<h1 id="installation">Installation: Famous 5-minute install</h1>
+<ol>
+ <li>Unzip the package in an empty directory</li>
+ <li>Open up <code>wp-config-sample.php</code> with a text editor like WordPad or similar and fill in your database connection details</li>
+ <li>Save the file as <code>wp-config.php</code> </li>
+ <li>Upload everything.</li>
+ <li>Launch <span class="file"><a href="wp-admin/install.php">/wp-admin/install.php</a></span> in your browser. This should setup the tables needed for your blog. If there is an error, double check your <span class="file">wp-config.php</span> file, and try again. If it fails again, please go to the <a href="http://wordpress.org/support/">support forums</a> with as much data as you can gather. </li>
+ <li><strong>Note the password given to you.</strong></li>
+ <li> The install script should then send you to the <a href="wp-login.php">login page</a>. Sign in with the username <code>admin</code> and the password generated during the installation. You can then click on 'Profile' to change the password.</li>
+</ol>
+
+<h1>Upgrading</h1>
+<p>Before you upgrade anything, make sure you have backup copies of any files you may have modified such as <code>index.php</code>.</p>
+<h2>Upgrading from any previous WordPress to 1.5:</h2>
+<ol>
+ <li>Delete your old WP files, saving ones you've modified </li>
+ <li>Upload the new files</li>
+ <li>Point your browser to <span class="file"><a href="wp-admin/upgrade.php">/wp-admin/upgrade.php</a></span></li>
+ <li>You wanted more, perhaps? That's it!</li>
+</ol>
+<h2>Template Changes</h2>
+<p>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, <a href="http://codex.wordpress.org/Upgrade_1.2_to_1.5">we've created a special guide for you</a>. </p>
+<h1>Online Resources</h1>
+<p>If you have any questions that aren't addressed in this document, please take advantage of WordPress' numerous online resources:</p>
+<dl>
+ <dt><a href="http://codex.wordpress.org/">The WordPress Codex </a></dt>
+ <dd>The Codex is the encyclopedia of all things WordPress. It is the most comprehensive source of information for WordPress available. </dd>
+ <dt><a href="http://wordpress.org/development/">The Development Blog</a></dt>
+ <dd>This is where you'll find the latest updates and news related to WordPress. Bookmark and check often. </dd>
+ <dt><a href="http://planet.wordpress.org/">WordPress Planet </a></dt>
+ <dd>The WordPress Planet is a news aggregator that brings together posts from WordPress blogs around the web. </dd>
+ <dt><a href="http://wordpress.org/support/">WordPress Support Forums</a></dt>
+ <dd>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. </dd>
+ <dt><a href="http://codex.wordpress.org/IRC">WordPress IRC Channel</a></dt>
+ <dd>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) </dd>
+</dl>
+
+<h1 id="requirements">System Recommendations</h1>
+<ul>
+ <li>PHP version <strong>4.1</strong> or higher</li>
+ <li>MySQL version <strong>3.23.23</strong> or higher</li>
+ <li>... and a link to <a href="http://wordpress.org">http://wordpress.org</a> on your site.</li>
+</ul>
+<p>WordPress is the official continuation of <a href="http://cafelog.com/">b2/caf&eacute;log</a>, which came from Michel V. The work has been continued by the <a href="http://wordpress.org/about/">WordPress developers</a>. If you would like to support WordPress, please consider <a href="http://wordpress.org/donate/">donating</a>. </p>
+
+<h1>Upgrading from another system</h1>
+<p>WordPress can <a href="http://codex.wordpress.org/Importing_from_other_blogging_software">import from a number of systems</a>. First you need to get WordPress installed and working as described above.</p>
+
+<h1 id="templates">XML-RPC Interface</h1>
+<p>You can now post to your WordPress blog with tools like <a href="http://ecto.kung-foo.tv/">Ecto</a>, <a href="http://blogbuddy.sourceforge.net">BlogBuddy</a>, <a href="http://bloggar.com/">Bloggar</a>, <a href="http://www.ubique.ch/wapblogger/">WapBlogger</a> (post from your Wap cellphone!), <a href="http://radio.userland.com">Radio Userland</a> (which means you can use Radio's email-to-blog feature), <a href="http://www.zempt.com/">Zempt</a>, <a href="http://www.newzcrawler.com/">NewzCrawler</a>, and other tools that support the Blogging APIs! :) You can read more about <a href="http://codex.wordpress.org/XML-RPC_Support">XML-RPC support on the Codex</a>.</p>
+
+<h1>Post via Email</h1>
+<p>You can post from an email client! To set this up go to your &quot;Writing&quot; options screen and fill in the connection details for your secret POP3 account. Then you need to set up <code>wp-mail.php</code> 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 <code>wp-mail.php</code> URL. </p>
+<p> 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 <i>delete</i> emails that are successfully posted. </p>
+<h1 id="notes">User Levels </h1>
+<p>You may allow or disallow user registration in your <a href="wp-admin/options-general.php">General options</a>. If &quot;new users can blog&quot; is disabled you must first raise the level of a newly registered user to allow them to post. Click the plus sign next to their name on the <a href="wp-admin/users.php">Users</a> page. </p>
+<h2>User Levels</h2>
+<ul>
+ <li>0 - New User </li>
+ <li>1 - User can post, edit, and delete their own posts.</li>
+ <li>5+ - Admin; can post, edit, delete other people's posts, and change the options.</li>
+ <li>Any user whose level is higher than 1, can edit and delete the posts and change the level of lower users. Example: a level 2 user is not an admin, but can edit the posts of level 1 users, and up the level of a new user from 0 to 1.</li>
+</ul>
+<p>Usually you want to have a team of level 1 users except for you.</p>
+<h1> Final notes</h1>
+<ul>
+ <li>If you have any suggestions, ideas, comments, or if you (gasp!) found a bug, join us in the <a href="http://wordpress.org/support/">Support Forums</a></li>
+ <li>WordPress now has a robust plugin API that makes extending the code easy. If you are a developer interested in utilizing this see the <a href="http://codex.wordpress.org/Plugin_API">plugin documentation in the Codex</a>. In most all cases you shouldn't modify any of the core code.</li>
+</ul>
+
+<h1>Share the Love</h1>
+<p>WordPress has no multi-million dollar marketing campaign or celebrity sponsors, but we do have something even better&#8212;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.</p>
+
+<h1>Copyright</h1>
+<p>WordPress is released under the <abbr title="GNU Public License">GPL</abbr> (see <a href="license.txt">license.txt</a>).</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/wp-inst/wp-admin/admin-db.php b/wp-inst/wp-admin/admin-db.php
new file mode 100644
index 0000000..b657edd
--- /dev/null
+++ b/wp-inst/wp-admin/admin-db.php
@@ -0,0 +1,90 @@
+<?php
+
+function get_users_drafts( $user_id ) {
+ global $wpdb;
+ $user_id = (int) $user_id;
+ $query = "SELECT ID, post_title FROM $wpdb->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';
+ if ( 1 < $user->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' ");
+ }
+ } else {
+ $other_drafts = false;
+ }
+ return apply_filters('get_others_drafts', $other_drafts);
+}
+
+function get_editable_authors( $user_id ) {
+ global $wpdb;
+ $user = get_userdata( $user_id );
+ $level_key = $wpdb->prefix . 'user_level';
+
+ if ( 7 > $user->user_level ) // TODO: ROLE SYSTEM
+ return false;
+
+ $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 = get_userdata( $user_id );
+ $level_key = $wpdb->prefix . 'user_level';
+
+ $query = "SELECT * FROM $wpdb->usermeta WHERE meta_key = '$level_key'";
+ if ( $exclude_zeros )
+ $query .= " AND meta_value != '0'";
+ $possible = $wpdb->get_results( $query );
+
+ if ( !$possible )
+ return false;
+
+ $user_ids = array();
+ foreach ( $possible as $mark )
+ if ( intval($mark->meta_value) <= $user->user_level )
+ $user_ids[] = $mark->user_id;
+ if ( empty( $user_ids ) )
+ return false;
+ return $user_ids;
+}
+
+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 );
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/admin-footer.php b/wp-inst/wp-admin/admin-footer.php
new file mode 100644
index 0000000..14b832b
--- /dev/null
+++ b/wp-inst/wp-admin/admin-footer.php
@@ -0,0 +1,13 @@
+
+<div id="footer"><p><a href="http://wordpress.org/"><img src="../wp-images/wp-small.png" alt="WordPress" /></a><br />
+<?php bloginfo('version'); ?> <br />
+<a href="http://codex.wordpress.org/"><?php _e('Documentation'); ?></a> &#8212; <a href="http://wordpress.org/support/"><?php _e('Support Forums'); ?></a> <br />
+<?php printf(__('%s seconds'), number_format(timer_stop(), 2)); ?>
+</p>
+
+</div>
+
+<?php do_action('admin_footer', ''); ?>
+
+</body>
+</html> \ No newline at end of file
diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php
new file mode 100644
index 0000000..cb3fcff
--- /dev/null
+++ b/wp-inst/wp-admin/admin-functions.php
@@ -0,0 +1,1398 @@
+<?php
+
+// Creates a new post from the "Write Post" form using $_POST information.
+function write_post() {
+ global $user_ID;
+
+ if ( !user_can_create_draft($user_ID) )
+ die( __('You are not allowed to create posts or drafts on this blog.') );
+
+ // Rename.
+ $_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 ( !user_can_edit_user($user_ID, $_POST['post_author']) )
+ die( __('You cannot post as this user.') );
+
+ if ( 'publish' == $_POST['post_status'] && (!user_can_create_post($user_ID)) )
+ $_POST['post_status'] = 'draft';
+
+ // 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 (user_can_set_post_date($user_ID) && (!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");
+ }
+
+ // Create the post.
+ $post_ID = wp_insert_post($_POST);
+ add_meta($post_ID);
+
+ return $post_ID;
+}
+
+// Update an existing post with values provided in $_POST.
+function edit_post() {
+ global $user_ID;
+
+ if ( !isset($blog_ID) )
+ $blog_ID = 1;
+
+ $post_ID = (int) $_POST['post_ID'];
+
+ if (!user_can_edit_post($user_ID, $post_ID, $blog_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 ( !user_can_edit_user($user_ID, $_POST['post_author']) )
+ die( __('You cannot post as this user.') );
+
+ if (user_can_set_post_date($user_ID) && (!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");
+ }
+
+ wp_update_post($_POST);
+
+ // Meta Stuff
+ if ($_POST['meta']) :
+ foreach ($_POST['meta'] as $key => $value) :
+ update_meta($key, $value['key'], $value['value']);
+ endforeach;
+ endif;
+
+ if ($_POST['deletemeta']) :
+ foreach ($_POST['deletemeta'] as $key => $value) :
+ delete_meta($key);
+ endforeach;
+ endif;
+
+ add_meta($post_ID);
+}
+
+function edit_comment() {
+ global $user_ID;
+
+ $comment_ID = (int) $_POST['comment_ID'];
+ $comment_post_ID = (int) $_POST['comment_post_ID'];
+
+ if (!user_can_edit_post_comments($user_ID, $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 (user_can_edit_post_date($user_ID, $post_ID) && (!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) {
+ $post = get_post($id);
+
+ $post->post_content = format_to_edit($post->post_content);
+ $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() {
+ global $content, $excerpt, $edited_post_title;
+
+ $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');
+ $content = wp_specialchars($content);
+ $post->post_content = apply_filters('default_content', $content);
+ $post->post_title = apply_filters('default_title', $edited_post_title);
+ $post->post_excerpt = apply_filters('default_excerpt', $excerpt);
+ $post->page_template = 'default';
+ $post->post_parent = 0;
+ $post->menu_order = 0;
+
+ return $post;
+}
+
+function get_comment_to_edit($id) {
+ $comment = get_comment($id);
+
+ $comment->comment_content = format_to_edit($comment->comment_content);
+ $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;
+}
+
+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;
+ $id_result = $wpdb->get_row("SHOW TABLE STATUS LIKE '$wpdb->categories'");
+ $cat_ID = $id_result->Auto_increment;
+ }
+
+ $cat_name = wp_specialchars($cat_name);
+
+ if ( empty($category_nicename) )
+ $category_nicename = sanitize_title($cat_name, $cat_ID);
+ else
+ $category_nicename = sanitize_title($category_nicename, $cat_ID);
+
+ if ( empty($category_description) )
+ $category_description = '';
+
+ if ( empty($category_parent) )
+ $category_parent = 0;
+
+ if ( !$update)
+ $query = "INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')";
+ else
+ $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'";
+
+ $result = $wpdb->query($query);
+
+ if ( $update ) {
+ $rval = $wpdb->rows_affected;
+ do_action('edit_category', $cat_ID);
+ } else {
+ $rval = $wpdb->insert_id;
+ do_action('create_category', $cat_ID);
+ }
+
+ return $rval;
+}
+
+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'");
+
+ do_action('delete_category', $cat_ID);
+
+ return 1;
+}
+
+function wp_delete_user($id) {
+ global $wpdb;
+
+ $id = (int) $id;
+
+ $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
+
+ if ($post_ids) {
+ $post_ids = implode(',', $post_ids);
+
+ // Delete comments, *backs
+ $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)");
+ // Clean cats
+ $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)");
+ // Clean post_meta
+ $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)");
+ // Clean links
+ $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
+ // Delete posts
+ $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id");
+ }
+
+ // FINALLY, delete user
+ $wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id");
+
+ do_action('delete_user', $id);
+
+ return true;
+}
+
+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, $sortbyname = FALSE )
+{
+ /*
+ * This function returns an list of all categories
+ * that have $parent as their parent
+ * if no parent is specified we will assume top level caegories
+ * are required.
+ */
+ global $wpdb;
+
+ // select sort order
+ $sort = "cat_id";
+ if( TRUE == $sortbyname )
+ {
+ $sort = "cat_name";
+ }
+
+ // First query the database
+ $cats_tmp = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY $sort");
+
+ // Now strip this down to a simple array of IDs
+ $cats = array();
+ if( count($cats_tmp) > 0 )
+ {
+ foreach( $cats_tmp as $cat )
+ {
+ $cats[] = $cat->cat_ID;
+ }
+ }
+
+ // Return the list of categories
+ return $cats;
+}
+
+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, TRUE);
+ $result = array();
+
+ 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);
+ }
+
+ return $result;
+}
+
+function write_nested_categories($categories) {
+ foreach($categories as $category) {
+ echo '<label for="category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'],
+ '" type="checkbox" name="post_category[]" id="category-', $category['cat_ID'], '"',
+ ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label>\n";
+
+ if(isset($category['children'])) {
+ echo "\n<span class='cat-nest'>\n";
+ write_nested_categories($category['children']);
+ echo "</span>\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, $current_user;
+
+ $user_level = $current_user->user_level;
+
+ 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);
+ $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
+ $pad = str_repeat('&#8212; ', $level);
+ if ( $user_level > 3 )
+ $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>" . __('Edit') . "</a></td><td><a href='categories.php?action=delete&amp;cat_ID=$category->cat_ID' onclick=\"return confirm('". 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."), $wpdb->escape($category->cat_name)) . "')\" class='delete'>" . __('Delete') . "</a>";
+ else
+ $edit = '';
+
+ $class = ('alternate' == $class) ? '' : 'alternate';
+ echo "<tr class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td>
+ <td>$category->category_description</td>
+ <td>$count</td>
+ <td>$edit</td>
+ </tr>";
+ cat_rows($category->cat_ID, $level + 1, $categories);
+ }
+ }
+ } else {
+ return false;
+ }
+}
+
+function page_rows( $parent = 0, $level = 0, $pages = 0 ) {
+ global $wpdb, $class, $user_level, $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('&#8212; ', $level);
+ $id = $post->ID;
+ $class = ('alternate' == $class) ? '' : 'alternate';
+?>
+ <tr class='<?php echo $class; ?>'>
+ <th scope="row"><?php echo $post->ID; ?></th>
+ <td>
+ <?php echo $pad; ?><?php the_title() ?>
+ </td>
+ <td><?php the_author() ?></td>
+ <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>
+ <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
+ <td><?php if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
+ <td><?php if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), the_title('','',0)) . "')\">" . __('Delete') . "</a>"; } ?></td>
+ </tr>
+
+<?php
+ page_rows($id, $level + 1, $pages);
+ }
+ }
+ } else {
+ return false;
+ }
+}
+
+function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {
+ global $wpdb, $bgcolor;
+ if (!$categories) {
+ $categories = $wpdb->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('&#8211; ', $level);
+ $category->cat_name = wp_specialchars($category->cat_name);
+ echo "\n\t<option value='$category->cat_ID'";
+ if ($currentparent == $category->cat_ID)
+ echo " selected='selected'";
+ echo ">$pad$category->cat_name</option>";
+ wp_dropdown_cats($currentcat, $currentparent, $category->cat_ID, $level + 1, $categories);
+ } }
+ } else {
+ return false;
+ }
+}
+
+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]);
+
+ // move the thumbnail to it's final destination
+
+ $path = explode('/', $file);
+ $thumbpath = substr($file, 0, strrpos($file, '/')) . '/thumb-' . $path[count($path)-1];
+
+ 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");
+ }
+ }
+
+ }
+ }
+
+ if(!empty($error))
+ {
+ return $error;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+// 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;
+?>
+<table id='meta-list' cellpadding="3">
+ <tr>
+ <th><?php _e('Key') ?></th>
+ <th><?php _e('Value') ?></th>
+ <th colspan='2'><?php _e('Action') ?></th>
+ </tr>
+<?php
+
+ foreach ($meta as $entry) {
+ ++$count;
+ if ( $count % 2 ) $style = 'alternate';
+ else $style = '';
+ if ( '_' == $entry['meta_key']{0} ) $style .= ' hidden';
+ echo "
+ <tr class='$style'>
+ <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>
+ <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>
+ <td align='center' width='10%'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='" . __('Update') ."' /></td>
+ <td align='center' width='10%'><input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='" . __('Delete') ."' /></td>
+ </tr>
+";
+ }
+ echo "
+ </table>
+";
+}
+
+// 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");
+?>
+<h3><?php _e('Add a new custom field to this post:') ?></h3>
+<table cellspacing="3" cellpadding="3">
+ <tr>
+<th colspan="2"><?php _e('Key') ?></th>
+<th><?php _e('Value') ?></th>
+</tr>
+ <tr valign="top">
+ <td align="right" width="18%">
+<?php if ($keys) : ?>
+<select id="metakeyselect" name="metakeyselect" tabindex="7">
+<option value="#NONE#"><?php _e('- Select -'); ?></option>
+<?php
+ foreach($keys as $key) {
+ echo "\n\t<option value='$key'>$key</option>";
+ }
+?>
+</select> <?php _e('or'); ?>
+<?php endif; ?>
+</td>
+<td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td>
+ <td><textarea id="metavalue" name="metavalue" rows="3" cols="25" tabindex="8"></textarea></td>
+ </tr>
+
+</table>
+<p class="submit"><input type="submit" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
+<?php
+}
+
+function add_meta($post_ID) {
+ global $wpdb;
+
+ $metakeyselect = $wpdb->escape( stripslashes( trim($_POST['metakeyselect']) ) );
+ $metakeyinput = $wpdb->escape( stripslashes( trim($_POST['metakeyinput']) ) );
+ $metavalue = $wpdb->escape( stripslashes( trim($_POST['metavalue']) ) );
+
+ if (!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, $postdata, $commentdata;
+ if ( $for_post && ('draft' == $postdata->post_status) ) {
+ $checked = 'checked="checked" ';
+ $edit = false;
+ } else {
+ $checked = ' ';
+ }
+
+ echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" '.$checked.'/> <label for="timestamp">' . __('Edit timestamp') . '</label></legend>';
+
+ $time_adj = time() + (get_settings('gmt_offset') * 3600);
+ $post_date = ($for_post) ? $postdata->post_date : $commentdata['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 "<select name=\"mm\">\n";
+ for ($i=1; $i < 13; $i=$i+1) {
+ echo "\t\t\t<option value=\"$i\"";
+ if ($i == $mm)
+ echo " selected='selected'";
+ if ($i < 10) {
+ $ii = "0".$i;
+ } else {
+ $ii = "$i";
+ }
+ echo ">".$month["$ii"]."</option>\n";
+ }
+
+?>
+</select>
+<input type="text" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" />
+<input type="text" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" /> @
+<input type="text" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" /> :
+<input type="text" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" />
+<input type="hidden" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
+<?php _e('Existing timestamp'); ?>:
+ <?php
+ // We might need to readjust to display proper existing timestamp
+ if ( $for_post && ('draft' == $postdata->post_status) ) {
+ $jj = mysql2date('d', $post_date);
+ $mm = mysql2date('m', $post_date);
+ $aa = mysql2date('Y', $post_date);
+ $hh = mysql2date('H', $post_date);
+ $mn = mysql2date('i', $post_date);
+ $ss = mysql2date('s', $post_date);
+ }
+ echo "{$month[$mm]} $jj, $aa @ $hh:$mn"; ?>
+</fieldset>
+ <?php
+}
+
+function check_admin_referer() {
+ $adminurl = strtolower( get_settings('siteurl') ) . '/wp-admin';
+ $referer = strtolower( $_SERVER['HTTP_REFERER'] );
+ if ( !strstr($referer, $adminurl) )
+ die(__('Sorry, you need to <a href="http://codex.wordpress.org/Enable_Sending_Referrers">enable sending referrers</a> for this feature to work.'));
+ do_action('check_admin_referer');
+}
+
+// insert_with_markers: Owen Winkler
+// Inserts an array of strings into a file (.htaccess), placing it between
+// BEGIN and END markers. Replaces existing marked info. Retains surrounding
+// data. Creates file if none exists.
+// Returns true on write success, false on failure.
+function insert_with_markers($filename, $marker, $insertion) {
+ if (!file_exists($filename) || is_writeable($filename)) {
+ if (!file_exists($filename)) {
+ $markerdata = '';
+ } else {
+ $markerdata = explode("\n", implode('', file($filename)));
+ }
+
+ $f = fopen($filename, 'w');
+ $foundit = false;
+ if ($markerdata) {
+ $state = true;
+ $newline = '';
+ foreach($markerdata as $markerline) {
+ if (strstr($markerline, "# BEGIN {$marker}")) $state = false;
+ if ($state) fwrite($f, "{$newline}{$markerline}");
+ if (strstr($markerline, "# END {$marker}")) {
+ fwrite($f, "{$newline}# BEGIN {$marker}");
+ if(is_array($insertion)) foreach($insertion as $insertline) fwrite($f, "{$newline}{$insertline}");
+ fwrite($f, "{$newline}# END {$marker}");
+ $state = true;
+ $foundit = true;
+ }
+ $newline = "\n";
+ }
+ }
+ if (!$foundit) {
+ fwrite($f, "# BEGIN {$marker}\n");
+ foreach($insertion as $insertline) fwrite($f, "{$insertline}\n");
+ fwrite($f, "# END {$marker}");
+ }
+ fclose($f);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// insert_with_markers: Owen Winkler
+// Returns an array of strings from a file (.htaccess) from between BEGIN
+// and END markers.
+function extract_from_markers($filename, $marker) {
+ $result = array();
+
+ if (!file_exists($filename)) {
+ return $result;
+ }
+
+ if($markerdata = explode("\n", implode('', file($filename))));
+ {
+ $state = false;
+ foreach($markerdata as $markerline) {
+ if(strstr($markerline, "# END {$marker}")) $state = false;
+ if($state) $result[] = $markerline;
+ if(strstr($markerline, "# BEGIN {$marker}")) $state = true;
+ }
+ }
+
+ return $result;
+}
+
+function save_mod_rewrite_rules() {
+ global $is_apache, $wp_rewrite;
+ $home_path = get_home_path();
+
+ if (! $wp_rewrite->using_mod_rewrite_permalinks())
+ return;
+
+ if ( ! ((!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')) )
+ return;
+
+ if (! $is_apache)
+ 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 '
+ <div id="quicktags">
+ <script src="quicktags.js" type="text/javascript"></script>
+ <script type="text/javascript">edToolbar();</script>
+';
+ echo '</div>';
+endif;
+}
+
+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<option value='" . $templates[$template] . "' $selected>$template</option>";
+ 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('&nbsp;', $level * 3);
+ if ($item->ID == $default)
+ $current = ' selected="selected"';
+ else
+ $current = '';
+
+ echo "\n\t<option value='$item->ID'$current>$pad $item->post_title</option>";
+ parent_dropdown($default, $item->ID, $level + 1);
+ }
+ } else {
+ return false;
+ }
+}
+
+function user_can_access_admin_page() {
+ global $pagenow;
+ global $menu;
+ global $submenu;
+ global $user_level;
+
+ $parent = get_admin_page_parent();
+
+ foreach ($menu as $menu_array) {
+ //echo "parent array: " . $menu_array[2];
+ if ($menu_array[2] == $parent) {
+ if ($user_level < $menu_array[1]) {
+ return false;
+ } else {
+ break;
+ }
+ }
+ }
+
+ if (isset($submenu[$parent])) {
+ foreach ($submenu[$parent] as $submenu_array) {
+ if ($submenu_array[2] == $pagenow) {
+ if ($user_level < $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;
+ }
+
+ $parent = 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])) {
+ $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])) {
+ $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 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&#8217;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&#8217;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 Template'),
+ 'style.css' => __('Stylesheet'),
+ 'comments.php' => __('Comments Template'),
+ 'comments-popup.php' => __('Popup Comments Template'),
+ 'footer.php' => __('Footer Template'),
+ 'header.php' => __('Header Template'),
+ 'sidebar.php' => __('Sidebar Template'),
+ 'archive.php' => __('Archive Template'),
+ 'category.php' => __('Category Template'),
+ 'page.php' => __('Page Template'),
+ 'search.php' => __('Search Template'),
+ 'single.php' => __('Post Template'),
+ '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 = '<a href="' . $plugin_uri[1] . '" title="' . __('Visit plugin homepage') . '">' . $plugin . '</a>';
+ }
+
+ if ('' == $author_uri[1]) {
+ $author = $author_name[1];
+ } else {
+ $author = '<a href="' . $author_uri[1] . '" title="' . __('Visit author homepage') . '">' . $author_name[1] . '</a>';
+ }
+
+ return array('Name' => $name, 'Title' => $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) {
+ $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 pimp_firefox() {
+ if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'Firefox' ) )
+ return;
+ $getit = __('WordPress recommends the open-source Firefox browser');
+ echo '
+ <p id="firefoxlink" style="text-align: center;"><a href="http://spreadfirefox.com/community/?q=affiliates&amp;id=2490&amp;t=1" title="' . $getit . '"><img src="../wp-images/get-firefox.png" alt="Get Firefox" /></a></p>
+ ';
+}
+add_action('admin_footer', 'pimp_firefox');
+
+function documentation_link( $for ) {
+ return;
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/admin-header.php b/wp-inst/wp-admin/admin-header.php
new file mode 100644
index 0000000..fb52818
--- /dev/null
+++ b/wp-inst/wp-admin/admin-header.php
@@ -0,0 +1,104 @@
+<?php
+@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
+if (!isset($_GET["page"])) require_once('admin.php'); ?>
+<?php get_admin_page_title(); ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
+<link rel="stylesheet" href="<?php echo get_settings('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
+
+<script type="text/javascript">
+//<![CDATA[
+
+function customToggleLink() {
+ // TODO: Only show link if there's a hidden row
+ document.write('<small>(<a href="javascript:;" id="customtoggle" onclick="toggleHidden()"><?php _e('Show hidden'); ?></a>)</small>');
+ // TODO: Rotate link to say "show" or "hide"
+ // TODO: Use DOM
+}
+
+function toggleHidden() {
+ var allElements = document.getElementsByTagName('tr');
+ for (i = 0; i < allElements.length; i++) {
+ if ( allElements[i].className.indexOf('hidden') != -1 ) {
+ allElements[i].className = allElements[i].className.replace('hidden', '');
+ }
+ }
+}
+
+<?php if ( isset($xfn) ) : ?>
+
+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('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;
+ }
+}
+
+window.onload = blurry;
+<?php endif; ?>
+
+
+//]]>
+</script>
+
+<?php if ( isset( $editing ) ) : ?>
+<script type="text/javascript" src="dbx.js"></script>
+<script type="text/javascript" src="dbx-key.js"></script>
+<?php endif; ?>
+
+<?php do_action('admin_head', ''); ?>
+</head>
+<body>
+
+<div id="wphead">
+<h1><?php echo wptexturize(get_settings(('blogname'))); ?> <span>(<a href="<?php echo get_settings('home') . '/'; ?>"><?php _e('View site') ?> &raquo;</a>)</span></h1>
+</div>
+
+<?php
+require(ABSPATH . '/wp-admin/menu-header.php');
+
+if ( $parent_file == 'options-general.php' ) {
+ require(ABSPATH . '/wp-admin/options-head.php');
+}
+?>
diff --git a/wp-inst/wp-admin/admin.php b/wp-inst/wp-admin/admin.php
new file mode 100644
index 0000000..64e602a
--- /dev/null
+++ b/wp-inst/wp-admin/admin.php
@@ -0,0 +1,69 @@
+<?php
+if ( defined('ABSPATH') )
+ require_once( ABSPATH . 'wp-config.php');
+else
+ require_once('../wp-config.php');
+
+require_once(ABSPATH . 'wp-admin/admin-functions.php');
+require_once(ABSPATH . 'wp-admin/admin-db.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<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+require(ABSPATH . '/wp-admin/menu.php');
+
+// Handle plugin admin pages.
+if (isset($_GET['page'])) {
+ $plugin_page = plugin_basename($_GET['page']);
+ $page_hook = get_plugin_page_hook($plugin_page, $pagenow);
+
+ if ( $page_hook ) {
+ if (! isset($_GET['noheader']))
+ require_once(ABSPATH . '/wp-admin/admin-header.php');
+
+ do_action($page_hook);
+ } else {
+ if ( validate_file($plugin_page) ) {
+ die(__('Invalid plugin page'));
+ }
+
+ if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page"))
+ die(sprintf(__('Cannot load %s.'), $plugin_page));
+
+ if (! isset($_GET['noheader']))
+ require_once(ABSPATH . '/wp-admin/admin-header.php');
+
+ include(ABSPATH . "wp-content/plugins/$plugin_page");
+ }
+
+ include(ABSPATH . 'wp-admin/admin-footer.php');
+
+ exit();
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/bookmarklet.php b/wp-inst/wp-admin/bookmarklet.php
new file mode 100644
index 0000000..555abee
--- /dev/null
+++ b/wp-inst/wp-admin/bookmarklet.php
@@ -0,0 +1,108 @@
+<?php
+$mode = 'bookmarklet';
+require_once('admin.php');
+
+if ($user_level == 0)
+ die ("Cheatin' uh?");
+
+if ('b' == $a) {
+
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<script type="text/javascript">
+<!--
+window.close()
+-->
+</script>
+</head>
+<body></body>
+</html>
+<?php
+} else {
+ $popuptitle = wp_specialchars(stripslashes($popuptitle));
+ $text = wp_specialchars(stripslashes(urldecode($text)));
+
+ $popuptitle = funky_javascript_fix($popuptitle);
+ $text = funky_javascript_fix($text);
+
+ $post_title = wp_specialchars($_REQUEST['post_title']);
+ if (!empty($post_title)) {
+ $post_title = stripslashes($post_title);
+ } else {
+ $post_title = $popuptitle;
+ }
+
+ $edited_post_title = wp_specialchars($post_title);
+
+// $post_pingback needs to be set in any file that includes edit-form.php
+ $post_pingback = get_settings('default_pingback_flag');
+
+ $content = wp_specialchars($_REQUEST['content']);
+ $popupurl = wp_specialchars($_REQUEST['popupurl']);
+ if ( !empty($content) ) {
+ $content = wp_specialchars( stripslashes($_REQUEST['content']) );
+ } else {
+ $content = '<a href="'.$popupurl.'">'.$popuptitle.'</a>'."\n$text";
+ }
+
+ /* /big funky fixes */
+
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title><?php bloginfo('name') ?> &rsaquo; Bookmarklet &#8212; WordPress</title>
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
+<link rel="stylesheet" href="wp-admin.css" type="text/css" />
+
+<style type="text/css">
+<!--
+
+#wpbookmarklet textarea,input,select {
+ border-width: 1px;
+ border-color: #cccccc;
+ border-style: solid;
+ padding: 2px;
+ margin: 1px;
+}
+
+#wpbookmarklet .checkbox {
+ background-color: #ffffff;
+ border-width: 0px;
+ padding: 0px;
+ margin: 0px;
+}
+
+#wpbookmarklet textarea {
+ font-family: Verdana, Geneva, Arial, Helvetica;
+ font-size: 0.9em;
+}
+
+#wpbookmarklet .wrap {
+ border: 0px;
+}
+
+#wpbookmarklet #postdiv {
+ margin-bottom: 0.5em;
+}
+
+#wpbookmarklet #titlediv {
+ margin-bottom: 1em;
+}
+
+-->
+</style>
+</head>
+<body id="wpbookmarklet">
+<div id="wphead">
+<h1><?php bloginfo('name') ?></h1>
+</div>
+
+<?php require('edit-form.php'); ?>
+
+<?php do_action('admin_footer', ''); ?>
+
+</body>
+</html><?php
+}
+?>
diff --git a/wp-inst/wp-admin/categories.php b/wp-inst/wp-admin/categories.php
new file mode 100644
index 0000000..5b327be
--- /dev/null
+++ b/wp-inst/wp-admin/categories.php
@@ -0,0 +1,167 @@
+<?php
+require_once('admin.php');
+
+$title = __('Categories');
+$parent_file = 'edit.php';
+
+$wpvarstoreset = array('action','cat');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+switch($action) {
+
+case 'addcat':
+
+ if ($user_level < 3)
+ die (__('Cheatin&#8217; uh?'));
+
+ wp_insert_category($_POST);
+
+ header('Location: categories.php?message=1#addcat');
+break;
+
+case 'delete':
+
+ check_admin_referer();
+
+ if ( $user_level < 3 )
+ die (__('Cheatin&#8217; uh?'));
+
+ $cat_ID = (int) $_GET['cat_ID'];
+ $cat_name = get_catname($cat_ID);
+
+ if ( 1 == $cat_ID )
+ die(sprintf(__("Can't delete the <strong>%s</strong> 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);
+ ?>
+
+<div class="wrap">
+ <h2><?php _e('Edit Category') ?></h2>
+ <form name="editcat" action="categories.php" method="post">
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="33%" scope="row"><?php _e('Category name:') ?></th>
+ <td width="67%"><input name="cat_name" type="text" value="<?php echo wp_specialchars($category->cat_name); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" />
+<input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Category slug:') ?></th>
+ <td><input name="category_nicename" type="text" value="<?php echo wp_specialchars($category->category_nicename); ?>" size="40" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Category parent:') ?></th>
+ <td>
+ <select name='category_parent'>
+ <option value='0' <?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option>
+ <?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?>
+ </select></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Description:') ?></th>
+ <td><textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description, 1); ?></textarea></td>
+ </tr>
+ </table>
+ <p class="submit"><input type="submit" name="submit" value="<?php _e('Edit category') ?> &raquo;" /></p>
+ </form>
+ <p><a href="categories.php"><?php _e('&laquo; Return to category list'); ?></a></p>
+</div>
+ <?php
+
+break;
+
+case 'editedcat':
+ if ($user_level < 3)
+ die (__('Cheatin&#8217; uh?'));
+
+ wp_update_category($_POST);
+
+ header('Location: categories.php?message=3');
+break;
+
+default:
+
+require_once ('admin-header.php');
+
+$messages[1] = __('Category added.');
+$messages[2] = __('Category deleted.');
+$messages[3] = __('Category updated.');
+?>
+
+<?php if (isset($_GET['message'])) : ?>
+<div class="updated"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<?php endif; ?>
+
+<div class="wrap">
+<?php if ( $user_level > 3 ) : ?>
+ <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
+<?php else : ?>
+ <h2><?php _e('Categories') ?> </h2>
+<?php endif; ?>
+<table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+ <th scope="col"><?php _e('ID') ?></th>
+ <th scope="col"><?php _e('Name') ?></th>
+ <th scope="col"><?php _e('Description') ?></th>
+ <th scope="col"><?php _e('# Posts') ?></th>
+ <th colspan="2"><?php _e('Action') ?></th>
+ </tr>
+<?php
+cat_rows();
+?>
+</table>
+
+</div>
+
+<?php if ( $user_level > 3 ) : ?>
+<div class="wrap">
+ <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete posts from that category, it will just set them back to the default category <strong>%s</strong>.'), get_catname(1)) ?>
+ </p>
+</div>
+
+<div class="wrap">
+ <h2><?php _e('Add New Category') ?></h2>
+ <form name="addcat" id="addcat" action="categories.php" method="post">
+
+ <p><?php _e('Name:') ?><br />
+ <input type="text" name="cat_name" value="" /></p>
+ <p><?php _e('Category parent:') ?><br />
+ <select name='category_parent' class='postform'>
+ <option value='0'><?php _e('None') ?></option>
+ <?php wp_dropdown_cats(0); ?>
+ </select></p>
+ <p><?php _e('Description: (optional)') ?> <br />
+ <textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>
+ <p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category &raquo;') ?>" /></p>
+ </form>
+</div>
+<?php endif; ?>
+
+<?php
+break;
+}
+
+include('admin-footer.php');
+?>
diff --git a/wp-inst/wp-admin/dbx-key.js b/wp-inst/wp-admin/dbx-key.js
new file mode 100644
index 0000000..a68ff66
--- /dev/null
+++ b/wp-inst/wp-admin/dbx-key.js
@@ -0,0 +1,44 @@
+
+
+//initialisation function
+window.onload = function()
+{
+ //initialise the docking boxes manager
+ var manager = new dbxManager('postmeta'); //session ID [/-_a-zA-Z0-9/]
+
+
+ //create new docking boxes group
+ var meta = new dbxGroup(
+ 'grabit', // container ID [/-_a-zA-Z0-9/]
+ 'vertical', // orientation ['vertical'|'horizontal']
+ '7', // drag threshold ['n' pixels]
+ 'no', // restrict drag movement to container axis ['yes'|'no']
+ '10', // animate re-ordering [frames per transition, or '0' for no effect]
+ 'yes', // include open/close toggle buttons ['yes'|'no']
+ 'closed', // default state ['open'|'closed']
+ 'open', // word for "open", as in "open this box"
+ 'close', // word for "close", as in "close this box"
+ 'click-down and drag to move this box', // sentence for "move this box" by mouse
+ 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
+ 'use the arrow keys to move this box', // sentence for "move this box" by keyboard
+ ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard
+ '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
+ );
+
+ var advanced = new dbxGroup(
+ 'advancedstuff', // container ID [/-_a-zA-Z0-9/]
+ 'vertical', // orientation ['vertical'|'horizontal']
+ '7', // drag threshold ['n' pixels]
+ 'yes', // restrict drag movement to container axis ['yes'|'no']
+ '10', // animate re-ordering [frames per transition, or '0' for no effect]
+ 'yes', // include open/close toggle buttons ['yes'|'no']
+ 'closed', // default state ['open'|'closed']
+ 'open', // word for "open", as in "open this box"
+ 'close', // word for "close", as in "close this box"
+ 'click-down and drag to move this box', // sentence for "move this box" by mouse
+ 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
+ 'use the arrow keys to move this box', // sentence for "move this box" by keyboard
+ ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard
+ '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
+ );
+};
diff --git a/wp-inst/wp-admin/dbx.js b/wp-inst/wp-admin/dbx.js
new file mode 100644
index 0000000..2cb73f9
--- /dev/null
+++ b/wp-inst/wp-admin/dbx.js
@@ -0,0 +1,6 @@
+// DBX2.0[beta] :: Docking Boxes (dbx)
+// *****************************************************
+// DOM scripting by brothercake -- http://www.brothercake.com/
+// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
+//******************************************************
+var dbx;function dbxManager(sid){dbx=this;if(!/^[-_a-z0-9]+$/i.test(sid)){alert('Error from dbxManager:\n"'+sid+'" is an invalid session ID'); return;}this.supported=!(document.getElementsByTagName('*').length==0||(navigator.vendor=='KDE'&&typeof window.sidebar=='undefined'));if(!this.supported){return;}this.etype=typeof document.addEventListener!='undefined'?'addEventListener':typeof document.attachEvent!='undefined'?'attachEvent':'none';this.eprefix=(this.etype=='attachEvent'?'on':'');if(typeof window.opera!='undefined'&&parseFloat(navigator.userAgent.toLowerCase().split(/opera[\/ ]/)[1].split(' ')[0],10) < 7.5){this.etype='none';}if(this.etype=='none'){this.supported=false; return;}this.running=0;this.gc=[];this.sid=sid;this.savedata={};this.cookiestate=this.getCookieState();};dbxManager.prototype.setCookieState=function(){var now=new Date();now.setTime(now.getTime()+(365*24*60*60*1000));var str='';for(j in this.savedata){str+=j+'='+this.savedata[j]+'&'}this.state=str.replace(/^(.+)&$/,'$1');if(typeof this.onstatechange=='undefined'||this.onstatechange()){document.cookie='dbx-'+this.sid+'='+this.state+'; expires='+now.toGMTString()+'; path=/';}};dbxManager.prototype.getCookieState=function(){this.cookiestate=null;if(document.cookie){if(document.cookie.indexOf('dbx-'+this.sid)!=-1){this.cookie=document.cookie.split('dbx-'+this.sid+'=')[1].split('&');for(var i in this.cookie){this.cookie[i]=this.cookie[i].split('=');this.cookie[i][1]=this.cookie[i][1].split(',');}this.cookiestate={};for(i in this.cookie){this.cookiestate[this.cookie[i][0]]=this.cookie[i][1];}}}return this.cookiestate;};dbxManager.prototype.addDataMember=function(gid,order){this.savedata[gid]=order;};dbxManager.prototype.createElement=function(tag){return typeof document.createElementNS!='undefined'?document.createElementNS('http://www.w3.org/1999/xhtml',tag):document.createElement(tag);};dbxManager.prototype.getTarget=function(e,pattern,node){if(typeof node!='undefined'){var target=node;}else{target=typeof e.target!='undefined'?e.target:e.srcElement;}var regex=new RegExp(pattern,'');while(!regex.test(target.className)){target=target.parentNode;}return target;};function dbxGroup(gid,dir,thresh,fix,ani,togs,def,open,close,move,toggle,kmove,ktoggle,syntax){if(!/^[-_a-z0-9]+$/i.test(gid)){alert('Error from dbxGroup:\n"'+gid+'" is an invalid container ID'); return;}this.container=document.getElementById(gid);if(this.container==null||!dbx.supported){return;}var self=this;this.gid=gid;this.dragok=false;this.box=null;this.vertical=dir=='vertical';this.threshold=parseInt(thresh,10);this.restrict=fix=='yes';this.resolution=parseInt(ani,10);this.toggles=togs=='yes';this.defopen=def!='closed';this.vocab={'open':open,'close':close,'move':move, 'toggle':toggle,'kmove':kmove, 'ktoggle':ktoggle,'syntax':syntax};this.container.style.position='relative';this.container.style.display='block';if(typeof window.opera!='undefined'){this.container.style.display='run-in';}this.boxes=[];this.buttons=[];this.order=[];this.eles=this.container.getElementsByTagName('*');for(var i=0;i<this.eles.length; i++){if(/dbx\-box/i.test(this.eles[i].className)&&!/dbx\-dummy/i.test(this.eles[i].className)){this.eles[i].style.position='relative';this.eles[i].style.display='block';this.boxes.push(this.eles[i]);this.eles[i].className+=' dbx-box-open';this.eles[i].className+=' dbxid'+this.order.length;this.order.push(this.order.length.toString()+'+');this.eles[i][dbx.etype](dbx.eprefix+'mousedown',function(e){if(!e){e=window.event;}self.mousedown(e,dbx.getTarget(e,'dbx\-box'));},false);}if(/dbx\-handle/i.test(this.eles[i].className)){this.eles[i].style.position='relative';this.eles[i].style.display='block';this.eles[i].className+=' dbx-handle-cursor';this.eles[i].setAttribute('title',this.eles[i].getAttribute('title')==null||this.eles[i].title==''?this.vocab.move:this.vocab.syntax.replace('%mytitle%',this.eles[i].title).replace('%dbxtitle%',this.vocab.move));if(this.toggles){this.buttons.push(this.addToggleBehavior(this.eles[i]));}else{this.eles[i][dbx.etype](dbx.eprefix+'key'+(typeof document.uniqueID!='undefined'||navigator.vendor=='Apple Computer, Inc.'?'down':'press'),function(e) {if(!e){e=window.event;}return self.keypress(e,dbx.getTarget(e,'dbx\-handle'));},false);this.eles[i][dbx.etype](dbx.eprefix+'focus',function(e){if(!e){e=window.event;}self.createTooltip(null,dbx.getTarget(e,'dbx\-handle'));},false);this.eles[i][dbx.etype](dbx.eprefix+'blur',function(){self.removeTooltip();},false);}}}dbx.addDataMember(this.gid,this.order.join(','));var dummy=this.container.appendChild(dbx.createElement('span'));dummy.className='dbx-box dbx-dummy';dummy.style.display='block';dummy.style.width='0';dummy.style.height='0';dummy.style.overflow='hidden';if(this.vertical){dummy.className+=' dbx-offdummy';}this.boxes.push(dummy);if(dbx.cookiestate!=null&&typeof dbx.cookiestate[this.gid]!='undefined'){var num=dbx.cookiestate[this.gid].length;if(num==this.boxes.length - 1){for(i=0;i<num; i++){var index=parseInt(dbx.cookiestate[this.gid][i],10);this.container.insertBefore(this.boxes[index],dummy);if(this.toggles&&dbx.cookiestate[this.gid][i].charAt(1)=='-'){this.toggleBoxState(this.buttons[index],false);}}this.getBoxOrder();}}else if(!this.defopen&&this.toggles){var len=this.buttons.length;for(i=0;i<len; i++){this.toggleBoxState(this.buttons[i],true);}}document[dbx.etype](dbx.eprefix+'mouseout',function(e){if(typeof e.target=='undefined'){e=window.event; e.relatedTarget=e.toElement;}if(e.relatedTarget==null){self.mouseup(e);}},false);document[dbx.etype](dbx.eprefix+'mousemove',function(e){self.mousemove(e);},false);document[dbx.etype](dbx.eprefix+'mouseup',function(e){self.mouseup(e);},false);this.keydown=false;document[dbx.etype](dbx.eprefix+'keydown',function(){self.keydown=true;},false);document[dbx.etype](dbx.eprefix+'keyup',function(){self.keydown=false;},false);};dbxGroup.prototype.addToggleBehavior=function(){var self=this;var button=arguments[0].appendChild(dbx.createElement('a'));button.appendChild(document.createTextNode('\u00a0'));button.style.cursor='pointer';button.href='javascript:void(null)';button.className='dbx-toggle dbx-toggle-open';button.setAttribute('title',this.vocab.toggle.replace('%toggle%',this.vocab.close));button.hasfocus=typeof window.opera!='undefined'||navigator.vendor=='Apple Computer, Inc.'?null:false;this.tooltip=null;button.onclick=function(){if(this.hasfocus===true||this.hasfocus===null){self.removeTooltip();self.toggleBoxState(this,true);}};button['onkey'+(typeof document.uniqueID!='undefined'||navigator.vendor=='Apple Computer, Inc.'?'down':'press')]=function(e){if(!e){e=window.event;}return self.keypress(e,this);};button.onfocus=function(){var len=self.buttons.length;for(var i=0;i<len; i++){self.buttons[i].className=self.buttons[i].className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/,'');}var isopen=(/dbx\-toggle\-open/.test(this.className));this.className+=' dbx-toggle-hilite-'+(isopen?'open':'closed');self.createTooltip(isopen,this);this.isactive=true;if(this.hasfocus!==null){this.hasfocus=true;}};button.onblur=function(){this.className=this.className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/,'');self.removeTooltip();if(this.hasfocus!==null){this.hasfocus=false;}};return button;};dbxGroup.prototype.toggleBoxState=function(button,regen){var isopen=(/dbx\-toggle\-open/.test(button.className));var parent=dbx.getTarget(null,'dbx\-box',button);dbx.box=parent;dbx.toggle=button;if(typeof dbx.container=='undefined'){dbx.group=dbx.getTarget(null,'dbx\-group',parent);}else{dbx.group=dbx.container;}if((!isopen&&(typeof dbx.onboxopen=='undefined'||dbx.onboxopen()))||(isopen&&(typeof dbx.onboxclose=='undefined'||dbx.onboxclose()))){button.className='dbx-toggle dbx-toggle-'+(isopen?'closed':'open');button.title=this.vocab.toggle.replace('%toggle%',isopen?this.vocab.open:this.vocab.close);if(typeof button.isactive!='undefined'){button.className+=' dbx-toggle-hilite-'+(isopen?'closed':'open')}parent.className=parent.className.replace(/[ ](dbx-box-)(open|closed)/,' $1'+(isopen?'closed':'open'));if(regen){this.getBoxOrder();}}};dbxGroup.prototype.shiftBoxPosition=function(e,anchor,positive){var parent=dbx.getTarget(null,'dbx\-box',anchor);dbx.group=this.container;dbx.box=parent;dbx.event=e;if(typeof dbx.onboxdrag=='undefined'||dbx.onboxdrag()){var positions=[];var len=this.boxes.length;for(var i=0;i<len; i++){positions[i]=[i,this.boxes[i][this.vertical?'offsetTop':'offsetLeft']];if(parent==this.boxes[i]){this.idref=i;}}positions.sort(this.compare);for(i=0;i<len; i++){if(positions[i][0]==this.idref){if((positive&&i < len - 2)||(!positive&&i > 0)){var sibling=this.boxes[positions[i+(positive?1:-1)][0]];if(this.resolution > 0){var visipos={'x':parent.offsetLeft,'y':parent.offsetTop};var siblingpos={'x':sibling.offsetLeft,'y':sibling.offsetTop};}var obj={'insert':(positive?sibling:parent),'before':(positive?parent:sibling)};this.container.insertBefore(obj.insert,obj.before);if(this.resolution > 0){var animators={'sibling':new dbxAnimator(this,sibling,siblingpos,this.resolution,true,anchor),'parent':new dbxAnimator(this,parent,visipos,this.resolution,true,anchor)};}else{anchor.focus();}break;}}}this.getBoxOrder();}};dbxGroup.prototype.compare=function(a,b){return a[1] - b[1];};dbxGroup.prototype.createTooltip=function(isopen,anchor){if(this.keydown){this.tooltip=this.container.appendChild(dbx.createElement('span'));this.tooltip.style.visibility='hidden';this.tooltip.className='dbx-tooltip';if(isopen!=null){this.tooltip.appendChild(document.createTextNode(this.vocab.kmove+this.vocab.ktoggle.replace('%toggle%',isopen?this.vocab.close:this.vocab.open)));}else{this.tooltip.appendChild(document.createTextNode(this.vocab.kmove));}var parent=dbx.getTarget(null,'dbx\-box',anchor);this.tooltip.style.left=parent.offsetLeft+'px';this.tooltip.style.top=parent.offsetTop+'px';var tooltip=this.tooltip;window.setTimeout(function(){if(tooltip!=null){tooltip.style.visibility='visible';}},500);}};dbxGroup.prototype.removeTooltip=function(){if(this.tooltip!=null){this.tooltip.parentNode.removeChild(this.tooltip); this.tooltip=null;}};dbxGroup.prototype.mousedown=function(e,box){var node=typeof e.target!='undefined'?e.target:e.srcElement;if(node.nodeName=='#text'){node=node.parentNode;}if(!/dbx\-(toggle|box|group)/i.test(node.className)){while(!/dbx\-(handle|box|group)/i.test(node.className)){node=node.parentNode;}}if(/dbx\-handle/i.test(node.className)){this.removeTooltip();this.released=false;this.initial={'x':e.clientX,'y':e.clientY};this.current={'x':0,'y':0};this.createCloneBox(box);if(typeof e.preventDefault!='undefined' ){e.preventDefault();}if(typeof document.onselectstart!='undefined'){document.onselectstart=function(){return false;}}}};dbxGroup.prototype.mousemove=function(e){if(this.dragok&&this.box!=null){this.positive=this.vertical?(e.clientY > this.current.y?true:false):(e.clientX > this.current.x?true:false);this.current={'x':e.clientX,'y':e.clientY};var overall={'x':this.current.x - this.initial.x,'y':this.current.y - this.initial.y};if(((overall.x>=0&&overall.x<=this.threshold)||(overall.x<=0&&overall.x>=0 - this.threshold))&&((overall.y>=0&&overall.y<=this.threshold)||(overall.y<=0&&overall.y>=0 - this.threshold))){this.current.x-=overall.x; this.current.y-=overall.y;}if(this.released||overall.x > this.threshold||overall.x < (0 - this.threshold)||overall.y > this.threshold||overall.y < (0 - this.threshold)){dbx.group=this.container;dbx.box=this.box;dbx.event=e;if(typeof dbx.onboxdrag=='undefined'||dbx.onboxdrag()){this.released=true;if(!this.restrict||!this.vertical){this.boxclone.style.left=(this.current.x - this.difference.x)+'px';}if(!this.restrict||this.vertical){this.boxclone.style.top=(this.current.y - this.difference.y)+'px';}this.moveOriginalToPosition(this.current.x,this.current.y);if(typeof e.preventDefault!='undefined' ){e.preventDefault();}}}}return true;};dbxGroup.prototype.mouseup=function(e){if(this.box!=null){this.moveOriginalToPosition(e.clientX,e.clientY);this.removeCloneBox();this.getBoxOrder();if(typeof document.onselectstart!='undefined'){document.onselectstart=function(){return true;}}}this.dragok=false;};dbxGroup.prototype.keypress=function(e,anchor){if(/^(3[7-9])|(40)$/.test(e.keyCode)){this.removeTooltip();if((this.vertical&&/^(38|40)$/.test(e.keyCode))||(!this.vertical&&/^(37|39)$/.test(e.keyCode))){this.shiftBoxPosition(e,anchor,/^[3][78]$/.test(e.keyCode)?false:true);if(typeof e.preventDefault!='undefined'){e.preventDefault();}else{return false;}typeof e.stopPropagation!='undefined'?e.stopPropagation():e.cancelBubble=true;this.keydown=false;}}return true;};dbxGroup.prototype.getBoxOrder=function(){this.order=[];var len=this.eles.length;for(var j=0; j<len; j++){if(/dbx\-box/i.test(this.eles[j].className)&&!/dbx\-(clone|dummy)/i.test(this.eles[j].className)){this.order.push(this.eles[j].className.split('dbxid')[1]+(/dbx\-box\-open/i.test(this.eles[j].className)?'+':'-'));}}dbx.savedata[this.gid]=this.order.join(',');dbx.setCookieState();};dbxGroup.prototype.createClone=function(){var clone=this.container.appendChild(arguments[0].cloneNode(true));clone.className+=' dbx-clone';clone.style.position='absolute';clone.style.visibility='hidden';clone.style.zIndex=arguments[1];clone.style.left=arguments[2].x+'px';clone.style.top=arguments[2].y+'px';clone.style.width=arguments[0].offsetWidth+'px';clone.style.height=arguments[0].offsetHeight+'px';return clone;};dbxGroup.prototype.createCloneBox=function(box){this.box=box;this.position={'x':this.box.offsetLeft,'y':this.box.offsetTop};this.difference={'x':(this.initial.x - this.position.x),'y':(this.initial.y - this.position.y)};this.boxclone=this.createClone(this.box,30000,this.position);this.boxclone.style.cursor='move';this.dragok=true;};dbxGroup.prototype.removeCloneBox=function(){this.container.removeChild(this.boxclone);this.box.style.visibility='visible';this.box=null;};dbxGroup.prototype.moveOriginalToPosition=function(clientX,clientY){var cloneprops={'xy':this.vertical?clientY - this.difference.y:clientX - this.difference.x,'wh':this.vertical?this.boxclone.offsetHeight:this.boxclone.offsetWidth};this.box.style.visibility='hidden';this.boxclone.style.visibility='visible';var len=this.boxes.length;for(var i=0;i<len; i++){var boxprops={'xy':this.vertical?this.boxes[i].offsetTop:this.boxes[i].offsetLeft,'wh':this.vertical?this.boxes[i].offsetHeight:this.boxes[i].offsetWidth};if((this.positive&&cloneprops.xy+cloneprops.wh > boxprops.xy&&cloneprops.xy < boxprops.xy)||(!this.positive&&cloneprops.xy < boxprops.xy&&cloneprops.xy+cloneprops.wh > boxprops.xy)){if(this.boxes[i]==this.box){return;}var sibling=this.box.nextSibling;while(sibling.className==null||!/dbx\-box/.test(sibling.className)){sibling=sibling.nextSibling;}if(this.boxes[i]==sibling){return;}if(this.resolution > 0){if(this.box[this.vertical?'offsetTop':'offsetLeft'] < boxprops.xy){var visibox=this.boxes[i].previousSibling;while(visibox.className==null||!/dbx\-box/.test(visibox.className)){visibox=visibox.previousSibling;}}else{visibox=this.boxes[i];}var visipos={'x':visibox.offsetLeft,'y':visibox.offsetTop};}var prepos={'x':this.box.offsetLeft,'y':this.box.offsetTop};this.container.insertBefore(this.box,this.boxes[i]);this.initial.x+=(this.box.offsetLeft - prepos.x);this.initial.y+=(this.box.offsetTop - prepos.y);if(this.resolution > 0&&visibox!=this.box){var animator=new dbxAnimator(this,visibox,visipos,this.resolution,false,null);}else{}break;}}};function dbxAnimator(caller,box,pos,res,kbd,anchor){this.caller=caller;this.box=box;this.timer=null;var before=pos[this.caller.vertical?'y':'x'];var after=this.box[this.caller.vertical?'offsetTop':'offsetLeft'];if(before!=after){if(dbx.running > this.caller.boxes.length - 1){return;}var clone=this.caller.createClone(this.box,29999,arguments[2]);clone.style.visibility='visible';this.box.style.visibility='hidden';this.animateClone(clone,before,after > before?after - before:0 - (before - after),this.caller.vertical?'top':'left',res,kbd,anchor);}};dbxAnimator.prototype.animateClone=function(clone,current,change,dir,res,kbd,anchor){var self=this;var count=0;dbx.running ++;this.timer=window.setInterval(function(){count ++;current+=change / res;clone.style[dir]=current+'px';if(count==res){window.clearTimeout(self.timer);self.timer=null;dbx.running --;self.caller.container.removeChild(clone);self.box.style.visibility='visible';if(kbd){if(anchor!=null&&anchor.parentNode.style.visibility!='hidden'){anchor.focus();}else if(self.caller.toggles){var button=self.caller.buttons[parseInt(self.box.className.split('dbxid')[1],10)];if(button!=null&&typeof button.isactive!='undefined'){button.focus();}}}}},20);};if(typeof window.attachEvent!='undefined'){window.attachEvent('onunload',function(){var ev=['mousedown','mousemove','mouseup','mouseout','click','keydown','keyup','focus','blur','selectstart','statechange','boxdrag','boxopen','boxclose'];var el=ev.length;var dl=document.all.length;for(var i=0;i<dl; i++){for(var j=0; j<el; j++){document.all[i]['on'+ev[j]]=null;}}});} \ No newline at end of file
diff --git a/wp-inst/wp-admin/edit-comments.php b/wp-inst/wp-admin/edit-comments.php
new file mode 100644
index 0000000..bcfd4c2
--- /dev/null
+++ b/wp-inst/wp-admin/edit-comments.php
@@ -0,0 +1,171 @@
+<?php
+require_once('admin.php');
+
+$title = __('Edit Comments');
+$parent_file = 'edit.php';
+
+require_once('admin-header.php');
+if (empty($_GET['mode'])) $mode = 'view';
+else $mode = wp_specialchars($_GET['mode'], 1);
+?>
+
+<script type="text/javascript">
+<!--
+function checkAll(form)
+{
+ for (i = 0, n = form.elements.length; i < n; i++) {
+ if(form.elements[i].type == "checkbox") {
+ if(form.elements[i].checked == true)
+ form.elements[i].checked = false;
+ else
+ form.elements[i].checked = true;
+ }
+ }
+}
+//-->
+</script>
+<div class="wrap">
+<h2><?php _e('Comments'); ?></h2>
+<form name="searchform" action="" method="get">
+ <fieldset>
+ <legend><?php _e('Show Comments That Contain...') ?></legend>
+ <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo wp_specialchars($_GET['s'], 1); ?>" size="17" />
+ <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+ <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
+ <?php _e('(Searches within comment text, e-mail, URI, and IP address.)') ?>
+ </fieldset>
+</form>
+<p><a href="?mode=view"><?php _e('View Mode') ?></a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p>
+<?php
+if ( !empty( $_POST['delete_comments'] ) ) :
+ $i = 0;
+ foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
+ $comment = (int) $comment;
+ $post_id = $wpdb->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 ( user_can_delete_post_comments($user_ID, $post_id) ) :
+ $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID = $comment");
+ ++$i;
+ endif;
+ endforeach;
+ echo "<div class='wrap'><p>" . sprintf(__('%s comments deleted.'), $i) . "</p></div>";
+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 "<ol class='commentlist' $start>";
+ $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 "<li class='$class'>";
+?>
+ <p><strong><?php _e('Name:') ?></strong> <?php comment_author() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('E-mail:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
+
+ <?php comment_text() ?>
+
+ <p><?php _e('Posted'); echo ' '; comment_date('M j, g:i A');
+ if ( user_can_edit_post_comments($user_ID, $comment->comment_post_ID) ) {
+ echo " | <a href=\"post.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" . __('Edit Comment') . "</a>";
+ }
+ if ( user_can_delete_post_comments($user_ID, $comment->comment_post_ID) ) {
+ echo " | <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;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) . "')\">" . __('Delete Comment') . "</a> &#8212; ";
+ } // end if any comments to show
+ // Get post title
+ if ( user_can_edit_post($user_ID, $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;
+ ?> <a href="post.php?action=edit&amp;post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post &#8220;%s&#8221;'), stripslashes($post_title)); ?></a>
+ <?php } ?>
+ | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p>
+ </li>
+
+<?php } // end foreach ?>
+</ol>
+
+<?php
+ } else {
+
+ ?>
+ <p>
+ <strong><?php _e('No comments found.') ?></strong></p>
+
+ <?php
+ } // end if ($comments)
+} elseif ('edit' == $mode) {
+
+ if ($comments) {
+ echo '<form name="deletecomments" id="deletecomments" action="" method="post">
+ <table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+ <th scope="col">*</th>
+ <th scope="col">' . __('Name') . '</th>
+ <th scope="col">' . __('E-mail') . '</th>
+ <th scope="col">' . __('IP') . '</th>
+ <th scope="col">' . __('Comment Excerpt') . '</th>
+ <th scope="col" colspan="3">' . __('Actions') . '</th>
+ </tr>';
+ 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';
+?>
+ <tr class='<?php echo $class; ?>'>
+ <td><?php if (user_can_delete_post_comments($user_ID, $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
+ <td><?php comment_author_link() ?></td>
+ <td><?php comment_author_email_link() ?></td>
+ <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
+ <td><?php comment_excerpt(); ?></td>
+ <td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a></td>
+ <td><?php if ( user_can_edit_post_comments($user_ID, $comment->comment_post_ID) ) {
+ echo "<a href='post.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td>
+ <td><?php if ( user_can_delete_post_comments($user_ID, $comment->comment_post_ID) ) {
+ echo "<a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;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') . "</a>"; } ?></td>
+ </tr>
+ <?php
+ } // end foreach
+ ?></table>
+ <p><a href="javascript:;" onclick="checkAll(document.getElementById('deletecomments')); return false; "><?php _e('Invert Checkbox Selection') ?></a></p>
+ <p class="submit"><input type="submit" name="Submit" value="<?php _e('Delete Checked Comments') ?> &raquo;" onclick="return confirm('<?php _e("You are about to delete these comments permanently \\n \'Cancel\' to stop, \'OK\' to delete.") ?>')" /> </p>
+ </form>
+<?php
+ } else {
+?>
+<p>
+<strong><?php _e('No results found.') ?></strong>
+</p>
+<?php
+ } // end if ($comments)
+}
+ ?>
+
+</div>
+
+<?php include('admin-footer.php'); ?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/edit-form-advanced.php b/wp-inst/wp-admin/edit-form-advanced.php
new file mode 100644
index 0000000..577cf77
--- /dev/null
+++ b/wp-inst/wp-admin/edit-form-advanced.php
@@ -0,0 +1,212 @@
+<?php
+$messages[1] = __('Post updated');
+$messages[2] = __('Custom field updated');
+$messages[3] = __('Custom field deleted.');
+?>
+<?php if (isset($_GET['message'])) : ?>
+<div class="updated"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<?php endif; ?>
+
+<form name="post" action="post.php" method="post" id="post">
+
+<div class="wrap">
+<h2><?php _e('Write Post'); ?></h2>
+<?php
+
+if (0 == $post_ID) {
+ $form_action = 'post';
+} else {
+ $form_action = 'editpost';
+ $form_extra = "<input type='hidden' name='post_ID' value='$post_ID' />";
+}
+
+$form_pingback = '<input type="hidden" name="post_pingback" value="' . get_option('default_pingback_flag') . '" id="post_pingback" />';
+
+$form_prevstatus = '<input type="hidden" name="prev_status" value="' . $post->post_status . '" />';
+
+$form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. str_replace("\n", ' ', $post->to_ping) .'" />';
+
+if ('' != $pinged) {
+ $pings .= '<p>'. __('Already pinged:') . '</p><ul>';
+ $already_pinged = explode("\n", trim($pinged));
+ foreach ($already_pinged as $pinged_url) {
+ $pings .= "\n\t<li>$pinged_url</li>";
+ }
+ $pings .= '</ul>';
+}
+
+$saveasdraft = '<input name="save" type="submit" id="save" tabindex="6" value="' . __('Save and Continue Editing') . '" />';
+
+if (empty($post->post_status)) $post->post_status = 'draft';
+
+?>
+
+<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="action" value="<?php echo $form_action ?>" />
+<input type="hidden" name="post_author" value="<?php echo $post->post_author ?>" />
+
+<?php echo $form_extra ?>
+<?php if (isset($_GET['message']) && 2 > $_GET['message']) : ?>
+<script type="text/javascript">
+<!--
+function focusit() {
+ // focus on first input field
+ document.post.title.focus();
+}
+window.onload = focusit;
+//-->
+</script>
+<?php endif; ?>
+<div id="poststuff">
+
+<div id="moremeta">
+<div id="grabit" class="dbx-group">
+
+<fieldset id="commentstatusdiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Discussion') ?></h3>
+<div class="dbx-content">
+<input name="advanced_view" type="hidden" value="1" />
+<label for="comment_status" class="selectit">
+<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
+<?php _e('Allow Comments') ?></label>
+<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label>
+</div>
+</fieldset>
+
+<fieldset id="passworddiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Password-Protect Post') ?></h3>
+<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div>
+</fieldset>
+
+<fieldset id="slugdiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Post slug') ?></h3>
+<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div>
+</fieldset>
+
+<fieldset id="categorydiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
+<div class="dbx-content"><?php dropdown_categories(get_settings('default_category')); ?></div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Post Status') ?></h3>
+<div class="dbx-content"><?php if ( user_can_create_post($user_ID) ) : ?>
+<label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); ?> /> <?php _e('Published') ?></label>
+<?php endif; ?>
+ <label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label>
+ <label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="radio" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></div>
+</fieldset>
+
+<?php if ($user_level > 4) : ?>
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Post Timestamp'); ?>:</h3>
+<div class="dbx-content"><?php touch_time(($action == 'edit')); ?></div>
+</fieldset>
+<?php endif; ?>
+
+<?php if ( $authors = get_editable_authors( $current_user->ID ) ) : // TODO: ROLE SYSTEM ?>
+<fieldset id="authordiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Post author'); ?>:</h3>
+<div class="dbx-content">
+<select name="post_author_override" id="post_author_override">
+<?php
+foreach ($authors as $o) :
+$o = get_userdata( $o->ID );
+if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
+else $selected = '';
+echo "<option value='$o->ID' $selected>$o->display_name</option>";
+endforeach;
+?>
+</select>
+</div>
+</fieldset>
+<?php endif; ?>
+
+</div>
+</div>
+
+<fieldset id="titlediv">
+ <legend><?php _e('Title') ?></legend>
+ <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>
+</fieldset>
+
+<fieldset id="postdiv">
+ <legend><?php _e('Post') ?></legend>
+<?php the_quicktags(); ?>
+<?php
+ $rows = get_settings('default_post_edit_rows');
+ if (($rows < 3) || ($rows > 100)) {
+ $rows = 10;
+ }
+?>
+<div><textarea rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="5" id="content"><?php echo $post->post_content ?></textarea></div>
+</fieldset>
+<script type="text/javascript">
+<!--
+edCanvas = document.getElementById('content');
+//-->
+</script>
+
+<?php echo $form_pingback ?>
+<?php echo $form_prevstatus ?>
+
+
+<p class="submit"><?php echo $saveasdraft; ?> <input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="6" />
+<?php
+if ('publish' != $post_status || 0 == $post_ID) {
+?>
+<?php if ( user_can_create_post($user_ID) ) : ?>
+ <input name="publish" type="submit" id="publish" tabindex="10" value="<?php _e('Publish') ?>" />
+<?php endif; ?>
+<?php
+}
+?>
+ <input name="referredby" type="hidden" id="referredby" value="<?php echo wp_specialchars($_SERVER['HTTP_REFERER']); ?>" />
+</p>
+
+<?php do_action('edit_form_advanced', ''); ?>
+
+<div id="advancedstuff" class="dbx-group" >
+
+<fieldset id="postexcerpt" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Optional Excerpt') ?></h3>
+<div class="dbx-content"><textarea rows="1" cols="40" name="excerpt" tabindex="4" id="excerpt"><?php echo $post->post_excerpt ?></textarea></div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Trackbacks') ?></h3>
+<div class="dbx-content"><?php _e('Send trackbacks to'); ?>: <?php echo $form_trackback; ?> (<?php _e('Separate multiple URIs with spaces'); ?>)
+<?php
+if ('' != $pinged)
+ echo $pings;
+?>
+</div>
+</fieldset>
+
+<fieldset id="postcustom" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3>
+<div id="postcustomstuff" class="dbx-content">
+<?php
+if($metadata = has_meta($post_ID)) {
+?>
+<?php
+ list_meta($metadata);
+?>
+<?php
+}
+ meta_form();
+?>
+</div>
+</fieldset>
+
+</div>
+
+<?php if ('edit' == $action) : ?>
+<p><input name="deletepost" class="button" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this post') ?>" <?php echo "onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), addslashes($post->post_title) ) . "')\""; ?> /></p>
+<?php endif; ?>
+
+</div>
+
+</div>
+
+</form> \ No newline at end of file
diff --git a/wp-inst/wp-admin/edit-form-comment.php b/wp-inst/wp-admin/edit-form-comment.php
new file mode 100644
index 0000000..9dd817d
--- /dev/null
+++ b/wp-inst/wp-admin/edit-form-comment.php
@@ -0,0 +1,89 @@
+<?php
+$submitbutton_text = __('Edit Comment &raquo;');
+$toprow_title = sprintf(__('Editing Comment # %s'), $comment->comment_ID);
+$form_action = 'editedcomment';
+$form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment->comment_ID . "' />\n<input type='hidden' name='comment_post_ID' value='".$comment->comment_post_ID;
+?>
+
+<form name="post" action="post.php" method="post" id="post">
+<div class="wrap">
+<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="action" value='<?php echo $form_action . $form_extra ?>' />
+
+<script type="text/javascript">
+function focusit() {
+ // focus on first input field
+ document.post.name.focus();
+}
+window.onload = focusit;
+</script>
+<fieldset id="namediv">
+ <legend><?php _e('Name:') ?></legend>
+ <div>
+ <input type="text" name="newcomment_author" size="22" value="<?php echo $comment->comment_author ?>" tabindex="1" id="name" />
+ </div>
+</fieldset>
+<fieldset id="emaildiv">
+ <legend><?php _e('E-mail:') ?></legend>
+ <div>
+ <input type="text" name="newcomment_author_email" size="30" value="<?php echo $comment->comment_author_email ?>" tabindex="2" id="email" />
+ </div>
+</fieldset>
+<fieldset id="uridiv">
+ <legend><?php _e('URI:') ?></legend>
+ <div>
+ <input type="text" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" id="URL" />
+ </div>
+</fieldset>
+
+<fieldset style="clear: both;">
+ <legend><?php _e('Comment') ?></legend>
+<?php the_quicktags(); ?>
+<?php
+ $rows = get_settings('default_post_edit_rows');
+ if (($rows < 3) || ($rows > 100)) {
+ $rows = 10;
+ }
+?>
+<div><textarea rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content" style="width: 99%"><?php echo $comment->comment_content ?></textarea></div>
+</fieldset>
+
+<script type="text/javascript">
+<!--
+edCanvas = document.getElementById('content');
+//-->
+</script>
+
+<p class="submit"><input type="submit" name="editcomment" id="editcomment" value="<?php echo $submitbutton_text ?>" style="font-weight: bold;" tabindex="6" />
+ <input name="referredby" type="hidden" id="referredby" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" />
+</p>
+
+</div>
+
+<div class="wrap">
+<h2><?php _e('Advanced'); ?></h2>
+
+<table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr>
+ <th scope="row" valign="top"><?php _e('Comment Status') ?>:</th>
+ <td><label for="comment_status_approved" class="selectit"><input id="comment_status_approved" name="comment_status" type="radio" value="1" <?php checked($comment->comment_approved, '1'); ?> /> <?php _e('Approved') ?></label><br />
+ <label for="comment_status_moderated" class="selectit"><input id="comment_status_moderated" name="comment_status" type="radio" value="0" <?php checked($comment->comment_approved, '0'); ?> /> <?php _e('Moderated') ?></label><br />
+ <label for="comment_status_spam" class="selectit"><input id="comment_status_spam" name="comment_status" type="radio" value="spam" <?php checked($comment->comment_approved, 'spam'); ?> /> <?php _e('Spam') ?></label></td>
+ </tr>
+
+<?php if ($user_level > 4) : ?>
+ <tr>
+ <th scope="row"><?php _e('Edit time'); ?>:</th>
+ <td><?php touch_time(('editcomment' == $action), 0); ?></td>
+ </tr>
+<?php endif; ?>
+
+ <tr>
+ <th scope="row"><?php _e('Delete'); ?>:</th>
+ <td><p><a class="delete" href="post.php?action=confirmdeletecomment&amp;noredir=true&amp;comment=<?php echo $comment->comment_ID; ?>&amp;p=<?php echo $comment->comment_post_ID; ?>"><?php _e('Delete comment') ?></a></p></td>
+ </tr>
+</table>
+
+</div>
+
+</form>
diff --git a/wp-inst/wp-admin/edit-form.php b/wp-inst/wp-admin/edit-form.php
new file mode 100644
index 0000000..11d62d4
--- /dev/null
+++ b/wp-inst/wp-admin/edit-form.php
@@ -0,0 +1,76 @@
+
+<div class="wrap">
+<h2><?php _e('Write Post'); ?></h2>
+<form name="post" action="post.php" method="post" id="simple">
+
+<?php if (isset($mode) && 'bookmarklet' == $mode) : ?>
+<input type="hidden" name="mode" value="bookmarklet" />
+<?php endif; ?>
+<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="action" value='post' />
+
+<script type="text/javascript">
+<!--
+function focusit() {
+ // focus on first input field
+ document.getElementById('title').focus();
+}
+window.onload = focusit;
+//-->
+</script>
+
+<div id="poststuff">
+ <fieldset id="titlediv">
+ <legend><a href="http://wordpress.org/docs/reference/post/#title" title="<?php _e('Help on titles') ?>"><?php _e('Title') ?></a></legend>
+ <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>
+ </fieldset>
+
+ <fieldset id="categorydiv">
+ <legend><a href="http://wordpress.org/docs/reference/post/#category" title="<?php _e('Help on categories') ?>"><?php _e('Categories') ?></a></legend>
+ <div><?php dropdown_categories($post->post_category); ?></div>
+ </fieldset>
+
+<br />
+<fieldset id="postdiv">
+ <legend><a href="http://wordpress.org/docs/reference/post/#post" title="<?php _e('Help with post field') ?>"><?php _e('Post') ?></a></legend>
+<?php the_quicktags(); ?>
+<?php
+ $rows = get_settings('default_post_edit_rows');
+ if (($rows < 3) || ($rows > 100)) {
+ $rows = 10;
+ }
+?>
+<div><textarea rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo $post->post_content ?></textarea></div>
+</fieldset>
+
+
+<script type="text/javascript">
+<!--
+edCanvas = document.getElementById('content');
+//-->
+</script>
+
+<input type="hidden" name="post_pingback" value="<?php echo get_option('default_pingback_flag') ?>" id="post_pingback" />
+
+<p><label for="trackback"> <?php printf(__('<a href="%s" title="Help on trackbacks"><strong>TrackBack</strong> a <abbr title="Universal Resource Identifier">URI</abbr></a>:</label> (Separate multiple <abbr title="Universal Resource Identifier">URI</abbr>s with spaces.)<br />'), 'http://wordpress.org/docs/reference/post/#trackback') ?>
+ <input type="text" name="trackback_url" style="width: 360px" id="trackback" tabindex="7" /></p>
+
+<p class="submit"><input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="<?php _e('Save as Draft') ?>" />
+ <input name="saveasprivate" type="submit" id="saveasprivate" tabindex="10" value="<?php _e('Save as Private') ?>" />
+
+ <?php if ( user_can_create_post($user_ID) ) : ?>
+ <input name="publish" type="submit" id="publish" tabindex="6" style="font-weight: bold;" value="<?php _e('Publish') ?>" />
+<?php endif; ?>
+
+<?php if ('bookmarklet' != $mode) {
+ echo '<input name="advanced" type="submit" id="advancededit" tabindex="7" value="' . __('Advanced Editing &raquo;') . '" />';
+ } ?>
+ <input name="referredby" type="hidden" id="referredby" value="<?php if (isset($_SERVER['HTTP_REFERER'])) echo urlencode($_SERVER['HTTP_REFERER']); ?>" />
+</p>
+
+<?php do_action('simple_edit_form', ''); ?>
+
+</div>
+</form>
+
+</div>
diff --git a/wp-inst/wp-admin/edit-page-form.php b/wp-inst/wp-admin/edit-page-form.php
new file mode 100644
index 0000000..a238423
--- /dev/null
+++ b/wp-inst/wp-admin/edit-page-form.php
@@ -0,0 +1,160 @@
+
+<div class="wrap">
+<h2><?php _e('Write Page'); ?></h2>
+<?php
+if (0 == $post_ID) {
+ $form_action = 'post';
+ $form_extra = '';
+} else {
+ $form_action = 'editpost';
+ $form_extra = "<input type='hidden' name='post_ID' value='$post_ID' />";
+}
+
+$sendto = $_SERVER['HTTP_REFERER'];
+
+if ( 0 != $post_ID && $sendto == get_permalink($post_ID) )
+ $sendto = 'redo';
+$sendto = wp_specialchars( $sendto );
+
+?>
+
+<form name="post" action="post.php" method="post" id="post">
+
+<?php
+if (isset($mode) && 'bookmarklet' == $mode) {
+ echo '<input type="hidden" name="mode" value="bookmarklet" />';
+}
+?>
+<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="action" value='<?php echo $form_action ?>' />
+<?php echo $form_extra ?>
+<input type="hidden" name="post_status" value="static" />
+
+<script type="text/javascript">
+<!--
+function focusit() {
+ // focus on first input field
+ document.post.title.focus();
+}
+window.onload = focusit;
+//-->
+</script>
+ <fieldset id="titlediv">
+ <legend><?php _e('Page Title') ?></legend>
+ <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>
+ </fieldset>
+<fieldset id="commentstatusdiv">
+ <legend><?php _e('Discussion') ?></legend>
+ <div>
+ <input name="advanced_view" type="hidden" value="1" />
+ <label for="comment_status" class="selectit">
+ <input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
+ <?php _e('Allow Comments') ?></label>
+ <label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label>
+ </div>
+</fieldset>
+ <fieldset id="postpassworddiv">
+ <legend><?php _e('Page Password') ?></legend>
+ <div><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div>
+ </fieldset>
+ <fieldset id="pageparent">
+ <legend><?php _e('Page Parent') ?></legend>
+ <div><select name="parent_id">
+ <option value='0'><?php _e('Main Page (no parent)'); ?></option>
+ <?php parent_dropdown($post->post_parent); ?>
+ </select>
+ </div>
+ </fieldset>
+<fieldset id="postdiv">
+ <legend><?php _e('Page Content') ?></legend>
+<?php the_quicktags(); ?>
+<?php
+ $rows = get_settings('default_post_edit_rows');
+ if (($rows < 3) || ($rows > 100)) {
+ $rows = 10;
+ }
+?>
+<div><textarea rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo $post->post_content ?></textarea></div>
+</fieldset>
+
+
+<script type="text/javascript">
+<!--
+edCanvas = document.getElementById('content');
+//-->
+</script>
+
+<p class="submit">
+ <input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php $post_ID ? _e('Edit Page') :_e('Create New Page') ?> &raquo;" />
+ <input name="referredby" type="hidden" id="referredby" value="<?php echo $sendto; ?>" />
+</p>
+
+<fieldset id="pageoptions">
+ <legend><?php _e('Page Options') ?></legend>
+<table width="100%" cellspacing="2" cellpadding="5" class="editform">
+<?php if ( 0 != count( get_page_templates() ) ) { ?>
+ <tr valign="top">
+ <th scope="row" width="30%"><?php _e('Page Template:') ?></th>
+ <td><div><select name="page_template">
+ <option value='default'><?php _e('Default Template'); ?></option>
+ <?php page_template_dropdown($post->page_template); ?>
+ </select>
+
+ </div>
+ </td>
+ </tr>
+<?php } ?>
+ <tr valign="top">
+ <th scope="row" width="30%"><?php _e('Page slug') ?>:</th>
+ <td><input name="post_name" type="text" size="25" id="post_name" value="<?php echo $post->post_name ?>" /></td>
+ </tr>
+<?php if ( $authors = get_editable_authors( $current_user->ID ) ) : // TODO: ROLE SYSTEM ?>
+ <tr>
+ <th scope="row" width="30%"><?php _e('Page owner'); ?>:</th>
+ <td>
+ <select name="post_author" id="post_author">
+ <?php
+ foreach ($authors as $o) :
+ $o = get_userdata( $o->ID );
+ if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
+ else $selected = '';
+ echo "<option value='$o->ID' $selected>$o->user_login ($o->first_name $o->last_name)</option>";
+ endforeach;
+ ?>
+ </select>
+ </td>
+ </tr>
+<?php endif; ?>
+ <tr>
+ <th scope="row" width="25%"><?php _e('Page Order') ?>:</th>
+ <td><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Delete'); ?>:</th>
+ <td><?php if ('edit' == $action) : ?>
+ <input name="deletepost" class="delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this page') ?>" <?php echo "onclick=\"return confirm('" . sprintf(__("You are about to delete this page \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), $wpdb->escape($post->post_title) ) . "')\""; ?> />
+<?php endif; ?></td>
+ </tr>
+</table>
+</fieldset>
+
+<fieldset id="postcustom">
+<legend><?php _e('Custom Fields') ?> <script type="text/javascript">customToggleLink();</script></legend>
+<div id="postcustomstuff">
+<?php
+if($metadata = has_meta($post_ID)) {
+?>
+<?php
+ list_meta($metadata);
+?>
+<?php
+}
+ meta_form();
+?>
+</div>
+</fieldset>
+
+<?php do_action('edit_page_form', ''); ?>
+</form>
+
+</div>
diff --git a/wp-inst/wp-admin/edit-pages.php b/wp-inst/wp-admin/edit-pages.php
new file mode 100644
index 0000000..6609e74
--- /dev/null
+++ b/wp-inst/wp-admin/edit-pages.php
@@ -0,0 +1,52 @@
+<?php
+require_once('admin.php');
+$title = __('Pages');
+$parent_file = 'edit.php';
+require_once('admin-header.php');
+
+get_currentuserinfo();
+?>
+
+<div class="wrap">
+<h2><?php _e('Page Management'); ?></h2>
+
+<?php
+/*
+if (isset($user_ID) && ('' != intval($user_ID))) {
+ $posts = $wpdb->get_results("
+ SELECT $wpdb->posts.*, $wpdb->users.user_level FROM $wpdb->posts
+ INNER JOIN $wpdb->users ON ($wpdb->posts.post_author = $wpdb->users.ID)
+ WHERE $wpdb->posts.post_status = 'static'
+ AND ($wpdb->users.user_level < $user_level OR $wpdb->posts.post_author = $user_ID)
+ ");
+} else { */
+ $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'");
+// } FIXME
+
+if ($posts) {
+?>
+<table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+ <th scope="col"><?php _e('ID') ?></th>
+ <th scope="col"><?php _e('Title') ?></th>
+ <th scope="col"><?php _e('Owner') ?></th>
+ <th scope="col"><?php _e('Updated') ?></th>
+ <th scope="col"></th>
+ <th scope="col"></th>
+ <th scope="col"></th>
+ </tr>
+<?php page_rows(); ?>
+</table>
+<?php
+} else {
+?>
+<p><?php _e('No pages yet.') ?></p>
+<?php
+} // end if ($posts)
+?>
+<p><?php _e('Pages are like posts except they live outside of the normal blog chronology. You can use pages to organize and manage any amount of content.'); ?></p>
+<h3><a href="page-new.php"><?php _e('Create New Page'); ?> &raquo;</a></h3>
+</div>
+
+
+<?php include('admin-footer.php'); ?>
diff --git a/wp-inst/wp-admin/edit.php b/wp-inst/wp-admin/edit.php
new file mode 100644
index 0000000..7f41629
--- /dev/null
+++ b/wp-inst/wp-admin/edit.php
@@ -0,0 +1,291 @@
+<?php
+require_once('admin.php');
+
+$title = __('Posts');
+$parent_file = 'edit.php';
+require_once('admin-header.php');
+
+$_GET['m'] = (int) $_GET['m'];
+
+get_currentuserinfo();
+
+$drafts = get_users_drafts( $user_ID );
+$other_drafts = get_others_drafts( $user_ID);
+
+if ($drafts || $other_drafts) {
+?>
+<div class="wrap">
+<?php if ($drafts) { ?>
+ <p><strong><?php _e('Your Drafts:') ?></strong>
+ <?php
+ $i = 0;
+ foreach ($drafts as $draft) {
+ if (0 != $i)
+ echo ', ';
+ $draft->post_title = stripslashes($draft->post_title);
+ if ($draft->post_title == '')
+ $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
+ echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
+ ++$i;
+ }
+ ?>
+ .</p>
+<?php } ?>
+
+<?php if ($other_drafts) { ?>
+ <p><strong><?php _e('Other&#8217;s Drafts:') ?></strong>
+ <?php
+ $i = 0;
+ foreach ($other_drafts as $draft) {
+ if (0 != $i)
+ echo ', ';
+ $draft->post_title = stripslashes($draft->post_title);
+ if ($draft->post_title == '')
+ $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
+ echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
+ ++$i;
+ }
+ ?>
+ .</p>
+
+<?php } ?>
+
+</div>
+<?php } ?>
+
+<div class="wrap">
+<h2>
+<?php
+$what_to_show = 'posts';
+$posts_per_page = 15;
+$posts_per_archive_page = -1;
+
+wp();
+
+if ( is_month() ) {
+ single_month_title(' ');
+} elseif ( is_search() ) {
+ printf(__('Search for &#8220;%s&#8221;'), wp_specialchars($_GET['s']) );
+} else {
+ if ( ! is_paged() || get_query_var('paged') == 1 )
+ _e('Last 15 Posts');
+ else
+ _e('Previous Posts');
+}
+?>
+</h2>
+
+<form name="searchform" action="" method="get" style="float: left; width: 16em; margin-right: 3em;">
+ <fieldset>
+ <legend><?php _e('Search Posts&hellip;') ?></legend>
+ <input type="text" name="s" value="<?php if (isset($s)) echo wp_specialchars($s, 1); ?>" size="17" />
+ <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+ </fieldset>
+</form>
+
+<form name="viewarc" action="" method="get" style="float: left; width: 20em; margin-bottom: 1em;">
+ <fieldset>
+ <legend><?php _e('Browse Month&hellip;') ?></legend>
+ <select name='m'>
+ <?php
+ $arc_result=$wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts ORDER BY post_date DESC");
+ foreach ($arc_result as $arc_row) {
+ $arc_year = $arc_row->yyear;
+ $arc_month = $arc_row->mmonth;
+
+ if( isset($_GET['m']) && $arc_year . zeroise($arc_month, 2) == (int) $_GET['m'] )
+ $default = 'selected="selected"';
+ else
+ $default = null;
+
+ echo "<option $default value=\"" . $arc_year.zeroise($arc_month, 2) . '">';
+ echo $month[zeroise($arc_month, 2)] . " $arc_year";
+ echo "</option>\n";
+ }
+ ?>
+ </select>
+ <input type="submit" name="submit" value="<?php _e('Show Month') ?>" />
+ </fieldset>
+</form>
+
+<br style="clear:both;" />
+
+<?php
+
+// define the columns to display, the syntax is 'internal name' => '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'] = '';
+
+?>
+
+<table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+
+<?php foreach($posts_columns as $column_display_name) { ?>
+ <th scope="col"><?php echo $column_display_name; ?></th>
+<?php } ?>
+
+ </tr>
+<?php
+if ($posts) {
+$bgcolor = '';
+foreach ($posts as $post) { start_wp();
+$class = ('alternate' == $class) ? '' : 'alternate';
+?>
+ <tr class='<?php echo $class; ?>'>
+
+<?php
+
+foreach($posts_columns as $column_name=>$column_display_name) {
+
+ switch($column_name) {
+
+ case 'id':
+ ?>
+ <th scope="row"><?php echo $id ?></th>
+ <?php
+ break;
+
+ case 'date':
+ ?>
+ <td><?php the_time('Y-m-d \<\b\r \/\> g:i:s a'); ?></td>
+ <?php
+ break;
+ case 'title':
+ ?>
+ <td><?php the_title() ?>
+ <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
+ <?php
+ break;
+
+ case 'categories':
+ ?>
+ <td><?php the_category(','); ?></td>
+ <?php
+ break;
+
+ case 'comments':
+ ?>
+ <td><a href="edit.php?p=<?php echo $id ?>&amp;c=1">
+ <?php comments_number(__('0'), __('1'), __('%')) ?>
+ </a></td>
+ <?php
+ break;
+
+ case 'author':
+ ?>
+ <td><?php the_author() ?></td>
+ <?php
+ break;
+
+ case 'control_view':
+ ?>
+ <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
+ <?php
+ break;
+
+ case 'control_edit':
+ ?>
+ <td><?php if ( user_can_edit_post($user_ID,$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
+ <?php
+ break;
+
+ case 'control_delete':
+ ?>
+ <td><?php if ( user_can_edit_post($user_ID,$post->ID) ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "')\">" . __('Delete') . "</a>"; } ?></td>
+ <?php
+ break;
+
+ default:
+ ?>
+ <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
+ <?php
+ break;
+ }
+}
+?>
+ </tr>
+<?php
+}
+} else {
+?>
+ <tr style='background-color: <?php echo $bgcolor; ?>'>
+ <td colspan="8"><?php _e('No posts found.') ?></td>
+ </tr>
+<?php
+} // end if ($posts)
+?>
+</table>
+
+<div class="navigation">
+<div class="alignleft"><?php next_posts_link(__('&laquo; Previous Entries')) ?></div>
+<div class="alignright"><?php previous_posts_link(__('Next Entries &raquo;')) ?></div>
+</div>
+
+<?php
+if ( 1 == count($posts) ) {
+
+ $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
+ if ($comments) {
+ ?>
+<h3><?php _e('Comments') ?></h3>
+<ol id="comments">
+<?php
+foreach ($comments as $comment) {
+$comment_status = wp_get_comment_status($comment->comment_ID);
+?>
+
+<li <?php if ("unapproved" == $comment_status) echo "class='unapproved'"; ?> >
+ <?php comment_date('Y-n-j') ?>
+ @
+ <?php comment_time('g:m:s a') ?>
+ <?php
+ if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) {
+ echo "[ <a href=\"post.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" . __('Edit') . "</a>";
+ echo " - <a href=\"post.php?action=deletecomment&amp;p=".$post->ID."&amp;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') . "</a> ";
+ if ( ('none' != $comment_status) && ($user_level >= 3) ) {
+ if ('approved' == wp_get_comment_status($comment->comment_ID)) {
+ echo " - <a href=\"post.php?action=unapprovecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\">" . __('Unapprove') . "</a> ";
+ } else {
+ echo " - <a href=\"post.php?action=approvecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\">" . __('Approve') . "</a> ";
+ }
+ }
+ echo "]";
+ } // end if any comments to show
+ ?>
+ <br />
+ <strong>
+ <?php comment_author() ?>
+ (
+ <?php comment_author_email_link() ?>
+ /
+ <?php comment_author_url_link() ?>
+ )</strong> (IP:
+ <?php comment_author_IP() ?>
+ )
+ <?php comment_text() ?>
+
+</li>
+<!-- /comment -->
+<?php //end of the loop, don't delete
+ } // end foreach
+ echo '</ol>';
+ }//end if comments
+ ?>
+<?php } ?>
+</div>
+<?php
+ include('admin-footer.php');
+?>
diff --git a/wp-inst/wp-admin/import-b2.php b/wp-inst/wp-admin/import-b2.php
new file mode 100644
index 0000000..9344025
--- /dev/null
+++ b/wp-inst/wp-admin/import-b2.php
@@ -0,0 +1,247 @@
+<?php
+if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. Double check that you updated wp-config-sample.php with the proper database connection information and renamed it to wp-config.php.");
+require_once('../wp-config.php');
+require_once('upgrade-functions.php');
+$step = $_GET['step'];
+if (!$step) $step = 0;
+header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <title>WordPress &#8212; b2 Conversion</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <style media="screen" type="text/css">
+ body {
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 15%;
+ margin-right: 15%;
+ }
+ #logo {
+ margin: 0;
+ padding: 0;
+ background-image: url(http://wordpress.org/images/wordpress.gif);
+ background-repeat: no-repeat;
+ height: 60px;
+ border-bottom: 4px solid #333;
+ }
+ #logo a {
+ display: block;
+ height: 60px;
+ }
+ #logo a span {
+ display: none;
+ }
+ p, li {
+ line-height: 140%;
+ }
+ </style>
+</head>
+<body>
+<h1 id="logo"><a href="http://wordpress.org"><span>WordPress</span></a></h1>
+<?php
+switch($step) {
+
+ case 0:
+?>
+<p>Welcome to WordPress. Since you&#8217;re upgrading from b2 everything should be relatively
+ familiar to you. Here are some notes on upgrading:</p>
+<ul>
+ <li>If you&#8217;re using an older version of b2, it's probably a good idea to upgrade
+ to at least .61 before making the leap to WordPress.</li>
+ <li>The templates are so much better, and there is so much more going on than
+ before it&#8217;s probably worth it to start from scratch and work back to your
+ design.</li>
+ <li>You need to transfer some of your settings from your old <code>b2config.php</code>
+ to <code>wp-config.php</code> file.</li>
+ <li>WordPress issues should be discussed in our <a href="http://wordpress.org/support/">support
+ forums</a>.</li>
+ <li><strong>Back up</strong> your database before you do anything. Yes, you.</li>
+</ul>
+<p>Have you looked at the <a href="../readme.html">readme</a>? If
+ you&#8217;re all ready, <a href="import-b2.php?step=1">let&#8217;s go</a>!</p>
+<?php
+ break;
+
+ case 1:
+?>
+<h1>Step 1</h1>
+<p>Okay first we&#8217;re going to set up the links database. This will allow you to host your own blogroll, complete with Weblogs.com updates.</p>
+<?php
+
+$got_links = false;
+$got_cats = false;
+$got_row = false;
+?>
+<p>Installing WP-Links.</p>
+<p>Checking for tables...</p>
+<?php
+$result = mysql_list_tables(DB_NAME);
+if (!$result) {
+ print "DB Error, could not list tables\n";
+ print 'MySQL Error: ' . mysql_error();
+ exit;
+}
+
+while ($row = mysql_fetch_row($result)) {
+ if ($row[0] == $wpdb->links)
+ $got_links = true;
+ if ($row[0] == $wpdb->linkcategories)
+ $got_cats = true;
+ //print "Table: $row[0]<br />\n";
+}
+if (!$got_cats) {
+ echo "<p>Can't find table '$wpdb->linkcategories', gonna create it...</p>\n";
+ $sql = "CREATE TABLE $wpdb->linkcategories ( " .
+ " cat_id int(11) NOT NULL auto_increment, " .
+ " cat_name tinytext NOT NULL, ".
+ " auto_toggle enum ('Y','N') NOT NULL default 'N', ".
+ " PRIMARY KEY (cat_id) ".
+ ") ";
+ $result = mysql_query($sql) or print ("Can't create the table '$wpdb->linkcategories' in the database.<br />" . $sql . "<br />" . mysql_error());
+ if ($result != false) {
+ echo "<p>Table '$wpdb->linkcategories' created OK</p>\n";
+ $got_cats = true;
+ }
+} else {
+ echo "<p>Found table '$wpdb->linkcategories', don't need to create it...</p>\n";
+ $got_cats = true;
+}
+if (!$got_links) {
+ echo "<p>Can't find '$wpdb->links', gonna create it...</p>\n";
+ $sql = "CREATE TABLE $wpdb->links ( " .
+ " link_id int(11) 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 int(11) NOT NULL default 0, " .
+ " link_description varchar(255) NOT NULL default '', " .
+ " link_visible enum ('Y','N') NOT NULL default 'Y', " .
+ " link_owner int NOT NULL DEFAULT '1', " .
+ " link_rating int 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 default '', " .
+ " PRIMARY KEY (link_id) " .
+ ") ";
+ $result = mysql_query($sql) or print ("Can't create the table '$wpdb->links' in the database.<br />" . $sql . "<br />" . mysql_error());
+ $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://wordpress.org/', 'WordPress', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');");
+ $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://photomatt.net/', 'Matt', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');");
+ $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://zed1.com/b2/', 'Mike', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');");
+
+ if ($result != false) {
+ echo "<p>Table '$wpdb->links' created OK</p>\n";
+ $got_links = true;
+ }
+} else {
+ echo "<p>Found table '$wpdb->links', don't need to create it...</p>\n";
+ echo "<p>... may need to update it though. Looking for column link_updated...</p>\n";
+ $query = "SELECT link_updated FROM $wpdb->links LIMIT 1";
+ $q = @mysql_query($query);
+ if ($q != false) {
+ if ($row = mysql_fetch_object($q)) {
+ echo "<p>You have column link_updated. Good!</p>\n";
+ }
+ } else {
+ $query = "ALTER TABLE $wpdb->links ADD COLUMN link_updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'";
+ $q = mysql_query($query) or mysql_doh("Doh, couldn't add column.", $query, mysql_error());
+ echo "<p>Added column link_updated...</p>\n";
+ }
+ echo "<p>Looking for column link_rel...</p>\n";
+ $query = "SELECT link_rel FROM $wpdb->links LIMIT 1";
+ $q = @mysql_query($query);
+ if ($q != false) {
+ if ($row = mysql_fetch_object($q)) {
+ echo "<p>You have column link_rel. Good!</p>\n";
+ }
+ } else {
+ $query = "ALTER TABLE $wpdb->links ADD COLUMN link_rel varchar(255) NOT NULL DEFAULT '' ";
+ $q = mysql_query($query) or mysql_doh("Doh, couldn't add column.", $query, mysql_error());
+ echo "<p>Added column link_rel...</p>\n";
+ }
+ $got_links = true;
+}
+
+if ($got_links && $got_cats) {
+ echo "<p>Looking for category 1...</p>\n";
+ $sql = "SELECT * FROM $wpdb->linkcategories WHERE cat_id=1 ";
+ $result = mysql_query($sql) or print ("Can't query '$wpdb->linkcategories'.<br />" . $sql . "<br />" . mysql_error());
+ if ($result != false) {
+ if ($row = mysql_fetch_object($result)) {
+ echo "<p>You have at least 1 category. Good!</p>\n";
+ $got_row = true;
+ } else {
+ echo "<p>Gonna insert category 1...</p>\n";
+ $sql = "INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, 'General')";
+ $result = mysql_query($sql) or print ("Can't query insert category.<br />" . $sql . "<br />" . mysql_error());
+ if ($result != false) {
+ echo "<p>Inserted category Ok</p>\n";
+ $got_row = true;
+ }
+ }
+ }
+}
+
+if ($got_row) {
+ echo "<p>All done!</p>\n";
+}
+?>
+<p>Did you defeat the boss monster at the end? Good, then you&#8217;re ready for
+ <a href="import-b2.php?step=2">Step 2</a>.</p>
+<?php
+ break;
+ case 2:
+?>
+<h1>Step 2</h1>
+<p>First we&#8217;re going to add excerpt, post, and password functionality...</p>
+
+<?php
+
+$query = "ALTER TABLE $wpdb->posts ADD COLUMN post_excerpt text NOT NULL;";
+$q = $wpdb->query($query);
+// 0.71 mods
+$query = "ALTER TABLE $wpdb->posts ADD post_status ENUM('publish','draft','private') NOT NULL,
+ADD comment_status ENUM('open','closed') NOT NULL,
+ADD ping_status ENUM('open','closed') NOT NULL,
+ADD post_password varchar(20) NOT NULL;";
+$q = $wpdb->query($query);
+?>
+
+<p>That went well! Now let's clean up the b2 database structure a bit...</p>
+
+<?php
+$query = "ALTER TABLE $wpdb->posts DROP INDEX ID";
+
+$q = $wpdb->query($query);
+
+?>
+
+<p>One down, two to go...</p>
+
+
+<p>So far so good.</p>
+<?php
+
+$query="ALTER TABLE $wpdb->posts DROP post_karma";
+$q = $wpdb->query($query);
+flush();
+?>
+
+<p>Almost there...</p>
+
+<?php
+
+$query = "ALTER TABLE $wpdb->users DROP INDEX ID";
+
+$q = $wpdb->query($query);
+upgrade_all();
+?>
+
+<p>Welcome to the family. <a href="../">Have fun</a>!</p>
+ <?php
+ break;
+}
+?>
+
+</body>
+</html> \ No newline at end of file
diff --git a/wp-inst/wp-admin/import-blogger.php b/wp-inst/wp-admin/import-blogger.php
new file mode 100644
index 0000000..19a47fc
--- /dev/null
+++ b/wp-inst/wp-admin/import-blogger.php
@@ -0,0 +1,207 @@
+<?php
+
+$wpvarstoreset = array('action');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+require_once('../wp-config.php');
+require_once('upgrade-functions.php');
+header( 'Content-Type: text/html; charset=utf-8' );
+switch ($action) {
+
+case "step1":
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <title>Blogger to WordPress - Converting...</title>
+ <link rel="stylesheet" href="wp-admin.css" type="text/css">
+</head>
+<body>
+<div class="wrap">
+<h1>Blogger to <img src="../wp-images/wpminilogo.png" width="50" height="50" border="0" alt="WordPress" align="top" /></h1>
+<p>The importer is running...</p>
+<ul>
+ <li>Importing posts and users
+ <ul><?php
+
+ for($bgy=1999; $bgy<=(date('Y')); $bgy++) {
+ for($bgm=1; $bgm<13; $bgm++) {
+
+ $bgmm = zeroise($bgm,2);
+
+ $archivefile = "../$bgy"."_"."$bgmm"."_01_wordpress.php";
+
+ if (file_exists($archivefile)) {
+
+ $f = fopen($archivefile,"r");
+ $archive = fread($f, filesize($archivefile));
+ fclose($f);
+ echo "<li>$bgy/$bgmm ";
+
+ $posts = explode('<wordpresspost>', $archive);
+
+ for ($i = 1; $i < count($posts); $i = $i + 1) {
+
+ $postinfo = explode('|||', $posts[$i]);
+ $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];
+
+ $post_author = trim($wpdb->escape($postinfo[1]));
+ // we'll check the author is registered already
+ $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$post_author'");
+ if (!$user) { // seems s/he's not, so let's register
+ $user_joindate = '1979-06-06 00:41:00'; // that's my birthdate (gmt+1) - I could choose any other date. You could change the date too. Just remember the year must be >=1970 or the world would just randomly fall on your head (everything might look fine, and then blam! major headache!)
+ $user_login = $wpdb->escape($post_author);
+ $pass1 = $wpdb->escape('password');
+ $user_email = $wpdb->escape('user@wordpress.org');
+ $user_url = $wpdb->escape('');
+ $user_joindate = $wpdb->escape($user_joindate);
+ $result = $wpdb->query("
+ INSERT INTO $wpdb->users (
+ user_login,
+ user_pass,
+ user_email,
+ user_url,
+ user_registered,
+ user_level,
+ ) VALUES (
+ '$user_login',
+ '$pass1',
+ '$user_email',
+ '$user_url',
+ '$user_joindate',
+ '1',
+ )");
+
+ echo ": Registered user <strong>$user_login</strong>";
+ }
+
+ $post_author_ID = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$post_author'");
+
+ $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 = $wpdb->escape($post_content);
+ $post_content = str_replace('<br>', '<br />', $post_content); // the XHTML touch... ;)
+
+ $post_title = $wpdb->escape($post_title);
+
+ // Quick-n-dirty check for dups:
+ $dupcheck = $wpdb->get_results("SELECT ID,post_date,post_title FROM $wpdb->posts WHERE post_date='$post_date' AND post_title='$post_title' LIMIT 1",ARRAY_A);
+ if ($dupcheck[0]['ID']) {
+ print "<br />\nSkipping duplicate post, ID = '" . $dupcheck[0]['ID'] . "'<br />\n";
+ print "Timestamp: " . $post_date . "<br />\n";
+ print "Post Title: '" . stripslashes($post_title) . "'<br />\n";
+ continue;
+ }
+
+ $result = $wpdb->query("
+ INSERT INTO $wpdb->posts
+ (post_author,post_date,post_content,post_title,post_category)
+ VALUES
+ ('$post_author_ID','$post_date','$post_content','$post_title','1')
+ ");
+
+
+ } echo '... <strong>Done</strong></li>';
+
+ }}
+ }
+
+ upgrade_all();
+ ?>
+</ul>
+<strong>Done</strong>
+</li>
+</ul>
+<p>&nbsp;</p>
+<p>Completed Blogger to WordPress import!</p>
+<p>Now you can go and <a href="../wp-login.php">log in</a>, have fun!</p>
+</div>
+</body>
+</html>
+ <?php
+ break;
+
+default:
+
+ ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <title>Blogger to WordPress Import Utility</title>
+ <link rel="stylesheet" href="wp-admin.css" type="text/css">
+</head>
+
+<body>
+<div class="wrap">
+<h1>Blogger to <img src="../wp-images/wpminilogo.png" width="50" height="50" border="0" alt="WordPress" align="top" /></h1>
+<p>This is a basic Blogger to WordPress import script.</p>
+<p>What it does:</p>
+<ul>
+ <li>Parses your archives to retrieve your blogger posts.</li>
+ <li>Adds an author whenever it sees a new nickname, all authors are imported at level 1, with a default profile and the password 'password'</li>
+</ul>
+<p>What it does not:</p>
+<ul>
+ <li>It sucks at making coffee.</li>
+ <li>It always forgets to call back.</li>
+</ul>
+
+<h2>First step: Install WordPress</h2>
+<p>Install the WordPress blog as explained in the <a href="../readme.html">read me</a>, then immediately come back here.</p>
+
+<h3>Second step: let's play with Blogger</h3>
+<p>Log into your Blogger account.<br />
+Go to the Settings, and make Blogger publish your files in the directory where your WordPress resides. Change the Date/Time format to be mm/dd/yyyy hh:mm:ss AM/PM (the first choice in the dropdown menu). In Archives: set the frequency to 'monthly' and the archive filename to 'wordpress.php' (without the quotes), set the ftp archive path to make Blogger publish the archives in your WordPress directory. Click 'save changes'.<br />
+Go to the Templates. Replace your existing template with this line (copy and paste):
+<blockquote>&lt;Blogger>&lt;wordpresspost>&lt;$BlogItemDateTime$>|||&lt;$BlogItemAuthorNickname$>|||&lt;$BlogItemBody$>|||&lt;$BlogItemNumber$>|||&lt;$BlogItemSubject$>&lt;/Blogger></blockquote>
+Go to the Archives, and click 'republish all'.<br />
+Check in your FTP that you've got the archive files published. They should look like this example: <code>2001_10_01_wordpress.php</code>. If they aren't there, redo the republish process.</p>
+<p>You're done with the hard part. :)</p>
+
+<form name="stepOne" method="get">
+<input type="hidden" name="action" value="step1" />
+<h3>Third step: w00t, let's click OK:</h3>
+<p>When you're ready, click OK to start importing: <input type="submit" name="submit" value="OK" /><br /><br />
+<i>Note: the script might take some time, like 1 second for 100 entries
+imported. DO NOT STOP IT or else you won't have a complete import.</i></p>
+</form>
+</div>
+</body>
+</html>
+ <?php
+ break;
+
+}
+
+?>
diff --git a/wp-inst/wp-admin/import-greymatter.php b/wp-inst/wp-admin/import-greymatter.php
new file mode 100644
index 0000000..4d96a82
--- /dev/null
+++ b/wp-inst/wp-admin/import-greymatter.php
@@ -0,0 +1,315 @@
+<?php
+if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. You must install WordPress before you import any entries.");
+
+require_once('../wp-config.php');
+require_once('upgrade-functions.php');
+
+$wpvarstoreset = array('action', 'gmpath', 'archivespath', 'lastentry');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+header( 'Content-Type: text/html; charset=utf-8' );
+?>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<title>WordPress &rsaquo; Import from GreyMatter</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style media="screen" type="text/css">
+ body {
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 20%;
+ margin-right: 20%;
+ }
+ #logo {
+ margin: 0;
+ padding: 0;
+ background-image: url(http://wordpress.org/images/logo.png);
+ background-repeat: no-repeat;
+ height: 60px;
+ border-bottom: 4px solid #333;
+ }
+ #logo a {
+ display: block;
+ text-decoration: none;
+ text-indent: -100em;
+ height: 60px;
+ }
+ p {
+ line-height: 140%;
+ }
+ #authors li {
+ padding:3px;
+ border: 1px solid #ccc;
+ width: 40%;
+ margin-bottom:2px;
+ }
+ </style>
+</head><body>
+<h1 id="logo"><a href="http://wordpress.org">WordPress</a></h1>
+
+<?php
+switch ($action) {
+
+case "step1":
+
+ function gm2autobr($string) { // transforms GM's |*| into wp's <br />\n
+ $string = str_replace("|*|","<br />\n",$string);
+ return($string);
+ }
+
+ if (!@chdir($archivespath))
+ die("Wrong path, $archivespath\ndoesn't exist\non the server");
+
+ if (!@chdir($gmpath))
+ die("Wrong path, $gmpath\ndoesn't exist\non the server");
+?>
+
+<p>The importer is running...</p>
+<ul>
+<li>importing users... <ul><?php
+
+ chdir($gmpath);
+ $userbase = file("gm-authors.cgi");
+
+ foreach($userbase as $user) {
+ $userdata=explode("|", $user);
+
+ $s=$userdata[4];
+ $user_joindate=substr($s,6,4)."-".substr($s,0,2)."-".substr($s,3,2)." 00:00:00";
+
+ $user_login=$wpdb->escape($userdata[0]);
+ $pass1=$wpdb->escape($userdata[1]);
+ $user_nickname=$wpdb->escape($userdata[0]);
+ $user_email=$wpdb->escape($userdata[2]);
+ $user_url=$wpdb->escape($userdata[3]);
+ $user_joindate=$wpdb->escape($user_joindate);
+
+ $loginthere = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '$user_login'");
+ if ($loginthere) {
+ echo "<li>user <i>$user_login</i>... <b>Already exists</b></li>";
+ continue;
+ }
+
+ $query = "INSERT INTO $wpdb->users (user_login,user_pass,user_email,user_url,user_registered,user_level) VALUES ('$user_login','$pass1','$user_email','$user_url','$user_joindate','1')";
+ $result = $wpdb->query($query);
+ if ($result==false) {
+ die ("<strong>ERROR</strong>: couldn't register an user!");
+ }
+ echo "<li>user <i>$user_login</i>... <b>Done</b></li>";
+
+ }
+
+?></ul><b>Done</b></li>
+<li>importing posts, comments, and karma...<br /><ul><?php
+
+ chdir($archivespath);
+
+ for($i = 0; $i <= $lastentry; $i = $i + 1) {
+
+ $entryfile = "";
+
+ if ($i<10000000) {
+ $entryfile .= "0";
+ if ($i<1000000) {
+ $entryfile .= "0";
+ if ($i<100000) {
+ $entryfile .= "0";
+ if ($i<10000) {
+ $entryfile .= "0";
+ if ($i<1000) {
+ $entryfile .= "0";
+ if ($i<100) {
+ $entryfile .= "0";
+ if ($i<10) {
+ $entryfile .= "0";
+ }}}}}}}
+
+ $entryfile .= "$i";
+
+ if (is_file($entryfile.".cgi")) {
+
+ $entry=file($entryfile.".cgi");
+ echo "<li>entry # $entryfile ";
+ $postinfo=explode("|",$entry[0]);
+ $postmaincontent=gm2autobr($entry[2]);
+ $postmorecontent=gm2autobr($entry[3]);
+
+ $post_author=trim($wpdb->escape($postinfo[1]));
+ // we'll check the author is registered, or if it's a deleted author
+ $sql = "SELECT * FROM $wpdb->users WHERE user_login = '$post_author'";
+ $result = $wpdb->query($sql);
+ if (! $result) { // if deleted from GM, we register the author as a level 0 user in wp
+ $user_joindate="1979-06-06 00:41:00";
+ $user_login=$wpdb->escape($post_author);
+ $pass1=$wpdb->escape("password");
+ $user_nickname=$wpdb->escape($post_author);
+ $user_email=$wpdb->escape("user@deleted.com");
+ $user_url=$wpdb->escape("");
+ $user_joindate=$wpdb->escape($user_joindate);
+ $query = "INSERT INTO $wpdb->users (user_login,user_pass,user_email,user_url,user_registered,user_level) VALUES ('$user_login','$pass1','$user_email','$user_url','$user_joindate','0')";
+ $result = $wpdb->query($query);
+ if ($result==false) {
+ die ("<strong>ERROR</strong>: couldn't register an user!");
+ }
+ echo ": registered deleted user <i>$user_login</i> at level 0 ";
+ }
+
+ $sql = "SELECT ID FROM $wpdb->users WHERE user_login = '$post_author'";
+ $post_author_ID = $wpdb->get_var($sql);
+
+ $post_title=gm2autobr($postinfo[2]);
+ $post_title=$wpdb->escape($post_title);
+
+ $postyear=$postinfo[6];
+ $postmonth=zeroise($postinfo[4],2);
+ $postday=zeroise($postinfo[5],2);
+ $posthour=zeroise($postinfo[7],2);
+ $postminute=zeroise($postinfo[8],2);
+ $postsecond=zeroise($postinfo[9],2);
+
+ if (($postinfo[10]=="PM") && ($posthour!="12"))
+ $posthour=$posthour+12;
+
+ $post_date="$postyear-$postmonth-$postday $posthour:$postminute:$postsecond";
+
+ $post_content=$postmaincontent;
+ if (strlen($postmorecontent)>3)
+ $post_content .= "<!--more--><br /><br />".$postmorecontent;
+ $post_content=$wpdb->escape($post_content);
+
+ $post_karma=$postinfo[12];
+
+ $query = "INSERT INTO $wpdb->posts (post_author,post_date,post_content,post_title) VALUES ('$post_author_ID','$post_date','$post_content','$post_title')";
+ $result = $wpdb->query($query);
+
+ if (!$result)
+ die ("Error in posting...");
+
+ $query = "SELECT ID FROM $wpdb->posts ORDER BY ID DESC LIMIT 1";
+ $post_ID = $wpdb->get_var($query);
+
+ // Grab a default category.
+ $post_category = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories LIMIT 1");
+
+ // Update the post2cat table.
+ $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category");
+
+ if (!$exists) {
+ $wpdb->query("
+ INSERT INTO $wpdb->post2cat
+ (post_id, category_id)
+ VALUES
+ ($post_ID, $post_category)
+ ");
+ }
+
+ $c=count($entry);
+ if ($c>4) {
+ for ($j=4;$j<$c;$j++) {
+ $entry[$j]=gm2autobr($entry[$j]);
+ $commentinfo=explode("|",$entry[$j]);
+ $comment_post_ID=$post_ID;
+ $comment_author=$wpdb->escape($commentinfo[0]);
+ $comment_author_email=$wpdb->escape($commentinfo[2]);
+ $comment_author_url=$wpdb->escape($commentinfo[3]);
+ $comment_author_IP=$wpdb->escape($commentinfo[1]);
+
+ $commentyear=$commentinfo[7];
+ $commentmonth=zeroise($commentinfo[5],2);
+ $commentday=zeroise($commentinfo[6],2);
+ $commenthour=zeroise($commentinfo[8],2);
+ $commentminute=zeroise($commentinfo[9],2);
+ $commentsecond=zeroise($commentinfo[10],2);
+ if (($commentinfo[11]=="PM") && ($commenthour!="12"))
+ $commenthour=$commenthour+12;
+ $comment_date="$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond";
+
+ $comment_content=$wpdb->escape($commentinfo[12]);
+
+ $sql3 = "INSERT INTO $wpdb->comments (comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_author_IP,comment_date,comment_content) VALUES ('$comment_post_ID','$comment_author','$comment_author_email','$comment_author_url','$comment_author_IP','$comment_date','$comment_content')";
+ $result3 = $wpdb->query($sql3);
+ if (!$result3)
+ die ("There is an error with the database, it can't store your comment..");
+ }
+ $comments=$c-4;
+ echo ": imported $comments comment";
+ if ($comments>1)
+ echo "s";
+ }
+ echo "... <b>Done</b></li>";
+ }
+ }
+ upgrade_all();
+ ?>
+</ul><b>Done</b></li></ul>
+<p>&nbsp;</p>
+<p>Completed GM 2 WordPress import !</p>
+<p>Now you can go and <a href="wp-login.php">log in</a>, have fun !</p>
+ <?php
+ break;
+
+default:
+?>
+
+<p>This is a basic GreyMatter to WordPress import script.</p>
+<p>What it does:</p>
+<ul>
+<li>parses gm-authors.cgi to import authors: everyone is imported at level 1</li>
+<li>parses the entries cgi files to import posts, comments, and karma on posts (although karma is not used on WordPress); if authors are found not to be in gm-authors.cgi, imports them at level 0</li>
+</ul>
+<p>What it does not:</p>
+<ul>
+<li>parse gm-counter.cgi (what's the use of that file ?), gm-banlist.cgi, gm-cplog.cgi (you can make a CP log hack if you really feel like it, but I question the need of a CP log)</li>
+<li>import gm-templates. you'll start with the basic template wp.php</li>
+<li>doesn't keep entries on top</li>
+</ul>
+
+<h3>First step: Install WordPress</h3>
+<p>Install the WordPress blog as explained in the <a href="../readme.html" target="_blank">ReadMe</a>, then immediately come back here.</p>
+
+<form name="stepOne" method="get">
+<input type="hidden" name="action" value="step1" />
+<h3>Second step: Provide GreyMatter details</h3>
+<table cellpadding="0">
+<tr>
+<td>Path to GM files:</td>
+<td><input type="text" style="width:300px" name="gmpath" value="/home/my/site/cgi-bin/greymatter/" /></td>
+</tr>
+<tr>
+<td>Path to GM entries:</td>
+<td><input type="text" style="width:300px" name="archivespath" value="/home/my/site/cgi-bin/greymatter/archives/" /></td>
+</tr>
+</table>
+
+<p>This importer will search for files 00000001.cgi to 000-whatever.cgi, so you need to enter the number of the last GM post here. (If you don't know that number, just log into your FTP and look it up in the entries' folder)</p>
+
+<table>
+<tr>
+<td>Last entry's number:</td>
+<td><input type="text" name="lastentry" value="00000001" /></td>
+</tr>
+</table>
+
+<p>When you're ready, click OK to start importing: <input type="submit" name="submit" value="OK" class="search" /></p>
+</form>
+
+</body>
+</html>
+ <?php
+ break;
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/import-livejournal.php b/wp-inst/wp-admin/import-livejournal.php
new file mode 100644
index 0000000..ce76638
--- /dev/null
+++ b/wp-inst/wp-admin/import-livejournal.php
@@ -0,0 +1,124 @@
+<?php
+define('XMLFILE', '');
+// Example:
+// define('XMLFILE', '/home/example/public_html/rss.xml');
+// or if it's in the same directory as import-rss.php
+// define('XMLFILE', 'rss.xml');
+
+$post_author = 1; // Author to import posts as author ID
+$timezone_offset = 0; // GMT offset of posts your importing
+
+
+$add_hours = intval($timezone_offset);
+$add_minutes = intval(60 * ($timezone_offset - $add_hours));
+
+if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. You must install WordPress before you import any entries.");
+require_once('../wp-config.php');
+
+$step = $_GET['step'];
+if (!$step) $step = 0;
+header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<title>WordPress &rsaquo; Import from RSS</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style media="screen" type="text/css">
+ body {
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 20%;
+ margin-right: 20%;
+ }
+ #logo {
+ margin: 0;
+ padding: 0;
+ background-image: url(http://wordpress.org/images/logo.png);
+ background-repeat: no-repeat;
+ height: 60px;
+ border-bottom: 4px solid #333;
+ }
+ #logo a {
+ display: block;
+ text-decoration: none;
+ text-indent: -100em;
+ height: 60px;
+ }
+ p {
+ line-height: 140%;
+ }
+ </style>
+</head><body>
+<h1 id="logo"><a href="http://wordpress.org/">WordPress</a></h1>
+<?php
+switch($step) {
+
+ case 0:
+?>
+<p>Howdy! This importer allows you to extract posts from a LiveJournal XML export file. To get started you must edit the following line in this file (<code>import-livejournal.php</code>) </p>
+<p><code>define('XMLFILE', '');</code></p>
+<p>You want to define where the XML file we'll be working with is, for example: </p>
+<p><code>define('XMLFILE', '2002-04.xml');</code></p>
+<p>You have to do this manually for security reasons.</p>
+<p>If you've done that and you&#8217;re all ready, <a href="import-livejournal.php?step=1">let's go</a>!</p>
+<?php
+ break;
+
+ case 1:
+if ('' != XMLFILE && !file_exists(XMLFILE)) die("The file you specified does not seem to exist. Please check the path you've given.");
+if ('' == XMLFILE) die("You must edit the XMLFILE line as described on the <a href='import-rss.php'>previous page</a> to continue.");
+
+// Bring in the data
+set_magic_quotes_runtime(0);
+$datalines = file(XMLFILE); // Read the file into an array
+$importdata = implode('', $datalines); // squish it
+$importdata = str_replace(array("\r\n", "\r"), "\n", $importdata);
+
+preg_match_all('|<entry>(.*?)</entry>|is', $importdata, $posts);
+$posts = $posts[1];
+
+echo '<ol>';
+foreach ($posts as $post) :
+$title = $date = $categories = $content = $post_id = '';
+echo "<li>Importing post... ";
+
+preg_match('|<subject>(.*?)</subject>|is', $post, $title);
+$title = $wpdb->escape( trim($title[1]) );
+$post_name = sanitize_title($title);
+
+preg_match('|<eventtime>(.*?)</eventtime>|is', $post, $date);
+$date = strtotime($date[1]);
+
+$post_date = date('Y-m-d H:i:s', $date);
+
+
+preg_match('|<event>(.*?)</event>|is', $post, $content);
+$content = str_replace( array('<![CDATA[', ']]>'), '', $wpdb->escape( trim($content[1]) ) );
+
+// Now lets put it in the DB
+if ($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'")) :
+ echo 'Post already imported';
+else :
+
+ $wpdb->query("INSERT INTO $wpdb->posts
+ (post_author, post_date, post_date_gmt, post_content, post_title,post_status, comment_status, ping_status, post_name)
+ VALUES
+ ('$post_author', '$post_date', DATE_ADD('$post_date', INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE), '$content', '$title', 'publish', '$comment_status', '$ping_status', '$post_name')");
+ $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'");
+ if (!$post_id) die("couldn't get post ID");
+ $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = 1");
+ if (!$exists) $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_id, 1) ");
+ echo 'Done!</li>';
+endif;
+
+
+endforeach;
+?>
+</ol>
+
+<h3>All done. <a href="../">Have fun!</a></h3>
+<?php
+ break;
+}
+?>
+</body>
+</html> \ No newline at end of file
diff --git a/wp-inst/wp-admin/import-mt.php b/wp-inst/wp-admin/import-mt.php
new file mode 100644
index 0000000..b520d4c
--- /dev/null
+++ b/wp-inst/wp-admin/import-mt.php
@@ -0,0 +1,418 @@
+<?php
+define('MTEXPORT', '');
+// enter the relative path of the import.txt file containing the mt entries. If the file is called import.txt and it is /wp-admin, then this line
+//should be define('MTEXPORT', 'import.txt');
+
+if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. You must install WordPress before you import any entries.");
+require_once('../wp-config.php');
+require_once('upgrade-functions.php');
+$step = $_GET['step'];
+if (!$step) $step = 0;
+header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<title>WordPress &rsaquo; Import from Movable Type</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style media="screen" type="text/css">
+ body {
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 20%;
+ margin-right: 20%;
+ }
+ #logo {
+ margin: 0;
+ padding: 0;
+ background-image: url(http://wordpress.org/images/logo.png);
+ background-repeat: no-repeat;
+ height: 60px;
+ border-bottom: 4px solid #333;
+ }
+ #logo a {
+ display: block;
+ text-decoration: none;
+ text-indent: -100em;
+ height: 60px;
+ }
+ p {
+ line-height: 140%;
+ }
+ #authors li {
+ padding:3px;
+ border: 1px solid #ccc;
+ width: 40%;
+ margin-bottom:2px;
+ }
+ </style>
+</head><body>
+<h1 id="logo"><a href="http://wordpress.org">WordPress</a></h1>
+<?php
+switch($step) {
+
+ case 0:
+?>
+<p>Howdy! We&#8217;re about to begin the process to import all of your Movable Type entries into WordPress. Before we get started, you need to edit this file (<code>import-mt.php</code>) and change one line so we know where to find your MT export file. To make this easy put the import file into the <code>wp-admin</code> directory. Look for the line that says:</p>
+<p><code>define('MTEXPORT', '');</code></p>
+<p>and change it to</p>
+<p><code>define('MTEXPORT', 'import.txt');</code></p>
+<p>You have to do this manually for security reasons.</p>
+<p>If you've done that and you&#8217;re all ready, <a href="import-mt.php?step=1">let's go</a>! Remember that the import process may take a minute or so if you have a large number of entries and comments. Think of all the rebuilding time you'll be saving once it's done. :)</p>
+<p>The importer is smart enough not to import duplicates, so you can run this multiple times without worry if&#8212;for whatever reason&#8212;it doesn't finish. If you get an <strong>out of memory</strong> error try splitting up the import file into pieces. </p>
+<?php
+ break;
+
+ case 1:
+if ('' != MTEXPORT && !file_exists(MTEXPORT)) die("The file you specified does not seem to exist. Please check the path you've given.");
+if ('' == MTEXPORT) die("You must edit the MTEXPORT line as described on the <a href='import-mt.php'>previous page</a> to continue.");
+// Bring in the data
+set_magic_quotes_runtime(0);
+$importdata = file(MTEXPORT); // 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);
+$authors = array();
+$temp = array();
+$posts = explode("--MT-ENTRY--", $importdata);
+unset( $importdata ); // Free up memory
+
+function users_form($n) {
+ global $wpdb, $testing;
+ $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID");
+ ?><select name="userselect[<?php echo $n; ?>]">
+ <option value="#NONE#">- Select -</option>
+ <?php foreach($users as $user) {
+ echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
+ } ?>
+ </select>
+<?php }
+
+$i = -1;
+foreach ($posts as $post) {
+ if ('' != trim($post)) {
+ ++$i;
+ unset($post_categories);
+ preg_match("|AUTHOR:(.*)|", $post, $thematch);
+ $thematch = trim($thematch[1]);
+ array_push($temp,"$thematch"); //store the extracted author names in a temporary array
+ }
+ }//end of foreach
+//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");
+ }
+//by this point, we have all unique authors in the array $authors
+?><p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
+<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <i>italics</i>. 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.'); ?></p>
+<p><?php _e('If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)'); ?></p>
+ <?php
+ echo '<ol id="authors">';
+ echo '<form action="?step=2" method="post">';
+ $j = -1;
+ foreach ($authors as $author) {
+ ++$j;
+ echo '<li><i>'.$author.'</i><br />'.'<input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30">';
+ users_form($j);
+ echo '</li>';
+ }
+ echo '<input type="submit" value="Submit">'.'<br/>';
+ echo '</form>';
+ echo '</ol>';
+
+ flush();
+
+ break;
+
+ case 2:
+ $newauthornames = array();
+ $formnames = array();
+ $selectnames = array();
+ $mtnames = 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($newauthornames,"$selectnames[$i]");
+ }
+ else {
+ array_push($newauthornames,"$formnames[$i]");
+ }
+ }
+
+ $j = -1;
+ //function to check the authorname and do the mapping
+ function checkauthor($author) {
+ global $wpdb, $mtnames, $newauthornames, $j;//mtnames is an array with the names in the mt import file
+ $md5pass = md5(changeme);
+ if (!(in_array($author, $mtnames))) { //a new mt author name is found
+ ++$j;
+ $mtnames[$j] = $author; //add that new mt author name to an array
+ $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$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[$j] == 'left_blank') { //check if the user does not want to change the authorname
+ $wpdb->query("INSERT INTO $wpdb->users (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$author', '$md5pass', '$author')"); // if user does not want to change, insert the authorname $author
+ $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$author'");
+ $newauthornames[$j] = $author; //now we have a name, in the place of left_blank.
+ } else {
+ $wpdb->query("INSERT INTO $wpdb->users (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$newauthornames[$j]', '$md5pass', '$newauthornames[$j]')"); //if not left_blank, insert the user specified name
+ $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$j]'");
+ }
+ } else return $user_id; // return pre-existing wp username if it exists
+ } else {
+ $key = array_search($author, $mtnames); //find the array key for $author in the $mtnames array
+ $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$key]'");//use that key to get the value of the author's name from $newauthornames
+ }
+ return $user_id;
+}//function checkauthor ends here
+
+ //bring in the posts now
+set_magic_quotes_runtime(0);
+$importdata = file(MTEXPORT); // 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--", $importdata);
+$authors = array();
+$temp = array();
+$posts = explode("--MT-ENTRY--", $importdata);
+unset( $importdata ); // Free up memory
+
+$i = -1;
+echo "<ol>";
+foreach ($posts as $post) { if ('' != trim($post)) {
+ ++$i;
+ unset($post_categories);
+ echo "<li>Processing post... ";
+
+ // 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<!--more-->\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);
+ echo '<i>'.stripslashes($post_title).'</i>... ';
+ $post_name = sanitize_title($post_title);
+ 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':
+ $post_allow_pings = trim($meta[2][0]);
+ if ($post_allow_pings == 1) {
+ $post_allow_pings = 'open';
+ } else {
+ $post_allow_pings = 'closed';
+ }
+ break;
+ case 'PRIMARY CATEGORY':
+ $post_categories[] = $wpdb->escape($value);
+ break;
+ case 'CATEGORY':
+ $post_categories[] = $wpdb->escape($value);
+ break;
+ case 'DATE':
+ $post_date = strtotime($value);
+ $post_date = date('Y-m-d H:i:s', $post_date);
+ $post_date_gmt = get_gmt_from_date("$post_date");
+ break;
+ default:
+// echo "\n$key: $value";
+ break;
+ } // end switch
+ } // End foreach
+
+ // Let's check to see if it's in already
+ if ($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$post_title' AND post_date = '$post_date'")) {
+ echo "Post already imported.";
+ } else {
+ $post_author = checkauthor($post_author);//just so that if a post already exists, new users are not created by checkauthor
+ $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_name, post_modified, post_modified_gmt)
+ VALUES
+ ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_name','$post_date', '$post_date_gmt')");
+ $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$post_title' AND post_date = '$post_date'");
+ if (0 != count($post_categories)) {
+ foreach ($post_categories as $post_category) {
+ // See if the category exists yet
+ $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'");
+ if (!$cat_id && '' != trim($post_category)) {
+ $cat_nicename = sanitize_title($post_category);
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')");
+ $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'");
+ }
+ if ('' == trim($post_category)) $cat_id = 1;
+ // Double check it's not there already
+ $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = $cat_id");
+
+ if (!$exists) {
+ $wpdb->query("
+ INSERT INTO $wpdb->post2cat
+ (post_id, category_id)
+ VALUES
+ ($post_id, $cat_id)
+ ");
+ }
+ } // end category loop
+ } else {
+ $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = 1");
+ if (!$exists) $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_id, 1) ");
+ }
+ echo " Post imported successfully...";
+ // Now for comments
+ $comments = explode("-----\nCOMMENT:", $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_email);
+ $comment_email = $wpdb->escape(trim($comment_email[1]));
+ $comment = preg_replace('|(\n?EMAIL:.*)|', '', $comment);
+
+ preg_match("|IP:(.*)|", $comment, $comment_ip);
+ $comment_ip = trim($comment_ip[1]);
+ $comment = preg_replace('|(\n?IP:.*)|', '', $comment);
+
+ preg_match("|URL:(.*)|", $comment, $comment_url);
+ $comment_url = $wpdb->escape(trim($comment_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 (!$wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) {
+ $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved)
+ VALUES
+ ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1')");
+ echo " Comment added.";
+ }
+ }
+ }
+
+ // 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]);
+ 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);
+
+ $comment_email = '';
+
+ preg_match("|IP:(.*)|", $ping, $comment_ip);
+ $comment_ip = trim($comment_ip[1]);
+ $ping = preg_replace('|(\n?IP:.*)|', '', $ping);
+
+ preg_match("|URL:(.*)|", $ping, $comment_url);
+ $comment_url = $wpdb->escape(trim($comment_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 = "<strong>$ping_title</strong>\n\n$comment_content";
+
+ // Check if it's already there
+ if (!$wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) {
+ $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved, comment_type)
+ VALUES
+ ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1', 'trackback')");
+ echo " Comment added.";
+ }
+
+ }
+ }
+ }
+ echo "</li>";
+ flush();
+
+} }
+upgrade_all();
+?>
+</ol>
+<h3>All done. <a href="../">Have fun!</a></h3>
+<?php
+ break;
+}
+?>
+</body>
+</html>
diff --git a/wp-inst/wp-admin/import-rss.php b/wp-inst/wp-admin/import-rss.php
new file mode 100644
index 0000000..cb7b615
--- /dev/null
+++ b/wp-inst/wp-admin/import-rss.php
@@ -0,0 +1,191 @@
+<?php
+define('RSSFILE', '');
+// Example:
+// define('RSSFILE', '/home/example/public_html/rss.xml');
+// or if it's in the same directory as import-rss.php
+// define('RSSFILE', 'rss.xml');
+
+$post_author = 1; // Author to import posts as author ID
+$timezone_offset = 0; // GMT offset of posts your importing
+
+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);
+}
+
+$add_hours = intval($timezone_offset);
+$add_minutes = intval(60 * ($timezone_offset - $add_hours));
+
+if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. You must install WordPress before you import any entries.");
+require_once('../wp-config.php');
+
+$step = $_GET['step'];
+if (!$step) $step = 0;
+header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<title>WordPress &rsaquo; Import from RSS</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style media="screen" type="text/css">
+ body {
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 20%;
+ margin-right: 20%;
+ }
+ #logo {
+ margin: 0;
+ padding: 0;
+ background-image: url(http://wordpress.org/images/logo.png);
+ background-repeat: no-repeat;
+ height: 60px;
+ border-bottom: 4px solid #333;
+ }
+ #logo a {
+ display: block;
+ text-decoration: none;
+ text-indent: -100em;
+ height: 60px;
+ }
+ p {
+ line-height: 140%;
+ }
+ </style>
+</head><body>
+<h1 id="logo"><a href="http://wordpress.org/">WordPress</a></h1>
+<?php
+switch($step) {
+
+ case 0:
+?>
+<p>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. To get started you must edit the following line in this file (<code>import-rss.php</code>) </p>
+<p><code>define('RSSFILE', '');</code></p>
+<p>You want to define where the RSS file we'll be working with is, for example: </p>
+<p><code>define('RSSFILE', 'rss.xml');</code></p>
+<p>You have to do this manually for security reasons. When you're done reload this page and we'll take you to the next step.</p>
+<?php if ('' != RSSFILE) : ?>
+<h2 style="text-align: right;"><a href="import-rss.php?step=1">Begin RSS Import &raquo;</a></h2>
+<?php endif; ?>
+<?php
+ break;
+
+ case 1:
+
+// Bring in the data
+set_magic_quotes_runtime(0);
+$datalines = file(RSSFILE); // Read the file into an array
+$importdata = implode('', $datalines); // squish it
+$importdata = str_replace(array("\r\n", "\r"), "\n", $importdata);
+
+preg_match_all('|<item>(.*?)</item>|is', $importdata, $posts);
+$posts = $posts[1];
+
+echo '<ol>';
+foreach ($posts as $post) :
+$title = $date = $categories = $content = $post_id = '';
+echo "<li>Importing post... ";
+
+preg_match('|<title>(.*?)</title>|is', $post, $title);
+$title = $wpdb->escape( trim($title[1]) );
+$post_name = sanitize_title($title);
+
+preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $date);
+
+if ($date) :
+ $date = strtotime($date[1]);
+else : // if we don't already have something from pubDate
+ preg_match('|<dc:date>(.*?)</dc:date>|is', $post, $date);
+ $date = preg_replace('|([-+])([0-9]+):([0-9]+)$|', '\1\2\3', $date[1]);
+ $date = str_replace('T', ' ', $date);
+ $date = strtotime($date);
+endif;
+
+$post_date = gmdate('Y-m-d H:i:s', $date);
+
+preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
+$categories = $categories[1];
+
+if (!$categories) :
+ preg_match_all('|<dc:subject>(.*?)</dc:subject>|is', $post, $categories);
+ $categories = $categories[1];
+endif;
+
+preg_match('|<guid.+?>(.*?)</guid>|is', $post, $guid);
+if ($guid) $guid = $wpdb->escape( trim($guid[1]) );
+else $guid = '';
+
+preg_match('|<content:encoded>(.*?)</content:encoded>|is', $post, $content);
+$content = str_replace( array('<![CDATA[', ']]>'), '', $wpdb->escape( trim($content[1]) ) );
+
+if (!$content) : // This is for feeds that put content in description
+ preg_match('|<description>(.*?)</description>|is', $post, $content);
+ $content = $wpdb->escape( unhtmlentities( trim($content[1]) ) );
+endif;
+
+// Clean up content
+$content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $content);
+$content = str_replace('<br>', '<br />', $content);
+$content = str_replace('<hr>', '<hr />', $content);
+
+// This can mess up on posts with no titles, but checking content is much slower
+// So we do it as a last resort
+if ('' == $title) :
+ $dupe = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' AND post_date = '$post_date'");
+else :
+ $dupe = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'");
+endif;
+
+// Now lets put it in the DB
+if ($dupe) :
+ echo 'Post already imported';
+else :
+
+ $wpdb->query("INSERT INTO $wpdb->posts
+ (post_author, post_date, post_date_gmt, post_content, post_title,post_status, comment_status, ping_status, post_name, guid)
+ VALUES
+ ('$post_author', '$post_date', DATE_ADD('$post_date', INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE), '$content', '$title', 'publish', '$comment_status', '$ping_status', '$post_name', '$guid')");
+ $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'");
+ if (!$post_id) die("couldn't get post ID");
+ if (0 != count($categories)) :
+ foreach ($categories as $post_category) :
+ $post_category = unhtmlentities($post_category);
+ // See if the category exists yet
+ $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'");
+ if (!$cat_id && '' != trim($post_category)) {
+ $cat_nicename = sanitize_title($post_category);
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')");
+ $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'");
+ }
+ if ('' == trim($post_category)) $cat_id = 1;
+ // Double check it's not there already
+ $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = $cat_id");
+
+ if (!$exists) {
+ $wpdb->query("
+ INSERT INTO $wpdb->post2cat
+ (post_id, category_id)
+ VALUES
+ ($post_id, $cat_id)
+ ");
+ }
+ endforeach;
+ else:
+ $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = 1");
+ if (!$exists) $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_id, 1) ");
+ endif;
+ echo 'Done!</li>';
+endif;
+
+
+endforeach;
+?>
+</ol>
+
+<h3>All done. <a href="../">Have fun!</a></h3>
+<?php
+ break;
+}
+?>
+</body>
+</html> \ No newline at end of file
diff --git a/wp-inst/wp-admin/import-textpattern.php b/wp-inst/wp-admin/import-textpattern.php
new file mode 100644
index 0000000..d2f8173
--- /dev/null
+++ b/wp-inst/wp-admin/import-textpattern.php
@@ -0,0 +1,138 @@
+<?php
+
+// For security reasons, fill in the connection details to your Textpattern database below:
+
+$tp_database_name = 'textpattern';
+$tp_database_username = 'username';
+$tp_database_password = 'password';
+$tp_database_host = 'localhost';
+
+if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. Double check that you updated wp-config-sample.php with the proper database connection information and renamed it to wp-config.php.");
+require_once('../wp-config.php');
+require_once('upgrade-functions.php');
+
+$step = $_GET['step'];
+if (!$step) $step = 0;
+header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<title>WordPress &rsaquo; Textpattern Import</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style media="screen" type="text/css">
+ body {
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 15%;
+ margin-right: 15%;
+ }
+ #logo {
+ margin: 0;
+ padding: 0;
+ background-image: url(http://wordpress.org/images/wordpress.gif);
+ background-repeat: no-repeat;
+ height: 60px;
+ border-bottom: 4px solid #333;
+ }
+ #logo a {
+ display: block;
+ text-decoration: none;
+ text-indent: -100em;
+ height: 60px;
+ }
+ p {
+ line-height: 140%;
+ }
+ </style>
+</head><body>
+<h1 id="logo"><a href="http://wordpress.org">WordPress</a></h1>
+<?php
+switch($step) {
+
+ case 0:
+?>
+<p>This script imports your entries from Textpattern into WordPress. It should be relatively painless, and we hope you're happy with the result.</p>
+<p>To run this, you first need to edit this file (<code>import-textpattern.php</code>) and enter your Textpattern database connection details. Let's check if the database connection information works...</p>
+<?php
+$connection = @mysql_connect($tp_database_host, $tp_database_username, $tp_database_password);
+$database = @mysql_select_db($tp_database_name);
+if ($connection && $database) {
+?>
+<p>Everything seems dandy so far, <a href="?step=1">let's get started</a>!</p>
+<?php
+} else {
+?>
+<p><em>It looks like your database information is incorrect. Please re-edit this file and double-check all the settings.</em></p>
+<?php
+}
+ break;
+
+ case 1:
+?>
+<h1>Step 1</h1>
+<p>First let's get posts and comments.</p>
+<?php
+// For people running this on .72
+$query = "ALTER TABLE `$wpdb->posts` ADD `post_name` VARCHAR(200) NOT NULL";
+maybe_add_column($wpdb->posts, 'post_name', $query);
+
+// Create post_name field
+$connection = @mysql_connect($tp_database_host, $tp_database_username, $tp_database_password);
+$database = @mysql_select_db($tp_database_name);
+
+// For now we're going to give everything the same author and same category
+$author = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_level = 10 LIMIT 1");
+$category = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories LIMIT 1");
+
+$posts = mysql_query('SELECT * FROM textpattern', $connection);
+
+while ($post = mysql_fetch_array($posts)) {
+ // ID, AuthorID, LastMod, LastModID, Posted, Title, Body, Body_html, Abstract, Category1, Category2, Annotate, AnnotateInvite, Status, Listing1, Listing2, Section
+ $posted = $post['Posted'];
+ // 20030216162119
+ $year = substr($posted,0,4);
+ $month = substr($posted,4,2);
+ $day = substr($posted,6,2);
+ $hour = substr($posted,8,2);
+ $minute = substr($posted,10,2);
+ $second = substr($posted,12,2);
+ $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
+ $posted = date('Y-m-d H:i:s', $timestamp);
+
+ $content = $wpdb->escape($post['Body_html']);
+ $title = $wpdb->escape($post['Title']);
+ $post_name = sanitize_title($title);
+
+ $wpdb->query("INSERT INTO $wpdb->posts
+ (post_author, post_date, post_content, post_title, post_category, post_name, post_status)
+ VALUES
+ ('$author', '$posted', '$content', '$title', '$category', '$post_name', 'publish')");
+
+ // Get wordpress post id
+ $wp_post_ID = $wpdb->get_var("SELECT ID FROM $wpdb->posts ORDER BY ID DESC LIMIT 1");
+
+ // Now let's insert comments if there are any for the TP post
+ $tp_id = $post['ID'];
+ $comments = mysql_query("SELECT * FROM txp_Discuss WHERE parentid = $tp_id");
+ if ($comments) {
+ while($comment = mysql_fetch_object($comments)) {
+ // discussid, parentid, name, email, web, ip, posted, message
+ // For some reason here "posted" is a real MySQL date, so we don't have to do anything about it
+ // comment_post_ID comment_author comment_author_email comment_author_url comment_author_IP comment_date comment_content comment_karma
+ $wpdb->query("INSERT INTO $wpdb->comments
+ (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content)
+ VALUES
+ ($wp_post_ID, '$comment->name', '$comment->email', '$comment->web', '$comment->ip', '$comment->posted', '$comment->message')");
+ }
+ }
+}
+
+upgrade_all();
+?>
+<p><strong>All done.</strong> Wasn&#8217;t that fun? <a href="../">Have fun</a>.</p>
+<?php
+break;
+}
+?>
+
+</body>
+</html>
diff --git a/wp-inst/wp-admin/index.php b/wp-inst/wp-admin/index.php
new file mode 100644
index 0000000..37dbef6
--- /dev/null
+++ b/wp-inst/wp-admin/index.php
@@ -0,0 +1,154 @@
+<?php
+require_once('admin.php');
+$title = __('Dashboard');
+require_once('admin-header.php');
+require_once (ABSPATH . WPINC . '/rss-functions.php');
+
+$today = current_time('mysql', 1);
+?>
+
+<div class="wrap">
+<div id="zeitgeist">
+<h2><?php _e('Latest Activity'); ?></h2>
+<?php
+if ( $recentposts = $wpdb->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") ) :
+?>
+<div>
+<h3><?php _e('Posts'); ?> <a href="edit.php" title="<?php _e('More posts...'); ?>">&raquo;</a></h3>
+<ul>
+<?php
+foreach ($recentposts as $post) {
+ if ($post->post_title == '')
+ $post->post_title = sprintf(__('Post #%s'), $post->ID);
+ echo "<li><a href='post.php?action=edit&amp;post=$post->ID'>";
+ the_title();
+ echo '</a></li>';
+}
+?>
+</ul>
+</div>
+<?php endif; ?>
+
+<?php
+if ( $scheduled = $wpdb->get_results("SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt > '$today'") ) :
+?>
+<div>
+<h3><?php _e('Scheduled Entries:') ?></h3>
+<ul>
+<?php
+foreach ($scheduled as $post) {
+ if ($post->post_title == '')
+ $post->post_title = sprintf(__('Post #%s'), $post->ID);
+ echo "<li>" . sprintf(__('%1$s in %2$s'), "<a href='post.php?action=edit&amp;post=$post->ID' title='" . __('Edit this post') . "'>$post->post_title</a>", human_time_diff( current_time('timestamp', 1), strtotime($post->post_date_gmt. ' GMT') )) . "</li>";
+}
+?>
+</ul>
+</div>
+<?php endif; ?>
+
+<?php
+if ( $comments = $wpdb->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") ) :
+?>
+<div>
+<h3><?php _e('Comments'); ?> <a href="edit-comments.php" title="<?php _e('More comments...'); ?>">&raquo;</a></h3>
+
+<?php
+if ( $numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_approved = '0'") ) :
+?>
+<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format($numcomments) ); ?> &raquo;</a></strong></p>
+<?php endif; ?>
+</div>
+
+<?php endif; ?>
+
+<ul>
+<?php
+foreach ($comments as $comment) {
+ echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');
+ edit_comment_link(__("Edit"), ' <small>(', ')</small>');
+ echo '</li>';
+}
+?>
+</ul>
+
+<div>
+<h3><?php _e('Blog Stats'); ?></h3>
+<?php
+$numposts = $wpdb->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);
+?>
+<p><?php printf(__('There are currently %1$s <a href="%2$s" title="Posts">posts</a> and %3$s <a href="%4$s" title="Comments">comments</a>, contained within %5$s <a href="%6$s" title="categories">categories</a>.'), $numposts, 'edit.php', $numcomms, 'edit-comments.php', $numcats, 'categories.php'); ?></p>
+</div>
+
+<?php
+$rss = @fetch_rss('http://feeds.technorati.com/cosmos/rss/?url='. trailingslashit(get_option('home')) .'&partner=wordpress');
+if ( isset($rss->items) && 0 != count($rss->items) ) {
+?>
+<div id="incominglinks">
+<h3><?php _e('Incoming Links'); ?> <cite><a href="http://www.technorati.com/cosmos/search.html?url=<?php echo trailingslashit(get_option('home')); ?>&amp;partner=wordpress"><?php _e('More'); ?> &raquo;</a></cite></h3>
+<ul>
+<?php
+$rss->items = array_slice($rss->items, 0, 10);
+foreach ($rss->items as $item ) {
+?>
+ <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wp_specialchars($item['title']); ?></a></li>
+<?php } ?>
+</ul>
+</div>
+<?php } ?>
+
+</div>
+
+<h2><?php _e('Dashboard'); ?></h2>
+<p><?php _e('Below is the latest news from the official WordPress development blog, click on a title to read the full entry.'); ?></p>
+<?php
+$rss = @fetch_rss('http://wordpress.org/development/feed/');
+if ( isset($rss->items) && 0 != count($rss->items) ) {
+?>
+<h3>WordPress Development Blog</h3>
+<?php
+$rss->items = array_slice($rss->items, 0, 3);
+foreach ($rss->items as $item ) {
+?>
+<h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> &#8212; <?php echo human_time_diff( strtotime($item['pubdate'], time() ) ); ?> <?php _e('ago'); ?></h4>
+<p><?php echo $item['description']; ?></p>
+<?php
+ }
+}
+?>
+
+
+<?php
+$rss = @fetch_rss('http://planet.wordpress.org/feed/');
+if ( isset($rss->items) && 0 != count($rss->items) ) {
+?>
+<div id="planetnews">
+<h3><?php _e('Other WordPress News'); ?> <a href="http://planet.wordpress.org/"><?php _e('more'); ?> &raquo;</a></h3>
+<ul>
+<?php
+$rss->items = array_slice($rss->items, 0, 20);
+foreach ($rss->items as $item ) {
+?>
+<li><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a></li>
+<?php
+ }
+?>
+</ul>
+</div>
+<?php
+}
+?>
+<div style="clear: both">&nbsp;
+<br clear="all" />
+</div>
+</div>
+
+<?php
+require('./admin-footer.php');
+?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/install-helper.php b/wp-inst/wp-admin/install-helper.php
new file mode 100644
index 0000000..86138db
--- /dev/null
+++ b/wp-inst/wp-admin/install-helper.php
@@ -0,0 +1,152 @@
+<?php
+require_once('../wp-config.php');
+$debug = 0;
+
+/**
+ ** maybe_create_table()
+ ** Create db table if it doesn't exist.
+ ** Returns: true if already exists or on successful completion
+ ** false on error
+ */
+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;
+}
+
+/**
+ ** 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<br />");
+ 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 "<p>testing</p>";
+echo "<pre>";
+
+//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 <br />';
+} else {
+ $res .= 'There was a problem with ' . $tablename . '<br />';
+ ++$error_count;
+}
+echo "</pre>";
+*/
+?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/install.php b/wp-inst/wp-admin/install.php
new file mode 100644
index 0000000..f5ad4b2
--- /dev/null
+++ b/wp-inst/wp-admin/install.php
@@ -0,0 +1,218 @@
+<?php
+define('WP_INSTALLING', true);
+if (!file_exists('../wp-config.php'))
+ die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, 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');
+
+$guessurl = str_replace('/wp-admin/install.php?step=2', '', 'http://' . $_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' );
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title><?php _e('WordPress &rsaquo; Installation'); ?></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <style media="screen" type="text/css">
+ <!--
+ html {
+ background: #eee;
+ }
+ body {
+ background: #fff;
+ color: #000;
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 20%;
+ margin-right: 20%;
+ padding: .2em 2em;
+ }
+
+ h1 {
+ color: #006;
+ font-size: 18px;
+ font-weight: lighter;
+ }
+
+ h2 {
+ font-size: 16px;
+ }
+
+ p, li, dt {
+ line-height: 140%;
+ padding-bottom: 2px;
+ }
+
+ ul, ol {
+ padding: 5px 5px 5px 20px;
+ }
+ #logo {
+ margin-bottom: 2em;
+ }
+ .step a, .step input {
+ font-size: 2em;
+ }
+ td input {
+ font-size: 1.5em;
+ }
+ .step, th {
+ text-align: right;
+ }
+ #footer {
+ text-align: center;
+ border-top: 1px solid #ccc;
+ padding-top: 1em;
+ font-style: italic;
+ }
+ -->
+ </style>
+</head>
+<body>
+<h1 id="logo"><img alt="WordPress" src="http://static.wordpress.org/logo.png" /></h1>
+<?php
+// Let's check to make sure WP isn't already installed.
+$wpdb->hide_errors();
+$installed = $wpdb->get_results("SELECT * FROM $wpdb->users");
+if ($installed) die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
+$wpdb->show_errors();
+
+switch($step) {
+
+ case 0:
+?>
+<p><?php printf(__('Welcome to WordPress installation. We&#8217;re now going to go through a few steps to get you up and running with the latest in personal publishing platforms. You may want to peruse the <a href="%s">ReadMe documentation</a> at your leisure.'), '../readme.html'); ?></p>
+ <h2 class="step"><a href="install.php?step=1"><?php _e('First Step &raquo;'); ?></a></h2>
+<?php
+ break;
+
+ case 1:
+
+?>
+<h1><?php _e('First Step'); ?></h1>
+<p><?php _e("Before we begin we need a little bit of information. Don't worry, you can always change these later."); ?></p>
+
+<form id="setup" method="post" action="install.php?step=2">
+<table width="100%">
+<tr>
+<th width="33%"><?php _e('Weblog title:'); ?></th>
+<td><input name="weblog_title" type="text" id="weblog_title" size="25" /></td>
+</tr>
+<tr>
+<th><?php _e('Your e-mail:'); ?></th>
+ <td><input name="admin_email" type="text" id="admin_email" size="25" /></td>
+</tr>
+</table>
+<p><em><?php _e('Double-check that email address before continuing.'); ?></em></p>
+<h2 class="step">
+<input type="submit" name="Submit" value="<?php _e('Continue to Second Step &raquo;'); ?>" />
+</h2>
+</form>
+
+<?php
+ break;
+ case 2:
+
+// Fill in the data we gathered
+$weblog_title = $_POST['weblog_title'];
+$admin_email = $_POST['admin_email'];
+// check e-mail address
+if (empty($admin_email)) {
+ die (__("<strong>ERROR</strong>: please type your e-mail address"));
+} else if (!is_email($admin_email)) {
+ die (__("<strong>ERROR</strong>: the e-mail address isn't correct"));
+}
+
+?>
+<h1><?php _e('Second Step'); ?></h1>
+<p><?php _e('Now we&#8217;re going to create the database tables and fill them with some default data.'); ?></p>
+
+
+<?php
+flush();
+
+// Set everything up
+make_db_current_silent();
+populate_options();
+
+$wpdb->query("UPDATE $wpdb->options SET option_value = '$weblog_title' WHERE option_name = 'blogname'");
+$wpdb->query("UPDATE $wpdb->options SET option_value = '$admin_email' WHERE option_name = 'admin_email'");
+
+// Now drop in some default links
+$wpdb->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) VALUES ('http://blog.carthik.net/index.php', 'Carthik', 1, 'http://blog.carthik.net/feed/');");
+$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) 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) 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) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/');");
+$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) 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) 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) 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) 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) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."')");
+
+// 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_title, post_category, post_name, post_modified, post_modified_gmt) 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')");
+
+$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.<br />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_title, post_category, post_name, post_modified, post_modified_gmt, post_status) 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')");
+
+// Set up admin user
+$random_password = substr(md5(uniqid(microtime())), 0, 6);
+$wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_level, user_registered) VALUES ( '1', 'admin', MD5('$random_password'), '$admin_email', '10', NOW() )");
+
+$message_headers = 'From: ' . stripslashes($_POST['weblog_title']) . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
+$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);
+
+@mail($admin_email, __('New WordPress Blog'), $message, $message_headers);
+
+upgrade_all();
+?>
+
+<p><em><?php _e('Finished!'); ?></em></p>
+
+<p><?php printf(__('Now you can <a href="%1$s">log in</a> with the <strong>username</strong> "<code>admin</code>" and <strong>password</strong> "<code>%2$s</code>".'), '../wp-login.php', $random_password); ?></p>
+<p><?php _e('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> 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:'); ?>
+</p>
+<dl>
+<dt><?php _e('Username'); ?></dt>
+<dd><code>admin</code></dd>
+<dt><?php _e('Password'); ?></dt>
+<dd><code><?php echo $random_password; ?></code></dd>
+ <dt><?php _e('Login address'); ?></dt>
+<dd><a href="../wp-login.php">wp-login.php</a></dd>
+</dl>
+<p><?php _e('Were you expecting more steps? Sorry to disappoint. All done! :)'); ?></p>
+<?php
+ break;
+}
+?>
+<p id="footer"><?php _e('<a href="http://wordpress.org/">WordPress</a>, personal publishing platform.'); ?></p>
+</body>
+</html>
diff --git a/wp-inst/wp-admin/link-add.php b/wp-inst/wp-admin/link-add.php
new file mode 100644
index 0000000..56f2d1e
--- /dev/null
+++ b/wp-inst/wp-admin/link-add.php
@@ -0,0 +1,272 @@
+<?php
+require_once('admin.php');
+
+$title = __('Add Link');
+$this_file = 'link-manager.php';
+$parent_file = 'link-manager.php';
+
+function 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<select name='$fieldname' size='1'>\n";
+ foreach ($results as $row) {
+ echo "\n\t<option value='$row->cat_id'";
+ if ($row->cat_id == $selected)
+ echo " selected='selected'";
+ echo ">$row->cat_id : " . wp_specialchars($row->cat_name);
+ if ($row->auto_toggle == 'Y')
+ echo ' (auto toggle)';
+ echo "</option>";
+ }
+ echo "\n</select>\n";
+}
+
+function xfn_check($class, $value = '', $type = 'check') {
+ global $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"';
+ }
+}
+
+$wpvarstoreset = array('action', 'cat_id', 'linkurl', 'name', 'image',
+ 'description', 'visible', 'target', 'category', 'link_id',
+ 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
+ 'notes', 'linkcheck[]');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+$link_url = stripslashes($_GET['linkurl']);
+$link_name = htmlentities(stripslashes(urldecode($_GET['name'])));
+
+
+$xfn = true;
+require('admin-header.php');
+?>
+
+<?php if ($_GET['added']) : ?>
+<div class="updated"><p><?php _e('Link added.'); ?></p></div>
+<?php endif; ?>
+<div class="wrap">
+<h2><?php _e('<strong>Add</strong> a link:') ?></h2>
+ <form name="addlink" method="post" action="link-manager.php">
+<fieldset class="options">
+ <legend><?php _e('Basics') ?></legend>
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="33%" scope="row"><?php _e('URI:') ?></th>
+ <td width="67%"><input type="text" name="linkurl" value="<?php echo wp_specialchars($_GET['linkurl'], 1); ?>" style="width: 95%;" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Link Name:') ?></th>
+ <td><input type="text" name="name" value="<?php echo wp_specialchars( urldecode($_GET['name']), 1 ); ?>" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Short description:') ?></th>
+ <td><input type="text" name="description" value="" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Category:') ?></th>
+ <td><?php category_dropdown('category'); ?></td>
+ </tr>
+</table>
+</fieldset>
+ <p class="submit">
+ <input type="submit" name="submit" value="<?php _e('Add Link &raquo;') ?>" />
+ </p>
+ <fieldset class="options">
+ <legend><?php _e('Link Relationship (XFN)') ?></legend>
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="33%" scope="row"><?php _e('rel:') ?></th>
+ <td width="67%"><input type="text" name="rel" id="rel" size="50" value="<?php echo $link_rel; ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
+ <td>
+ <table cellpadding="3" cellspacing="5">
+ <tr>
+ <th scope="row"> <?php _e('identity') ?> </th>
+ <td>
+ <label for="me">
+ <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
+ <?php _e('another web address of mine') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('friendship') ?> </th>
+ <td>
+ <label for="contact">
+ <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
+ <label for="acquaintance">
+ <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php _e('acquaintance') ?></label>
+ <label id="friend">
+ <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
+ <label for="friendship">
+ <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('physical') ?> </th>
+ <td>
+ <label for="met">
+ <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
+ <?php _e('met') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('professional') ?> </th>
+ <td>
+ <label for="co-worker">
+ <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
+ <?php _e('co-worker') ?></label>
+ <label for="colleague">
+ <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
+ <?php _e('colleague') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('geographical') ?> </th>
+ <td>
+ <label for="co-resident">
+ <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
+ <?php _e('co-resident') ?></label>
+ <label for="neighbor">
+ <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
+ <?php _e('neighbor') ?></label>
+ <label for="geographical">
+ <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
+ <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('family'); ?> </th>
+ <td>
+ <label for="child">
+ <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> />
+ <?php _e('child') ?></label>
+ <label for="kin">
+ <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?> />
+ <?php _e('kin') ?></label>
+ <label for="parent">
+ <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
+ <?php _e('parent') ?></label>
+ <label for="sibling">
+ <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
+ <?php _e('sibling') ?></label>
+ <label for="spouse">
+ <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
+ <?php _e('spouse') ?></label>
+ <label for="family">
+ <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
+ <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('romantic') ?> </th>
+ <td>
+ <label for="muse">
+ <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
+ <?php _e('muse') ?></label>
+ <label for="crush">
+ <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
+ <?php _e('crush') ?></label>
+ <label for="date">
+ <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
+ <?php _e('date') ?></label>
+ <label for="romantic">
+ <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
+ <?php _e('sweetheart') ?></label>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</fieldset>
+ <p class="submit">
+ <input type="submit" name="submit" value="<?php _e('Add Link &raquo;') ?>" />
+ </p>
+<fieldset class="options">
+ <legend><?php _e('Advanced') ?></legend>
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="33%" scope="row"><?php _e('Image URI:') ?></th>
+ <td width="67%"><input type="text" name="image" size="50" value="" style="width: 95%" /></td>
+ </tr>
+<tr>
+ <th scope="row"><?php _e('RSS URI:') ?> </th>
+ <td><input name="rss_uri" type="text" id="rss_uri" value="" size="50" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Notes:') ?></th>
+ <td><textarea name="notes" cols="50" rows="10" style="width: 95%"></textarea></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Rating:') ?></th>
+ <td><select name="rating" size="1">
+ <?php
+ for ($r = 0; $r < 10; $r++) {
+ echo(' <option value="'.$r.'">'.$r.'</option>');
+ }
+?>
+ </select>
+ &nbsp;<?php _e('(Leave at 0 for no rating.)') ?> </td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Target') ?></th>
+ <td><label>
+ <input type="radio" name="target" value="_blank" />
+ <code>_blank</code></label>
+<br />
+<label><input type="radio" name="target" value="_top" />
+<code>_top</code></label>
+<br />
+<label><input type="radio" name="target" value="" checked="checked" />
+<?php _e('none') ?></label>
+<?php _e('(Note that the <code>target</code> attribute is illegal in XHTML 1.1 and 1.0 Strict.)') ?></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Visible:') ?></th>
+ <td><label>
+ <input type="radio" name="visible" checked="checked" value="Y" />
+<?php _e('Yes') ?></label><br />
+<label><input type="radio" name="visible" value="N" /> <input type="hidden" name="action" value="Add" />
+<?php _e('No') ?></label></td>
+ </tr>
+</table>
+</fieldset>
+
+ <p class="submit">
+ <input type="submit" name="submit" value="<?php _e('Add Link &raquo;') ?>" />
+ </p>
+ </form>
+</div>
+
+<div class="wrap">
+<?php printf(__('<p>You can drag <a href="%s" title="Link add bookmarklet">Link This</a> to your toolbar and when you click it a window will pop up that will allow you to add whatever site you&#8217;re on to your links! Right now this only works on Mozilla or Netscape, but we&#8217;re working on it.</p>'), "javascript:void(linkmanpopup=window.open('" . get_settings('siteurl') . "/wp-admin/link-add.php?action=popup&amp;linkurl='+escape(location.href)+'&amp;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();") ?>
+</div>
+
+<?php
+require('admin-footer.php');
+?>
diff --git a/wp-inst/wp-admin/link-categories.php b/wp-inst/wp-admin/link-categories.php
new file mode 100644
index 0000000..86f3da3
--- /dev/null
+++ b/wp-inst/wp-admin/link-categories.php
@@ -0,0 +1,453 @@
+<?php
+// Links
+// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
+require_once('admin.php');
+$title = __('Link Categories');
+$this_file='link-categories.php';
+$parent_file = 'link-manager.php';
+
+$wpvarstoreset = array('action', 'cat', 'auto_toggle');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+switch ($action) {
+ case 'addcat':
+ {
+ if ($user_level < 5)
+ die (__("Cheatin' uh ?"));
+
+ $cat_name = wp_specialchars($_POST['cat_name']);
+ $auto_toggle = $_POST['auto_toggle'];
+ if ($auto_toggle != 'Y') {
+ $auto_toggle = 'N';
+ }
+
+ $show_images = $_POST['show_images'];
+ if ($show_images != 'Y') {
+ $show_images = 'N';
+ }
+
+ $show_description = $_POST['show_description'];
+ if ($show_description != 'Y') {
+ $show_description = 'N';
+ }
+
+ $show_rating = $_POST['show_rating'];
+ if ($show_rating != 'Y') {
+ $show_rating = 'N';
+ }
+
+ $show_updated = $_POST['show_updated'];
+ if ($show_updated != 'Y') {
+ $show_updated = 'N';
+ }
+
+ $sort_order = $_POST['sort_order'];
+
+ $sort_desc = $_POST['sort_desc'];
+ if ($sort_desc != 'Y') {
+ $sort_desc = 'N';
+ }
+ $text_before_link = $_POST['text_before_link'];
+ $text_after_link = $_POST['text_after_link'];
+ $text_after_all = $_POST['text_after_all'];
+
+ $list_limit = $_POST['list_limit'];
+ if ($list_limit == '')
+ $list_limit = -1;
+
+ $wpdb->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 <strong>%s</strong> link category: this is the default one"), $cat_name));
+
+ if ($user_level < 5)
+ 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 = '';
+ }
+?>
+
+<div class="wrap">
+ <h2><?php printf(__('Edit &#8220%s&#8221; Category'), wp_specialchars($row->cat_name)); ?></h2>
+
+ <form name="editcat" method="post">
+ <input type="hidden" name="action" value="editedcat" />
+ <input type="hidden" name="cat_id" value="<?php echo $row->cat_id ?>" />
+<fieldset class="options">
+<legend><?php _e('Category Options') ?></legend>
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+<tr>
+ <th width="33%" scope="row"><?php _e('Name:') ?></th>
+ <td width="67%"><input name="cat_name" type="text" value="<?php echo wp_specialchars($row->cat_name)?>" size="30" /></td>
+</tr>
+<tr>
+ <th scope="row"><?php _e('Show:') ?></th>
+ <td>
+ <label>
+ <input type="checkbox" name="show_images" value="Y" <?php checked('Y', $row->show_images); ?> />
+ <?php _e('Image') ?></label> <br />
+ <label>
+ <input type="checkbox" name="show_description" value="Y" <?php checked('Y', $row->show_description); ?> />
+ <?php _e('Description') ?></label>
+ <?php _e('(shown in <code>title</code> regardless)') ?><br />
+ <label>
+ <input type="checkbox" name="show_rating" value="Y" <?php checked('Y', $row->show_rating); ?> />
+ <?php _e('Rating') ?></label> <br />
+ <label>
+ <input type="checkbox" name="show_updated" value="Y" <?php checked('Y', $row->show_updated); ?> />
+ <?php _e('Updated') ?></label>
+<?php _e('(shown in <code>title</code> regardless)') ?></td>
+</tr>
+<tr>
+ <th scope="row"><?php _e('Sort order:') ?></th>
+ <td>
+ <select name="sort_order" size="1">
+ <option value="name" <?php echo ($row->sort_order == 'name') ? 'selected="selected"' : ''?>><?php _e('Name') ?></option>
+ <option value="id" <?php echo ($row->sort_order == 'id') ? 'selected' : ''?>><?php _e('Id') ?></option>
+ <option value="url" <?php echo ($row->sort_order == 'url') ? 'selected' : ''?>><?php _e('URL') ?></option>
+ <option value="rating" <?php echo ($row->sort_order == 'rating') ? 'selected' : ''?>><?php _e('Rating') ?></option>
+ <option value="updated" <?php echo ($row->sort_order == 'updated') ? 'selected' : ''?>><?php _e('Updated') ?></option>
+ <option value="rand" <?php echo ($row->sort_order == 'rand') ? 'selected' : ''?>><?php _e('Random') ?></option>
+ <option value="length" <?php echo ($row->sort_order == 'length') ? 'selected' : ''?>><?php _e('Name Length') ?></option>
+ </select>
+ <label>
+ <input type="checkbox" name="sort_desc" value="Y" <?php checked('Y', $row->sort_desc); ?> />
+ <?php _e('Descending') ?></label>
+ </td>
+</tr>
+<tr>
+ <th scope="row"><?php _e('Limit:') ?></th>
+ <td>
+ <input type="text" name="list_limit" size="5" value="<?php echo $row->list_limit ?>" />
+ <?php _e('(Leave empty for no limit to number of links shown)') ?>
+ </td>
+</tr>
+<tr>
+ <th scope="row"><?php _e('Toggle:') ?></th>
+ <td><label>
+ <input type="checkbox" name="auto_toggle" value="Y" <?php checked('Y', $row->auto_toggle); ?> />
+ <?php _e('When new link is added toggle all others to be invisible') ?></label></td>
+</tr>
+
+</table>
+</fieldset>
+<fieldset class="options">
+<legend><?php _e('Formatting') ?></legend>
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+<tr>
+ <th width="33%" scope="row"><?php _e('Before Link:') ?></th>
+ <td width="67%"><input type="text" name="text_before_link" size="45" value="<?php echo wp_specialchars($row->text_before_link)?>" /></td>
+</tr>
+<tr>
+<th scope="row"><?php _e('Between Link and Description:') ?></th>
+<td><input type="text" name="text_after_link" size="45" value="<?php echo wp_specialchars($row->text_after_link)?>" /></td>
+</tr>
+<tr>
+<th scope="row"><?php _e('After Link:') ?></th>
+<td><input type="text" name="text_after_all" size="45" value="<?php echo wp_specialchars($row->text_after_all)?>"/></td>
+</tr>
+</table>
+</fieldset>
+<p class="submit"><input type="submit" name="submit" value="<?php _e('Save Category Settings &raquo;') ?>" /></p>
+</form>
+
+</div>
+<?php
+ } // end if row
+ break;
+ } // end Edit
+ case "editedcat":
+ {
+ if ($user_level < 5)
+ die (__("Cheatin' uh ?"));
+
+ $submit=$_POST["submit"];
+ if (isset($submit)) {
+
+ $cat_id = (int)$_POST["cat_id"];
+
+ $cat_name= wp_specialchars($_POST["cat_name"]);
+ $auto_toggle = $_POST["auto_toggle"];
+ if ($auto_toggle != 'Y') {
+ $auto_toggle = 'N';
+ }
+
+ $show_images = $_POST["show_images"];
+ if ($show_images != 'Y') {
+ $show_images = 'N';
+ }
+
+ $show_description = $_POST["show_description"];
+ if ($show_description != 'Y') {
+ $show_description = 'N';
+ }
+
+ $show_rating = $_POST["show_rating"];
+ if ($show_rating != 'Y') {
+ $show_rating = 'N';
+ }
+
+ $show_updated = $_POST["show_updated"];
+ if ($show_updated != 'Y') {
+ $show_updated = 'N';
+ }
+
+ $sort_order = $_POST["sort_order"];
+
+ $sort_desc = $_POST["sort_desc"];
+ if ($sort_desc != 'Y') {
+ $sort_desc = 'N';
+ }
+ $text_before_link = $_POST["text_before_link"];
+ $text_after_link = $_POST["text_after_link"];
+ $text_after_all = $_POST["text_after_all"];
+
+ $list_limit = $_POST["list_limit"];
+ if ($list_limit == '')
+ $list_limit = -1;
+
+ $wpdb->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 ($user_level < 5) {
+ die(__("You have do not have sufficient permissions to edit the link categories for this blog. :)"));
+ }
+?>
+
+<div class="wrap">
+ <h2><?php _e('Link Categories:') ?></h2>
+ <table width="100%" cellpadding="5" cellspacing="0" border="0">
+ <tr>
+ <th rowspan="2" valign="bottom"><?php _e('Name') ?></th>
+ <th rowspan="2" valign="bottom"><?php _e('ID') ?></th>
+ <th rowspan="2" valign="bottom"><?php _e('Toggle?') ?></th>
+ <th colspan="4" valign="bottom" class="alternate"><?php _e('Show') ?></th>
+ <th rowspan="2" valign="bottom"><?php _e('Sort Order') ?></th>
+ <th rowspan="2" valign="bottom"><?php _e('Desc?') ?></th>
+ <th colspan="3" valign="bottom" class="alternate"><?php _e('Formatting') ?></th>
+ <th rowspan="2" valign="bottom"><?php _e('Limit') ?></th>
+ <th rowspan="2" colspan="2">&nbsp;</th>
+ </tr>
+ <tr>
+ <th valign="top"><?php _e('Images') ?></th>
+ <th valign="top"><?php _e('Description') ?></th>
+ <th valign="top"><?php _e('Rating') ?></th>
+ <th valign="top"><?php _e('Updated') ?></th>
+ <th valign="top"><?php _e('Before') ?></th>
+ <th valign="top"><?php _e('Between') ?></th>
+ <th valign="top"><?php _e('After') ?></th>
+ </tr>
+<?php
+$results = $wpdb->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;
+ }
+?>
+ <tr valign="middle" align="center" <?php echo $style ?> style="border-bottom: 1px dotted #9C9A9C;">
+ <td><?php echo wp_specialchars($row->cat_name)?></td>
+ <td ><?php echo $row->cat_id?></td>
+ <td><?php echo $row->auto_toggle == 'Y' ? __('Yes') : __('No') ?></td>
+ <td><?php echo $row->show_images == 'Y' ? __('Yes') : __('No') ?></td>
+ <td><?php echo $row->show_description == 'Y' ? __('Yes') : __('No') ?></td>
+ <td><?php echo $row->show_rating == 'Y' ? __('Yes') : __('No') ?></td>
+ <td><?php echo $row->show_updated == 'Y' ? __('Yes') : __('No') ?></td>
+ <td><?php echo $row->sort_order ?></td>
+ <td><?php echo $row->sort_desc == 'Y' ? __('Yes') : __('No') ?></td>
+ <td nowrap="nowrap"><?php echo htmlentities($row->text_before_link)?>&nbsp;</td>
+ <td nowrap="nowrap"><?php echo htmlentities($row->text_after_link)?>&nbsp;</td>
+ <td nowrap="nowrap"><?php echo htmlentities($row->text_after_all)?></td>
+ <td><?php echo $row->list_limit ?></td>
+ <td><a href="link-categories.php?cat_id=<?php echo $row->cat_id?>&amp;action=Edit" class="edit"><?php _e('Edit') ?></a></td>
+ <td><a href="link-categories.php?cat_id=<?php echo $row->cat_id?>&amp;action=Delete" onclick="return confirm('<?php _e("You are about to delete this category.\\n \'Cancel\' to stop, \'OK\' to delete.") ?>');" class="delete"><?php _e('Delete') ?></a></td>
+ </tr>
+<?php
+ ++$i;
+ }
+?>
+ </table>
+<p><?php _e('These are the defaults for when you call a link category with no additional arguments. All of these settings may be overwritten.') ?></p>
+
+</div>
+
+<div class="wrap">
+ <form name="addcat" method="post">
+ <input type="hidden" name="action" value="addcat" />
+ <h2><?php _e('Add a Link Category:') ?></h2>
+<fieldset class="options">
+<legend><?php _e('Category Options') ?></legend>
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+<tr>
+ <th width="33%" scope="row"><?php _e('Name:') ?></th>
+ <td width="67%"><input type="text" name="cat_name" size="30" /></td>
+</tr>
+<tr>
+ <th scope="row"><?php _e('Show:') ?></th>
+ <td>
+ <label>
+ <input type="checkbox" name="show_images" value="Y" />
+ <?php _e('Image') ?></label> <br />
+ <label>
+ <input type="checkbox" name="show_description" value="Y" />
+ <?php _e('Description') ?></label>
+ <?php _e('(shown in <code>title</code> regardless)') ?><br />
+ <label>
+ <input type="checkbox" name="show_rating" value="Y" />
+ <?php _e('Rating') ?></label> <br />
+ <label>
+ <input type="checkbox" name="show_updated" value="Y" />
+ <?php _e('Updated') ?></label>
+<?php _e('(shown in <code>title</code> regardless)') ?></td>
+</tr>
+<tr>
+ <th scope="row"><?php _e('Sort order:') ?></th>
+ <td>
+ <select name="sort_order" size="1">
+ <option value="name"><?php _e('Name') ?></option>
+ <option value="id"><?php _e('Id') ?></option>
+ <option value="url"><?php _e('URL') ?></option>
+ <option value="rating"><?php _e('Rating') ?></option>
+ <option value="updated"><?php _e('Updated') ?></option>
+ <option value="rand"><?php _e('Random') ?></option>
+ </select>
+ <label>
+ <input type="checkbox" name="sort_desc" value="Y" />
+ <?php _e('Descending') ?></label>
+ </td>
+</tr>
+<tr>
+ <th scope="row"><?php _e('Limit:') ?></th>
+ <td>
+ <input type="text" name="list_limit" size="5" value="" /> <?php _e('(Leave empty for no limit to number of links shown)') ?>
+ </td>
+</tr>
+<tr>
+ <th scope="row"><?php _e('Toggle:') ?></th>
+ <td><label>
+ <input type="checkbox" name="auto_toggle" value="Y" />
+ <?php _e('When new link is added toggle all others to be invisible') ?></label></td>
+</tr>
+
+</table>
+</fieldset>
+<fieldset class="options">
+<legend><?php _e('Formatting') ?></legend>
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+<tr>
+ <th width="33%" scope="row"><?php _e('Before Link:') ?></th>
+ <td width="67%"><input type="text" name="text_before_link" size="45" value="&lt;li&gt;" /></td>
+</tr>
+<tr>
+<th scope="row"><?php _e('Between Link and Description:') ?></th>
+<td><input type="text" name="text_after_link" size="45" value="&lt;br /&gt;" /></td>
+</tr>
+<tr>
+<th scope="row"><?php _e('After Link:') ?></th>
+<td><input type="text" name="text_after_all" size="45" value="&lt;/li&gt;"/></td>
+</tr>
+</table>
+</fieldset>
+<p class="submit"><input type="submit" name="submit" value="<?php _e('Add Category &raquo;') ?>" /></p>
+ </form>
+</div>
+<div class="wrap">
+ <h3><?php _e('Note:') ?></h3>
+ <?php printf(__('<p>Deleting a link category does not delete links from that category.<br />It will just set them back to the default category <b>%s</b>.'), get_linkcatname(1)) ?></p>
+</div>
+<?php
+ break;
+ } // end default
+} // end case
+?>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-inst/wp-admin/link-import.php b/wp-inst/wp-admin/link-import.php
new file mode 100644
index 0000000..698bd7f
--- /dev/null
+++ b/wp-inst/wp-admin/link-import.php
@@ -0,0 +1,131 @@
+<?php
+// Links
+// Copyright (C) 2002 Mike Little -- mike@zed1.com
+
+require_once('admin.php');
+$parent_file = 'link-manager.php';
+$title = __('Import Blogroll');
+$this_file = 'link-import.php';
+
+$step = $_POST['step'];
+if (!$step) $step = 0;
+?>
+<?php
+switch ($step) {
+ case 0:
+ {
+ include_once('admin-header.php');
+ if ($user_level < 5)
+ die (__("Cheatin&#8217; uh?"));
+
+ $opmltype = 'blogrolling'; // default.
+?>
+
+<div class="wrap">
+
+ <h2><?php _e('Import your blogroll from another system') ?> </h2>
+ <!-- <form name="blogroll" action="link-import.php" method="get"> -->
+ <form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
+
+ <ol>
+ <li><?php _e('Go to <a href="http://www.blogrolling.com">Blogrolling.com</a> and sign in. Once you&#8217;ve done that, click on <strong>Get Code</strong>, and then look for the <strong><abbr title="Outline Processor Markup Language">OPML</abbr> code</strong>') ?>.</li>
+ <li><?php _e('Or go to <a href="http://blo.gs">Blo.gs</a> and sign in. Once you&#8217;ve done that in the \'Welcome Back\' box on the right, click on <strong>share</strong>, and then look for the <strong><abbr title="Outline Processor Markup Language">OPML</abbr> link</strong> (favorites.opml).') ?></li>
+ <li><?php _e('Select that text and copy it or copy the link/shortcut into the box below.') ?><br />
+ <input type="hidden" name="step" value="1" />
+ <?php _e('Your OPML URL:') ?> <input type="text" name="opml_url" size="65" />
+ </li>
+ <li>
+ <?php _e('<strong>or</strong> you can upload an OPML file from your desktop aggregator:') ?><br />
+ <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
+ <label><?php _e('Upload this file:') ?> <input name="userfile" type="file" /></label>
+ </li>
+
+ <li><?php _e('Now select a category you want to put these links in.') ?><br />
+ <?php _e('Category:') ?> <select name="cat_id">
+<?php
+ $categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
+ foreach ($categories as $category) {
+?>
+ <option value="<?php echo $category->cat_id; ?>"><?php echo $category->cat_id.': '.$category->cat_name; ?></option>
+<?php
+ } // end foreach
+?>
+ </select>
+
+ </li>
+
+ <li><input type="submit" name="submit" value="<?php _e('Import!') ?>" /></li>
+ </ol>
+ </form>
+
+</div>
+<?php
+ break;
+ } // end case 0
+
+ case 1: {
+ include_once('admin-header.php');
+ if ($user_level < 5)
+ die (__("Cheatin' uh ?"));
+?>
+<div class="wrap">
+
+ <h2><?php _e('Importing...') ?></h2>
+<?php
+ $cat_id = $_POST['cat_id'];
+ if (($cat_id == '') || ($cat_id == 0)) {
+ $cat_id = 1;
+ }
+
+ $opml_url = $_POST['opml_url'];
+ if (isset($opml_url) && $opml_url != '') {
+ $blogrolling = true;
+ }
+ else // try to get the upload file.
+ {
+ $uploaddir = get_settings('fileupload_realpath');
+ $uploadfile = $uploaddir.'/'.$_FILES['userfile']['name'];
+
+ if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
+ {
+ //echo "Upload successful.";
+ $blogrolling = false;
+ $opml_url = $uploadfile;
+ } else {
+ echo __("Upload error");
+ }
+ }
+
+ if (isset($opml_url) && $opml_url != '') {
+ $opml = implode('', file($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] = '';
+ $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(__("<p>Inserted <strong>%s</strong></p>"), $names[$i]);
+ }
+?>
+ <p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
+<?php
+ } // end if got url
+ else
+ {
+ echo "<p>" . __("You need to supply your OPML url. Press back on your browser and try again") . "</p>\n";
+ } // end else
+
+?>
+</div>
+<?php
+ break;
+ } // end case 1
+} // end switch
+?>
+</body>
+</html>
diff --git a/wp-inst/wp-admin/link-manager.php b/wp-inst/wp-admin/link-manager.php
new file mode 100644
index 0000000..2f0a140
--- /dev/null
+++ b/wp-inst/wp-admin/link-manager.php
@@ -0,0 +1,755 @@
+<?php
+// Links
+// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
+
+require_once('admin.php');
+
+$title = __('Manage Links');
+$this_file = $parent_file = 'link-manager.php';
+
+function xfn_check($class, $value = '', $type = 'check') {
+ global $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"';
+ }
+}
+
+function 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<select name='$fieldname' size='1'>";
+ foreach ($results as $row) {
+ echo "\n\t<option value='$row->cat_id'";
+ if ($row->cat_id == $selected)
+ echo " selected='selected'";
+ echo ">$row->cat_id: ".wp_specialchars($row->cat_name);
+ if ('Y' == $row->auto_toggle)
+ echo ' (auto toggle)';
+ echo "</option>\n";
+ }
+ echo "\n</select>\n";
+}
+
+$wpvarstoreset = array('action','cat_id', 'linkurl', 'name', 'image',
+ 'description', 'visible', 'target', 'category', 'link_id',
+ 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
+ 'notes', 'linkcheck[]');
+
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+$links_show_cat_id = $_COOKIE['links_show_cat_id_' . COOKIEHASH];
+$links_show_order = $_COOKIE['links_show_order_' . COOKIEHASH];
+
+if ('' != $_POST['assign']) $action = 'assign';
+if ('' != $_POST['visibility']) $action = 'visibility';
+if ('' != $_POST['move']) $action = 'move';
+if ('' != $_POST['linkcheck']) $linkcheck = $_POST[linkcheck];
+
+switch ($action) {
+ case 'assign':
+ {
+ check_admin_referer();
+
+ // check the current user's level first.
+ if ($user_level < 5)
+ die (__("Cheatin' uh ?"));
+
+ //for each link id (in $linkcheck[]): if the current user level >= 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, user_level FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)");
+ foreach ($results as $row) {
+ if (($user_level >= $row->user_level)) { // ok to proceed
+ $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 ($user_level < 5)
+ 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 ($user_level < 5)
+ 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();
+
+ $link_url = wp_specialchars($_POST['linkurl']);
+ $link_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $link_url) ? $link_url : 'http://' . $link_url;
+ $link_name = wp_specialchars($_POST['name']);
+ $link_image = wp_specialchars($_POST['image']);
+ $link_target = $_POST['target'];
+ $link_category = $_POST['category'];
+ $link_description = $_POST['description'];
+ $link_visible = $_POST['visible'];
+ $link_rating = $_POST['rating'];
+ $link_rel = $_POST['rel'];
+ $link_notes = $_POST['notes'];
+ $link_rss_uri = wp_specialchars($_POST['rss_uri']);
+ $auto_toggle = get_autotoggle($link_category);
+
+ if ($user_level < 5)
+ die (__("Cheatin' uh ?"));
+
+ // 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.
+ if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {
+ $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");
+ }
+ $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', $user_ID, $link_rating, '" . $link_rel . "', '" . $link_notes . "', '$link_rss_uri')");
+
+ header('Location: ' . $_SERVER['HTTP_REFERER'] . '?added=true');
+ break;
+ } // end Add
+
+ case 'editlink':
+ {
+ if (isset($submit)) {
+
+ 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;
+
+ check_admin_referer();
+
+ $link_id = (int) $_POST['link_id'];
+ $link_url = wp_specialchars($_POST['linkurl']);
+ $link_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $link_url) ? $link_url : 'http://' . $link_url;
+ $link_name = wp_specialchars($_POST['name']);
+ $link_image = wp_specialchars($_POST['image']);
+ $link_target = wp_specialchars($_POST['target']);
+ $link_category = $_POST['category'];
+ $link_description = $_POST['description'];
+ $link_visible = $_POST['visible'];
+ $link_rating = $_POST['rating'];
+ $link_rel = $_POST['rel'];
+ $link_notes = $_POST['notes'];
+ $link_rss_uri = $_POST['rss_uri'];
+ $auto_toggle = get_autotoggle($link_category);
+
+ if ($user_level < 5)
+ die (__("Cheatin' uh ?"));
+
+ // if we are in an auto toggle category and this one is visible then we
+ // need to make the others invisible before we update this one.
+ if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {
+ $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");
+ }
+
+ $wpdb->query("UPDATE $wpdb->links SET link_url='" . $link_url . "',
+ link_name='" . $link_name . "',\n link_image='" . $link_image . "',
+ link_target='$link_target',\n link_category=$link_category,
+ link_visible='$link_visible',\n link_description='" . $link_description . "',
+ link_rating=$link_rating,
+ link_rel='" . $link_rel . "',
+ link_notes='" . $link_notes . "',
+ link_rss = '$link_rss_uri'
+ WHERE link_id=$link_id");
+ } // end if save
+ setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
+ wp_redirect($this_file);
+ break;
+ } // end Save
+
+ case 'Delete':
+ {
+ check_admin_referer();
+
+ $link_id = (int) $_GET['link_id'];
+
+ if ($user_level < 5)
+ die (__("Cheatin' uh ?"));
+
+ $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = $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 = true;
+ include_once ('admin-header.php');
+ if ($user_level < 5)
+ die(__('You do not have sufficient permissions to edit the links for this blog.'));
+
+ $link_id = (int) $_GET['link_id'];
+ $row = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = $link_id");
+
+ if ($row) {
+ $link_url = wp_specialchars($row->link_url, 1);
+ $link_name = wp_specialchars($row->link_name, 1);
+ $link_image = $row->link_image;
+ $link_target = $row->link_target;
+ $link_category = $row->link_category;
+ $link_description = wp_specialchars($row->link_description);
+ $link_visible = $row->link_visible;
+ $link_rating = $row->link_rating;
+ $link_rel = $row->link_rel;
+ $link_notes = wp_specialchars($row->link_notes);
+ $link_rss_uri = wp_specialchars($row->link_rss);
+ } else {
+ die( __('Link not found.') );
+ }
+
+?>
+
+<div class="wrap">
+ <form action="" method="post" name="editlink" id="editlink">
+ <h2><?php _e('Edit a link:') ?></h2>
+<fieldset class="options">
+ <legend><?php _e('Basics') ?></legend>
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="33%" scope="row"><?php _e('URI:') ?></th>
+ <td width="67%"><input type="text" name="linkurl" value="<?php echo $link_url; ?>" style="width: 95%;" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Link Name:') ?></th>
+ <td><input type="text" name="name" value="<?php echo $link_name; ?>" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Short description:') ?></th>
+ <td><input type="text" name="description" value="<?php echo $link_description; ?>" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Category:') ?></th>
+ <td><?php category_dropdown('category', $link_category); ?></td>
+ </tr>
+</table>
+</fieldset>
+ <p class="submit">
+ <input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
+ </p>
+ <fieldset class="options">
+ <legend><?php _e('Link Relationship (XFN)') ?></legend>
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="33%" scope="row"><?php _e('rel:') ?></th>
+ <td width="67%"><input type="text" name="rel" id="rel" size="50" value="<?php echo $link_rel; ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
+ <td>
+ <table cellpadding="3" cellspacing="5">
+ <tr>
+ <th scope="row"> <?php _e('identity') ?> </th>
+ <td>
+ <label for="me">
+ <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
+ <?php _e('another web address of mine') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('friendship') ?> </th>
+ <td>
+ <label for="contact">
+ <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
+ <label for="acquaintance">
+ <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php _e('acquaintance') ?></label>
+ <label id="friend">
+ <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
+ <label for="friendship">
+ <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('physical') ?> </th>
+ <td>
+ <label for="met">
+ <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
+ <?php _e('met') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('professional') ?> </th>
+ <td>
+ <label for="co-worker">
+ <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
+ <?php _e('co-worker') ?></label>
+ <label for="colleague">
+ <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
+ <?php _e('colleague') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('geographical') ?> </th>
+ <td>
+ <label for="co-resident">
+ <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
+ <?php _e('co-resident') ?></label>
+ <label for="neighbor">
+ <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
+ <?php _e('neighbor') ?></label>
+ <label for="geographical">
+ <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
+ <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('family') ?> </th>
+ <td>
+ <label for="child">
+ <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> />
+ <?php _e('child') ?></label>
+ <label for="kin">
+ <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?> />
+ <?php _e('kin') ?></label>
+ <label for="parent">
+ <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
+ <?php _e('parent') ?></label>
+ <label for="sibling">
+ <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
+ <?php _e('sibling') ?></label>
+ <label for="spouse">
+ <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
+ <?php _e('spouse') ?></label>
+ <label for="family">
+ <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
+ <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('romantic') ?> </th>
+ <td>
+ <label for="muse">
+ <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
+ <?php _e('muse') ?></label>
+ <label for="crush">
+ <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
+ <?php _e('crush') ?></label>
+ <label for="date">
+ <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
+ <?php _e('date') ?></label>
+ <label for="romantic">
+ <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
+ <?php _e('sweetheart') ?></label>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</fieldset>
+ <p class="submit">
+ <input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
+ </p>
+<fieldset class="options">
+ <legend><?php _e('Advanced') ?></legend>
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="33%" scope="row"><?php _e('Image URI:') ?></th>
+ <td width="67%"><input type="text" name="image" size="50" value="<?php echo $link_image; ?>" style="width: 95%" /></td>
+ </tr>
+<tr>
+ <th scope="row"><?php _e('RSS URI:') ?> </th>
+ <td><input name="rss_uri" type="text" id="rss_uri" value="<?php echo $link_rss_uri; ?>" size="50" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Notes:') ?></th>
+ <td><textarea name="notes" cols="50" rows="10" style="width: 95%"><?php echo $link_notes; ?></textarea></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Rating:') ?></th>
+ <td><select name="rating" size="1">
+<?php
+ for ($r = 0; $r < 10; $r++) {
+ echo(' <option value="'.$r.'" ');
+ if ($link_rating == $r)
+ echo 'selected="selected"';
+ echo('>'.$r.'</option>');
+ }
+?>
+ </select>
+ &nbsp;<?php _e('(Leave at 0 for no rating.)') ?> </td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Target') ?></th>
+ <td><label>
+ <input type="radio" name="target" value="_blank" <?php echo(($link_target == '_blank') ? 'checked="checked"' : ''); ?> />
+ <code>_blank</code></label><br />
+<label>
+<input type="radio" name="target" value="_top" <?php echo(($link_target == '_top') ? 'checked="checked"' : ''); ?> />
+<code>_top</code></label><br />
+<label>
+<input type="radio" name="target" value="" <?php echo(($link_target == '') ? 'checked="checked"' : ''); ?> />
+<?php _e('none') ?></label><br />
+<?php _e('(Note that the <code>target</code> attribute is illegal in XHTML 1.1 and 1.0 Strict.)') ?></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Visible:') ?></th>
+ <td><label>
+ <input type="radio" name="visible" <?php if ($link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
+<?php _e('Yes') ?></label><br /><label>
+<input type="radio" name="visible" <?php if ($link_visible == 'N') echo "checked='checked'"; ?> value="N" />
+<?php _e('No') ?></label></td>
+ </tr>
+</table>
+</fieldset>
+<p class="submit"><input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
+ <input type="hidden" name="action" value="editlink" />
+ <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
+ <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
+ <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /></p>
+ </form>
+</div>
+<?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 ($user_level < 5) {
+ 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") {
+?>
+<script type="text/javascript">
+<!--
+function checkAll(form)
+{
+ for (i = 0, n = form.elements.length; i < n; i++) {
+ if(form.elements[i].type == "checkbox") {
+ if(form.elements[i].checked == true)
+ form.elements[i].checked = false;
+ else
+ form.elements[i].checked = true;
+ }
+ }
+}
+//-->
+</script>
+
+<div class="wrap">
+ <form name="cats" method="post" action="">
+ <table width="75%" cellpadding="3" cellspacing="3">
+ <tr>
+ <td>
+ <?php _e('<strong>Show</strong> links in category:'); ?><br />
+ </td>
+ <td>
+ <?php _e('<strong>Order</strong> by:');?>
+ </td>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td>
+<?php
+ $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
+ echo " <select name=\"cat_id\">\n";
+ echo " <option value=\"All\"";
+ if ($cat_id == 'All')
+ echo " selected='selected'";
+ echo "> " . __('All') . "</option>\n";
+ foreach ($results as $row) {
+ echo " <option value=\"".$row->cat_id."\"";
+ if ($row->cat_id == $cat_id)
+ echo " selected='selected'";
+ echo ">".$row->cat_id.": ".wp_specialchars($row->cat_name);
+ if ($row->auto_toggle == 'Y')
+ echo ' (auto toggle)';
+ echo "</option>\n";
+ }
+ echo " </select>\n";
+?>
+ </td>
+ <td>
+ <select name="order_by">
+ <option value="order_id" <?php if ($order_by == 'order_id') echo " selected='selected'";?>><?php _e('Link ID') ?></option>
+ <option value="order_name" <?php if ($order_by == 'order_name') echo " selected='selected'";?>><?php _e('Name') ?></option>
+ <option value="order_url" <?php if ($order_by == 'order_url') echo " selected='selected'";?>><?php _e('URI') ?></option>
+ <option value="order_desc" <?php if ($order_by == 'order_desc') echo " selected='selected'";?>><?php _e('Description') ?></option>
+ <option value="order_owner" <?php if ($order_by == 'order_owner') echo " selected='selected'";?>><?php _e('Owner') ?></option>
+ <option value="order_rating" <?php if ($order_by == 'order_rating') echo " selected='selected'";?>><?php _e('Rating') ?></option>
+ </select>
+ </td>
+ <td>
+ <input type="submit" name="action" value="<?php _e('Show') ?>" />
+ </td>
+ </tr>
+ </table>
+ </form>
+
+</div>
+
+<form name="links" id="links" method="post" action="">
+<div class="wrap">
+
+ <input type="hidden" name="link_id" value="" />
+ <input type="hidden" name="action" value="" />
+ <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
+ <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
+ <table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+ <th width="15%"><?php _e('Name') ?></th>
+ <th><?php _e('URI') ?></th>
+ <th><?php _e('Category') ?></th>
+ <th><?php _e('rel') ?></th>
+ <th><?php _e('Image') ?></th>
+ <th><?php _e('Visible') ?></th>
+ <th colspan="2"><?php _e('Action') ?></th>
+ <th>&nbsp;</th>
+ </tr>
+<?php
+ $sql = "SELECT link_url, link_name, link_image, link_description, link_visible,
+ link_category AS cat_id, cat_name AS category, $wpdb->users.user_login, link_id,
+ link_rating, link_rel, $wpdb->users.user_level
+ FROM $wpdb->links
+ LEFT JOIN $wpdb->linkcategories ON $wpdb->links.link_category = $wpdb->linkcategories.cat_id
+ LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->links.link_owner ";
+
+ if (isset($cat_id) && ($cat_id != 'All')) {
+ $sql .= " WHERE link_category = $cat_id ";
+ }
+ $sql .= ' ORDER BY link_' . $sqlorderby;
+
+ // echo "$sql";
+ $links = $wpdb->get_results($sql);
+ if ($links) {
+ foreach ($links as $link) {
+ $link->link_name = wp_specialchars($link->link_name);
+ $link->link_category = wp_specialchars($link->link_category);
+ $link->link_description = wp_specialchars($link->link_description);
+ $link->link_url = wp_specialchars($link->link_url);
+ $short_url = str_replace('http://', '', $link->link_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).'...';
+
+ $image = ($link->link_image != null) ? __('Yes') : __('No');
+ $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
+ ++$i;
+ $style = ($i % 2) ? ' class="alternate"' : '';
+?>
+ <tr valign="middle" <?php echo $style; ?>>
+ <td><strong><?php echo $link->link_name; ?></strong><br />
+<?php
+ echo sprintf(__('Description: %s'), $link->link_description) . "</td>";
+ echo "<td><a href=\"$link->link_url\" title=\"" . sprintf(__('Visit %s'), $link->link_name) . "\">$short_url</a></td>";
+ echo <<<LINKS
+ <td>$link->category</td>
+ <td>$link->link_rel</td>
+ <td align='center'>$image</td>
+ <td align='center'>$visible</td>
+LINKS;
+ $show_buttons = 1; // default
+
+ if ($link->user_level > $user_level) {
+ $show_buttons = 0;
+ }
+
+ if ($show_buttons) {
+ echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&amp;action=linkedit" class="edit">' . __('Edit') . '</a></td>';
+ echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&amp;action=Delete"' . " onclick=\"return confirm('" . __("You are about to delete this link.\\n \'Cancel\' to stop, \'OK\' to delete.") . "');" . '" class="delete">' . __('Delete') . '</a></td>';
+ echo '<td><input type="checkbox" name="linkcheck[]" value="' . $link->link_id . '" /></td>';
+ } else {
+ echo "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>\n";
+ }
+ echo "\n\t</tr>";
+ }
+ }
+?>
+</table>
+
+</div>
+
+<div class="wrap">
+ <table width="100%" cellpadding="3" cellspacing="3">
+ <tr><th colspan="4"><?php _e('Manage Multiple Links:') ?></th></tr>
+ <tr><td colspan="4"><?php _e('Use the checkboxes on the right to select multiple links and choose an action below:') ?></td></tr>
+ <tr>
+ <td>
+ <?php _e('Assign ownership to:'); ?>
+<?php
+ $results = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users WHERE user_level > 0 ORDER BY ID");
+ echo " <select name=\"newowner\" size=\"1\">\n";
+ foreach ($results as $row) {
+ echo " <option value=\"".$row->ID."\"";
+ echo ">".$row->user_login;
+ echo "</option>\n";
+ }
+ echo " </select>\n";
+?>
+ <input name="assign" type="submit" id="assign" value="<?php _e('Go') ?>" />
+ </td>
+ <td>
+ <input name="visibility" type="submit" id="visibility" value="<?php _e('Toggle Visibility') ?>" />
+ </td>
+ <td>
+ <?php _e('Move to category:'); category_dropdown('category'); ?> <input name="move" type="submit" id="move" value="<?php _e('Go') ?>" />
+ </td>
+ <td align="right">
+ <a href="#" onclick="checkAll(document.getElementById('links')); return false; "><?php _e('Toggle Checkboxes') ?></a>
+ </td>
+ </tr>
+</table>
+
+<?php
+ } // end if !popup
+?>
+</div>
+</form>
+
+
+<?php
+ break;
+ } // end default
+} // end case
+?>
+
+<?php include('admin-footer.php'); ?>
diff --git a/wp-inst/wp-admin/link-parse-opml.php b/wp-inst/wp-admin/link-parse-opml.php
new file mode 100644
index 0000000..8ec0465
--- /dev/null
+++ b/wp-inst/wp-admin/link-parse-opml.php
@@ -0,0 +1,65 @@
+<?php
+require_once('../wp-config.php');
+
+// columns we wish to find are: link_url, link_name, link_target, link_description
+// we need to map XML attribute names to our columns
+$opml_map = array('URL' => '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]<br />\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: %s at line %d",
+ 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);
+?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/menu-header.php b/wp-inst/wp-admin/menu-header.php
new file mode 100644
index 0000000..b661146
--- /dev/null
+++ b/wp-inst/wp-admin/menu-header.php
@@ -0,0 +1,58 @@
+<ul id="adminmenu">
+<?php
+$self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
+$self = preg_replace('|^.*/plugins/|i', '', $self);
+
+get_admin_page_parent();
+
+foreach ($menu as $item) {
+ $class = '';
+
+ // 0 = name, 1 = user_level, 2 = file
+ if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
+
+ if ($user_level >= $item[1]) {
+ if ( file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") )
+ echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
+ else
+ echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
+ }
+}
+
+?>
+ <li class="last"><a href="<?php echo get_settings('siteurl')
+ ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php printf(__('Logout (%s)'), $user_identity) ?></a></li>
+</ul>
+
+<?php
+// Sub-menu
+if ( isset($submenu["$parent_file"]) ) :
+?>
+<ul id="adminmenu2">
+<?php
+foreach ($submenu["$parent_file"] as $item) :
+ if ($user_level < $item[1]) {
+ continue;
+ }
+
+if ( isset($submenu_file) ) {
+ if ( $submenu_file == $item[2] ) $class = ' class="current"';
+ else $class = '';
+} else if ( (isset($plugin_page) && $plugin_page == $item[2]) || (!isset($plugin_page) && $self == $item[2]) ) $class = ' class="current"';
+else $class = '';
+
+$menu_hook = get_plugin_page_hook($item[2], $parent_file);
+
+if (file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") || ! empty($menu_hook)) {
+ if ( 'admin.php' == $pagenow )
+ echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
+ else
+ echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$parent_file}?page={$item[2]}'$class>{$item[0]}</a></li>";
+ } else {
+ echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
+ }
+endforeach;
+?>
+
+</ul>
+<?php endif; ?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/menu.php b/wp-inst/wp-admin/menu.php
new file mode 100644
index 0000000..8055d38
--- /dev/null
+++ b/wp-inst/wp-admin/menu.php
@@ -0,0 +1,67 @@
+<?php
+// This array constructs the admin menu bar.
+//
+// Menu item name
+// The minimum level the user needs to access the item: between 0 and 10
+// The URL of the item's file
+$menu[0] = array(__('Dashboard'), 0, 'index.php');
+if( $wpblog == 'main' && $user_level == 10) {
+ $menu[1] = array(__('Site Admin'), 10, 'wpmu-admin.php' );
+}
+$menu[5] = array(__('Write'), 1, 'post.php');
+$menu[10] = array(__('Manage'), 1, 'edit.php');
+$menu[20] = array(__('Links'), 5, 'link-manager.php');
+$menu[25] = array(__('Presentation'), 8, 'themes.php');
+$menu[30] = array(__('Plugins'), 8, 'plugins.php');
+$menu[35] = array(__('Users'), 0, 'profile.php');
+$menu[40] = array(__('Options'), 6, 'options-general.php');
+
+if ( get_option('use_fileupload') )
+ $menu[45] = array(__('Upload'), get_settings('fileupload_minlevel'), 'upload.php');
+
+$submenu[ 'wpmu-admin.php' ][5] = array( 'Blogs', 10, 'wpmu-blogs.php' );
+$submenu[ 'wpmu-admin.php' ][10] = array( 'Users', 10, 'wpmu-users.php' );
+$submenu['post.php'][5] = array(__('Write Post'), 1, 'post.php');
+$submenu['post.php'][10] = array(__('Write Page'), 5, 'page-new.php');
+
+$submenu['edit.php'][5] = array(__('Posts'), 1, 'edit.php');
+$submenu['edit.php'][10] = array(__('Pages'), 5, 'edit-pages.php');
+$submenu['edit.php'][15] = array(__('Categories'), 1, 'categories.php');
+$submenu['edit.php'][20] = array(__('Comments'), 1, 'edit-comments.php');
+$referers = $wpdb->get_var( "SELECT sum( visitTimes ) FROM referer_visitLog WHERE blogID='".$wpblog."' AND dayofmonth='".date( 'j' )."'" );
+$submenu['edit.php'][21] = array(sprintf(__("Referers (%s)"), $referers ), 1, 'referers.php' );
+$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
+$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), $awaiting_mod), 1, 'moderation.php');
+$submenu['edit.php'][30] = array(__('Files'), 8, 'templates.php');
+
+$submenu['link-manager.php'][5] = array(__('Manage Links'), 5, 'link-manager.php');
+$submenu['link-manager.php'][10] = array(__('Add Link'), 5, 'link-add.php');
+$submenu['link-manager.php'][15] = array(__('Link Categories'), 5, 'link-categories.php');
+$submenu['link-manager.php'][20] = array(__('Import Links'), 5, 'link-import.php');
+
+$submenu['profile.php'][5] = array(__('Your Profile'), 0, 'profile.php');
+$submenu['profile.php'][10] = array(__('Authors &amp; Users'), 5, 'users.php');
+
+$submenu['options-general.php'][5] = array(__('General'), 6, 'options-general.php');
+$submenu['options-general.php'][10] = array(__('Writing'), 6, 'options-writing.php');
+$submenu['options-general.php'][15] = array(__('Reading'), 6, 'options-reading.php');
+$submenu['options-general.php'][20] = array(__('Discussion'), 6, 'options-discussion.php');
+$submenu['options-general.php'][30] = array(__('Miscellaneous'), 6, 'options-misc.php');
+
+$submenu['plugins.php'][5] = array(__('Plugins'), 8, 'plugins.php');
+
+$submenu['themes.php'][5] = array(__('Themes'), 8, 'themes.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-inst/wp-admin/moderation.php b/wp-inst/wp-admin/moderation.php
new file mode 100644
index 0000000..3428bdf
--- /dev/null
+++ b/wp-inst/wp-admin/moderation.php
@@ -0,0 +1,220 @@
+<?php
+require_once('admin.php');
+
+$title = __('Moderate comments');
+$parent_file = 'edit.php';
+
+$wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+$comment = array();
+if (isset($_POST["comment"])) {
+ foreach ($_POST["comment"] as $k => $v) {
+ $comment[intval($k)] = $v;
+ }
+}
+
+switch($action) {
+
+case 'update':
+
+ if ($user_level < 3) {
+ die(__('<p>Your level is not high enough to moderate comments.</p>'));
+ }
+
+ $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 "<div class='updated'>\n<p>";
+ $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 <br />") . "\n";
+ } else {
+ echo sprintf(__("%s comments approved <br />"), $approved) . "\n";
+ }
+ }
+ if ($deleted) {
+ if ('1' == $deleted) {
+ echo __("1 comment deleted <br />") . "\n";
+ } else {
+ echo sprintf(__("%s comments deleted <br />"), $deleted) . "\n";
+ }
+ }
+ if ($spam) {
+ if ('1' == $spam) {
+ echo __("1 comment marked as spam <br />") . "\n";
+ } else {
+ echo sprintf(__("%s comments marked as spam <br />"), $spam) . "\n";
+ }
+ }
+ if ($ignored) {
+ if ('1' == $ignored) {
+ echo __("1 comment unchanged <br />") . "\n";
+ } else {
+ echo sprintf(__("%s comments unchanged <br />"), $ignored) . "\n";
+ }
+ }
+ echo "</p></div>\n";
+}
+
+?>
+
+<div class="wrap">
+
+<?php
+if ($user_level > 3)
+ $comments = $wpdb->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__);
+?>
+ <h2><?php _e('Moderation Queue') ?></h2>
+ <form name="approval" action="moderation.php" method="post">
+ <input type="hidden" name="action" value="update" />
+ <ol id="comments" class="commentlist">
+<?php
+$i = 0;
+ foreach($comments as $comment) {
+ ++$i;
+ $comment_date = mysql2date(get_settings("date_format") . " @ " . get_settings("time_format"), $comment->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<li id='comment-$comment->comment_ID' $class>";
+ ?>
+ <p><strong><?php _e('Name:') ?></strong> <?php comment_author_link() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('E-mail:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_email) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
+<?php comment_text() ?>
+<p><?php
+echo '<a href="post.php?action=editcomment&amp;comment='.$comment->comment_ID.'">' . __('Edit') . '</a> | ';?>
+<a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a> |
+<?php
+echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;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) . "')\">" . __('Delete just this comment') . "</a> | "; ?> <?php _e('Bulk action:') ?>
+ <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-approve" value="approve" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-approve"><?php _e('Approve') ?></label>
+ <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-spam" value="spam" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-spam"><?php _e('Spam') ?></label>
+ <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-delete" value="delete" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-delete"><?php _e('Delete') ?></label>
+ <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-nothing" value="later" checked="checked" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-nothing"><?php _e('Defer until later') ?></label>
+ </p>
+
+ </li>
+<?php
+ }
+?>
+ </ol>
+
+ <p class="submit"><input type="submit" name="submit" value="<?php _e('Moderate Comments &raquo;') ?>" /></p>
+<script type="text/javascript">
+// <![CDATA[
+function markAllForDelete() {
+ for (var i=0; i< document.approval.length; i++) {
+ if (document.approval[i].value == "delete") {
+ document.approval[i].checked = true;
+ }
+ }
+}
+function markAllForApprove() {
+ for (var i=0; i< document.approval.length; i++) {
+ if (document.approval[i].value == "approve") {
+ document.approval[i].checked = true;
+ }
+ }
+}
+function markAllForDefer() {
+ for (var i=0; i< document.approval.length; i++) {
+ if (document.approval[i].value == "later") {
+ document.approval[i].checked = true;
+ }
+ }
+}
+function markAllAsSpam() {
+ for (var i=0; i< document.approval.length; i++) {
+ if (document.approval[i].value == "spam") {
+ document.approval[i].checked = true;
+ }
+ }
+}
+document.write('<ul><li><a href="javascript:markAllForApprove()"><?php _e('Mark all for approval'); ?></a></li><li><a href="javascript:markAllAsSpam()"><?php _e('Mark all as spam'); ?></a></li><li><a href="javascript:markAllForDelete()"><?php _e('Mark all for deletion'); ?></a></li><li><a href="javascript:markAllForDefer()"><?php _e('Mark all for later'); ?></a></li></ul>');
+// ]]>
+</script>
+
+<noscript>
+ <p>
+ <input name="feelinglucky" type="checkbox" id="feelinglucky" value="true" /> <label for="feelinglucky"><?php _e('Delete every comment marked "defer." <strong>Warning: This can&#8217;t be undone.</strong>'); ?></label>
+ </p>
+</noscript>
+ </form>
+<?php
+} else {
+ // nothing to approve
+ echo __("<p>Currently there are no comments for you to moderate.</p>") . "\n";
+}
+?>
+
+</div>
+
+<?php
+
+break;
+}
+
+
+include('admin-footer.php') ?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/options-discussion.php b/wp-inst/wp-admin/options-discussion.php
new file mode 100644
index 0000000..e3732ec
--- /dev/null
+++ b/wp-inst/wp-admin/options-discussion.php
@@ -0,0 +1,100 @@
+<?php
+require_once('admin.php');
+
+$title = __('Discussion Options');
+$parent_file = 'options-general.php';
+
+include('admin-header.php');
+
+if ($action == 'retrospam') {
+ if ( $_GET['move'] == 'true' ) {
+ retrospam_mgr::move_spam( $_GET[ids] );
+ }
+ $retrospaminator = new retrospam_mgr();
+ $result = $retrospaminator->find_spam();
+ echo $retrospaminator->display_edit_form( $result );
+ include('./admin-footer.php');
+ exit;
+}
+?>
+
+<div class="wrap">
+ <h2><?php _e('Discussion Options') ?></h2>
+ <form name="form1" method="post" action="options.php">
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="page_options" value="'default_pingback_flag','default_ping_status','default_comment_status','comments_notify','moderation_notify','comment_moderation','require_name_email','comment_whitelist','comment_max_links','moderation_keys','blacklist_keys','open_proxy_check'" />
+<fieldset class="options">
+ <legend><?php _e('Usual settings for an article: <em>(These settings may be overridden for individual articles.)</em>') ?></legend>
+ <ul>
+ <li>
+ <label for="default_pingback_flag">
+ <input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_settings('default_pingback_flag')); ?> />
+ <?php _e('Attempt to notify any Weblogs linked to from the article (slows down posting.)') ?></label>
+ </li>
+ <li>
+ <label for="default_ping_status">
+ <input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_settings('default_ping_status')); ?> />
+ <?php _e('Allow link notifications from other Weblogs (pingbacks and trackbacks.)') ?></label>
+ </li>
+ <li>
+ <label for="default_comment_status">
+ <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_settings('default_comment_status')); ?> />
+ <?php _e('Allow people to post comments on the article') ?></label>
+ </li>
+ </ul>
+</fieldset>
+<fieldset class="options">
+ <legend><?php _e('E-mail me whenever:') ?></legend>
+ <ul>
+ <li>
+ <label for="comments_notify">
+ <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_settings('comments_notify')); ?> />
+ <?php _e('Anyone posts a comment') ?> </label>
+ </li>
+ <li>
+ <label for="moderation_notify">
+ <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_settings('moderation_notify')); ?> />
+ <?php _e('A comment is held for moderation') ?> </label>
+ </li>
+ </ul>
+</fieldset>
+<fieldset class="options">
+ <legend><?php _e('Before a comment appears:') ?></legend>
+ <ul>
+ <li>
+ <label for="comment_moderation">
+ <input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_settings('comment_moderation')); ?> />
+ <?php _e('An administrator must approve the comment (regardless of any matches below)') ?> </label>
+ </li>
+ <li><label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_settings('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label></li>
+ <li><label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_settings('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label></li>
+ </ul>
+</fieldset>
+<fieldset class="options">
+ <legend><?php _e('Comment Moderation') ?></legend>
+ <p><?php printf(__('Hold a comment in the queue if it contains more than %s links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="text" id="comment_max_links" size="3" value="' . get_settings('comment_max_links'). '" />' ) ?></p>
+
+ <p><?php _e('When a comment contains any of these words in its content, name, URI, e-mail, or IP, hold it in the moderation queue: (Separate multiple words with new lines.) <a href="http://codex.wordpress.org/Spam_Words">Common spam words</a>.') ?></p>
+ <p>
+ <textarea name="moderation_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('moderation_keys'); ?></textarea>
+ </p>
+ <p>
+ <a id="retrospambutton" href="options-discussion.php?action=retrospam"><?php _e('Check past comments against moderation list'); ?></a>
+ </p>
+</fieldset>
+<fieldset class="options">
+ <legend><?php _e('Comment Blacklist') ?></legend>
+ <p><?php _e('This is a list of words that you want completely blacklisted from your blog. Be very careful what you add here, because if a comment matches something here it will be completely nuked and there will be no notification. Remember that partial words can match, so if there is any chance something here might match it would be better to put it in the moderation box above.') ?></p>
+ <p>
+ <textarea name="blacklist_keys" cols="60" rows="4" id="blacklist_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('blacklist_keys'); ?></textarea>
+ </p>
+ <p><label for="open_proxy_check">
+ <input name="open_proxy_check" type="checkbox" id="open_proxy_check" value="1" <?php checked('1', get_settings('open_proxy_check')); ?> />
+ <?php _e('Blacklist comments from open and insecure proxies.') ?></label></p>
+</fieldset>
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Update Options') ?>" />
+ </p>
+ </form>
+</div>
+<?php include('./admin-footer.php'); ?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/options-general.php b/wp-inst/wp-admin/options-general.php
new file mode 100644
index 0000000..2a09684
--- /dev/null
+++ b/wp-inst/wp-admin/options-general.php
@@ -0,0 +1,91 @@
+<?php
+require_once('admin.php');
+
+$title = __('General Options');
+$parent_file = 'options-general.php';
+
+include('admin-header.php');
+?>
+
+<div class="wrap">
+ <h2><?php _e('General Options') ?></h2>
+ <form name="form1" method="post" action="options.php">
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="'blogname','blogdescription','admin_email','users_can_register','gmt_offset','date_format','time_format','start_of_week','comment_registration'" />
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Weblog title:') ?></th>
+ <td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Tagline:') ?></th>
+ <td><input name="blogdescription" type="text" id="blogdescription" style="width: 95%" value="<?php form_option('blogdescription'); ?>" size="45" />
+ <br />
+<?php _e('In a few words, explain what this weblog is about.') ?></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('E-mail address:') ?> </th>
+ <td><input name="admin_email" type="text" id="admin_email" value="<?php form_option('admin_email'); ?>" size="40" class="code" />
+ <br />
+<?php _e('This address is used only for admin purposes.') ?></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Membership:') ?></th>
+ <td> <label for="users_can_register">
+ <input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked('1', get_settings('users_can_register')); ?> />
+ <?php _e('Anyone can register') ?></label><br />
+ <label for="comment_registration">
+ <input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_settings('comment_registration')); ?> />
+ <?php _e('Users must be registered and logged in to comment') ?>
+ </label>
+</td>
+ </tr>
+ </table>
+ <fieldset class="options">
+ <legend><?php _e('Date and Time') ?></legend>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr>
+ <th scope="row" width="33%"><?php _e('<abbr title="Coordinated Universal Time">UTC</abbr> time is:') ?> </th>
+ <td><code><?php echo gmdate('Y-m-d g:i:s a'); ?></code></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Times in the weblog should differ by:') ?> </th>
+ <td><input name="gmt_offset" type="text" id="gmt_offset" size="2" value="<?php form_option('gmt_offset'); ?>" />
+ <?php _e('hours') ?> </td>
+ </tr>
+ <tr>
+ <th scope="row">&nbsp;</th>
+ <td><?php _e('The following use the same syntax as the <a href="http://php.net/date">PHP <code>date()</code> function</a>. Save option to update sample output.') ?> </td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Default date format:') ?></th>
+ <td><input name="date_format" type="text" id="date_format" size="30" value="<?php form_option('date_format'); ?>" /><br />
+<?php _e('Output:') ?> <strong><?php echo mysql2date(get_settings('date_format'), current_time('mysql')); ?></strong></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Default time format:') ?></th>
+ <td><input name="time_format" type="text" id="time_format" size="30" value="<?php form_option('time_format'); ?>" /><br />
+<?php _e('Output:') ?> <strong><?php echo gmdate(get_settings('time_format'), current_time('timestamp')); ?></strong></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Weeks in the calendar should start on:') ?></th>
+ <td><select name="start_of_week" id="start_of_week">
+ <?php
+for ($day_index = 0; $day_index <= 6; $day_index++) :
+ if ($day_index == get_settings('start_of_week')) $selected = " selected='selected'";
+ else $selected = '';
+echo "\n\t<option value='$day_index' $selected>$weekday[$day_index]</option>";
+endfor;
+?>
+</select></td>
+ </tr>
+
+</table>
+
+ </fieldset>
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
+ </p>
+ </form>
+</div>
+<?php include("admin-footer.php") ?>
diff --git a/wp-inst/wp-admin/options-head.php b/wp-inst/wp-admin/options-head.php
new file mode 100644
index 0000000..7fc54d6
--- /dev/null
+++ b/wp-inst/wp-admin/options-head.php
@@ -0,0 +1,24 @@
+<?php
+
+$wpvarstoreset = array('action','standalone', 'option_group_id');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+?>
+
+<br clear="all" />
+
+<?php if (isset($_GET['updated'])) : ?>
+<div class="updated"><p><strong><?php _e('Options saved.') ?></strong></p></div>
+<?php endif; ?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/options-misc.php b/wp-inst/wp-admin/options-misc.php
new file mode 100644
index 0000000..190192e
--- /dev/null
+++ b/wp-inst/wp-admin/options-misc.php
@@ -0,0 +1,46 @@
+<?php
+require_once('admin.php');
+
+$title = __('Miscellaneous Options');
+$parent_file = 'options-general.php';
+
+include('admin-header.php');
+
+?>
+
+<div class="wrap">
+<h2><?php _e('Miscellaneous Options') ?></h2>
+<form name="miscoptions" method="post" action="options.php">
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="page_options" value="'hack_file','use_fileupload','fileupload_minlevel','use_geo_positions','use_linksupdate'" />
+ <fieldset class="options">
+ <legend>
+ <input name="use_fileupload" type="checkbox" id="use_fileupload" value="1" <?php checked('1', get_settings('use_fileupload')); ?> />
+ <label for="use_fileupload"><?php _e('Allow File Uploads') ?></label></legend>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr>
+ <th scope="row"><?php _e('Minimum level to upload:') ?></th>
+ <td><select name="fileupload_minlevel" id="fileupload_minlevel">
+ <?php
+ for ($i = 1; $i < 11; $i++) {
+ if ($i == get_settings('fileupload_minlevel')) $selected = " selected='selected'";
+ else $selected = '';
+ echo "\n\t<option value='$i' $selected>$i</option>";
+ }
+ ?>
+ </select></td>
+ </tr>
+ </table>
+ </fieldset>
+ <p><input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_settings('use_linksupdate')); ?> />
+ <label for="use_linksupdate"><?php _e('Track Links&#8217; Update Times') ?></label></p>
+ <p>
+ <label><input type="checkbox" name="hack_file" value="1" <?php checked('1', get_settings('hack_file')); ?> /> <?php _e('Use legacy <code>my-hacks.php</code> file support') ?></label>
+ </p>
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
+ </p>
+</form>
+</div>
+
+<?php include('./admin-footer.php'); ?>
diff --git a/wp-inst/wp-admin/options-permalink.php b/wp-inst/wp-admin/options-permalink.php
new file mode 100644
index 0000000..d080b4b
--- /dev/null
+++ b/wp-inst/wp-admin/options-permalink.php
@@ -0,0 +1,116 @@
+<?php
+require_once('admin.php');
+
+$title = __('Permalink Options');
+$parent_file = 'options-general.php';
+
+include('admin-header.php');
+
+$home_path = get_home_path();
+
+if ( isset($_POST) ) {
+ if ( isset($_POST['permalink_structure']) ) {
+ $permalink_structure = $_POST['permalink_structure'];
+ if (! empty($permalink_structure) )
+ $permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
+ $wp_rewrite->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');
+
+generate_page_rewrite_rules();
+
+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;
+
+save_mod_rewrite_rules();
+?>
+
+<?php if (isset($_POST['submit'])) : ?>
+<div class="updated"><p><?php
+if ($writable)
+ _e('Permalink structure updated.');
+else
+ _e('You should update your .htaccess now.');
+?></p></div>
+<?php endif; ?>
+
+<div class="wrap">
+ <h2><?php _e('Edit Permalink Structure') ?></h2>
+ <p><?php _e('By default WordPress uses web URIs which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URI structure for your permalinks and archives. This can improve the aesthetics, usability, and longevity of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
+
+<?php if ($is_apache) : ?>
+<dl>
+<dt><?php _e('Structure'); ?>: <code>/%year%/%monthnum%/%day%/%postname%/</code></dt>
+ <strong>
+ <dd><?php _e('Result'); ?>: <code><?php echo get_settings('home') . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></dd>
+ </strong>
+ <dt><?php _e('Structure'); ?>: <code>/archives/%post_id%</code></dt>
+ <strong>
+ <dd><?php _e('Result'); ?>: <code><?php echo get_settings('home'); ?>/archives/123</code></dd>
+ </strong>
+ <dt></dt>
+</dl>
+
+<p><?php _e('For the above to work you must have something called <code>mod_rewrite</code> installed on your server. (Ask your host.) If that isn&#8217;t available, you can prefix the structure with <code>/index.php/</code> . This is the recommend method if you are on any web server but Apache.'); ?></p>
+
+<?php else : ?>
+<dl>
+<dt><?php _e('Structure'); ?>: <code>/index.php/%year%/%monthnum%/%day%/%postname%/</code></dt>
+ <strong>
+ <dd><?php _e('Result'); ?>: <code><?php echo get_settings('home') . '/index.php/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></dd>
+ </strong>
+ <dt><?php _e('Structure'); ?>: <code>/index.php/archives/%post_id%</code></dt>
+ <strong>
+ <dd><?php _e('Result'); ?>: <code><?php echo get_settings('home'); ?>/index.php/archives/123</code></dd>
+ </strong>
+ <dt></dt>
+</dl>
+<?php endif; ?>
+
+ <form name="form" action="options-permalink.php" method="post">
+ <p><?php _e('Use the template tags above to create a virtual site structure:') ?></p>
+ <p>
+ <?php _e('Structure'); ?>: <input name="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo $permalink_structure; ?>" size="50" />
+ </p>
+<?php if ($is_apache) : ?>
+ <p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/taxonomy/categorias</code> would make your category links like <code>http://example.org/taxonomy/categorias/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
+<?php else : ?>
+ <p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/index.php/taxonomy/categorias</code> would make your category links like <code>http://example.org/index.php/taxonomy/categorias/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
+<?php endif; ?>
+ <p>
+ <?php _e('Category base'); ?>: <input name="category_base" type="text" class="code" value="<?php echo $category_base; ?>" size="30" />
+ </p>
+ <p class="submit">
+ <input type="submit" name="submit" value="<?php _e('Update Permalink Structure &raquo;') ?>" />
+ </p>
+ </form>
+<?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
+ <p><?php _e('If your <code>.htaccess</code> was <a href="http://codex.wordpress.org/Make_a_Directory_Writable">writable</a> we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
+<form action="options-permalink.php" method="post">
+ <p>
+<textarea rows="5" style="width: 98%;" name="rules"><?php echo $wp_rewrite->mod_rewrite_rules(); ?>
+</textarea>
+ </p>
+</form>
+<?php endif; ?>
+
+</div>
+
+<?php require('./admin-footer.php'); ?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/options-reading.php b/wp-inst/wp-admin/options-reading.php
new file mode 100644
index 0000000..b9b4933
--- /dev/null
+++ b/wp-inst/wp-admin/options-reading.php
@@ -0,0 +1,63 @@
+<?php
+require_once('admin.php');
+
+$title = __('Reading Options');
+$parent_file = 'options-general.php';
+
+include('admin-header.php');
+?>
+
+<div class="wrap">
+<h2><?php _e('Reading Options') ?></h2>
+<form name="form1" method="post" action="options.php">
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="page_options" value="'posts_per_page','what_to_show','posts_per_rss','rss_use_excerpt','blog_charset','gzipcompression' " />
+ <fieldset class="options">
+ <legend><?php _e('Blog Pages') ?></legend>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Show at most:') ?></th>
+ <td>
+ <input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" size="3" />
+ <select name="what_to_show" id="what_to_show" >
+ <option value="days" <?php selected('days', get_settings('what_to_show')); ?>><?php _e('days') ?></option>
+ <option value="posts" <?php selected('posts', get_settings('what_to_show')); ?>><?php _e('posts') ?></option>
+ </select>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+
+ <fieldset class="options">
+ <legend><?php _e('Syndication Feeds') ?></legend>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Show the most recent:') ?></th>
+ <td><input name="posts_per_rss" type="text" id="posts_per_rss" value="<?php form_option('posts_per_rss'); ?>" size="3" /> <?php _e('posts') ?></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('For each article, show:') ?> </th>
+ <td>
+ <label><input name="rss_use_excerpt" type="radio" value="0" <?php checked(0, get_settings('rss_use_excerpt')); ?> /> <?php _e('Full text') ?></label><br />
+ <label><input name="rss_use_excerpt" type="radio" value="1" <?php checked(1, get_settings('rss_use_excerpt')); ?> /> <?php _e('Summary') ?></label>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Encoding for pages and feeds:') ?></th>
+ <td><input name="blog_charset" type="text" id="blog_charset" value="<?php form_option('blog_charset'); ?>" size="20" class="code" /><br />
+ <?php _e('The character encoding you write your blog in (UTF-8 is <a href="http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html">recommended</a>)') ?></td>
+ </tr>
+ </table>
+ <p>
+ <label><input type="checkbox" name="gzipcompression" value="1" <?php checked('1', get_settings('gzipcompression')); ?> />
+ <?php _e('WordPress should compress articles (gzip) if browsers ask for them') ?></label>
+ </p>
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
+ </p>
+</form>
+</div>
+<?php include('./admin-footer.php'); ?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/options-writing.php b/wp-inst/wp-admin/options-writing.php
new file mode 100644
index 0000000..792e3be
--- /dev/null
+++ b/wp-inst/wp-admin/options-writing.php
@@ -0,0 +1,101 @@
+<?php
+require_once('admin.php');
+
+$title = __('Writing Options');
+$parent_file = 'options-general.php';
+
+include('admin-header.php');
+?>
+
+<div class="wrap">
+ <h2><?php _e('Writing Options') ?></h2>
+ <form name="form1" method="post" action="options.php">
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="page_options" value="'default_post_edit_rows','use_smilies','use_balanceTags','ping_sites','mailserver_url', 'mailserver_port','mailserver_login','mailserver_pass','default_category','default_email_category','new_users_can_blog'" />
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th width="33%" scope="row"> <?php _e('Size of the post box:') ?></th>
+ <td><input name="default_post_edit_rows" type="text" id="default_post_edit_rows" value="<?php form_option('default_post_edit_rows'); ?>" size="2" style="width: 1.5em; " />
+ <?php _e('lines') ?></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Formatting:') ?></th>
+ <td> <label for="label">
+ <input name="use_smilies" type="checkbox" id="label" value="1" <?php checked('1', get_settings('use_smilies')); ?> />
+ <?php _e('Convert emoticons like <code>:-)</code> and <code>:-P</code> to graphics on display') ?></label> <br /> <label for="label2">
+ <input name="use_balanceTags" type="checkbox" id="label2" value="1" <?php checked('1', get_settings('use_balanceTags')); ?> />
+ <?php _e('WordPress should correct invalidly nested XHTML automatically') ?></label></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Default post category:') ?></th>
+ <td><select name="default_category" id="default_category">
+<?php
+$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
+foreach ($categories as $category) :
+if ($category->cat_ID == get_settings('default_category')) $selected = " selected='selected'";
+else $selected = '';
+ echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
+endforeach;
+?>
+ </select></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Newly registered members:') ?></th>
+ <td> <label for="new_users_can_blog0"><input name="new_users_can_blog" id="new_users_can_blog0" type="radio" value="0" <?php checked('0', get_settings('new_users_can_blog')); ?> /> <?php _e('Cannot write articles') ?></label><br />
+<label for="new_users_can_blog1"><input name="new_users_can_blog" id="new_users_can_blog1" type="radio" value="1" <?php checked('1', get_settings('new_users_can_blog')); ?> /> <?php _e('May submit drafts for review') ?></label><br />
+<label for="new_users_can_blog2"><input name="new_users_can_blog" id="new_users_can_blog2" type="radio" value="2" <?php checked('2', get_settings('new_users_can_blog')); ?> /> <?php _e('May publish articles') ?></label><br /></td>
+ </tr>
+</table>
+
+<fieldset class="options">
+ <legend><?php _e('Writing by e-mail') ?></legend>
+ <p><?php printf(__('To post to WordPress by e-mail you must set up a secret e-mail account with POP3 access. Any mail received at this address will be posted, so it&#8217;s a good idea to keep this address very secret. Here are three random strings you could use: <code>%s</code>, <code>%s</code>, <code>%s</code>.'), substr(md5(uniqid(microtime())),0,5), substr(md5(uniqid(microtime())),0,5), substr(md5(uniqid(microtime())),0,5)) ?></p>
+
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th scope="row"><?php _e('Mail server:') ?></th>
+ <td><input name="mailserver_url" type="text" id="mailserver_url" value="<?php form_option('mailserver_url'); ?>" size="40" />
+ <label for="mailserver_port"><?php _e('Port:') ?></label>
+ <input name="mailserver_port" type="text" id="mailserver_port" value="<?php form_option('mailserver_port'); ?>" size="6" />
+ </td>
+ </tr>
+ <tr valign="top">
+ <th width="33%" scope="row"><?php _e('Login name:') ?></th>
+ <td><input name="mailserver_login" type="text" id="mailserver_login" value="<?php form_option('mailserver_login'); ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Password:') ?></th>
+ <td>
+ <input name="mailserver_pass" type="text" id="mailserver_pass" value="<?php form_option('mailserver_pass'); ?>" size="40" />
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('Default post by mail category:') ?></th>
+ <td><select name="default_email_category" id="default_email_category">
+<?php
+//Alreay have $categories from default_category
+foreach ($categories as $category) :
+if ($category->cat_ID == get_settings('default_email_category')) $selected = " selected='selected'";
+else $selected = '';
+echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
+endforeach;
+?>
+ </select></td>
+ </tr>
+ </table>
+</fieldset>
+
+<fieldset class="options">
+ <legend><?php _e('Update Services') ?></legend>
+ <p><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="http://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service URIs with line breaks.') ?></p>
+
+ <textarea name="ping_sites" id="ping_sites" style="width: 98%;" rows="3" cols="50"><?php form_option('ping_sites'); ?></textarea>
+</fieldset>
+
+<p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
+</p>
+</form>
+</div>
+
+<?php include('./admin-footer.php') ?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/options.php b/wp-inst/wp-admin/options.php
new file mode 100644
index 0000000..c6158d3
--- /dev/null
+++ b/wp-inst/wp-admin/options.php
@@ -0,0 +1,123 @@
+<?php
+require_once('admin.php');
+
+$title = __('Options');
+$this_file = 'options.php';
+$parent_file = 'options-general.php';
+
+$wpvarstoreset = array('action');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+if ($user_level < 6)
+ die ( __('Cheatin&#8217; uh?') );
+
+switch($action) {
+
+case 'update':
+ $any_changed = 0;
+
+ if (!$_POST['page_options']) {
+ foreach ($_POST as $key => $value) {
+ $option_names[] = "'$key'";
+ }
+ $option_names = implode(',', $option_names);
+ } else {
+ $option_names = stripslashes($_POST['page_options']);
+ }
+
+ $options = $wpdb->get_results("SELECT $wpdb->options.option_id, option_name, option_type, option_value, option_admin_level FROM $wpdb->options WHERE option_name IN ($option_names)");
+
+ // 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) {
+ $options = apply_filters( 'options_to_update' , $options );
+ foreach ($options as $option) {
+ // should we even bother checking?
+ if ($user_level >= $option->option_admin_level) {
+ $old_val = $option->option_value;
+ $new_val = trim($_POST[$option->option_name]);
+ if( in_array($option->option_name, $nonbools) && ( $new_val == '0' || $new_val == '') )
+ $new_val = 'closed';
+ if ($new_val !== $old_val) {
+ $result = $wpdb->query("UPDATE $wpdb->options SET option_value = '$new_val' WHERE option_name = '$option->option_name'");
+ $any_changed++;
+ }
+ }
+ }
+ unset($cache_settings); // so they will be re-read
+ get_settings('siteurl'); // make it happen now
+ } // end if options
+
+ 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.
+ save_mod_rewrite_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'); ?>
+
+<div class="wrap">
+ <h2><?php _e('All options'); ?></h2>
+ <form name="form" action="options.php" method="post">
+ <input type="hidden" name="action" value="update" />
+ <table width="98%">
+<?php
+$options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
+
+foreach ($options as $option) :
+ $value = wp_specialchars($option->option_value);
+ echo "
+<tr>
+ <th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
+ <td><input type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . $value . "' /></td>
+ <td>$option->option_description</td>
+</tr>";
+endforeach;
+?>
+ </table>
+<p class="submit"><input type="submit" name="Update" value="<?php _e('Update Settings &raquo;') ?>" /></p>
+ </form>
+</div>
+
+
+<?php
+break;
+} // end switch
+
+include('admin-footer.php');
+?>
diff --git a/wp-inst/wp-admin/page-new.php b/wp-inst/wp-admin/page-new.php
new file mode 100644
index 0000000..b2432d8
--- /dev/null
+++ b/wp-inst/wp-admin/page-new.php
@@ -0,0 +1,26 @@
+<?php
+require_once('admin.php');
+$title = __('New Page');
+$parent_file = 'post.php';
+require_once('admin-header.php');
+
+get_currentuserinfo();
+?>
+
+<?php if ( isset($_GET['saved']) ) : ?>
+<div class="updated"><p><strong><?php _e('Page saved.') ?> <a href="edit-pages.php"><?php _e('Manage pages'); ?> &raquo;</a></strong></p></div>
+<?php endif; ?>
+
+<?php
+if ($user_level > 0) {
+ $action = 'post';
+ get_currentuserinfo();
+
+ $post = get_default_post_to_edit();
+ $post->post_status = 'static';
+
+ include('edit-page-form.php');
+}
+?>
+
+<?php include('admin-footer.php'); ?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/plugin-editor.php b/wp-inst/wp-admin/plugin-editor.php
new file mode 100644
index 0000000..16de1cf
--- /dev/null
+++ b/wp-inst/wp-admin/plugin-editor.php
@@ -0,0 +1,124 @@
+<?php
+require_once('admin.php');
+
+$title = __("Edit Plugins");
+$parent_file = 'plugins.php';
+
+$wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+$plugins = get_plugins();
+$plugin_files = array_keys($plugins);
+
+if (empty($file)) {
+ $file = $plugin_files[0];
+}
+
+$file = validate_file_to_edit($file, $plugin_files);
+$real_file = get_real_file_to_edit("wp-content/plugins/$file");
+
+switch($action) {
+
+case 'update':
+
+ if ($user_level < 5) {
+ die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>'));
+ }
+
+ $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 ($user_level <= 5) {
+ die(__('<p>You have do not have sufficient permissions to edit plugins for this blog.</p>'));
+ }
+
+ 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);
+ }
+
+ ?>
+<?php if (isset($_GET['a'])) : ?>
+ <div class="updated"><p><?php _e('File edited successfully.') ?></p></div>
+<?php endif; ?>
+ <div class="wrap">
+ <?php
+ if (is_writeable($real_file)) {
+ echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>';
+ } else {
+ echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>';
+ }
+ ?>
+ <div id="templateside">
+<h3><?php _e('Plugin files') ?></h3>
+
+<?php
+if ($plugin_files) :
+?>
+ <ul>
+<?php foreach($plugin_files as $plugin_file) : ?>
+ <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
+<?php endforeach; ?>
+ </ul>
+<?php endif; ?>
+</div>
+ <?php if (!$error) { ?>
+ <form name="template" id="template" action="plugin-editor.php" method="post">
+ <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="file" value="<?php echo $file ?>" />
+ </div>
+<?php if ( is_writeable($real_file) ) : ?>
+ <p class="submit">
+<?php
+ echo "<input type='submit' name='submit' value=' " . __('Update File') . " &raquo;' tabindex='2' />";
+?>
+</p>
+<?php else : ?>
+<p><em><?php _e('If this file was writable you could edit it.'); ?></em></p>
+<?php endif; ?>
+ </form>
+ <?php
+ } else {
+ echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
+ }
+ ?>
+</div>
+<?php
+break;
+}
+
+include("admin-footer.php") ?>
diff --git a/wp-inst/wp-admin/plugins.php b/wp-inst/wp-admin/plugins.php
new file mode 100644
index 0000000..3b0f997
--- /dev/null
+++ b/wp-inst/wp-admin/plugins.php
@@ -0,0 +1,120 @@
+<?php
+require_once('admin.php');
+
+if ( isset($_GET['action']) ) {
+ check_admin_referer();
+
+ if ('activate' == $_GET['action']) {
+ $current = get_settings('active_plugins');
+ if (!in_array($_GET['plugin'], $current)) {
+ $current[] = trim( $_GET['plugin'] );
+ sort($current);
+ update_option('active_plugins', $current);
+ include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] ));
+ do_action('activate_' . trim( $_GET['plugin'] ));
+ }
+ header('Location: plugins.php?activate=true');
+ } else if ('deactivate' == $_GET['action']) {
+ $current = get_settings('active_plugins');
+ array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
+ update_option('active_plugins', $current);
+ do_action('deactivate_' . trim( $_GET['plugin'] ));
+ header('Location: plugins.php?deactivate=true');
+ }
+}
+
+$title = __('Manage Plugins');
+require_once('admin-header.php');
+
+// Clean up options
+// If any plugins don't exist, axe 'em
+
+$check_plugins = get_settings('active_plugins');
+
+// Sanity check. If the active plugin list is not an array, make it an
+// empty array.
+if ( !is_array($check_plugins) ) {
+ $check_plugins = array();
+ update_option('active_plugins', $check_plugins);
+}
+
+// If a plugin file does not exist, remove it from the list of active
+// plugins.
+foreach ($check_plugins as $check_plugin) {
+ if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) {
+ $current = get_settings('active_plugins');
+ unset($current[$_GET['plugin']]);
+ update_option('active_plugins', $current);
+ }
+}
+?>
+
+<?php if (isset($_GET['activate'])) : ?>
+<div class="updated"><p><?php _e('Plugin <strong>activated</strong>.') ?></p>
+</div>
+<?php endif; ?>
+<?php if (isset($_GET['deactivate'])) : ?>
+<div class="updated"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p>
+</div>
+<?php endif; ?>
+
+<div class="wrap">
+<h2><?php _e('Plugin Management'); ?></h2>
+<p><?php _e('Plugins are files you usually download separately from WordPress that add functionality. To install a plugin you generally just need to put the plugin file into your <code>wp-content/plugins</code> directory. Once a plugin is installed, you may activate it or deactivate it here. If something goes wrong with a plugin and you can&#8217;t use WordPress, delete that plugin from the <code>wp-content/plugins</code> directory and it will be automatically deactivated.'); ?></p>
+<?php
+
+if ( get_settings('active_plugins') )
+ $current_plugins = get_settings('active_plugins');
+
+$plugins = get_plugins();
+
+if (empty($plugins)) {
+ _e("<p>Couldn't open plugins directory or there are no plugins available.</p>"); // TODO: make more helpful
+} else {
+?>
+<table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+ <th><?php _e('Plugin'); ?></th>
+ <th><?php _e('Version'); ?></th>
+ <th><?php _e('Author'); ?></th>
+ <th><?php _e('Description'); ?></th>
+ <th><?php _e('Action'); ?></th>
+ </tr>
+<?php
+ $style = '';
+ foreach($plugins as $plugin_file => $plugin_data) {
+ $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
+
+ if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
+ $action = "<a href='plugins.php?action=deactivate&amp;plugin=$plugin_file' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
+ $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>";
+ $style .= $style == 'alternate' ? ' active' : 'active';
+ } else {
+ $action = "<a href='plugins.php?action=activate&amp;plugin=$plugin_file' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
+ }
+ $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 "
+ <tr $style>
+ <td class=\"name\">{$plugin_data['Title']}</td>
+ <td class=\"vers\">{$plugin_data['Version']}</td>
+ <td class=\"auth\">{$plugin_data['Author']}</td>
+ <td class=\"desc\">{$plugin_data['Description']}</td>
+ <td class=\"togl\">$action</td>
+ </tr>";
+ }
+?>
+
+</table>
+<?php
+}
+?>
+
+<h2><?php _e('Get More Plugins'); ?></h2>
+<p><?php _e('You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>. To install a plugin you generally just need to upload the plugin file into your <code>wp-content/plugins</code> directory. Once a plugin is uploaded, you may activate it here.'); ?></p>
+
+</div>
+
+<?php
+include('admin-footer.php');
+?>
diff --git a/wp-inst/wp-admin/post.php b/wp-inst/wp-admin/post.php
new file mode 100644
index 0000000..e29156b
--- /dev/null
+++ b/wp-inst/wp-admin/post.php
@@ -0,0 +1,410 @@
+<?php
+require_once('admin.php');
+
+$wpvarstoreset = array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder' );
+
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+if (isset($_POST['deletepost'])) {
+$action = "delete";
+}
+
+ // Fix submenu highlighting for pages.
+if (false !== strpos($_SERVER['HTTP_REFERER'], 'edit-pages.php')) $submenu_file = 'page-new.php';
+
+$editing = true;
+
+switch($action) {
+case 'post':
+
+ $post_ID = write_post();
+
+ // Redirect.
+ if (!empty($_POST['mode'])) {
+ switch($_POST['mode']) {
+ case 'bookmarklet':
+ $location = 'bookmarklet.php?a=b';
+ break;
+ case 'sidebar':
+ $location = 'sidebar.php?a=b';
+ break;
+ default:
+ $location = 'post.php';
+ break;
+ }
+ } else {
+ $location = 'post.php?posted=true';
+ }
+
+ if ( 'static' == $_POST['post_status'] )
+ $location = "page-new.php?saved=true";
+
+ if ( '' != $_POST['advanced'] || isset($_POST['save']) )
+ $location = "post.php?action=edit&post=$post_ID";
+
+ header("Location: $location");
+ exit();
+ break;
+
+case 'edit':
+ $title = __('Edit');
+
+ require_once('admin-header.php');
+
+ $post_ID = $p = (int) $_GET['post'];
+
+ if ( !current_user_can('edit_post', $post_ID) )
+ die ( __('You are not allowed to edit this post.') );
+
+ if ( !user_can_edit_post($user_ID, $post_ID) )
+ die ( __('You are not allowed to view other users\' private posts.') );
+
+ $post = get_post_to_edit($post_ID);
+
+ if ($post->post_status == 'static')
+ include('edit-page-form.php');
+ else
+ include('edit-form-advanced.php');
+
+ ?>
+ <div id='preview' class='wrap'>
+ <h2><?php _e('Post Preview (updated when post is saved)'); ?></h2>
+ <h3 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__("Permanent Link: %s"), get_the_title()); ?>"><?php the_title(); ?></a></h3>
+ <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(','); ?> &#8212; <?php the_author() ?> @ <?php the_time() ?></div>
+
+ <div class="storycontent">
+ <?php
+ echo apply_filters('the_content', $post->post_content);
+ ?>
+ </div>
+ </div>
+ <?php
+ break;
+
+case 'editpost':
+ edit_post();
+
+ if ($_POST['save']) {
+ $location = $_SERVER['HTTP_REFERER'];
+ } elseif ($_POST['updatemeta']) {
+ $location = $_SERVER['HTTP_REFERER'] . '&message=2#postcustom';
+ } elseif ($_POST['deletemeta']) {
+ $location = $_SERVER['HTTP_REFERER'] . '&message=3#postcustom';
+ } elseif (isset($_POST['referredby']) && $_POST['referredby'] != $_SERVER['HTTP_REFERER']) {
+ $location = $_POST['referredby'];
+ if ( $_POST['referredby'] == 'redo' )
+ $location = get_permalink( $post_ID );
+ } else {
+ $location = 'post.php';
+ }
+ header ('Location: ' . $location); // Send user on their way while we keep working
+
+ exit();
+ break;
+
+case 'delete':
+ check_admin_referer();
+
+ $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
+
+ if (!user_can_delete_post($user_ID, $post_id)) {
+ die( __('You are not allowed to delete this post.') );
+ }
+
+ 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';
+ $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. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)'));
+
+ if ( !user_can_edit_post_comments($user_ID, $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. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( !user_can_delete_post_comments($user_ID, $comment->comment_post_ID) )
+ die( __('You are not allowed to delete comments on this post.') );
+
+ echo "<div class='wrap'>\n";
+ echo "<p>" . __('<strong>Caution:</strong> You are about to delete the following comment:') . "</p>\n";
+ echo "<table border='0'>\n";
+ echo "<tr><td>" . __('Author:') . "</td><td>$comment->comment_author</td></tr>\n";
+ echo "<tr><td>" . __('E-mail:') . "</td><td>$comment->comment_author_email</td></tr>\n";
+ echo "<tr><td>". __('URL:') . "</td><td>$comment->comment_author_url</td></tr>\n";
+ echo "<tr><td>". __('Comment:') . "</td><td>$comment->comment_content</td></tr>\n";
+ echo "</table>\n";
+ echo "<p>" . __('Are you sure you want to do that?') . "</p>\n";
+
+ echo "<form action='".get_settings('siteurl')."/wp-admin/post.php' method='get'>\n";
+ echo "<input type='hidden' name='action' value='deletecomment' />\n";
+ echo "<input type='hidden' name='p' value='$p' />\n";
+ echo "<input type='hidden' name='comment' value='{$comment->comment_ID}' />\n";
+ echo "<input type='hidden' name='noredir' value='1' />\n";
+ echo "<input type='submit' value='" . __('Yes') . "' />";
+ echo "&nbsp;&nbsp;";
+ echo "<input type='button' value='" . __('No') . "' onclick='self.location='". get_settings('siteurl') ."/wp-admin/edit.php?p=$p&amp;c=1#comments';' />\n";
+ echo "</form>\n";
+ echo "</div>\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. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( ! $comment = get_comment($comment) )
+ die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'post.php'));
+
+ if (!user_can_delete_post_comments($user_ID, $commentdata['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':
+
+ require_once('./admin-header.php');
+
+ 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. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( !user_can_edit_post_comments($user_ID, $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. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( !user_can_edit_post_comments($user_ID, $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. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( !user_can_edit_post_comments($user_ID, $commentdata['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');
+?>
+<?php if ( isset($_GET['posted']) ) : ?>
+<div class="updated"><p><?php printf(__('Post saved. <a href="%s">View site &raquo;</a>'), get_bloginfo('home')); ?></p></div>
+<?php endif; ?>
+<?php
+ if ( user_can_create_draft($user_ID) ) {
+ $action = 'post';
+ get_currentuserinfo();
+ if ( $drafts = get_users_drafts( $user_ID ) ) {
+ ?>
+ <div class="wrap">
+ <p><strong><?php _e('Your Drafts:') ?></strong>
+ <?php
+ for ( $i = 0; $i < 15; $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 "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
+ }
+ ?>
+ <?php if ( 15 < count($drafts) ) { ?>
+ , <a href="edit.php"><?php echo sprintf(__('and %s more'), (count($drafts) - 15) ); ?> &raquo;</a>
+ <?php } ?>
+ .</p>
+ </div>
+ <?php
+ }
+
+ $post = get_default_post_to_edit();
+
+ include('edit-form-advanced.php');
+?>
+<div class="wrap">
+<?php _e('<h3>WordPress bookmarklet</h3>
+<p>Right click on the following link and choose "Add to favorites" to create a posting shortcut.</p>') ?>
+<p>
+
+<?php
+$bookmarklet_height= (get_settings('use_trackback')) ? 480 : 440;
+
+if ($is_NS4 || $is_gecko) {
+?>
+<a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}void(window.open('<?php echo get_settings('siteurl') ?>/wp-admin/bookmarklet.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title),'<?php _e('WordPress bookmarklet') ?>','scrollbars=yes,width=600,height=460,left=100,top=150,status=yes'));"><?php printf(__('Press It - %s'), wp_specialchars(get_settings('blogname'))); ?></a>
+<?php
+} else if ($is_winIE) {
+?>
+<a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;void(btw=window.open('<?php echo get_settings('siteurl') ?>/wp-admin/bookmarklet.php?text='+encodeURIComponent(Q)+'<?php echo $bookmarklet_tbpb ?>&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title),'bookmarklet','scrollbars=yes,width=600,height=<?php echo $bookmarklet_height ?>,left=100,top=150,status=yes'));btw.focus();"><?php printf(__('Press it - %s'), get_settings('blogname')); ?></a>
+<script type="text/javascript">
+<!--
+function oneclickbookmarklet(blah) {
+window.open ("profile.php?action=IErightclick", "oneclickbookmarklet", "width=500, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=120, left=120, screenY=120, top=120");
+}
+// -->
+</script>
+<br />
+<br />
+<?php _e('One-click bookmarklet:') ?><br />
+<a href="javascript:oneclickbookmarklet(0);"><?php _e('click here') ?></a>
+<?php
+} else if ($is_opera) {
+?>
+<a href="javascript:void(window.open('<?php echo get_settings('siteurl'); ?>/wp-admin/bookmarklet.php?popupurl='+escape(location.href)+'&popuptitle='+escape(document.title)+'<?php echo $bookmarklet_tbpb ?>','bookmarklet','scrollbars=yes,width=600,height=<?php echo $bookmarklet_height ?>,left=100,top=150,status=yes'));"><?php printf(__('Press it - %s'), get_settings('blogname')); ?></a>
+<?php
+} else if ($is_macIE) {
+?>
+<a href="javascript:Q='';if(top.frames.length==0);void(btw=window.open('<?php echo get_settings('siteurl'); ?>/wp-admin/bookmarklet.php?text='+escape(document.getSelection())+'&popupurl='+escape(location.href)+'&popuptitle='+escape(document.title)+'<?php echo $bookmarklet_tbpb ?>','bookmarklet','scrollbars=yes,width=600,height=<?php echo $bookmarklet_height ?>,left=100,top=150,status=yes'));btw.focus();"><?php printf(__('Press it - %s'), get_settings('blogname')); ?></a>
+<?php
+}
+?>
+</p>
+</div>
+<?php
+} else {
+?>
+<div class="wrap">
+<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />
+You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
+When you&#8217;re promoted, just reload this page and you&#8217;ll be able to blog. :)'), get_settings('admin_email')); ?>
+</p>
+</div>
+<?php
+}
+
+ break;
+} // end switch
+/* </Edit> */
+include('admin-footer.php');
+?>
diff --git a/wp-inst/wp-admin/profile.php b/wp-inst/wp-admin/profile.php
new file mode 100644
index 0000000..4fe4162
--- /dev/null
+++ b/wp-inst/wp-admin/profile.php
@@ -0,0 +1,281 @@
+<?php
+require_once('admin.php');
+
+$title = 'Profile';
+$parent_file = 'profile.php';
+
+$wpvarstoreset = array('action', 'profile', 'user');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+require_once('../wp-config.php');
+auth_redirect();
+switch($action) {
+
+case 'update':
+
+ get_currentuserinfo();
+
+ /* checking the nickname has been typed */
+ if (empty($_POST["newuser_nickname"])) {
+ die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)"));
+ return false;
+ }
+
+ /* if the ICQ UIN has been entered, check to see if it has only numbers */
+ if (!empty($_POST["newuser_icq"])) {
+ if ((ereg("^[0-9]+$",$_POST["newuser_icq"]))==false) {
+ die (__("<strong>ERROR</strong>: your ICQ UIN can only be a number, no letters allowed"));
+ return false;
+ }
+ }
+
+ /* checking e-mail address */
+ if (empty($_POST["newuser_email"])) {
+ die (__("<strong>ERROR</strong>: please type your e-mail address"));
+ return false;
+ } else if (!is_email($_POST["newuser_email"])) {
+ die (__("<strong>ERROR</strong>: the e-mail address isn't correct"));
+ return false;
+ }
+
+ $pass1 = $_POST["pass1"];
+ $pass2 = $_POST["pass2"];
+ do_action('check_passwords', array($user_login, &$pass1, &$pass2));
+
+ if ( '' == $pass1 ) {
+ if ( '' != $pass2 )
+ die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
+ $updatepassword = "";
+ } else {
+ if ('' == $pass2)
+ die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
+ if ( $pass1 != $pass2 )
+ die (__("<strong>ERROR</strong>: you typed two different passwords. Go back to correct that."));
+ $newuser_pass = $pass1;
+ $updatepassword = "user_pass=MD5('$newuser_pass'), ";
+ wp_clearcookie();
+ wp_setcookie($user_login, $newuser_pass);
+ }
+
+ $newuser_firstname = wp_specialchars($_POST['newuser_firstname']);
+ $newuser_lastname = wp_specialchars($_POST['newuser_lastname']);
+ $new_display_name = wp_specialchars($_POST['display_name']);
+ $newuser_nickname = $_POST['newuser_nickname'];
+ $newuser_nicename = sanitize_title($newuser_nickname);
+ $newuser_icq = wp_specialchars($_POST['newuser_icq']);
+ $newuser_aim = wp_specialchars($_POST['newuser_aim']);
+ $newuser_msn = wp_specialchars($_POST['newuser_msn']);
+ $newuser_yim = wp_specialchars($_POST['newuser_yim']);
+ $newuser_email = wp_specialchars($_POST['newuser_email']);
+ $newuser_url = wp_specialchars($_POST['newuser_url']);
+ $newuser_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $newuser_url) ? $newuser_url : 'http://' . $newuser_url;
+ $user_description = $_POST['user_description'];
+
+ $result = $wpdb->query("UPDATE $wpdb->users SET $updatepassword user_email='$newuser_email', user_url='$newuser_url', user_nicename = '$newuser_nicename', display_name = '$new_display_name' WHERE ID = $user_ID");
+
+ update_usermeta( $user_ID, 'first_name', $newuser_firstname );
+ update_usermeta( $user_ID, 'last_name', $newuser_lastname );
+ update_usermeta( $user_ID, 'nickname', $newuser_nickname );
+ update_usermeta( $user_ID, 'description', $user_description );
+ update_usermeta( $user_ID, 'icq', $newuser_icq );
+ update_usermeta( $user_ID, 'aim', $newuser_aim );
+ update_usermeta( $user_ID, 'msn', $newuser_msn );
+ update_usermeta( $user_ID, 'yim', $newuser_yim );
+
+ do_action('profile_update', $user_ID);
+
+ wp_redirect('profile.php?updated=true');
+break;
+
+case 'IErightclick':
+
+ $bookmarklet_height= 550;
+
+ ?>
+
+ <div class="menutop">&nbsp;IE one-click bookmarklet</div>
+
+ <table width="100%" cellpadding="20">
+ <tr><td>
+
+ <p>To have a one-click bookmarklet, just copy and paste this<br />into a new text file:</p>
+ <?php
+ $regedit = "REGEDIT4\r\n[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Post To &WP : ". get_settings('blogname') ."]\r\n@=\"javascript:doc=external.menuArguments.document;Q=doc.selection.createRange().text;void(btw=window.open('". get_settings('siteurl') ."/wp-admin/bookmarklet.php?text='+escape(Q)+'".$bookmarklet_tbpb."&popupurl='+escape(doc.location.href)+'&popuptitle='+escape(doc.title),'bookmarklet','scrollbars=no,width=480,height=".$bookmarklet_height.",left=100,top=150,status=yes'));btw.focus();\"\r\n\"contexts\"=hex:31\"";
+ ?>
+ <pre style="margin: 20px; background-color: #cccccc; border: 1px dashed #333333; padding: 5px; font-size: 12px;"><?php echo $regedit; ?></pre>
+ <p>Save it as wordpress.reg, and double-click on this file in an Explorer<br />
+ window. Answer Yes to the question, and restart Internet Explorer.<br /><br />
+ That's it, you can now right-click in an IE window and select <br />
+ 'Post to WP' to make the bookmarklet appear. :)</p>
+
+ <p align="center">
+ <form>
+ <input class="search" type="button" value="1" name="Close this window" />
+ </form>
+ </p>
+ </td></tr>
+ </table>
+ <?php
+
+break;
+
+
+default:
+ $parent_file = 'profile.php';
+ include_once('admin-header.php');
+ $profiledata = get_userdata($user_ID);
+
+ $bookmarklet_height= 440;
+
+if (isset($updated)) { ?>
+<div class="updated">
+<p><strong><?php _e('Profile updated.') ?></strong></p>
+</div>
+<?php } ?>
+<div class="wrap">
+<h2><?php _e('Profile'); ?></h2>
+<form name="profile" id="profile" action="profile.php" method="post">
+ <p>
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
+ </p>
+
+ <table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform">
+ <tr>
+ <th width="33%" scope="row"><?php _e('Username:') ?></th>
+ <td width="67%"><?php echo $profiledata->user_login; ?></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Level:') ?></th>
+ <td><?php echo $profiledata->user_level; ?></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Posts:') ?></th>
+ <td> <?php
+ $posts = get_usernumposts($user_ID);
+ echo $posts;
+ ?></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('First name:') ?></th>
+ <td><input type="text" name="newuser_firstname" id="newuser_firstname" value="<?php echo $profiledata->first_name ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Last name:') ?></th>
+ <td><input type="text" name="newuser_lastname" id="newuser_lastname2" value="<?php echo $profiledata->last_name ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Nickname:') ?></th>
+ <td><input type="text" name="newuser_nickname" id="newuser_nickname2" value="<?php echo $profiledata->nickname ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('How to display name:') ?> </th>
+ <td>
+ <select name="display_name">
+ <option value="<?php echo $profiledata->display_name; ?>"><?php echo $profiledata->display_name; ?></option>
+ <option value="<?php echo $profiledata->nickname ?>"><?php echo $profiledata->nickname ?></option>
+ <option value="<?php echo $profiledata->user_login ?>"><?php echo $profiledata->user_login ?></option>
+ <?php if ( !empty( $profiledata->first_name ) ) : ?>
+ <option value="<?php echo $profiledata->first_name ?>"><?php echo $profiledata->first_name ?></option>
+ <?php endif; ?>
+ <?php if ( !empty( $profiledata->last_name ) ) : ?>
+ <option value="<?php echo $profiledata->last_name ?>"><?php echo $profiledata->last_name ?></option>
+ <?php endif; ?>
+ <?php if ( !empty( $profiledata->first_name ) && !empty( $profiledata->last_name ) ) : ?>
+ <option value="<?php echo $profiledata->first_name." ".$profiledata->last_name ?>"><?php echo $profiledata->first_name." ".$profiledata->last_name ?></option>
+ <option value="<?php echo $profiledata->last_name." ".$profiledata->first_name ?>"><?php echo $profiledata->last_name." ".$profiledata->first_name ?></option>
+ <?php endif; ?>
+ </select> </td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('E-mail:') ?></th>
+ <td><input type="text" name="newuser_email" id="newuser_email2" value="<?php echo $profiledata->user_email ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Website:') ?></th>
+ <td><input type="text" name="newuser_url" id="newuser_url2" value="<?php echo $profiledata->user_url ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('ICQ:') ?></th>
+ <td><input type="text" name="newuser_icq" id="newuser_icq2" value="<?php if ($profiledata->icq > 0) { echo $profiledata->icq; } ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('AIM:') ?></th>
+ <td><input type="text" name="newuser_aim" id="newuser_aim2" value="<?php echo $profiledata->aim ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('MSN IM:') ?> </th>
+ <td><input type="text" name="newuser_msn" id="newuser_msn2" value="<?php echo $profiledata->msn ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Yahoo IM:') ?> </th>
+ <td> <input type="text" name="newuser_yim" id="newuser_yim2" value="<?php echo $profiledata->yim ?>" /> </td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Profile:') ?></th>
+ <td><textarea name="user_description" rows="5" id="textarea2" style="width: 99%; "><?php echo $profiledata->user_description ?></textarea></td>
+ </tr>
+<?php
+$show_password_fields = apply_filters('show_password_fields', true);
+if ( $show_password_fields ) :
+?>
+ <tr>
+ <th scope="row"><?php _e('New <strong>Password</strong> (Leave blank to stay the same.)') ?></th>
+ <td><input type="password" name="pass1" size="16" value="" />
+ <br />
+ <input type="password" name="pass2" size="16" value="" /></td>
+ </tr>
+<?php endif; ?>
+ </table>
+ <p class="submit">
+ <input type="submit" value="<?php _e('Update Profile &raquo;') ?>" name="submit" />
+ </p>
+</form>
+</div>
+
+
+<?php if ($is_gecko && $profiledata->user_level != 0) { ?>
+<div class="wrap">
+ <script type="text/javascript">
+//<![CDATA[
+function addPanel()
+ {
+ if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function"))
+ window.sidebar.addPanel("WordPress Post: <?php echo get_settings('blogname'); ?>","<?php echo get_settings('siteurl'); ?>/wp-admin/sidebar.php","");
+ else
+ alert(<?php __("'No Sidebar found! You must use Mozilla 0.9.4 or later!'") ?>);
+ }
+//]]>
+</script>
+ <strong><?php _e('SideBar') ?></strong><br />
+ <?php _e('Add the <a href="#" onclick="addPanel()">WordPress Sidebar</a>!') ?>
+ <?php } elseif (($is_winIE) || ($is_macIE)) { ?>
+ <strong><?php _e('SideBar') ?></strong><br />
+ <?php __('Add this link to your favorites:') ?><br />
+<a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;void(_search=open('<?php echo get_settings('siteurl');
+ ?>/wp-admin/sidebar.php?text='+escape(Q)+'&popupurl='+escape(location.href)+'&popuptitle='+escape(document.title),'_search'))"><?php _e('WordPress Sidebar') ?></a>.
+
+</div>
+<?php } ?>
+</div>
+ <?php
+
+break;
+}
+
+/* </Profile | My Profile> */
+include('admin-footer.php');
+ ?>
diff --git a/wp-inst/wp-admin/quicktags.js b/wp-inst/wp-admin/quicktags.js
new file mode 100644
index 0000000..7f4d7a3
--- /dev/null
+++ b/wp-inst/wp-admin/quicktags.js
@@ -0,0 +1,389 @@
+// new edit toolbar used with permission
+// by Alex King
+// http://www.alexking.org/
+
+var edButtons = new Array();
+var edLinks = new Array();
+var edOpenTags = new Array();
+
+function edButton(id, display, tagStart, tagEnd, access, open) {
+ this.id = id; // used to name the toolbar button
+ this.display = display; // label on button
+ this.tagStart = tagStart; // open tag
+ this.tagEnd = tagEnd; // close tag
+ this.access = access; // access key
+ this.open = open; // set to -1 if tag does not need to be closed
+}
+
+function zeroise(number, threshold) {
+ // FIXME: or we could use an implementation of printf in js here
+ var str = number.toString();
+ if (number < 0) { str = str.substr(1, str.length) }
+ while (str.length < threshold) { str = "0" + str }
+ if (number < 0) { str = '-' + str }
+ return str;
+}
+
+var now = new Date();
+var datetime = now.getUTCFullYear() + '-' +
+zeroise(now.getUTCMonth() + 1, 2) + '-' +
+zeroise(now.getUTCDate(), 2) + 'T' +
+zeroise(now.getUTCHours(), 2) + ':' +
+zeroise(now.getUTCMinutes(), 2) + ':' +
+zeroise(now.getUTCSeconds() ,2) +
+'+00:00';
+
+edButtons[edButtons.length] =
+new edButton('ed_strong'
+,'b'
+,'<strong>'
+,'</strong>'
+,'b'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_em'
+,'i'
+,'<em>'
+,'</em>'
+,'i'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_link'
+,'link'
+,''
+,'</a>'
+,'a'
+); // special case
+
+edButtons[edButtons.length] =
+new edButton('ed_block'
+,'b-quote'
+,'\n\n<blockquote>'
+,'</blockquote>\n\n'
+,'q'
+);
+
+
+edButtons[edButtons.length] =
+new edButton('ed_del'
+,'del'
+,'<del datetime="' + datetime + '">'
+,'</del>'
+,'d'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_ins'
+,'ins'
+,'<ins datetime="' + datetime + '">'
+,'</ins>'
+,'s'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_img'
+,'img'
+,''
+,''
+,'m'
+,-1
+); // special case
+
+edButtons[edButtons.length] =
+new edButton('ed_ul'
+,'ul'
+,'<ul>\n'
+,'</ul>\n\n'
+,'u'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_ol'
+,'ol'
+,'<ol>\n'
+,'</ol>\n\n'
+,'o'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_li'
+,'li'
+,'\t<li>'
+,'</li>\n'
+,'l'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_code'
+,'code'
+,'<code>'
+,'</code>'
+,'c'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_more'
+,'more'
+,'<!--more-->'
+,''
+,'t'
+,-1
+);
+/*
+edButtons[edButtons.length] =
+new edButton('ed_next'
+,'page'
+,'<!--nextpage-->'
+,''
+,'p'
+,-1
+);
+*/
+function edLink() {
+ this.display = '';
+ this.URL = '';
+ this.newWin = 0;
+}
+
+edLinks[edLinks.length] = new edLink('WordPress'
+ ,'http://wordpress.org/'
+ );
+
+edLinks[edLinks.length] = new edLink('alexking.org'
+ ,'http://www.alexking.org/'
+ );
+
+function edShowButton(button, i) {
+ if (button.id == 'ed_img') {
+ document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage(edCanvas);" value="' + button.display + '" />');
+ }
+ else if (button.id == 'ed_link') {
+ document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertLink(edCanvas, ' + i + ');" value="' + button.display + '" />');
+ }
+ else {
+ document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertTag(edCanvas, ' + i + ');" value="' + button.display + '" />');
+ }
+}
+
+function edShowLinks() {
+ var tempStr = '<select onchange="edQuickLink(this.options[this.selectedIndex].value, this);"><option value="-1" selected>(Quick Links)</option>';
+ for (i = 0; i < edLinks.length; i++) {
+ tempStr += '<option value="' + i + '">' + edLinks[i].display + '</option>';
+ }
+ tempStr += '</select>';
+ document.write(tempStr);
+}
+
+function edAddTag(button) {
+ if (edButtons[button].tagEnd != '') {
+ edOpenTags[edOpenTags.length] = button;
+ document.getElementById(edButtons[button].id).value = '/' + document.getElementById(edButtons[button].id).value;
+ }
+}
+
+function edRemoveTag(button) {
+ for (i = 0; i < edOpenTags.length; i++) {
+ if (edOpenTags[i] == button) {
+ edOpenTags.splice(i, 1);
+ document.getElementById(edButtons[button].id).value = document.getElementById(edButtons[button].id).value.replace('/', '');
+ }
+ }
+}
+
+function edCheckOpenTags(button) {
+ var tag = 0;
+ for (i = 0; i < edOpenTags.length; i++) {
+ if (edOpenTags[i] == button) {
+ tag++;
+ }
+ }
+ if (tag > 0) {
+ return true; // tag found
+ }
+ else {
+ return false; // tag not found
+ }
+}
+
+function edCloseAllTags() {
+ var count = edOpenTags.length;
+ for (o = 0; o < count; o++) {
+ edInsertTag(edCanvas, edOpenTags[edOpenTags.length - 1]);
+ }
+}
+
+function edQuickLink(i, thisSelect) {
+ if (i > -1) {
+ var newWin = '';
+ if (edLinks[i].newWin == 1) {
+ newWin = ' target="_blank"';
+ }
+ var tempStr = '<a href="' + edLinks[i].URL + '"' + newWin + '>'
+ + edLinks[i].display
+ + '</a>';
+ thisSelect.selectedIndex = 0;
+ edInsertContent(edCanvas, tempStr);
+ }
+ else {
+ thisSelect.selectedIndex = 0;
+ }
+}
+
+function edSpell(myField) {
+ var word = '';
+ if (document.selection) {
+ myField.focus();
+ var sel = document.selection.createRange();
+ if (sel.text.length > 0) {
+ word = sel.text;
+ }
+ }
+ else if (myField.selectionStart || myField.selectionStart == '0') {
+ var startPos = myField.selectionStart;
+ var endPos = myField.selectionEnd;
+ if (startPos != endPos) {
+ word = myField.value.substring(startPos, endPos);
+ }
+ }
+ if (word == '') {
+ word = prompt('Enter a word to look up:', '');
+ }
+ if (word !== null && /^\w[\w ]*$/.test(word)) {
+ window.open('http://www.answers.com/' + escape(word));
+ }
+}
+
+function edToolbar() {
+ document.write('<div id="ed_toolbar">');
+ for (i = 0; i < edButtons.length; i++) {
+ edShowButton(edButtons[i], i);
+ }
+ document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="Dictionary lookup" value="lookup" />');
+ document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="Close all open tags" value="Close Tags" />');
+// edShowLinks(); // disabled by default
+ document.write('</div>');
+}
+
+// insertion code
+
+function edInsertTag(myField, i) {
+ //IE support
+ if (document.selection) {
+ myField.focus();
+ sel = document.selection.createRange();
+ if (sel.text.length > 0) {
+ sel.text = edButtons[i].tagStart + sel.text + edButtons[i].tagEnd;
+ }
+ else {
+ if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') {
+ sel.text = edButtons[i].tagStart;
+ edAddTag(i);
+ }
+ else {
+ sel.text = edButtons[i].tagEnd;
+ edRemoveTag(i);
+ }
+ }
+ myField.focus();
+ }
+ //MOZILLA/NETSCAPE support
+ else if (myField.selectionStart || myField.selectionStart == '0') {
+ var startPos = myField.selectionStart;
+ var endPos = myField.selectionEnd;
+ var cursorPos = endPos;
+ var scrollTop = myField.scrollTop;
+
+ if (startPos != endPos) {
+ myField.value = myField.value.substring(0, startPos)
+ + edButtons[i].tagStart
+ + myField.value.substring(startPos, endPos)
+ + edButtons[i].tagEnd
+ + myField.value.substring(endPos, myField.value.length);
+ cursorPos += edButtons[i].tagStart.length + edButtons[i].tagEnd.length;
+ }
+ else {
+ if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') {
+ myField.value = myField.value.substring(0, startPos)
+ + edButtons[i].tagStart
+ + myField.value.substring(endPos, myField.value.length);
+ edAddTag(i);
+ cursorPos = startPos + edButtons[i].tagStart.length;
+ }
+ else {
+ myField.value = myField.value.substring(0, startPos)
+ + edButtons[i].tagEnd
+ + myField.value.substring(endPos, myField.value.length);
+ edRemoveTag(i);
+ cursorPos = startPos + edButtons[i].tagEnd.length;
+ }
+ }
+ myField.focus();
+ myField.selectionStart = cursorPos;
+ myField.selectionEnd = cursorPos;
+ myField.scrollTop = scrollTop;
+ }
+ else {
+ if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') {
+ myField.value += edButtons[i].tagStart;
+ edAddTag(i);
+ }
+ else {
+ myField.value += edButtons[i].tagEnd;
+ edRemoveTag(i);
+ }
+ myField.focus();
+ }
+}
+
+function edInsertContent(myField, myValue) {
+ //IE support
+ if (document.selection) {
+ myField.focus();
+ sel = document.selection.createRange();
+ sel.text = myValue;
+ myField.focus();
+ }
+ //MOZILLA/NETSCAPE support
+ else if (myField.selectionStart || myField.selectionStart == '0') {
+ var startPos = myField.selectionStart;
+ var endPos = myField.selectionEnd;
+ myField.value = myField.value.substring(0, startPos)
+ + myValue
+ + myField.value.substring(endPos, myField.value.length);
+ myField.focus();
+ myField.selectionStart = startPos + myValue.length;
+ myField.selectionEnd = startPos + myValue.length;
+ } else {
+ myField.value += myValue;
+ myField.focus();
+ }
+}
+
+function edInsertLink(myField, i, defaultValue) {
+ if (!defaultValue) {
+ defaultValue = 'http://';
+ }
+ if (!edCheckOpenTags(i)) {
+ var URL = prompt('Enter the URL' ,defaultValue);
+ if (URL) {
+ edButtons[i].tagStart = '<a href="' + URL + '">';
+ edInsertTag(myField, i);
+ }
+ }
+ else {
+ edInsertTag(myField, i);
+ }
+}
+
+function edInsertImage(myField) {
+ var myValue = prompt('Enter the URL of the image', 'http://');
+ if (myValue) {
+ myValue = '<img src="'
+ + myValue
+ + '" alt="' + prompt('Enter a description of the image', '')
+ + '" />';
+ edInsertContent(myField, myValue);
+ }
+} \ No newline at end of file
diff --git a/wp-inst/wp-admin/referers.php b/wp-inst/wp-admin/referers.php
new file mode 100644
index 0000000..342d437
--- /dev/null
+++ b/wp-inst/wp-admin/referers.php
@@ -0,0 +1,431 @@
+<?php
+
+// $Id: referers.php,v 1.6 2005/01/25 11:35:39 donncha Exp $
+
+require_once('admin.php');
+$title = "Referers";
+$parent_file = 'edit.php';
+include( '../wp-config.php' );
+require_once("admin-header.php");
+
+$b2varstoreset = array('action','standalone', "day", "order", "num" );
+for ($i=0; $i<count($b2varstoreset); $i += 1) {
+ $b2var = $b2varstoreset[$i];
+ if (!isset($$b2var)) {
+ if (empty($HTTP_POST_VARS["$b2var"])) {
+ if (empty($HTTP_GET_VARS["$b2var"])) {
+ $$b2var = '';
+ } else {
+ $$b2var = $HTTP_GET_VARS["$b2var"];
+ }
+ } else {
+ $$b2var = $HTTP_POST_VARS["$b2var"];
+ }
+ }
+}
+
+function makeHiddenVals()
+{
+ $fields = array( "day", "order", "num", "more", "ignoreDIRECT", "visitID", "internal" );
+ reset( $fields );
+ while( list( $key, $field ) = each( $fields ) )
+ {
+ if( $field == 'action' )
+ {
+ $sep = '?';
+ }
+ else
+ {
+ $sep = '&';
+ }
+
+ global $$field;
+ if( $$field != '' )
+ $vals .= "<input type='hidden' name='".$field."' value='".$$field."'>\n";
+ }
+ return $vals;
+}
+
+function makeURL( $var, $val )
+{
+ $fields = array( "action", "day", "order", "num", "more", "ignoreDIRECT", "visitID", "internal" );
+ reset( $fields );
+ while( list( $key, $field ) = each( $fields ) )
+ {
+ if( $field == 'action' )
+ {
+ $sep = '?';
+ }
+ else
+ {
+ $sep = '&';
+ }
+ if( $field != $var )
+ {
+ global $$field;
+ if( $$field != '' )
+ $url .= $sep.$field."=".$$field;
+ }
+ else
+ {
+ $url .= $sep.$var."=".$val;
+ }
+ }
+ return $url;
+}
+
+if( $action == '' )
+{
+ $action = 'listday';
+ $day = date( 'j' );
+}
+
+print '<div class="wrap">';
+
+if( $action == 'Delete' )
+{
+ if( is_array( $del ) )
+ {
+ reset( $del );
+ while( list( $key, $val ) = each( $del ) )
+ {
+ $query = "DELETE FROM referer_visitLog
+ WHERE visitID = '".$val."'
+ AND blogID = '".$wpblog."'";
+ $result = $wpdb->query($query);
+ }
+ }
+ $action = "listday";
+}
+elseif( $action == 'deletedirect' )
+{
+ $query = "DELETE FROM referer_visitLog
+ WHERE dayofmonth='".$day."'
+ AND referingURL = 'DIRECT'
+ AND blogID = '".$wpblog."'";
+ $result = $wpdb->query($query);
+ printf ("Records deleted: %d\n", $wpdb->rows_affected);
+ $action = "listday";
+}
+elseif( $action == 'Add To Blacklist' )
+{
+ if( is_array( $del ) )
+ {
+ reset( $del );
+ while( list( $key, $val ) = each( $del ) )
+ {
+ $query = "SELECT referingURL
+ FROM referer_visitLog
+ WHERE visitID = '".$val."'
+ AND blogID = '".$wpblog."'";
+ $result=$wpdb->get_var( $query );
+ if( $result )
+ {
+ $query = "INSERT INTO referer_blacklist VALUES( NULL, '".$wpblog."', '".$result."', NOW() )";
+ $result = $wpdb->query($query);
+ }
+ }
+ }
+ $action = "listday";
+}
+elseif( $action == 'deleteblacklist' )
+{
+ if( is_array( $del ) )
+ {
+ reset( $del );
+ while( list( $key, $val ) = each( $del ) )
+ {
+ $query = "DELETE FROM referer_blacklist WHERE ID='".$val."' AND blogID = '".$wpblog."'";
+ $result = $wpdb->query($query);
+ }
+ }
+ $action = "blacklist";
+}
+
+switch( $action )
+{
+ case "blacklist":
+ $query = "SELECT * FROM referer_blacklist
+ WHERE blogID = '".$wpblog."'";
+ $result = $wpdb->get_results($query, ARRAY_A );
+ if( $result )
+ {
+ print "<div class='wrap'><h2>Referer Blacklist</h2>";
+ print "<form action='referers.php' method='post'>";
+ print "<input type='hidden' name='action' value='deleteblacklist'>";
+ print "<input type='submit' value='Delete'>";
+ print "<table>";
+ $c = 1;
+ while( list( $key, $row1 ) = each( $result ) )
+ {
+ if( substr( $row1[ 'URL' ], 0, 16 ) == 'http://www.google' )
+ {
+ $displayurl = "Google: ". substr( $row1[ 'URL' ], strpos( $row1[ 'URL' ], "search" )+6 );
+ }
+ elseif( strstr( $row1[ 'URL' ], 'search.yahoo' ) )
+ {
+ $displayurl = "Yahoo: ". substr( $row1[ 'URL' ], strpos( $row1[ 'URL' ], "p=" )+2 );
+ }
+ elseif( strpos( $row1[ 'URL' ], 'www.blueyonder.co.uk' ) )
+ {
+ $displayurl = "Blueyonder: ". substr( $row1[ 'URL' ], strpos( $row1[ 'URL' ], "q=" )+2 );
+ }
+ else
+ {
+ $displayurl = $row1[ 'URL' ];
+ }
+ print "<tr><td>$c</td><td><a href='".$row1[ 'URL' ]."'>".$displayurl."</a></td><td><input type='checkbox' name='del[]' value='".$row1['ID']."'></td></tr>\n";
+ $c++;
+ }
+ print "</table>";
+ print "</form>";
+ print "</div>";
+ }
+ else
+ {
+ print "No URLs in blacklist yet!";
+ }
+ break;
+ case "listday":
+
+ $query = "select visitTimes,referingURL,date_format( visitTime, '%k:%i' ) as visitTime2, visitURL, visitID from referer_visitLog where dayofmonth='".$day."'";
+ if( $wpblog != 'root' )
+ $query .= " and blogID='".$wpblog."'";
+
+ if( $internal == 'yes' )
+ $query .= " and referingURL NOT LIKE '".get_settings( "siteurl" )."%'";
+
+ if( $ignoreDIRECT == 'yes' )
+ $query .= " and referingURL != 'DIRECT'";
+
+ if( $order == '' || $order == 'time' )
+ {
+ $query .= " order by visitTime desc";
+ }
+ elseif( $order == 'hits' )
+ {
+ $query .= " order by visitTimes desc";
+ }
+ elseif( $order == 'url' )
+ {
+ $query .= " order by visitURL desc";
+ }
+ if( $num == '' )
+ {
+ $num = 0;
+ }
+ if( $more == '' || $more == '0' )
+ $more = '30';
+
+ $query .= " limit $num,$more";
+
+ $result = $wpdb->get_results($query, ARRAY_A );
+ $rows = $wpdb->num_rows;
+ if( $result )
+ {
+ // javascript from http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_10105441.html and
+ // http://members.aol.com/grassblad/html/chkAllBut.html
+ print "<script langage='javascript'>
+ <!--
+ function selectAll(cbList,bSelect) {
+ for (var i=0; i<cbList.length; i++)
+ cbList[i].selected = cbList[i].checked = bSelect
+ }
+
+ function reverseAll(cbList) {
+ for (var i=0; i<cbList.length; i++) {
+ cbList[i].checked = !(cbList[i].checked)
+ cbList[i].selected = !(cbList[i].selected)
+ }
+ }
+ //-->
+ </script>";
+ $c = $num+1;
+ $nav = "<br /><div align='center'>";
+ $nav .= "<a href='referers.php?action=month'>Month View</a> | ";
+ $nav .= "<a href='referers.php".makeURL( "num", 0 )."'>Top</a>";
+ if( $ignoreDIRECT == 'yes' )
+ {
+ $nav .= " | <a href='referers.php".makeURL( "ignoreDIRECT", 'no' )."'>Display DIRECT requests</a>";
+ }
+ else
+ {
+ $nav .= " | <a href='referers.php".makeURL( "ignoreDIRECT", 'yes' )."'>Hide DIRECT requests</a>";
+ }
+ if( $internal == 'yes' )
+ {
+ $nav .= " | <a href='referers.php".makeURL( "internal", 'no' )."'>Display internal requests</a>";
+ }
+ else
+ {
+ $nav .= " | <a href='referers.php".makeURL( "internal", 'yes' )."'>Hide internal requests</a>";
+ }
+
+ if( $num >= 10 )
+ {
+ if( $num > $more )
+ {
+ $nav .= " | <a href='referers.php".makeURL( "num", ( $num - $more ) )."'>Previous $more</a>";
+ }
+ }
+ else
+ {
+ $nav .= " | Previous";
+ }
+ if( $rows >= $more )
+ {
+ $nav .= " | <a href='referers.php".makeURL( "num", ($num + $more) )."'>Next $more</a>";
+ }
+ else
+ {
+ $nav .= " | Next";
+ }
+ $nav .= " | <a href='referers.php".makeURL( "more", ($more + 10) )."'>More Hits</a>";
+ $nav .= " | <a href='referers.php".makeURL( "more", ($more - 10) )."'>Less Hits</a>";
+ $nav .= "<br />";
+ print "<div class='wrap'><h2>Referers</h2>";
+ print $nav;
+ $today = date( 'd' );
+ if( $day > $today )
+ {
+ $month = date( 'F', mktime (0,0,0,date("m")-1,date("d"), date("Y")) );
+ }
+ else
+ {
+ $month = date( 'F' );
+ }
+ print "<form action='referers.php' name='deletedirect'>";
+ print "<input type='hidden' name='action' value='deletedirect'>";
+ print makeHiddenVals();
+ print "</form>";
+ print "<form action='referers.php' name='referers'>";
+ print makeHiddenVals();
+ //print "<input type='hidden' name='action' value='delete'>";
+ print "<table border=0 cellspacing=0 cellpadding=2>";
+ print "<caption> Referers For $day $month</caption>";
+ print "<tr><th>#</th><th>Refering URL</th>
+ <th><a href='referers.php".makeURL( "order", "hits" )."' title='order by hits'>Hits</a></th>
+ <th><a href='referers.php".makeURL( "order", "url" )."' title='order by entry page'>Entry Page</a></th>
+ <th><a href='referers.php".makeURL( "order", "time" )."' title='order by time'>Last</a></th>
+ <th>Selected</th>
+ </tr>
+ <tr><td colspan='6' align='right'><INPUT TYPE=button VALUE='Select All' ONCLICK='selectAll(this.form,true)'>
+ <INPUT class='edit' TYPE=button VALUE='Clear All' ONCLICK='selectAll(this.form,false)'>
+ <INPUT class='edit' TYPE=button VALUE='Reverse' ONCLICK='reverseAll(this.form)'>
+ &nbsp;|&nbsp;<input class='edit' type='submit' name='action' value='Delete' onclick='javascript:document.referers.submit()'>
+ &nbsp;|&nbsp;<input class='edit' type='submit' name='action' value='Add To Blacklist'>
+ &nbsp;|&nbsp;<input class='edit' type='button' name='action' value='Delete Direct Referers' onclick='javascript:document.deletedirect.submit()'></td></tr>\n";
+ while( list( $key, $row1 ) = each( $result ) )
+ {
+ if( $col == 'f5f5f5' )
+ {
+ $col = 'ffffff';
+ }
+ else
+ {
+ $col = 'f5f5f5';
+ }
+ if( $row1[ 'referingURL' ] != 'DIRECT' )
+ {
+ if( substr( $row1[ 'referingURL' ], 0, 17 ) == 'http://www.google' )
+ {
+ $args = parse_url( $row1[ 'referingURL' ] );
+ parse_str( $args[ 'query' ] );
+ $url = "<a href='".$row1[ 'referingURL' ]."' title='".$row1[ 'referingURL' ]."'>Google: ".stripslashes( htmlspecialchars( $q ) )."</a>";
+ }
+ elseif( strstr( $row1[ 'referingURL' ], 'search.yahoo' ) )
+ {
+ $args = parse_url( $row1[ 'referingURL' ] );
+ parse_str( $args[ 'query' ] );
+ $url = "<a href='".$row1[ 'referingURL' ]."' title='".$row1[ 'referingURL' ]."'>Yahoo: ".stripslashes( htmlspecialchars( $p ) )."</a>";
+ }
+ elseif( strpos( $row1[ 'referingURL' ], 'www.blueyonder.co.uk' ) )
+ {
+ $args = parse_url( $row1[ 'referingURL' ] );
+ parse_str( $args[ 'query' ] );
+ $url = "<a href='".$row1[ 'referingURL' ]."' title='".$row1[ 'referingURL' ]."'>Blueyonder: ".stripslashes( htmlspecialchars( $q ) )."</a>";
+ }
+ else
+ {
+ $url = "<a href='".$row1[ 'referingURL' ]."' title='".$row1[ 'referingURL' ]."'>".substr( $row1[ 'referingURL' ], 0, 40 )."</a>";
+ }
+ }
+ else
+ {
+ $url = 'DIRECT';
+ }
+ $visitID = $row1[ 'visitID' ];
+ print "<tr bgcolor='#$col'>
+ <td>".$c."</td>
+ <td>".$url."</td>
+ <td>".substr($row1[ 'visitTimes' ],0, 40 )."</td>
+ <td><a href='".$row1[ 'visitURL' ]."'>".substr($row1[ 'visitURL' ],0, 40 )."</a></td>
+ <td>".$row1[ 'visitTime2' ]."</td>
+ <td align='right'><input type=checkbox name='del[]' value='".$visitID."'></td>
+ </tr>";
+ $c++;
+
+ }
+ print "</table>";
+ print $nav;
+ print "</form>";
+ print "</div>";
+ }
+ break;
+ default:
+ $query = "select sum( visitTimes ) as c, dayofmonth from referer_visitLog ";
+ if( $wpblog != 'root' )
+ $query .= "where blogID='".$wpblog."' ";
+ $query .= "group by referer_visitLog.dayofmonth";
+ $result = $wpdb->get_results($query, ARRAY_A );
+ if( $result )
+ {
+ $c = 0;
+ $col = 'ccc';
+ print "<div class='wrap'><h2>Referers</h2>";
+ print "<table><td valign='top'>";
+ print "<table border=1 cellspacing=0 cellpadding=2>";
+ print "<tr><th>Day</th><th>Hits</th>";
+ while( list( $key, $row1 ) = each( $result ) )
+ {
+ if( $col == 'f5f5f5' )
+ {
+ $col = 'ffffff';
+ }
+ else
+ {
+ $col = 'f5f5f5';
+ }
+ print "<tr bgcolor='#";
+ if( $row1[ 'dayofmonth' ] == date( 'j' ) )
+ {
+ print "ffdddd";
+ }
+ else
+ {
+ print $col;
+ }
+ print "'><td><a href='referers.php?action=listday&day=".$row1[ 'dayofmonth' ]."'>".$row1[ 'dayofmonth']."</a></td><td>".$row1[ 'c']."</td></tr>";
+ $c++;
+ if( $c == '15' )
+ {
+ print "</table>";
+ print "</td><td valign='top'>";
+ print "<table border=1 cellspacing=0 cellpadding=2>";
+ print "<tr><th>Day</th><th>Hits</th>";
+ }
+
+ }
+ print "</table>";
+ print "</td></table>";
+ print "<br><a href='referers.php?action=blacklist'>View Blacklist</a>";
+ print "</div>";
+ }
+ else
+ {
+ print "There are no referers for your site! Wait until Google indexes you!";
+ }
+}
+print "</div>";
+include("admin-footer.php");
+?>
diff --git a/wp-inst/wp-admin/setup-config.php b/wp-inst/wp-admin/setup-config.php
new file mode 100644
index 0000000..da753c1
--- /dev/null
+++ b/wp-inst/wp-admin/setup-config.php
@@ -0,0 +1,156 @@
+<?php
+define('WP_INSTALLING', true);
+
+if (file_exists('../wp-config.php'))
+ die("The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.");
+
+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' );
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>WordPress &rsaquo; Setup Configuration File</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style media="screen" type="text/css">
+ <!--
+ body {
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 15%;
+ margin-right: 15%;
+ }
+ #logo {
+ margin: 0;
+ padding: 0;
+ background-image: url(http://wordpress.org/images/logo.png);
+ background-repeat: no-repeat;
+ height: 60px;
+ border-bottom: 4px solid #333;
+ }
+ #logo a {
+ display: block;
+ height: 60px;
+ }
+ #logo a span {
+ display: none;
+ }
+ p, li {
+ line-height: 140%;
+ }
+ -->
+ </style>
+</head>
+<body>
+<h1 id="logo"><a href="http://wordpress.org"><span>WordPress</span></a></h1>
+<?php
+
+switch($step) {
+ case 0:
+?>
+<p>Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
+<ol>
+ <li>Database name</li>
+ <li>Database username</li>
+ <li>Database password</li>
+ <li>Database host</li>
+ <li>Table prefix (if you want to run more than one WordPress in a single database) </li>
+</ol>
+<p><strong>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 <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p>
+<p>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&#8217;re all ready, <a href="setup-config.php?step=1">let&#8217;s go</a>! </p>
+<?php
+ break;
+
+ case 1:
+ ?>
+</p>
+<form method="post" action="setup-config.php?step=2">
+ <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
+ <table>
+ <tr>
+ <th scope="row">Database Name</th>
+ <td><input name="dbname" type="text" size="45" value="wordpress" /></td>
+ <td>The name of the database you want to run WP in. </td>
+ </tr>
+ <tr>
+ <th scope="row">User Name</th>
+ <td><input name="uname" type="text" size="45" value="username" /></td>
+ <td>Your MySQL username</td>
+ </tr>
+ <tr>
+ <th scope="row">Password</th>
+ <td><input name="pwd" type="text" size="45" value="password" /></td>
+ <td>...and MySQL password.</td>
+ </tr>
+ <tr>
+ <th scope="row">Database Host</th>
+ <td><input name="dbhost" type="text" size="45" value="localhost" /></td>
+ <td>99% chance you won't need to change this value.</td>
+ </tr>
+ <tr>
+ <th scope="row">Table Prefix</th>
+ <td><input name="prefix" type="text" id="prefix" value="wp_" size="45" /></td>
+ <td>If you want to run multiple WordPress installations in a single database, change this.</td>
+ </tr>
+ </table>
+ <input name="submit" type="submit" value="Submit" />
+</form>
+<?php
+ break;
+
+ case 2:
+ $dbname = $_POST['dbname'];
+ $uname = $_POST['uname'];
+ $passwrd = $_POST['pwd'];
+ $dbhost = $_POST['dbhost'];
+ $prefix = $_POST['prefix'];
+ if (empty($prefix)) $prefix = 'wp_';
+
+ // Test the db connection.
+ define('DB_NAME', $dbname);
+ define('DB_USER', $uname);
+ define('DB_PASSWORD', $passwrd);
+ define('DB_HOST', $dbhost);
+
+ // We'll fail here if the values are no good.
+ require_once('../wp-includes/wp-db.php');
+ $handle = fopen('../wp-config.php', 'w');
+
+ foreach ($configFile as $line_num => $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);
+?>
+<p>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 <a href="install.php">run the install!</a></p>
+<?php
+ break;
+
+}
+?>
+</body>
+</html>
diff --git a/wp-inst/wp-admin/sidebar.php b/wp-inst/wp-admin/sidebar.php
new file mode 100644
index 0000000..fa75f32
--- /dev/null
+++ b/wp-inst/wp-admin/sidebar.php
@@ -0,0 +1,81 @@
+<?php
+$mode = 'sidebar';
+
+require_once('admin.php');
+
+get_currentuserinfo();
+
+if ($user_level == 0)
+ die ("Cheatin' uh ?");
+
+if ('b' == $_GET['a']) {
+
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>WordPress &#8250; Posted</title>
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=UTF-8" />
+<link rel="stylesheet" href="wp-admin.css" type="text/css" />
+</head>
+<body>
+ <p>Posted !</p>
+ <p><a href="sidebar.php">Click here</a> to post again.</p>
+</body>
+</html><?php
+
+} else {
+
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>WordPress &#8250; Sidebar</title>
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('blog_charset'); ?>" />
+<link rel="stylesheet" href="wp-admin.css" type="text/css" />
+<style type="text/css" media="screen">
+form {
+ padding: 3px;
+}
+.sidebar-categories {
+ display: block;
+ height: 6.6em;
+ overflow: auto;
+ background-color: #f4f4f4;
+}
+.sidebar-categories label {
+ font-size: 10px;
+ display: block;
+ width: 90%;
+}
+</style>
+</head>
+<body id="sidebar">
+<h1 id="wphead"><a href="http://wordpress.org" rel="external">WordPress</a></h1>
+<form name="post" action="post.php" method="POST">
+<div><input type="hidden" name="action" value="post" />
+<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="mode" value="sidebar" />
+<p>Title:
+<input type="text" name="post_title" size="20" tabindex="1" style="width: 100%;" />
+</p>
+<p>Categories:
+<span class="sidebar-categories">
+<?php dropdown_categories(); ?>
+</span>
+</p>
+<p>
+Post:
+<textarea rows="8" cols="12" style="width: 100%" name="content" tabindex="2"></textarea>
+</p>
+<p>
+ <input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="Save as Draft" />
+ <input name="publish" type="submit" id="publish" tabindex="6" style="font-weight: bold;" value="Publish" />
+
+</p>
+</div>
+</form>
+
+</body>
+</html>
+<?php
+}
+?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/template-chooser.php b/wp-inst/wp-admin/template-chooser.php
new file mode 100644
index 0000000..a2e6819
--- /dev/null
+++ b/wp-inst/wp-admin/template-chooser.php
@@ -0,0 +1,202 @@
+<?php
+
+/* $Id: template-chooser.php,v 1.6 2005/02/24 13:46:48 donncha Exp $ */
+
+
+$title = "Choose a Template";
+$parent_file = 'edit.php';
+require_once('admin.php');
+
+$b2varstoreset = array('action','standalone','redirect','profile','error','warning','a','file', 'template', 'date' );
+for ($i=0; $i<count($b2varstoreset); $i += 1) {
+ $b2var = $b2varstoreset[$i];
+ if (!isset($$b2var)) {
+ if (empty($HTTP_POST_VARS["$b2var"])) {
+ if (empty($HTTP_GET_VARS["$b2var"])) {
+ $$b2var = '';
+ } else {
+ $$b2var = $HTTP_GET_VARS["$b2var"];
+ }
+ } else {
+ $$b2var = $HTTP_POST_VARS["$b2var"];
+ }
+ }
+}
+require_once("admin-header.php");
+print '<div class="wrap"> ';
+switch( $action )
+{
+ case "activate":
+ if ($dir = @opendir("../wp-content/sitetemplates/$template/templates/")) {
+ while ($file = readdir($dir))
+ {
+ if( $file != '.' && $file != '..' )
+ {
+ copy( "../wp-content/sitetemplates/$template/templates/$file", "../wp-content/blogs/$wpblog/templates/$file" );
+ }
+ }
+ closedir($dir);
+ // modify css file.
+ $cssfile = '';
+ $fp = fopen( "../wp-content/blogs/$wpblog/templates/wp-layout.css", "r" );
+ while (!feof ($fp))
+ {
+ $cssfile .= fgets($fp, 4096);
+ }
+ fclose ($fp);
+ $cssfile = str_replace( "BASE/", "BASE", $cssfile );
+ $cssfile = str_replace( "BASE", $base, $cssfile );
+ $fp = fopen( "../wp-content/blogs/".$wpblog."/templates/wp-layout.css", "w" );
+ fwrite( $fp, $cssfile );
+ fclose( $fp );
+ }
+ $wpsmarty->cache_dir = "../" . $wpsmarty->cache_dir;
+ $wpsmarty->clear_all_cache();
+ print "<div class='updated'>Theme $file activated.</div><br>";
+ break;
+ case "backup":
+ $today = date( "YmdHis" );
+ if ($dir = @opendir("../wp-content/blogs/".$wpblog."/templates/"))
+ {
+ while ($file = readdir($dir))
+ {
+ if( substr( $file, 0 , 6 ) != 'backup' && $file != '.' && $file != '..' )
+ {
+ $backupFiles[] = $file;
+ }
+ if( substr( $file, 0 , 6 ) == 'backup' )
+ {
+ $numBackups[ substr( $file, 0 , 21 ) ] = true;
+ }
+ }
+ closedir( $dir );
+
+ if( is_array( $backupFiles ) )
+ {
+ if( count( $numBackups ) < 5 )
+ {
+ while( list( $key, $val ) = each( $backupFiles ) )
+ {
+ copy( "../wp-content/blogs/".$wpblog."/templates/".$val, "../wp-content/blogs/".$wpblog."/templates/backup$today-$val" );
+ }
+ print "<div class='updated'>Created Backup: $today</div><br>";
+ }
+ else
+ {
+ print "<div class='updated'>Maximum number of backups already made. You must delete one backup to save another.</div><br>";
+ }
+ }
+ }
+ break;
+ case "delete":
+ if ($dir = @opendir("../wp-content/blogs/$wpblog/templates/"))
+ {
+ $deletedFiles = false;
+ while ($file = readdir($dir))
+ {
+ if( substr( $file, 0 , 20 ) == 'backup'.$date )
+ {
+ $deletedFiles = true;
+ unlink( "../wp-content/blogs/$wpblog/templates/$file" );
+ }
+ }
+ if( $deletedFiles )
+ {
+ print "<div class='updated'>Deleted backup: $date</div><br>";
+ }
+ }
+ break;
+ case "restore":
+ if ($dir = @opendir("../wp-content/blogs/$wpblog/templates/"))
+ {
+ while ($file = readdir($dir))
+ {
+ if( substr( $file, 0 , 20 ) == 'backup'.$date )
+ {
+ $restoreFiles[] = $file;
+ }
+ }
+ closedir( $dir );
+
+ if( is_array( $restoreFiles ) )
+ {
+ while( list( $key, $val ) = each( $restoreFiles ) )
+ {
+ copy( "../wp-content/blogs/$wpblog/templates/$val", "../wp-content/blogs/$wpblog/templates/" . substr( $val, 21 ) );
+ }
+ print "<div class='updated'>Restored backup: $date </div><br>";
+ }
+ }
+ break;
+ case "view":
+ if( is_file( "../wp-content/blogs/$wpblog/templates/backup".$date."-index.html" ) )
+ {
+ print "index.html backup from $date<br>";
+ print "<form><textarea style='font-size: 10px' rows=20 cols=80 readonly>";
+ readfile( "../wp-content/blogs/$wpblog/templates/backup".$date."-index.html" );
+ print "</textarea></form>";
+ }
+ break;
+ default:
+ break;
+}
+print "<script LANGUAGE='JavaScript'>
+<!--
+function confirmSubmit(msg)
+{
+ return confirm('Are you sure you want to '+msg);
+}
+// -->
+</script>";
+$siteurl = get_settings( 'siteurl' );
+$examplesdir = "../wp-content/sitetemplates";
+if ($dir = @opendir( $examplesdir ))
+{
+ $c = "col0";
+ $main = "<table class='templatelist'>\n";
+ $msg = "use this template?";
+ while ($file = readdir($dir))
+ {
+ if( $file != '.' && $file != '..' && $file != '.htaccess' && is_dir( "../wp-content/sitetemplates/".$file ) )
+ {
+ if( file_exists( "../wp-content/sitetemplates/" . $file . "/index.php" ) )
+ {
+ include( "../wp-content/sitetemplates/".$file . "/index.php" );
+ $main.= "<tr><td><a href='".$base."wp-inst/wp-content/sitetemplates/".$file."/screenshot.gif'><img style='border: 1px dashed #000' border=0 src='".$base."wp-inst/wp-content/sitetemplates/". $file ."/screenshot-sm.gif'></a></td><td>";
+ $main .= "$title - $when<br>";
+ $main .= "<a href='$url'>$author</a><br>";
+ $main .= $description;
+ $main .= "<br /><a onclick=\"return confirmSubmit('$msg')\" href='template-chooser.php?action=activate&template=$file'>Use This Theme</a>";
+ $main .= "</td></tr>\n";
+ }
+ }
+ }
+ $main .= "</table>";
+ closedir($dir);
+ print $main;
+ print "<p style='padding: 5px'><b>Warning!</b> By clicking on <em style='color: #00f'>Use This Theme</em> you will overwrite your current template. Backup your existing template if you want to use it in the future!</p>";
+}
+print "<a href='template-chooser.php?action=backup'>Backup</a> existing template? You can make a total of 5 backups.<br>";
+if ($dir = @opendir("../wp-content/blogs/$wpblog/templates/"))
+{
+ while ($file = readdir($dir))
+ {
+ if( substr( $file, 0 , 6 ) == 'backup' )
+ {
+ $backups[ substr( $file, 6, 14 ) ] = "backup";
+ }
+ }
+ if( is_array( $backups ) )
+ {
+ print "Backups:<br>\n";
+ print "<table>";
+ while( list( $key, $val ) = each( $backups ) )
+ {
+ print "<tr><td><b>$key</b>: </td><td><a onclick=\"return confirmSubmit('restore this backup?')\" href='template-chooser.php?action=restore&date=$key'>Restore</a></td><td><a onclick=\"return confirmSubmit('delete this backup?')\" href='template-chooser.php?action=delete&date=$key'>Delete</a></td><td><a href='template-chooser.php?action=view&date=$key'>View index.html</a></td></tr>\n";
+ }
+ print "</table>";
+ }
+}
+print "</div>";
+include("admin-footer.php");
+?>
diff --git a/wp-inst/wp-admin/templates.php b/wp-inst/wp-admin/templates.php
new file mode 100644
index 0000000..f32209c
--- /dev/null
+++ b/wp-inst/wp-admin/templates.php
@@ -0,0 +1,187 @@
+<?php
+
+/* $Id: templates.php,v 1.8 2005/03/12 20:18:49 donncha Exp $ */
+
+require_once('admin.php');
+$title = __("Template &amp; file editing");
+$parent_file = 'edit.php';
+
+
+if( isset( $_POST[ 'file' ] ) )
+ $file = $_POST[ 'file' ];
+
+if( isset( $_GET[ 'file' ] ) )
+ $file = $_GET[ 'file' ];
+
+if ($file=="")
+{
+ $file = "index.html";
+}
+
+$file = str_replace( '..', '', $file );
+
+if (substr($file,0,1) == "/")
+ $file = ".".$file;
+
+$file = stripslashes($file);
+if (':' == substr($file,1,1))
+ die ('Sorry, can&#8217;t call files with their real path.');
+
+if( $wpblog != '' )
+{
+ $templateDir = "../wp-content/blogs/".$wpblog."/templates/";
+ $filename = $templateDir . "$file";
+}
+else
+{
+ $templateDir = "../templates/";
+ $filename = "templates/$file";
+}
+if( $backup != '' && $backup >= 0 && $backup <= 5 && is_file( $filename . "." . $backup ) )
+{
+ $filename .= "." . $backup;
+}
+
+switch($_POST[ 'action' ]) {
+
+case 'update':
+
+ if ($user_level < 5) {
+ die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>'));
+ }
+
+ $newcontent = stripslashes($_POST['newcontent']);
+ $f = fopen( $filename, "r" );
+ $content = fread( $f, filesize( $filename ) );
+ fclose( $f );
+ if( $content != $newcontent )
+ {
+ for( $t = 4; $t >= 1; $t -- )
+ {
+ if( is_file( $filename . "." . $t ) )
+ {
+ rename( $filename . "." . $t, $filename . "." . ( $t + 1 ) );
+ }
+ }
+ rename( $filename, $filename . ".1" );
+
+ $f = fopen( $filename, "w+" );
+ fwrite($f,$newcontent);
+ fclose($f);
+
+ $wpsmarty->cache_dir = "../" . $wpsmarty->cache_dir;
+ $wpsmarty->clear_all_cache();
+
+ header( "Location: templates.php?file=$file&a=te" );
+ }
+ else
+ {
+ header( "Location: templates.php?file=$file" );
+ }
+
+ exit();
+
+break;
+
+default:
+
+ require_once('admin-header.php');
+
+ if ($user_level <= 3) {
+ die('<p>You have no right to edit the template for this blog.<br>Ask for a promotion to your <a href="mailto:$admin_email">blog admin</a>. :)</p>');
+ }
+
+ if (!is_file($filename))
+ $error = 1;
+
+ if (!$error) {
+ $f = fopen($filename, 'r');
+ $content = fread($f, filesize($filename));
+ $content = htmlspecialchars($content);
+ }
+
+ ?>
+ <div class="wrap">
+ <?php
+ echo "<h2>Editing <strong>$file</strong></h2>";
+ if( $backup != '' )
+ echo ", backup <strong>$backup</strong>";
+ echo " $warning";
+ if ('te' == $a)
+ echo "<em>File edited successfully.</em>";
+
+ if (!$error) {
+ ?>
+ <form name="template" action="templates.php" method="post">
+ <textarea cols="80" rows="20" style="width:100%; font-family: 'Courier New', Courier, monopace; font-size:small;" name="newcontent" tabindex="1"><?php echo $content ?></textarea>
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="file" value="<?php echo $file ?>" />
+ <br />
+ <?php
+ if (is_writeable($filename)) {
+ echo "<input type=\"submit\" name=\"submit\" class=\"search\" value=\"update template !\" tabindex=\"2\" />";
+ } else {
+ echo "<input type=\"button\" name=\"oops\" class=\"search\" value=\"(you cannot update that file/template: must make it writable, e.g. CHMOD 666)\" tabindex=\"2\" />";
+ }
+ ?>
+ </form>
+ <?php
+ } else {
+ echo '<p>Oops, no such file exists! Double check the name and try again, merci.</p>';
+ }
+ ?>
+</div>
+<div class="wrap">
+ <p>To edit a file, type its name here:</p>
+ <form name="file" action="templates.php" method="get">
+ <input type="text" name="file" />
+ <input type="submit" name="submit" class="search" value="go" />
+ </form>
+ <p>Note: of course, you can also edit the files/templates in your text editor of choice and upload them. This online editor is only meant to be used when you don't have access to a text editor or FTP client.</p>
+ <b>You can also edit the following files.</b><br />
+ <br />
+ <?php
+ $templates = array (
+ "Main Page" => "index.html",
+ "Site Style Sheet" => "wp-layout.css",
+ "Posts" => "post.html",
+ "Comments" => "comments.html",
+ "Old Template" => "index.tpl",
+ "Old Style Sheet" => "site.css"
+ );
+ print "<table>";
+ print "<tr><th>File</th><th colspan='5'>Backups</th><th>Notes</th></tr>";
+ $notes = false;
+ reset( $templates );
+ foreach( $templates as $templateName => $templateFilename )
+ {
+ print "<tr><td><a href='templates.php?file=$templateFilename'><nobr>$templateName</nobr></a></td>";
+ for( $t = 1; $t <= 5 ; $t ++ )
+ {
+ if( is_file( $templateDir . $templateFilename . "." . $t ) )
+ {
+ print "<td><a href='templates.php?file=".$templateFilename."&backup=".$t."'>".$t."</a></td>";
+ }
+ else
+ {
+ print "<td>" . $t . "</td>";
+ }
+ }
+ if( $notes == false )
+ {
+ print "<td rowspan=10 valign='top' style='padding:10px'>";
+ $notes = true;
+ print "When you edit a file a backup is made of the old file.<br> Up to 5 backups are made before the oldest is lost. It's a FIFO queue so the newest backup is always <em>1</em> and the oldest being <em>5</em>. <br />
+ If the backup of a particular file exists it will be hyperlinked and clicking on that link will allow you to edit that file. Updating that backup template will restore the backup when saved and overwrite the template.<br />
+ (*) You probably don't want to edit the XML files unless you're absolutely sure you know what you're doing!<br />";
+ print "</td>";
+ }
+ print "</tr>\n";
+ }
+ print "</table> </div> ";
+
+break;
+}
+
+include("admin-footer.php");
+?>
diff --git a/wp-inst/wp-admin/theme-editor.php b/wp-inst/wp-admin/theme-editor.php
new file mode 100644
index 0000000..3ebf035
--- /dev/null
+++ b/wp-inst/wp-admin/theme-editor.php
@@ -0,0 +1,157 @@
+<?php
+require_once('admin.php');
+
+$title = __("Edit Themes");
+$parent_file = 'themes.php';
+
+$wpvarstoreset = array('action','redirect','profile','error','warning','a','file', 'theme');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+$themes = get_themes();
+
+if (empty($theme)) {
+ $theme = get_current_theme();
+} else {
+ $theme = stripslashes($theme);
+ }
+
+
+if ( ! isset($themes[$theme]) )
+ die(__('The requested theme does not exist.'));
+
+$allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);
+
+if (empty($file)) {
+ $file = $allowed_files[0];
+}
+
+$file = validate_file_to_edit($file, $allowed_files);
+$real_file = get_real_file_to_edit($file);
+
+switch($action) {
+
+case 'update':
+
+ if ($user_level < 5) {
+ die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>'));
+ }
+
+ $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 ($user_level <= 5) {
+ die(__('<p>You have do not have sufficient permissions to edit themes for this blog.</p>'));
+ }
+
+ 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);
+ }
+
+ ?>
+<?php if (isset($_GET['a'])) : ?>
+ <div class="updated"><p><?php _e('File edited successfully.') ?></p></div>
+<?php endif; ?>
+ <div class="wrap">
+ <form name="theme" action="theme-editor.php" method="post">
+ <?php _e('Select theme to edit:') ?>
+ <select name="theme" id="theme">
+ <?php
+ foreach ($themes as $a_theme) {
+ $theme_name = $a_theme['Name'];
+ if ($theme_name == $theme) $selected = " selected='selected'";
+ else $selected = '';
+ $theme_name = wp_specialchars($theme_name, true);
+ echo "\n\t<option value=\"$theme_name\" $selected>$theme_name</option>";
+ }
+?>
+ </select>
+ <input type="submit" name="Submit" value="<?php _e('Select') ?> &raquo;" />
+ </form>
+ </div>
+
+ <div class="wrap">
+ <?php
+ if (is_writeable($real_file)) {
+ echo '<h2>' . sprintf(__('Editing <code>%s</code>'), $file) . '</h2>';
+ } else {
+ echo '<h2>' . sprintf(__('Browsing <code>%s</code>'), $file) . '</h2>';
+ }
+ ?>
+ <div id="templateside">
+ <h3><?php printf(__("<strong>'%s'</strong> theme files"), $theme) ?></h3>
+
+<?php
+if ($allowed_files) :
+?>
+ <ul>
+<?php foreach($allowed_files as $allowed_file) : ?>
+ <li><a href="theme-editor.php?file=<?php echo "$allowed_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>"><?php echo get_file_description($allowed_file); ?></a></li>
+<?php endforeach; ?>
+ </ul>
+<?php endif; ?>
+</div>
+ <?php
+ if (!$error) {
+ ?>
+ <form name="template" id="template" action="theme-editor.php" method="post">
+ <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="file" value="<?php echo $file ?>" />
+ <input type="hidden" name="theme" value="<?php echo $theme ?>" />
+ </div>
+<?php if ( is_writeable($real_file) ) : ?>
+ <p class="submit">
+<?php
+ echo "<input type='submit' name='submit' value=' " . __('Update File') . " &raquo;' tabindex='2' />";
+?>
+</p>
+<?php else : ?>
+<p><em><?php _e('If this file was writable you could edit it.'); ?></em></p>
+<?php endif; ?>
+ </form>
+ <?php
+ } else {
+ echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
+ }
+ ?>
+</div>
+<?php
+break;
+}
+
+include("admin-footer.php") ?>
diff --git a/wp-inst/wp-admin/themes.php b/wp-inst/wp-admin/themes.php
new file mode 100644
index 0000000..7aed945
--- /dev/null
+++ b/wp-inst/wp-admin/themes.php
@@ -0,0 +1,172 @@
+<?php
+require_once('admin.php');
+
+if ( isset($_GET['action']) ) {
+ check_admin_referer();
+
+ if ('activate' == $_GET['action']) {
+ if (isset($_GET['template'])) {
+ update_option('template', $_GET['template']);
+ }
+
+ if (isset($_GET['stylesheet'])) {
+ update_option('stylesheet', $_GET['stylesheet']);
+ }
+
+ do_action('switch_theme', get_current_theme());
+
+ header('Location: themes.php?activated=true');
+ }
+ }
+
+$title = __('Manage Themes');
+$parent_file = 'themes.php';
+require_once('admin-header.php');
+?>
+<?php if ( ! validate_current_theme() ) : ?>
+<div class="updated"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
+<?php elseif ( isset($activated) ) : ?>
+<div class="updated"><p><?php _e('New theme activated'); ?></p></div>
+<?php endif; ?>
+
+<?php
+$themes = get_themes();
+$allowed_themes = get_site_settings( "allowed_themes" );
+if( $allowed_themes == false ) {
+ $allowed_themes = $themes;
+}
+
+$current_theme = get_current_theme();
+
+if( isset( $allowed_themes[ $current_theme ] ) == false ) {
+ $allowed_themes[ $current_theme ] = true;
+}
+
+$current_title = $themes[$current_theme]['Title'];
+$current_version = $themes[$current_theme]['Version'];
+$current_parent_theme = $themes[$current_theme]['Parent Theme'];
+$current_template_dir = $themes[$current_theme]['Template Dir'];
+$current_stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
+$current_template = $themes[$current_theme]['Template'];
+$current_stylesheet = $themes[$current_theme]['Stylesheet'];
+
+reset( $themes );
+while( list( $key, $val ) = each( $themes ) ) {
+ if( isset( $allowed_themes[ $key ] ) == false ) {
+ unset( $themes[ $key ] );
+ }
+}
+reset( $themes );
+?>
+
+<div class="wrap">
+<h2><?php _e('Current Theme'); ?></h2>
+<div id="currenttheme">
+<h3><?php printf(__('%1$s %2$s by %3$s'), $current_title, $current_version, $themes[$current_theme]['Author']) ; ?></h3>
+<p><?php echo $themes[$current_theme]['Description']; ?></p>
+<?php if ($current_parent_theme) { ?>
+ <p><?php printf(__('The active theme is <strong>%1$s</strong>. The template files are located in <code>%2$s</code>. The stylesheet files are located in <code>%3$s</code>. <strong>%4$s</strong> uses templates from <strong>%5$s</strong>. Changes made to the templates will affect both themes.'), $current_theme, $current_template_dir, $current_stylesheet_dir, $current_theme, $current_parent_theme); ?></p>
+<?php } else { ?>
+ <p><?php printf(__('The active theme is <strong>%1$s</strong>. The template files are located in <code>%2$s</code>. The stylesheet files are located in <code>%3$s</code>.'), $current_theme, $current_template_dir, $current_stylesheet_dir); ?></p>
+<?php } ?>
+</div>
+
+<h2><?php _e('Themes Available'); ?></h2>
+<?php if ( 1 < count($themes) ) { ?>
+<table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+ <th><?php _e('Name'); ?></th>
+ <th><?php _e('Author'); ?></th>
+ <th><?php _e('Description'); ?></th>
+ <th></th>
+ </tr>
+<?php
+ $style = '';
+
+ $theme_names = array_keys($themes);
+ natcasesort($theme_names);
+
+ foreach ($theme_names as $theme_name) {
+ $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'];
+
+ if ($template == $current_template && $stylesheet == $current_stylesheet) {
+ $action = '<strong>' . __('Active Theme') . '</strong>';
+ $current = true;
+ } else {
+ $action = "<a href='themes.php?action=activate&amp;template=$template&amp;stylesheet=$stylesheet' title='" . __('Select this theme') . "' class='edit'>" . __('Select') . '</a>';
+ $current = false;
+ }
+
+ $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
+ if ($current) $style .= $style == 'alternate' ? ' active' : 'active';
+ if ($style != '') $style = 'class="' . $style . '"';
+
+ echo "
+ <tr $style>";
+if ( $current )
+ echo "<td><strong>$title $version</strong></td>";
+else
+ echo "<td>$title $version</td>";
+echo "
+ <td class=\"auth\">$author</td>
+ <td class=\"desc\">$description</td>
+ <td class=\"togl\">$action</td>
+ </tr>";
+ }
+?>
+
+</table>
+<?php
+}
+?>
+
+<?php
+// List broken themes, if any.
+$broken_themes = get_broken_themes();
+if (count($broken_themes)) {
+?>
+
+<h2><?php _e('Broken Themes'); ?></h2>
+<p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p>
+
+<table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+ <th><?php _e('Name'); ?></th>
+ <th><?php _e('Description'); ?></th>
+ </tr>
+<?php
+ $theme = '';
+
+ $theme_names = array_keys($broken_themes);
+ natcasesort($theme_names);
+
+ foreach ($theme_names as $theme_name) {
+ $title = $broken_themes[$theme_name]['Title'];
+ $description = $broken_themes[$theme_name]['Description'];
+
+ $theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
+ echo "
+ <tr $theme>
+ <td>$title</td>
+ <td>$description</td>
+ </tr>";
+ }
+?>
+</table>
+<?php
+}
+?>
+
+<h2><?php _e('Get More Themes'); ?></h2>
+<p><?php _e('You can find additional themes for your site in the <a href="http://wordpress.org/extend/themes/">WordPress theme directory</a>. To install a theme you generally just need to upload the theme folder into your <code>wp-content/themes</code> directory. Once a theme is uploaded, you may activate it here.'); ?></p>
+
+</div>
+
+<?php
+include('admin-footer.php');
+?>
diff --git a/wp-inst/wp-admin/toggle.png b/wp-inst/wp-admin/toggle.png
new file mode 100644
index 0000000..e8e6cae
--- /dev/null
+++ b/wp-inst/wp-admin/toggle.png
Binary files differ
diff --git a/wp-inst/wp-admin/update-links.php b/wp-inst/wp-admin/update-links.php
new file mode 100644
index 0000000..a02474e
--- /dev/null
+++ b/wp-inst/wp-admin/update-links.php
@@ -0,0 +1,44 @@
+<?php
+require_once( dirname( dirname(__FILE__) ) . '/wp-config.php');
+require_once( ABSPATH . 'wp-includes/class-snoopy.php');
+
+if ( !get_option('use_linksupdate') )
+ die('Feature disabled.');
+
+$link_uris = $wpdb->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;
+}
+?> \ No newline at end of file
diff --git a/wp-inst/wp-admin/upgrade-functions.php b/wp-inst/wp-admin/upgrade-functions.php
new file mode 100644
index 0000000..cc39422
--- /dev/null
+++ b/wp-inst/wp-admin/upgrade-functions.php
@@ -0,0 +1,753 @@
+<?php
+
+require_once(ABSPATH . '/wp-admin/admin-functions.php');
+require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
+// Functions to be called in install and upgrade scripts
+function upgrade_all() {
+ populate_options();
+ upgrade_100();
+ upgrade_101();
+ upgrade_110();
+ upgrade_130();
+ upgrade_160();
+ save_mod_rewrite_rules();
+}
+
+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.
+ // FIXME: user_nickname is no longer in the user table. Need to update and
+ // move this code to where the new usermeta table is setup.
+// $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'
+ // <michel_v> 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, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
+ $wpdb->query("UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'");
+
+ // 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;
+ $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;
+ 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();
+}
+
+// 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<br />");
+ 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'");
+
+ @ $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 "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
+
+ // 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)]}<br>";
+ 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 "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br/>Found index:".$index_string."</pre>\n";
+ }
+ //else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br/><b>Did not find index:</b>".$index_string."<br/>".print_r($indices, true)."</pre>\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 "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
+ $wpdb->query($query);
+ }
+ }
+
+ return $for_update;
+}
+
+function make_db_current() {
+ global $wp_queries;
+
+ $alterations = dbDelta($wp_queries);
+ echo "<ol>\n";
+ foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
+ echo "</ol>\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("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
+
+ // Update comments template inclusion.
+ $line = str_replace("<?php include(ABSPATH . 'wp-comments.php'); ?>", "<?php comments_template(); ?>", $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() {
+ return true;
+ // 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;
+}
+?>
diff --git a/wp-inst/wp-admin/upgrade-schema.php b/wp-inst/wp-admin/upgrade-schema.php
new file mode 100644
index 0000000..261a350
--- /dev/null
+++ b/wp-inst/wp-admin/upgrade-schema.php
@@ -0,0 +1,295 @@
+<?php
+// Here we keep the DB structure and option values
+
+$wp_queries="CREATE TABLE $wpdb->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',
+ 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 '<li>',
+ text_after_link varchar(128) NOT NULL default '<br />',
+ text_after_all varchar(128) NOT NULL default '</li>',
+ 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 int(11) 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') 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',
+ 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_level int(2) unsigned NOT NULL default '0',
+ 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),
+ UNIQUE KEY user_login (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)
+);
+CREATE TABLE $wpdb->blogs (
+ blog_id bigint(20) NOT NULL auto_increment,
+ site_id bigint(20) NOT NULL default '0',
+ blogname varchar(50) NOT NULL default '',
+ registered datetime NOT NULL default '0000-00-00 00:00:00',
+ last_updated datetime NOT NULL default '0000-00-00 00:00:00',
+ is_public enum('yes','no') NOT NULL default 'yes',
+ PRIMARY KEY (blog_id),
+ KEY site_id (site_id),
+ KEY blogname (blogname)
+);
+CREATE TABLE $wpdb->site (
+ id bigint(20) NOT NULL auto_increment,
+ domain varchar(255) NOT NULL default '',
+ path varchar(255) NOT NULL default '',
+ PRIMARY KEY (id),
+ KEY domain (domain),
+ KEY path (path)
+);
+CREATE TABLE $wpdb->sitemeta (
+ meta_id bigint(20) NOT NULL auto_increment,
+ site_id bigint(20) NOT NULL default '0',
+ meta_key varchar(255) default NULL,
+ meta_value longtext,
+ PRIMARY KEY (meta_id),
+ KEY meta_key (meta_key),
+ KEY site_id (site_id)
+);
+CREATE TABLE `referer_blacklist` (
+ `ID` int(11) NOT NULL auto_increment,
+ `blogID` varchar(32) NOT NULL default '',
+ `URL` varchar(250) NOT NULL default '',
+ `t` timestamp(14) NOT NULL,
+ PRIMARY KEY (`ID`),
+ KEY `blogID` (`blogID`,`URL`),
+ KEY `URL` (`URL`)
+);
+CREATE TABLE `referer_visitLog` (
+`blogID` char( 32 ) default NULL ,
+`visitID` int( 11 ) NOT NULL AUTO_INCREMENT ,
+`visitTime` timestamp( 14 ) NOT NULL ,
+`visitURL` char( 250 ) default NULL ,
+`referingURL` char( 250 ) default NULL ,
+`baseDomain` char( 250 ) default NULL ,
+`refpost` int( 11 ) NOT NULL default '0',
+`visitTimes` int( 10 ) NOT NULL default '0',
+`dayofmonth` smallint( 2 ) NOT NULL default '0',
+PRIMARY KEY ( `visitID` ) ,
+KEY `blogID` ( `blogID` ) ,
+KEY `refpost` ( `refpost` ) ,
+KEY `dayofmonth` ( `dayofmonth` )
+);
+CREATE TABLE `wp_linkclicks` (
+ `blogID` varchar(11) default NULL,
+ `link_id` int(11) NOT NULL auto_increment,
+ `link_url` text NOT NULL,
+ `link_clicks` int(11) NOT NULL default '0',
+ `link_date` datetime NOT NULL default '0000-00-00 00:00:00',
+ `link_title` text NOT NULL,
+ UNIQUE KEY `link_id` (`link_id`),
+ KEY `blogID` (`blogID`)
+);
+";
+
+function populate_options() {
+ global $wpdb, $wpblog;
+
+ $guessurl = preg_replace('|/wp-admin/.*|i', '', 'http://' . $_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', 1);
+ 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('use_fileupload', 1);
+ add_option('fileupload_realpath', ABSPATH . 'wp-content/blogs.dir/'.$wpdb->blogid.'/files');
+ add_option('fileupload_url', get_option('siteurl') . '/files');
+ add_option('fileupload_allowedtypes', 'jpg jpeg gif png');
+ add_option('fileupload_maxk', 300);
+ add_option('fileupload_minlevel', 6);
+ 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', 9);
+ 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', '<em>');
+ add_option('links_recently_updated_append', '</em>');
+ add_option('links_recently_updated_time', 120);
+ add_option('comment_moderation', 1);
+ add_option('moderation_notify', 0);
+ add_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
+ 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');
+ add_option('category_base');
+ add_option('ping_sites', 'http://rpc.pingomatic.com/');
+ add_option('advanced_edit', 0);
+ add_option('comment_max_links', 2);
+ // 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);
+
+ // 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');
+ 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;
+}
+
+?>
diff --git a/wp-inst/wp-admin/upgrade.php b/wp-inst/wp-admin/upgrade.php
new file mode 100644
index 0000000..c4a176c
--- /dev/null
+++ b/wp-inst/wp-admin/upgrade.php
@@ -0,0 +1,95 @@
+<?php
+define('WP_INSTALLING', true);
+if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. Double check that you updated wp-config-sample.php with the proper database connection information and renamed it to wp-config.php.");
+require('../wp-config.php');
+timer_start();
+require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
+
+$step = $_GET['step'];
+if (!$step) $step = 0;
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>WordPress &rsaquo; Upgrade</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <style media="screen" type="text/css">
+ <!--
+ html {
+ background: #eee;
+ }
+ body {
+ background: #fff;
+ color: #000;
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 20%;
+ margin-right: 20%;
+ padding: .2em 2em;
+ }
+
+ h1 {
+ color: #006;
+ font-size: 18px;
+ font-weight: lighter;
+ }
+
+ h2 {
+ font-size: 16px;
+ }
+
+ p, li, dt {
+ line-height: 140%;
+ padding-bottom: 2px;
+ }
+
+ ul, ol {
+ padding: 5px 5px 5px 20px;
+ }
+ #logo {
+ margin-bottom: 2em;
+ }
+.step a, .step input {
+ font-size: 2em;
+}
+.step, th {
+ text-align: right;
+}
+#footer {
+text-align: center; border-top: 1px solid #ccc; padding-top: 1em; font-style: italic;
+}
+ -->
+ </style>
+</head>
+<body>
+<h1 id="logo"><img alt="WordPress" src="http://static.wordpress.org/logo.png" /></h1>
+<?php
+switch($step) {
+
+ case 0:
+?>
+<p><?php _e('This file upgrades you from any previous version of WordPress to the latest. It may take a while though, so be patient.'); ?></p>
+ <h2 class="step"><a href="upgrade.php?step=1"><?php _e('Upgrade WordPress &raquo;'); ?></a></h2>
+<?php
+ break;
+
+ case 1:
+ make_db_current_silent();
+ upgrade_all();
+?>
+<h2><?php _e('Step 1'); ?></h2>
+ <p><?php printf(__("There's actually only one step. So if you see this, you're done. <a href='%s'>Have fun</a>!"), __get_option('home')); ?></p>
+
+<!--
+<pre>
+<?php printf(__('%s queries'), $wpdb->num_queries); ?>
+
+<?php printf(__('%s seconds'), timer_stop(0)); ?>
+</pre>
+-->
+
+<?php
+ break;
+}
+?>
+</body>
+</html>
diff --git a/wp-inst/wp-admin/upload.php b/wp-inst/wp-admin/upload.php
new file mode 100644
index 0000000..61c8f21
--- /dev/null
+++ b/wp-inst/wp-admin/upload.php
@@ -0,0 +1,235 @@
+<?php
+require_once('admin.php');
+
+$title = 'Upload Image or File';
+
+require_once('admin-header.php');
+
+if ($user_level == 0) //Checks to see if user has logged in
+ die (__("Cheatin' uh ?"));
+
+if (!get_settings('use_fileupload')) //Checks if file upload is enabled in the config
+ die (__("The admin disabled this function"));
+
+if ( !get_settings('fileupload_minlevel') )
+ die (__("You are not allowed to upload files"));
+
+$allowed_types = explode(' ', "jpg jpeg png gif");
+
+if ($_POST['submit']) {
+ $action = 'upload';
+} else {
+ $action = '';
+}
+
+if (!is_writable(get_settings('fileupload_realpath')))
+ $action = 'not-writable';
+$action = apply_filters('fileupload_init',$action);
+?>
+
+<div class="wrap">
+
+<?php
+switch ($action) {
+case 'not-writable':
+?>
+<p><?php printf(__("It doesn't look like you can use the file upload feature at this time because the directory you have specified (<code>%s</code>) doesn't appear to be writable by WordPress. Check the permissions on the directory and for typos."), get_settings('fileupload_realpath')) ?></p>
+
+<?php
+break;
+case '':
+ foreach ($allowed_types as $type) {
+ $type_tags[] = "<code>$type</code>";
+ }
+ $i = implode(', ', $type_tags);
+?>
+<p><?php printf(__('You can upload files with the extension %1$s as long as they are no larger than %2$s <abbr title="Kilobytes">KB</abbr>. If you&#8217;re an admin you can configure these values under <a href="%3$s">options</a>.'), $i, get_settings('fileupload_maxk'), 'options-misc.php') ?></p>
+ <form action="upload.php" method="post" enctype="multipart/form-data">
+ <p>
+ <label for="img1"><?php _e('File:') ?></label>
+ <br />
+ <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo get_settings('fileupload_maxk') * 1024 ?>" />
+ <input type="file" name="img1" id="img1" size="35" class="uploadform" /></p>
+ <p>
+ <label for="imgdesc"><?php _e('Description:') ?></label><br />
+ <input type="text" name="imgdesc" id="imgdesc" size="30" class="uploadform" />
+ </p>
+
+ <p><?php _e('Create a thumbnail?') ?></p>
+ <p>
+ <label for="thumbsize_no">
+ <input type="radio" name="thumbsize" value="none" checked="checked" id="thumbsize_no" />
+ <?php _e('No thanks') ?></label>
+ <br />
+ <label for="thumbsize_small">
+<input type="radio" name="thumbsize" value="small" id="thumbsize_small" />
+<?php _e('Small (200px largest side)') ?></label>
+ <br />
+ <label for="thumbsize_large">
+<input type="radio" name="thumbsize" value="large" id="thumbsize_large" />
+<?php _e('Large (400px largest side)') ?></label>
+ <br />
+ <label for="thumbsize_custom">
+ <input type="radio" name="thumbsize" value="custom" id="thumbsize_custom" />
+<?php _e('Custom size') ?></label>
+ :
+ <input type="text" name="imgthumbsizecustom" size="4" />
+ <?php _e('px (largest side)') ?> </p>
+ <p><input type="submit" name="submit" value="<?php _e('Upload File') ?>" /></p>
+ </form>
+</div><?php
+break;
+case 'upload':
+
+ $imgalt = basename( (isset($_POST['imgalt'])) ? $_POST['imgalt'] : '' );
+
+ $img1_name = (strlen($imgalt)) ? $imgalt : basename( $_FILES['img1']['name'] );
+ $img1_name = preg_replace('/[^a-z0-9_.]/i', '', $img1_name);
+ $img1_size = $_POST['img1_size'] ? intval($_POST['img1_size']) : intval($_FILES['img1']['size']);
+
+ $img1_type = (strlen($imgalt)) ? $_POST['img1_type'] : $_FILES['img1']['type'];
+ $imgdesc = htmlentities2($_POST['imgdesc']);
+
+ $pi = pathinfo($img1_name);
+ $imgtype = strtolower($pi['extension']);
+
+ if (in_array($imgtype, $allowed_types) == false)
+ die(sprintf(__('File %1$s of type %2$s is not allowed.') , $img1_name, $imgtype));
+
+ if (strlen($imgalt)) {
+ $pathtofile = get_settings('fileupload_realpath')."/".$imgalt;
+ $img1 = $_POST['img1'];
+ } else {
+ $pathtofile = get_settings('fileupload_realpath')."/".$img1_name;
+ $img1 = $_FILES['img1']['tmp_name'];
+ }
+ // do_action rather than apply_filters - becuase there's nothing we can change at this point
+ do_action('fileupload_pre',array('filename'=>$pathtofile, 'filesize'=>$img1_size, 'fullpath'=>$pathtofile));
+
+ // makes sure not to upload duplicates, rename duplicates
+ $i = 1;
+ $pathtofile2 = $pathtofile;
+ $tmppathtofile = $pathtofile2;
+ $img2_name = $img1_name;
+
+ while ( file_exists($pathtofile2) ) {
+ $pos = strpos( strtolower($tmppathtofile), '.' . trim($imgtype) );
+ $pathtofile_start = substr($tmppathtofile, 0, $pos);
+ $pathtofile2 = $pathtofile_start.'_'.zeroise($i++, 2).'.'.trim($imgtype);
+ $img2_name = explode('/', $pathtofile2);
+ $img2_name = $img2_name[count($img2_name)-1];
+ }
+
+ if (file_exists($pathtofile) && !strlen($imgalt)) {
+ $i = explode(' ', get_settings('fileupload_allowedtypes'));
+ $i = implode(', ',array_slice($i, 1, count($i)-2));
+ $moved = move_uploaded_file($img1, $pathtofile2);
+ // if move_uploaded_file() fails, try copy()
+ if (!$moved) {
+ $moved = copy($img1, $pathtofile2);
+ }
+ if (!$moved) {
+ die(sprintf(__("Couldn't upload your file to %s."), $pathtofile2));
+ } else {
+ chmod($pathtofile2, 0666);
+ @unlink($img1);
+ }
+
+ //
+
+ // duplicate-renaming function contributed by Gary Lawrence Murphy
+ ?>
+ <p><strong><?php __('Duplicate File?') ?></strong></p>
+ <p><b><em><?php printf(__("The filename '%s' already exists!"), $img1_name); ?></em></b></p>
+ <p> <?php printf(__("Filename '%1\$s' moved to '%2\$s'"), $img1, "$pathtofile2 - $img2_name") ?></p>
+ <p><?php _e('Confirm or rename:') ?></p>
+ <form action="upload.php" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo get_settings('fileupload_maxk') *1024 ?>" />
+ <input type="hidden" name="img1_type" value="<?php echo $img1_type;?>" />
+ <input type="hidden" name="img1_name" value="<?php echo $img2_name;?>" />
+ <input type="hidden" name="img1_size" value="<?php echo $img1_size;?>" />
+ <input type="hidden" name="img1" value="<?php echo $pathtofile2;?>" />
+ <input type="hidden" name="thumbsize" value="<?php echo $_REQUEST['thumbsize'];?>" />
+ <input type="hidden" name="imgthumbsizecustom" value="<?php echo $_REQUEST['imgthumbsizecustom'];?>" />
+ <?php _e('Alternate name:') ?><br /><input type="text" name="imgalt" size="30" class="uploadform" value="<?php echo $img2_name;?>" /><br />
+ <br />
+ <?php _e('Description:') ?><br /><input type="text" name="imgdesc" size="30" class="uploadform" value="<?php echo $imgdesc;?>" />
+ <br />
+ <input type="submit" name="submit" value="<?php _e('Rename') ?>" class="search" />
+ </form>
+</div>
+<?php
+
+require('admin-footer.php');
+die();
+
+ }
+
+ if (!strlen($imgalt)) {
+ @$moved = move_uploaded_file($img1, $pathtofile); //Path to your images directory, chmod the dir to 777
+ // move_uploaded_file() can fail if open_basedir in PHP.INI doesn't
+ // include your tmp directory. Try copy instead?
+ if(!$moved) {
+ $moved = copy($img1, $pathtofile);
+ }
+ // Still couldn't get it. Give up.
+ if (!$moved) {
+ die(sprintf(__("Couldn't upload your file to %s."), $pathtofile));
+ } else {
+ chmod($pathtofile, 0666);
+ @unlink($img1);
+ }
+
+ } else {
+ rename($img1, $pathtofile)
+ or die(sprintf(__("Couldn't upload your file to %s."), $pathtofile));
+ }
+
+ if($_POST['thumbsize'] != 'none' ) {
+ if($_POST['thumbsize'] == 'small') {
+ $max_side = 200;
+ }
+ elseif($_POST['thumbsize'] == 'large') {
+ $max_side = 400;
+ }
+ elseif($_POST['thumbsize'] == 'custom') {
+ $max_side = intval($_POST['imgthumbsizecustom']);
+ }
+
+ $result = wp_create_thumbnail($pathtofile, $max_side, NULL);
+ if($result != 1) {
+ print $result;
+ }
+ }
+
+// Defined as a filter - because we might want to change the name
+$img1_name = apply_filters('fileupload_post',$img1_name);
+if ( ereg('image/',$img1_type) )
+ $piece_of_code = "<img src='" . get_settings('fileupload_url') ."/$img1_name' alt='$imgdesc' />";
+else
+ $piece_of_code = "<a href='". get_settings('fileupload_url') . "/$img1_name' title='$imgdesc'>$imgdesc</a>";
+
+$piece_of_code = htmlspecialchars( $piece_of_code );
+?>
+
+<h3><?php _e('File uploaded!') ?></h3>
+<p><?php printf(__("Your file <code>%s</code> was uploaded successfully!"), $img1_name); ?></p>
+<p><?php _e('Here&#8217;s the code to display it:') ?></p>
+<p><code><?php echo $piece_of_code; ?></code>
+</p>
+<p><strong><?php _e('Image Details') ?></strong>: <br />
+Name:
+<?php echo $img1_name; ?>
+<br />
+<?php _e('Size:') ?>
+<?php echo round($img1_size / 1024, 2); ?> <?php _e('<abbr title="Kilobyte">KB</abbr>') ?><br />
+<?php _e('Type:') ?>
+<?php echo $img1_type; ?>
+</p>
+</div>
+<p><a href="upload.php"><?php _e('Upload another') ?></a></p>
+<?php
+break;
+}
+include('admin-footer.php');
+?>
diff --git a/wp-inst/wp-admin/user-edit.php b/wp-inst/wp-admin/user-edit.php
new file mode 100644
index 0000000..adac5a0
--- /dev/null
+++ b/wp-inst/wp-admin/user-edit.php
@@ -0,0 +1,216 @@
+<?php
+require_once('admin.php');
+
+$title = __('Edit User');
+$parent_file = 'profile.php';
+$submenu_file = 'users.php';
+
+$wpvarstoreset = array('action', 'redirect', 'profile', 'user_id');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+ $wpvar = $wpvarstoreset[$i];
+ if (!isset($$wpvar)) {
+ if (empty($_POST["$wpvar"])) {
+ if (empty($_GET["$wpvar"])) {
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ }
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ }
+ }
+}
+
+switch ($action) {
+case 'update':
+
+get_currentuserinfo();
+$edituser = get_userdata($user_id);
+if ($edituser->user_level >= $user_level) die( __('You do not have permission to edit this user.') );
+
+/* checking the nickname has been typed */
+if (empty($_POST["new_nickname"])) {
+ die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)"));
+ return false;
+}
+
+$new_user_login = wp_specialchars($_POST['new_user_login']);
+$pass1 = $_POST['pass1'];
+$pass2 = $_POST['pass2'];
+do_action('check_passwords', array($new_user_login, &$pass1, &$pass2));
+
+if ( '' == $pass1 ) {
+ if ( '' != $pass2 )
+ die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
+ $updatepassword = '';
+} else {
+ if ( '' == $pass2)
+ die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
+ if ( $pass1 != $pass2 )
+ die (__("<strong>ERROR</strong>: you typed two different passwords. Go back to correct that."));
+ $new_pass = $pass1;
+ $updatepassword = "user_pass=MD5('$new_pass'), ";
+}
+
+$new_firstname = wp_specialchars($_POST['new_firstname']);
+$new_lastname = wp_specialchars($_POST['new_lastname']);
+$new_nickname = $_POST['new_nickname'];
+$new_nicename = sanitize_title($new_nickname, $user_id);
+$new_icq = wp_specialchars($_POST['new_icq']);
+$new_aim = wp_specialchars($_POST['new_aim']);
+$new_msn = wp_specialchars($_POST['new_msn']);
+$new_yim = wp_specialchars($_POST['new_yim']);
+$new_email = wp_specialchars($_POST['new_email']);
+$new_url = wp_specialchars($_POST['new_url']);
+$new_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $new_url) ? $new_url : 'http://' . $new_url;
+$display_name = wp_specialchars($_POST['display_name']);
+$new_description = $_POST['new_description'];
+
+$result = $wpdb->query("UPDATE $wpdb->users SET user_login = '$new_user_login', $updatepassword user_email='$new_email', user_url='$new_url', user_nicename = '$new_nicename', display_name = '$display_name' WHERE ID = '$user_id'");
+
+update_usermeta( $user_id, 'first_name', $new_firstname );
+update_usermeta( $user_id, 'last_name', $new_lastname );
+update_usermeta( $user_id, 'nickname', $new_nickname );
+update_usermeta( $user_id, 'description', $new_description );
+update_usermeta( $user_id, 'icq', $new_icq );
+update_usermeta( $user_id, 'aim', $new_aim );
+update_usermeta( $user_id, 'msn', $new_msn );
+update_usermeta( $user_id, 'yim', $new_yim );
+
+header("Location: user-edit.php?user_id=$user_id&updated=true");
+
+break;
+
+case 'switchposts':
+
+check_admin_referer();
+
+/* TODO: Switch all posts from one user to another user */
+
+break;
+
+default:
+include ('admin-header.php');
+
+$edituser = get_userdata($user_id);
+
+if ($edituser->user_level >= $user_level) die( __('You do not have permission to edit this user.') );
+?>
+
+<?php if ( isset($_GET['updated']) ) : ?>
+<div class="updated">
+ <p><strong><?php _e('User updated.') ?></strong></p>
+</div>
+<?php endif; ?>
+
+<div class="wrap">
+<h2><?php _e('Edit User'); ?></h2>
+<form name="edituser" id="edituser" action="user-edit.php" method="post">
+<table width="99%" border="0" cellspacing="2" cellpadding="3">
+ <tr>
+ <th width="33%" scope="row"><?php _e('Username:') ?></th>
+ <td width="73%"><input type="text" name="new_user_login" id="new_user_login" value="<?php echo $edituser->user_login; ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Level:') ?></th>
+ <td><?php echo $edituser->user_level; ?></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Posts:') ?></th>
+ <td><?php echo get_usernumposts($edituser->ID); ?></td>
+ </tr>
+<?php if ( '0000-00-00 00:00:00' != $edituser->user_registered ) { ?>
+ <tr>
+ <th scope="row"><?php _e('Registered on:') ?></th>
+ <td><?php echo substr($edituser->user_registered, 0, 11); ?></td>
+ </tr>
+<?php } ?>
+ <tr>
+ <th scope="row"><?php _e('First name:') ?></th>
+ <td><input type="text" name="new_firstname" id="new_firstname" value="<?php echo $edituser->first_name ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Last name:') ?></th>
+ <td><input type="text" name="new_lastname" id="new_lastname2" value="<?php echo $edituser->last_name ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Profile:') ?></th>
+ <td><textarea name="new_description" rows="5" id="new_description" style="width: 99%; "><?php echo $edituser->user_description ?></textarea></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Nickname:') ?></th>
+ <td><input type="text" name="new_nickname" id="new_nickname" value="<?php echo $edituser->nickname ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('E-mail:') ?></th>
+ <td><input type="text" name="new_email" id="new_email" value="<?php echo $edituser->user_email ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Website:') ?></th>
+ <td><input type="text" name="new_url" id="new_url" value="<?php echo $edituser->user_url ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('ICQ:') ?></th>
+ <td><input type="text" name="new_icq" id="new_icq" value="<?php if ($edituser->icq > 0) { echo $edituser->icq; } ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('AIM:') ?></th>
+ <td><input type="text" name="new_aim" id="new_aim" value="<?php echo $edituser->aim ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('MSN IM:') ?>
+ </th>
+ <td><input type="text" name="new_msn" id="new_msn" value="<?php echo $edituser->msn ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Yahoo IM:') ?>
+ </th>
+ <td><input type="text" name="new_yim" id="new_yim" value="<?php echo $edituser->yim ?>" />
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Identity on blog:') ?>
+ </th>
+ <td> <select name="display_name">
+ <option value="<?php echo $edituser->display_name; ?>"><?php echo $edituser->display_name; ?></option>
+ <option value="<?php echo $edituser->nickname ?>"><?php echo $edituser->nickname ?></option>
+ <option value="<?php echo $edituser->user_login ?>"><?php echo $edituser->user_login ?></option>
+ <?php if ( !empty( $edituser->first_name ) ) : ?>
+ <option value="<?php echo $edituser->first_name ?>"><?php echo $edituser->first_name ?></option>
+ <?php endif; ?>
+ <?php if ( !empty( $edituser->last_name ) ) : ?>
+ <option value="<?php echo $edituser->last_name ?>"><?php echo $edituser->last_name ?></option>
+ <?php endif; ?>
+ <?php if ( !empty( $edituser->first_name ) && !empty( $edituser->last_name ) ) : ?>
+ <option value="<?php echo $edituser->first_name." ".$edituser->last_name ?>"><?php echo $edituser->first_name." ".$edituser->last_name ?></option>
+ <option value="<?php echo $edituser->last_name." ".$edituser->first_name ?>"><?php echo $edituser->last_name." ".$edituser->first_name ?></option>
+ <?php endif; ?>
+ </select>
+ </td>
+ </tr>
+<?php
+$show_password_fields = apply_filters('show_password_fields', true);
+if ( $show_password_fields ) :
+?>
+ <tr>
+ <th scope="row"><?php _e('New <strong>Password</strong> (Leave blank to stay the same.)') ?></th>
+ <td><input type="password" name="pass1" size="16" value="" />
+ <br />
+ <input type="password" name="pass2" size="16" value="" /></td>
+ </tr>
+<?php endif; ?>
+</table>
+ <p class="submit">
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
+ <input type="submit" value="<?php _e('Update User &raquo;') ?>" name="submit" />
+ </p>
+</form>
+</div>
+
+<?php
+break;
+}
+
+include('admin-footer.php');
+?>
diff --git a/wp-inst/wp-admin/users.php b/wp-inst/wp-admin/users.php
new file mode 100644
index 0000000..296c6a8
--- /dev/null
+++ b/wp-inst/wp-admin/users.php
@@ -0,0 +1,290 @@
+<?php
+require_once('admin.php');
+require_once( ABSPATH . WPINC . '/registration-functions.php');
+
+$title = __('Users');
+$parent_file = 'profile.php';
+
+$action = $_REQUEST['action'];
+
+switch ($action) {
+case 'adduser':
+ check_admin_referer();
+
+ $user_login = wp_specialchars(trim($_POST['user_login']));
+ $pass1 = $_POST['pass1'];
+ $pass2 = $_POST['pass2'];
+ $user_email = wp_specialchars(trim($_POST['email']));
+ $user_firstname = wp_specialchars(trim($_POST['firstname']));
+ $user_lastname = wp_specialchars(trim($_POST['lastname']));
+ $user_uri = wp_specialchars(trim($_POST['uri']));
+
+ /* checking that username has been typed */
+ if ($user_login == '')
+ die (__('<strong>ERROR</strong>: Please enter a username.'));
+
+ /* checking the password has been typed twice */
+ do_action('check_passwords', array($user_login, &$pass1, &$pass2));
+ if ($pass1 == '' || $pass2 == '')
+ die (__('<strong>ERROR</strong>: Please enter your password twice.'));
+
+ /* checking the password has been typed twice the same */
+ if ($pass1 != $pass2)
+ die (__('<strong>ERROR</strong>: Please type the same password in the two password fields.'));
+
+ $user_nickname = $user_login;
+
+ if ( username_exists( $user_login ) )
+ die (__('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
+
+ /* checking e-mail address */
+ if (empty($user_email)) {
+ die (__("<strong>ERROR</strong>: please type an e-mail address"));
+ return false;
+ } else if (!is_email($user_email)) {
+ die (__("<strong>ERROR</strong>: the email address isn't correct"));
+ return false;
+ }
+
+ $user_ID = create_user( $user_login, $pass1, $user_email, 0 );
+
+ update_usermeta( $user_ID, 'first_name', $user_firstname);
+ update_usermeta( $user_ID, 'last_name', $user_lastname);
+ update_usermeta( $user_ID, 'first_name', $user_firstname);
+
+ $stars = '';
+ for ($i = 0; $i < strlen($pass1); $i = $i + 1)
+ $stars .= '*';
+
+ $user_login = stripslashes($user_login);
+ $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
+ $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
+ $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
+
+ @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
+ header('Location: users.php');
+break;
+
+case 'promote':
+ check_admin_referer();
+
+ if (empty($_GET['prom'])) {
+ header('Location: users.php');
+ }
+
+ $id = (int) $_GET['id'];
+ $prom = $_GET['prom'];
+
+ $user_data = get_userdata($id);
+
+ $usertopromote_level = $user_data->user_level;
+
+ if ( $user_level <= $usertopromote_level )
+ die(__('Can&#8217;t change the level of a user whose level is higher than yours.'));
+
+ if ('up' == $prom) {
+ $new_level = $usertopromote_level + 1;
+ } elseif ('down' == $prom) {
+ $new_level = $usertopromote_level - 1;
+ }
+ update_usermeta( $id, $wpdb->prefix . 'user_level', $new_level);
+
+ header('Location: users.php');
+
+break;
+
+case 'delete':
+
+ check_admin_referer();
+
+ $id = (int) $_GET['id'];
+
+ if (!$id) {
+ header('Location: users.php');
+ }
+
+ $user_data = get_userdata($id);
+ $usertodelete_level = $user_data->user_level;
+
+ if ($user_level <= $usertodelete_level)
+ die(__('Can&#8217;t delete a user whose level is higher than yours.'));
+
+ wp_delete_user($id);
+
+ header('Location: users.php?deleted=true');
+
+break;
+
+default:
+
+ include ('admin-header.php');
+ ?>
+
+<?php if (isset($_GET['deleted'])) : ?>
+<div class="updated"><p><?php _e('User deleted.') ?></p></div>
+<?php endif; ?>
+<div class="wrap">
+ <h2><?php _e('Authors') ?></h2>
+ <table cellpadding="3" cellspacing="3" width="100%">
+ <tr>
+ <th><?php _e('ID') ?></th>
+ <th><?php _e('Nickname') ?></th>
+ <th><?php _e('Name') ?></th>
+ <th><?php _e('E-mail') ?></th>
+ <th><?php _e('Website') ?></th>
+ <th><?php _e('Level') ?></th>
+ <th><?php _e('Posts') ?></th>
+ <th>&nbsp;</th>
+ </tr>
+ <?php
+ $authors =
+ $users = get_author_user_ids();
+ $style = '';
+ foreach ($users as $user) {
+ $user_data = get_userdata($user);
+ $email = $user_data->user_email;
+ $url = $user_data->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' and post_status = 'publish'");
+ if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_data->ID' title='" . __('View posts') . "'>$numposts</a>";
+ echo "
+<tr $style>
+ <td align='center'>$user_data->ID</td>
+ <td><strong>$user_data->user_login</strong></td>
+ <td>$user_data->first_name $user_data->last_name</td>
+ <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
+ <td><a href='$url' title='website: $url'>$short_url</a></td>
+ <td align='center'>";
+ if (($user_level >= 2) and ($user_level > $user_data->user_level) and ($user_data->user_level > 0))
+ echo " <a href=\"users.php?action=promote&amp;id=".$user_data->ID."&amp;prom=down\">-</a> ";
+ echo $user_data->user_level;
+ if (($user_level >= 2) and ($user_level > ($user_data->user_level + 1)))
+ echo " <a href=\"users.php?action=promote&amp;id=".$user_data->ID."&amp;prom=up\">+</a> ";
+ echo "</td><td align='right'>$numposts</td>";
+ echo '<td>';
+ if (($user_level >= 2) and ($user_level > $user_data->user_level))
+ echo "<a href='user-edit.php?user_id=$user_data->ID' class='edit'>".__('Edit')."</a>";
+ echo '</td>';
+ echo '</tr>';
+ }
+
+ ?>
+
+ </table>
+</div>
+
+<?php
+$users = get_nonauthor_user_ids();
+if ($users) {
+?>
+<div class="wrap">
+ <h2><?php _e('Registered Users') ?></h2>
+ <table cellpadding="3" cellspacing="3" width="100%">
+ <tr>
+ <th><?php _e('ID') ?></th>
+ <th><?php _e('Nickname') ?></th>
+ <th><?php _e('Name') ?></th>
+ <th><?php _e('E-mail') ?></th>
+ <th><?php _e('Website') ?></th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+<?php
+$style = '';
+foreach ($users as $user) {
+ $user_data = get_userdata($user);
+ $email = $user_data->user_email;
+ $url = $user_data->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"';
+echo "\n<tr $style>
+<td align='center'>$user_data->ID</td>
+<td><strong>$user_data->user_login</strong></td>
+<td>$user_data->first_name $user_data->last_name</td>
+<td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
+<td><a href='$url' title='website: $url'>$short_url</a></td>
+<td align='center'>";
+
+ if ($user_level >= 6)
+ echo "<a href='users.php?action=promote&amp;id=$user_data->ID&amp;prom=up' class='edit'>". __('Promote') . '</a>';
+ echo "</td>\n";
+ echo '<td>';
+ if (($user_level >= 6) and ($user_level > $user_data->user_level))
+ echo "<a href='user-edit.php?user_id=$user_data->ID' class='edit'>".__('Edit')."</a>";
+ echo '</td><td>';
+ if ($user_level >= 6)
+ echo "<a href='users.php?action=delete&amp;id=$user_data->ID' class='delete' onclick='return confirm(\"" . __('You are about to delete this user \n OK to delete, Cancel to stop.') . "\")'>" . __('Delete'). '</a>';
+ echo '</td></tr>';
+
+}
+
+?>
+
+ </table>
+ <p><?php _e('Deleting a user also deletes all posts made by that user.') ?></p>
+</div>
+
+ <?php
+ } ?>
+<div class="wrap">
+<h2><?php _e('Add New User') ?></h2>
+<?php printf(__('<p>Users can <a href="%s/wp-register.php">register themselves</a> or you can manually create users here.</p>'), get_settings('siteurl')); ?>
+<form action="" method="post" name="adduser" id="adduser">
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th scope="row" width="33%"><?php _e('Nickname') ?>
+ <input name="action" type="hidden" id="action" value="adduser" /></th>
+ <td width="66%"><input name="user_login" type="text" id="user_login" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('First Name') ?> </th>
+ <td><input name="firstname" type="text" id="firstname" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Last Name') ?> </th>
+ <td><input name="lastname" type="text" id="lastname" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('E-mail') ?></th>
+ <td><input name="email" type="text" id="email" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Website') ?></th>
+ <td><input name="uri" type="text" id="uri" /></td>
+ </tr>
+<?php
+$show_password_fields = apply_filters('show_password_fields', true);
+if ( $show_password_fields ) :
+?>
+ <tr>
+ <th scope="row"><?php _e('Password (twice)') ?> </th>
+ <td><input name="pass1" type="password" id="pass1" />
+ <br />
+ <input name="pass2" type="password" id="pass2" /></td>
+ </tr>
+<?php endif; ?>
+ </table>
+ <p class="submit">
+ <input name="adduser" type="submit" id="adduser" value="<?php _e('Add User') ?> &raquo;" />
+ </p>
+ </form>
+</div>
+ <?php
+
+break;
+}
+
+include('admin-footer.php');
+?>
diff --git a/wp-inst/wp-admin/wp-admin.css b/wp-inst/wp-admin/wp-admin.css
new file mode 100644
index 0000000..d2e47c1
--- /dev/null
+++ b/wp-inst/wp-admin/wp-admin.css
@@ -0,0 +1,682 @@
+* html #poststuff {
+ height: 100%; /* kill peekaboo bug in IE */
+}
+
+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: #fff;
+ 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 {
+ background: #f0f0f0;
+ display: block;
+ font-size: 11px;
+ padding: 0 2px;
+}
+
+fieldset label.selectit:hover {
+ background: #dadada;
+}
+
+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: 2px solid #69c;
+ color: #333;
+ font: normal 22px/18px serif;
+ margin: 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;
+}
+
+.alignleft {
+ float: left
+}
+
+.alignright {
+ float: right;
+}
+
+.alternate {
+ background: #eee;
+}
+
+.anchors {
+ margin: 10px 20px 10px 20px;
+}
+
+.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;
+}
+
+.ed_button {
+ padding: 1px;
+}
+
+.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(../wp-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;
+}
+
+.unapproved {
+ color: #888;
+}
+
+.unapproved a:link {
+ color: #b9bcff;
+}
+
+.unapproved a:visited {
+ color: #696dff;
+}
+
+.unapproved a:hover {
+ color: #009ef0;
+}
+
+.updated {
+ background: #f0f8ff;
+ border: 1px solid #69c;
+ 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: 6px 0;
+}
+
+#adminmenu {
+ background: #fff;
+ border-bottom: 2px solid #707070;
+ margin: 0;
+ padding: .2em;
+}
+
+#adminmenu .current, #adminmenu2 .current {
+ font-weight: bold;
+}
+
+#adminmenu a {
+ border: 1px solid #fff;
+ color: #333;
+ font-size: 16px;
+ font-weight: normal;
+ margin: 0;
+ padding: 3px 5px;
+ text-decoration: none;
+}
+
+#adminmenu a:hover, .current {
+ background: #ccc;
+ border: 1px solid #9d9d9d;
+ color: #171717;
+}
+
+#adminmenu li, #adminmenu2 li {
+ display: inline;
+ line-height: 200%;
+ list-style: none;
+ text-align: center;
+}
+
+#adminmenu2 {
+ background: #a3a3a3;
+ border-bottom: none;
+ margin: 0;
+ padding: 3px 2em 0;
+}
+
+#adminmenu2 .current {
+ background: #f2f2f2;
+ border-top: 1px solid #9a9a9a;
+ border-right: 2px solid #4f4f4f;
+ color: #000;
+}
+
+#adminmenu2 a {
+ border: none;
+ color: #fff;
+ font-size: 12px;
+ padding: .3em .4em .33em;
+}
+
+#adminmenu2 a:hover {
+ background: #f0f0f0;
+ color: #393939;
+}
+
+#adminmenu2 li {
+ line-height: 170%;
+}
+
+
+#categorydiv input, #poststatusdiv input, #commentstatusdiv input, #pingstatusdiv input {
+ border: none;
+}
+
+#content, #titlediv input, #quicktags {
+ margin-left: 2%;
+ width: 97%;
+}
+
+#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;
+}
+
+#excerpt {
+ height: 1.8em;
+ width: 98%;
+}
+
+#footer {
+ text-align: center;
+}
+
+#login {
+ background: #fff;
+ border: 2px 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(../wp-images/wp-small.png) no-repeat;
+ margin-top: 0;
+}
+
+#login h1 a {
+ display: block;
+ text-indent: -1000px;
+}
+
+#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;
+}
+
+
+#postcustom .updatemeta, #postcustom .deletemeta {
+ margin: auto;
+ width: 5em;
+}
+
+#postcustom table {
+ border: 1px solid #ccc;
+ margin: .5em;
+ width: 98%;
+}
+
+#postcustom table input, #postcustom table textarea {
+ width: 95%;
+}
+
+#poststuff {
+ margin-right: 16em;
+}
+
+#profile {
+ margin: 10px;
+}
+
+#profile .left {
+ border-right: 1px dashed #ccc;
+ float: left;
+ margin-right: 5px;
+ padding-right: 5px;
+}
+
+#profile label {
+ float: left;
+ padding-right: 3px;
+ text-align: right;
+ width: 85px;
+}
+
+#profile p {
+ margin: 0 0 4px 0;
+}
+
+#save {
+ width: 15em;
+}
+
+#template div {
+ margin-right: 190px;
+}
+
+#template textarea {
+ font: small 'Courier New', Courier, monospace;
+ width: 99%;
+}
+
+#templateside {
+ float: right;
+ width: 170px;
+}
+
+#templateside h3, #postcustom p {
+ margin: 0;
+}
+
+#templateside ol, #templateside ul {
+ list-style: none;
+ margin: .5em;
+ padding: 0;
+}
+
+#wphead {
+ background: url(../wp-images/header-shadow.png) #f2f2f2 repeat-x bottom;
+ padding: 1px 5px 11px;
+}
+
+#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: 27%;
+}
+
+#zeitgeist h2, fieldset legend a {
+ border-bottom: none;
+}
+
+#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;
+}
+
+/* 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;
+}
+
+
+/****************************************************************
+ 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-left: 5px;
+}
+#moremeta {
+ line-height: 130%;
+ margin-right: 15px;
+ position: absolute;
+ right: 5%;
+ width: 14.5em;
+ border-left: 1px solid #dfe8f1;
+}
+
+#slugdiv input, #passworddiv input, #authordiv select {
+ margin-top: .5em;
+ width: 95%;
+}
+
+#moremeta h3, #advancedstuff h3 {
+ padding: 3px;
+ font-weight: normal;
+ font-size: 13px;
+}
+
+#advancedstuff div {
+ margin-top: .5em;
+ margin-left: 2%;
+}
+
+/* default box styles */
+.dbx-box {
+}
+
+/* box when toggle is open */
+.dbx-box-open {
+}
+
+/* box when toggle is closed */
+.dbx-box-closed {
+}
+
+/* toggle state of inner content area */
+.dbx-box-open .dbx-content {
+ display:block;
+}
+.dbx-box-closed .dbx-content {
+ display:none;
+}
+
+/* handles */
+.dbx-handle {
+ background-color: #dfe8f1;
+ margin: 0;
+ padding: 0;
+}
+
+/* handle cursors */
+.dbx-handle-cursor {
+ cursor:move;
+}
+
+/* toggle images */
+a.dbx-toggle, a.dbx-toggle:visited {
+ display:block;
+ width: 12px;
+ height: 12px;
+ overflow: hidden;
+ background-image: url( toggle.png );
+ position: absolute;
+ top: .3em;
+ right: .3em;
+ border-bottom: 0;
+ background-position: 0 0;
+}
+
+a.dbx-toggle-open, a.dbx-toggle-open:visited {
+ background-position: 0;
+}
+
+a.dbx-toggle-closed, a.dbx-toggle-closed:visited {
+ background-position: -12px 0;
+}
+
+a.dbx-toggle-hilite-open, a.dbx-toggle-hilite-open:visited {
+ background-position: 0;
+}
+
+a.dbx-toggle-hilite-closed, a.dbx-toggle-hilite-closed:visited {
+ background-position: -12px 0;
+}
+
+/* additional clone styles */
+.dbx-clone {
+ opacity: 0.8;
+ -moz-opacity: 0.8;
+ -khtml-opacity: 0.8;
+ filter: alpha(opacity=80);
+} \ No newline at end of file
diff --git a/wp-inst/wp-admin/wpmu-admin.php b/wp-inst/wp-admin/wpmu-admin.php
new file mode 100644
index 0000000..0ba4b7e
--- /dev/null
+++ b/wp-inst/wp-admin/wpmu-admin.php
@@ -0,0 +1,33 @@
+<?php
+require_once('admin.php');
+
+$title = __('WPMU Admin');
+$parent_file = 'wpmu-admin.php';
+require_once('admin-header.php');
+if( $wpblog != 'main' || $user_level < 10) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+}
+if (isset($_GET['updated'])) {
+ ?><div class="updated"><p><strong><?php _e('Options saved.') ?></strong></p></div><?php
+}
+?>
+<div class="wrap">
+<?php
+
+do_action( "wpmuadminresult", "" );
+
+switch( $_GET[ 'action' ] ) {
+ default:
+ // print some global stats.
+ $stats = get_sitestats();
+ print "<h2>Site Stats</h2>
+ There are currently ".$stats[ 'blogs' ]." <a href='wpmu-blogs.php'>blogs</a> running on this server and ".$stats[ 'users' ]." <a href='wpmu-users.php'>users</a>.</p><br /><br />
+ ";
+
+ do_action( "wpmuadmindefaultpage", "" );
+ break;
+}
+
+?>
+</div>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-inst/wp-admin/wpmu-blogs.php b/wp-inst/wp-admin/wpmu-blogs.php
new file mode 100644
index 0000000..1caa46f
--- /dev/null
+++ b/wp-inst/wp-admin/wpmu-blogs.php
@@ -0,0 +1,304 @@
+<?php
+require_once('admin.php');
+
+$title = __('WPMU Admin');
+$parent_file = 'wpmu-admin.php';
+require_once('admin-header.php');
+if( $wpblog != 'main' || $user_level < 10) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+}
+if (isset($_GET['updated'])) {
+ ?><div class="updated"><p><strong><?php _e('Options saved.') ?></strong></p></div><?php
+}
+print '<div class="wrap">';
+switch( $_GET[ 'action' ] ) {
+ case "editblog":
+ $options_table_name = $wpmuBaseTablePrefix . $_GET[ 'id' ] ."_options";
+ $query = "SELECT *
+ FROM ".$options_table_name."
+ WHERE option_name NOT LIKE 'rss%'";
+ $options = $wpdb->get_results( $query, ARRAY_A );
+ $query = "SELECT *
+ FROM ".$wpdb->blogs."
+ WHERE blog_id = '".$_GET[ 'id' ]."'";
+ $details = $wpdb->get_row( $query, ARRAY_A );
+ $is_archived = get_settings( "is_archived" );
+ if( $is_archived == '' )
+ $is_archived = 'no';
+
+ print "<h2>Edit Blog</h2>";
+ ?>
+ <form name="form1" method="post" action="wpmu-edit.php?action=updateblog">
+ <input type="hidden" name="id" value="<?php echo $_GET[ 'id' ] ?>" />
+ <table><td valign='top'>
+ <table width="100%" border='0' cellspacing="2" cellpadding="5" class="editform">
+ <tr valign="top">
+ <th scope="row">Blogname</th>
+ <td><input name="blog[blogname]" type="text" id="blog_name" value="<?php echo $details[ 'blogname' ] ?>" size="20" />.<?php echo $domain; ?></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Registered</th>
+ <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo $details[ 'registered' ] ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Last Updated</th>
+ <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo $details[ 'last_updated' ] ?>" size="40" /></td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Public</th>
+ <td><input type='radio' name='blog[is_public]' value='yes'<?php if( $details[ 'is_public' ] == 'yes' ) echo " checked"?>> Yes&nbsp;&nbsp;
+ <input type='radio' name='blog[is_public]' value='no'<?php if( $details[ 'is_public' ] == 'no' ) echo " checked"?>> No &nbsp;&nbsp;
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">Archived</th>
+ <td><input type='radio' name='option[is_archived]' value='yes'<?php if( $is_archived == 'yes' ) echo " checked"?>> Yes&nbsp;&nbsp;
+ <input type='radio' name='option[is_archived]' value='no'<?php if( $is_archived == 'no' ) echo " checked"?>> No &nbsp;&nbsp;
+ </td>
+ </tr>
+ <tr><td colspan='2'>
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
+ </p>
+ <br />
+ <br />
+ </td></tr>
+ <?php
+ while( list( $key, $val ) = each( $options ) ) {
+ ?>
+ <tr valign="top">
+ <th scope="row"><?php echo ucwords( str_replace( "_", " ", $val[ 'option_name' ] ) ) ?></th>
+ <td><input name="option[<?php echo $val[ 'option_name' ] ?>]" type="text" id="<?php echo $val[ 'option_name' ] ?>" value="<?php echo $val[ 'option_value' ] ?>" size="40" /></td>
+ </tr>
+ <?php
+ }
+ ?>
+ </table>
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
+ </p>
+ </td>
+ <td valign='top'>
+ <?php
+ $themes = get_themes();
+ $query = "SELECT option_value
+ FROM ".$options_table_name."
+ WHERE option_name = 'allowed_themes'";
+ $blog_allowed_themes = $wpdb->get_var( $query );
+ if( $blog_allowed_themes != false )
+ $blog_allowed_themes = unserialize( $blog_allowed_themes );
+ $allowed_themes = get_site_settings( "allowed_themes" );
+ if( $allowed_themes == false ) {
+ $allowed_themes = array_keys( $themes );
+ }
+ $out = '';
+ while( list( $key, $val ) = each( $themes ) ) {
+ if( isset( $allowed_themes[ $key ] ) == false ) {
+ if( isset( $blog_allowed_themes[ $key ] ) == true ) {
+ $checked = 'checked ';
+ } else {
+ $checked = '';
+ }
+
+ $out .= '
+ <tr valign="top">
+ <th title="'.$val[ "Description" ].'" scope="row">'.$key.'</th>
+ <td><input name="theme['.$key.']" type="checkbox" id="'.$key.'" value="on" '.$checked.'/></td>
+ </tr> ';
+ }
+ }
+ if( $out != '' ) {
+ print "<h3>Blog Themes</h3>";
+ print '<table width="100%" border="0" cellspacing="2" cellpadding="5" class="editform">';
+ print '<tr><th>Theme</th><th>Enable</th></tr>';
+ print $out;
+ print "</table>";
+ }
+ ?>
+ </td>
+ </table>
+ <?php
+ break;
+ default:
+ $query = "SELECT *
+ FROM ".$wpdb->blogs."
+ WHERE site_id = '".$wpdb->siteid."'";
+ if( $_GET[ 's' ] != '' ) {
+ $query = "SELECT *
+ FROM ".$wpdb->blogs.", ".$wpdb->site."
+ WHERE site_id = '".$wpdb->siteid."'
+ AND ".$wpdb->blogs.".site_id = ".$wpdb->site.".id
+ AND blogname like '%".$_GET[ 's' ]."%'";
+ }
+ $blog_list = $wpdb->get_results( $query, ARRAY_A );
+?>
+<h2>Blogs</h2>
+<form name="searchform" action="wpmu-blogs.php" method="get" style="float: left; width: 16em; margin-right: 3em;">
+ <fieldset>
+ <legend><?php _e('Search Blogs&hellip;') ?></legend>
+ <input type='hidden' name='action' value='blogs'>
+ <input type="text" name="s" value="<?php if (isset($_GET[ 's' ])) echo wp_specialchars($_GET[ 's' ], 1); ?>" size="17" />
+ <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+ </fieldset>
+</form>
+
+<br style="clear:both;" />
+
+<?php
+
+// define the columns to display, the syntax is 'internal name' => 'display name'
+$posts_columns = array(
+ 'id' => __('ID'),
+ 'blogname' => __('Blog Name'),
+ 'last_updated' => __('Last Updated'),
+ 'registered' => __('Registered')
+);
+$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
+
+// you can not edit these at the moment
+$posts_columns['control_view'] = '';
+$posts_columns['control_edit'] = '';
+$posts_columns['control_backend'] = '';
+$posts_columns['control_delete'] = '';
+
+?>
+
+<table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+
+<?php foreach($posts_columns as $column_display_name) { ?>
+ <th scope="col"><?php echo $column_display_name; ?></th>
+<?php } ?>
+
+ </tr>
+<?php
+if ($blog_list) {
+$bgcolor = '';
+foreach ($blog_list as $blog) {
+$class = ('alternate' == $class) ? '' : 'alternate';
+?>
+ <tr class='<?php echo $class; ?>'>
+
+<?php
+
+foreach($posts_columns as $column_name=>$column_display_name) {
+
+ switch($column_name) {
+
+ case 'id':
+ ?>
+ <th scope="row"><?php echo $blog[ 'blog_id' ] ?></th>
+ <?php
+ break;
+
+ case 'blogname':
+ ?>
+ <td><?php echo $blog[ 'blogname' ] ?>
+ </td>
+ <?php
+ break;
+
+ case 'last_updated':
+ ?>
+ <td><?php echo $blog[ 'last_updated' ] ?></td>
+ <?php
+ break;
+
+ case 'registered':
+ ?>
+ <td><?php echo $blog[ 'registered' ] ?></td>
+ <?php
+ break;
+
+ case 'control_view':
+ ?>
+ <td><a href="<?php echo get_blogaddress_by_name( $blog[ 'blogname' ] ); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
+ <?php
+ break;
+
+ case 'control_edit':
+ ?>
+ <td><?php echo "<a href='wpmu-blogs.php?action=editblog&amp;id=".$blog[ 'blog_id' ]."' class='edit'>" . __('Edit') . "</a>"; ?></td>
+ <?php
+ break;
+
+ case 'control_backend':
+ ?>
+ <td><?php echo "<a href='".get_blogaddress_by_name( $blog[ 'blogname' ] )."wp-admin/' class='edit'>" . __('Backend') . "</a>"; ?></td>
+ <?php
+ break;
+
+ case 'control_delete':
+ ?>
+ <td><?php echo "<a href='wpmu-edit.php?action=deleteblog&amp;id=".$blog[ 'blog_id' ]."' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this blog?\\n \'OK\' to delete, \'Cancel\' to stop.") ) . "')\">" . __('Delete') . "</a>"; ?></td>
+ <?php
+ break;
+
+ default:
+ ?>
+ <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
+ <?php
+ break;
+ }
+}
+?>
+ </tr>
+<?php
+}
+print "</table>";
+} else {
+?>
+ <tr style='background-color: <?php echo $bgcolor; ?>'>
+ <td colspan="8"><?php _e('No blogs found.') ?></td>
+ </tr>
+<?php
+} // end if ($blogs)
+
+ $themes = get_themes();
+ $allowed_themes = get_site_settings( "allowed_themes" );
+ if( $allowed_themes == false ) {
+ $allowed_themes = array_keys( $themes );
+ }
+
+ print "<br />";
+ print "<form action='wpmu-edit.php?action=updatethemes' method='POST'>";
+ print "<h3>Site Themes</h3>";
+ print '<table border="0" cellspacing="2" cellpadding="5" class="editform">';
+ print "<caption>Disable themes site-wide. You can enable themes on a blog by blog basis.</caption>";
+ print '<tr><th>Theme</th><th>Description</th><th>Disabled</th></tr>';
+ while( list( $key, $val ) = each( $themes ) ) {
+ $enabled = '';
+ $disabled = '';
+ if( isset( $allowed_themes[ $key ] ) == true ) {
+ $enabled = 'checked ';
+ } else {
+ $disabled = 'checked ';
+ }
+ ?>
+ <tr valign="top">
+ <th scope="row"><?php echo $key ?></th>
+ <td><?php echo $val[ 'Description' ] ?></td>
+ <td>
+ <input name="theme[<?php echo $key ?>]" type="radio" id="<?php echo $key ?>" value="disabled" <?php echo $disabled ?>/> Yes
+ &nbsp;&nbsp;&nbsp;
+ <input name="theme[<?php echo $key ?>]" type="radio" id="<?php echo $key ?>" value="enabled" <?php echo $enabled ?>/> No
+ </td>
+ </tr>
+ <?php
+ }
+ ?>
+ </table>
+ <input type='submit' value='Update Themes'>
+ </form>
+ <?php
+break;
+} // end switch( $action )
+?>
+
+<div class="navigation">
+<div class="alignleft"><?php //next_posts_link(__('&laquo; Previous Entries')) ?></div>
+<div class="alignright"><?php //previous_posts_link(__('Next Entries &raquo;')) ?></div>
+</div>
+
+</div>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-inst/wp-admin/wpmu-edit.php b/wp-inst/wp-admin/wpmu-edit.php
new file mode 100644
index 0000000..02beff9
--- /dev/null
+++ b/wp-inst/wp-admin/wpmu-edit.php
@@ -0,0 +1,102 @@
+<?php
+require_once('admin.php');
+
+do_action( "wpmuadminedit", "" );
+
+switch( $_GET[ 'action' ] ) {
+ case "updateblog":
+ $options_table_name = $wpmuBaseTablePrefix . $_POST[ 'id' ] ."_options";
+
+ // themes
+ if( is_array( $_POST[ 'theme' ] ) ) {
+ $allowed_themes = $_POST[ 'theme' ];
+ $_POST[ 'option' ][ 'allowed_themes' ] = $_POST[ 'theme' ];
+ }
+ if( is_array( $_POST[ 'option' ] ) ) {
+ while( list( $key, $val ) = each( $_POST[ 'option' ] ) ) {
+ if ( is_array($val) || is_object($val) )
+ $val = serialize($val);
+
+ $query = "SELECT option_id, option_value
+ FROM ".$options_table_name."
+ WHERE option_name = '".$key."'";
+ $opts = $wpdb->get_row( $query, ARRAY_A );
+ $optvalue = $opts[ 'option_value' ];
+ $option_id = $opts[ 'option_id' ];
+ if( $opts == false ) {
+ $query = "INSERT INTO ".$options_table_name." ( `option_id` , `blog_id` , `option_name` , `option_can_override` , `option_type` , `option_value` , `option_width` , `option_height` , `option_description` , `option_admin_level` , `autoload` )
+ VALUES ( NULL, '0', '".$key."', 'Y', '1', '".$val."', '20', '8', '', '1', 'yes')";
+ $wpdb->query( $query );
+ } elseif( $optvalue != $val ) {
+ $query = "UPDATE ".$options_table_name."
+ SET option_value = '".$val."'
+ WHERE option_name = '".$key."'";
+ $wpdb->query( $query );
+ }
+ }
+ }
+
+ // update blogs table
+ if( $_POST[ 'blog' ][ 'blogname' ] != 'main' ) {
+ $query = "UPDATE ".$wpdb->blogs."
+ SET blogname = '".$_POST[ 'blog' ][ 'blogname' ]."',
+ registered = '".$_POST[ 'blog' ][ 'registered' ]."',
+ last_updated = '".$_POST[ 'blog' ][ 'last_updated' ]."',
+ is_public = '".$_POST[ 'blog' ][ 'is_public' ]."'
+ WHERE blog_id = '".$_POST[ 'id' ]."'";
+ $wpdb->query( $query );
+ }
+ header( "Location: wpmu-blogs.php?action=editblog&id=".$_POST[ 'id' ]."&updated=true" );
+ break;
+ case "deleteblog":
+ $query = "UPDATE ".$wpdb->blogs."
+ SET is_public = 'archived'
+ WHERE blog_id = '".$_GET[ 'id' ]."'";
+ $wpdb->query( $query );
+ break;
+ case "updateuser":
+ unset( $_POST[ 'option' ][ 'ID' ] );
+ if( is_array( $_POST[ 'option' ] ) ) {
+ while( list( $key, $val ) = each( $_POST[ 'option' ] ) ) {
+ $query = "UPDATE ".$wpdb->users."
+ SET ".$key." = '".$val."'
+ WHERE ID = '".$_POST[ 'id' ]."'";
+ $wpdb->query( $query );
+ }
+ }
+ if( is_array( $_POST[ 'meta' ] ) ) {
+ while( list( $key, $val ) = each( $_POST[ 'meta' ] ) ) {
+ $query = "UPDATE ".$wpdb->usermeta."
+ SET meta_key = '".$_POST[ 'metaname' ][ $key ]."',
+ meta_value = '".$val."'
+ WHERE umeta_id = '".$key."'";
+ $wpdb->query( $query );
+ }
+ }
+ if( is_array( $_POST[ 'metadelete' ] ) ) {
+ while( list( $key, $val ) = each( $_POST[ 'metadelete' ] ) ) {
+ $query = "DELETE FROM ".$wpdb->usermeta."
+ WHERE umeta_id = '".$key."'";
+ $wpdb->query( $query );
+ }
+ }
+ header( "Location: wpmu-users.php?action=edit&id=".$_POST[ 'id' ]."&updated=true" );
+ break;
+ case "updatethemes":
+ if( is_array( $_POST[ 'theme' ] ) ) {
+ $themes = array_flip( array_keys( get_themes() ) );
+ reset( $themes );
+ while( list( $key, $val ) = each( $themes ) )
+ {
+ if( $_POST[ 'theme' ][ addslashes( $key ) ] == 'enabled' )
+ $allowed_themes[ $key ] = true;
+ }
+ update_site_settings( 'allowed_themes', $allowed_themes );
+ }
+ header( "Location: wpmu-blogs.php?updated=true" );
+ break;
+ default:
+ header( "Location: wpmu-admin.php" );
+ break;
+}
+?>
diff --git a/wp-inst/wp-admin/wpmu-users.php b/wp-inst/wp-admin/wpmu-users.php
new file mode 100644
index 0000000..c1f7e1a
--- /dev/null
+++ b/wp-inst/wp-admin/wpmu-users.php
@@ -0,0 +1,199 @@
+<?php
+require_once('admin.php');
+
+$title = __('WPMU Admin');
+$parent_file = 'wpmu-admin.php';
+require_once('admin-header.php');
+if( $wpblog != 'main' || $user_level < 10) {
+ die( __('<p>You do not have permission to access this page.</p>') );
+}
+if (isset($_GET['updated'])) {
+ ?><div class="updated"><p><strong><?php _e('Options saved.') ?></strong></p></div><?php
+}
+
+print '<div class="wrap">';
+switch( $_GET[ 'action' ] ) {
+ case "edit":
+ print "<h2>Edit User</h2>";
+ $options_table_name = $wpmuBaseTablePrefix . $_GET[ 'id' ] ."_options";
+ $query = "SELECT *
+ FROM ".$wpdb->users."
+ WHERE ID = '".$_GET[ 'id' ]."'";
+ $userdetails = $wpdb->get_results( $query, ARRAY_A );
+ $query = "SELECT *
+ FROM ".$wpdb->usermeta."
+ WHERE user_id = '".$_GET[ 'id' ]."'";
+ $usermetadetails= $wpdb->get_results( $query, ARRAY_A );
+ ?>
+ <table><td valign='top'>
+ <form name="form1" method="post" action="wpmu-edit.php?action=updateuser">
+ <input type="hidden" name="id" value="<?php echo $_GET[ 'id' ] ?>" />
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <?php
+ unset( $userdetails[0][ 'ID' ] );
+ while( list( $key, $val ) = each( $userdetails[0] ) ) {
+ ?>
+ <tr valign="top">
+ <th width="33%" scope="row"><?php echo ucwords( str_replace( "_", " ", $key ) ) ?></th>
+ <td><input name="option[<?php echo $key ?>]" type="text" id="<?php echo $val ?>" value="<?php echo $val ?>" size="40" /></td>
+ </tr>
+ <?php
+ }
+ ?>
+ </table>
+ </td><td valign='top'>
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform">
+ <tr><th style='text-align: left'>Name</th><th style='text-align: left'>Value</th><th style='text-align: left'>Delete</th></tr>
+ <?php
+ while( list( $key, $val ) = each( $usermetadetails ) ) {
+ ?>
+ <tr valign="top">
+ <th width="33%" scope="row"><input name="metaname[<?php echo $val[ 'umeta_id' ] ?>]" type="text" id="<?php echo $val[ 'meta_key' ] ?>" value="<?php echo $val[ 'meta_key' ] ?>"></th>
+ <td><input name="meta[<?php echo $val[ 'umeta_id' ] ?>]" type="text" id="<?php echo $val[ 'meta_value' ] ?>" value="<?php echo $val[ 'meta_value' ] ?>" size="40" /></td>
+ <td><input type='checkbox' name='metadelete[<?php echo $val[ 'umeta_id' ] ?>]'></td>
+ </tr>
+ <?php
+ }
+ ?>
+ </table>
+ </td></table>
+
+ <p class="submit">
+ <input type="submit" name="Submit" value="<?php _e('Update User') ?> &raquo;" />
+ </p>
+ <?php
+ break;
+ default:
+ $query = "SELECT *
+ FROM ".$wpdb->users;
+ if( $_GET[ 's' ] != '' ) {
+ $query .= " WHERE user_login LIKE '%".$_GET[ 's' ]."%'";
+ }
+ $user_list = $wpdb->get_results( $query, ARRAY_A );
+?>
+<h2>Users</h2>
+<form name="searchform" action="wpmu-admin.php" method="get" style="float: left; width: 16em; margin-right: 3em;">
+ <fieldset>
+ <legend><?php _e('Search Users&hellip;') ?></legend>
+ <input type='hidden' name='action' value='users'>
+ <input type="text" name="s" value="<?php if (isset($_GET[ 's' ])) echo wp_specialchars($_GET[ 's' ], 1); ?>" size="17" />
+ <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+ </fieldset>
+</form>
+
+<br style="clear:both;" />
+
+<?php
+
+// define the columns to display, the syntax is 'internal name' => 'display name'
+$posts_columns = array(
+ 'ID' => __('ID'),
+ 'user_login' => __('Login'),
+ 'user_email' => __('Email'),
+ 'display_name' => __('Name'),
+ 'user_registered' => __('Registered')
+);
+$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
+
+// you can not edit these at the moment
+$posts_columns['control_edit'] = '';
+$posts_columns['control_delete'] = '';
+
+?>
+
+<table width="100%" cellpadding="3" cellspacing="3">
+ <tr>
+
+<?php foreach($posts_columns as $column_display_name) { ?>
+ <th scope="col"><?php echo $column_display_name; ?></th>
+<?php } ?>
+
+ </tr>
+<?php
+if ($user_list) {
+$bgcolor = '';
+foreach ($user_list as $user) {
+$class = ('alternate' == $class) ? '' : 'alternate';
+?>
+ <tr class='<?php echo $class; ?>'>
+
+<?php
+
+foreach($posts_columns as $column_name=>$column_display_name) {
+
+ switch($column_name) {
+
+ case 'ID':
+ ?>
+ <th scope="row"><?php echo $user[ 'ID' ] ?></th>
+ <?php
+ break;
+
+ case 'user_login':
+ ?>
+ <td><?php echo $user[ 'user_login' ] ?>
+ </td>
+ <?php
+ break;
+
+ case 'display_name':
+ ?>
+ <td><?php echo $user[ 'display_name' ] ?></td>
+ <?php
+ break;
+
+ case 'user_email':
+ ?>
+ <td><?php echo $user[ 'user_email' ] ?></td>
+ <?php
+ break;
+
+ case 'user_registered':
+ ?>
+ <td><?php echo $user[ 'user_registered' ] ?></td>
+ <?php
+ break;
+
+ case 'control_edit':
+ ?>
+ <td><?php echo "<a href='wpmu-users.php?action=edit&amp;id=".$user[ 'ID' ]."' class='edit'>" . __('Edit') . "</a>"; ?></td>
+ <?php
+ break;
+
+ case 'control_delete':
+ ?>
+ <td><?php echo "<a href='wpmu-users.php?action=delete&amp;id=".$user[ 'ID' ]."' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this user?\\n \'OK\' to delete, \'Cancel\' to stop.") ) . "')\">" . __('Delete') . "</a>"; ?></td>
+ <?php
+ break;
+
+ default:
+ ?>
+ <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
+ <?php
+ break;
+ }
+}
+?>
+ </tr>
+<?php
+}
+} else {
+?>
+ <tr style='background-color: <?php echo $bgcolor; ?>'>
+ <td colspan="8"><?php _e('No users found.') ?></td>
+ </tr>
+<?php
+} // end if ($users)
+?>
+</table>
+
+<div class="navigation">
+<div class="alignleft"><?php //next_posts_link(__('&laquo; Previous Entries')) ?></div>
+<div class="alignright"><?php //previous_posts_link(__('Next Entries &raquo;')) ?></div>
+</div>
+<?php
+}
+
+?>
+</div>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-inst/wp-atom.php b/wp-inst/wp-atom.php
new file mode 100644
index 0000000..feb2845
--- /dev/null
+++ b/wp-inst/wp-atom.php
@@ -0,0 +1,45 @@
+<?php
+
+if (empty($wp)) {
+ require_once('wp-config.php');
+ wp('feed=atom');
+}
+
+header('Content-type: application/atom+xml; charset=' . get_settings('blog_charset'), true);
+$more = 1;
+
+?>
+<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
+<feed version="0.3"
+ xmlns="http://purl.org/atom/ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xml:lang="<?php echo get_option('rss_language'); ?>"
+ <?php do_action('atom_ns'); ?>
+ >
+ <title><?php bloginfo_rss('name') ?></title>
+ <link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />
+ <tagline><?php bloginfo_rss("description") ?></tagline>
+ <modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></modified>
+ <copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog'), 0); ?></copyright>
+ <generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
+ <?php do_action('atom_head'); ?>
+ <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+ <entry>
+ <author>
+ <name><?php the_author() ?></name>
+ </author>
+ <title type="text/html" mode="escaped"><![CDATA[<?php the_title_rss() ?>]]></title>
+ <link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />
+ <id><?php the_guid(); ?></id>
+ <modified><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></modified>
+ <issued><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></issued>
+ <?php the_category_rss('rdf') ?>
+ <summary type="text/plain" mode="escaped"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
+<?php if ( !get_settings('rss_use_excerpt') ) : ?>
+ <content type="<?php bloginfo('html_type'); ?>" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
+<?php endif; ?>
+<?php rss_enclosure(); ?>
+<?php do_action('atom_entry'); ?>
+ </entry>
+ <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
+</feed>
diff --git a/wp-inst/wp-blog-header.php b/wp-inst/wp-blog-header.php
new file mode 100644
index 0000000..c087324
--- /dev/null
+++ b/wp-inst/wp-blog-header.php
@@ -0,0 +1,21 @@
+<?php
+
+if (! isset($wp_did_header)):
+if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) {
+ if ( strstr( $_SERVER['PHP_SELF'], 'wp-admin') ) $path = '';
+ else $path = 'wp-admin/';
+ die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='{$path}setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, 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-inst/wp-comments-post.php b/wp-inst/wp-comments-post.php
new file mode 100644
index 0000000..ae81a4a
--- /dev/null
+++ b/wp-inst/wp-comments-post.php
@@ -0,0 +1,67 @@
+<?php
+/*
+// This is a common User Agent used by comment spammers.
+if( $_SERVER["HTTP_USER_AGENT"] == "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90)" || $_SERVER["HTTP_USER_AGENT"] == 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)' || $_SERVER["HTTP_USER_AGENT"] == 'Mozilla/3.0 (compatible; Indy Library)' )
+{
+ die();
+}
+*/
+require( dirname(__FILE__) . '/wp-config.php' );
+
+$comment_post_ID = (int) $_POST['comment_post_ID'];
+
+$status = $wpdb->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');
+
+wp_new_comment($commentdata);
+
+setcookie('comment_author_' . COOKIEHASH, stripslashes($comment_author), time() + 30000000, COOKIEPATH);
+setcookie('comment_author_email_' . COOKIEHASH, stripslashes($comment_author_email), time() + 30000000, COOKIEPATH);
+setcookie('comment_author_url_' . COOKIEHASH, stripslashes($comment_author_url), time() + 30000000, COOKIEPATH);
+
+nocache_headers();
+
+$location = (empty($_POST['redirect_to'])) ? $_SERVER["HTTP_REFERER"] : $_POST['redirect_to'];
+
+wp_redirect($location);
+?>
diff --git a/wp-inst/wp-comments.php b/wp-inst/wp-comments.php
new file mode 100644
index 0000000..f45044d
--- /dev/null
+++ b/wp-inst/wp-comments.php
@@ -0,0 +1,52 @@
+<?php // Do not delete these lines
+
+/* $Id: wp-comments.php,v 1.3 2004/11/22 11:14:01 donncha Exp $ */
+
+global $wpsmarty;
+if ('wp-comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
+die ('Please do not load this page directly. Thanks!');
+$commentstext = '';
+$withcomments = true;
+if (($withcomments && $wpsmarty->template_exists( "blog-comments.html" ) ) or (is_single()))
+{
+ unset( $t );
+ 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
+ ?><p><?php _e("Enter your password to view comments."); ?><p><?php
+ return;
+ }
+ }
+ $query = "SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date";
+ $comments = $wpdb->get_results( $query );
+ if( is_array( $comments ) )
+ {
+ foreach( $comments as $key => $comment )
+ {
+ $t[ $key ] = $comment;
+ $t[ $key ]->comment_content = stripslashes( $t[ $key ]->comment_content );
+ }
+ }
+ else
+ {
+ $t = $comments;
+ }
+ $wpsmarty->assign( "comments", $t);
+ $wpsmarty->assign( "comment_author_url", $comment_author_url );
+ $wpsmarty->assign( "comment_author", $comment_author );
+ $wpsmarty->assign( "comment_author_email", $comment_author_email );
+ $wpsmarty->assign( "req", $req );
+ $wpsmarty->assign( "redirect_to", htmlspecialchars($_SERVER["REQUEST_URI"]) );
+ $wpsmarty->assign( "post", $post );
+ $wpsmarty->caching = false;
+ if( is_single() == false )
+ {
+ if( $wpsmarty->template_exists( "blog-comments.html" ) )
+ $commentstext .= $wpsmarty->fetch( "blog-comments.html" );
+ }
+ else
+ {
+ $commentstext .= $wpsmarty->fetch( "comments.html" );
+ }
+ $wpsmarty->caching = true;
+}
+?>
diff --git a/wp-inst/wp-commentsrss2.php b/wp-inst/wp-commentsrss2.php
new file mode 100644
index 0000000..906d8b9
--- /dev/null
+++ b/wp-inst/wp-commentsrss2.php
@@ -0,0 +1,76 @@
+<?php
+
+if (empty($wp)) {
+ require_once('wp-config.php');
+ wp('feed=rss2&withcomments=1');
+}
+
+header('Content-type: text/xml;charset=' . get_settings('blog_charset'), true);
+
+echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>';
+?>
+<!-- generator="wordpress/<?php echo $wp_version ?>" -->
+<rss version="2.0"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/">
+<channel>
+<?php
+$i = 0;
+if (have_posts()) :
+ while (have_posts()) : the_post();
+ if ($i < 1) {
+ $i++;
+?>
+ <title><?php if (is_single() || is_page()) { echo "Comments on: "; the_title_rss(); } else { bloginfo_rss("name"); echo " Comments"; } ?></title>
+ <link><?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?></link>
+ <description><?php bloginfo_rss("description") ?></description>
+ <pubDate><?php echo gmdate('r'); ?></pubDate>
+ <generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>
+
+<?php
+ if (is_single() || is_page()) {
+ $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 comment_post_ID = '$id'
+ AND $wpdb->comments.comment_approved = '1' AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'static')
+ AND post_date < '".date("Y-m-d H:i:59")."'
+ ORDER BY comment_date 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 = 'publish' OR $wpdb->posts.post_status = 'static')
+ AND $wpdb->comments.comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s")."'
+ ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') );
+ }
+ // this line is WordPress' motor, do not delete it.
+ if ($comments) {
+ foreach ($comments as $comment) {
+?>
+ <item>
+ <title>by: <?php comment_author_rss() ?></title>
+ <link><?php comment_link() ?></link>
+ <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>
+ <guid><?php comment_link() ?></guid>
+ <?php
+ if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {
+ ?>
+ <description>Protected Comments: Please enter your password to view comments.</description>
+ <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
+ <?php
+ } else {
+ ?>
+ <description><?php comment_text_rss() ?></description>
+ <content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
+ <?php
+ } // close check for password
+ ?>
+ </item>
+<?php
+ }
+ }
+ }
+endwhile; endif;
+?>
+</channel>
+</rss>
diff --git a/wp-inst/wp-config-sample.php b/wp-inst/wp-config-sample.php
new file mode 100644
index 0000000..f6bb06e
--- /dev/null
+++ b/wp-inst/wp-config-sample.php
@@ -0,0 +1,19 @@
+<?php
+
+/* $Id: wp-config-sample.php,v 1.2 2005/01/13 23:33:38 donncha Exp $ */
+
+// ** MySQL settings ** //
+define('DB_NAME', 'wordpress'); // The name of the database
+define('DB_USER', 'username'); // Your MySQL username
+define('DB_PASSWORD', 'password'); // ...and password
+define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
+define('VHOST', 'VHOSTSETTING');
+
+
+$table_prefix = 'wp_'; // example: 'wp_' or 'b2' or 'mylogin_'
+
+/* Stop editing */
+
+define('ABSPATH', dirname(__FILE__).'/');
+require_once(ABSPATH.'wpmu-settings.php');
+?>
diff --git a/wp-inst/wp-content/blogs b/wp-inst/wp-content/blogs
new file mode 100644
index 0000000..5842897
--- /dev/null
+++ b/wp-inst/wp-content/blogs
@@ -0,0 +1,20 @@
+<?php
+require_once( "../wp-config.php" );
+if( is_file( ABSPATH . "wp-content/blogs.dir/" . $blog_id . $_SERVER[ 'REQUEST_URI' ] ) ) {
+ // get mime type
+ $ext = substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 );
+ if( $ext == 'jpg' )
+ $ext = 'jpeg';
+ $mimetype = "image/$ext";
+ header("Content-type: $mimetype" );
+ readfile( ABSPATH . "wp-content/blogs.dir/" . $blog_id . $_SERVER[ 'REQUEST_URI' ] );
+} else {
+ // 404
+ header("HTTP/1.1 404 Not Found");
+ print "<html><head><title>Error 404! File Not Found!</title></head>";
+ print "<body>";
+ print "<h1>File Not Found!</h1>";
+ print "No! No! Run Away! This file has escaped and is running wild!";
+ print "</body></html>";
+}
+?>
diff --git a/wp-inst/wp-content/plugins/BAStats/BAStats.php b/wp-inst/wp-content/plugins/BAStats/BAStats.php
new file mode 100644
index 0000000..ebe3f17
--- /dev/null
+++ b/wp-inst/wp-content/plugins/BAStats/BAStats.php
@@ -0,0 +1,566 @@
+<?php
+/*
+Plugin Name: BAStats
+Plugin URI: http://asymptomatic.net/wp-hacks
+Description: This plugin calculates statistics for a WordPress weblog.
+Author: Owen Winkler
+Version: 1.0&beta; build 8
+Author URI: http://asymptomatic.net
+*/
+
+/*
+BAStats - calculates statistics for a WordPress weblog.
+Copyright (c) 2004 Owen Winkler
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to
+do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall
+be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+include_once('BAStats_logger.php');
+
+class BASP
+{
+ var $settings = array();
+ var $table_version = 6;
+ var $added_tables = false;
+ var $colors = array('#FF0000', '#FF1E00', '#FF3C00', '#FF5900', '#FF7700', '#FF9500', '#FFB300', '#FFD000', '#FFEE00', '#F2FF00', '#D5FF00', '#B7FF00', '#99FF00', '#7BFF00', '#5EFF00', '#40FF00', '#22FF00', '#04FF00', '#00FF1A', '#00FF37', '#00FF55', '#00FF73', '#00FF91', '#00FFAE', '#00FFCC', '#00FFEA', '#00F7FF', '#00D9FF', '#00BBFF', '#009DFF', '#0080FF', '#0062FF', '#0044FF', '#0026FF', '#0009FF', '#1500FF', '#3300FF', '#5100FF', '#6F00FF', '#8C00FF', '#AA00FF', '#C800FF', '#E600FF', '#FF00FB', '#FF00DD', '#FF00BF', '#FF00A2', '#FF0084', '#FF0066', '#FF0048', '#FF002B', '#FF000D',);
+
+
+ function BASP()
+ {
+ add_action('admin_menu', array(&$this, 'admin_menu'));
+ add_action('admin_footer', array(&$this, 'admin_footer'));
+ add_action('wp_head', array(&$this, 'wp_head'));
+ add_action('template_redirect', array(&$this, 'template_redirect'));
+
+ $this->settings = get_settings('bastats');
+ $this->wpdb_tables();
+
+ if($this->settings['table_version'] != $this->table_version)
+ {
+ $this->make_tables();
+ $this->added_tables = true;
+ }
+ }
+
+ function admin_footer()
+ {
+ update_option('bastats', $this->settings);
+ }
+
+ function admin_menu()
+ {
+ $pfile = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
+ add_submenu_page('index.php', 'BA Stats', 'Stats', 8, $pfile, array(&$this, 'plugin_content'));
+ add_options_page('BA Stats', 'Stats', 8, $pfile, array(&$this, 'plugin_options'));
+ }
+
+ function plugin_options()
+ {
+ include('BAStats_options.php');
+ }
+
+ function plugin_content()
+ {
+ global $wpdb;
+
+ if($this->added_tables)
+ {
+ echo '<div class="updated"><p>Modified BA Stats Tables.</p></div>';
+ }
+
+ $reports = $this->get_reports();
+ $report_tags = array_keys($reports);
+
+ $rangeset = isset($_GET['rangeset']) ? $_GET['rangeset'] : 'ten_minutes';
+ list($start, $end) = $this->get_range($rangeset);
+ $limit = isset($_GET['limit']) ? $_GET['limit'] : '10';
+ $report = isset($_GET['report']) ? $_GET['report'] : $report_tags[0];
+?>
+<div class="wrap">
+<h2>Site Statistics</h2>
+<?php
+ $totalPages = $wpdb->get_var("SELECT count(page_id) FROM {$wpdb->pages}");
+ $totalSessions = $wpdb->get_var("SELECT count(visit_id) FROM {$wpdb->visitors}");
+ $totalHits = $wpdb->get_var("SELECT count(visit) FROM {$wpdb->log}");
+
+
+ echo "<p><strong>Unique Pages Served:</strong> {$totalPages}";
+ echo "<strong style=\"margin-left:50px;\">Total Sessions:</strong> {$totalSessions}";
+ echo "<strong style=\"margin-left:50px;\">Total Page Hits:</strong> {$totalHits}</p>";
+
+
+ echo '<form method="get">
+ <input type="hidden" name="page" value="' . $_GET['page'] .'"/>';
+
+ if(isset($_GET['filter']) > 0)
+ {
+ list($filt_type,$filt_crit) = explode('=', $_GET['filter'], 2);
+ $filter = stripslashes($_GET['filter']);
+ switch($filt_type)
+ {
+ case 'host':
+ $filt_crit_output = BAStats::inttoip($filt_crit);
+ $filt_label = "Host is " . $filt_crit_output;
+ break;
+ case 'search':
+ $filt_crit_output = $wpdb->get_var("SELECT search_engine FROM {$wpdb->searches} WHERE search_refer = {$filt_crit};");
+ $filt_label = "Search Engine is " . $filt_crit_output;
+ break;
+ case 'referer':
+ $filt_crit_output = $wpdb->get_var("SELECT referer_string FROM {$wpdb->refer} WHERE referer_id= {$filt_crit};");
+ $filt_label = "Referer is " . $filt_crit_output;
+ break;
+ }
+ echo '<fieldset id="stat_filter" style="clear:both;">
+ <legend>Filter:</legend>';
+ echo "<label style=\"display:block;\"><input type=\"checkbox\" name=\"filter\" value=\"{$filter}\" checked=\"checked\"/> {$filt_label}</label>\n";
+ if(!is_array($reports[$report]['filters']) || !in_array($filt_type, $reports[$report]['filters']))
+ {
+ echo "<div style=\"text-indent:3em;\"><em>Filter does not apply to this report</em></div>";
+ }
+ echo '</fieldset>';
+ }
+
+ foreach($reports as $kreport => $vreport)
+ {
+ if($filt_type != '')
+ {
+ if(isset($vreport['filters']) && in_array($filt_type, $vreport['filters']))
+ {
+ $methods[$kreport] = array(sprintf($vreport['title'], $filt_crit_output), 10, 'background-color:#CCCCCC;');
+ }
+ elseif(!isset($vreport['filters']))
+ {
+ $methods[$kreport] = $vreport['title'];
+ }
+ }
+ else
+ {
+ if(!isset($vreport['filters']))
+ {
+ $methods[$kreport] = $vreport['title'];
+ }
+ }
+ }
+ if(!in_array($report, array_keys($methods)))
+ {
+ $report = $report_tags[0];
+ }
+ echo '<fieldset id="stat_method" style="float: left; margin-right: 1em;"><legend>Report:</legend>'
+ . $this->build_select('report', $methods, $report)
+ . '</fieldset>';
+
+ $limits = array(
+ '10' => '10',
+ '20' => '20',
+ '50' => '50',
+ '-1' => 'Everything',
+ );
+ echo '<fieldset id="stat_limit" style="float: left; margin-right: 1em;"><legend>Count:</legend>'
+ . $this->build_select('limit', $limits, $limit)
+ . '</fieldset>';
+
+ $dateranges = array(
+ 'ten_minutes' => '10 Minutes',
+ 'last_hour' => 'Last Hour',
+ 'last_6hours' => 'Last 6 Hours',
+ 'twenty_four' => 'Last 24 Hours',
+ 'today' => 'Since Midnight Today',
+ 'yesterday' => 'Yesterday',
+ 'last_week' => 'Last 7 Days',
+ );
+ if($timestamps = $wpdb->get_col("select distinct date_format(stamp, '%Y-%m') from {$wpdb->log};"))
+ {
+ foreach($timestamps as $item)
+ {
+ $dateranges[$item] = date('F Y', strtotime($item . '-01'));
+ }
+ }
+ $dateranges[''] = 'Everything';
+ echo '<fieldset id="stat_daterange" style="float: left; margin-right: 1em;"><legend>Date Range:</legend>'
+ . $this->build_select('rangeset', $dateranges, $rangeset)
+ . '</fieldset>';
+
+ echo '<p class="submit" style="clear:both;"><input type="submit" value="Show" /></p>
+ </form>
+ </div>';
+
+ switch($reports[$report]['report_type'])
+ {
+ case 'graph':
+ echo '<div class="wrap"><h2>Result Graph</h2><div style="text-align:center;"><img src="' . get_bloginfo('siteurl') . '/wp-content/plugins/BAStats/BAStats_graph.php?graph=' . $report . '&amp;rangeset=' . $rangeset . '&amp;limit=' . $limit . '" /></div>';
+
+ $query = $reports[$report]['series'];
+ $qry = preg_replace('/{([^}]+)}/e', '\$\1', $query);
+ $data = $wpdb->get_results($qry);
+
+ $label_filter = create_function('$row', $reports[$report]['label_filter']);
+
+ echo "<ul>";
+ $count = 0;
+ foreach($data as $row)
+ {
+ echo "<li style=\"list-style:none;\"><span style=\"color:" . $this->get_color($count, count($data)) . ";font-size:x-large;\">&bull;</span> {$count}: " . $label_filter($row) . "</li>";
+ //echo "<li>" . print_r($row, 1)."<br/>{$reports[$report]['label_filter']}</li>";
+ $count ++;
+ }
+ echo "</ul>";
+ echo '</div>';
+ break;
+ }
+
+ $stamp = '';
+ $lasthere = '';
+ if($start != false)
+ {
+ $stamp .= " AND stamp >= '" . date('Y-m-d H:i:s', $start) . "'";
+ $lasthere .= " AND lasthere >= '" . date('Y-m-d H:i:s', $start) . "'";
+ }
+ if($end != false)
+ {
+ $stamp .= " AND stamp <= '" . date('Y-m-d H:i:s', $end) . "'";
+ $lasthere .= " AND lasthere <= '" . date('Y-m-d H:i:s', $end) . "'";
+ }
+ $qrylimit = '';
+ if($limit != -1)
+ {
+ $qrylimit = " LIMIT {$limit}";
+ }
+
+ foreach($reports[$report]['queries'] as $query)
+ {
+ if(($query != $reports[$report]['queries'][0]) && is_array($data))
+ {
+ extract($data[0]);
+ }
+ $qry = preg_replace('/{([^}]+)}/e', '\$\1', $query);
+ //$qry = sprintf($reports[$report]['query'], $where);
+
+ $data = $wpdb->get_results($qry, ARRAY_A);
+ }
+
+ echo '<div class="wrap"><h2>Query Results</h2>';
+
+ echo '<table id="stats_output" width="100%" cellpadding="3" cellspacing="3">
+ <thead>
+ <tr>
+ ';
+ foreach($reports[$report]['columns'] as $caption => $field)
+ {
+ echo "<th scope=\"col\">{$caption}</th>\n";
+ if(isset($reports[$report]['column_filter'][$caption]))
+ {
+ //echo "<strong>Filter Function:</strong>{$reports[$report]['column_filter'][$caption]}";
+ $column_filter[$caption] = create_function('$row', $reports[$report]['column_filter'][$caption]);
+ }
+ }
+ echo '</tr>
+ </thead>
+ <tbody>
+ ';
+
+
+ if(is_array($data) && count($data) > 0)
+ {
+ foreach($data as $item)
+ {
+ $alternate = ($alternate == '')? ' class="alternate"' : '';
+ echo "<tr{$alternate}>\n";
+ foreach($reports[$report]['columns'] as $caption => $field)
+ {
+ $output = $item[$field];
+ if(isset($column_filter[$caption]))
+ {
+ $output = $column_filter[$caption]($item);
+ }
+ echo "<td>{$output}</td>\n";
+ }
+ echo "</tr>\n";
+ }
+ }
+ else
+ {
+ echo "<tr class=\"alternate\"><td colspan=\"3\">No results</td></tr>";
+ }
+ echo '</tbody>
+ </table>';
+ echo "<div style=\"background-color:#EEE;margin:15px;font-size:xx-small;\">
+ You have downloaded BETA software. Provide this information to the developer only upon request:<br />
+ {$qry}</div><!--div><pre>". /*print_r(array_keys($data[0]), 1) .*/ "</pre></div-->";
+?>
+</div>
+<?php
+ }
+
+ function wpdb_tables() {
+ global $wpdb, $table_prefix;
+
+ $wpdb->visitors = "{$table_prefix}bas_visitors";
+ $wpdb->refer = "{$table_prefix}bas_refer";
+ $wpdb->os = "{$table_prefix}bas_os";
+ $wpdb->ua = "{$table_prefix}bas_ua";
+ $wpdb->log = "{$table_prefix}bas_log";
+ $wpdb->pages = "{$table_prefix}bas_pages";
+ $wpdb->searches = "{$table_prefix}bas_searches";
+ }
+
+ function make_tables() {
+ global $wpdb, $table_prefix;
+ if(!include_once(ABSPATH . 'wp-admin/upgrade-functions.php')) {
+ die(_e('There is was error adding the required tables to the database. Please refer to the documentation regarding this issue.', 'BAStats'));
+ }
+ $qry = "CREATE TABLE {$table_prefix}bas_visitors (
+ visit_id BIGINT(11) NOT NULL AUTO_INCREMENT,
+ visit_ip BIGINT(11) UNSIGNED,
+ referer INT(4),
+ osystem INT(4),
+ useragent INT(4),
+ lasthere DATETIME,
+ PRIMARY KEY (visit_id),
+ KEY refer (referer),
+ KEY os (osystem),
+ KEY ua (useragent)
+ );
+ CREATE TABLE {$table_prefix}bas_refer (
+ referer_id INT(4) NOT NULL AUTO_INCREMENT,
+ referer_string tinytext,
+ PRIMARY KEY (referer_id)
+ );
+ CREATE TABLE {$table_prefix}bas_os (
+ os_id INT(4) NOT NULL AUTO_INCREMENT,
+ os_string varchar(255),
+ PRIMARY KEY (os_id)
+ );
+ CREATE TABLE {$table_prefix}bas_ua (
+ ua_id INT(4) NOT NULL AUTO_INCREMENT,
+ ua_string varchar(255),
+ PRIMARY KEY (ua_id)
+ );
+ CREATE TABLE {$table_prefix}bas_log (
+ visit BIGINT(11) NOT NULL,
+ stamp DATETIME,
+ outbound TINYINT,
+ page BIGINT(11),
+ KEY visit (visit),
+ KEY page (page),
+ KEY stamp (stamp)
+ );
+ CREATE TABLE {$table_prefix}bas_pages (
+ page_id BIGINT(11) NOT NULL AUTO_INCREMENT,
+ page_string varchar(255),
+ permalink varchar(255),
+ page_label varchar(255),
+ PRIMARY KEY (page_id)
+ );
+ CREATE TABLE {$table_prefix}bas_searches (
+ search_refer BIGINT(11),
+ search_phrase varchar(255),
+ search_engine varchar(255),
+ KEY search_refer (search_refer)
+ );
+ ";
+ dbDelta($qry);
+
+ $this->settings['table_version'] = $this->table_version;
+ update_option('bastats', $this->settings);
+ }
+
+ function get_range($rangeset)
+ {
+ if(preg_match('/([0-9]{4})-([0-9]{2})(-([0-9]{2}))?(->([0-9]{4})-([0-9]{2})(-([0-9]{2}))?)?/', $rangeset, $dateset))
+ {
+ if($dateset[5] == '')
+ {
+ if($dateset[4] == '')
+ {
+ $start = mktime(0, 0, 0, $dateset[2], 1, $dateset[1]);
+ $end = mktime(23, 59, 59, $dateset[2], date('t', $start), $dateset[1]);
+ }
+ else
+ {
+ $start = mktime(0, 0, 0, $dateset[2], $dateset[4], $dateset[1]);
+ $end = mktime(23, 59, 59, $dateset[2], $dateset[4], $dateset[1]);
+ }
+ }
+ else
+ {
+ if($dateset[4] == '')
+ {
+ $start = mktime(0, 0, 0, $dateset[2], 1, $dateset[1]);
+ }
+ else
+ {
+ $start = mktime(0, 0, 0, $dateset[2], $dateset[4], $dateset[1]);
+ }
+ if($dateset[9] == '')
+ {
+ $end = mktime(23, 59, 59, $dateset[7], date('t', mktime(23, 59, 59, $dateset[7], 1, $dateset[6])), $dateset[6]);
+ }
+ else
+ {
+ $end = mktime(23, 59, 59, $dateset[7], $dateset[9], $dateset[6]);
+ }
+ }
+ }
+ else if(preg_match('/(today|last_week|yesterday|last_hour|last_6hours|ten_minutes|twenty_four)/', $rangeset, $dateset))
+ {
+ $dateinfo = getdate();
+ extract($dateinfo);
+ switch($dateset[1])
+ {
+ case 'today':
+ $start = mktime(0, 0, 0, $mon, $mday, $year);
+ $end = mktime(23, 59, 59, $mon, $mday, $year);
+ break;
+ case 'last_week':
+ $start = mktime(0, 0, 0, $mon, $mday - 7, $year);
+ $end = mktime(23, 59, 59, $mon, $mday, $year);
+ break;
+ case 'yesterday':
+ $start = mktime(0, 0, 0, $mon, $mday - 1, $year);
+ $end = mktime(23, 59, 59, $mon, $mday - 1, $year);
+ break;
+ case 'last_hour':
+ $start = mktime($hours - 1, $minutes, $seconds, $mon, $mday, $year);
+ $end = mktime($hours, $minutes, $seconds, $mon, $mday, $year);
+ break;
+ case 'last_6hours':
+ $start = mktime($hours - 6, $minutes, $seconds, $mon, $mday, $year);
+ $end = mktime($hours, $minutes, $seconds, $mon, $mday, $year);
+ break;
+ case 'ten_minutes':
+ $start = mktime($hours, $minutes - 10, $seconds, $mon, $mday, $year);
+ $end = mktime($hours, $minutes, $seconds, $mon, $mday, $year);
+ break;
+ case 'twenty_four':
+ $start = mktime($hours - 24, $minutes, $seconds, $mon, $mday, $year);
+ $end = mktime($hours, $minutes, $seconds, $mon, $mday, $year);
+ break;
+ }
+ }
+ else
+ {
+ $start = false;
+ $end = false;
+ }
+
+ return array($start, $end);
+ }
+
+ function build_select($name, $valuedisplay, $check)
+ {
+ $ret = "<select id=\"{$name}\" name=\"{$name}\">\n";
+ $options = array();
+ foreach($valuedisplay as $value => $display)
+ {
+ $selected = ($value == $check) ? ' selected="selected"' : '';
+ if(is_array($display))
+ {
+ $style = ($display[2] != '') ? " style=\"$display[2]\" " : '';
+ $options[$display[1]][] = "<option value=\"{$value}\"{$style}{$selected}>{$display[0]}</option>";
+ }
+ else
+ {
+ $options[100][] = "<option value=\"{$value}\"{$selected}>{$display}</option>";
+ }
+ }
+ ksort($options, SORT_NUMERIC);
+ foreach($options as $option)
+ {
+ $ret .= implode("\n", $option);
+ }
+ $ret .= "</select>\n";
+ return $ret;
+ }
+
+ function refer_replace($url)
+ {
+ $engs = BAStats::search_engines();
+ foreach($engs as $keng => $eng)
+ {
+ $repl[$keng] = "<strong class=\"BAStats_seng\">{$eng[0]}:</strong> \\" . $eng[1];
+ }
+ $url = preg_replace(array_keys($repl), array_values($repl), $url);
+ $url = preg_replace('/^http:\/\//', '', $url);
+ $url = urldecode($url);
+ if($url == '') $url = '[No Referrer]';
+ return $url;
+ }
+
+ function wp_head()
+ {
+ $title = trim(wp_title(' ', false));
+ BAStats::label($title);
+ return true;
+ }
+
+ function get_reports()
+ {
+ global $wpdb;
+ include_once('BAStats_reports.php');
+ return $reports;
+ }
+
+ function get_color($index, $total)
+ {
+ $out = count($this->colors) / $total * $index;
+ return $this->colors[$out];
+ }
+
+ function template_redirect()
+ {
+ $bas_options = get_settings('bas_options');
+ if(!is_array($bas_options)) $bas_options = array();
+ /* Actually DO statistics logging */
+ $do_logging = true;
+ if(!in_array('log_admins', $bas_options))
+ {
+ global $user_level;
+ get_currentuserinfo();
+ if (isset($user_level) && ($user_level >= 8)) $do_logging = false;
+ }
+ if(!in_array('log_console', $bas_options))
+ {
+ if(strstr($_SERVER['REQUEST_URI'], '/wp-admin')) $do_logging = false;
+ }
+ if(!in_array('log_content', $bas_options))
+ {
+ if(strstr($_SERVER['REQUEST_URI'], '/wp-content')) $do_logging = false;
+ }
+ if(!in_array('log_self', $bas_options))
+ {
+ $serveraddr = $_SERVER['LOCAL_ADDR'];
+ if($serveraddr == '') $serveraddr = $_SERVER['SERVER_ADDR'];
+ if($_SERVER['REMOTE_ADDR'] == $serveraddr) $do_logging = false;
+ }
+ if($do_logging)
+ {
+ BAStats::log($title);
+ }
+ //echo "<!-- BAStats Logged -->";
+ }
+}
+
+$basp = new BASP();
+
+?>
diff --git a/wp-inst/wp-content/plugins/BAStats/BAStats_graph.php b/wp-inst/wp-content/plugins/BAStats/BAStats_graph.php
new file mode 100644
index 0000000..a673730
--- /dev/null
+++ b/wp-inst/wp-content/plugins/BAStats/BAStats_graph.php
@@ -0,0 +1,375 @@
+<?php
+/*
+Version: 1.0&beta; build 8
+
+BAStats - calculates statistics for a WordPress weblog.
+Copyright (c) 2004 Owen Winkler
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to
+do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall
+be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+class BAS_graph
+{
+ var $width = 600;
+ var $height = 400;
+ var $colors = array();
+ var $caption = "";
+
+ var $series = array();
+ var $xlabels = array();
+
+ var $image;
+ var $graphtype = 'bar';
+
+ function BAS_graph()
+ {
+ $this->image = ImageCreate($this->width, $this->height);
+ $this->InitColors();
+ }
+
+ function InitColors()
+ {
+ $this->SetColor('y_grade', '#EEEEEE');
+ $this->SetColor('x_grade', '#FFFFFF');
+ $this->SetColor('background', '#FFFFFF');
+ $this->SetColor('frame', '#EEEEEE');
+ $this->SetColor('values', '#999999');
+ $this->SetColor('black', '#000000');
+ $this->SetColor('white', '#FFFFFF');
+ $this->SetColor('light_gray', '#CCCCCC');
+ }
+
+ function SetColor($name, $hcolor)
+ {
+ if(isset($this->colors[$name]))
+ {
+ ImageColorDeallocate($this->image, $this->colors[$name]);
+ }
+ $this->colors[$name] = $this->hexcolor($hcolor);
+ }
+
+ function hexcolor($h)
+ {
+ if($h{0} == '#') $h = substr($h, 1);
+ sscanf($h, "%2x%2x%2x", $red, $green, $blue);
+ return ImageColorAllocate($this->image, $red, $green, $blue);
+ }
+
+ function AddSeries($name, $s)
+ {
+ $this->series[$name] = $s;
+ }
+
+ function DrawRect($rectary, $color)
+ {
+ ImageRectangle($this->image, $rectary[0], $rectary[1], $rectary[2], $rectary[3], $color);
+ }
+
+ function Build()
+ {
+ ImageFill($this->image, 0, 0, $this->colors['background']);
+ ImageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $this->colors['frame']);
+
+ $fwidth = ImageFontWidth(1);
+ $fheight = ImageFontHeight(1);
+
+ $graph_max = 0;
+ $graph_min = 9999;
+ foreach($this->series as $seriesname => $series)
+ {
+ foreach($this->xlabels as $label)
+ {
+ if(!isset($series[$label]))
+ {
+ $this->series[$seriesname][$label] = 0;
+ }
+ }
+ }
+ foreach($this->series as $s)
+ {
+ $av = array_values($s);
+ $series_max = count($s) > 1 ? max($s) : $av[0];
+ $graph_max = max($series_max, $graph_max);
+ $series_min = count($s) > 1 ? min($s) : $av[0];
+ $graph_min = min($series_min, $graph_min);
+ }
+ //owd($this->series);
+ if($graph_max == $graph_min)
+ {
+ $graph_max += 10;
+ $graph_min = 0;
+ }
+ $graph_min = 0;
+
+ ImageString($this->image, 1, 60, 2, $graph_min . ' - ' . $graph_max, $this->colors['black']);
+ $cw_graph_max = floor(log10(abs($graph_max)) + 1) * $fwidth;
+
+ $graph_rect = array($cw_graph_max + 2 * $fwidth, $fheight * 2, $this->width - $cw_graph_max, $this->height - $fwidth * 17);
+ $this->DrawRect($graph_rect, $this->colors['frame']);
+ $graph_height = $graph_rect[3] - $graph_rect[1];
+ $graph_width = $graph_rect[2] - $graph_rect[0];
+ for($z=0;$z<=4;$z++)
+ {
+ $y = $graph_rect[1] + ($z * $graph_height / 4);
+ ImageLine($this->image, $graph_rect[0], $y, $graph_rect[2], $y, $this->colors['frame']);
+ ImageString($this->image, 1, 4, $y - $fheight / 2, round(($graph_height - ($y - $graph_rect[1])) / $graph_height * ($graph_max - $graph_min) + $graph_min), $this->colors['black']);
+ }
+
+ $x_spot = 0;
+ $graph_inc = $graph_width / (count($series));
+ $bar_width = ($graph_inc - 1) / count($this->series);
+ foreach($this->xlabels as $label)
+ {
+ //$x_spot = 0;
+ $series_index = 0;
+ foreach($this->series as $seriesname => $series)
+ {
+ $value = isset($series[$label])? $series[$label] : 0;
+ $x = $x_spot * $graph_inc + $graph_rect[0];
+ $y = $graph_rect[1] + $graph_height - ($value - $graph_min) * (($graph_height) / ($graph_max - $graph_min));
+
+ switch($this->graphtype)
+ {
+ case 'bar':
+ ImageFilledRectangle($this->image, $x + $series_index * $bar_width, $y, $x + ($series_index + 1) * $bar_width - 1, $graph_rect[3], $this->colors[$seriesname]);
+ $labely = min($y + ($fheight * 1), $graph_rect[3] - ($fheight * 1.5));
+ ImageString($this->image, 1, $x + $series_index * $bar_width + $fwidth + 1, $labely + 1, $value, $this->colors['black']);
+ ImageString($this->image, 1, $x + $series_index * $bar_width + $fwidth, $labely, $value, $this->colors['light_gray']);
+ break;
+ case 'line';
+ ImageFilledRectangle($this->image, $x-2, $y-2, $x+2, $y+2, $this->colors[$seriesname]);
+ ImageString($this->image, 1, $x - ($fwidth * log10($value) / 2), $y - ($fheight * 1.2), $value, $this->colors['values']);
+ if($lx[$seriesname] != 0)
+ {
+ ImageLine($this->image, $lx[$seriesname], $ly[$seriesname], $x, $y, $this->colors[$seriesname]);
+ }
+ else
+ {
+ ImageString($this->image, 1, $x + $fwidth, $y - ($fheight * .5), $seriesname, $this->colors[$seriesname]);
+ //ImageString($this->image, 1, $x + $series_index * $bar_width, $graph_rect[3] - ($fheight * 2), $seriesname, $this->colors[$seriesname]);
+ }
+ $lx[$seriesname] = $x;
+ $ly[$seriesname] = $y;
+ break;
+ }
+
+ $series_index ++;
+ }
+
+ $x = $x_spot * $graph_inc + $graph_rect[0] - ($fheight / 2);
+ $y = min($graph_rect[3] + $fwidth * strlen($label), $this->height);
+ ImageStringUp($this->image, 1, $x, $y + $fwidth /2, $label, $this->colors['black']);
+ $x_spot ++;
+ }
+ }
+
+ function Output()
+ {
+ $this->Build();
+ if(function_exists('ImageGif'))
+ {
+ Header("Content-type: image/gif");
+ ImageGif($this->image);
+ }
+ else
+ {
+ Header("Content-type: image/jpeg");
+ ImageJpeg($this->image);
+ }
+ }
+}
+
+?>
+<?php
+
+class BAS_grapher extends BAS_graph
+{
+
+
+ function BAS_grapher($graph)
+ {
+ BAS_graph::BAS_graph();
+
+ global $user_level;
+ get_currentuserinfo();
+
+ // Authorize the user to operate this page solo
+ if($user_level == 0)
+ {
+ die("Unauthorized.");
+ }
+
+ $this->do_graph($graph);
+ }
+
+ function do_graph($graph)
+ {
+ global $basp, $wpdb;
+
+ $reports = $basp->get_reports();
+
+ $report = $reports[$graph];
+
+ $rangeset = isset($_GET['rangeset']) ? $_GET['rangeset'] : 'ten_minutes';
+ list($start, $end) = $basp->get_range($rangeset);
+ $stamp = '';
+ $lasthere = '';
+ $_starttext = '';
+ $_endtext = '';
+ $limit = isset($_GET['limit']) ? $_GET['limit'] : '10';
+ if($start != false)
+ {
+ $_starttext = "'" . date('Y-m-d H:i:s', $start) . "'";
+ $stamp .= " AND stamp >= '" . date('Y-m-d H:i:s', $start) . "'";
+ $lasthere .= " AND lasthere >= '" . date('Y-m-d H:i:s', $start) . "'";
+ }
+ if($end != false)
+ {
+ $_endtext = "'" . date('Y-m-d H:i:s', $end) . "'";
+ $stamp .= " AND stamp <= '" . date('Y-m-d H:i:s', $end) . "'";
+ $lasthere .= " AND lasthere <= '" . date('Y-m-d H:i:s', $end) . "'";
+ }
+ $_stamp = $stamp;
+ $_lasthere = $lasthere;
+ //Range increments
+ $timespan = $end - $start;
+
+ if($timespan > 60*60*24*365*2) { //1 year
+ $_grouping = "DATE_FORMAT(stamp, '%Y')";
+ $_ordering = "DATE_FORMAT(stamp, '%Y')";
+ $_datechunk = "'%Y'";
+ }
+ elseif($timespan > 60*60*24*31) { //1 month
+ $_grouping = "DATE_FORMAT(stamp, '%Y-%m')";
+ $_ordering = "DATE_FORMAT(stamp, '%Y-%m')";
+ $_datechunk = "'%Y-%m'";
+ }
+ elseif($timespan > 60*60*24) { //1 day
+ $_grouping = "DATE_FORMAT(stamp, '%Y-%m-%d')";
+ $_ordering = "DATE_FORMAT(stamp, '%Y-%m-%d')";
+ $_datechunk = "'%Y-%m-%d'";
+ }
+ elseif($timespan > 60*60) { //1 hour
+ $_grouping = "DATE_FORMAT(stamp, '%Y-%m-%d %H')";
+ $_ordering = "DATE_FORMAT(stamp, '%Y-%m-%d %H')";
+ $_datechunk = "'%Y-%m-%d %H'";
+ }
+ elseif($timespan > 60) { //1 minute
+ $_grouping = "DATE_FORMAT(stamp, '%Y-%m-%d %H:%i')";
+ $_ordering = "DATE_FORMAT(stamp, '%Y-%m-%d %H:%i')";
+ $_datechunk = "'%Y-%m-%d %H:%i'";
+ }
+ else {
+ $_grouping = "DATE_FORMAT(stamp, '%Y-%m-%d')";
+ $_ordering = "DATE_FORMAT(stamp, '%Y-%m-%d')";
+ $_datechunk = "'%Y-%m-%d'";
+ }
+
+
+ $query = $report['series'];
+ $qry = preg_replace('/{([^}]+)}/e', '\$\1', $query);
+ $data = $wpdb->get_results($qry);
+
+ $series_filter = create_function('$row', $report['label_filter']);
+
+
+
+ $newcolor = 0;
+ if($data)
+ {
+ foreach($data as $s_data)
+ {
+ $series_index = $s_data->$report['series_index'];
+ $series_caption = $series_index . ':' . $series_filter($s_data->$report['series_label']);
+ $qresult = '';
+
+ foreach($report['data'] as $query)
+ {
+ if(($query != $report['data'][0]) && is_array($qresult))
+ {
+ extract($qresult[0]);
+ }
+ //$qry = preg_replace_callback('/{([^}]+)}/e', 'graph_query', $query);
+ $qry = preg_replace('/{([^}]+)}/e', 'substr(\'\1\', 0, 1)!=\'_\'?addslashes(\$\1):\$\1', $query);
+ //$qry = preg_replace('/{([^}]+)}/e', '\$\1', $query);
+ $qresult = $wpdb->get_results($qry);
+ }
+ if($qresult)
+ {
+ foreach($qresult as $res)
+ {
+ $this->xlabels[$res->Label] = $res->Label;
+ $series[$res->Label] = $res->Count;
+ }
+ }
+ else
+ {
+ die('No Results: ' . $qry);
+ }
+
+ $this->AddSeries($series_caption, $series);
+ $this->SetColor($series_caption, $basp->get_color($newcolor, count($data)));
+ $newcolor++;
+ }
+ }
+
+ /*
+ // TEST DATA //
+ $this->xlabels = array('2005-02-16'=>'2005-02-16', '2005-02-17'=>'2005-02-17', '2005-02-18'=>'2005-02-18');
+ $this->AddSeries('test', array('2005-02-16'=>10, '2005-02-17'=>35, '2005-02-18'=>13));
+ $this->SetColor('test', $colors[0]);
+ */
+
+ //$g->graphtype = 'line';
+ $this->Build();
+ //owd($g->series);
+ $this->output();
+ }
+}
+
+
+function include_up($filename)
+{
+ $c=0;
+ while(!is_file($filename))
+ {
+ $filename = '../' . $filename;
+ $c++;
+ if($c==30) {
+ echo 'Could not find ' . basename($filename) . '.';
+ return '';
+ }
+ }
+ return $filename;
+}
+
+function owd($v)
+{
+ echo "<pre>".print_r($v,1)."</pre>";
+}
+
+require_once(include_up('wp-config.php'));
+require_once("BAStats.php");
+
+$g = new BAS_grapher($_GET['graph']);
+?> \ No newline at end of file
diff --git a/wp-inst/wp-content/plugins/BAStats/BAStats_logger.php b/wp-inst/wp-content/plugins/BAStats/BAStats_logger.php
new file mode 100644
index 0000000..8db8ae6
--- /dev/null
+++ b/wp-inst/wp-content/plugins/BAStats/BAStats_logger.php
@@ -0,0 +1,310 @@
+<?php
+
+/*
+Version: 1.0&beta; build 8
+
+BAStats - Calculates statistics for a WordPress weblog.
+Copyright (c) 2004 Owen Winkler
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to
+do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall
+be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+class BAStats
+{
+
+ function BAStats_logger()
+ {
+ global $wpdb;
+
+
+ }
+
+ function log($label = '')
+ {
+ global $wpdb, $table_prefix;
+
+ $create_session = false;
+
+ //Find user session
+ if(isset($_COOKIE['basp']))
+ {
+ $sid = $_COOKIE['basp'];
+ $sdata = $wpdb->get_row("SELECT * FROM {$wpdb->visitors}, {$wpdb->refer}, {$wpdb->ua}, {$wpdb->os} WHERE visit_id = {$sid} AND referer = referer_id AND osystem = os_id AND useragent = ua_id");
+ if(!$sdata) $create_session = true;
+ }
+ elseif($sdata = $wpdb->get_row("SELECT * FROM {$wpdb->visitors}, {$wpdb->refer}, {$wpdb->ua}, {$wpdb->os} WHERE referer = referer_id AND osystem = os_id AND useragent = ua_id AND lasthere > DATE_SUB(NOW(), INTERVAL 20 MINUTE) AND visit_ip = " . ip2long($_SERVER['REMOTE_ADDR']) . " AND ua_string = '" . addslashes($_SERVER['HTTP_USER_AGENT']) . "' ORDER BY lasthere DESC LIMIT 1"))
+ {
+ $sid = $sdata->visit_id;
+ }
+ elseif(strpos($_SERVER['HTTP_REFERER'], get_settings('site_url')) && ($sdata = $wpdb->get_row("SELECT * FROM {$wpdb->visitors}, {$wpdb->refer}, {$wpdb->ua}, {$wpdb->os} WHERE referer = referer_id AND osystem = os_id AND useragent = ua_id AND visit_ip = " . ip2long($_SERVER['REMOTE_ADDR']) . " AND ua_string = '" . addslashes($_SERVER['HTTP_USER_AGENT']) . "' ORDER BY lasthere DESC LIMIT 1")))
+ {
+ $sid = $sdata->visit_id;
+ }
+ else
+ {
+ $create_session = true;
+ }
+ if($create_session)
+ {
+ //Create new session
+ $refer_id = $wpdb->get_var("SELECT referer_id FROM {$wpdb->refer} WHERE referer_string = '" . addslashes($_SERVER['HTTP_REFERER']) . "';");
+ if($refer_id == '')
+ {
+ $wpdb->query("INSERT INTO {$wpdb->refer} (referer_string) VALUES ('" . addslashes($_SERVER['HTTP_REFERER']) . "');");
+ $refer_id =$wpdb->insert_id;
+ }
+ $os_id = $wpdb->get_var("SELECT os_id FROM {$wpdb->os} WHERE os_string = '" . addslashes(BAStats::OSMap($_SERVER['HTTP_USER_AGENT'])) . "';");
+ if($os_id == '')
+ {
+ $wpdb->query("INSERT INTO {$wpdb->os} (os_string) VALUES ('" . addslashes(BAStats::OSMap($_SERVER['HTTP_USER_AGENT'])) . "');");
+ $os_id = $wpdb->insert_id;
+ }
+ $ua_id = $wpdb->get_var("SELECT ua_id FROM {$wpdb->ua} WHERE ua_string = '" . addslashes($_SERVER['HTTP_USER_AGENT']) . "';");
+ if($ua_id == '')
+ {
+ $wpdb->query("INSERT INTO {$wpdb->ua} (ua_string) VALUES ('" . addslashes($_SERVER['HTTP_USER_AGENT']) . "');");
+ $ua_id = $wpdb->insert_id;
+ }
+ $qry = "INSERT INTO {$wpdb->visitors} (visit_ip, referer, osystem, useragent, lasthere) VALUES (";
+ $qry .= ip2long($_SERVER['REMOTE_ADDR']);
+ $qry .= ", " . $refer_id;
+ $qry .= ", " . $os_id;
+ $qry .= ", " . $ua_id;
+ $qry .= ", '" . date('Y-m-d H:i:s') . "'";
+ $qry .= ");";
+ $wpdb->query($qry);
+ $sid = $wpdb->insert_id;
+ $sdata = $wpdb->get_row("SELECT * FROM {$wpdb->visitors}, {$wpdb->refer}, {$wpdb->ua}, {$wpdb->os} WHERE visit_id = {$sid} AND referer = referer_id AND osystem = os_id AND useragent = ua_id");
+ }
+ setcookie('basp', $sid, time()+60*20, '/');
+
+ $page_string = '';
+ $permalink = '';
+ BAStats::getPageString($page_string, $permalink);
+
+ $page = $wpdb->get_row("SELECT * FROM {$wpdb->pages} WHERE page_string = '" . addslashes($page_string) . "';");
+ if(!$page)
+ {
+ $wpdb->query("INSERT INTO {$wpdb->pages} (page_string, permalink, page_label) VALUES ('" . addslashes($page_string) . "', '" . addslashes($permalink) . "', '" . addslashes($label) . "');");
+ $page = $wpdb->get_row("SELECT * FROM {$wpdb->pages} WHERE page_string = '" . addslashes($page_string) . "';");
+ }
+
+ $options = get_settings('bas_options');
+ $settings = get_settings('bas_settings');
+ if(in_array('log_spam', $options) && in_array('referer_spam', $settings))
+ {
+ $logok = true;
+ $badlist = explode("\n", $settings['referer_spam']);
+ foreach($badlist as $entry)
+ {
+ if(isset($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'], $entry) !== false)
+ {
+ $logok = false;
+ break;
+ }
+ }
+ }
+ else
+ {
+ $logok = true;
+ }
+
+ if($logok)
+ {
+ BAStats::log_search($_SERVER['HTTP_REFERER'], $sdata->referer);
+
+ if($page->page_id != '')
+ {
+ $wpdb->query("INSERT INTO {$wpdb->log} (visit, stamp, outbound, page) VALUES ({$sid}, '" . date('Y-m-d H:i:s') . "', 0, {$page->page_id});");
+ }
+ }
+ else
+ {
+ if(in_array('die_spam', $options))
+ {
+ die('Sorry. Your referral domain is in a spam wordlist, and may not view this site.');
+ }
+ }
+
+ /*echo "<pre>";
+ print_r($sid);
+ print_r($sdata);
+ print_r($page);
+ echo "<br/>{$wpdb->last_query}";
+ echo "</pre>";*/
+ }
+
+ function getPageString(&$page_string, &$permalink)
+ {
+ if(isset($_SERVER['HTTP_X_REWRITE_URL']))
+ {
+ $page_string = $_SERVER['HTTP_X_REWRITE_URL'];
+ $permalink = $_SERVER['REQUEST_URI'];
+ }
+ elseif(isset($_SERVER['ORIG_PATH_INFO']))
+ {
+ $page_string = $_SERVER['ORIG_PATH_INFO'];
+ $permalink = $_SERVER['ORIG_PATH_INFO'];
+ }
+ else
+ {
+ $page_string = $_SERVER['REQUEST_URI'];
+ $permalink = $_SERVER['REQUEST_URI'];
+ }
+ }
+
+ function label($label = '')
+ {
+ global $wpdb;
+ $page_string = '';
+ $permalink = '';
+ BAStats::getPageString($page_string, $permalink);
+ if($label != '') $wpdb->query("UPDATE {$wpdb->pages} SET page_label = '" . addslashes($label) . "' WHERE page_string = '" . addslashes($page_string) . "';");
+ }
+
+ function iptoint($ip)
+ {
+ return ip2long($ip);
+ }
+
+ function inttoip($int)
+ {
+ return long2ip($int);
+ }
+
+ function OSMap($ua)
+ {
+ $matches = array(
+ 'Win.*NT 5\.0'=>'Windows 2000',
+ 'Win.*NT 5.1'=>'Windows XP',
+ 'Win.*(XP|2000|ME|NT|9.?)'=>'Windows $1',
+ 'Windows .*(3\.11|NT)'=>'Windows $1',
+ 'Win32'=>'Windows [unknown version]',
+ 'Linux 2\.(.?)\.'=>'Linux 2.$1.x',
+ 'Linux'=>'Linux [unknown version]',
+ 'FreeBSD .*-CURRENT$'=>'FreeBSD -CURRENT',
+ 'FreeBSD (.?)\.'=>'FreeBSD $1.x',
+ 'NetBSD 1\.(.?)\.'=>'NetBSD 1.$1.x',
+ '(Free|Net|Open)BSD'=>'$1BSD [unknown version]',
+ 'HP-UX B\.(10|11)\.'=>'HP-UX B.$1.x',
+ 'IRIX(64)? 6\.'=>'IRIX 6.x',
+ 'SunOS 4\.1'=>'SunOS 4.1.x',
+ 'SunOS 5\.([4-6])'=>'Solaris 2.$1.x',
+ 'SunOS 5\.([78])'=>'Solaris $1.x',
+ 'Mac_PowerPC'=>'Mac OS [PowerPC]',
+ 'Mac'=>'Mac OS',
+ 'X11'=>'UNIX [unknown version]',
+ 'Unix'=>'UNIX [unknown version]',
+ 'BeOS'=>'BeOS [unknown version]',
+ 'QNX'=>'QNX [unknown version]',
+ );
+ $uas = array_map(create_function('$a', 'return "#.*$a.*#";'), array_keys($matches));
+ return preg_replace($uas, array_values($matches), $ua);
+ }
+
+ function BrowserMap($ua)
+ {
+ $matches = array(
+ '^Mozilla/\d+\.\d+ \(compatible; iCab ([^;]); ([^;]); [NUI]; ([^;])\)'=>'iCab $1',
+ '^Opera/(\d+\.\d+) \(([^;]+); [^)]+\)'=>'Opera $1',
+ '^Mozilla/\d+\.\d+ \(compatible; MSIE [^;]+; ([^)]+)\) Opera (\d+\.\d+)'=>'Opera $2',
+ '^Mozilla/\d+\.\d+ \(([^;]+); [^)]+\) Opera (\d+\.\d+)'=>'Opera $2',
+ '^Mozilla/[1-9]\.0 ?\(compatible; MSIE ([1-9]\.[0-9b]+);(?: ?[^;]+;)*? (Mac_[^;)]+|Windows [^;)]+)(?:; [^;]+)*\)'=>'MSIE $1',
+ '^Mozilla/\d+\.\d+ \([^;]+; [NIU]; ([^;]+); [^;]+; Galeon\) Gecko/\d{8}$'=>'Galeon',
+ '^Mozilla/\d+\.\d+ \([^;]+; [NIU]; Galeon; [^;]+; ([^;)]+)\)$'=>'Galeon $1',
+ '^Mozilla/\d+\.\d+ Galeon/([0-9.]+) \(([^;)]+)\) Gecko/\d{8}$'=>'Galeon $1',
+ '^Mozilla/\d+\.\d+ \([^;]+; [NIU]; ([^;]+); [^;]+; rv:[^;]+(?:; [^;]+)*\) Gecko/\d{8} ([a-zA-Z ]+/[0-9.b]+)'=>'$2',
+ '^Mozilla/\d+\.\d+ \([^;]+; [NIU]; ([^;]+); [^;]+; rv:([^;]+)(?:; [^;]+)*\) Gecko/\d{8}$'=>'Mozilla $2',
+ '^Mozilla/\d+\.\d+ \([^;]+; [NIU]; ([^;]+); [^;]+; (m\d+)(?:; [^;]+)*\) Gecko/\d{8}$'=>'Mozilla $2',
+ '^Mozilla/\d+\.\d+ \([^;]+; [NIU]; ([^;]+)(?:; [^;]+)*\) Mozilla/(.+)$'=>'Mozilla $2',
+ '^Mozilla/4\.(\d+)[^(]+\(X11; [NIU] ?; ([^;]+)(?:; [^;]+)*\)'=>'Netscape 4.$1',
+ '^Mozilla/4\.(\d+)[^(]+\((OS/2|Linux|Macintosh|Win[^;]*)[;,] [NUI] ?[^)]*\)'=>'Netscape 4.$1',
+ '^Mozilla/3\.(\d+)\S*[^(]+\(X11; [NIU] ?; ([^;]+)(?:; [^;)]+)*\)'=>'Netscape 3.$1',
+ '^Mozilla/3\.(\d+)\S*[^(]+\(([^;]+); [NIU] ?(?:; [^;)]+)*\)'=>'Netscape 3.$1',
+ '^Mozilla/2\.(\d+)\S*[^(]+\(([^;]+); [NIU] ?(?:; [^;)]+)*\)'=>'Netscape 2.$1',
+ '^Mozilla \(X11; [NIU] ?; ([^;)]+)\)'=>'Netscape',
+ '^Mozilla/3.0 \(compatible; StarOffice/(\d+)\.\d+; ([^)]+)\)$'=>'StarOffice $1',
+ '^ELinks \((.+); (.+); .+\)$'=>'ELinks $1',
+ '^Mozilla/3\.0 \(compatible; NetPositive/([0-9.]+); BeOS\)$'=>'NetPositive $1',
+ '^Konqueror/(\S+)$'=>'Konqueror $1',
+ '^Mozilla/5\.0 \(compatible; Konqueror/([^;]); ([^)]+)\).*$'=>'Konqueror $1',
+ '^Lynx/(\S+)'=>'Lynx/$1',
+ '^Mozilla/4.0 WebTV/(\d+\.\d+) \(compatible; MSIE 4.0\)$'=>'WebTV $1',
+ '^Mozilla/4.0 \(compatible; MSIE 5.0; (Win98 A); (ATHMWWW1.1); MSOCD;\)$'=>'$2',
+ '^(RMA/1.0) \(compatible; RealMedia\)$'=>'$1',
+ '^antibot\D+([0-9.]+)/(\S+)'=>'antibot $1',
+ '^Mozilla/[1-9]\.\d+ \(compatible; ([^;]+); ([^)]+)\)$'=>'$1',
+ '^Mozilla/([1-9]\.\d+)'=>'compatible Mozilla/$1',
+ '\bmsnbot/([0-9.]+)'=>'MSN Search Bot $1',
+ '^Mozilla/\d+\.\d+ \(Macintosh; U; PPC Mac OS X; en\) AppleWebKit/\d+\.\d+ \(KHTML, like Gecko\) Safari/(\d+\.\d+)'=>'Safari $1',
+ '^([^;]+)$'=>'$1',
+ );
+ foreach($matches as $srch => $repl)
+ {
+ if(preg_match('#' . $srch . '#i', $ua, $m))
+ {
+ return preg_replace('/\$([0-9])/e', '"$m[\1]"', $repl);
+ }
+ }
+ return 'Unknown';
+ }
+
+ function search_engines()
+ {
+ $ret = array(
+ '/images\\.google(\\.[a-z]{2,3})+.*(\\?|&)prev=\/images%3Fq%3D(.+?)(%26.*|$)/i'=> array('Google Image Search', 3),
+ '/www\\.google(\\.[a-z]{2,3})+.*(\\?|&)q=([^&]+).*/i'=> array('Google Search', 3),
+ '/search\\.msn\\.com.*(\?|&)q=([^&]+).*/i'=>array('MSN Search', 2),
+ '/video\\.search\\.yahoo(\\.[a-z]{2,3})+.*(\\?|&)back=p%3D(.*?)(%26.*|$)/i'=>array('Yahoo Video Search', 3),
+ '/video\.search\.yahoo(\\.[a-z]{2,3}).*(\?|&)va=([^&]+).*/i'=>array('Yahoo Video Search', 3),
+ '/alltheweb\\.com.*(\?|&)q=([^&]+).*/i'=>array('AllTheWeb Search', 2),
+ '/search\.yahoo\.com.*(\?|&)p=([^&]+).*/i'=>array('Yahoo Search', 2),
+ '/web\.ask\.com.*(\?|&)ask=([^&]+).*/i'=>array('Ask Jeeves Search', 2),
+ '/aolsearch\.aol(\\.[a-z]{2,3})+.*(\?|&)query=([^&]+).*/i'=>array('AOL Search', 3),
+ '/www\.dogpile\.com.*\/([^\/]+)/i'=>array('Dogpile', 1),
+ '/www\\.mywebsearch\\.com.*(\\?|&)searchfor=(.+?)(&|$).*/i'=>array('MyWay', 2),
+ '/search\\.wanadoo(\\.[a-z]{2,3})+.*(\\?|&)q=(.+?)(&|$).*/i'=>array('Wanadoo', 3),
+ '/www\\.technorati\\.com\/tag\/(.*)/i'=>array('Technorati Tags', 1),
+ );
+ $ret['/' . get_settings('site_url') . '.*(\?|&)s=([^&]+).*/i'] = array('Local Search', 2);
+ return $ret;
+ }
+
+ function log_search($refer, $rid)
+ {
+ global $wpdb;
+
+ $engs = BAStats::search_engines();
+ foreach($engs as $keng => $eng)
+ {
+ if(preg_match($keng, $refer, $matches))
+ {
+ $wpdb->query("INSERT INTO {$wpdb->searches} (search_refer, search_phrase, search_engine) VALUES ({$rid}, '" . addslashes(urldecode($matches[$eng[1]])) . "', '" . addslashes($eng[0]) . "');");
+ break;
+ }
+ }
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-content/plugins/BAStats/BAStats_options.php b/wp-inst/wp-content/plugins/BAStats/BAStats_options.php
new file mode 100644
index 0000000..c6c7606
--- /dev/null
+++ b/wp-inst/wp-content/plugins/BAStats/BAStats_options.php
@@ -0,0 +1,171 @@
+<?php
+/*
+Version: 1.0&beta; build 8
+
+BAStats - calculates statistics for a WordPress weblog.
+Copyright (c) 2004 Owen Winkler
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to
+do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall
+be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+
+global $wpdb;
+
+function check_option($opt)
+{
+ $settings = get_settings('bas_options');
+ if(in_array($opt, $settings)) echo ' checked="checked"';
+}
+
+$default_options = array();
+$default_settings = array (
+ 'referer_spam' => "nutzu.com",
+);
+
+switch($_POST['action'])
+{
+case 'label':
+ $wpdb->query("UPDATE {$wpdb->pages} SET page_label = '{$_POST['Label']}' WHERE page_string = '{$_POST['URI']}';");
+ $result = "Added Label '{$_POST['Label']}' to URI '{$_POST['URI']}'";
+ break;
+case 'options':
+ update_option('bas_options', $_POST['bas_options']);
+ update_option('bas_settings', $_POST['bas_settings']);
+ break;
+case 'purge':
+ switch($_POST['range'])
+ {
+ case 'all':
+ $wpdb->query('TRUNCATE {$wpdb->visitors};');
+ $wpdb->query('TRUNCATE {$wpdb->refer};');
+ $wpdb->query('TRUNCATE {$wpdb->os};');
+ $wpdb->query('TRUNCATE {$wpdb->ua};');
+ $wpdb->query('TRUNCATE {$wpdb->log};');
+ $wpdb->query('TRUNCATE {$wpdb->pages};');
+ $wpdb->query('TRUNCATE {$wpdb->searches};');
+ $result = "Purged all stats.";
+ break;
+ case 'hits':
+ $wpdb->query('TRUNCATE {$wpdb->log};');
+ $result = "Purged all hits.";
+ break;
+ case 'oldhits':
+ $monthago = date('Y-m-d', time()-60*60*24*30);
+ $wpdb->query("DELETE FROM {$wpdb->log} WHERE stamp < '{$monthago}';");
+ $result = "Purged all hits older than 30 days.";
+ break;
+ }
+default:
+ add_option('bas_options', $default_options);
+ add_option('bas_settings', $default_settings);
+}
+
+$options = get_settings('bas_options');
+$settings = get_settings('bas_settings');
+
+if($result != '')
+{
+ echo "<div class=\"updated\"><p>{$result}</p></div>";
+}
+?>
+
+<div class="wrap">
+<form method="post">
+<input type="hidden" name="action" value="options" />
+<h2>BA Stats Options</h2>
+<p>Set the options below according to your loggin preferences, then click Update Options to commit your choices.</p>
+
+<h3>Basic Tracking Options</h3>
+
+<ul>
+ <li>
+ <label><input type="checkbox" name="bas_options[]" value="log_admins" <?php check_option('log_admins'); ?>/> Track page hits for logged in WordPress users of level 8+.</label>
+ </li>
+ <li>
+ <label><input type="checkbox" name="bas_options[]" value="log_console" <?php check_option('log_console'); ?>/> Track page hits for the WordPress admin console pages.</label>
+ </li>
+ <li>
+ <label><input type="checkbox" name="bas_options[]" value="log_content" <?php check_option('log_content'); ?>/> Track page hits for <code>/wp-content/</code> area.</label>
+ </li>
+ <li>
+ <?php
+ $serveraddr = $_SERVER['LOCAL_ADDR'];
+ if($serveraddr == '') $serveraddr = $_SERVER['SERVER_ADDR'];
+ ?>
+ <label><input type="checkbox" name="bas_options[]" value="log_self" <?php check_option('log_self'); ?>/> Track page hits from this site's IP address (<?php echo $serveraddr; ?> ).</label>
+ </li>
+</ul>
+
+<!-- hr style="border:0;color:#6699CC;height:1px;background-color:#6699CC;"/>
+<h3>Advanced File Tracking</h3>
+
+<ul>
+ <li>
+ <label><input type="checkbox" name="bas_options[]" value="log_images" <?php check_option('log_images'); ?>/> Track hits on local images (jpg, gif, png).</label>
+ </li>
+</ul -->
+
+
+<hr style="border:0;color:#6699CC;height:1px;background-color:#6699CC;"/>
+<h3>Referer Spam</h3>
+
+<p>Each of the following lines is indicative of referer spam when BAStats finds it anywhere in the referer header field:</p>
+<textarea name="bas_settings[referer_spam]" style="width:50%;height:5em;"><?php echo $settings['referer_spam']; ?></textarea>
+<p>What to do about referer spam:</p>
+<ul>
+ <li><label><input type="checkbox" name="bas_options[]" value="log_spam" <?php check_option('log_spam'); ?>/> Don't log referers that match the spam entries.</label></li>
+ <li><label><input type="checkbox" name="bas_options[]" value="die_spam" <?php check_option('die_spam'); ?>/> Immediately stop further script processing of requests that match the spam list.</label></li>
+</ul>
+<p class="submit"><input type="submit" value="Update Options"></p>
+</form>
+</div>
+
+<div class="wrap">
+<h2>Label Page</h2>
+<p>Submit the values in this form to provide a recognizable label for a page that typically appears only as a URI.</p>
+<p>For example, you might want to label the page <code>/index.php</code> as "<code>Home Page</code>".</p>
+<form method="post">
+<input type="hidden" name="action" value="label" />
+<label for="label_URI">URI to label: <input type="text" id="label_URI" name="URI" /></label>
+<label for="label_text">Label to use: <input type="text" id="label_text" name="Label" /></label>
+<p class="submit"><input type="submit" value="Apply Label"></p>
+</form>
+</div>
+
+<div class="wrap">
+<h2>Clear Stats</h2>
+<p>Submit this form to purge old stats from your stats tables.</p>
+<p>Select the action that best suits your needs from the dropdown, then click Purge.</p>
+<form method="post" onsubmit="return confirm('Are you sure you want to perform this action on your stats? It can't be undone.');>
+<input type="hidden" name="action" value="purge" />
+<label>Action:
+<select name="range">
+<option value="">Choose one</option>
+<option value="all" style="background-color:red;color:white;font-weight:bold;">Purge All Stats</option>
+<option value="hits">Purge Only Hits</option>
+<option value="oldhits">Purge Only Hits Older Than 30 Days</option>
+</select>
+</label>
+<p class="submit"><input type="submit" value="Purge"></p>
+</form>
+</div> \ No newline at end of file
diff --git a/wp-inst/wp-content/plugins/BAStats/BAStats_reports.php b/wp-inst/wp-content/plugins/BAStats/BAStats_reports.php
new file mode 100644
index 0000000..a1e4744
--- /dev/null
+++ b/wp-inst/wp-content/plugins/BAStats/BAStats_reports.php
@@ -0,0 +1,330 @@
+<?php
+/*
+Version: 1.0&beta; build 8
+
+BAStats - calculates statistics for a WordPress weblog.
+Copyright (c) 2004 Owen Winkler
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to
+do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall
+be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+
+$reports = array(
+ // Each element of the $reports array is an array describing a single report.
+ // Each element of the $reports array must have a unique key.
+ 'top_page_hits'=> array (
+ //The 'title' key is the name that appears in the report dropdown
+ 'title'=>'Top Page Hits',
+ //The 'report_type' key can be 'table' or 'graph', depending on what it displays.
+ 'report_type'=>'table',
+ //The 'query' key contains an array of queries to execute in order
+ //to retrieve the report data.
+ //{stamp} is replaced with the date range selected in the UI.
+ //{qrylimit} is replaced with the limit setting from the UI.
+ 'queries'=> array(
+ "SELECT *, count(page_id) AS `Count` FROM {$wpdb->pages}, {$wpdb->log} WHERE page = page_id {stamp} GROUP BY page_id ORDER BY `Count` DESC {qrylimit}",
+ ),
+ //The 'columns' key contains an array of 'Column Caption'=>'field_from_query' values.
+ 'columns'=>array('Page'=>'page_string', 'Count'=>'Count'),
+ //The 'column_filter' key contains an array of filters indexed by column caption.
+ //For the values in that column, instead of the raw data value, the filter is applied
+ //to the value of $row, which contains the row data from the query for that result row.
+ 'column_filter'=>array(
+ 'Page'=>'return ($row["page_label"] == \'\') ? "<a href=\"{$row[\'page_string\']}\">{$row[\'page_string\']}</a>" : "<a href=\"{$row[\'page_string\']}\" style=\"font-weight:bold;\">{$row[\'page_label\']}</a><br><div style=\"font-size:xx-small;text-indent:3em;\">{$row[\'page_string\']}</div>";',
+ )
+ ),
+ 'top_page_hits_referer'=> array (
+ 'title'=>'Top Page Hits From Referrer',
+ 'report_type'=>'table',
+ 'filters'=>array('referer'),
+ 'queries'=> array(
+ "SELECT *, count(page_id) AS `Count` FROM {$wpdb->pages}, {$wpdb->log}, {$wpdb->visitors} WHERE visit = visit_id AND page = page_id AND referer = {filt_crit} {stamp} GROUP BY page_id ORDER BY `Count` DESC {qrylimit}",
+ ),
+ 'columns'=>array('Page'=>'page_string', 'Count'=>'Count'),
+ 'column_filter'=>array(
+ 'Page'=>'return ($row["page_label"] == \'\') ? "<a href=\"{$row[\'page_string\']}\">{$row[\'page_string\']}</a>" : "<a href=\"{$row[\'page_string\']}\" style=\"font-weight:bold;\">{$row[\'page_label\']}</a><br><div style=\"font-size:xx-small;text-indent:3em;\">{$row[\'page_string\']}</div>";',
+ )
+ ),
+ 'top_page_hits_host'=> array (
+ 'title'=>'Top Page Hits From %s',
+ 'report_type'=>'table',
+ 'filters'=>array('host'),
+ 'queries'=>array(
+ "SELECT *, count(page_id) AS `Count` FROM {$wpdb->pages}, {$wpdb->log}, {$wpdb->visitors} WHERE page = page_id AND visit= visit_id AND visit_ip = {filt_crit} {stamp} GROUP BY page_id ORDER BY `Count` DESC {qrylimit}",
+ ),
+ 'columns'=>array('Page'=>'page_string', 'Count'=>'Count'),
+ 'column_filter'=>array(
+ 'Page'=>'return ($row["page_label"] == \'\') ? "<a href=\"{$row[\'page_string\']}\">{$row[\'page_string\']}</a>" : "<a href=\"{$row[\'page_string\']}\" style=\"font-weight:bold;\">{$row[\'page_label\']}</a><br><div style=\"font-size:xx-small;text-indent:3em;\">{$row[\'page_string\']}</div>";',
+ )
+ ),
+ 'top_hosts'=> array (
+ 'title'=>'Top Hosts',
+ 'report_type'=>'table',
+ 'queries'=>array(
+ "SELECT *, count(visit_id) AS `Count` FROM {$wpdb->visitors}, {$wpdb->log} WHERE visit_id = visit {stamp} GROUP BY visit_ip ORDER BY `Count` DESC {qrylimit}",
+ ),
+ 'columns'=>array('Host IP'=>'visit_ip', 'Count'=>'Count'),
+ 'column_filter'=>array(
+ 'Host IP'=>'return "<a href=\"" . add_query_arg(array("filter"=>"host={$row[\'visit_ip\']}", "report"=>"host_profile"), $_SERVER[\'REQUEST_URI\']) . "\">" . long2ip($row[\'visit_ip\']) . "</a>";',
+ )
+ ),
+ 'top_refer'=> array (
+ 'title'=>'Top Referring Pages',
+ 'report_type'=>'table',
+ 'queries'=>array(
+ "SELECT *, count(visit_id) AS `Count` FROM {$wpdb->refer}, {$wpdb->visitors} WHERE referer_id = referer AND referer_string <> '' {lasthere} GROUP BY referer ORDER BY `Count` DESC {qrylimit}",
+ ),
+ 'columns'=>array('Referring Page'=>'referer_string', 'Count'=>'Count'),
+ 'column_filter'=>array(
+ 'Referring Page'=>'return "<a href=\"{$row[\'referer_string\']}\">" . substr(BASP::refer_replace($row[\'referer_string\']), 0, 100) . "</a>";',
+ 'Count'=>'return "<a href=\"" . add_query_arg(array("filter"=>"referer={$row[\'referer\']}", "report"=>"top_page_hits_referer"), $_SERVER[\'REQUEST_URI\']) . "\">{$row[\'Count\']}</a>";',
+ )
+ ),
+ 'top_refer_host'=> array (
+ 'title'=>'Top Referring Pages for %s',
+ 'report_type'=>'table',
+ 'filters'=>array('host'),
+ 'queries'=>array(
+ "SELECT *, count(visit_id) AS `Count` FROM {$wpdb->refer}, {$wpdb->visitors} WHERE referer_id = referer AND visit_ip = {filt_crit} {lasthere} GROUP BY referer ORDER BY `Count` DESC {qrylimit}",
+ ),
+ 'columns'=>array('Referring Page'=>'referer_string', 'Count'=>'Count'),
+ 'column_filter'=>array(
+ 'Referring Page'=>'return "<a href=\"{$row[\'referer_string\']}\">" . substr(BASP::refer_replace($row[\'referer_string\']), 0, 100) . "</a>";',
+ )
+ ),
+ 'top_os'=> array (
+ 'title'=>'Top Operating Systems',
+ 'report_type'=>'table',
+ 'queries'=>array(
+ "SELECT *, count(visit_id) AS `Count` FROM {$wpdb->os}, {$wpdb->visitors} WHERE os_id = osystem {lasthere} GROUP BY os_id ORDER BY `Count` DESC {qrylimit}",
+ ),
+ 'columns'=>array('Operating System'=>'os_string', 'Count'=>'Count'),
+ 'column_filter'=>array(
+ )
+ ),
+ 'top_ua'=> array (
+ 'title'=>'Top User Agents',
+ 'report_type'=>'table',
+ 'queries'=>array(
+ "SELECT *, count(ua_id) AS `Count` FROM {$wpdb->ua}, {$wpdb->visitors} WHERE ua_id = useragent {lasthere} GROUP BY ua_id ORDER BY `Count` DESC {qrylimit}",
+ ),
+ 'columns'=>array('User Agent'=>'ua_string', 'Count'=>'Count'),
+ 'column_filter'=>array(
+ 'User Agent'=>'return BAStats::BrowserMap($row["ua_string"]) . "<div style=\"font-size:xx-small;text-indent:3em;\">{$row["ua_string"]}</div>";',
+ )
+ ),
+ 'top_searches'=> array (
+ 'title'=>'Top Search Phrases',
+ 'report_type'=>'table',
+ 'queries'=>array(
+ "SELECT *, count(search_refer) AS `Count` FROM {$wpdb->searches}, {$wpdb->visitors}, {$wpdb->refer} WHERE search_refer = referer_id AND search_refer = referer AND referer_string <> '' {lasthere} GROUP BY search_refer ORDER BY `Count` DESC {qrylimit}",
+ ),
+ 'columns'=>array('Search Phrase'=>'search_phrase', 'Search Engine'=>'search_engine', 'Count'=>'Count'),
+ 'column_filter'=>array(
+ 'Search Phrase'=>'return "<a href=\"{$row[\'referer_string\']}\">{$row[\'search_phrase\']}</a>";',
+ 'Search Engine'=>'return "<a href=\"" . add_query_arg(array("filter"=>"search={$row[\'search_refer\']}", "report"=>"search_profile"), $_SERVER[\'REQUEST_URI\']) . "\">{$row[\'search_engine\']}</a>";',
+ )
+ ),
+
+ 'recent_page_hits'=> array (
+ 'title'=>'Recent Page Hits',
+ 'report_type'=>'table',
+ 'queries'=> array(
+ "SELECT * FROM {$wpdb->pages}, {$wpdb->log}, {$wpdb->visitors} WHERE page = page_id AND visit = visit_id {stamp} ORDER BY stamp DESC {qrylimit}",
+ ),
+ 'columns'=>array('Page'=>'page_string', 'Date'=>'stamp', 'Host IP'=>'visit_ip'),
+ 'column_filter'=>array(
+ 'Page'=>'return ($row["page_label"] == \'\') ? "<a href=\"{$row[\'page_string\']}\">{$row[\'page_string\']}</a>" : "<a href=\"{$row[\'page_string\']}\" style=\"font-weight:bold;\">{$row[\'page_label\']}</a><br><div style=\"font-size:xx-small;text-indent:3em;\">{$row[\'page_string\']}</div>";',
+ 'Host IP'=>'return "<a href=\"" . add_query_arg(array("filter"=>"host={$row[\'visit_ip\']}", "report"=>"host_profile"), $_SERVER[\'REQUEST_URI\']) . "\">" . long2ip($row[\'visit_ip\']) . "</a>";',
+ )
+ ),
+ 'recent_page_hits_host'=> array (
+ 'title'=>'Recent Page Hits From %s',
+ 'report_type'=>'table',
+ 'filters'=>array('host'),
+ 'queries'=>array(
+ "SELECT * FROM {$wpdb->pages}, {$wpdb->log}, {$wpdb->visitors} WHERE page = page_id AND visit= visit_id AND visit_ip = {filt_crit} {stamp} ORDER BY stamp DESC {qrylimit}",
+ ),
+ 'columns'=>array('Page'=>'page_string', 'Date'=>'stamp'),
+ 'column_filter'=>array(
+ 'Page'=>'return ($row["page_label"] == \'\') ? "<a href=\"{$row[\'page_string\']}\">{$row[\'page_string\']}</a>" : "<a href=\"{$row[\'page_string\']}\" style=\"font-weight:bold;\">{$row[\'page_label\']}</a><br><div style=\"font-size:xx-small;text-indent:3em;\">{$row[\'page_string\']}</div>";',
+ )
+ ),
+ 'recent_hosts'=> array (
+ 'title'=>'Recent Hosts',
+ 'report_type'=>'table',
+ 'queries'=>array(
+ "SELECT * FROM {$wpdb->visitors}, {$wpdb->log} WHERE visit_id = visit {stamp} ORDER BY stamp DESC {qrylimit}",
+ ),
+ 'columns'=>array('Host IP'=>'visit_ip', 'Date'=>'stamp'),
+ 'column_filter'=>array(
+ 'Host IP'=>'return "<a href=\"" . add_query_arg(array("filter"=>"host={$row[\'visit_ip\']}", "report"=>"host_profile"), $_SERVER[\'REQUEST_URI\']) . "\">" . long2ip($row[\'visit_ip\']) . "</a>";',
+ )
+ ),
+ /*
+ 'recent_refer'=> array (
+ 'title'=>'Recent Referring Pages',
+ 'report_type'=>'table',
+ 'queries'=>array(
+ "SELECT * FROM {$wpdb->refer}, {$wpdb->visitors} WHERE referer_id = referer AND referer_string <> '' {lasthere} ORDER BY lasthere DESC {qrylimit}",
+ ),
+ 'columns'=>array('Referring Page'=>'referer_string', 'Date'=>'lasthere'),
+ 'column_filter'=>array(
+ 'Referring Page'=>'return "<a href=\"{$row[\'referer_string\']}\">" . substr(BASP::refer_replace($row[\'referer_string\']), 0, 100) . "</a>";',
+ )
+ ),
+ */
+ /* New recet_refer report, thanks to Steve Smith @ www.orderedlist.com */
+ 'recent_refer'=> array (
+ 'title'=>'Recent Referring Pages',
+ 'report_type'=>'table',
+ 'queries'=>array(
+ "SELECT * FROM {$wpdb->refer}, {$wpdb->visitors}, {$wpdb->pages} right join {$wpdb->log} on visit_id = visit WHERE referer_id = referer AND referer_string <> '' {lasthere} and page_id = page group by visit ORDER BY lasthere desc, stamp {qrylimit}",
+ ),
+ 'columns'=>array('Referring Page'=>'referer_string', 'Page' => 'page_string', 'Date'=>'lasthere'),
+ 'column_filter'=>array(
+ 'Referring Page'=>'return "<a href=\"{$row[\'referer_string\']}\">" . substr(BASP::refer_replace($row[\'referer_string\']), 0, 100) . "</a>";',
+ 'Page'=>'return ($row["page_label"] == \'\') ? "<a href=\"{$row[\'page_string\']}\">{$row[\'page_string\']}</a>" : "<a href=\"{$row[\'page_string\']}\" style=\"font-weight:bold;\">{$row[\'page_label\']}</a><br><div style=\"font-size:xx-small;text-indent:3em;\">{$row[\'page_string\']}</ div>";',
+ )
+ ),
+ 'recent_os'=> array (
+ 'title'=>'Recent Operating Systems',
+ 'report_type'=>'table',
+ 'queries'=>array(
+ "SELECT * FROM {$wpdb->os}, {$wpdb->visitors} WHERE os_id = osystem {lasthere} ORDER BY lasthere DESC {qrylimit}",
+ ),
+ 'columns'=>array('Operating System'=>'os_string', 'Date'=>'lasthere'),
+ 'column_filter'=>array(
+ )
+ ),
+ 'recent_ua'=> array (
+ 'title'=>'Recent User Agents',
+ 'report_type'=>'table',
+ 'queries'=>array(
+ "SELECT * FROM {$wpdb->ua}, {$wpdb->visitors} WHERE ua_id = useragent {lasthere} ORDER BY lasthere DESC {qrylimit}",
+ ),
+ 'columns'=>array('User Agent'=>'ua_string', 'Date'=>'lasthere'),
+ 'column_filter'=>array(
+ 'User Agent'=>'return BAStats::BrowserMap($row["ua_string"]) . "<div style=\"font-size:xx-small;text-indent:3em;\">{$row["ua_string"]}</div>";',
+ )
+ ),
+ 'recent_searches'=> array (
+ 'title'=>'Recent Search Phrases',
+ 'report_type'=>'table',
+ 'queries'=>array(
+ "SELECT * FROM {$wpdb->searches}, {$wpdb->visitors}, {$wpdb->refer} WHERE referer_id = search_refer AND search_refer = referer AND referer_string <> '' {lasthere} ORDER BY lasthere DESC {qrylimit}",
+ ),
+ 'columns'=>array('Search Phrase'=>'search_phrase', 'Search Engine'=>'search_engine', 'Date'=>'lasthere'),
+ 'column_filter'=>array(
+ 'Search Phrase'=>'return "<a href=\"{$row[\'referer_string\']}\">{$row[\'search_phrase\']}</a>";',
+ 'Search Engine'=>'return "<a href=\"" . add_query_arg(array("filter"=>"search={$row[\'search_refer\']}", "report"=>"search_profile"), $_SERVER[\'REQUEST_URI\']) . "\">{$row[\'search_engine\']}</a>";',
+ )
+ ),
+
+ 'host_profile'=> array (
+ 'title'=>'Host Profile for %s',
+ 'report_type'=>'table',
+ 'filters'=>array('host'),
+ 'queries'=> array(
+ "SELECT * FROM {$wpdb->visitors}, {$wpdb->refer}, {$wpdb->ua} WHERE ua_id = useragent AND referer = referer_id AND visit_ip = {filt_crit} {lasthere} ORDER BY lasthere DESC {qrylimit}",
+ ),
+ 'columns'=>array('Host IP'=>'visit_ip', 'Date'=>'lasthere'),
+ 'column_filter'=>array(
+ 'Host IP'=>'return "<a href=\"" . add_query_arg(array("filter"=>"host={$row[\'visit_ip\']}", "report"=>"top_page_hits_host"), $_SERVER[\'REQUEST_URI\']) . "\">" . long2ip($row[\'visit_ip\']) . "</a>
+ <div style=\"font-size:xx-small;text-indent:3em;\">Referring Page: {$row["referer_string"]}</div>
+ <div style=\"font-size:xx-small;text-indent:3em;\">User Agent: {$row["ua_string"]}</div>
+ ";',
+ )
+ ),
+ 'search_profile'=> array (
+ 'title'=>'Search Results from %s',
+ 'report_type'=>'table',
+ 'filters'=>array('search'),
+ 'queries'=>array(
+ "SELECT DISTINCT search_engine FROM {$wpdb->searches} WHERE search_refer = {filt_crit}",
+ "SELECT * FROM {$wpdb->searches}, {$wpdb->visitors}, {$wpdb->refer} WHERE search_refer = referer_id AND search_refer = referer AND search_engine = '{search_engine}' {lasthere} ORDER BY lasthere DESC {qrylimit}",
+ ),
+ 'columns'=>array('Search Phrase'=>'search_phrase', 'Search Engine'=>'search_engine', 'Date'=>'lasthere'),
+ 'column_filter'=>array(
+ 'Search Phrase'=>'return "<a href=\"{$row[\'referer_string\']}\">{$row[\'search_phrase\']}</a>";',
+ )
+ ),
+
+ 'graph_top_hits_segment'=> array (
+ 'title'=>'Graph Top 5 Page Hits - Segmented',
+ 'report_type'=>'graph',
+ 'queries'=> array(
+ "SELECT *, count(page_id) AS `Count` FROM {$wpdb->pages}, {$wpdb->log} WHERE page = page_id {stamp} GROUP BY page_id ORDER BY `Count` DESC {qrylimit}",
+ ),
+ 'columns'=>array('Page'=>'page_string', 'Count'=>'Count'),
+ 'column_filter'=>array(
+ 'Page'=>'return ($row["page_label"] == \'\') ? "<a href=\"{$row[\'page_string\']}\">{$row[\'page_string\']}</a>" : "<a href=\"{$row[\'page_string\']}\" style=\"font-weight:bold;\">{$row[\'page_label\']}</a><br><div style=\"font-size:xx-small;text-indent:3em;\">{$row[\'page_string\']}</div>";',
+ ),
+ 'series'=>"SELECT *, count(page_id) AS `Count` FROM {$wpdb->pages}, {$wpdb->log} WHERE page = page_id {stamp} GROUP BY page_id ORDER BY `Count` DESC LIMIT 5",
+ 'series_index'=>'page_id',
+ 'series_label'=>'page_string',
+ 'label_filter'=>'return ($row->page_label == \'\') ? "<a href=\"{$row->page_string}\">{$row->page_string}</a>" : "<a href=\"{$row->page_string}\" style=\"font-weight:bold;\">{$row->page_label}</a><br><div style=\"font-size:xx-small;text-indent:3em;\">{$row->page_string}</div>";',
+ 'data'=> array(
+ "SELECT {_grouping} AS Label, count(page_id) AS `Count` FROM {$wpdb->pages}, {$wpdb->log} WHERE page = page_id AND page_id = {series_index} {_stamp} GROUP BY {_grouping} ORDER BY {_ordering}",
+ ),
+ ),
+ 'graph_top_hits'=> array (
+ 'title'=>'Graph Top Page Hits',
+ 'report_type'=>'graph',
+ 'queries'=> array(
+ "SELECT *, count(page_id) AS `Count` FROM {$wpdb->pages}, {$wpdb->log} WHERE page = page_id {stamp} GROUP BY page_id ORDER BY `Count` DESC {qrylimit}",
+ ),
+ 'columns'=>array('Page'=>'page_string', 'Count'=>'Count'),
+ 'column_filter'=>array(
+ 'Page'=>'return ($row["page_label"] == \'\') ? "<a href=\"{$row[\'page_string\']}\">{$row[\'page_string\']}</a>" : "<a href=\"{$row[\'page_string\']}\" style=\"font-weight:bold;\">{$row[\'page_label\']}</a><br><div style=\"font-size:xx-small;text-indent:3em;\">{$row[\'page_string\']}</div>";',
+ ),
+ 'series'=>"SELECT page_id, page_string, page_label, count(page_id) AS `Count` FROM {$wpdb->pages}, {$wpdb->log} WHERE page = page_id {stamp} GROUP BY page_id ORDER BY `Count` DESC LIMIT {limit}",
+ 'series_index'=>'page_id',
+ 'series_label'=>'page_string',
+ 'label_filter'=>'return ($row->page_label == \'\') ? "<a href=\"{$row->page_string}\">{$row->page_string}</a>" : "<a href=\"{$row->page_string}\" style=\"font-weight:bold;\">{$row->page_label}</a><br><div style=\"font-size:xx-small;text-indent:3em;\">{$row->page_string}</div>";',
+ 'data'=> array(
+ "SELECT count(page_id) AS `Count` FROM {$wpdb->pages}, {$wpdb->log} WHERE page = page_id AND page_id = {series_index} {_stamp} ORDER BY {_ordering}",
+ ),
+ ),
+ /*
+ // Spam Graph not ready for primetime. :(
+ 'graph_spam'=> array (
+ 'title'=>'Graph Spam Frequency',
+ 'report_type'=>'graph',
+ 'queries'=> array(
+ "SELECT count(comment_id) AS `Spam` FROM {$wpdb->comments} WHERE comment_approved='spam' {_stamp};",
+ ),
+ 'columns'=>array('Spam Comments'=>'Spam'),
+ 'column_filter'=>array(
+ ),
+ 'series'=>"SELECT 'Spam Comments' as Spam",
+ 'series_index'=>'Spam',
+ 'series_label'=>'Spam',
+ 'label_filter'=>'return "Spam Comments";',
+ 'data'=> array(
+ "SELECT DATE_FORMAT(comment_date, '%Y-%m-%d %H:%i') AS Label, count(comment_id) AS `Count` FROM {$wpdb->comments} WHERE comment_approved='spam' AND comment_date >= {_starttext} AND comment_date <= {_endtext} GROUP BY DATE_FORMAT(comment_date, '%Y-%m-%d %H:%i') ORDER BY DATE_FORMAT(comment_date, {_datechunk})",
+ ),
+ ),
+ */
+);
+?> \ No newline at end of file
diff --git a/wp-inst/wp-content/plugins/hello.php b/wp-inst/wp-content/plugins/hello.php
new file mode 100644
index 0000000..3eee83f
--- /dev/null
+++ b/wp-inst/wp-content/plugins/hello.php
@@ -0,0 +1,73 @@
+<?php
+/*
+Plugin Name: Hello Dolly
+Plugin URI: http://wordpress.org/#
+Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong. Hello, Dolly. This is, by the way, the world's first official WordPress plugin. When enabled you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.
+Author: Matt Mullenweg
+Version: 1.0
+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 "<p id='dolly'>$chosen</p>";
+}
+
+// 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 "
+ <style type='text/css'>
+ #dolly {
+ position: absolute;
+ top: 5px;
+margin: 0; padding: 0;
+ right: 3em;
+ font-size: 20px;
+ color: #666;
+ }
+ </style>
+ ";
+}
+
+add_action('admin_head', 'dolly_css');
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-content/plugins/jb_Recent_Comments_List.php b/wp-inst/wp-content/plugins/jb_Recent_Comments_List.php
new file mode 100644
index 0000000..2622b00
--- /dev/null
+++ b/wp-inst/wp-content/plugins/jb_Recent_Comments_List.php
@@ -0,0 +1,68 @@
+<?php
+
+/*
+Plugin Name: Recent Comments List
+Plugin URI: http://freepressblog.org/plugins/recentComments.html
+
+Description: This plugin will add a list of the most frequent comments posted to your blog. They are gathered in descending order (newest at the top), but then group them together by post title, so that comments from the same post are listed together. The list items will be links to the comments, and will contain the name of the commenter. Derived from the "Top/Recent Commenters" plugin by Scott Reilly (http://www.coffee2code.com/wp-plugins/)
+Author: Jared Bangs
+Author URI: http://freepressblog.org/
+Version: 1.7
+*/
+
+function get_recent_comments($no_comments = 5, $comment_lenth = 5) {
+
+ global $wpdb, $tablecomments, $tableposts, $id;
+ if (!isset($tablecomments)) $tablecomments = $wpdb->comments;
+ if (!isset($tableposts)) $tableposts = $wpdb->posts;
+
+ $request = "SELECT ID, comment_ID, comment_content, comment_author, post_title FROM $tablecomments LEFT JOIN $tableposts ON $tableposts.ID=$tablecomments.comment_post_ID ";
+ $request .= "WHERE post_status = 'publish' ";
+ if(!$show_pass_post) $request .= "AND post_password ='' ";
+ $request .= "AND comment_approved = '1' ORDER BY comment_ID DESC LIMIT $no_comments";
+ $comments = $wpdb->get_results($request);
+ $output = '';
+
+ foreach ($comments as $comment) {
+
+ $comment_author = stripslashes($comment->comment_author);
+
+ if ($comment_author == "")
+ $comment_author = "anonymous";
+
+ $comment_content = strip_tags($comment->comment_content);
+ $comment_content = stripslashes($comment_content);
+ $words=split(" ",$comment_content);
+ $comment_excerpt = join(" ",array_slice($words,0,$comment_lenth));
+
+ $permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID;
+ $postlink = get_permalink($comment->ID);
+
+ // Assemble link
+ $post_title = '<a href="' . $postlink . '">' . stripslashes($comment->post_title) . '</a>';
+ $comment_ID = stripslashes($comment->comment_ID);
+ $postTitles[$post_title][$comment_ID] = '<li><span class="commentAuthor">' . $comment_author . ':</span> <a href="' . $permalink;
+ $postTitles[$post_title][$comment_ID] .= '" title="View the entire comment by ' . $comment_author.'">' . $comment_excerpt.'...</a></li>';
+ }
+
+ $output = '<div id="recentcomments"><span id="recentCommentsTitle">Recent Comments:</span><ul id="recentcommentsList">' . "\n";
+
+ foreach ($postTitles as $title => $commentPreview) {
+
+ $output .= '<li><span class="recentCommentsPostTitle">' . $title . ':</span>' . "\n";
+ $output .= '<ul>' . "\n";
+
+ foreach ($commentPreview as $comID => $commentPreviewHTML) {
+ $output .= $commentPreviewHTML . "\n";
+ }
+
+ $output .= '</ul>' . "\n";
+ $output .= '</li>';
+ }
+
+ $output .= "\n" . '</ul>' . "\n" . '</div>' . "\n";
+
+ return $output;
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-content/plugins/kittens-spaminator.php b/wp-inst/wp-content/plugins/kittens-spaminator.php
new file mode 100644
index 0000000..937df6b
--- /dev/null
+++ b/wp-inst/wp-content/plugins/kittens-spaminator.php
@@ -0,0 +1,529 @@
+<?php
+/*
+Plugin Name: Kitten's Spaminator
+Version: 1.0rc7
+Plugin URI: http://blog.mookitty.co.uk/wordpress/spaminator/
+Description: Spam prevention and blocking using tarpitting and strike counting. Comments are assigned strikes for spam content, and a comment that meets the criteria for spam is blocked from posting.<br>If you're using WP 1.3 or higher, you have an admin menu under "Options" if you wish to change the defaults. For 1.2 users, you must edit the plugin file directly.<br><strong> Copyright 2004, Released under the GPL.</strong>
+Author: Kitten
+Author URI: http://blog.mookitty.co.uk
+
+INSTALLATION INSTRUCTIONS
+=========================
+1) If you're viewing this on the web, select all and paste it into a new text file named "kittens-spaminator.php"
+
+2) Copy the "kittens-spaminator.php" file to your wp-contents/plugins directory.
+
+3) On your plugins admin page, activate the plugin.
+
+4) Enjoy your freedom from spam!
+
+ 4a) Configure options if you don't like the defaults. Use the admin page for WP 1.3+, edit
+ edit this file for 1.2.
+=========================
+
+Change Log:
+0.1a - initial release
+0.2a - add more stuff
+0.3a - add whitelisting, fix checker function
+0.3b - fix debug code error
+0.4a - changed even more stuff
+0.5a - add crapflood check, change default values
+0.6a - add stike if no email,etc
+0.6b - fix php error
+0.7a - add check for empty email (Donncha)
+0.8a - add encoded char check, from functions.php
+0.9a - add post ID check, from techgnome
+0.9b - clean up email stuff & version
+0.10a - add user regex for especially annoying spam
+0.10b - fix user regex bug
+0.10c - fix another user regex bug
+0.10d - clean up code, add TODO
+0.11a - add URL check, fix strpos errors, interface for $strike_cnt
+0.11b - add user regex for email
+1.0rc - Release candidate, add GPL license
+1.0rc2 - Add admin page skel, 1.2 fixes, name whitelisting, "how" in email, clear TODOs
+ fix excessive links bug, change default for no referrer, double stripslashes on the
+ comment (to make the comment_url filter work to detect strange urls), fix html
+ entities
+1.0rc3 - Add check for real url in URL field, expand character entities check, check
+ all urls for dashes (most spam urls have dashes). Change user_regex_c to hopefully
+ catch the garbage spammer. Add record keeping on passed comments.
+1.0rc4 - Now used now 'preprocess' comment filter hook, only works with v1.5 nightlies from
+ Jan 5th or later. New email address for returned mail.
+1.0rc5 - New shiny admin interface + Kitten's regex service.
+1.0rc6 - Fix install bug.
+1.0rc7 - Sanitize regex service text, trim form fields.
+*/
+
+/**************---------------- CLASS DEFINITIONS ----------------**************/
+/// Admin page
+if ( ! class_exists( 'spaminator_admin_page' ) ) :
+class spaminator_admin_page
+{
+ function spaminator_admin_page( $post = '' )
+ {
+ $this->installed = get_settings( 'spaminator_status' );
+ // Get and load old options
+ $this->opts = get_settings( 'spaminator_settings' );
+ if ( count( $this->opts ) == 6 ) {
+ foreach ( $this->opts as $key => $val ) $this->$key = $val;
+ }
+ // Override with new options
+ if ( 'Save Options' == $post['save_spaminator_options'] ) {
+ $this->save_options = trim( $post['save_spaminator_options'] );
+ $this->strikes = trim( $post['spaminator_strikes'] );
+ $this->user_regex_c = trim( $post['spaminator_comment_regex'] );
+ $this->user_regex_e = trim( $post['spaminator_email_regex'] );
+ $this->nap_time = trim( $post['spaminator_naptime'] );
+ $this->send_mail = trim( $post['spaminator_sendmail'] );
+ $this->crap_flood = trim( $post['spaminator_crapflood'] );
+ }
+
+ if ( 'Remove Options' == $post['remove_spaminator_options'] ) {
+ $this->remove_options();
+ }
+
+ // Need to set things up
+ $this->install_options = $post['install_spaminator_options'];
+ $this->process_options();
+
+ // Get regex list
+ if ( 'Get Regexs' == $post['get_regexs'] ) {
+ $this->get_regexs();
+ }
+ }
+
+ function process_options()
+ {
+ // Install
+ if ( 'Install now' == $this->install_options && 'installed' != $this->installed ) {
+ add_option( 'spaminator_status', 'installed', 'Spaminator install flag' );
+ $settings = array( 'strikes' => 5,
+ 'user_regex_e' => '/^byob.*[0-9]{1,4}/i',
+ 'user_regex_c' => '/bea?stiality|rape|incest/i',
+ 'nap_time' => 60,
+ 'send_mail' => TRUE,
+ 'crap_flood' => 60 );
+ add_option( 'spaminator_settings', $settings, 'Spaminator options' );
+ $this->installed = get_settings( 'spaminator_status' );
+ $this->opts = get_settings( 'spaminator_settings' );
+ if ( count( $this->opts ) == 6 ) {
+ foreach ( $this->opts as $key => $val ) $this->$key = $val;
+ } else {
+ die( "There was a problem installing the default settings. Please try again." );
+ }
+ }
+
+ // Save new options
+ if ( 'Save Options' == $this->save_options ) {
+ $settings = array( 'strikes' => $this->strikes,
+ 'user_regex_c' => $this->user_regex_c,
+ 'user_regex_e' => $this->user_regex_e,
+ 'nap_time' => $this->nap_time,
+ 'send_mail' => $this->send_mail,
+ 'crap_flood' => $this->crap_flood );
+ update_option( 'spaminator_settings', $settings );
+ $this->updated = '<div class="updated"><p>The Spaminator&#146;s settings were updated successfully.</p></div>' . "\n";
+ }
+ }
+
+ function get_regexs()
+ {
+ $f = @fopen( "http://mookitty.co.uk/regexs.txt", 'r' );
+ $data = @fread( $f, 2048 ); // even if corrupted, only 2K max
+ @fclose( $f );
+
+ if ( strlen( $data ) < 1 ) {
+ $this->regexs = 'Sorry, no data available.<br />See <a href="http://mookitty.co.uk/regexs.txt">this page</a> for the latest.';
+ } else {
+ $this->regexs = htmlentities( $data );
+ }
+ }
+
+ function remove_options()
+ {
+ delete_option( 'spaminator_status' );
+ delete_option( 'spaminator_settings' );
+ $this->installed = '';
+ $this->updated = '<div class="updated"><p style="color: red;"><strong>The Spaminator&#146;s settings were removed.</strong> You are now using the built in defaults.</p></div>' . "\n";
+ }
+
+ function display_admin_page()
+ {
+ if ( 'installed' == $this->installed ) {
+ return $this->show_form();
+ } else {
+ return $this->show_install_form();
+ }
+ }
+
+ function show_install_form()
+ {
+ $text = $this->updated;
+ $text .= '<div class="wrap"><h2>Install The Spaminator&#146;s Config</h2>' . "\n";
+ $text .= '<form method="post" action="">' . "\n";
+ $text .= '<h3>Do you want to be able to configure The Spaminator from this admin page?</h3>' . "\n";
+ $text .= "<p>This will install The Spaminator's options in your database.</p>" . "\n";
+ $text .= '<input type="submit" name="install_spaminator_options" value="Install now" />' . "\n";
+ $text .= '</form>'. "\n";
+ $text .= '</div>' . "\n";
+ return $text;
+ }
+
+ function show_form()
+ {
+ $text = $this->updated;
+ $text .= '<div class="wrap"><h2>Configure The Spaminator</h2>' . "\n";
+ $text .= '<form method="post" action="" name="spaminator_options">' . "\n";
+ $text .= '<table>' . "\n";
+ $text .= '<tr><td>Strikes:</td>' . "\n";
+ $text .= '<td><input type="text" name="spaminator_strikes" value="'.$this->strikes.'" /></td>' . "\n";
+ $text .= '<td>The number of "hits" needed to kill a comment as spam.</td></tr>' . "\n";
+
+ $text .= '<tr><td>Send email?</td>' . "\n";
+ $text .= '<td><select name="spaminator_sendmail">' . "\n";
+ if ( $this->send_mail ) {
+ $text .= '<option value="1" selected="selected">Yes&nbsp;&nbsp;</option>' . "\n";
+ $text .= '<option value="0">No</option>' . "\n";
+ } else {
+ $text .= '<option value="1">Yes&nbsp;&nbsp;</option>' . "\n";
+ $text .= '<option value="0" selected="selected">No</option>' . "\n";
+ }
+ $text .= '</select></td>' . "\n";
+ $text .= '<td>Send email confirmation of each comment killed?</td></tr>' . "\n";
+
+
+ $text .= '<tr><td>Nap Time:</td>' . "\n";
+ $text .= '<td><input type="text" name="spaminator_naptime" value="'.$this->nap_time.'" /></td>' . "\n";
+ $text .= '<td>How long to tarpit the spammer, in seconds.</td></tr>' . "\n";
+
+ $text .= '<tr><td>Crap Flood:</td>' . "\n";
+ $text .= '<td><input type="text" name="spaminator_crapflood" value="'.$this->crap_flood.'" /></td>' . "\n";
+ $text .= '<td>Minimum amount of time allowed between comments from same IP address.</td></tr>' . "\n";
+
+
+ $text .= '<tr><td>Email regex:</td>' . "\n";
+ $text .= '<td><input type="text" name="spaminator_email_regex" value="'.$this->user_regex_e.'" /></td>' . "\n";
+ $text .= '<td>Special pattern in the email address of the commenter to kill comments.</td></tr>' . "\n";
+
+
+ $text .= '<tr><td>Comment regex:</td>' . "\n";
+ $text .= '<td><input type="text" name="spaminator_comment_regex" value="'.$this->user_regex_c.'" /></td>' . "\n";
+ $text .= '<td>Special pattern in the comment body to kill comments.</td></tr>' . "\n";
+
+ $text .= '</table>' . "\n";
+ $text .= '<input type="submit" name="save_spaminator_options" value="Save Options" />' . "\n";
+ $text .= '</form>'. "\n";
+ $text .= '</div>' . "\n";
+
+ $text .= '<div class="wrap"><h2>Kitten\'s Regex Service</h2>' . "\n";
+ if ( !empty( $this->regexs ) ) {
+ $text .= "<pre>$this->regexs</pre>";
+ } else {
+ $text .= '<p>If you\'d like to see <a href="http://blog.mookitty.co.uk/wordpress/regex-service/">Kitten\'s custom regexs</a> that she\'s currently using to keep spam away, click the button below:</p>' . "\n";
+ $text .= '<p><strong style="color: red">Notice:</strong> This is highly dependant on your server configuration, and may not work. You\'ve been warned.</p>' . "\n";
+ $text .= '<form method="post" action="" name="kittens_regexs">' . "\n";
+ $text .= '<input type="submit" name="get_regexs" value="Get Regexs" />' . "\n";
+ $text .= '</form>' . "\n";
+ }
+ $text .= '</div>' . "\n";
+
+ $text .= '<div class="wrap"><h2>Remove The Spaminator&#146;s Options</h2>' . "\n";
+ $text .= '<p><strong style="color: red">Help!</strong> I\'ve totally screwed up my settings and want to use the built in defaults.</p>' . "\n";
+ $text .= '<form method="post" action="" name="remove_spaminator_options">' . "\n";
+ $text .= '<p>Really remove the user options?</p>' . "\n";
+ $text .= '<input type="submit" name="remove_spaminator_options" value="Remove Options" />' . "\n";
+ $text .= '</form>'. "\n";
+ $text .= '</div>' . "\n";
+
+ return $text;
+ }
+}
+endif;
+
+/// Spam redirector class
+if ( ! class_exists( 'spam_killer' ) ) :
+class spam_killer
+{
+ // Class vars
+ var $how;
+ var $post;
+ var $strikes;
+ var $strike_cnt;
+ var $word_list;
+ var $nap_time;
+ var $send_mail;
+ var $crap_flood;
+
+ function spam_killer( $post )
+ {
+ global $wpdb;
+ $options = array(
+ //==================================================================
+ // Adjust the number of strikes needed to reject a comment
+ strikes => 5, // Number
+ //==================================================================
+ // Change this to fight a particular spammer
+ user_regex_c => '/bea?stiality|rape|incest/i', // Text string
+ user_regex_e => '/^byob.*[0-9]{1,4}/i', // Text string
+ //==================================================================
+ // Adjust the nap time to vary the TarPit delay
+ nap_time => 10, // Time in seconds
+ //==================================================================
+ // Change to TRUE to enable sending email when a spammer is caught
+ send_mail => true, // TRUE or FALSE
+ //==================================================================
+ // Adjust the minimum time between posts (crapflooding)
+ crap_flood => 60, // Time in seconds
+ //==================================================================
+ );
+
+ $installed = get_settings( 'spaminator_status' );
+
+ if ( 'installed' == $installed ) { // this is set via the admin page
+ $saved_options = get_settings( 'spaminator_settings' );
+ if ( is_array( $saved_options ) ) $options = $saved_options; // override
+ }
+
+ foreach ( $options as $key => $opt ) $this->$key = $opt;
+
+ $this->post = $post;
+ $this->strike_cnt = 0;
+ $this->word_list = get_settings('moderation_keys');
+ /*
+ if( $wpdb->options != 'wp_main_options' )
+ {
+ $query = "SELECT option_value from wp_main_options WHERE option_name='moderation_keys'";
+ $this->word_list .= "\n" . $wpdb->get_var( $query );
+ }
+ */
+ }
+
+ function count_strikes( $str = 0, $how )
+ {
+ $this->how[] = $how; // list all checks so far
+ $this->strike_cnt += $str;
+
+ // stats
+ $this->post['comment_content'] .= "<!-- X-spaminator-strike: $how, $str -->";
+
+ if ( $this->strike_cnt >= $this->strikes ) {
+
+ // Maybe send mail - we got spammer tail
+ if ( $this->send_mail ) {
+ $why = implode( ", ", $this->how );
+ $body = "The Spaminator has killed a comment.\r\n\r\n";
+ $body .= "The details:\r\n";
+ $body .= "Strikes : $this->strike_cnt/$this->strikes\r\n";
+ $body .= "How : $why\r\n";
+ $body .= "IP Addr : ".$_SERVER['REMOTE_ADDR']."\r\n";
+ $body .= "Referer : ".$_SERVER['HTTP_REFERER']."\r\n";
+ $body .= "Client : ".$_SERVER['HTTP_USER_AGENT']."\r\n";
+ $body .= "Request : ".$_SERVER['REQUEST_METHOD']." ". $_SERVER['REQUEST_URI']."\r\n";
+ $body .= "Post ID : ".$this->post['comment_post_ID']."\r\n";
+ $body .= "Email : ".$this->post['comment_author_email']."\r\n";
+ $body .= "Author : ".$this->post['comment_author']."\r\n";
+ $body .= "URL : ".$this->post['comment_author_url']."\r\n";
+ $body .= "Body:\r\n";
+ $body .= $this->post['comment_content']."\r\n\r\n";
+ $body .= "--\r\nThis email has been sent because the Spaminator plugin is set to send emails when a suspected spam has been blocked.\r\nTo not receive these emails change the ".'$this->send_mail'." variable to FALSE.\r\n\r\nThanks for using this plugin, hope it helps!\r\nhttp://mookitty.co.uk/devblog/";
+ $headers = "From: The Spaminator <wp.spaminator@gmail.com>";
+ $to = "[" . get_settings('blogname') . "] Spaminator: Spammer caught!";
+
+ @mail( get_settings('admin_email'), $to, $body, $headers );
+ }
+
+ // Let's waste spambot time:
+ sleep ( $this->nap_time );
+
+ // Make sure the bot thinks that spam was posted:
+ header( "HTTP/1.0 200 OK" );
+
+ // Tell humans something else:
+ echo "<p>Sorry, you've been prevented from commenting on this blog.</p>\n";
+ echo "<p>Either your comment content was found to contain spam, or<br />\n";
+ echo "your IP address (or a subnet of your IP address) has spammed this blog before.</p>\n";
+ echo "<p>If you think you got this page in error, your entered name might be too short.</p>\n";
+ echo "<p>You can also complain to <a href=\"wp.spaminator@gmail.com\">wp.spaminator@gmail.com</a>. View source to see why you got blocked.\n";
+ echo "<p>Strike count: $this->strike_cnt</p>\n";
+ echo "\n<!-- ", implode( ", ", $this->how ), " -->";
+ exit;
+ }
+ }
+
+ function process_comment()
+ {
+ global $wpdb, $table_prefix;
+ if ( empty($wpdb->comments) ) $wpdb->comments = $table_prefix . 'comments';
+ if ( empty($wpdb->posts) ) $wpdb->posts = $table_prefix . 'posts';
+
+ /// Set up vars to use:
+
+ $type = $this->post['comment_type'];
+ $url = parse_url( $this->post['comment_author_url'] );
+ $postID = $this->post['comment_post_ID'];
+ $author = $this->post['comment_author'];
+ if ( empty( $this->post['comment_author_email'] ) ) {
+ if ( 'trackback' == $type ) {
+ $this->post['comment_author_email'] = 'trackback@' . $url['host'];
+ } elseif ( 'pingback' == $type ) {
+ $this->post['comment_author_email'] = 'pingback@' . $url['host'];
+ }
+ }
+ $email = $this->post['comment_author_email'];
+ // Filter the text so that links show up, etc.
+ $comment = apply_filters( 'comment_text', stripslashes(stripslashes($this->post['comment_content'])) );
+// $forward = $this->post['redirect_to'];
+ $remote = $_SERVER['REMOTE_ADDR'];
+ $referer = $_SERVER['HTTP_REFERER'];
+ $iplist = preg_grep( "/^([0-9]{1,3}\.?){2}/", explode("\n", $this->word_list) );
+ $wdlist = explode( "\n", $this->word_list );
+ $wdlist = array_diff( $wdlist, $iplist );
+ // Get email for whitelist
+ if ( !empty( $email ) ) {
+ $whlist = $wpdb->get_row("SELECT comment_approved, comment_author FROM $wpdb->comments WHERE comment_author_email = '$email' AND comment_approved = '1' AND NOW()+0 > UNIX_TIMESTAMP( DATE_ADD( comment_date, INTERVAL 1 DAY ) ) GROUP BY comment_author;");
+ } else {
+ $whlist = '0';
+ }
+
+ // This returns a unix timestamp
+ $cfchck = $wpdb->get_var("SELECT UNIX_TIMESTAMP(comment_date) FROM $wpdb->comments WHERE comment_author_IP = '$remote' ORDER BY comment_date_gmt DESC LIMIT 1;");
+
+ /// Check for spam:
+
+ // User regex check
+ if ( preg_match( $this->user_regex_c, $comment ) > 0 ) {
+ $this->count_strikes( 10, 'user regex - comment' );
+ }
+ if ( preg_match( $this->user_regex_e, $email ) > 0 ) {
+ $this->count_strikes( 10, 'user regex - email ');
+ }
+
+ // If non-existing post, spam for sure
+ if ( !$wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE ID = '$postID'") ) {
+ $this->count_strikes( 10, 'non-existant post' );
+ }
+
+ // If previously approved, they get a headstart
+ if ( '1' == $whlist->comment_approved ) $this->count_strikes( -3, 'whitelist' );
+
+ // Check referer, see if a bot is directly inserting comment
+ if ( FALSE === strpos( $referer, get_settings('siteurl') ) ) {
+ $this->count_strikes( 3, 'bad referer - spambot?' );
+ }
+
+ // Check IP, see if it's a known spammer
+ $this->checker( $iplist, $remote, 5, 'IP check' );
+
+ // Check for crapflood
+ if ( $cfchck + $this->crap_flood > time() ) {
+ $this->count_strikes( 3, 'crap flooding' );
+ }
+
+ // Count links
+ if ( (count(explode('http', $comment)) - 1 ) > ( (int) get_settings('comment_max_links') ) ) {
+ $this->count_strikes( 3, 'excessive links' );
+ }
+
+ // Check email
+ $this->checker( $wdlist, $email, 1, 'email check' );
+
+ // Check author
+ // If the email is whitelisted, the name gets a free pass
+ // the most recent version of the name is used
+ if ( $author != $whlist->comment_author ) {
+ $this->checker( $wdlist, $author, 1, 'author check' );
+ }
+
+ // Check URL
+ // 3 points here, in case of "no body links" spam
+ $this->checker( $wdlist, $url['host'], 3, 'author url' );
+
+ // Check comment
+ $this->checker( $wdlist, $comment, 1, 'comment body' );
+
+ // From functions.php:
+ // Useless numeric encoding is a pretty good spam indicator:
+ // Extract entities:
+ if (preg_match_all('/&#?(\d+);/', $url['host'] . $author . $email, $chars)) {
+ foreach ($chars[1] as $char) {
+ // If it's an encoded char in the normal ASCII set, reject
+ if ($char < 128) $this->count_strikes( 1, 'html entity' );
+ }
+ }
+
+ // Check for dashes in urls
+ // Urls that are auto formatted will get counted twice - feature, not bug!
+ preg_match_all( '#(http:)?//([^\s"\'<>]*)#i', $comment, $match );
+ array_push( $match[2], $url['host'] );
+ array_push( $match[2], $email );
+ $cnt_dash = 0;
+ foreach ( $match[2] as $u ) {
+ $cnt_dash += substr_count( $u, '-' );
+ }
+ if ( $cnt_dash > 0 ) {
+ $this->count_strikes( $cnt_dash, 'url dashes' );
+ }
+
+ // Check if provided url is legit
+ if ( strlen( $url['host'] ) > 0 && ! checkdnsrr( $url['host'], 'A' ) ) {
+ $this->count_strikes( 4, "unknown url, $url" );
+ }
+
+ return $this->post;
+
+ } // end of function process_comment
+
+ function checker( $haystack, $needle, $strike_val, $how )
+ {
+ if ( is_array( $haystack ) && count( $haystack ) > 0 && strlen( $needle ) > 3 ) {
+ foreach ( $haystack as $item ) {
+ $item = trim( $item );
+ // skip empties & shorts in mod keys, faster than filtering list
+ if ( strlen( $item ) < 3 ) continue;
+
+ $word_cnt = substr_count( $needle, $item );
+ if ( $word_cnt > 0 ) {
+ $this->count_strikes( $strike_val * $word_cnt, $how . ' - ' . $item );
+ }
+ }
+ }
+ // Add a strike if email, etc is empty
+ if ( empty( $needle ) ) $this->count_strikes( 1, "empty field - $how" );
+ if ( ! empty( $needle ) && strlen( $needle ) <=3 ) $this->count_strikes( 1, 'short field' );
+
+ // Record keeping
+ $this->post['comment_content'] .= "<!-- X-spaminator-passed: $how -->";
+
+ } // end of function checker
+
+} // end class spam killer
+endif;
+/**************-------------- END CLASS DEFINITIONS --------------**************/
+
+/**************---------------- STANDALONE SECTION ---------------**************/
+/// Control block if comment posted.
+if ( ! function_exists( 'spaminate_comment' ) ) {
+ function spaminate_comment( $comment ) {
+ $incoming_spam = new spam_killer( $comment );
+ $foo = $incoming_spam->process_comment();
+ return $foo;
+ }
+}
+
+// Adds the menu item
+if ( ! function_exists( 'add_spaminator_menu' ) ) {
+ function add_spaminator_menu()
+ {
+ add_options_page(__('Spaminator Config'), __('Spaminator'), 9, 'kittens-spaminator.php');
+ }
+} elseif ( 'kittens-spaminator.php' == $_GET['page'] ) {
+ $spamiator_iface = new spaminator_admin_page( $_POST );
+ echo $spamiator_iface->display_admin_page();
+}
+
+add_action('preprocess_comment', 'spaminate_comment');
+add_action('admin_menu', 'add_spaminator_menu');
+/**************-------------- END STANDALONE SECTION -------------**************/
+
+?>
diff --git a/wp-inst/wp-content/plugins/wp_ozh_clickcounter.php b/wp-inst/wp-content/plugins/wp_ozh_clickcounter.php
new file mode 100644
index 0000000..53906c4
--- /dev/null
+++ b/wp-inst/wp-content/plugins/wp_ozh_clickcounter.php
@@ -0,0 +1,522 @@
+<?php
+/*
+Plugin Name: Click Counter
+Plugin URI: http://frenchfragfactory.net/ozh/archives/2004/09/17/click-counter-plugin-for-wordpress/
+Description: Adds a click counter to links in your posts (<a href="../wp-content/plugins/wp_ozh_clickcounter.php">quick readme & manual</a>)
+Version: 1.0
+Author: Ozh
+Author URI: http://planetOzh.com
+*/
+// script called directly (or something global badly misconfigured :)
+if (!function_exists("get_settings")) {wp_ozh_click_readme();die;}
+
+
+/*************************************
+ * OPTIONAL EDIT BELOW *
+ * ~~ *
+ *************************************/
+
+// when specified "default value" it means it can be overridden on a per-link basis in each post
+
+// Core variables
+
+$wp_ozh_click['table'] = 'wp_linkclicks';
+ /* name of the table where stats will be stored. Look at the bottom or at plugin page to learn how to create this table */
+$wp_ozh_click['file'] = get_settings('siteurl') . "/go.php" ;
+ /* name of the click counter php file (provided with the plugin archive). A good place for it is your blog root. */
+
+
+// Basic features
+
+$wp_ozh_click['do_posts'] = 1;
+ /* 0 or 1, or true / false
+ * Add or not a link counter to links in your posts */
+
+$wp_ozh_click['do_comments'] = 1;
+ /* 0 or 1, or true / false
+ * Add or not a link counter to links in comments */
+
+ /* There is a quick editing needed if you also want to add a counter
+ * to commenters' website when specified, see plugin page. */
+
+$wp_ozh_click['track_all_links'] = 1 ;
+ /* 0 : adds a counter only when you add count="value" in your links html tag
+ * 1 : adds a counter to all external links in your posts (no need to add counter="1" if you plan to track them all)
+ * To keep track of internal links if set to 1, put absolute path (http://yourblog/link) instead of relative (/link) */
+
+$wp_ozh_click['in_title'] = 0 ;
+ /* 1 or 0 (or true / false)
+ * add number of hits in link title tag : <a href="http://site.com" title="X hits">site</a> */
+
+$wp_ozh_click['in_plain'] = 0 ;
+ /* 1 or 0 (or true / false)
+ * add number of hits in plain text : <a href="http://site.com">site</a> <span class="hitcounter">(XX hits)</span> */
+
+$wp_ozh_click['0click'] = 'No Click';
+ /* default text for zero clicks. */
+
+$wp_ozh_click['1click'] = 'One hit';
+ /* default text for one click */
+
+$wp_ozh_click['clicks'] = '%% hits';
+ /* default text for several clicks, where %% will be replaced by a number */
+
+$wp_ozh_click['method'] = 2 ;
+ /* 1, 2 or 3
+ * There are 3 link 'href' modification modes available
+ * Each has advantages and drawbacks
+ * All validate any Doctype up to xhtml 1.1
+ *
+ * From input <a href="http://site.com">, each methods gives the following html :
+ *
+ * Method 1 :
+ * ^^^^^^^^^^
+ * <a href="http://site.com" onclick="window.location='/go.php?http://site.com'; return false">
+ * Cool : status bar shows real link without further trick.
+ * Less cool : doesnt work with "open link in new window"
+ *
+ * Method 2 :
+ * ^^^^^^^^^^
+ * <a href="/yourblog/go.php?http://site.com">
+ * Cool : works with "open in new window" and doesn't require Javascript enabled
+ * Less cool : shows ugly link "/blog/go.php?http://site.com" in status bar
+ *
+ * Method 3 :
+ * ^^^^^^^^^^
+ * like method 2 but also modify status bar to hide the "yoursite.com/blog/go.php?" part
+ * with an onmouseover="javascript:window.status='http://site.com'; return false"
+ * Cool : status bar shows real link.
+ * Less cool : adds a few bytes of html. But who cares :)
+ *
+ * I'd suggest you use preferably method 3, or at least method 2. Method 1 is really less
+ * accurate since it doesn't keep track of links opened in a new window */
+
+
+// Link title features
+// The plugin is able to retrieve a remote file title (from it's <title> html tag)
+
+$wp_ozh_click['get_title'] = 0;
+ /* 1 or 0 (or true / false)
+ * Get remote page title the first time a user clicks a link to store it along with hits in the table
+ * Will slow down a bit the first clicker (1 or 2 seconds, time for your website to retrieve the distant page)
+ * Titles stored are used for example when printing top clicked links
+ * !! Note : uses fopen(), check your host has enabled this !! */
+
+$wp_ozh_click['get_title_forcerefresh'] = 50;
+ /* Refresh remote page title every XX clicks ?
+ * Set to 0 if you don't want to check & refresh titles every XX clicks
+ * (the higher traffic - then clicks - you get, the higher you should set this
+ * To be honest this is really a gadget - almost totally useless :)
+ * Examples : 50 for Joe's blog, 3000 for Slashdottish blog */
+
+$wp_ozh_click['extensions'] = array (
+ "ace", "arj", "bin", "bz2", "dat", "deb", "gz", "hqx", "pak", "pk3", "rar", "rpm", "sea", "sit", "tar", "wsz", "zip",
+ "aif", "aiff", "au", "mid", "mod", "mp3", "ogg", "ram", "rm", "wav",
+ "ani", "bmp", "dwg", "eps", "eps2", "gif", "ico", "jpeg", "jpg", "png", "psd", "psp", "qt", "svg", "swf", "tga", "tiff", "wmf", "xcf",
+ "avi", "mov", "mpeg", "mpg",
+ "c", "class", "h", "java ", "jar", "js",
+ "bat", "chm", "cur", "dll", "exe", "hlp", "inf", "ocx", "pps", "ppt", "reg", "scr", "xls",
+ "css", "conf", "doc", "ini", "pdf", "rtf", "ttf", "txt"
+); /* Most common non html file extensions
+ * These are files that have no <title> html tag, so their link title will be $document.$ext */
+
+// Top links function features
+
+$wp_ozh_click['top_limit'] = 5;
+ /* default number of top links to be displayed by wp_ozh_click_topclicks() */
+
+$wp_ozh_click['top_pattern'] = '<li><a href="%%link_url%%" title="%%link_title%%">%%link_title_trim%%</a>: %%link_clicks%%</li>';
+ /* default pattern used to display top links
+ * Any %%tag%% where "tag" can be : link_id, link_url, link_clicks, link_date, link_title, link_title_trim (shortened, see below)
+ * Example : '%%link_title%% (%%link_url%%) = %%link_clicks%%' */
+
+$wp_ozh_click['trim'] = 15;
+ /* default maximum length of link titles
+ * When printing top links titles, trim long link titles output to XX characters (0 not to trim) */
+
+
+
+
+/*************************************
+ * DO NOT EDIT BELOW *
+ * ~~ *
+ *************************************/
+
+//**************************************************************************************************************************
+
+
+// inputs a URL, returns an integer (number of clicks for the URL)
+function wp_ozh_click_getcount2 ($wpblog, $url = "") {
+ global $wpdb, $wp_ozh_click;
+ $url = str_replace("&amp;", "&", $url);
+ $url = wp_ozh_click_getrealpath($url);
+ return $wpdb->get_var("SELECT link_clicks FROM $wp_ozh_click[table] WHERE blogID='$wpblog' AND link_url='$url'");
+}
+
+function wp_ozh_click_getcount ($url = "") {
+ global $wpblog;
+
+ if( @include_once( "Cache/Function.php" ) )
+ {
+ $cache = new Cache_Function( 'file', array('cache_dir' => ABSPATH . "/wp-content/smarty-cache", 'filename_prefix' => 'wp_ozh_click_getcount_cache_' ), 600 );
+ $count = $cache->call( "wp_ozh_click_getcount2", $wpblog, $url );
+ }
+ else
+ {
+ $count = wp_ozh_click_getcount2( $wpblog, $url );
+ }
+
+ return $count;
+}
+
+// inputs a URL, returns text
+function wp_ozh_click_getclicks ($url = '', $zeroclick = '',
+ $oneclick = '', $lotsaclicks = '' ) {
+ $result = wp_ozh_click_getcount ($url);
+ $result = wp_ozh_click_labelize ($result, $zeroclick, $oneclick, $lotsaclicks);
+ $wp_ozh_click['temp'] = "...".$url;
+ return $result;
+}
+
+// inputs a number, returns text like "<number> hits"
+function wp_ozh_click_labelize ($number = 0, $zeroclick = '',
+ $oneclick = '', $lotsaclicks = '' ) {
+ global $wp_ozh_click;
+ if (!$zeroclick) $zeroclick = $wp_ozh_click['0click'];
+ if (!$oneclick) $oneclick = $wp_ozh_click['1click'];
+ if (!$lotsaclicks) $lotsaclicks = $wp_ozh_click['clicks'];
+
+ switch ($number) :
+ case "":
+ return $zeroclick;
+ break;
+ case 1:
+ return $oneclick;
+ break;
+ default:
+ return (str_replace ("%%", $number, $lotsaclicks));
+ endswitch;
+}
+
+
+// parses string to detect and process pairs of tag="value"
+function wp_ozh_click_parse ($html="", $all=0) {
+ global $wp_ozh_click;
+
+ preg_match_all ('/[^=]{1,}="[^"]+"/', $html, $wp_ozh_click['link']);
+ foreach ($wp_ozh_click['link'][0] as $pair) {
+ list ($tag , $value) = explode ("=", $pair , 2);
+ $wp_ozh_click['link'][trim($tag)]=trim($value, '"');
+ }
+ unset ($wp_ozh_click['link'][0]);
+
+ $wp_ozh_click['modify_href'] = 0;
+ // do we want to display clicks ?
+ if ( !isset($wp_ozh_click['link']['count']) || $wp_ozh_click['link']['count'] != "0" ) {
+ if (
+ ( ($all == 1) && (eregi("^[a-z]+://", $wp_ozh_click['link']['href'])) )
+ ||
+ ( isset($wp_ozh_click['link']['count'] ) )
+ ) {
+ $wp_ozh_click['modify_href'] = 1;
+ }
+ }
+
+ if ($wp_ozh_click['modify_href']) {
+ if ( (!isset($wp_ozh_click['link']['count']) && $wp_ozh_click['track_all_links'] && $wp_ozh_click['in_title'] ) || ( $wp_ozh_click['in_title'] && $wp_ozh_click['link']['count']=="1" ) || stristr($wp_ozh_click['link']['count'],'title') ) {
+ if (isset($wp_ozh_click['link']['title'])) {
+ $wp_ozh_click['link']['title']= $wp_ozh_click['link']['title'] . " (" . wp_ozh_click_getclicks($wp_ozh_click['link']['href']) . ")";
+ } else {
+ $wp_ozh_click['link']['title']= "(" . wp_ozh_click_getclicks($wp_ozh_click['link']['href']) . ")";
+ }
+ }
+ if ( (!isset($wp_ozh_click['link']['count']) && $wp_ozh_click['track_all_links'] && $wp_ozh_click['in_plain'] ) || ( $wp_ozh_click['in_plain'] && $wp_ozh_click['link']['count']=="1" ) || stristr($wp_ozh_click['link']['count'],'inline') ) {
+ $wp_ozh_click['after'] = ' <span class="hitcounter">(' . wp_ozh_click_getclicks($wp_ozh_click['link']['href']) . ')</span>' ;
+ }
+
+ switch ($wp_ozh_click['method']) :
+ case 1 :
+ $wp_ozh_click['link']['onclick'] = "window.location='". $wp_ozh_click['file'] . "?" . $wp_ozh_click['link']['href'] . "'; return false";
+ break;
+ case 2 :
+ $wp_ozh_click['link']['href'] = $wp_ozh_click['file'] . "?" . $wp_ozh_click['link']['href'] ;
+ break;
+ case 3 :
+ $wp_ozh_click['link']['onmouseover']="javascript:window.status='". $wp_ozh_click['link']['href'] ."'; return true;" ;
+ $wp_ozh_click['link']['onmouseout']="javascript:window.status=''; return true;" ;
+ $wp_ozh_click['link']['href'] = $wp_ozh_click['file'] . "?" . $wp_ozh_click['link']['href'] ;
+ endswitch;
+
+
+ unset ($wp_ozh_click['link']['count']);
+ }
+
+ $html='';
+ foreach ($wp_ozh_click['link'] as $key => $value) {
+ $html .= $key . "=\"" . $value . "\" ";
+ }
+ $html=trim($html);
+ return '<a '. $html .'>';
+}
+
+// convert relative path ("/blog/dir/file" or "dir/this/file") into absolute (from blog's index.php)
+function wp_ozh_click_getrealpath ($url = "") {
+ $url = preg_replace ("/#.*$/",'',$url);
+
+ if (!eregi("^[a-z]+://", $url)) {
+ if (eregi("^/", $url)) {
+ $url = 'http://' . $_SERVER['HTTP_HOST'] . $url;
+ } else {
+ $url = get_settings('siteurl') . '/' . $url;
+ }
+ }
+ return $url;
+}
+
+
+// increments field link_click for a given URL
+function wp_ozh_click_increment ($url="") {
+ global $wpdb, $wp_ozh_click, $wpblog;
+ $url = wp_ozh_click_getrealpath($url);
+
+ // if (!get_magic_quotes_gpc()) {$url = add_magic_quotes($url);}
+
+ $result = $wpdb->get_var("SELECT link_clicks FROM $wp_ozh_click[table] WHERE blogID='$wpblog' AND link_url='$url'");
+
+ if ($result) {
+ $todo = 'link_clicks=(link_clicks + 1)';
+ if (($wp_ozh_click['get_title_forcerefresh']) && (($result % $wp_ozh_click['get_title_forcerefresh']) == 0)) {
+ $link_title=wp_ozh_click_gettitle($url);
+ if ($link_title) {
+ $todo .= ", link_title='$link_title'";
+ }
+ }
+ $return = $wpdb->query("UPDATE $wp_ozh_click[table] SET $todo WHERE blogID='$wpblog' AND link_url='$url'");
+ } else {
+ $link_date = gmdate('Y-m-d H:i:s', (time() + (get_settings('gmt_offset') * 3600)));
+ if ($wp_ozh_click['get_title']) {
+ $link_title=wp_ozh_click_gettitle($url);
+ } else {
+ $link_title='';
+ }
+ $return = $wpdb->query("INSERT INTO $wp_ozh_click[table] (blogID, link_url, link_clicks, link_date, link_title) VALUES ('$wpblog', '$url', 1, '$link_date', '$link_title')");
+ };
+ return $return;
+}
+
+
+// prints most clicked links
+function wp_ozh_click_topclicks ($limit = '', $trim = '', $pattern = '') {
+ global $wpdb, $wp_ozh_click, $wpblog;
+ if (!$limit) $limit = $wp_ozh_click['top_limit'];
+ if (!$pattern) $pattern = $wp_ozh_click['top_pattern'];
+ if (!$trim) $trim = $wp_ozh_click['trim'];
+
+ $results = $wpdb->get_results("select * from $wp_ozh_click[table] WHERE blogID='$wpblog' ORDER BY link_clicks DESC LIMIT $limit");
+ foreach ($results as $result) {
+ $html = $pattern;
+ $html = preg_replace ( "/%%link_url%%/i", $wp_ozh_click['file'] . "?" . "$result->link_url", $html);
+ $html = preg_replace ( "/%%link_clicks%%/i", wp_ozh_click_labelize($result->link_clicks), $html);
+ $html = preg_replace ( "/%%link_date%%/i", "$result->link_date", $html);
+ if (!$result->link_title) {
+ // prettyfies link_title for display : no "http://www." or trailing "/"
+ $result->link_title = preg_replace("/((ht)*f*tp:\/\/)*(www\.)*/", "", $result->link_url);
+ $result->link_title = preg_replace("/\/$/", "", $result->link_title);
+ }
+ if ($trim && (strlen($result->link_title) > $trim)) {
+ $result->link_title_trim = substr($result->link_title, 0, $trim) . '&#8230';
+ } else {
+ $result->link_title_trim = $result->link_title;
+ }
+ $html = preg_replace ( "/%%link_title_trim%%/i", "$result->link_title_trim", $html);
+ $html = preg_replace ( "/%%link_title%%/i", "$result->link_title", $html);
+ echo $html . "\n";
+ }
+}
+
+
+// prints number of links tracked
+function wp_ozh_click_linkcount ($display=1) {
+ global $wpdb, $wp_ozh_click;
+ if (!$wp_ozh_click['stats']) wp_ozh_click_getstats();
+ if ($display)
+ echo $wp_ozh_click['stats']->linkcount;
+ return $wp_ozh_click['stats']->linkcount;
+}
+
+
+// prints total number of clicks
+function wp_ozh_click_clickcount ($display=1) {
+ global $wpdb, $wp_ozh_click;
+ if (!$wp_ozh_click['stats']) wp_ozh_click_getstats();
+ if ($display)
+ echo $wp_ozh_click['stats']->clickcount;
+ return $wp_ozh_click['stats']->clickcount;
+
+}
+
+
+// retrieves various stats
+function wp_ozh_click_getstats () {
+ global $wpdb, $wp_ozh_click, $wpblog;
+ $wp_ozh_click['stats'] = $wpdb->get_row("SELECT count(*) AS linkcount, sum(link_clicks) AS clickcount FROM $wp_ozh_click[table] WHERE blogID='$wpblog'");
+ //echo $wp_ozh_click['stats']->clickcount;
+ //echo "<hr>";
+ //echo $wp_ozh_click['stats']->linkcount;
+ return $wp_ozh_click['stats'];
+}
+
+// return title of a (local or remote) webpage
+function wp_ozh_click_gettitle ($url = "") {
+ global $wp_ozh_click;
+ eregi("/([^#\?\/]+)\.([a-z0-9]+)$", $url, $file);
+ $ext = $file[2];
+ $file = $file[1];
+ $in_array = in_array($ext, $wp_ozh_click['extensions']);
+ switch ($in_array):
+ case true:
+ return "$file.$ext";
+ break;
+ case false:
+ if (function_exists('fopen')) {
+ $fp = @fopen ($url, 'r');
+ if( $fp ) {
+ while (! feof ($fp)){
+ $webpage .= fgets ($fp, 1024);
+ if (stristr($webpage, '<title>' )){
+ break;
+ }
+ }
+ if (eregi("<title>(.*)</title>", $webpage, $out)) {
+ return addslashes($out[1]);
+ } else {
+ return "";
+ }
+ } else {
+ return "$url";
+ }
+ } else {
+ return "";
+ }
+ break;
+ endswitch;
+}
+
+
+// readme & check install
+function wp_ozh_click_readme() {
+ echo '<html><head>
+ <title>Click Counter Plugin for Wordpress - By Ozh</title>
+ <link rel="stylesheet" href="../../wp-admin/wp-admin.css" type="text/css" />
+ </head>
+ <body>
+ <div id="wphead" style="height: 4.5em">
+ <h1 align="right">Click Counter Plugin - By Ozh</h1>
+ </div>
+ <div class="wrap">
+ <h2>Thanks :)</h2>
+ <p>Thank you for installing this plugin !</p>
+ <h2>About this plugin</h2>
+ <p>This plugin adds a "tracker" to links in your posts and your comments, so that when someone clicks on them, the link\'s hit counter increments. The number of hits can also be displayed in a variety of flavours. You can choose to add a hit counter to all links (default) or only to chosen links</p>
+ <h2>2 steps installation and usage "out of the box"</h2>
+ <ol><li><p>First, create a new table in your WordPress MySQL database, named wp_linkclicks, using for example PHPMyAdmin with the following query :</p>
+ <pre class="updated">
+CREATE TABLE `wp_linkclicks` (
+ `link_id` INT NOT NULL AUTO_INCREMENT ,
+ `link_url` TEXT NOT NULL ,
+ `link_clicks` INT NOT NULL ,
+ `link_date` DATETIME NOT NULL ,
+ `link_title` TEXT NOT NULL ,
+ UNIQUE (
+ `link_id`
+ )
+);</pre></li>
+ <li><p>Then put the plugin file in <strong><em>yourblog</em>/wp-content/plugins/</strong> and <strong>activate it</strong>
+ from the <a href="../../wp-admin/plugins.php">admin interface</a>.</p></li></ol>
+ <p>The plugin should now work silently without further working. Get back to blogging and posting link as usual :)</p>
+ <h2>Optional Configuration</h2>
+ <p>You will find detailed information about how to configure the plugin in its source itself:
+ the section you can configure is well commented. You can do so from within the <a href="../../wp-admin/templates.php?file=wp-content/plugins/wp_ozh_clickcounter.php">admin interface</a> as well.
+ <p>You can also find detailed information and examples of use
+ at the <a href="http://frenchfragfactory.net/ozh/">plugin\'s homepage</a>.</p>
+ <h2>Feedback & Disclaimer</h2>
+ <p>I\'d appreciate your leaving a comment on the plugin page, to suggest any improvement, bug fix, or just to say if you like the plugin or not :)
+ By the way, you\'ll find on <a href="http://frenchfragfactory.net/ozh/archives/category/wordpress/">my site</a> a few other plugins (<a href="http://frenchfragfactory.net/ozh/archives/2004/08/27/ip-to-nation-plugin/">IP to Nation plugin</a> in particular) you may find of interest.</p>
+ <p>Any resemblance between this page and a well-known admin interface is purely coincidental :-P</p>
+ </div>
+ <div id="footer"><p><a href="http://planetOzh.com/"><img src="http://frenchfragfactory.net/ozh/wp-images/btn_planetozh.png" border="0" alt="planetOzh.com" /></a><br />
+ </div>
+ </body></html>
+ ';
+}
+
+// the one that starts it all
+function wp_ozh_click_modifyhrefs ($input) {
+ $input = preg_replace_callback ("/<a ([^>]{1,})>(.+?<\/a>)/", "wp_ozh_click_do_posts", $input);
+ // ** OMFG ** I finally understood what preg_replace_callback is ! :))
+ return $input;
+}
+
+// callback function
+function wp_ozh_click_do_posts($text) {
+ global $wp_ozh_click;
+ unset ($wp_ozh_click['after']);
+
+ $before = wp_ozh_click_parse($text[1],$wp_ozh_click['track_all_links']);
+ $text = $text[2];
+ return $before.$text.$wp_ozh_click['after'];
+}
+
+function wp_ozh_click_comment_author_link() {
+ global $comment;
+ $url = apply_filters('comment_url', $comment->comment_author_url);
+ $author = apply_filters('comment_author', $comment->comment_author);
+ if (!$author) $author = 'Anonymous';
+
+ if (empty($url)) :
+ echo $author;
+ else:
+ echo wp_ozh_click_modifyhrefs("<a href=\"$url\" rel=\"external\">$author</a>");
+ endif;
+}
+
+
+// Add per-post filtering:
+if ($wp_ozh_click['do_posts'])
+ add_filter('the_content', 'wp_ozh_click_modifyhrefs');
+if ($wp_ozh_click['do_comments'])
+ add_filter('comment_text', 'wp_ozh_click_modifyhrefs');
+
+
+// And that's it.
+
+
+/* Future enhancements ?
+ - handle malformed html tags like <a href=http://site.com count=1>site</a> (no "quotes")
+*/
+
+
+/* Example post :
+ Post this in your blog and watch how modifying the script configuration affects display of counters.
+
+--8<-----8<-----[cut & paste]-
+<strong>Tests with external links : href="http://external-link.com" </strong>
+<a href="http://external-link.com" count="0">count="0"</a> never shows click count
+<a href="http://external-link.com" count="1">count="1"</a> shows click count according to defaults as set in the plugin
+<a href="http://external-link.com" count="title">count="title"</a> always shows a count in link title (mouseover)
+<a href="http://external-link.com" count="inline">count="inline"</a> always shows a count next to title in plain text
+<a href="http://external-link.com" count="inline title">count="inline title"</a> always shows both
+<a href="http://external-link.com">count not specified</a> shows or not depending on defaults as set in the plugin (tracking all links or not)
+
+<strong>Tests with internal links : href="/local_dir/file"</strong>
+<a href="/local_dir/file" count="0">count="0"</a> never shows click count
+<a href="/local_dir/file" count="1">count="1"</a> always shows click count, according to defaults
+<a href="/local_dir/file" count="title">count="title"</a> always shows click count in link title
+<a href="/local_dir/file" count="inline">count="inline"</a> always shows click count next to title in plain text
+<a href="/local_dir/file" count="inline title">count="inline title"</a> always shows both
+<a href="/local_dir/file">count not specified</a> never shows click count
+--8<-----8<-----[cut & paste]-
+
+*/
+
+?>
diff --git a/wp-inst/wp-content/plugins/wpmu-plugin.php b/wp-inst/wp-content/plugins/wpmu-plugin.php
new file mode 100644
index 0000000..c30ff7c
--- /dev/null
+++ b/wp-inst/wp-content/plugins/wpmu-plugin.php
@@ -0,0 +1,598 @@
+<?php
+/*
+ Plugin Name: WPMU Administration Console
+ Plugin URI: http://derek.ditch.name/
+ Description: Use this plugin to install new users, remove existing, and configure WPMU. <strong>Warning!</strong> This plugin is not ready for general use. It may lead to serious problems on your site if enabled!
+ Author: Derek Ditch
+ Author URI: http://derek.ditch.name
+ Version: 0.1
+ */
+
+ /* THINGS TO DO:
+ - Add option to backup database and/or templates into tarball or similar
+ - Add smarty code to insert aggregate of hosted blogs on main blog page
+
+ BUGS
+ - NONE so far! Please send me your bug reports! <derek AT ditch DOT name>
+ */
+
+if( ! function_exists('wpmu_admin_run') ){
+ function wpmu_admin_run() {
+ add_options_page( __('WPMU Administration'), __('WPMU'), 10, ABSPATH.'wp-content/plugins/wpmu-plugin.php');
+ }
+ }
+
+ if ( is_plugin_page() ){
+
+ function setPasswd($login){
+ global $table_prefix;
+
+ // Connect to the db
+ $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
+ mysql_select_db(DB_NAME);
+
+ $random_password = substr(md5(uniqid(microtime())), 0, 6);
+ mysql_query("UPDATE {$table_prefix}users SET user_pass=MD5('$random_password') WHERE ID='1'");
+
+ return $random_password;
+ }
+
+ function emailNewUser($password){
+ global $email, $login, $base;
+
+ $from = 'From: WPMU Admin <wordpress@'.$_SERVER['HTTP_HOST'].'>';
+ $message_headers = "$from";
+
+ mail($email, '
+ New WordPress Blog', "Your new WordPress blog has been successfully set up at:
+
+ http://{$_SERVER['HTTP_HOST']}{$base}{$login}/
+
+ You can log in to your account with the following information:
+
+ Username: $login
+ Password: $password
+
+ We hope you enjoy your new weblog. Thanks!
+
+ --The WordPress Team
+ http://wordpress.org/
+ ", $message_headers);
+ }
+
+ function emailNewPass($password, $email, $login){
+
+ $from = 'From: WPMU Admin <wordpress@'.$_SERVER['HTTP_HOST'].'>';
+ $message_headers = "$from";
+
+ mail($email, 'New WordPress Password', "
+ Your WordPress has been reset. If you do not think this should be happening,
+ please contact your site admin for further info.:
+
+ You can log in to your account with the following information:
+
+ Username: $login
+ Password: $password
+
+ Happy blogging. Thanks!
+
+ --The WordPress Team
+ http://wordpress.org/
+ ", $message_headers);
+
+ }
+
+ function &getUserInfo($blog){
+
+ global $wpmuBaseTablePrefix, $wpdb;
+
+ return $wpdb->get_row("SELECT CONCAT(user_lastname, ', ', user_firstname) as name, user_email, user_url FROM {$wpmuBaseTablePrefix}{$blog}_users WHERE ID='1' ");
+ }
+
+ function getSchema(){
+ global $login;
+
+ // Load the schema
+ $queries = file(ABSPATH.'wp-admin/upgrade-schema.php');
+ $queries = str_replace('$wpdb->', $login . '_', $queries);
+ $queries = implode('', $queries);
+ preg_match('/\"(.*?)\"/s', $queries, $matches);
+
+ $queries = $matches[1];
+
+ // Taken from upgrade-functions.php
+ // 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(str_replace('PREFIX', '', $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
+ }
+ }
+
+ return array($cqueries, $iqueries, $for_update);
+ }
+
+ // Expects array of queries ready to be executed.
+ function installdb($queries){
+
+ // Connect to the db
+ $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
+ mysql_select_db(DB_NAME);
+
+ // Process each query.
+ foreach($queries as $query){
+ mysql_query($query);
+ }
+
+ mysql_close($link);
+ }
+
+ function deletedb($login){
+
+ global $table_prefix;
+
+ $delete_tables = array();
+
+ // Connect to the db
+ $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
+
+ $tables = mysql_list_tables(DB_NAME);
+ for ($i = 0; $i < mysql_num_rows($tables); $i++) {
+ if ((substr($tablename = mysql_tablename($tables,$i),0,strlen($table_prefix))==$table_prefix)) {
+ $delete_tables[] = $tablename;
+ }
+ }
+
+ mysql_free_result($tables);
+
+ foreach($delete_tables as $tablename){
+ mysql_query("DROP TABLE $tablename");
+ }
+ }
+
+ function dboptions(){
+ global $login, $base, $firstname, $lastname, $email, $table_prefix;
+ $name = '';
+ $value = '';
+ $description = '';
+
+ $qry = "INSERT INTO {$table_prefix}options (option_name, option_value, option_description) VALUES ('{&$name}', '{&$value}', '{&$description}')";
+
+ // Load the schema
+ $queries = file(ABSPATH.'wp-admin/upgrade-schema.php');
+ $queries = str_replace('$wpdb->', $login . '_', $queries);
+ $queries = implode('', $queries);
+
+ // Connect to the db
+ $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
+ mysql_select_db(DB_NAME);
+
+ $result = mysql_query("SELECT * FROM derek_users");
+
+ // Catch all add_option usage
+ preg_match_all('/add_option\((.*?)\)\;/', $queries, $matches);
+ foreach($matches[1] as $match){
+
+ list($name, $value, $description) = explode(',', $match);
+ $name = trim($name, " '");
+ $value = trim($value, " '");
+ $description = trim($description, " '");
+ $qry = "INSERT INTO PREFIXoptions (option_name, option_value, option_description) VALUES ('$name', '$value', '$description')";
+ $qry = str_replace('PREFIX', addslashes($login) . '_', $qry);
+
+ // Shouldn't be any result set since these are all INSERT queries.
+ mysql_query($qry);
+ } // foreach
+
+ // Need to update fileupload_realpath, fileupload_url, siteurl
+ // These values are not parsed correctly from schema because they utilize variables
+ $guessurl = 'http://' . $_SERVER['HTTP_HOST'] . $base . $login . '/';
+ mysql_query("UPDATE ". addslashes($login) ."_options SET option_value='" . ABSPATH . "wp-content/blogs/$login/images/' WHERE option_name='fileupload_realpath'");
+ mysql_query("UPDATE ". addslashes($login) ."_options SET option_value='{$guessurl}wp-content/blogs/$login/images/' WHERE option_name='fileupload_url'");
+ mysql_query("UPDATE ". addslashes($login) ."_options SET option_value='$guessurl', option_description='WordPress web address' WHERE option_name='siteurl'");
+ mysql_query("UPDATE ". addslashes($login) ."_options SET option_value='a:0:{}' WHERE option_name='active_plugins'");
+
+ // Need to add user information (login, pass, real name, e-mail, homepage) to db.
+ mysql_query("INSERT INTO {$login}_users (ID, user_login, user_nickname, user_email, user_level, user_idmode, user_firstname, user_lastname, user_url) VALUES ( '1', '$login', 'Administrator', '$email', '10', 'nickname', '$firstname', '$lastname', '$guessurl')");
+
+ // Set up a few options not to load by default
+ $fatoptions = array( 'moderation_keys', 'recently_edited' );
+ foreach ($fatoptions as $fatoption) :
+ mysql_query("UPDATE {$login}_options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
+ endforeach;
+
+ // Need to add some default information
+ $now = date('Y-m-d H:i:s');
+ $now_gmt = gmdate('Y-m-d H:i:s');
+ mysql_query("INSERT INTO ". addslashes($login) . "_categories (cat_ID, cat_name) VALUES ('0', 'Uncategorized')");
+ mysql_query("INSERT INTO ". addslashes($login) . "_posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_modified, post_modified_gmt) VALUES ('1', '$now', '$now_gmt', 'Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!', 'Hello world!', '0', '$now', '$now_gmt')");
+ mysql_query("INSERT INTO ". addslashes($login) . "_post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)");
+ mysql_query("INSERT INTO ". addslashes($login) . "_comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content) VALUES ('1', 'Mr WordPress', 'mr@wordpress.org', 'http://wordpress.org', '127.0.0.1', '$now', '$now_gmt', 'Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.')");
+ mysql_query("INSERT INTO ". addslashes($login) . "_linkcategories (cat_id, cat_name) VALUES (1, 'Blogroll')");
+
+ // Links
+ mysql_query("INSERT INTO ". addslashes($login) . "_links (link_url, link_name, link_category) VALUES ('http://photomatt.net/', 'Matt', 1);");
+ mysql_query("INSERT INTO ". addslashes($login) . "_links (link_url, link_name, link_category) VALUES ('http://blog.carthik.net/index.php', 'Carthik', 1);");
+ mysql_query("INSERT INTO ". addslashes($login) . "_links (link_url, link_name, link_category) VALUES ('http://zengun.org/weblog/', 'Michel', 1);");
+ mysql_query("INSERT INTO ". addslashes($login) . "_links (link_url, link_name, link_category) VALUES ('http://zed1.com/journalized/', 'Mike', 1);");
+ mysql_query("INSERT INTO ". addslashes($login) . "_links (link_url, link_name, link_category) VALUES ('http://dougal.gunters.org/', 'Dougal', 1);");
+ mysql_query("INSERT INTO ". addslashes($login) . "_links (link_url, link_name, link_category) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1);");
+ mysql_query("INSERT INTO ". addslashes($login) . "_links (link_url, link_name, link_category) VALUES ('http://derek.ditch.name', 'Derek', 1);");
+ mysql_query("INSERT INTO ". addslashes($login) . "_links (link_url, link_name, link_category) VALUES ('http://www.alexking.org/', 'Alex', 1);");
+ mysql_query("INSERT INTO ". addslashes($login) . "_links (link_url, link_name, link_category) VALUES ('http://mu.wordpress.org', 'WPMU', 1);");
+ mysql_query("INSERT INTO ". addslashes($login) . "_links (link_url, link_name, link_category) VALUES ('http://wordpress.org', 'Wordpress', 1);");
+
+
+ mysql_close($link);
+ }
+
+ // Taken from Aidan Lister <aidan@php.net> http://aidan.dotgeek.org/lib/?file=function.copyr.php
+ function copyr($source, $dest){
+
+ // Simple copy for a file
+ if (is_file($source)) {
+ return copy($source, $dest);
+ }
+
+ // Make destination directory
+ if (!is_dir($dest)) {
+ mkdir($dest);
+ }
+
+ // Loop through the folder
+ $dir = dir($source);
+ while (false !== $entry = $dir->read()) {
+ // Skip pointers
+ if ($entry == '.' || $entry == '..') {
+ continue;
+ }
+
+ // Deep copy directories
+ if ($dest !== "$source/$entry") {
+ copyr("$source/$entry", "$dest/$entry");
+ }
+ }
+
+ // Clean up
+ $dir->close();
+ return true;
+ }
+
+ // Taken from Aidan Lister <aidan@php.net> http://aidan.dotgeek.org/lib/?file=function.rmdirr.php
+ function rmdirr($dirname)
+ {
+ // Sanity check
+ if (!file_exists($dirname)) {
+ return false;
+ }
+
+ // Simple delete for a file
+ if (is_file($dirname)) {
+ return unlink($dirname);
+ }
+
+ // Loop through the folder
+ $dir = dir($dirname);
+ while (false !== $entry = $dir->read()) {
+ // Skip pointers
+ if ($entry == '.' || $entry == '..') {
+ continue;
+ }
+
+ // Recurse
+ rmdirr("$dirname/$entry");
+ }
+
+ // Clean up
+ $dir->close();
+ return rmdir($dirname);
+ }
+
+ function setup($login){
+ global $base;
+ list($cqueries, $iqueries, $updates) = getSchema();
+
+ foreach($cqueries as $key => $qry){
+ $cqueries[$key] = str_replace('PREFIX', $install_prefix, $qry);
+ }
+
+ // Create the blog dir
+ mkdir( ABSPATH . 'wp-content/blogs/' . $login, 0777);
+ mkdir( ABSPATH . 'wp-content/blogs/' . $login . '/images', 0777);
+ mkdir( ABSPATH . 'wp-content/blogs/' . $login . '/templates', 0777);
+ mkdir( ABSPATH . 'wp-content/blogs/' . $login . '/templates_c', 0777);
+ mkdir( ABSPATH . 'wp-content/blogs/' . $login . '/smartycache', 0777);
+
+ copyr(ABSPATH . 'wp-content/sitetemplates/humancondition/templates' , ABSPATH . 'wp-content/blogs/' . $login . '/templates');
+
+ // Modify template files with correct paths
+ $cssfile = file_get_contents(ABSPATH . 'wp-content/blogs/' . $login . '/templates/wp-layout.css');
+ $cssfile = str_replace('BASE', $base, $cssfile);
+
+ $fh = fopen(ABSPATH . 'wp-content/blogs/' . $login . '/templates/wp-layout.css', w);
+ fwrite($fh, $cssfile);
+ fclose($fh);
+
+ // Get the DB pristine
+ installdb($cqueries);
+ dboptions();
+ $password = setPasswd($login);
+
+ // Notify him/her that his/her blog is ready
+ emailNewUser($password);
+ }
+
+
+ /* ############ PAGE ENTRY STARTS HERE ##############*/
+
+ // Set all vars from POST or GET
+ $wpvarstoreset = array('action', 'login', 'firstname', 'lastname', 'email');
+ for($i=0; $i<count($wpvarstoreset); $i += 1){
+ $wpvar = $wpvarstoreset[$i];
+ if(! isset($$wpvar)){
+ if( empty( $_POST["$wpvar"])){
+ if(empty($_GET["$wpvar"])){
+ $$wpvar = '';
+ } else {
+ $$wpvar = $_GET["$wpvar"];
+ } // GET
+ } else {
+ $$wpvar = $_POST["$wpvar"];
+ } // POST
+ }
+ } // for
+
+ if( 'main' != $wpblog ){
+ // Give error message. This blog isn't authorized to modify the whole site.
+ print('<div class="wrap"><p align="center"><font color="red">Error: </font> This site is not authorized to access this page. Please contact your site administrator if you need assistance.</p></div>');
+ include('admin-footer.php');
+ exit;
+ }
+
+ /*
+ switch($action){
+
+ case 'options':
+ // Update the disk space allowed
+ wpmu_adminOptionSet('wpmu_space_allocated',$option['wpmu_space_allocated']);
+
+ do_action('wpmu_options_admin_set',array('option'=>&$option));
+
+ break;
+
+ case 'add':
+ // Perform some simple input validation.
+ if( $login == ''){
+ die(__('<div class="wrap"><p align="center"><font color=red>Error: </font> Please enter a login.</p></div>'));
+ } elseif ( $email == '' || ! preg_match('/^.+@.+\..{2,4}$/', $email) ){
+ die(__('<div class="wrap"><p align="center"><font color=red>Error: </font> Please enter a valid e-mail address.</p></div>'));
+ }
+
+ $current_users = wpmu_getBlogs();
+ foreach($current_users as $user){
+ if($login == $user)
+ die(__('<div class="wrap"><p align="center"><font color=red>Error: </font> Username already exists. Please select a new unique value</p></div>'));
+ }
+
+ setup($login);
+
+ break;
+
+ case 'delete':
+ if( $login == ''){
+ die(__('<div class="wrap"><p align="center"><font color=red>Error: </font> Something didn\'t work correctly. Please use the delete button.</p></div>'));
+ }
+
+ // Pure irreversible destruction. Do not try this at home, we are professionals
+ deletedb($login);
+ rmdirr(ABSPATH . '/wp-content/blogs/' . $login);
+ break;
+
+ case 'resetpw':
+ if( $login == ''){
+ die(__('<div class="wrap"><p align="center"><font color=red>Error: </font> Something didn\'t work correctly. Please use the reset password button.</p></div>'));
+ }
+
+ // Get user info
+ list($name, $email, $URI) = getUserInfo($login);
+
+ emailNewPass(setPasswd($login), $email, $login);
+ break;
+
+ default:
+ break;
+ }
+ */
+
+ $dirs = wpmu_getBlogs();
+ $spaceAllowed = wpmu_adminOption_get("wpmu_space_allocated", (1024 * 1024));
+
+ ?>
+ <!-- commented out html because plugin has not be sufficiently tested -->
+ <div class="wrap">
+ <p>The WPMU admin plugin is temporarily disabled.</p>
+ </div>
+ <!--
+ <div class="wrap">
+ <h2><?php _e('Blogs') ?></h2>
+ <table cellpadding="3" cellspacing="3" width="100%">
+ <tr>
+ <th><?php _e('Name') ?></th>
+ <th><?php _e('E-mail') ?></th>
+ <th><?php _e('Website') ?></th>
+ <th><?php _e('Login') ?></th>
+ <th><?php _e('Password') ?></th>
+ <th>&nbsp;</th>
+ </tr>
+ <tr>
+ </tr>
+ <?php foreach($dirs as $blog):
+ $thisBlog =& getUserInfo($blog);
+ ?>
+ <tr class="alternate">
+ <td><?php echo $thisBlog->name; ?></td>
+ <td><?php echo $thisBlog->user_email; ?></td>
+ <td><a href="<?php echo $thisBlog->user_url; ?>"><?php echo $thisBlog->user_url; ?></a></td>
+ <td style="text-align:center;"><?php echo $blog; ?></td>
+ <td><?php if('main' !== $blog): ?><a href="<?php echo get_settings('siteurl'); ?>/wp-admin/admin.php?page=wpmu-plugin.php&action=resetpw&login=<?php echo $blog; ?>" class="delete" onclick="return confirm('Are you sure you wish to reset this password? This cannot be undone.')">Reset</a><?php endif; ?></td>
+ <td><?php if('main' !== $blog): ?><a href="<?php echo get_settings('siteurl'); ?>/wp-admin/admin.php?page=wpmu-plugin.php&action=delete&login=<?php echo $blog; ?>" class="delete" onclick="return confirm('Are you sure you wish to delete this site? This cannot be undone and all data will be lost.')">Delete</a><?php endif; ?></td>
+ <tr>
+ <?php endforeach; ?>
+
+ </table>
+ </div>
+
+ <div class="wrap">
+ <h2>
+ <?php
+ _e('Options');
+ $options = array(
+ 0=>array(
+ 'caption'=>'Disk Space (bytes)',
+ 'name'=>'wpmu_space_allocated',
+ 'value'=>$spaceAllowed,
+ 'type'=>'text'
+ ),
+/* 1=>array(
+ 'caption'=>'Plugins Enabled',
+ 'name'=>'all_user_plugins',
+ 'value'=>'none',
+ 'type'=>'text'
+ )
+*/ );
+ do_action('wpmu_options_admin_get', array('options'=>&$options));
+ ?>
+ </h2>
+ <form name="form1" method="post" action="<?php echo get_settings('siteurl'); ?>/wp-admin/admin.php?page=wpmu-plugin.php">
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <input name="action" type="hidden" id="action" value="options" />
+ </tr>
+ <?php
+ foreach ($options as $thisOption) {
+ switch ($thisOption['type']) {
+ case 'text':
+ ?>
+ <tr>
+ <th scope="row" width="33%"><?php _e($thisOption['caption']) ?></th>
+ <td width="66%"><input name="option[<?php echo $thisOption['name']; ?>]" type="<?php echo $thisOption['type']; ?>" id="option[<?php echo $thisOption['name']; ?>]" value="<?php echo $thisOption['value']; ?>"/></td>
+ </tr>
+ <?php
+ break;
+
+ case 'checkbox':
+ if (is_array($thisOption['value'])) {
+ ?>
+ <tr>
+ <td align="right"><b><?php _e('Plugins') ?></b></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ <table class="editform" width="100%">
+ <tr>
+ <td width="33%"><b><?php _e('Plugin Name');?></b></td><td width="66%"><b><?php _e('Active');?></b></td>
+ </tr>
+ <?php
+ foreach ($thisOption['value'] as $filename => $thisItem) {
+ ?>
+ <tr>
+ <td><?php echo $thisItem['Name'] ?></td>
+ <td align="center"><input name="option[<?php echo $thisOption['name']; ?>][<?php echo $filename; ?>]" type="checkbox" id="option[<?php echo $thisOption['name']; ?>][<?php echo $thisOption['name']; ?>]" value="1" <?php checked('1', $thisItem['enabled']) ?> /></td>
+ </tr>
+ <?php
+ }
+ ?>
+ </table>
+ </td>
+ </tr>
+ <?php
+ } else {
+ ?>
+ <tr>
+ <th scope="row" width="33%"><?php _e($thisOption['caption']) ?></th>
+ <td width="66%"><input name="option[<?php echo $thisOption['name']; ?>]" type="<?php echo $thisOption['type']; ?>" id="option[<?php echo $thisOption['name']; ?>]" value="1"/></td>
+ </tr>
+ <?php
+ }
+ break;
+ }
+ }
+ ?>
+ </table>
+ <p class="submit">
+ <input name="options" type="submit" id="options" value="<?php _e('Update') ?> &raquo;" />
+ </p>
+ </form>
+ </div>
+ -->
+
+ <?php /*
+ <!--
+
+ <div class="wrap">
+ <h2><?php _e('Add New Blog') ?></h2>
+ <form name="form1" method="post" action="<?php echo get_settings('siteurl'); ?>/wp-admin/admin.php?page=wpmu-plugin.php">
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th scope="row" width="33%"><?php _e('Nickname') ?>
+ <input name="action" type="hidden" id="action" value="add" /></th>
+ <td width="66%"><input name="login" type="text" id="user_login" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('First Name') ?> </th>
+ <td><input name="firstname" type="text" id="firstname" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Last Name') ?> </th>
+ <td><input name="lastname" type="text" id="lastname" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('E-mail') ?></th>
+ <td><input name="email" type="text" id="email" /></td>
+ </tr>
+ </table>
+ <p class="submit">
+ <input name="add" type="submit" id="add" value="<?php _e('Add') ?> &raquo;" />
+ </p>
+ </form>
+ </div>
+ -->
+ */
+ ?>
+
+
+ <?php
+
+ // if (is_plugin_page())
+ } else {
+ if('main' == $wpblog){
+ add_action('admin_menu', 'wpmu_admin_run');
+ }
+
+ } // else
+
+?>
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/img/bg.gif b/wp-inst/wp-content/sitetemplates/humancondition/img/bg.gif
new file mode 100644
index 0000000..c54c3d6
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/img/bg.gif
Binary files differ
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/img/bullet.gif b/wp-inst/wp-content/sitetemplates/humancondition/img/bullet.gif
new file mode 100644
index 0000000..e22be35
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/img/bullet.gif
Binary files differ
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/img/date.gif b/wp-inst/wp-content/sitetemplates/humancondition/img/date.gif
new file mode 100644
index 0000000..315ea86
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/img/date.gif
Binary files differ
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/img/fg.gif b/wp-inst/wp-content/sitetemplates/humancondition/img/fg.gif
new file mode 100644
index 0000000..8f3f7f1
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/img/fg.gif
Binary files differ
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/img/footer.gif b/wp-inst/wp-content/sitetemplates/humancondition/img/footer.gif
new file mode 100644
index 0000000..5148dbe
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/img/footer.gif
Binary files differ
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/img/header.gif b/wp-inst/wp-content/sitetemplates/humancondition/img/header.gif
new file mode 100644
index 0000000..eb9add4
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/img/header.gif
Binary files differ
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/img/posts.gif b/wp-inst/wp-content/sitetemplates/humancondition/img/posts.gif
new file mode 100644
index 0000000..d1d9efd
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/img/posts.gif
Binary files differ
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/img/today.gif b/wp-inst/wp-content/sitetemplates/humancondition/img/today.gif
new file mode 100644
index 0000000..c48e391
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/img/today.gif
Binary files differ
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/index.php b/wp-inst/wp-content/sitetemplates/humancondition/index.php
new file mode 100644
index 0000000..fac9dcd
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/index.php
@@ -0,0 +1,10 @@
+<?php
+
+/* $Id: index.php,v 1.1.1.1 2004/10/14 12:07:23 donncha Exp $ */
+
+$author = "Ian Main";
+$title = "Human Condition";
+$when = "2004";
+$url = "http://www.e-lusion.com/";
+$description = "Runner up of a WP <a href='http://www.alexking.org/index.php?content=software/wordpress/styles.php'>style competition</a> held by Alex King.";
+?>
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/screenshot-sm.gif b/wp-inst/wp-content/sitetemplates/humancondition/screenshot-sm.gif
new file mode 100644
index 0000000..e146d6b
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/screenshot-sm.gif
Binary files differ
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/screenshot.gif b/wp-inst/wp-content/sitetemplates/humancondition/screenshot.gif
new file mode 100644
index 0000000..329bff9
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/screenshot.gif
Binary files differ
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/templates/comments.html b/wp-inst/wp-content/sitetemplates/humancondition/templates/comments.html
new file mode 100644
index 0000000..06b10bc
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/templates/comments.html
@@ -0,0 +1,57 @@
+<h2 id="comments">{comments_number zero="Comments" one="1 Comment" more="% Comments"}
+{if $post->comment_status == 'open'}
+<a href="#postcomment" title="{_e text="Leave a comment";}">&raquo;</a>
+{/if}
+</h2>
+{if $post->ping_status}
+<p>{_e text='The <acronym title="Uniform Resource Identifier">URI</acronym> to TrackBack this entry is:'} <em>{trackback_url}</em></p>
+{/if}
+{if $comments != ''}
+ <ol id="commentlist">
+ {foreach from=$comments key=key item=comment}
+ {globalvar var='comment' value=$comment}
+ <li id="comment-{comment_ID}">
+ {comment_text}
+ <p><cite>{comment_type} {_e text="by"} {comment_author_link} &#8212; {comment_date} @ <a href="#comment-{comment_ID}">{comment_time}</a></cite> {edit_comment_link link='Edit This' before=' |'}</p>
+ </li>
+ {/foreach}
+ </ol>
+{else} <!-- this is displayed if there are no comments so far -->
+ <p>{_e text="No comments yet."}</p>
+{/if}
+<p>{comments_rss_link link_text='<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.'}</p>
+<h2 id="postcomment">{_e text="Leave a comment"}</h2>
+{if 'open' == $post->comment_status}
+<p>{_e text="Line and paragraph breaks automatic, e-mail address never displayed, <acronym title='Hypertext Markup Language'>HTML</acronym> allowed:"} <code>{allowed_tags}</code></p>
+
+<form action="{$siteurl}/wp-comments-post.php" method="post" id="commentform">
+ <p>
+ <input type="text" name="author" id="author" class="textarea" value="{insert name=var var=comment_author}" size="28" tabindex="1" />
+ <label for="author">{_e text="Name"}</label> {if $req != ''} {_e text='(required)'} {/if}
+ <input type="hidden" name="comment_post_ID" value="{$post->ID}" />
+ <input type="hidden" name="redirect_to" value="{$redirect_to}" />
+ </p>
+
+ <p>
+ <input type="text" name="email" id="email" value="{insert name=var var=comment_author_email}" size="28" tabindex="2" />
+ <label for="email">{_e text="E-mail"}</label> {if $req != ''} {_e text='(required)'}{/if}
+ </p>
+
+ <p>
+ <input type="text" name="url" id="url" value="{insert name=var var=comment_author_url}" size="28" tabindex="3" />
+ <label for="url">{_e text="<acronym title='Uniform Resource Identifier'>URI</acronym>"}</label>
+ </p>
+
+ <p>
+ <label for="comment">{_e text="Your Comment"}</label>
+ <br />
+ <textarea name="comment" id="comment" cols="60" rows="4" tabindex="4"></textarea>
+ </p>
+
+ <p>
+ <input name="submit" type="submit" tabindex="5" value="{_e text="Say It!"}" />
+ </p>
+</form>
+{else} <!-- comments are closed -->
+<p>{_e text="Sorry, the comment form is closed at this time."}</p>
+{/if}
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/templates/index.html b/wp-inst/wp-content/sitetemplates/humancondition/templates/index.html
new file mode 100644
index 0000000..8e0f633
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/templates/index.html
@@ -0,0 +1,127 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
+<title>{bloginfo show='name'} {single_post_title prefix=' :: '}{single_cat_title prefix=' :: '}{single_month_title prefix=' :: '}</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="imagetoolbar" content="no">
+<meta content="TRUE" name="MSSmartTagsPreventParsing">
+<meta name="generator" content="WordPressMU, WP {$wp_version}"><!-- leave this for stats -->
+<style type="text/css" media="screen">
+@import url( "{$siteurl}/templates/wp-layout.css" );
+</style>
+<link rel="alternate" type="text/xml" title="RDF" href="{bloginfo show='rdf_url'}">
+<link rel="alternate" type="text/xml" title="RSS" href="{bloginfo show='rss2_url'}">
+<link rel="pingback" href="{bloginfo show='pingback_url'}"></head>
+</head>
+<body>
+{comments_popup_script}
+<div id="rap">
+<h1 id="header"><a href="{$siteurl}" title="{bloginfo show='name'}">{bloginfo show='name'}</a></h1>
+<div id="content">
+{$content}
+<br /><br />
+<blockquote><div class='STORYCONTENT' align='middle'>{posts_nav_link}</div></blockquote>
+<br>
+{referer}
+{if $refererlinks != ""}
+<blockquote>
+Referers in the last 24 hours:
+<ol>
+{foreach from=$refererlinks item=link}
+<li> <a href="{$link.referingURL}">{$link.baseDomain}</a> ({$link.visitTimes})
+{/foreach}
+</ol>
+</blockquote>
+{/if}
+<br><br><br><br><br><br><br>
+<br><br><br><br><br><br><br>
+<br><br><br><br><br><br><br>
+</div>
+<div id="menu">
+ <ul>
+ <li><a href="{$siteurl}">Home</a></li>
+ <li>Links:
+ <ul>
+ {get_links category='-1' before='<li>' after='</li>' between='' show_images='0' orderby='_updated' show_description='0' show_rating='0' limit='-1' show_updated='-1'}
+ </ul>
+ </li>
+ <li>Categories:
+ <ul>
+ {list_cats optionall='0' all='All' sort_column='name'}
+ </ul>
+ </li>
+ <li>Search: <form id="searchform" method="get" action="{$Smarty.server.PHP_SELF}">
+ <div><input type="text" name="s" size="15" /><br />
+ <input type="submit" name="submit" value="search" />
+ </div></form>
+ </li>
+ <li>Archives:
+ <ul>
+ {get_archives type='monthly'}
+ </ul>
+ </li>
+ {lastposts posts='20'}
+ {if $lastposts != ''}
+ <li>Most Recent Posts
+ <ul>
+ {foreach from=$lastposts key=id item=title}
+ <li><a href="{get_permalink id=$id}" title="{$title}">{$title|truncate:20:"..."}</a></li>
+ {/foreach}
+ </ul>
+ </li>
+ {/if}
+ {todayayearago when='month'}
+ {if $todayayearago != ''}
+ <li>A Month Ago
+ <ul>
+ {foreach from=$todayayearago key=id item=details}
+ <li><a href="{get_permalink id=$id}" title="{$details.content|truncate:20:"..."}">{$details.title|truncate:20:"..."}</a></li>
+ {/foreach}
+ </ul>
+ </li>
+ {/if}
+
+ {popularposts}
+ {if $pposts != ''}
+ <li>Most Popular Posts
+ <ul>
+ {foreach from=$pposts key=key item=hits}
+ <li><nobr><a href="{get_permalink id=$hits.postID}" title="{$hits.title}">{$hits.title|truncate:30:"..."}</a>: {$key}</nobr></li>
+ {/foreach}
+ </ul>
+ </li>
+ {/if}
+ <br><br>
+ <li>blo.gs favourites
+ <ul>
+ {blogroll blogID="" blogteststring=""}
+ </ul>
+ </li>
+ <li>Most Popular Clicks
+ <ul>
+ {wp_ozh_click_topclicks limit=10}
+ </ul>
+
+ <li>Other:
+ <ul>
+ <li><a href="{$siteurl}/wp-login.php">login</a></li>
+ </ul>
+ </li>
+ <li>Meta:
+ <ul>
+ <li><a href="{bloginfo show='rss_url'}">RSS .92</a></li>
+ <li><a href="{bloginfo show='rdf_url'}">RDF 1.0</a></li>
+ <li><a href="{bloginfo show='rss2_url'}">RSS 2.0</a></li>
+ <li><a href="{bloginfo show='comments_rss2_url'}">Comments RSS 2.0</a></li>
+ <li><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a></li>
+ <li><a href="http://wordpress.org/" title="Powered by WordPress, personal publishing platform">WP</a></li>
+ <li><a href="http://mu.wordpress.org/" title="Powered by WordPress, personal publishing platform">WPMU</a></li>
+ </ul>
+ </li>
+ </ul>
+<!-- WordPress Counter - Check the referers list in your backend! -->
+<script type="text/javascript" language="JavaScript1.2" src="{$siteurl}/wp-counter.php"></script>
+<noscript>
+<img width=1 height=1 src="{$siteurl}/wp-counter.php?page=img&loc={$smarty.server.SERVER_NAME}/{$smarty.server.REQUEST_URI}" alt="Stat Counter" border=0>
+</noscript>
+</div>
+</body>
+</html>
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/templates/post.html b/wp-inst/wp-content/sitetemplates/humancondition/templates/post.html
new file mode 100644
index 0000000..f61aa85
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/templates/post.html
@@ -0,0 +1,18 @@
+{the_date d='' before='<h2>' after='</h2>'}
+<div class="post">
+<h3 class="storytitle" id="post-{the_ID}"> <a href="{permalink_link}" rel="bookmark" title="Permanent Link: {the_title_rss}">{the_title}</a> </h3>
+<div class="meta">Filed under: {the_category seperator=", "}</div>
+<div class="storycontent">
+ {the_content}
+</div>
+
+<div class="feedback">
+ {link_pages before='<br />Pages: ' after='<br />' next_or_number='number'}
+ {comments_popup_link zero='Comments (0)' one='Comments (1)' more='Comments (%)'}
+</div>
+
+<!--
+{trackback_rdf}
+
+-->
+</div>
diff --git a/wp-inst/wp-content/sitetemplates/humancondition/templates/wp-layout.css b/wp-inst/wp-content/sitetemplates/humancondition/templates/wp-layout.css
new file mode 100644
index 0000000..84d689f
--- /dev/null
+++ b/wp-inst/wp-content/sitetemplates/humancondition/templates/wp-layout.css
@@ -0,0 +1,413 @@
+/* =-=-=-=-=-=-=-=-=-[Theme Name: Human Condition]-=-=-=-=-=-=-=-=-= */
+/* =-=-=-=-=-=-=-=-=-[Designed for Alexking Wordpress Competition - 30/01/04 - Ian Main - www.e-lusion.com]-=-=-=-=-=-=-=-=-= */
+
+/* =-=-=-=-=-=-=-=-=-[Licensing]-=-=-=-=-=-=-=-=-=
+
+1. GPL - Ian Main */
+
+/* =-=-=-=-=-=-=-=-=-[Hacks Used]-=-=-=-=-=-=-=-=-=
+
+1. BMH - #content */
+
+body, html {
+ margin: 0 auto;
+ background: #E4F2FF url(BASE/wp-inst/wp-content/sitetemplates/humancondition/img/bg.gif) repeat-y center;
+ width: 767px;
+ font-family: Lucida Grande, Lucida Sans Unicode, Lucida, Helvetica, Verdana, Arial, Sans-serif;
+ text-align: center;
+ }
+
+a:link {
+ color: #3F729E;
+ text-decoration: none;
+ page-break-after: always;
+ }
+
+a:visited {
+ color: #ABABAB;
+ text-decoration: none;
+ }
+
+a:hover, a:active {
+ color: #093860;
+ }
+
+#rap {
+ margin-left: auto;
+ margin-right: auto;
+ width: 749px;
+ }
+
+#header {
+ background: url(BASE/wp-inst/wp-content/sitetemplates/humancondition/img/header.gif) no-repeat;
+ height: 154px;
+ width: 747px;
+ margin: 0 auto;
+ text-align: left;
+ }
+
+#header a {
+ text-decoration: none;
+ font-size: .8em;
+ position: relative;
+ top: 95px;
+ left: 10px;
+ font-family: verdana, arial, helvetica, geneva, sans-serif;
+ text-transform: uppercase;
+ }
+
+#header a:visited {
+ color: #3F729E;
+ }
+
+#header a:hover {
+ color: #093860;
+ }
+
+#content {
+ text-align: left;
+ background: url(BASE/wp-inst/wp-content/sitetemplates/humancondition/img/fg.gif) repeat-y;
+ width: 749px;
+ padding: 10px;
+ float: left;
+ voice-family: "\"}\"";
+ voice-family: inherit;
+ width: 729px;
+ }
+
+.post {
+ width: 540px;
+ }
+
+h2 {
+ width: 508px;
+ font-size: .7em;
+ background: url(BASE/wp-inst/wp-content/sitetemplates/humancondition/img/date.gif) no-repeat;
+ height: 23px;
+ margin: 0;
+ padding-top: 4px;
+ padding-left: 5px;
+ color: #0E2E4A;
+ }
+
+h3 {
+ font-size: .9em;
+ margin: 5px 0 0 0;
+ }
+
+h3 a:link {
+ color: #000;
+ }
+
+h3 a:visited {
+ color: #000;
+ text-decoration: none;
+ }
+
+h3 a:hover, a:active {
+ color: #093860;
+ }
+
+#commentlist {
+ margin: 0;
+ padding: 0;
+ }
+
+#commentlist li {
+ background: #F3F3F3;
+ border: 1px solid #ddd;
+ font-size: 1em;
+ width: 530px;
+ margin-bottom: 20px;
+ padding: 0 5px 3px 5px;
+ }
+
+ol#commentlist {
+ font-size: 1em;
+ list-style: none;
+ }
+
+#commentlist code {
+ font-family: Courier New, Courier, mono;
+ border: 1px dashed #F3A0A0;
+ background: #F9E4E4;
+ padding: 0 5px 0 5px;
+ text-align: left;
+ }
+
+#commentlist cite {
+ margin: 0;
+ padding: 5px;
+ font-size: .9em;
+ font-style: normal;
+ background: #fff;
+ }
+
+#commentlist li p {
+ width: 530px;
+ }
+
+
+#content p {
+ font-size: .7em;
+ /* width: 535px; */
+ }
+
+.storycontent ul {
+ list-style-type: none;
+ margin-left: 10px;
+ margin-right: 20px;
+ padding: 0;
+ font-size: .7em;
+ }
+
+.storycontent ul li {
+ list-style-image: url(BASE/wp-inst/wp-content/sitetemplates/humancondition/img/bullet.gif);
+ margin-left: 20px;
+ }
+
+.storycontent ol {
+
+ margin-left: 10px;
+ margin-right: 20px;
+ padding: 0;
+ font-size: .7em;
+ }
+
+.storycontent ol li {
+
+ margin-left: 20px;
+ }
+
+.meta {
+ font-size: .7em;
+ background: #eee;
+ margin: 5px 0 0 0;
+ padding: 3px;
+ width: 502px;
+ color: #3A3A3A;
+ }
+
+.post-categories {
+ display: inline;
+ margin: 0;
+ padding: 0;
+ }
+
+.post-categories li {
+ display: inline;
+ list-style-type: none;
+ padding: 0;
+ margin: 0;
+ }
+
+.storycontent {
+ font-size: 1em;
+ border-left: 1px solid #ddd;
+ padding-left: 5px;
+ text-align: justify;
+ width: 535px;
+ margin: 10px 0 0 0;
+ }
+
+.storycontent a:hover {
+ background: #EFF8FF;
+ }
+
+.feedback {
+ font-size: .7em;
+ background: #eee;
+ margin: 10px 0 40px 0;
+ padding: 3px;
+ width: 502px;
+ color: #3A3A3A;
+ }
+
+#menu {
+ width: 200px;
+ margin-left: -207px;
+ float: right;
+ text-align: left;
+ margin-bottom: 20px;
+ }
+
+#menu ul {
+ color: #030;
+ font-weight: bold;
+ list-style-type: none;
+ margin: 0 0 0 20px;
+ padding-left: 10px;
+ width: 160px;
+ }
+
+#menu ul li {
+ color: #242424;
+ font-family: Lucida Grande, Lucida Sans Unicode, Lucida, Helvetica, Verdana, Arial, Sans-serif;
+ font-weight: bold;
+ font-size: .7em;
+ margin-top: 15px;
+ padding: 5px;
+ border: 1px solid #D7D7D7;
+ background: #EAEAEA;
+ }
+
+#menu ul ul {
+ font-weight: normal;
+ line-height: 100%;
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+ text-align: left;
+ }
+
+#menu ul ul li {
+ background: none;
+ font-family: Lucida Grande, Lucida Sans Unicode, Lucida, Helvetica, Verdana, Arial, Sans-serif;
+ font-size: 1em;
+ font-weight: normal;
+ margin-top: 5px;
+ padding: 0;
+ border: 0;
+ }
+
+#menu input {
+ background-color: #fff;
+ border: 1px solid #3F729E;
+ font-family: verdana, arial, helvetica, geneva, sans-serif;
+ font-size: .9em;
+ font-weight: normal;
+ }
+
+#wp-calendar {
+ background: #fff;
+ border: 1px solid #ddd;
+ empty-cells: show;
+ font-size: 14px;
+ width: 140px;
+ }
+
+#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: url(BASE/wp-inst/wp-content/sitetemplates/humancondition/img/posts.gif);
+ color: #333;
+ }
+
+#wp-calendar caption {
+ color: #242424;
+ font-size: .8em;
+ text-align: left;
+ padding-bottom: 2px;
+ padding-left: 2px;
+ }
+
+#wp-calendar td {
+ color: #999;
+ font: normal 11px Verdana, Geneva, sans-serif;
+ padding: 1px 1px;
+ text-align: right;
+ }
+
+#wp-calendar td.pad:hover {
+ background: #fff;
+ }
+
+#wp-calendar #today {
+ background: url(BASE/wp-inst/wp-content/sitetemplates/humancondition/img/today.gif);
+ color: #666;
+ }
+
+#wp-calendar th {
+ color: #7EABD1;
+ font-style: normal;
+ text-transform: capitalize;
+ }
+
+.credit {
+
+ clear: both;
+ background: url(BASE/wp-inst/wp-content/sitetemplates/humancondition/img/footer.gif) no-repeat;
+ width: 747px;
+ height: 26px;
+ margin: 0 auto;
+ font-size: .6em;
+ line-height: 2.4em;
+ text-align: center;
+ }
+
+cite {
+ margin: 0;
+ padding: 0;
+ font-size: .9em;
+ font-style: normal;
+ }
+
+/* =-=-=-=-=-=-=-=-=-[Formatting]-=-=-=-=-=-=-=-=-= */
+
+blockquote {
+ border: 1px dashed #7EACD1;
+ margin: 0;
+ background: #F2F9FF;
+ padding: 5px;
+ text-align: left;
+ font-size: .9em;
+ }
+
+code {
+ font-size: 1.2em;
+ color: #4C4C4C;
+ }
+
+abbr, acronym {
+ border-bottom: 3px double #7DAAD0;
+ }
+
+input {
+ border: 3px double #7DAAD0;
+ background: #EFF8FF;
+ margin: 5px;
+ padding-left: 3px;
+ color: #3F729E;
+ font-family: Arial, Helvetica, sans-serif;
+ }
+
+input:hover {
+ background: #D2E5F4;
+ }
+
+textarea {
+ border: 3px double #7DAAD0;
+ background: #EFF8FF;
+ margin: 5px;
+ padding-left: 3px;
+ color: #3F729E;
+ width: 70%;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 1.2em;
+ }
+
+textarea:hover {
+ background: #D2E5F4;
+ }
+
+select {
+ border: 3px double #7DAAD0;
+ background: #EFF8FF;
+ margin: 5px;
+ padding-left: 3px;
+ color: #3F729E;
+ font-family: Arial, Helvetica, sans-serif;
+ }
diff --git a/wp-inst/wp-content/smarty-plugins/block.textformat.php b/wp-inst/wp-content/smarty-plugins/block.textformat.php
new file mode 100644
index 0000000..aaebab2
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/block.textformat.php
@@ -0,0 +1,102 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {textformat}{/textformat} block plugin
+ *
+ * Type: block function<br>
+ * Name: textformat<br>
+ * Purpose: format text a certain way with preset styles
+ * or custom wrap/indent settings<br>
+ * @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat}
+ * (Smarty online manual)
+ * @param array
+ * <pre>
+ * Params: style: string (email)
+ * indent: integer (0)
+ * wrap: integer (80)
+ * wrap_char string ("\n")
+ * indent_char: string (" ")
+ * wrap_boundary: boolean (true)
+ * </pre>
+ * @param string contents of the block
+ * @param Smarty clever simulation of a method
+ * @return string string $content re-formatted
+ */
+function smarty_block_textformat($params, $content, &$smarty)
+{
+ if (is_null($content)) {
+ return;
+ }
+
+ $style = null;
+ $indent = 0;
+ $indent_first = 0;
+ $indent_char = ' ';
+ $wrap = 80;
+ $wrap_char = "\n";
+ $wrap_cut = false;
+ $assign = null;
+
+ foreach ($params as $_key => $_val) {
+ switch ($_key) {
+ case 'style':
+ case 'indent_char':
+ case 'wrap_char':
+ case 'assign':
+ $$_key = (string)$_val;
+ break;
+
+ case 'indent':
+ case 'indent_first':
+ case 'wrap':
+ $$_key = (int)$_val;
+ break;
+
+ case 'wrap_cut':
+ $$_key = (bool)$_val;
+ break;
+
+ default:
+ $smarty->trigger_error("textformat: unknown attribute '$_key'");
+ }
+ }
+
+ if ($style == 'email') {
+ $wrap = 72;
+ }
+
+ // split into paragraphs
+ $_paragraphs = preg_split('![\r\n][\r\n]!',$content);
+ $_output = '';
+
+ for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
+ if ($_paragraphs[$_x] == '') {
+ continue;
+ }
+ // convert mult. spaces & special chars to single space
+ $_paragraphs[$_x] = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'), array(' ',''), $_paragraphs[$_x]);
+ // indent first line
+ if($indent_first > 0) {
+ $_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x];
+ }
+ // wordwrap sentences
+ $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut);
+ // indent lines
+ if($indent > 0) {
+ $_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]);
+ }
+ }
+ $_output = implode($wrap_char . $wrap_char, $_paragraphs);
+
+ return $assign ? $smarty->assign($assign, $_output) : $_output;
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/compiler.assign.php b/wp-inst/wp-content/smarty-plugins/compiler.assign.php
new file mode 100644
index 0000000..2e02017
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/compiler.assign.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {assign} compiler function plugin
+ *
+ * Type: compiler function<br>
+ * Name: assign<br>
+ * Purpose: assign a value to a template variable
+ * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
+ * (Smarty online manual)
+ * @param string containing var-attribute and value-attribute
+ * @param Smarty_Compiler
+ */
+function smarty_compiler_assign($tag_attrs, &$compiler)
+{
+ $_params = $compiler->_parse_attrs($tag_attrs);
+
+ if (!isset($_params['var'])) {
+ $compiler->_syntax_error("assign: missing 'var' parameter", E_USER_WARNING);
+ return;
+ }
+
+ if (!isset($_params['value'])) {
+ $compiler->_syntax_error("assign: missing 'value' parameter", E_USER_WARNING);
+ return;
+ }
+
+ return "\$this->assign({$_params['var']}, {$_params['value']});";
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/custom_fields.enclosure.php b/wp-inst/wp-content/smarty-plugins/custom_fields.enclosure.php
new file mode 100644
index 0000000..d4a359b
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/custom_fields.enclosure.php
@@ -0,0 +1,17 @@
+<?php
+
+/* $Id: custom_fields.enclosure.php,v 1.2 2004/10/14 14:15:50 donncha Exp $ */
+
+
+function enclosure( &$smarty, $params, $custom_params )
+{
+ global $siteurl, $wpblog;
+
+ while( list( $key, $val ) = each( $custom_params ) )
+ {
+ $enclosure[] = split( "\n", $val );
+ }
+ $smarty->assign( "enclosure", $enclosure );
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/custom_fields.photoblog.php b/wp-inst/wp-content/smarty-plugins/custom_fields.photoblog.php
new file mode 100644
index 0000000..968cc59
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/custom_fields.photoblog.php
@@ -0,0 +1,14 @@
+<?php
+
+/* $Id: custom_fields.photoblog.php,v 1.3 2004/11/10 10:27:29 donncha Exp $ */
+
+
+function photoblog( &$smarty, $params, $custom_params )
+{
+ global $siteurl, $wpblog;
+
+ $smarty->assign( "photoblog", $siteurl."/images/photoblog-".$custom_params[0].".jpg" );
+
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.assign.php b/wp-inst/wp-content/smarty-plugins/function.assign.php
new file mode 100644
index 0000000..0eb2960
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.assign.php
@@ -0,0 +1,30 @@
+<?php
+
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: function
+ * Name: assign
+ * Purpose: assign a value to a template variable
+ * -------------------------------------------------------------
+ */
+function smarty_function_assign($params, &$smarty)
+{
+ extract($params);
+
+ if (empty($var)) {
+ $smarty->trigger_error("assign: missing 'var' parameter");
+ return;
+ }
+
+ if (!in_array('value', array_keys($params))) {
+ $smarty->trigger_error("assign: missing 'value' parameter");
+ return;
+ }
+
+ $smarty->assign($var, $value);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.assign_debug_info.php b/wp-inst/wp-content/smarty-plugins/function.assign_debug_info.php
new file mode 100644
index 0000000..8015624
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.assign_debug_info.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {assign_debug_info} function plugin
+ *
+ * Type: function<br>
+ * Name: assign_debug_info<br>
+ * Purpose: assign debug info to the template<br>
+ * @param array unused in this plugin, this plugin uses {@link Smarty::$_config},
+ * {@link Smarty::$_tpl_vars} and {@link Smarty::$_smarty_debug_info}
+ * @param Smarty
+ */
+function smarty_function_assign_debug_info($params, &$smarty)
+{
+ $assigned_vars = $smarty->_tpl_vars;
+ ksort($assigned_vars);
+ if (@is_array($smarty->_config[0])) {
+ $config_vars = $smarty->_config[0];
+ ksort($config_vars);
+ $smarty->assign("_debug_config_keys", array_keys($config_vars));
+ $smarty->assign("_debug_config_vals", array_values($config_vars));
+ }
+
+ $included_templates = $smarty->_smarty_debug_info;
+
+ $smarty->assign("_debug_keys", array_keys($assigned_vars));
+ $smarty->assign("_debug_vals", array_values($assigned_vars));
+
+ $smarty->assign("_debug_tpls", $included_templates);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.blogroll.php b/wp-inst/wp-content/smarty-plugins/function.blogroll.php
new file mode 100644
index 0000000..843f597
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.blogroll.php
@@ -0,0 +1,145 @@
+<?php
+
+/* $Id: function.blogroll.php,v 1.2 2004/11/30 00:50:56 donncha Exp $ */
+
+// Modified version of PHP blogroll by Phil Ringnalda @ http://philringnalda.com/phpblogroll/
+// Modified by Donncha O Caoimh, donncha@linux.ie
+
+$GLOBALS['blogroll_open_tags' ] = array(
+ 'WEBLOGUPDATES' => '<WEBLOGUPDATES>',
+ 'WEBLOG' => '<WEBLOG>');
+
+$GLOBALS['blogroll_close_tags' ] = array(
+ 'WEBLOGUPDATES' => '</WEBLOGUPDATES>');
+
+// declare the character set - UTF-8 is the default
+$GLOBALS['blogroll_type' ] = 'ISO-8859-1';
+
+
+function smarty_function_blogroll($params, &$smarty)
+{
+ global $blogroll_open_tags, $blogroll_close_tags, $blogroll_type;
+ global $b2sitePath, $site, $blogteststring;
+ global $wpblog;
+
+ $origCache = $smarty->cache_dir;
+ $smarty->cache_dir = ABSPATH . "/wp-content/smarty-cache";
+
+ extract( $params );
+ if( $blogID == '' )
+ {
+ $smarty->display( ABSPATH . "/wp-content/smarty-templates/noblogroll.tpl" );
+ }
+ else
+ {
+ $blogroll_xml_source = 'http://blo.gs/'.$blogID.'/favorites.xml';
+ //$blogroll_xml_source = '/tmp/favorites.xml';
+ $blogroll_xml_test = $blogteststring;
+
+ $smarty->caching = 2;
+ $smarty->cache_lifetime = 7200; // cache is updated at most once every hour.
+ if( $smarty->template_exists( "blogroll.tpl" ) == false )
+ {
+ copy( ABSPATH . "/wp-content/smarty-templates/blogroll.tpl", ABSPATH . "/wp-content/blogs/".$wpblog."/templates/blogroll.tpl" );
+ $origDir = $smarty->template_dir;
+ $smarty->template_dir = ABSPATH . "/templates";
+ }
+
+ if( $smarty->is_cached( "blogroll.tpl", $wpblog ) == false )
+ {
+ $smarty->clear_cache( 'blogroll.tpl', $wpblog );
+ $blogroll_remote_fp = @fopen($blogroll_xml_source,"r");
+ $blogroll_remote_data = '';
+ if( $blogroll_remote_fp )
+ {
+ while (!feof ($blogroll_remote_fp))
+ {
+ $blogroll_remote_data .= fgets($blogroll_remote_fp, 4096);
+ }
+ fclose($blogroll_remote_fp);
+ if (stristr($blogroll_remote_data, $blogroll_xml_test))
+ {
+ // create our parser
+ $blogroll_xml_parser = xml_parser_create($blogroll_type);
+
+ // set some parser options
+ xml_parser_set_option($blogroll_xml_parser, XML_OPTION_CASE_FOLDING, true);
+ xml_parser_set_option($blogroll_xml_parser, XML_OPTION_TARGET_ENCODING, $blogroll_type);
+
+ // this tells PHP what functions to call when it finds an element
+ // these funcitons also handle the element's attributes
+ xml_set_element_handler($blogroll_xml_parser, 'blogrollStartElement','blogrollEndElement');
+
+ if (!xml_parse($blogroll_xml_parser, $blogroll_remote_data)) {
+ die(sprintf( "XML error: %s at line %d\n\n",
+ xml_error_string(xml_get_error_code($blogroll_xml_parser)),
+ xml_get_current_line_number($blogroll_xml_parser)));
+ }
+
+ xml_parser_free($blogroll_xml_parser);
+ }
+
+ }
+ else
+ {
+ $smarty->assign( "gendate", date("n/d g:ia") );
+ $links[] = array( 'url' => '', 'name' => 'Not Available' );
+ $smarty->assign( "links", $links );
+ }
+ }
+ $smarty->display( "blogroll.tpl", $wpblog );
+ }
+ $smarty->cache_dir = $origCache;
+ if( $origDir != '' )
+ $smarty->template_dir = $origDir;
+}
+
+function blogrollStartElement($parser, $name, $attrs=''){
+ global $blogroll_open_tags, $blogroll_temp, $blogroll_current_tag, $blogroll_weblog_index;
+ $blogroll_current_tag = $name;
+ if ($format = $blogroll_open_tags[$name]){
+ switch($name){
+ case 'WEBLOGUPDATES':
+ //starting to parse
+ $blogroll_weblog_index = -1;
+ break;
+ case 'WEBLOG':
+ //indivdual blog
+ $blogroll_weblog_index++;
+ $blogroll_temp[$blogroll_weblog_index]['name'] = htmlentities(addslashes((strlen($attrs['NAME']) > 19) ? substr($attrs['NAME'], 0, 17) . "..." : $attrs['NAME']));
+ $blogroll_temp[$blogroll_weblog_index]['url'] = $attrs['URL'];
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+function blogrollEndElement($parser, $name, $attrs=''){
+ global $blogroll_close_tags, $blogroll_temp, $blogroll_current_tag;
+ if ($format = $blogroll_close_tags[$name])
+ {
+ switch($name){
+ case 'WEBLOGUPDATES':
+ blogrollWriteLinks();
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+
+function blogrollWriteLinks()
+{
+ global $blogroll_temp, $wpsmarty;
+ $wpsmarty->assign( "gendate", date("n/d g:ia") );
+ reset( $blogroll_temp );
+ while( list( $key, $val ) = each( $blogroll_temp ) )
+ {
+ $links[ $key ] = array( 'url' => $val[ 'url' ], 'name' => stripslashes( $val[ 'name' ] ) );
+ }
+ $wpsmarty->assign( "links", $links );
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.config_load.php b/wp-inst/wp-content/smarty-plugins/function.config_load.php
new file mode 100644
index 0000000..db7f8f6
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.config_load.php
@@ -0,0 +1,140 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {config_load} function plugin
+ *
+ * Type: function<br>
+ * Name: config_load<br>
+ * Purpose: load config file vars
+ * @link http://smarty.php.net/manual/en/language.function.config.load.php {config_load}
+ * (Smarty online manual)
+ * @param array Format:
+ * <pre>
+ * array('file' => required config file name,
+ * 'section' => optional config file section to load
+ * 'scope' => local/parent/global
+ * 'global' => overrides scope, setting to parent if true)
+ * </pre>
+ * @param Smarty
+ */
+function smarty_function_config_load($params, &$smarty)
+{
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $_debug_start_time = smarty_core_get_microtime($_params, $smarty);
+ }
+
+ $_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null;
+ $_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null;
+ $_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global';
+ $_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false;
+
+ if (!isset($_file) || strlen($_file) == 0) {
+ $smarty->trigger_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ if (isset($_scope)) {
+ if ($_scope != 'local' &&
+ $_scope != 'parent' &&
+ $_scope != 'global') {
+ $smarty->trigger_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ } else {
+ if ($_global) {
+ $_scope = 'parent';
+ } else {
+ $_scope = 'local';
+ }
+ }
+
+ $_params = array('resource_name' => $_file,
+ 'resource_base_path' => $smarty->config_dir,
+ 'get_source' => false);
+ $smarty->_parse_resource_name($_params);
+ $_file_path = $_params['resource_type'] . ':' . $_params['resource_name'];
+ if (isset($_section))
+ $_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section);
+ else
+ $_compile_file = $smarty->_get_compile_path($_file_path);
+
+ if($smarty->force_compile || !file_exists($_compile_file)) {
+ $_compile = true;
+ } elseif ($smarty->compile_check) {
+ $_params = array('resource_name' => $_file,
+ 'resource_base_path' => $smarty->config_dir,
+ 'get_source' => false);
+ $_compile = $smarty->_fetch_resource_info($_params) &&
+ $_params['resource_timestamp'] > filemtime($_compile_file);
+ } else {
+ $_compile = false;
+ }
+
+ if($_compile) {
+ // compile config file
+ if(!is_object($smarty->_conf_obj)) {
+ require_once SMARTY_DIR . $smarty->config_class . '.class.php';
+ $smarty->_conf_obj = new $smarty->config_class();
+ $smarty->_conf_obj->overwrite = $smarty->config_overwrite;
+ $smarty->_conf_obj->booleanize = $smarty->config_booleanize;
+ $smarty->_conf_obj->read_hidden = $smarty->config_read_hidden;
+ $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;
+ }
+
+ $_params = array('resource_name' => $_file,
+ 'resource_base_path' => $smarty->config_dir,
+ $_params['get_source'] = true);
+ if (!$smarty->_fetch_resource_info($_params)) {
+ return;
+ }
+ $smarty->_conf_obj->set_file_contents($_file, $_params['source_content']);
+ $_config_vars = array_merge($smarty->_conf_obj->get($_file),
+ $smarty->_conf_obj->get($_file, $_section));
+ if(function_exists('var_export')) {
+ $_output = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>';
+ } else {
+ $_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars),array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>';
+ }
+ $_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp']));
+ require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
+ smarty_core_write_compiled_resource($_params, $smarty);
+ } else {
+ include($_compile_file);
+ }
+
+ if ($smarty->caching) {
+ $smarty->_cache_info['config'][$_file] = true;
+ }
+
+ $smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars);
+ $smarty->_config[0]['files'][$_file] = true;
+
+ if ($_scope == 'parent') {
+ $smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars);
+ $smarty->_config[1]['files'][$_file] = true;
+ } else if ($_scope == 'global') {
+ for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) {
+ $smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars);
+ $smarty->_config[$i]['files'][$_file] = true;
+ }
+ }
+
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $smarty->_smarty_debug_info[] = array('type' => 'config',
+ 'filename' => $_file.' ['.$_section.'] '.$_scope,
+ 'depth' => $smarty->_inclusion_depth,
+ 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
+ }
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.cork.php b/wp-inst/wp-content/smarty-plugins/function.cork.php
new file mode 100644
index 0000000..fac9c31
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.cork.php
@@ -0,0 +1,157 @@
+<?php
+/*
+ Smarty plugin
+ -------------------------------------------------------------
+ File: function.cork.php
+ Type: function
+ Name: cork
+ Purpose: Piratize your content!
+ -------------------------------------------------------------
+
+ $Id: function.cork.php,v 1.1.1.1 2004/10/14 12:07:23 donncha Exp $
+*/
+
+function smarty_function_cork($params, &$smarty)
+{
+ extract( $params );
+
+ if( '0919' != date('md') )
+ {
+ return $content;
+ }
+ // Always replace these:
+ $patterns = array(
+ '%\bmy\b%' => 'me',
+ '%\bcareful\b%' => 'wide',
+ '%\bfooling\b%' => 'codding',
+ '%\bjoking\b%' => 'codding',
+ '%\b[Ee]xcuse me\b%' => 'C\'mere',
+ '%\bcommon sense\b%' => 'cop on',
+ '%\bkick\b%' => 'funt',
+ '%\bgood looking\b%' => 'fine half',
+ '%\bgood looking guy\b%' => 'flah',
+ '%\bgood looking girl\b%' => 'flah',
+ '%\bbeautiful girl\b%' => 'flah',
+ '%\bbeautiful woman\b%' => 'flah',
+ '%\btired\b%' => 'flahed out',
+ '%\bexhausted\b%' => 'flahed out',
+ '%\bunpleasant\b%' => 'ganky',
+ '%\bterrible\b%' => 'nawful',
+ '%\bnot nice\b%' => 'ganky',
+ '%\blook\b%' => 'gawk',
+ '%\bidiot\b%' => 'gowl',
+ '%\bthat\'s good\b%' => 'how bad?',
+ '%\b[Nn]o!\b%' => 'I wil, yeah!',
+ '%\blovely\b%' => 'massive',
+ '%\bLovely\b%' => 'Massive',
+ '%\bnot real\b%' => 'mockeyah',
+ '%\bgirlfriend\b%' => 'oul doll',
+ '%\bskipping school\b%' => 'on the hop',
+ '%\bvery lucky\b%' => 'poxed',
+ '%\btrainers\b%' => 'rubber dollies',
+ '%\brunners\b%' => 'rubber dollies',
+ '%\bsports shoes\b%' => 'rubber dollies',
+ '%\bake a look\b%' => 'ake a sconse',
+ '%\bis vain\b%' => 'is septic',
+ '%\bfemale\b%' => 'wan',
+ '%\b\wouldn\'t dareb%' => 'would yeah',
+ '%\bHe looks bad\b%' => 'State a him la',
+ '%\bvery\b%' => 'pure',
+ '%\bcare\b%' => 'give two f*cks',
+ '%\bprostitue\b%' => 'brasser',
+ '%\bmale\b%' => 'fein',
+ '%\bman\b%' => 'feen',
+ '%\bstupid\b%' => 'gowl',
+ '%\bpotatoes\b%' => 'poppies',
+ '%\becstasy\b%' => 'yolkies',
+ '%\b[Gg]arda\b%' => 'Shades',
+ '%\b[Pp]olice\b%' => 'Law',
+ '%\bGarda motorbike\b%' => 'Speedy',
+ '%\bdeformed\b%' => 'gammy',
+ '%\bbroken\b%' => 'gammy',
+ '%\bdrink\b%' => 'on the tear',
+ '%\bdrinking\b%' => 'gattin',
+ '%\bGreat\b%' => 'How Bad!',
+ '%\bave a go\b%' => 'ave a lash',
+ '%\bmother\b%' => 'mam',
+ '%\blook\b%' => 'lamp',
+ '%\bhome\b%' => 'gaff',
+ '%\bhouse\b%' => 'gaff',
+ '%\bnose\b%' => 'gonzer',
+ '%\bHow\'s the form?\b%' => 'How are you?',
+ '%\bhaircut\b%' => 'bazzer',
+ '%\bsatisfaction\b%' => 'soot',
+ '%\bvomiting\b%' => 'gawking',
+ '%\bvomit\b%' => 'gawk',
+ '%\bsnail\b%' => 'shelityhorn',
+ '%\bvery nice\b%' => 'me daza',
+ '%\bThis\b%' => 'Dis'
+ #'%\b\b%' => '',
+ );
+
+ // Replace the words:
+ $content = array_apply_regexp($patterns,$content);
+
+ // Word ending mangling:
+ $patterns = array(
+ '/ing\b/' => "in'",
+ // '/([a-zA-Z]{3,}[^lbro])ly(\W)/' => '$1-like$2',
+ );
+
+ $content = array_apply_regexp($patterns,$content);
+
+ // Random exclamations and such:
+ $patterns = array(
+ '/(\.\s)/e' => 'avast("$0",3)',
+ );
+
+ $content = array_apply_regexp($patterns,$content);
+
+ // Let's increase the chance for exclamation marks and question marks
+ $patterns = array(
+ '/([!\?]\s)/e' => 'avast("$0",5)',
+ );
+
+ $content = array_apply_regexp($patterns,$content);
+
+ return $content;
+}
+
+// support function for cork()
+function avast($stub = '',$chance = 5) {
+ $shouts = array(
+ ", like!",
+ ", you know like?",
+ ", la!",
+ ", boy!",
+ "Like eh, $stub"
+ );
+
+ shuffle($shouts);
+
+ return (((1 == rand(1,$chance))?array_shift($shouts):$stub) . ' ');
+}
+
+// This function takes an array of ('/pattern/' => 'replacement') pairs
+// and applies them all to $content.
+function array_apply_regexp($patterns,$content) {
+ // Extract the values:
+ $keys = array_keys($patterns);
+ $values = array_values($patterns);
+
+ // Modify the key patterns to avoid modifying the contents
+ // of HTML tags
+ for ($i = 0; $i < count($keys); $i++) {
+ $regexp = $keys[$i];
+
+// $regexp = preg_replace('%^(.)(.+)(.)$%','$1(?!<[^>])$2(?![>])$3',$regexp);
+
+ $keys[$i] = $regexp;
+ }
+
+ // Replace the words:
+ $content = preg_replace($keys,$values,$content);
+
+ return $content;
+}
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.counter.php b/wp-inst/wp-content/smarty-plugins/function.counter.php
new file mode 100644
index 0000000..cfe5dd8
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.counter.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {counter} function plugin
+ *
+ * Type: function<br>
+ * Name: counter<br>
+ * Purpose: print out a counter value
+ * @link http://smarty.php.net/manual/en/language.function.counter.php {counter}
+ * (Smarty online manual)
+ * @param array parameters
+ * @param Smarty
+ * @return string|null
+ */
+function smarty_function_counter($params, &$smarty)
+{
+ static $counters = array();
+
+ $name = (isset($params['name'])) ? $params['name'] : 'default';
+ if (!isset($counters[$name])) {
+ $counters[$name] = array(
+ 'start'=>1,
+ 'skip'=>1,
+ 'direction'=>'up',
+ 'count'=>1
+ );
+ }
+ $counter =& $counters[$name];
+
+ if (isset($params['start'])) {
+ $counter['start'] = $counter['count'] = (int)$params['start'];
+ }
+
+ if (!empty($params['assign'])) {
+ $counter['assign'] = $params['assign'];
+ }
+
+ if (isset($counter['assign'])) {
+ $smarty->assign($counter['assign'], $counter['count']);
+ }
+
+ if (isset($params['print'])) {
+ $print = (bool)$params['print'];
+ } else {
+ $print = empty($counter['assign']);
+ }
+
+ if ($print) {
+ $retval = $counter['count'];
+ } else {
+ $retval = null;
+ }
+
+ if (isset($params['skip'])) {
+ $counter['skip'] = $params['skip'];
+ }
+
+ if (isset($params['direction'])) {
+ $counter['direction'] = $params['direction'];
+ }
+
+ if ($counter['direction'] == "down")
+ $counter['count'] -= $counter['skip'];
+ else
+ $counter['count'] += $counter['skip'];
+
+ return $retval;
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.custom_fields.php b/wp-inst/wp-content/smarty-plugins/function.custom_fields.php
new file mode 100644
index 0000000..8c684b7
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.custom_fields.php
@@ -0,0 +1,31 @@
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: function.custom_fields.php
+ * Type: function
+ * Name: custom_fields
+ * Purpose: Passes the custom field value to the named function
+ * -------------------------------------------------------------
+ */
+function smarty_function_custom_fields($params, &$smarty)
+{
+ global $wpblog, $siteurl;
+
+ extract( $params );
+ $fields = get_post_custom();
+ if( is_array( $fields ) )
+ {
+ while( list( $func, $custom_params ) = each( $fields ) )
+ {
+ $func = str_replace('../', '', $func);
+ $file = $smarty->plugins_dir . "/custom_fields." . $func . ".php";
+ if( is_file( $file ) )
+ {
+ include_once( $file );
+ $func( $smarty, $params, $custom_params );
+ }
+ }
+ }
+}
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.cycle.php b/wp-inst/wp-content/smarty-plugins/function.cycle.php
new file mode 100644
index 0000000..fe78bb8
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.cycle.php
@@ -0,0 +1,102 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {cycle} function plugin
+ *
+ * Type: function<br>
+ * Name: cycle<br>
+ * Date: May 3, 2002<br>
+ * Purpose: cycle through given values<br>
+ * Input:
+ * - name = name of cycle (optional)
+ * - values = comma separated list of values to cycle,
+ * or an array of values to cycle
+ * (this can be left out for subsequent calls)
+ * - reset = boolean - resets given var to true
+ * - print = boolean - print var or not. default is true
+ * - advance = boolean - whether or not to advance the cycle
+ * - delimiter = the value delimiter, default is ","
+ * - assign = boolean, assigns to template var instead of
+ * printed.
+ *
+ * Examples:<br>
+ * <pre>
+ * {cycle values="#eeeeee,#d0d0d0d"}
+ * {cycle name=row values="one,two,three" reset=true}
+ * {cycle name=row}
+ * </pre>
+ * @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle}
+ * (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author credit to Mark Priatel <mpriatel@rogers.com>
+ * @author credit to Gerard <gerard@interfold.com>
+ * @author credit to Jason Sweat <jsweat_php@yahoo.com>
+ * @version 1.3
+ * @param array
+ * @param Smarty
+ * @return string|null
+ */
+function smarty_function_cycle($params, &$smarty)
+{
+ static $cycle_vars;
+
+ $name = (empty($params['name'])) ? 'default' : $params['name'];
+ $print = (isset($params['print'])) ? (bool)$params['print'] : true;
+ $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true;
+ $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false;
+
+ if (!in_array('values', array_keys($params))) {
+ if(!isset($cycle_vars[$name]['values'])) {
+ $smarty->trigger_error("cycle: missing 'values' parameter");
+ return;
+ }
+ } else {
+ if(isset($cycle_vars[$name]['values'])
+ && $cycle_vars[$name]['values'] != $params['values'] ) {
+ $cycle_vars[$name]['index'] = 0;
+ }
+ $cycle_vars[$name]['values'] = $params['values'];
+ }
+
+ $cycle_vars[$name]['delimiter'] = (isset($params['delimiter'])) ? $params['delimiter'] : ',';
+
+ if(is_array($cycle_vars[$name]['values'])) {
+ $cycle_array = $cycle_vars[$name]['values'];
+ } else {
+ $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
+ }
+
+ if(!isset($cycle_vars[$name]['index']) || $reset ) {
+ $cycle_vars[$name]['index'] = 0;
+ }
+
+ if (isset($params['assign'])) {
+ $print = false;
+ $smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
+ }
+
+ if($print) {
+ $retval = $cycle_array[$cycle_vars[$name]['index']];
+ } else {
+ $retval = null;
+ }
+
+ if($advance) {
+ if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
+ $cycle_vars[$name]['index'] = 0;
+ } else {
+ $cycle_vars[$name]['index']++;
+ }
+ }
+
+ return $retval;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.debug.php b/wp-inst/wp-content/smarty-plugins/function.debug.php
new file mode 100644
index 0000000..4345230
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.debug.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {debug} function plugin
+ *
+ * Type: function<br>
+ * Name: debug<br>
+ * Date: July 1, 2002<br>
+ * Purpose: popup debug window
+ * @link http://smarty.php.net/manual/en/language.function.debug.php {debug}
+ * (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @param array
+ * @param Smarty
+ * @return string output from {@link Smarty::_generate_debug_output()}
+ */
+function smarty_function_debug($params, &$smarty)
+{
+ if (isset($params['output'])) {
+ $smarty->assign('_smarty_debug_output', $params['output']);
+ }
+ require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
+ return smarty_core_display_debug_console(null, $smarty);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.eightball.php b/wp-inst/wp-content/smarty-plugins/function.eightball.php
new file mode 100644
index 0000000..ccfbb4b
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.eightball.php
@@ -0,0 +1,23 @@
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: function.eightball.php
+ * Type: function
+ * Name: eightball
+ * Purpose: outputs a random magic answer
+ * -------------------------------------------------------------
+ */
+function smarty_function_eightball($params, &$smarty)
+{
+ $answers = array('Yes',
+ 'No',
+ 'No way',
+ 'Outlook not so good',
+ 'Ask again soon',
+ 'Maybe in your reality');
+
+ $result = array_rand($answers);
+ echo $answers[$result];
+}
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.eval.php b/wp-inst/wp-content/smarty-plugins/function.eval.php
new file mode 100644
index 0000000..3a4b8b2
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.eval.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {eval} function plugin
+ *
+ * Type: function<br>
+ * Name: eval<br>
+ * Purpose: evaluate a template variable as a template<br>
+ * @link http://smarty.php.net/manual/en/language.function.eval.php {eval}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ */
+function smarty_function_eval($params, &$smarty)
+{
+
+ if (!isset($params['var'])) {
+ $smarty->trigger_error("eval: missing 'var' parameter");
+ return;
+ }
+
+ if($params['var'] == '') {
+ return;
+ }
+
+ $smarty->_compile_source('evaluated template', $params['var'], $_var_compiled);
+
+ ob_start();
+ $smarty->_eval('?>' . $_var_compiled);
+ $_contents = ob_get_contents();
+ ob_end_clean();
+
+ if (!empty($params['assign'])) {
+ $smarty->assign($params['assign'], $_contents);
+ } else {
+ return $_contents;
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.fetch.php b/wp-inst/wp-content/smarty-plugins/function.fetch.php
new file mode 100644
index 0000000..f5a6987
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.fetch.php
@@ -0,0 +1,220 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {fetch} plugin
+ *
+ * Type: function<br>
+ * Name: fetch<br>
+ * Purpose: fetch file, web or ftp data and display results
+ * @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string|null if the assign parameter is passed, Smarty assigns the
+ * result to a template variable
+ */
+function smarty_function_fetch($params, &$smarty)
+{
+ if (empty($params['file'])) {
+ $smarty->_trigger_fatal_error("[plugin] parameter 'file' cannot be empty");
+ return;
+ }
+
+ $content = '';
+ if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) {
+ $_params = array('resource_type' => 'file', 'resource_name' => $params['file']);
+ require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
+ if(!smarty_core_is_secure($_params, $smarty)) {
+ $smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed');
+ return;
+ }
+
+ // fetch the file
+ if($fp = @fopen($params['file'],'r')) {
+ while(!feof($fp)) {
+ $content .= fgets ($fp,4096);
+ }
+ fclose($fp);
+ } else {
+ $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] . '\'');
+ return;
+ }
+ } else {
+ // not a local file
+ if(preg_match('!^http://!i',$params['file'])) {
+ // http fetch
+ if($uri_parts = parse_url($params['file'])) {
+ // set defaults
+ $host = $server_name = $uri_parts['host'];
+ $timeout = 30;
+ $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
+ $agent = "Smarty Template Engine ".$smarty->_version;
+ $referer = "";
+ $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
+ $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
+ $_is_proxy = false;
+ if(empty($uri_parts['port'])) {
+ $port = 80;
+ } else {
+ $port = $uri_parts['port'];
+ }
+ if(!empty($uri_parts['user'])) {
+ $user = $uri_parts['user'];
+ }
+ if(!empty($uri_parts['pass'])) {
+ $pass = $uri_parts['pass'];
+ }
+ // loop through parameters, setup headers
+ foreach($params as $param_key => $param_value) {
+ switch($param_key) {
+ case "file":
+ case "assign":
+ case "assign_headers":
+ break;
+ case "user":
+ if(!empty($param_value)) {
+ $user = $param_value;
+ }
+ break;
+ case "pass":
+ if(!empty($param_value)) {
+ $pass = $param_value;
+ }
+ break;
+ case "accept":
+ if(!empty($param_value)) {
+ $accept = $param_value;
+ }
+ break;
+ case "header":
+ if(!empty($param_value)) {
+ if(!preg_match('![\w\d-]+: .+!',$param_value)) {
+ $smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'");
+ return;
+ } else {
+ $extra_headers[] = $param_value;
+ }
+ }
+ break;
+ case "proxy_host":
+ if(!empty($param_value)) {
+ $proxy_host = $param_value;
+ }
+ break;
+ case "proxy_port":
+ if(!preg_match('!\D!', $param_value)) {
+ $proxy_port = (int) $param_value;
+ } else {
+ $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
+ return;
+ }
+ break;
+ case "agent":
+ if(!empty($param_value)) {
+ $agent = $param_value;
+ }
+ break;
+ case "referer":
+ if(!empty($param_value)) {
+ $referer = $param_value;
+ }
+ break;
+ case "timeout":
+ if(!preg_match('!\D!', $param_value)) {
+ $timeout = (int) $param_value;
+ } else {
+ $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
+ return;
+ }
+ break;
+ default:
+ $smarty->_trigger_fatal_error("[plugin] unrecognized attribute '".$param_key."'");
+ return;
+ }
+ }
+ if(!empty($proxy_host) && !empty($proxy_port)) {
+ $_is_proxy = true;
+ $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);
+ } else {
+ $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);
+ }
+
+ if(!$fp) {
+ $smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)");
+ return;
+ } else {
+ if($_is_proxy) {
+ fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n");
+ } else {
+ fputs($fp, "GET $uri HTTP/1.0\r\n");
+ }
+ if(!empty($host)) {
+ fputs($fp, "Host: $host\r\n");
+ }
+ if(!empty($accept)) {
+ fputs($fp, "Accept: $accept\r\n");
+ }
+ if(!empty($agent)) {
+ fputs($fp, "User-Agent: $agent\r\n");
+ }
+ if(!empty($referer)) {
+ fputs($fp, "Referer: $referer\r\n");
+ }
+ if(isset($extra_headers) && is_array($extra_headers)) {
+ foreach($extra_headers as $curr_header) {
+ fputs($fp, $curr_header."\r\n");
+ }
+ }
+ if(!empty($user) && !empty($pass)) {
+ fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n");
+ }
+
+ fputs($fp, "\r\n");
+ while(!feof($fp)) {
+ $content .= fgets($fp,4096);
+ }
+ fclose($fp);
+ $csplit = split("\r\n\r\n",$content,2);
+
+ $content = $csplit[1];
+
+ if(!empty($params['assign_headers'])) {
+ $smarty->assign($params['assign_headers'],split("\r\n",$csplit[0]));
+ }
+ }
+ } else {
+ $smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax");
+ return;
+ }
+ } else {
+ // ftp fetch
+ if($fp = @fopen($params['file'],'r')) {
+ while(!feof($fp)) {
+ $content .= fgets ($fp,4096);
+ }
+ fclose($fp);
+ } else {
+ $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] .'\'');
+ return;
+ }
+ }
+
+ }
+
+
+ if (!empty($params['assign'])) {
+ $smarty->assign($params['assign'],$content);
+ } else {
+ return $content;
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.get_recent_comments.php b/wp-inst/wp-content/smarty-plugins/function.get_recent_comments.php
new file mode 100644
index 0000000..ec504f3
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.get_recent_comments.php
@@ -0,0 +1,25 @@
+<?php
+
+/* $Id: function.get_recent_comments.php,v 1.1 2005/03/11 16:05:26 donncha Exp $ */
+
+/*
+ Smarty plugin
+ -------------------------------------------------------------
+ File: function.get_hashcash_special_code.hp
+ Type: function
+ Name: get_hashcash_special_code
+ Purpose: print hascash code.
+ -------------------------------------------------------------
+
+ $Id: function.get_recent_comments.php,v 1.1 2005/03/11 16:05:26 donncha Exp $
+*/
+
+function smarty_function_get_recent_comments($params, &$smarty)
+{
+ $no_comments = 5;
+ $comment_lenth = 5;
+ extract( $params );
+
+ return get_recent_comments( $no_comments, $comment_lenth );
+}
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.getcustomfield.php b/wp-inst/wp-content/smarty-plugins/function.getcustomfield.php
new file mode 100644
index 0000000..9307dcb
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.getcustomfield.php
@@ -0,0 +1,39 @@
+<?php
+
+/* $Id: function.getcustomfield.php,v 1.1.1.1 2004/10/14 12:07:23 donncha Exp $ */
+
+// custom fields hack by Mystis @ http://www.mystis.net/b2customfields.html
+// commentary @ http://tidakada.com/board/viewtopic.php?t=2693
+// Highly modified by Donncha O Caoimh, donncha@linux.ie
+
+function smarty_function_getcustomfield($params, &$smarty)
+{
+ global $tableposts,$id, $site;
+
+ extract( $params );
+
+ $sql = "SELECT field_contents
+ FROM b2customfieldsContents
+ WHERE postID = '".$id."'
+ AND blog = '".$site."'
+ AND field_name = '".$name."'";
+ $result = mysql_query($sql);
+ if( @mysql_num_rows( $result ) )
+ {
+ $row = mysql_fetch_array($result);
+ $output = $row[ 'field_contents' ];
+ $output = convert_bbcode(convert_smilies(stripslashes($output)));
+ if( strstr( $output, ";;;" ) )
+ {
+ $output = split(";;;", $output );
+ }
+ }
+ else
+ {
+ $output = '';
+ }
+
+ $smarty->assign( "customfield", $output );
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.globalvar.php b/wp-inst/wp-content/smarty-plugins/function.globalvar.php
new file mode 100644
index 0000000..a9b5899
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.globalvar.php
@@ -0,0 +1,34 @@
+<?php
+
+/* $Id: function.globalvar.php,v 1.1.1.1 2004/10/14 12:07:23 donncha Exp $ */
+
+
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: function
+ * Name: globalvar
+ * Purpose: Make a Smarty variable global in PHP land.
+ * -------------------------------------------------------------
+ */
+function smarty_function_globalvar($params, &$smarty)
+{
+ extract($params);
+
+ if (empty($var)) {
+ $smarty->trigger_error("globalvar: missing 'var' parameter");
+ return;
+ }
+
+ if (!in_array('value', array_keys($params))) {
+ $smarty->trigger_error("globalvar: missing 'value' parameter");
+ return;
+ }
+
+ global $$var;
+ $$var = $value;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.googleit.php b/wp-inst/wp-content/smarty-plugins/function.googleit.php
new file mode 100644
index 0000000..1b896e1
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.googleit.php
@@ -0,0 +1,38 @@
+<?php
+
+/* $Id: function.googleit.php,v 1.1.1.1 2004/10/14 12:07:23 donncha Exp $ */
+
+/*
+ Smarty plugin
+ -------------------------------------------------------------
+ File: function.googleit.php
+ Type: function
+ Name: googleit
+ Purpose: Return google search for string.
+ -------------------------------------------------------------
+
+ COPYRIGHT Donncha O Caoimh.
+
+ $Id: function.googleit.php,v 1.1.1.1 2004/10/14 12:07:23 donncha Exp $
+*/
+
+function smarty_function_googleit($params, &$smarty)
+{
+ extract( $params );
+ if( $search != '' )
+ {
+ $search1 = str_replace( " ", "+", $search );
+ echo '<a href="http://www.google.com/search?q=' . strip_tags( $search1 ).'" title="Search for '. strip_tags( $search ).'">';
+ if( $link != '' )
+ {
+ echo $link;
+ }
+ else
+ {
+ echo "Search";
+ }
+ echo '</a>';
+ }
+
+}
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.html_checkboxes.php b/wp-inst/wp-content/smarty-plugins/function.html_checkboxes.php
new file mode 100644
index 0000000..ed8ad7f
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.html_checkboxes.php
@@ -0,0 +1,143 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_checkboxes} function plugin
+ *
+ * File: function.html_checkboxes.php<br>
+ * Type: function<br>
+ * Name: html_checkboxes<br>
+ * Date: 24.Feb.2003<br>
+ * Purpose: Prints out a list of checkbox input types<br>
+ * Input:<br>
+ * - name (optional) - string default "checkbox"
+ * - values (required) - array
+ * - options (optional) - associative array
+ * - checked (optional) - array default not set
+ * - separator (optional) - ie <br> or &nbsp;
+ * - output (optional) - the output next to each checkbox
+ * - assign (optional) - assign the output as an array to this variable
+ * Examples:
+ * <pre>
+ * {html_checkboxes values=$ids output=$names}
+ * {html_checkboxes values=$ids name='box' separator='<br>' output=$names}
+ * {html_checkboxes values=$ids checked=$checked separator='<br>' output=$names}
+ * </pre>
+ * @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
+ * (Smarty online manual)
+ * @author Christopher Kvarme <christopher.kvarme@flashjab.com>
+ * @author credits to Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses smarty_function_escape_special_chars()
+ */
+function smarty_function_html_checkboxes($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
+
+ $name = 'checkbox';
+ $values = null;
+ $options = null;
+ $selected = null;
+ $separator = '';
+ $labels = true;
+ $output = null;
+
+ $extra = '';
+
+ foreach($params as $_key => $_val) {
+ switch($_key) {
+ case 'name':
+ case 'separator':
+ $$_key = $_val;
+ break;
+
+ case 'labels':
+ $$_key = (bool)$_val;
+ break;
+
+ case 'options':
+ $$_key = (array)$_val;
+ break;
+
+ case 'values':
+ case 'output':
+ $$_key = array_values((array)$_val);
+ break;
+
+ case 'checked':
+ case 'selected':
+ $selected = array_map('strval', array_values((array)$_val));
+ break;
+
+ case 'checkboxes':
+ $smarty->trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING);
+ $options = (array)$_val;
+ break;
+
+ case 'assign':
+ break;
+
+ default:
+ if(!is_array($_val)) {
+ $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
+ } else {
+ $smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
+ }
+ break;
+ }
+ }
+
+ if (!isset($options) && !isset($values))
+ return ''; /* raise error here? */
+
+ settype($selected, 'array');
+ $_html_result = array();
+
+ if (isset($options)) {
+
+ foreach ($options as $_key=>$_val)
+ $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
+
+
+ } else {
+ foreach ($values as $_i=>$_key) {
+ $_val = isset($output[$_i]) ? $output[$_i] : '';
+ $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
+ }
+
+ }
+
+ if(!empty($params['assign'])) {
+ $smarty->assign($params['assign'], $_html_result);
+ } else {
+ return implode("\n",$_html_result);
+ }
+
+}
+
+function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) {
+ $_output = '';
+ if ($labels) $_output .= '<label>';
+ $_output .= '<input type="checkbox" name="'
+ . smarty_function_escape_special_chars($name) . '[]" value="'
+ . smarty_function_escape_special_chars($value) . '"';
+
+ if (in_array((string)$value, $selected)) {
+ $_output .= ' checked="checked"';
+ }
+ $_output .= $extra . ' />' . $output;
+ if ($labels) $_output .= '</label>';
+ $_output .= $separator;
+
+ return $_output;
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.html_image.php b/wp-inst/wp-content/smarty-plugins/function.html_image.php
new file mode 100644
index 0000000..c62b0fe
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.html_image.php
@@ -0,0 +1,139 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_image} function plugin
+ *
+ * Type: function<br>
+ * Name: html_image<br>
+ * Date: Feb 24, 2003<br>
+ * Purpose: format HTML tags for the image<br>
+ * Input:<br>
+ * - file = file (and path) of image (required)
+ * - height = image height (optional, default actual height)
+ * - width = image width (optional, default actual width)
+ * - basedir = base directory for absolute paths, default
+ * is environment variable DOCUMENT_ROOT
+ *
+ * Examples: {html_image file="images/masthead.gif"}
+ * Output: <img src="images/masthead.gif" width=400 height=23>
+ * @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image}
+ * (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author credits to Duda <duda@big.hu> - wrote first image function
+ * in repository, helped with lots of functionality
+ * @version 1.0
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses smarty_function_escape_special_chars()
+ */
+function smarty_function_html_image($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
+
+ $alt = '';
+ $file = '';
+ $height = '';
+ $width = '';
+ $extra = '';
+ $prefix = '';
+ $suffix = '';
+ $server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
+ $basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
+ foreach($params as $_key => $_val) {
+ switch($_key) {
+ case 'file':
+ case 'height':
+ case 'width':
+ case 'dpi':
+ case 'basedir':
+ $$_key = $_val;
+ break;
+
+ case 'alt':
+ if(!is_array($_val)) {
+ $$_key = smarty_function_escape_special_chars($_val);
+ } else {
+ $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
+ }
+ break;
+
+ case 'link':
+ case 'href':
+ $prefix = '<a href="' . $_val . '">';
+ $suffix = '</a>';
+ break;
+
+ default:
+ if(!is_array($_val)) {
+ $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
+ } else {
+ $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
+ }
+ break;
+ }
+ }
+
+ if (empty($file)) {
+ $smarty->trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
+ return;
+ }
+
+ if (substr($file,0,1) == '/') {
+ $_image_path = $basedir . $file;
+ } else {
+ $_image_path = $file;
+ }
+
+ if(!isset($params['width']) || !isset($params['height'])) {
+ if ($smarty->security &&
+ ($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) &&
+ (require_once(SMARTY_CORE_DIR . 'core.is_secure.php')) &&
+ (!smarty_core_is_secure($_params, $smarty)) ) {
+ $smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE);
+
+ } elseif (!$_image_data = @getimagesize($_image_path)) {
+ if(!file_exists($_image_path)) {
+ $smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
+ return;
+ } else if(!is_readable($_image_path)) {
+ $smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
+ return;
+ } else {
+ $smarty->trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
+ return;
+ }
+ }
+
+ if(!isset($params['width'])) {
+ $width = $_image_data[0];
+ }
+ if(!isset($params['height'])) {
+ $height = $_image_data[1];
+ }
+
+ }
+
+ if(isset($params['dpi'])) {
+ if(strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
+ $dpi_default = 72;
+ } else {
+ $dpi_default = 96;
+ }
+ $_resize = $dpi_default/$params['dpi'];
+ $width = round($width * $_resize);
+ $height = round($height * $_resize);
+ }
+
+ return $prefix . '<img src="'.$file.'" alt="'.$alt.'" width="'.$width.'" height="'.$height.'"'.$extra.' />' . $suffix;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.html_options.php b/wp-inst/wp-content/smarty-plugins/function.html_options.php
new file mode 100644
index 0000000..ae864f7
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.html_options.php
@@ -0,0 +1,121 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_options} function plugin
+ *
+ * Type: function<br>
+ * Name: html_options<br>
+ * Input:<br>
+ * - name (optional) - string default "select"
+ * - values (required if no options supplied) - array
+ * - options (required if no values supplied) - associative array
+ * - selected (optional) - string default not set
+ * - output (required if not options supplied) - array
+ * Purpose: Prints the list of <option> tags generated from
+ * the passed parameters
+ * @link http://smarty.php.net/manual/en/language.function.html.options.php {html_image}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses smarty_function_escape_special_chars()
+ */
+function smarty_function_html_options($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
+
+ $name = null;
+ $values = null;
+ $options = null;
+ $selected = array();
+ $output = null;
+
+ $extra = '';
+
+ foreach($params as $_key => $_val) {
+ switch($_key) {
+ case 'name':
+ $$_key = (string)$_val;
+ break;
+
+ case 'options':
+ $$_key = (array)$_val;
+ break;
+
+ case 'values':
+ case 'output':
+ $$_key = array_values((array)$_val);
+ break;
+
+ case 'selected':
+ $$_key = array_map('strval', array_values((array)$_val));
+ break;
+
+ default:
+ if(!is_array($_val)) {
+ $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
+ } else {
+ $smarty->trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
+ }
+ break;
+ }
+ }
+
+ if (!isset($options) && !isset($values))
+ return ''; /* raise error here? */
+
+ $_html_result = '';
+
+ if (isset($options)) {
+
+ foreach ($options as $_key=>$_val)
+ $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
+
+ } else {
+
+ foreach ($values as $_i=>$_key) {
+ $_val = isset($output[$_i]) ? $output[$_i] : '';
+ $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
+ }
+
+ }
+
+ if(!empty($name)) {
+ $_html_result = '<select name="' . $name . '"' . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
+ }
+
+ return $_html_result;
+
+}
+
+function smarty_function_html_options_optoutput($key, $value, $selected) {
+ if(!is_array($value)) {
+ $_html_result = '<option label="' . smarty_function_escape_special_chars($value) . '" value="' .
+ smarty_function_escape_special_chars($key) . '"';
+ if (in_array((string)$key, $selected))
+ $_html_result .= ' selected="selected"';
+ $_html_result .= '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n";
+ } else {
+ $_html_result = smarty_function_html_options_optgroup($key, $value, $selected);
+ }
+ return $_html_result;
+}
+
+function smarty_function_html_options_optgroup($key, $values, $selected) {
+ $optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
+ foreach ($values as $key => $value) {
+ $optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
+ }
+ $optgroup_html .= "</optgroup>\n";
+ return $optgroup_html;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.html_radios.php b/wp-inst/wp-content/smarty-plugins/function.html_radios.php
new file mode 100644
index 0000000..dc7baee
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.html_radios.php
@@ -0,0 +1,150 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_radios} function plugin
+ *
+ * File: function.html_radios.php<br>
+ * Type: function<br>
+ * Name: html_radios<br>
+ * Date: 24.Feb.2003<br>
+ * Purpose: Prints out a list of radio input types<br>
+ * Input:<br>
+ * - name (optional) - string default "radio"
+ * - values (required) - array
+ * - options (optional) - associative array
+ * - checked (optional) - array default not set
+ * - separator (optional) - ie <br> or &nbsp;
+ * - output (optional) - the output next to each radio button
+ * - assign (optional) - assign the output as an array to this variable
+ * Examples:
+ * <pre>
+ * {html_radios values=$ids output=$names}
+ * {html_radios values=$ids name='box' separator='<br>' output=$names}
+ * {html_radios values=$ids checked=$checked separator='<br>' output=$names}
+ * </pre>
+ * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
+ * (Smarty online manual)
+ * @author Christopher Kvarme <christopher.kvarme@flashjab.com>
+ * @author credits to Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses smarty_function_escape_special_chars()
+ */
+function smarty_function_html_radios($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
+
+ $name = 'radio';
+ $values = null;
+ $options = null;
+ $selected = null;
+ $separator = '';
+ $labels = true;
+ $output = null;
+ $extra = '';
+
+ foreach($params as $_key => $_val) {
+ switch($_key) {
+ case 'name':
+ case 'separator':
+ $$_key = (string)$_val;
+ break;
+
+ case 'checked':
+ case 'selected':
+ if(is_array($_val)) {
+ $smarty->trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
+ } else {
+ $selected = (string)$_val;
+ }
+ break;
+
+ case 'labels':
+ $$_key = (bool)$_val;
+ break;
+
+ case 'options':
+ $$_key = (array)$_val;
+ break;
+
+ case 'values':
+ case 'output':
+ $$_key = array_values((array)$_val);
+ break;
+
+ case 'radios':
+ $smarty->trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING);
+ $options = (array)$_val;
+ break;
+
+ case 'assign':
+ break;
+
+ default:
+ if(!is_array($_val)) {
+ $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
+ } else {
+ $smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
+ }
+ break;
+ }
+ }
+
+ if (!isset($options) && !isset($values))
+ return ''; /* raise error here? */
+
+ $_html_result = array();
+
+ if (isset($options)) {
+
+ foreach ($options as $_key=>$_val)
+ $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
+
+ } else {
+
+ foreach ($values as $_i=>$_key) {
+ $_val = isset($output[$_i]) ? $output[$_i] : '';
+ $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
+ }
+
+ }
+
+ if(!empty($params['assign'])) {
+ $smarty->assign($params['assign'], $_html_result);
+ } else {
+ return implode("\n",$_html_result);
+ }
+
+}
+
+function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) {
+ $_output = '';
+ if ($labels) {
+ $_id = smarty_function_escape_special_chars($name . '_' . $value);
+ $_output .= '<label for="' . $_id . '">';
+ }
+ $_output .= '<input type="radio" name="'
+ . smarty_function_escape_special_chars($name) . '" value="'
+ . smarty_function_escape_special_chars($value) . '"';
+
+ if ($labels) $_output .= ' id="' . $_id . '"';
+
+ if ($value==$selected) {
+ $_output .= ' checked="checked"';
+ }
+ $_output .= $extra . ' />' . $output;
+ if ($labels) $_output .= '</label>';
+ $_output .= $separator;
+
+ return $_output;
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.html_select_date.php b/wp-inst/wp-content/smarty-plugins/function.html_select_date.php
new file mode 100644
index 0000000..fc2d449
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.html_select_date.php
@@ -0,0 +1,316 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {html_select_date} plugin
+ *
+ * Type: function<br>
+ * Name: html_select_date<br>
+ * Purpose: Prints the dropdowns for date selection.
+ *
+ * ChangeLog:<br>
+ * - 1.0 initial release
+ * - 1.1 added support for +/- N syntax for begin
+ * and end year values. (Monte)
+ * - 1.2 added support for yyyy-mm-dd syntax for
+ * time value. (Jan Rosier)
+ * - 1.3 added support for choosing format for
+ * month values (Gary Loescher)
+ * - 1.3.1 added support for choosing format for
+ * day values (Marcus Bointon)
+ * - 1.3.2 suppport negative timestamps, force year
+ * dropdown to include given date unless explicitly set (Monte)
+ * @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date}
+ * (Smarty online manual)
+ * @version 1.3.2
+ * @author Andrei Zmievski
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_html_select_date($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
+ require_once $smarty->_get_plugin_filepath('function','html_options');
+ /* Default values. */
+ $prefix = "Date_";
+ $start_year = strftime("%Y");
+ $end_year = $start_year;
+ $display_days = true;
+ $display_months = true;
+ $display_years = true;
+ $month_format = "%B";
+ /* Write months as numbers by default GL */
+ $month_value_format = "%m";
+ $day_format = "%02d";
+ /* Write day values using this format MB */
+ $day_value_format = "%d";
+ $year_as_text = false;
+ /* Display years in reverse order? Ie. 2000,1999,.... */
+ $reverse_years = false;
+ /* Should the select boxes be part of an array when returned from PHP?
+ e.g. setting it to "birthday", would create "birthday[Day]",
+ "birthday[Month]" & "birthday[Year]". Can be combined with prefix */
+ $field_array = null;
+ /* <select size>'s of the different <select> tags.
+ If not set, uses default dropdown. */
+ $day_size = null;
+ $month_size = null;
+ $year_size = null;
+ /* Unparsed attributes common to *ALL* the <select>/<input> tags.
+ An example might be in the template: all_extra ='class ="foo"'. */
+ $all_extra = null;
+ /* Separate attributes for the tags. */
+ $day_extra = null;
+ $month_extra = null;
+ $year_extra = null;
+ /* Order in which to display the fields.
+ "D" -> day, "M" -> month, "Y" -> year. */
+ $field_order = 'MDY';
+ /* String printed between the different fields. */
+ $field_separator = "\n";
+ $time = time();
+ $all_empty = null;
+ $day_empty = null;
+ $month_empty = null;
+ $year_empty = null;
+
+ foreach ($params as $_key=>$_value) {
+ switch ($_key) {
+ case 'prefix':
+ case 'time':
+ case 'start_year':
+ case 'end_year':
+ case 'month_format':
+ case 'day_format':
+ case 'day_value_format':
+ case 'field_array':
+ case 'day_size':
+ case 'month_size':
+ case 'year_size':
+ case 'all_extra':
+ case 'day_extra':
+ case 'month_extra':
+ case 'year_extra':
+ case 'field_order':
+ case 'field_separator':
+ case 'month_value_format':
+ case 'month_empty':
+ case 'day_empty':
+ case 'year_empty':
+ $$_key = (string)$_value;
+ break;
+
+ case 'all_empty':
+ $$_key = (string)$_value;
+ $day_empty = $month_empty = $year_empty = $all_empty;
+ break;
+
+ case 'display_days':
+ case 'display_months':
+ case 'display_years':
+ case 'year_as_text':
+ case 'reverse_years':
+ $$_key = (bool)$_value;
+ break;
+
+ default:
+ $smarty->trigger_error("[html_select_date] unknown parameter $_key", E_USER_WARNING);
+
+ }
+ }
+
+ if(preg_match('!^-\d+$!',$time)) {
+ // negative timestamp, use date()
+ $time = date('Y-m-d',$time);
+ }
+ // If $time is not in format yyyy-mm-dd
+ if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) {
+ // use smarty_make_timestamp to get an unix timestamp and
+ // strftime to make yyyy-mm-dd
+ $time = strftime('%Y-%m-%d', smarty_make_timestamp($time));
+ }
+ // Now split this in pieces, which later can be used to set the select
+ $time = explode("-", $time);
+
+ // make syntax "+N" or "-N" work with start_year and end_year
+ if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
+ if ($match[1] == '+') {
+ $end_year = strftime('%Y') + $match[2];
+ } else {
+ $end_year = strftime('%Y') - $match[2];
+ }
+ }
+ if (preg_match('!^(\+|\-)\s*(\d+)$!', $start_year, $match)) {
+ if ($match[1] == '+') {
+ $start_year = strftime('%Y') + $match[2];
+ } else {
+ $start_year = strftime('%Y') - $match[2];
+ }
+ }
+ if (strlen($time[0]) > 0) {
+ if ($start_year > $time[0] && !isset($params['start_year'])) {
+ // force start year to include given date if not explicitly set
+ $start_year = $time[0];
+ }
+ if($end_year < $time[0] && !isset($params['end_year'])) {
+ // force end year to include given date if not explicitly set
+ $end_year = $time[0];
+ }
+ }
+
+ $field_order = strtoupper($field_order);
+
+ $html_result = $month_result = $day_result = $year_result = "";
+
+ if ($display_months) {
+ $month_names = array();
+ $month_values = array();
+ if(isset($month_empty)) {
+ $month_names[''] = $month_empty;
+ $month_values[''] = '';
+ }
+ for ($i = 1; $i <= 12; $i++) {
+ $month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
+ $month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
+ }
+
+ $month_result .= '<select name=';
+ if (null !== $field_array){
+ $month_result .= '"' . $field_array . '[' . $prefix . 'Month]"';
+ } else {
+ $month_result .= '"' . $prefix . 'Month"';
+ }
+ if (null !== $month_size){
+ $month_result .= ' size="' . $month_size . '"';
+ }
+ if (null !== $month_extra){
+ $month_result .= ' ' . $month_extra;
+ }
+ if (null !== $all_extra){
+ $month_result .= ' ' . $all_extra;
+ }
+ $month_result .= '>'."\n";
+
+ $month_result .= smarty_function_html_options(array('output' => $month_names,
+ 'values' => $month_values,
+ 'selected' => $a=$time[1] ? strftime($month_value_format, mktime(0, 0, 0, (int)$time[1], 1, 2000)) : '',
+ 'print_result' => false),
+ $smarty);
+ $month_result .= '</select>';
+ }
+
+ if ($display_days) {
+ $days = array();
+ if (isset($day_empty)) {
+ $days[''] = $day_empty;
+ $day_values[''] = '';
+ }
+ for ($i = 1; $i <= 31; $i++) {
+ $days[] = sprintf($day_format, $i);
+ $day_values[] = sprintf($day_value_format, $i);
+ }
+
+ $day_result .= '<select name=';
+ if (null !== $field_array){
+ $day_result .= '"' . $field_array . '[' . $prefix . 'Day]"';
+ } else {
+ $day_result .= '"' . $prefix . 'Day"';
+ }
+ if (null !== $day_size){
+ $day_result .= ' size="' . $day_size . '"';
+ }
+ if (null !== $all_extra){
+ $day_result .= ' ' . $all_extra;
+ }
+ if (null !== $day_extra){
+ $day_result .= ' ' . $day_extra;
+ }
+ $day_result .= '>'."\n";
+ $day_result .= smarty_function_html_options(array('output' => $days,
+ 'values' => $day_values,
+ 'selected' => $time[2],
+ 'print_result' => false),
+ $smarty);
+ $day_result .= '</select>';
+ }
+
+ if ($display_years) {
+ if (null !== $field_array){
+ $year_name = $field_array . '[' . $prefix . 'Year]';
+ } else {
+ $year_name = $prefix . 'Year';
+ }
+ if ($year_as_text) {
+ $year_result .= '<input type="text" name="' . $year_name . '" value="' . $time[0] . '" size="4" maxlength="4"';
+ if (null !== $all_extra){
+ $year_result .= ' ' . $all_extra;
+ }
+ if (null !== $year_extra){
+ $year_result .= ' ' . $year_extra;
+ }
+ $year_result .= '>';
+ } else {
+ $years = range((int)$start_year, (int)$end_year);
+ if ($reverse_years) {
+ rsort($years, SORT_NUMERIC);
+ } else {
+ sort($years, SORT_NUMERIC);
+ }
+ $yearvals = $years;
+ if(isset($year_empty)) {
+ array_unshift($years, $year_empty);
+ array_unshift($yearvals, '');
+ }
+ $year_result .= '<select name="' . $year_name . '"';
+ if (null !== $year_size){
+ $year_result .= ' size="' . $year_size . '"';
+ }
+ if (null !== $all_extra){
+ $year_result .= ' ' . $all_extra;
+ }
+ if (null !== $year_extra){
+ $year_result .= ' ' . $year_extra;
+ }
+ $year_result .= '>'."\n";
+ $year_result .= smarty_function_html_options(array('output' => $years,
+ 'values' => $yearvals,
+ 'selected' => $time[0],
+ 'print_result' => false),
+ $smarty);
+ $year_result .= '</select>';
+ }
+ }
+
+ // Loop thru the field_order field
+ for ($i = 0; $i <= 2; $i++){
+ $c = substr($field_order, $i, 1);
+ switch ($c){
+ case 'D':
+ $html_result .= $day_result;
+ break;
+
+ case 'M':
+ $html_result .= $month_result;
+ break;
+
+ case 'Y':
+ $html_result .= $year_result;
+ break;
+ }
+ // Add the field seperator
+ if($i != 2) {
+ $html_result .= $field_separator;
+ }
+ }
+
+ return $html_result;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.html_select_time.php b/wp-inst/wp-content/smarty-plugins/function.html_select_time.php
new file mode 100644
index 0000000..00cd1ae
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.html_select_time.php
@@ -0,0 +1,192 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_select_time} function plugin
+ *
+ * Type: function<br>
+ * Name: html_select_time<br>
+ * Purpose: Prints the dropdowns for time selection
+ * @link http://smarty.php.net/manual/en/language.function.html.select.time.php {html_select_time}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses smarty_make_timestamp()
+ */
+function smarty_function_html_select_time($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
+ require_once $smarty->_get_plugin_filepath('function','html_options');
+ /* Default values. */
+ $prefix = "Time_";
+ $time = time();
+ $display_hours = true;
+ $display_minutes = true;
+ $display_seconds = true;
+ $display_meridian = true;
+ $use_24_hours = true;
+ $minute_interval = 1;
+ $second_interval = 1;
+ /* Should the select boxes be part of an array when returned from PHP?
+ e.g. setting it to "birthday", would create "birthday[Hour]",
+ "birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]".
+ Can be combined with prefix. */
+ $field_array = null;
+ $all_extra = null;
+ $hour_extra = null;
+ $minute_extra = null;
+ $second_extra = null;
+ $meridian_extra = null;
+
+ foreach ($params as $_key=>$_value) {
+ switch ($_key) {
+ case 'prefix':
+ case 'time':
+ case 'field_array':
+ case 'all_extra':
+ case 'hour_extra':
+ case 'minute_extra':
+ case 'second_extra':
+ case 'meridian_extra':
+ $$_key = (string)$_value;
+ break;
+
+ case 'display_hours':
+ case 'display_minutes':
+ case 'display_seconds':
+ case 'display_meridian':
+ case 'use_24_hours':
+ $$_key = (bool)$_value;
+ break;
+
+ case 'minute_interval':
+ case 'second_interval':
+ $$_key = (int)$_value;
+ break;
+
+ default:
+ $smarty->trigger_error("[html_select_time] unknown parameter $_key", E_USER_WARNING);
+ }
+ }
+
+ $time = smarty_make_timestamp($time);
+
+ $html_result = '';
+
+ if ($display_hours) {
+ $hours = $use_24_hours ? range(0, 23) : range(1, 12);
+ $hour_fmt = $use_24_hours ? '%H' : '%I';
+ for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
+ $hours[$i] = sprintf('%02d', $hours[$i]);
+ $html_result .= '<select name=';
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Hour"';
+ }
+ if (null !== $hour_extra){
+ $html_result .= ' ' . $hour_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+ $html_result .= smarty_function_html_options(array('output' => $hours,
+ 'values' => $hours,
+ 'selected' => strftime($hour_fmt, $time),
+ 'print_result' => false),
+ $smarty);
+ $html_result .= "</select>\n";
+ }
+
+ if ($display_minutes) {
+ $all_minutes = range(0, 59);
+ for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval)
+ $minutes[] = sprintf('%02d', $all_minutes[$i]);
+ $selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
+ $html_result .= '<select name=';
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Minute"';
+ }
+ if (null !== $minute_extra){
+ $html_result .= ' ' . $minute_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+
+ $html_result .= smarty_function_html_options(array('output' => $minutes,
+ 'values' => $minutes,
+ 'selected' => $selected,
+ 'print_result' => false),
+ $smarty);
+ $html_result .= "</select>\n";
+ }
+
+ if ($display_seconds) {
+ $all_seconds = range(0, 59);
+ for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval)
+ $seconds[] = sprintf('%02d', $all_seconds[$i]);
+ $selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
+ $html_result .= '<select name=';
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Second]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Second"';
+ }
+
+ if (null !== $second_extra){
+ $html_result .= ' ' . $second_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+
+ $html_result .= smarty_function_html_options(array('output' => $seconds,
+ 'values' => $seconds,
+ 'selected' => $selected,
+ 'print_result' => false),
+ $smarty);
+ $html_result .= "</select>\n";
+ }
+
+ if ($display_meridian && !$use_24_hours) {
+ $html_result .= '<select name=';
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Meridian"';
+ }
+
+ if (null !== $meridian_extra){
+ $html_result .= ' ' . $meridian_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+
+ $html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'),
+ 'values' => array('am', 'pm'),
+ 'selected' => strtolower(strftime('%p', $time)),
+ 'print_result' => false),
+ $smarty);
+ $html_result .= "</select>\n";
+ }
+
+ return $html_result;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.html_table.php b/wp-inst/wp-content/smarty-plugins/function.html_table.php
new file mode 100644
index 0000000..62d7410
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.html_table.php
@@ -0,0 +1,137 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_table} function plugin
+ *
+ * Type: function<br>
+ * Name: html_table<br>
+ * Date: Feb 17, 2003<br>
+ * Purpose: make an html table from an array of data<br>
+ * Input:<br>
+ * - loop = array to loop through
+ * - cols = number of columns
+ * - rows = number of rows
+ * - table_attr = table attributes
+ * - tr_attr = table row attributes (arrays are cycled)
+ * - td_attr = table cell attributes (arrays are cycled)
+ * - trailpad = value to pad trailing cells with
+ * - vdir = vertical direction (default: "down", means top-to-bottom)
+ * - hdir = horizontal direction (default: "right", means left-to-right)
+ * - inner = inner loop (default "cols": print $loop line by line,
+ * $loop will be printed column by column otherwise)
+ *
+ *
+ * Examples:
+ * <pre>
+ * {table loop=$data}
+ * {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
+ * {table loop=$data cols=4 tr_attr=$colors}
+ * </pre>
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_html_table($params, &$smarty)
+{
+ $table_attr = 'border="1"';
+ $tr_attr = '';
+ $td_attr = '';
+ $cols = 3;
+ $rows = 3;
+ $trailpad = '&nbsp;';
+ $vdir = 'down';
+ $hdir = 'right';
+ $inner = 'cols';
+
+ if (!isset($params['loop'])) {
+ $smarty->trigger_error("html_table: missing 'loop' parameter");
+ return;
+ }
+
+ foreach ($params as $_key=>$_value) {
+ switch ($_key) {
+ case 'loop':
+ $$_key = (array)$_value;
+ break;
+
+ case 'cols':
+ case 'rows':
+ $$_key = (int)$_value;
+ break;
+
+ case 'table_attr':
+ case 'trailpad':
+ case 'hdir':
+ case 'vdir':
+ case 'inner':
+ $$_key = (string)$_value;
+ break;
+
+ case 'tr_attr':
+ case 'td_attr':
+ $$_key = $_value;
+ break;
+ }
+ }
+
+ $loop_count = count($loop);
+ if (empty($params['rows'])) {
+ /* no rows specified */
+ $rows = ceil($loop_count/$cols);
+ } elseif (empty($params['cols'])) {
+ if (!empty($params['rows'])) {
+ /* no cols specified, but rows */
+ $cols = ceil($loop_count/$rows);
+ }
+ }
+
+ $output = "<table $table_attr>\n";
+
+ for ($r=0; $r<$rows; $r++) {
+ $output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n";
+ $rx = ($vdir == 'down') ? $r*$cols : ($rows-1-$r)*$cols;
+
+ for ($c=0; $c<$cols; $c++) {
+ $x = ($hdir == 'right') ? $rx+$c : $rx+$cols-1-$c;
+ if ($inner!='cols') {
+ /* shuffle x to loop over rows*/
+ $x = floor($x/$cols) + ($x%$cols)*$rows;
+ }
+
+ if ($x<$loop_count) {
+ $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[$x] . "</td>\n";
+ } else {
+ $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">$trailpad</td>\n";
+ }
+ }
+ $output .= "</tr>\n";
+ }
+ $output .= "</table>\n";
+
+ return $output;
+}
+
+function smarty_function_html_table_cycle($name, $var, $no) {
+ if(!is_array($var)) {
+ $ret = $var;
+ } else {
+ $ret = $var[$no % count($var)];
+ }
+
+ return ($ret) ? ' '.$ret : '';
+}
+
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.is_aside.php b/wp-inst/wp-content/smarty-plugins/function.is_aside.php
new file mode 100644
index 0000000..495407d
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.is_aside.php
@@ -0,0 +1,42 @@
+<?php
+
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: function
+ * Name: assign
+ * Purpose: assign a value to a template variable
+ * -------------------------------------------------------------
+ */
+function smarty_function_is_aside($params, &$smarty)
+{
+ extract($params);
+
+ $category = get_the_category();
+ //$wpsmarty->assign( "category", $category[0]->cat_name );
+ $t = count( $category );
+ $ret = false;
+ if( $t > 1 )
+ {
+ for( $i = 0; $i < $t; $i++ )
+ {
+ if( $category[$i]->cat_name == 'Asides' )
+ {
+ $ret = true;
+ }
+ }
+ }
+ else
+ {
+ if( $category[0]->cat_name == 'Asides' )
+ {
+ $ret = true;
+ }
+ }
+
+ $smarty->assign( "is_aside", $ret );
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.lastposts.php b/wp-inst/wp-content/smarty-plugins/function.lastposts.php
new file mode 100644
index 0000000..60da376
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.lastposts.php
@@ -0,0 +1,66 @@
+<?php
+
+/* $Id: function.lastposts.php,v 1.3 2005/01/09 11:54:18 donncha Exp $ */
+
+
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: function
+ * Name: lastposts
+ * Purpose: Returns a list of the last posts to the blog
+ * -------------------------------------------------------------
+ */
+
+function getposts( $wpblog, $posts )
+{
+ global $wpdb;
+
+ $query = "SELECT ID, post_title
+ FROM ".$wpdb->posts."
+ WHERE unix_timestamp( post_date ) < unix_timestamp( NOW() )
+ AND post_status = 'publish'
+ ORDER BY `post_date` DESC LIMIT 0, ".intval( $posts );
+ $result = $wpdb->get_results( $query );
+ if( $result )
+ {
+ foreach( $result as $details )
+ {
+ $postdata[ $details->ID ] = stripslashes( strip_tags( $details->post_title ) );
+ }
+
+ return $postdata;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+function smarty_function_lastposts($params, &$smarty)
+{
+
+ global $wpblog;
+
+ $posts = 10;
+ extract($params);
+
+ if( $posts > 40 )
+ $posts = 40;
+
+ if( @include_once( "Cache/Function.php" ) )
+ {
+ $cache = new Cache_Function( 'file', array('cache_dir' => ABSPATH . "/wp-content/smarty-cache", 'filename_prefix' => 'lastposts_cache_' ), 600 );
+ $lastposts = $cache->call( "getposts", $wpblog, $posts );
+ }
+ else
+ {
+ $lastposts = getposts( $wpblog, $posts );
+ }
+
+ $smarty->assign( "lastposts", $lastposts );
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.mailto.php b/wp-inst/wp-content/smarty-plugins/function.mailto.php
new file mode 100644
index 0000000..64c122c
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.mailto.php
@@ -0,0 +1,163 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {mailto} function plugin
+ *
+ * Type: function<br>
+ * Name: mailto<br>
+ * Date: May 21, 2002
+ * Purpose: automate mailto address link creation, and optionally
+ * encode them.<br>
+ * Input:<br>
+ * - address = e-mail address
+ * - text = (optional) text to display, default is address
+ * - encode = (optional) can be one of:
+ * * none : no encoding (default)
+ * * javascript : encode with javascript
+ * * javascript_charcode : encode with javascript charcode
+ * * hex : encode with hexidecimal (no javascript)
+ * - cc = (optional) address(es) to carbon copy
+ * - bcc = (optional) address(es) to blind carbon copy
+ * - subject = (optional) e-mail subject
+ * - newsgroups = (optional) newsgroup(s) to post to
+ * - followupto = (optional) address(es) to follow up to
+ * - extra = (optional) extra tags for the href link
+ *
+ * Examples:
+ * <pre>
+ * {mailto address="me@domain.com"}
+ * {mailto address="me@domain.com" encode="javascript"}
+ * {mailto address="me@domain.com" encode="hex"}
+ * {mailto address="me@domain.com" subject="Hello to you!"}
+ * {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
+ * {mailto address="me@domain.com" extra='class="mailto"'}
+ * </pre>
+ * @link http://smarty.php.net/manual/en/language.function.mailto.php {mailto}
+ * (Smarty online manual)
+ * @version 1.2
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author credits to Jason Sweat (added cc, bcc and subject functionality)
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_mailto($params, &$smarty)
+{
+ $extra = '';
+
+ if (empty($params['address'])) {
+ $smarty->trigger_error("mailto: missing 'address' parameter");
+ return;
+ } else {
+ $address = $params['address'];
+ }
+
+ $text = $address;
+
+ // netscape and mozilla do not decode %40 (@) in BCC field (bug?)
+ // so, don't encode it.
+ $mail_parms = array();
+ foreach ($params as $var=>$value) {
+ switch ($var) {
+ case 'cc':
+ case 'bcc':
+ case 'followupto':
+ if (!empty($value))
+ $mail_parms[] = $var.'='.str_replace('%40','@',rawurlencode($value));
+ break;
+
+ case 'subject':
+ case 'newsgroups':
+ $mail_parms[] = $var.'='.rawurlencode($value);
+ break;
+
+ case 'extra':
+ case 'text':
+ $$var = $value;
+
+ default:
+ }
+ }
+
+ $mail_parm_vals = '';
+ for ($i=0; $i<count($mail_parms); $i++) {
+ $mail_parm_vals .= (0==$i) ? '?' : '&';
+ $mail_parm_vals .= $mail_parms[$i];
+ }
+ $address .= $mail_parm_vals;
+
+ $encode = (empty($params['encode'])) ? 'none' : $params['encode'];
+ if (!in_array($encode,array('javascript','javascript_charcode','hex','none')) ) {
+ $smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex");
+ return;
+ }
+
+ if ($encode == 'javascript' ) {
+ $string = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');';
+
+ $js_encode = '';
+ for ($x=0; $x < strlen($string); $x++) {
+ $js_encode .= '%' . bin2hex($string[$x]);
+ }
+
+ return '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
+
+ } elseif ($encode == 'javascript_charcode' ) {
+ $string = '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
+
+ for($x = 0, $y = strlen($string); $x < $y; $x++ ) {
+ $ord[] = ord($string[$x]);
+ }
+
+ $_ret = "<script type=\"text/javascript\" language=\"javascript\">\n";
+ $_ret .= "<!--\n";
+ $_ret .= "{document.write(String.fromCharCode(";
+ $_ret .= implode(',',$ord);
+ $_ret .= "))";
+ $_ret .= "}\n";
+ $_ret .= "//-->\n";
+ $_ret .= "</script>\n";
+
+ return $_ret;
+
+
+ } elseif ($encode == 'hex') {
+
+ preg_match('!^(.*)(\?.*)$!',$address,$match);
+ if(!empty($match[2])) {
+ $smarty->trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.");
+ return;
+ }
+ $address_encode = '';
+ for ($x=0; $x < strlen($address); $x++) {
+ if(preg_match('!\w!',$address[$x])) {
+ $address_encode .= '%' . bin2hex($address[$x]);
+ } else {
+ $address_encode .= $address[$x];
+ }
+ }
+ $text_encode = '';
+ for ($x=0; $x < strlen($text); $x++) {
+ $text_encode .= '&#x' . bin2hex($text[$x]).';';
+ }
+
+ $mailto = "&#109;&#97;&#105;&#108;&#116;&#111;&#58;";
+ return '<a href="'.$mailto.$address_encode.'" '.$extra.'>'.$text_encode.'</a>';
+
+ } else {
+ // no encoding
+ return '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
+
+ }
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.math.php b/wp-inst/wp-content/smarty-plugins/function.math.php
new file mode 100644
index 0000000..0439107
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.math.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {math} function plugin
+ *
+ * Type: function<br>
+ * Name: math<br>
+ * Purpose: handle math computations in template<br>
+ * @link http://smarty.php.net/manual/en/language.function.math.php {math}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_math($params, &$smarty)
+{
+ // be sure equation parameter is present
+ if (empty($params['equation'])) {
+ $smarty->trigger_error("math: missing equation parameter");
+ return;
+ }
+
+ $equation = $params['equation'];
+
+ // make sure parenthesis are balanced
+ if (substr_count($equation,"(") != substr_count($equation,")")) {
+ $smarty->trigger_error("math: unbalanced parenthesis");
+ return;
+ }
+
+ // match all vars in equation, make sure all are passed
+ preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]+)!",$equation, $match);
+ $allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10',
+ 'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
+
+ foreach($match[1] as $curr_var) {
+ if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
+ $smarty->trigger_error("math: function call $curr_var not allowed");
+ return;
+ }
+ }
+
+ foreach($params as $key => $val) {
+ if ($key != "equation" && $key != "format" && $key != "assign") {
+ // make sure value is not empty
+ if (strlen($val)==0) {
+ $smarty->trigger_error("math: parameter $key is empty");
+ return;
+ }
+ if (!is_numeric($val)) {
+ $smarty->trigger_error("math: parameter $key: is not numeric");
+ return;
+ }
+ $equation = preg_replace("/\b$key\b/",$val, $equation);
+ }
+ }
+
+ eval("\$smarty_math_result = ".$equation.";");
+
+ if (empty($params['format'])) {
+ if (empty($params['assign'])) {
+ return $smarty_math_result;
+ } else {
+ $smarty->assign($params['assign'],$smarty_math_result);
+ }
+ } else {
+ if (empty($params['assign'])){
+ printf($params['format'],$smarty_math_result);
+ } else {
+ $smarty->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
+ }
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.photoblog.php b/wp-inst/wp-content/smarty-plugins/function.photoblog.php
new file mode 100644
index 0000000..984fda1
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.photoblog.php
@@ -0,0 +1,102 @@
+<?php
+
+/* $Id: function.photoblog.php,v 1.4 2004/11/30 00:50:56 donncha Exp $ */
+
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: function.photoblog.php
+ * Type: function
+ * Name: photoblog
+ * Purpose: outputs an image from the images/ directory.
+ * -------------------------------------------------------------
+ */
+function get_post_id( $when )
+{
+ global $wpdb;
+ $query = "SELECT post_id FROM ".$wpdb->postmeta." WHERE meta_key='photoblog' AND meta_value='".$when."'";
+ $post_id = $wpdb->get_var( $query );
+ return $post_id;
+
+}
+function smarty_function_photoblog($params, &$smarty)
+{
+ global $id, $wpblog, $siteurl, $wpdb;
+
+ $start = "<div align='center'>";
+ $msg = "<b>Pic of the Day</b><br>";
+ $randmsg = "<b>Random Pic</b><br>";
+ $end = "</div>";
+ $class = "pictureborder";
+ $display = 'yes';
+
+ extract( $params );
+ if( isset( $when ) == false )
+ {
+ $when = date( "Ymd" );
+ }
+
+ if( is_file( ABSPATH."wp-content/blogs/".$wpblog."/images/photoblog-".$when.".jpg" ) )
+ {
+ $post_id = get_post_id( $when );
+ if( $display == 'yes' )
+ {
+ echo $start;
+ echo $msg;
+ echo "<img class='$class' src='".$siteurl."/images/photoblog-".$when.".jpg'>";
+ if( $post_id )
+ {
+ $t = $id;
+ $id = $post_id;
+ print "<br /><a href='".get_permalink( $post_id )."'>";
+ print comments_number( 'View Comments', 'Comments (1)', $more='Comments (%)');
+ print "</a>";
+ $id = $t;
+ }
+ echo $end;
+ }
+ else
+ {
+ return array( "image" => $siteurl."/images/photoblog-".$when.".jpg" );
+ }
+ }
+ else
+ {
+ $dir = "wp-content/blogs/".$wpblog."/images/";
+ if (is_dir($dir)) {
+ if ($dh = opendir($dir)) {
+ while (($file = readdir($dh)) !== false) {
+ if( strpos( $file, "hotoblog-" ) == 1 )
+ {
+ $files[] = $file;
+ }
+ }
+ closedir($dh);
+ $pic = $files[ rand( 0, count( $files ) - 1 ) ];
+ if( $pic != '' )
+ {
+ $when = substr( $pic, 10, 8 );
+ $post_id = get_post_id( $when );
+ if( $display == 'yes' )
+ {
+ echo $start;
+ echo $randmsg;
+ echo "<img class='$class' src='".$siteurl."/images/".$pic."'>";
+ if( $post_id )
+ {
+ $t = $id;
+ $id = $post_id;
+ print "<br /><a href='".get_permalink( $post_id )."'>";
+ print comments_number( 'View Comments', 'Comments (1)', $more='Comments (%)');
+ print "</a>";
+ $id = $t;
+ }
+ echo $end;
+ }
+ }
+
+ }
+ }
+ }
+}
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.pirate.php b/wp-inst/wp-content/smarty-plugins/function.pirate.php
new file mode 100644
index 0000000..f26d7ac
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.pirate.php
@@ -0,0 +1,181 @@
+<?php
+
+/* $Id: function.pirate.php,v 1.1.1.1 2004/10/14 12:07:23 donncha Exp $ */
+
+/*
+ Smarty plugin
+ -------------------------------------------------------------
+ File: function.pirate.php
+ Type: function
+ Name: pirate
+ Purpose: Piratize your content!
+ -------------------------------------------------------------
+
+ $Id: function.pirate.php,v 1.1.1.1 2004/10/14 12:07:23 donncha Exp $
+*/
+
+function smarty_function_pirate($params, &$smarty)
+{
+ extract( $params );
+
+ if( '0919' != date('md') )
+ {
+ return $content;
+ }
+ // Always replace these:
+ $patterns = array(
+ '%\bmy\b%' => 'me',
+ '%\bboss\b%' => 'admiral',
+ '%\bmanager\b%' => 'admiral',
+ '%\b[Cc]aptain\b%' => "Cap'n",
+ '%\bmyself\b%' => 'meself',
+ '%\byour\b%' => 'yer',
+ '%\byou\b%' => 'ye',
+ '%\bfriend\b%' => 'matey',
+ '%\bfriends\b%' => 'maties',
+ '%\bco[-]?worker\b%' => 'shipmate',
+ '%\bco[-]?workers\b%' => 'shipmates',
+ '%\bearlier\b%' => 'afore',
+ '%\bold\b%' => 'auld',
+ '%\bthe\b%' => "th'",
+ '%\bof\b%' => "o'",
+ "%\bdon't\b%" => "dern't",
+ '%\bdo not\b%' => "dern't",
+ '%\bnever\b%' => "ne'er",
+ '%\bever\b%' => "e'er",
+ '%\bover\b%' => "o'er",
+ '%\bYes\b%' => 'Aye',
+ '%\bNo\b%' => 'Nay',
+ "%\bdon't know\b%" => "dinna",
+ "%\bhadn't\b%" => "ha'nae",
+ "%\bdidn't\b%"=> "di'nae",
+ "%\bwasn't\b%" => "weren't",
+ "%\bhaven't\b%" => "ha'nae",
+ '%\bfor\b%' => 'fer',
+ '%\bbetween\b%' => 'betwixt',
+ '%\baround\b%' => "aroun'",
+ '%\bto\b%' => "t'",
+ "%\bit's\b%" => "'tis",
+ '%\bwoman\b%' => 'wench',
+ '%\blady\b%' => 'wench',
+ '%\bwife\b%' => 'lady',
+ '%\bgirl\b%' => 'lass',
+ '%\bgirls\b%' => 'lassies',
+ '%\bguy\b%' => 'lubber',
+ '%\bman\b%' => 'lubber',
+ '%\bfellow\b%' => 'lubber',
+ '%\bdude\b%' => 'lubber',
+ '%\bboy\b%' => 'lad',
+ '%\bboys\b%' => 'laddies',
+ '%\bchildren\b%' => 'little sandcrabs',
+ '%\bkids\b%' => 'minnows',
+ '%\bhim\b%' => 'that scurvey dog',
+ '%\bher\b%' => 'that comely wench',
+ '%\bhim\.\b%' => 'that drunken sailor',
+ '%\bHe\b%' => 'The ornery cuss',
+ '%\bShe\b%' => 'The winsome lass',
+ "%\bhe's\b%" => 'he be',
+ "%\bshe's\b%" => 'she be',
+ '%\bwas\b%' => "were bein'",
+ '%\bHey\b%' => 'Avast',
+ '%\bher\.\b%' => 'that lovely lass',
+ '%\bfood\b%' => 'chow',
+ '%\broad\b%' => 'sea',
+ '%\broads\b%' => 'seas',
+ '%\bstreet\b%' => 'river',
+ '%\bstreets\b%' => 'rivers',
+ '%\bhighway\b%' => 'ocean',
+ '%\bhighways\b%' => 'oceans',
+ '%\bcar\b%' => 'boat',
+ '%\bcars\b%' => 'boats',
+ '%\btruck\b%' => 'schooner',
+ '%\btrucks\b%' => 'schooners',
+ '%\bSUV\b%' => 'ship',
+ '%\bairplane\b%' => 'flying machine',
+ '%\bjet\b%' => 'flying machine',
+ '%\bmachine\b%' => 'contraption',
+ '%\bdriving\b%' => 'sailing',
+ '%\bdrive\b%' => 'sail',
+ );
+
+ // Replace the words:
+ $content = array_apply_regexp($patterns,$content);
+
+ // Word ending mangling:
+ $patterns = array(
+ '/ing\b/' => "in'",
+ // '/([a-zA-Z]{3,}[^lbro])ly(\W)/' => '$1-like$2',
+ );
+
+ $content = array_apply_regexp($patterns,$content);
+
+ // Random exclamations and such:
+ $patterns = array(
+ '/(\.\s)/e' => 'avast("$0",3)',
+ );
+
+ $content = array_apply_regexp($patterns,$content);
+
+ // Let's increase the chance for exclamation marks and question marks
+ $patterns = array(
+ '/([!\?]\s)/e' => 'avast("$0",2)',
+ );
+
+ $content = array_apply_regexp($patterns,$content);
+
+ return $content;
+}
+
+// support function for pirate()
+function avast($stub = '',$chance = 5) {
+ $shouts = array(
+ ", avast$stub",
+ "$stub Ahoy!",
+ ", and a bottle of rum!",
+ ", by Blackbeard's sword$stub",
+ ", by Davy Jones' locker$stub",
+ "$stub Walk the plank!",
+ "$stub Aarrr!",
+ "$stub Yaaarrrrr!",
+ ", pass the grog!",
+ ", and dinna spare the whip!",
+ ", with a chest full of booty$stub",
+ ", and a bucket o' chum$stub",
+ ", we'll keel-haul ye!",
+ "$stub Shiver me timbers!",
+ "$stub And hoist the mainsail!",
+ "$stub And swab the deck!",
+ ", ye scurvey dog$stub",
+ "$stub Fire the cannons!",
+ ", to be sure$stub",
+ ", I'll warrant ye$stub",
+ );
+
+ shuffle($shouts);
+
+ return (((1 == rand(1,$chance))?array_shift($shouts):$stub) . ' ');
+}
+
+// This function takes an array of ('/pattern/' => 'replacement') pairs
+// and applies them all to $content.
+function array_apply_regexp($patterns,$content) {
+ // Extract the values:
+ $keys = array_keys($patterns);
+ $values = array_values($patterns);
+
+ // Modify the key patterns to avoid modifying the contents
+ // of HTML tags
+ for ($i = 0; $i < count($keys); $i++) {
+ $regexp = $keys[$i];
+
+// $regexp = preg_replace('%^(.)(.+)(.)$%','$1(?!<[^>])$2(?![>])$3',$regexp);
+
+ $keys[$i] = $regexp;
+ }
+
+ // Replace the words:
+ $content = preg_replace($keys,$values,$content);
+
+ return $content;
+}
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.popularposts.php b/wp-inst/wp-content/smarty-plugins/function.popularposts.php
new file mode 100644
index 0000000..4a66e32
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.popularposts.php
@@ -0,0 +1,80 @@
+<?php
+
+/* $Id: function.popularposts.php,v 1.2 2005/01/09 11:54:18 donncha Exp $ */
+
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: function.popularposts.php
+ * Type: function
+ * Name: popularposts
+ * Purpose: outputs an image from the images/ directory.
+ * -------------------------------------------------------------
+ */
+
+function getlinks( $wpblog )
+{
+ global $wpdb, $site;
+ $s = strlen( $site );
+ $sql = "SELECT visitURL, sum( visitTimes ) as c
+ FROM `referer_visitLog`
+ WHERE blogID = '".$wpblog."'
+ AND visitURL LIKE '%/'
+ GROUP BY visitURL
+ ORDER BY c DESC LIMIT 0 , 30";
+ $results = $wpdb->get_results($sql);
+ if( $results )
+ {
+ reset( $results );
+ while( list( $key, $t ) = each( $results ) )
+ {
+ if( substr( $t->visitURL, -9 ) == 'index.php' )
+ $t->visitURL = substr( $t->visitURL, 0, -9 );
+ $hits[ $t->visitURL ] += $t->c;
+ }
+ arsort( $hits );
+ $hits = array_flip( $hits );
+ reset( $hits );
+ while( list( $key, $val ) = each( $hits ) )
+ {
+ if( substr( $val, -1 ) == '/' )
+ {
+ $post_name = substr( $val, 0, -1 );
+ $post_name = substr( $post_name, strrpos( $post_name, '/' ) + 1 );
+ $sql = "SELECT post_title
+ FROM ".$wpdb->posts."
+ WHERE post_name = '".$post_name."'";
+ $results = $wpdb->get_results($sql);
+ if( $results )
+ {
+ $links[ $key ] = array( "url" => $val, "title" => stripslashes( $results[0]->post_title ) );
+ }
+ }
+ }
+ }
+ else
+ {
+ $links = false;
+ }
+
+ return $links;
+}
+
+function smarty_function_popularposts($params, &$smarty)
+{
+ global $wpblog;
+ extract( $params );
+
+ if( @include_once( "Cache/Function.php" ) )
+ {
+ $cache = new Cache_Function( 'file', array('cache_dir' => ABSPATH . "/wp-content/smarty-cache", 'filename_prefix' => 'popularposts_cache_' ), 3600 );
+ $links = $cache->call( "getlinks", $wpblog );
+ }
+ else
+ {
+ $links = getlinks( $wpblog, $site );
+ }
+
+ $smarty->assign( "pposts", $links );
+}
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.popup.php b/wp-inst/wp-content/smarty-plugins/function.popup.php
new file mode 100644
index 0000000..2ba54de
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.popup.php
@@ -0,0 +1,117 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {popup} function plugin
+ *
+ * Type: function<br>
+ * Name: popup<br>
+ * Purpose: make text pop up in windows via overlib
+ * @link http://smarty.php.net/manual/en/language.function.popup.php {popup}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_popup($params, &$smarty)
+{
+ $append = '';
+ foreach ($params as $_key=>$_value) {
+ switch ($_key) {
+ case 'text':
+ case 'trigger':
+ case 'function':
+ case 'inarray':
+ $$_key = (string)$_value;
+ if ($_key == 'function' || $_key == 'inarray')
+ $append .= ',' . strtoupper($_key) . ",'$_value'";
+ break;
+
+ case 'caption':
+ case 'closetext':
+ case 'status':
+ $append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'";
+ break;
+
+ case 'fgcolor':
+ case 'bgcolor':
+ case 'textcolor':
+ case 'capcolor':
+ case 'closecolor':
+ case 'textfont':
+ case 'captionfont':
+ case 'closefont':
+ case 'fgbackground':
+ case 'bgbackground':
+ case 'caparray':
+ case 'capicon':
+ case 'background':
+ case 'frame':
+ $append .= ',' . strtoupper($_key) . ",'$_value'";
+ break;
+
+ case 'textsize':
+ case 'captionsize':
+ case 'closesize':
+ case 'width':
+ case 'height':
+ case 'border':
+ case 'offsetx':
+ case 'offsety':
+ case 'snapx':
+ case 'snapy':
+ case 'fixx':
+ case 'fixy':
+ case 'padx':
+ case 'pady':
+ case 'timeout':
+ case 'delay':
+ $append .= ',' . strtoupper($_key) . ",$_value";
+ break;
+
+ case 'sticky':
+ case 'left':
+ case 'right':
+ case 'center':
+ case 'above':
+ case 'below':
+ case 'noclose':
+ case 'autostatus':
+ case 'autostatuscap':
+ case 'fullhtml':
+ case 'hauto':
+ case 'vauto':
+ case 'mouseoff':
+ case 'followmouse':
+ if ($_value) $append .= ',' . strtoupper($_key);
+ break;
+
+ default:
+ $smarty->trigger_error("[popup] unknown parameter $_key", E_USER_WARNING);
+ }
+ }
+
+ if (empty($text) && !isset($inarray) && empty($function)) {
+ $smarty->trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required");
+ return false;
+ }
+
+ if (empty($trigger)) { $trigger = "onmouseover"; }
+
+ $retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\'';
+ $retval .= $append . ');"';
+ if ($trigger == 'onmouseover')
+ $retval .= ' onmouseout="nd();"';
+
+
+ return $retval;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.popup_init.php b/wp-inst/wp-content/smarty-plugins/function.popup_init.php
new file mode 100644
index 0000000..f62c33c
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.popup_init.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {popup_init} function plugin
+ *
+ * Type: function<br>
+ * Name: popup_init<br>
+ * Purpose: initialize overlib
+ * @link http://smarty.php.net/manual/en/language.function.popup.init.php {popup_init}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_popup_init($params, &$smarty)
+{
+ $zindex = 1000;
+
+ if (!empty($params['zindex'])) {
+ $zindex = $params['zindex'];
+ }
+
+ if (!empty($params['src'])) {
+ return '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>' . "\n"
+ . '<script type="text/javascript" language="JavaScript" src="'.$params['src'].'"></script>' . "\n";
+ } else {
+ $smarty->trigger_error("popup_init: missing src parameter");
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.referer.php b/wp-inst/wp-content/smarty-plugins/function.referer.php
new file mode 100644
index 0000000..cda8e59
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.referer.php
@@ -0,0 +1,128 @@
+<?php
+
+/* $Id: function.referer.php,v 1.4 2005/03/11 17:52:56 donncha Exp $ */
+
+
+// Based on code by Nathan Young @ http://ncyoung.com/entry/57
+// Modified by Donncha O Caoimh, donncha@linux.ie
+
+
+function getreferers( $wpblog, $siteDomain )
+{
+ global $wpdb;
+
+ /*if( $p || $cat || $m )
+ {
+ $sql = "select baseDomain,referingURL, visitTimes from referer_visitLog WHERE visitURL = '".$currentURL."' ORDER BY visitTime ASC LIMIT 0 , 10";
+ }
+ else
+ {*/
+ $sql = "select referingURL, visitTimes, visitTime from referer_visitLog WHERE blogID='".$wpblog."' and visitTime >= NOW() - INTERVAL 24 HOUR ORDER BY visitTime DESC";
+ //}
+ $result = $wpdb->get_results($sql);
+ if( $result )
+ {
+ foreach( $result as $details )
+ {
+ if( $details->referingURL == 'DIRECT' )
+ {
+ $details->baseDomain = $details->referingURL;
+ }
+ else
+ {
+ $t = preg_replace("/http:\/\//i", "", $details->referingURL );
+ $t = preg_replace("/^www\./i", "", $t );
+ $t = preg_replace("/\/.*/i", "", $t );
+ $details->baseDomain = $t;
+ }
+ if( $details->baseDomain != 'DIRECT' )
+ {
+ if( substr( $details->baseDomain, 0, 6 ) == 'google' )
+ {
+ $refererlinks[ 'google' ][ 'visitTimes' ] += $details->visitTimes;
+ $refererlinks[ 'google' ][ 'referingURL' ] = "http://www.google.com/";
+ $refererlinks[ 'google' ][ 'baseDomain' ] = "google.com";
+ }
+ elseif( strpos( $details->baseDomain, "ebsearch.com" ) )
+ {
+ $refererlinks[ 'websearch' ][ 'visitTimes' ] += $details->visitTimes;
+ $refererlinks[ 'websearch' ][ 'referingURL' ] = "http://www.websearch.com/";
+ $refererlinks[ 'websearch' ][ 'baseDomain' ] = "websearch.com";
+ }
+ elseif( strpos( $details->baseDomain, "ahoo.com" ) )
+ {
+ $refererlinks[ 'yahoo' ][ 'visitTimes' ] += $details->visitTimes;
+ $refererlinks[ 'yahoo' ][ 'referingURL' ] = "http://www.yahoo.com/";
+ $refererlinks[ 'yahoo' ][ 'baseDomain' ] = "yahoo.com";
+ }
+ elseif( strpos( $details->baseDomain, "sxml.infospace.com" ) )
+ {
+ $refererlinks[ 'yahoo' ][ 'visitTimes' ] += $details->visitTimes;
+ $refererlinks[ 'yahoo' ][ 'referingURL' ] = "http://msxml.infospace.com/";
+ $refererlinks[ 'yahoo' ][ 'baseDomain' ] = "infospace.com";
+ }
+ elseif( strpos( $details->baseDomain, $siteDomain ) === false )
+ {
+ $refererlinks[ $details->referingURL ][ "referingURL" ] = $details->referingURL;
+ $refererlinks[ $details->referingURL ][ "visitTimes" ] += $details->visitTimes;
+ $refererlinks[ $details->referingURL ][ "baseDomain" ] = $details->baseDomain;
+ }
+ }
+ }
+ if(is_array( $refererlinks ) == false )
+ $refererlinks = array();
+ reset( $refererlinks );
+ while( list( $key, $val ) = each( $refererlinks ) )
+ {
+ if( $val[ 'visitTimes' ] < 3 )
+ unset( $refererlinks[ $key ] );
+ }
+ }
+ else
+ {
+ $refererlinks = '';
+ }
+ return $refererlinks;
+}
+
+function smarty_function_referer($params, &$smarty)
+{
+ global $post, $wpdb, $wpblog;
+
+
+ $ref = getenv('HTTP_REFERER');
+ $currentURL = $_SERVER['REQUEST_URI'];
+ $fullCurrentURL = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
+
+ $tomorrow = date( "d", mktime (0,0,0,date("m") ,date("d")+1,date("Y")) );
+ if( $site == 'root' )
+ {
+ $sql = "delete from referer_visitLog WHERE dayofmonth = '$tomorrow'"; // delete referers from a (month - 1 day) ago.
+ $result = $wpdb->query( $query );
+ }
+
+ $siteurl = get_settings( "siteurl" );
+ $siteDomain = str_replace( "http://", "", $siteurl );
+ if( strpos( $siteDomain, "/" ) )
+ $siteDomain = substr( $siteDomain, 0, strpos( $siteDomain, "/" ) );
+
+ // find referers for current page
+
+ if( @include_once( "Cache/Function.php" ) )
+ {
+ $cache = new Cache_Function( 'file', array('cache_dir' => ABSPATH . "/wp-content/smarty-cache", 'filename_prefix' => 'referers_cache_' ), 600 );
+ $refererlinks = $cache->call( "getreferers", $wpblog, $siteDomain );
+ }
+ else
+ {
+ $refererlinks = getreferers( $wpblog, $siteDomain );
+ }
+
+
+ if( is_array( $refererlinks ) )
+ reset( $refererlinks );
+
+ $smarty->assign( "refererlinks", $refererlinks );
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.relatedstories.php b/wp-inst/wp-content/smarty-plugins/function.relatedstories.php
new file mode 100644
index 0000000..2af572c
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.relatedstories.php
@@ -0,0 +1,85 @@
+<?php
+
+/* $Id: function.relatedstories.php,v 1.2 2005/01/09 11:54:18 donncha Exp $ */
+
+/*
+ Originally by GamerZ, http://tidakada.com/board/viewtopic.php?t=1805&postdays=0&postorder=asc&start=0
+ Extensively modified by Donncha O Caoimh.
+
+ Add {$relatedstories} to your post.tpl to enable it
+*/
+
+function relatedstories( $wpblog, $posts, $post )
+{
+ global $wpdb, $tableposts;
+
+ $p = false;
+
+ if( count( $posts ) == 1 )
+ {
+ if( $post->ID != "" )
+ {
+ $query = "SELECT post_title, post_content FROM $tableposts WHERE ID='".$post->ID."'";
+ $p = $wpdb->get_row( $query );
+ if( $p )
+ {
+ $titlesearch = $p->post_title;
+ if( $titlesearch == '' )
+ $titlesearch = substr( str_replace( "'", "", strip_tags( $p->post_content ) ), 0, 20 );
+
+ $howmanystories=5;
+
+ $exclude = array ("a", "and", "are", "do", "it", "its", "is", "in", "i", "my", "the", "to", "with", "you", "this", "them" );
+
+ $qry = "SELECT DISTINCT ID, DATE_FORMAT(post_date, '%e/%c/%y') as c, post_content, post_title FROM $tableposts WHERE (";
+
+ $titlesearch = preg_replace('/, +/', '', $titlesearch);
+ $titlesearch = strtolower( trim($titlesearch) );
+ $words = explode (" ", $titlesearch);
+ $words = array_diff($words,$exclude);
+
+ reset( $words );
+ foreach ($words as $word)
+ {
+ if( strlen( $word ) > 2 )
+ {
+ $word = addslashes( $word );
+ $qry .= "(post_content LIKE '% $word%' OR post_title LIKE '% $word%') OR ";
+ $usedWords .= stripslashes( $word ).", ";
+ }
+ }
+ $usedWords = substr( $usedWords, 0, -2 );
+ $qry = substr ($qry, 0, strlen ($qry) - 4);
+ $qry .= ") AND (ID != '".$post->ID."') ORDER BY post_date DESC LIMIT $howmanystories";
+ $p = $wpdb->get_results( $qry );
+ }
+ }
+ }
+ else
+ {
+ }
+ return array( "p" => $p, "usedWords" => $usedWords );
+}
+
+
+function smarty_function_relatedstories( $params, &$smarty )
+{
+ global $wpblog, $wpdb, $post, $tableposts, $posts;
+
+ extract( $params );
+ if( @include_once( "Cache/Function.php" ) )
+ {
+ $cache = new Cache_Function( 'file', array('cache_dir' => ABSPATH . "/wp-content/smarty-cache", 'filename_prefix' => 'relatedstories_cache_' ), 3600 );
+ $links = $cache->call( "relatedstories", $wpblog, $posts, $post );
+ }
+ else
+ {
+ $links = relatedstories( $wpblog, $posts, $post );
+ }
+
+
+ $smarty->assign( "relatedstories", $links[ 'p' ] );
+ $smarty->assign( "relatedstoriesWords", $links[ 'usedWords' ] );
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.todayayearago.php b/wp-inst/wp-content/smarty-plugins/function.todayayearago.php
new file mode 100644
index 0000000..b6781c0
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.todayayearago.php
@@ -0,0 +1,84 @@
+<?php
+
+/* $Id: function.todayayearago.php,v 1.2 2005/01/09 11:54:18 donncha Exp $ */
+
+/*
+ Smarty plugin
+ -------------------------------------------------------------
+ File: function.todayayearago.php
+ Type: function
+ Name: todayayearago
+ Purpose: Print links to posts a year ago.
+ -------------------------------------------------------------
+
+ COPYRIGHT Indigo Anand Meridian @ http://indiboi.com/
+ Modified for Smarty plugin API by Donncha O Caoimh
+
+ $Id: function.todayayearago.php,v 1.2 2005/01/09 11:54:18 donncha Exp $
+*/
+
+function todayayearago( $when, $wpblog, $spacer ='<br /' )
+{
+ global $tableposts,$row,$blogfilename,$querystring_start,$querystring_equal,$time_difference, $siteurl, $wpdb;
+
+ if( $spacer == '' )
+ $spacer = '<br />';
+
+ if( $when == 'month' )
+ {
+ if( date('m') == '01' )
+ {
+ $year = (date('Y', time()+($time_difference * 3600)) - 1);
+ }
+ else
+ {
+ $year = (date('Y', time()+($time_difference * 3600)));
+ }
+ $month = date('m', time()+($time_difference * 3600)) - 1;
+ }
+ else
+ {
+ $year = (date('Y', time()+($time_difference * 3600))) - 1;
+ $month = date('m', time()+($time_difference * 3600));
+ }
+
+ $day = date("d", (time()+($time_difference * 3600)));
+
+ $reqhistory = "SELECT post_date, ID, post_title, SUBSTRING(post_content, 1, 100) as post_content
+ FROM $tableposts
+ WHERE YEAR(post_date) = $year
+ AND MONTH(post_date) = $month
+ AND DAYOFMONTH(post_date) = $day
+ AND post_status = 'publish'";
+ $reqhistory = $wpdb->get_results($reqhistory);
+ if( $reqhistory )
+ {
+ foreach( $reqhistory as $row )
+ {
+ $todayayearago[ $row->ID ] = array( "title" => strip_tags( stripslashes($row->post_title) ),
+ "content" => strip_tags( stripslashes( $row->post_content ) ) );
+ }
+ }
+ return $todayayearago;
+}
+
+function smarty_function_todayayearago($params, &$smarty)
+{
+ global $wpblog, $tableposts,$row,$blogfilename,$querystring_start,$querystring_equal,$time_difference, $siteurl, $wpdb;
+
+ extract( $params );
+
+ if( @include_once( "Cache/Function.php" ) )
+ {
+ $cache = new Cache_Function( 'file', array('cache_dir' => ABSPATH . "/wp-content/smarty-cache", 'filename_prefix' => 'todayayearago_cache_' ), 3600 );
+ $todayayearago = $cache->call( "todayayearago", $when, $wpblog, $spacer );
+ }
+ else
+ {
+ $todayayearago = todayayearago( $when, $wpblog, $spacer );
+ }
+
+
+ $smarty->assign( "todayayearago", $todayayearago );
+}
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.wp_ozh_click_comment_author_link.php b/wp-inst/wp-content/smarty-plugins/function.wp_ozh_click_comment_author_link.php
new file mode 100644
index 0000000..1924d4b
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.wp_ozh_click_comment_author_link.php
@@ -0,0 +1,27 @@
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: function
+ * Name: wp_ozh_click_topclicks
+ * Purpose: Prints list of top links
+ * -------------------------------------------------------------
+ */
+function smarty_function_wp_ozh_click_comment_author_link($params, &$smarty)
+{
+ extract($params);
+
+ if( function_exists( wp_ozh_click_comment_author_link ) )
+ {
+ wp_ozh_click_comment_author_link();
+ }
+ else
+ {
+ comment_author_link();
+ }
+}
+
+/* vim: set expandtab: */
+
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/function.wp_ozh_click_topclicks.php b/wp-inst/wp-content/smarty-plugins/function.wp_ozh_click_topclicks.php
new file mode 100644
index 0000000..6296629
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.wp_ozh_click_topclicks.php
@@ -0,0 +1,23 @@
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: function
+ * Name: wp_ozh_click_topclicks
+ * Purpose: Prints list of top links
+ * -------------------------------------------------------------
+ */
+function smarty_function_wp_ozh_click_topclicks($params, &$smarty)
+{
+ extract($params);
+
+ if( function_exists( wp_ozh_click_topclicks ) )
+ {
+ wp_ozh_click_topclicks( $limit, $trim, $pattern );
+ }
+}
+
+/* vim: set expandtab: */
+
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/insert.getreferer.php b/wp-inst/wp-content/smarty-plugins/insert.getreferer.php
new file mode 100644
index 0000000..5fa4bb8
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/insert.getreferer.php
@@ -0,0 +1,211 @@
+<?php
+
+/* $Id: insert.getreferer.php,v 1.1.1.1 2004/10/14 12:07:23 donncha Exp $ */
+
+
+// Based on code by Nathan Young @ http://ncyoung.com/entry/57
+// Modified by Donncha O Caoimh, donncha@linux.ie
+
+
+// TODO - see if I really need "visitID" in the table.
+
+
+function err( $err )
+{
+ error_log( "$err\n", 3, "/tmp/err.txt" );
+}
+
+function doCheckRef( $url )
+{
+ $check = true;
+ // Do we need to check the referer? If it's from a known site we can save some cycles.
+ $checklist = array( "direct", "http://www.technorati.com", "http://www.google", "http://www.yahoo", "http://www.linux.ie", "http://blogs.linux.ie", "http://blo.gs" );
+ reset( $checklist );
+ while( list( $key, $val ) = each( $checklist ) )
+ {
+ $p = strpos( strtolower( $url ), $val );
+ if( $p !== false )
+ /*
+ {
+ mail( "donncha@tradesignals.com", "check1: $val $url", "" );
+ return true;
+ }
+ else
+ */
+ {
+ $check = false;
+ }
+ }
+ /*
+ if( $check )
+ {
+ err( "check3: *$url*" );
+ }
+ else
+ {
+ err( "ok3: *$url*" );
+ }
+ */
+ return $check;
+}
+
+function smarty_insert_getreferer()
+{
+ global $siteurl, $p, $m, $cat, $site, $wpdb, $wpblog;
+
+
+ // delete tomorrow's referers today
+ $tomorrow = date( "j", mktime (0,0,0,date("m") ,date("d")+1,date("Y")) );
+ $sec = date( "s" );
+ $hour = date( "G" );
+ if( $sec == 30 && $hour < 2 )
+ {
+ $sql = "delete from referer_visitLog WHERE dayofmonth = '$tomorrow'"; // delete referers from a (month + 1 day) ago.
+ $wpdb->query($sql);
+ }
+
+ $ref = getenv('HTTP_REFERER');
+ $ua = getenv( 'HTTP_USER_AGENT' );
+ $currentURL = $_SERVER['REQUEST_URI'];
+ $fullCurrentURL = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
+ if( $ref == '' )
+ {
+ $ref = "DIRECT";
+ }
+
+ $found = false;
+
+ if( $currentURL[ strlen( $currentURL ) -1 ] == '/' )
+ {
+ $found = true;
+ }
+ else
+ {
+ $count_files = array( "wp-admin" );
+ reset( $count_files );
+ while( list( $key, $val ) = each( $count_files ) )
+ {
+ $pos = strpos( $currentURL, $val );
+ if( $pos == true )
+ {
+ $found = true;
+ }
+ }
+ if( $found == true )
+ {
+ // Don't bother going further - no need to record request!
+ return;
+ }
+ }
+
+ if ($ref || $ref = strip_tags($ref) )
+ {
+
+ $realReferer = true;
+ $ignorePages = Array( 'lastupdated.php', 'b2rdf.php', 'b2rss2.php', 'b2bookmarklet.php', 'b2referers.php', 'b2commentspopup.php' );
+ foreach ($ignorePages as $ignoresite){
+ if (stristr($currentURL, $ignoresite)){
+ $realReferer = false;
+ }
+ }
+
+ $ignore = Array(
+ 'http://www.myelin.co.nz/ecosystem/bot.php',
+ 'http://radio.xmlstoragesystem.com/rcsPublic/',
+ 'http://blogdex.media.mit.edu//',
+ 'http://subhonker6.userland.com/rcsPublic/',
+ 'mastadonte.com',
+ 'http://blo.gs/ping.php',
+ $siteurl
+ );
+ foreach ($ignore as $ignoresite){
+ if (stristr($ref, $ignoresite)){
+ $realReferer = false;
+ }
+ }
+
+ $doubleCheckReferers = 1;
+
+ $checkRef = doCheckRef( $ref );
+
+ if( $realReferer && $checkRef && $ref != 'DIRECT' && $doubleCheckReferers)
+ {
+ //this is so that the page up until the call to
+ //logReferer will get shown before it tries to check
+ //back against the refering URL.
+ flush();
+ //err( "checking $ref" );
+
+ $goodReferer = 0;
+ $fp = @fopen ($ref, "r");
+ if ($fp){
+ socket_set_timeout($fp, 5);
+ while (!feof ($fp)) {
+ $page .= trim(fgets($fp));
+ }
+ if (strstr($page,$fullCurrentURL)){
+ $goodReferer = 1;
+ }
+ }
+
+ if(!$goodReferer){
+ $realReferer = false;
+ }
+ if( $realReferer == true )
+ {
+ $query = "SELECT ID FROM referer_blacklist WHERE URL like '%$ref%'";
+ //error_log( "$query\n", 3, "/tmp/queries.txt" );
+ #mail( "donncha@tradesignals.com", "query", $query );
+ $result = $wpdb->get_row( $query );
+ if( $result )
+ {
+ $ref = "DIRECT";
+ }
+ }
+
+ }
+
+ $useragents = array( "http://www.syndic8.com", "http://dir.com/pompos.html", "NaverBot-1.0", "http://help.yahoo.com/help/us/ysearch/slurp", "http://www.google.com/bot.html", "http://www.blogdigger.com/", "http://search.msn.com/msnbot.htm", "Feedster, LLC.", "http://www.breakingblogs.com/timbo_bot.html", "fastbuzz.com", "http://www.pubsub.com/", "http://www.bloglines.com", "http://www.drupal.org/", "Ask Jeeves/Teoma", "ia_archiver", "http://minutillo.com/steve/feedonfeeds/", "larbin_2", "lmspider", "kinjabot", "lickBot 2.0", "Downes/Referrers", "daypopbot", "www.globalspec.com" );
+ reset( $useragents );
+ while( list( $key, $val ) = each( $useragents ) )
+ {
+ if( strpos( $ua, $val ) !== false )
+ {
+ $realReferer = false;
+ }
+ }
+
+ if( $realReferer )
+ {
+ if( $ref == 'DIRECT' )
+ {
+ $anchor = $ref;
+ }
+ else
+ {
+ $anchor = preg_replace("/http:\/\//i", "", $ref);
+ $anchor = preg_replace("/^www\./i", "", $anchor);
+ $anchor = preg_replace("/\/.*/i", "", $anchor);
+ }
+ $today = date( "d" );
+
+ $sql = "update referer_visitLog
+ set visitTimes = visitTimes + 1
+ where blogID = '$wpblog'
+ AND dayofmonth = '$today'
+ AND referingURL = '$ref'
+ AND baseDomain = '$anchor'
+ AND visitURL = '$currentURL'";
+ $result = $wpdb->query( $sql );
+ if( $result == false )
+ {
+ $sql ="insert delayed into referer_visitLog (blogID,referingURL,baseDomain,visitURL,refpost, visitTimes, dayofmonth)
+ values ('$wpblog','$ref','$anchor','$currentURL','$p','1', '$today')";
+
+ $result = $wpdb->query( $sql );
+ }
+ }
+ }
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/insert.var.php b/wp-inst/wp-content/smarty-plugins/insert.var.php
new file mode 100644
index 0000000..21d8c39
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/insert.var.php
@@ -0,0 +1,21 @@
+<?php
+
+function smarty_insert_var( $params, $smarty )
+{
+ global $REMOTE_ADDR;
+
+ extract( $params );
+
+ if( $REMOTE_ADDR == '217.75.13.250' )
+ error_log( "$var: ".$$var."\n", 3, "/tmp/err.txt" );
+ if( $var )
+ {
+ global $$var;
+ return $$var;
+ }
+ else
+ {
+ return "";
+ }
+}
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.capitalize.php b/wp-inst/wp-content/smarty-plugins/modifier.capitalize.php
new file mode 100644
index 0000000..2b9169c
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.capitalize.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty capitalize modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: capitalize<br>
+ * Purpose: capitalize words in the string
+ * @link http://smarty.php.net/manual/en/language.modifiers.php#LANGUAGE.MODIFIER.CAPITALIZE
+ * capitalize (Smarty online manual)
+ * @param string
+ * @return string
+ */
+function smarty_modifier_capitalize($string, $uc_digits = false)
+{
+ smarty_modifier_capitalize_ucfirst(null, $uc_digits);
+ return preg_replace_callback('!\b\w+\b!', 'smarty_modifier_capitalize_ucfirst', $string);
+}
+
+function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null)
+{
+ static $_uc_digits = false;
+
+ if(isset($uc_digits)) {
+ $_uc_digits = $uc_digits;
+ return;
+ }
+
+ if(!preg_match('!\d!',$string[0]) || $_uc_digits)
+ return ucfirst($string[0]);
+ else
+ return $string[0];
+}
+
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.cat.php b/wp-inst/wp-content/smarty-plugins/modifier.cat.php
new file mode 100644
index 0000000..2e37940
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.cat.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty cat modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: cat<br>
+ * Date: Feb 24, 2003
+ * Purpose: catenate a value to a variable
+ * Input: string to catenate
+ * Example: {$var|cat:"foo"}
+ * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
+ * (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_cat($string, $cat)
+{
+ return $string . $cat;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.count_characters.php b/wp-inst/wp-content/smarty-plugins/modifier.count_characters.php
new file mode 100644
index 0000000..49ce655
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.count_characters.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty count_characters modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: count_characteres<br>
+ * Purpose: count the number of characters in a text
+ * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php
+ * count_characters (Smarty online manual)
+ * @param string
+ * @param boolean include whitespace in the character count
+ * @return integer
+ */
+function smarty_modifier_count_characters($string, $include_spaces = false)
+{
+ if ($include_spaces)
+ return(strlen($string));
+
+ return preg_match_all("/[^\s]/",$string, $match);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.count_paragraphs.php b/wp-inst/wp-content/smarty-plugins/modifier.count_paragraphs.php
new file mode 100644
index 0000000..6a9833c
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.count_paragraphs.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty count_paragraphs modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: count_paragraphs<br>
+ * Purpose: count the number of paragraphs in a text
+ * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
+ * count_paragraphs (Smarty online manual)
+ * @param string
+ * @return integer
+ */
+function smarty_modifier_count_paragraphs($string)
+{
+ // count \r or \n characters
+ return count(preg_split('/[\r\n]+/', $string));
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.count_sentences.php b/wp-inst/wp-content/smarty-plugins/modifier.count_sentences.php
new file mode 100644
index 0000000..0c210f0
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.count_sentences.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty count_sentences modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: count_sentences
+ * Purpose: count the number of sentences in a text
+ * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
+ * count_sentences (Smarty online manual)
+ * @param string
+ * @return integer
+ */
+function smarty_modifier_count_sentences($string)
+{
+ // find periods with a word before but not after.
+ return preg_match_all('/[^\s]\.(?!\w)/', $string, $match);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.count_words.php b/wp-inst/wp-content/smarty-plugins/modifier.count_words.php
new file mode 100644
index 0000000..42c8a74
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.count_words.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty count_words modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: count_words<br>
+ * Purpose: count the number of words in a text
+ * @link http://smarty.php.net/manual/en/language.modifier.count.words.php
+ * count_words (Smarty online manual)
+ * @param string
+ * @return integer
+ */
+function smarty_modifier_count_words($string)
+{
+ // split text by ' ',\r,\n,\f,\t
+ $split_array = preg_split('/\s+/',$string);
+ // count matches that contain alphanumerics
+ $word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array);
+
+ return count($word_count);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.date_format.php b/wp-inst/wp-content/smarty-plugins/modifier.date_format.php
new file mode 100644
index 0000000..2f36b3b
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.date_format.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Include the {@link shared.make_timestamp.php} plugin
+ */
+require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
+/**
+ * Smarty date_format modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: date_format<br>
+ * Purpose: format datestamps via strftime<br>
+ * Input:<br>
+ * - string: input date string
+ * - format: strftime format for output
+ * - default_date: default date if $string is empty
+ * @link http://smarty.php.net/manual/en/language.modifier.date.format.php
+ * date_format (Smarty online manual)
+ * @param string
+ * @param string
+ * @param string
+ * @return string|void
+ * @uses smarty_make_timestamp()
+ */
+function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null)
+{
+ if (substr(PHP_OS,0,3) == 'WIN') {
+ $_win_from = array ('%e', '%T', '%D');
+ $_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y');
+ $format = str_replace($_win_from, $_win_to, $format);
+ }
+ if($string != '') {
+ return strftime($format, smarty_make_timestamp($string));
+ } elseif (isset($default_date) && $default_date != '') {
+ return strftime($format, smarty_make_timestamp($default_date));
+ } else {
+ return;
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.debug_print_var.php b/wp-inst/wp-content/smarty-plugins/modifier.debug_print_var.php
new file mode 100644
index 0000000..b9bb184
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.debug_print_var.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty debug_print_var modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: debug_print_var<br>
+ * Purpose: formats variable contents for display in the console
+ * @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php
+ * debug_print_var (Smarty online manual)
+ * @param array|object
+ * @param integer
+ * @param integer
+ * @return string
+ */
+function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
+{
+ $_replace = array("\n"=>'<i>&#92;n</i>', "\r"=>'<i>&#92;r</i>', "\t"=>'<i>&#92;t</i>');
+ if (is_array($var)) {
+ $results = "<b>Array (".count($var).")</b>";
+ foreach ($var as $curr_key => $curr_val) {
+ $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length);
+ $results .= "<br>".str_repeat('&nbsp;', $depth*2)."<b>".strtr($curr_key, $_replace)."</b> =&gt; $return";
+ }
+ } else if (is_object($var)) {
+ $object_vars = get_object_vars($var);
+ $results = "<b>".get_class($var)." Object (".count($object_vars).")</b>";
+ foreach ($object_vars as $curr_key => $curr_val) {
+ $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length);
+ $results .= "<br>".str_repeat('&nbsp;', $depth*2)."<b>$curr_key</b> =&gt; $return";
+ }
+ } else if (is_resource($var)) {
+ $results = '<i>'.(string)$var.'</i>';
+ } else if (empty($var) && $var != "0") {
+ $results = '<i>empty</i>';
+ } else {
+ if (strlen($var) > $length ) {
+ $results = substr($var, 0, $length-3).'...';
+ } else {
+ $results = $var;
+ }
+ $results = htmlspecialchars($results);
+ $results = strtr($results, $_replace);
+ }
+ return $results;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.default.php b/wp-inst/wp-content/smarty-plugins/modifier.default.php
new file mode 100644
index 0000000..8268e39
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.default.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty default modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: default<br>
+ * Purpose: designate default value for empty variables
+ * @link http://smarty.php.net/manual/en/language.modifier.default.php
+ * default (Smarty online manual)
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_default($string, $default = '')
+{
+ if (!isset($string) || $string === '')
+ return $default;
+ else
+ return $string;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.escape.php b/wp-inst/wp-content/smarty-plugins/modifier.escape.php
new file mode 100644
index 0000000..a32a876
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.escape.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty escape modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: escape<br>
+ * Purpose: Escape the string according to escapement type
+ * @link http://smarty.php.net/manual/en/language.modifier.escape.php
+ * escape (Smarty online manual)
+ * @param string
+ * @param html|htmlall|url|quotes|hex|hexentity|javascript
+ * @return string
+ */
+function smarty_modifier_escape($string, $esc_type = 'html')
+{
+ switch ($esc_type) {
+ case 'html':
+ return htmlspecialchars($string, ENT_QUOTES);
+
+ case 'htmlall':
+ return htmlentities($string, ENT_QUOTES);
+
+ case 'url':
+ return rawurlencode($string);
+
+ case 'quotes':
+ // escape unescaped single quotes
+ return preg_replace("%(?<!\\\\)'%", "\\'", $string);
+
+ case 'hex':
+ // escape every character into hex
+ $return = '';
+ for ($x=0; $x < strlen($string); $x++) {
+ $return .= '%' . bin2hex($string[$x]);
+ }
+ return $return;
+
+ case 'hexentity':
+ $return = '';
+ for ($x=0; $x < strlen($string); $x++) {
+ $return .= '&#x' . bin2hex($string[$x]) . ';';
+ }
+ return $return;
+
+ case 'decentity':
+ $return = '';
+ for ($x=0; $x < strlen($string); $x++) {
+ $return .= '&#' . ord($string[$x]) . ';';
+ }
+ return $return;
+
+ case 'javascript':
+ // escape quotes and backslashes, newlines, etc.
+ return strtr($string, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/'));
+
+ case 'mail':
+ // safe way to display e-mail address on a web page
+ return str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '), $string);
+
+ case 'nonstd':
+ // escape non-standard chars, such as ms document quotes
+ $_res = '';
+ for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
+ $_ord = ord($string{$_i});
+ // non-standard char, escape it
+ if($_ord >= 126){
+ $_res .= '&#' . $_ord . ';';
+ }
+ else {
+ $_res .= $string{$_i};
+ }
+ }
+ return $_res;
+
+ default:
+ return $string;
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.highlightsearch.php b/wp-inst/wp-content/smarty-plugins/modifier.highlightsearch.php
new file mode 100644
index 0000000..cba48e3
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.highlightsearch.php
@@ -0,0 +1,80 @@
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: modifier
+ * Name: highlight
+ * Version: 0.5
+ * Date: 2003-03-27
+ * Author: Pavel Prishivalko, aloner#telephone.ru
+ * Purpose: Highlight search term in text
+ * Install: Drop into the plugin directory
+ *
+ * Extended To 0.5 By: Alexey Kulikov <alex@pvl.at>
+ * Strips Tags for nice output, allows multiple term for highlight
+ * Modified and simplified to high light b2 searches by Donncha O Caoimh
+ * Added google search highlight using code from http://www.textism.com/tools/google_hilite/
+ * -------------------------------------------------------------
+ */
+
+function smarty_modifier_highlightsearch($text, $start_tag='<b style="color: #000; background-color: #ff0;">', $end_tag='</b>')
+{
+ global $smarty, $p, $s, $_SERVER, $HTTP_REFERER;
+
+ $orig = $text;
+
+ if( $s != '' )
+ {
+ $b = preg_quote($s);
+
+ if (!preg_match('/<.+>/',$text)) {
+
+ // If there are no tags in the text, we'll just do a simple search and replace
+ $text = preg_replace('/(\b'.$b.'\b)/i',$start_tag.'$1'.$end_tag,$text);
+
+ } else {
+
+ // If there are tags, we need to stay outside them
+ $text = preg_replace('/(?<=>)([^<]+)?(\b'.$b.'\b)/i','$1'.$start_tag.'$2'.$end_tag,$text);
+
+ }
+ }
+ else
+ {
+ $ref = urldecode($_SERVER[ 'HTTP_REFERER' ]);
+ // let's see if the referrer is google
+ if (preg_match('/^http:\/\/w?w?w?\.?google.*/i',$ref))
+ {
+ // if so, tweezer out the search query
+ $query = preg_replace('/^.*q=([^&]+)&?.*$/i','$1',$ref);
+
+ // scrub away nasty quote marks
+ $query = preg_replace('/\'|"/','',$query);
+
+ // chop the search terms into an array
+ $query_array = preg_split ("/[\s,\+\.]+/",$query);
+
+ // loop through the search terms
+ foreach($query_array as $b)
+ {
+ if (!preg_match('/<.+>/',$text)) {
+
+ // If there are no tags in the text, we'll just do a simple search and replace
+ $text = preg_replace('/(\b'.$b.'\b)/i',$start_tag.'$1'.$end_tag,$text);
+
+ } else {
+
+ // If there are tags, we need to stay outside them
+ $text = preg_replace('/(?<=>)([^<]+)?(\b'.$b.'\b)/i','$1'.$start_tag.'$2'.$end_tag,$text);
+
+ }
+ }
+ }
+ }
+ if( $text != $orig )
+ if( $p != '' )
+ $smarty->clear_cache( "post.tpl", $p.$p );
+
+ return $text;
+}
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.indent.php b/wp-inst/wp-content/smarty-plugins/modifier.indent.php
new file mode 100644
index 0000000..1642bac
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.indent.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty indent modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: indent<br>
+ * Purpose: indent lines of text
+ * @link http://smarty.php.net/manual/en/language.modifier.indent.php
+ * indent (Smarty online manual)
+ * @param string
+ * @param integer
+ * @param string
+ * @return string
+ */
+function smarty_modifier_indent($string,$chars=4,$char=" ")
+{
+ return preg_replace('!^!m',str_repeat($char,$chars),$string);
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.lower.php b/wp-inst/wp-content/smarty-plugins/modifier.lower.php
new file mode 100644
index 0000000..0b4d151
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.lower.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty lower modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: lower<br>
+ * Purpose: convert string to lowercase
+ * @link http://smarty.php.net/manual/en/language.modifier.lower.php
+ * lower (Smarty online manual)
+ * @param string
+ * @return string
+ */
+function smarty_modifier_lower($string)
+{
+ return strtolower($string);
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.nl2br.php b/wp-inst/wp-content/smarty-plugins/modifier.nl2br.php
new file mode 100644
index 0000000..d6fabff
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.nl2br.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty plugin
+ *
+ * Type: modifier<br>
+ * Name: nl2br<br>
+ * Date: Feb 26, 2003
+ * Purpose: convert \r\n, \r or \n to <<br>>
+ * Input:<br>
+ * - contents = contents to replace
+ * - preceed_test = if true, includes preceeding break tags
+ * in replacement
+ * Example: {$text|nl2br}
+ * @link http://smarty.php.net/manual/en/language.modifier.nl2br.php
+ * nl2br (Smarty online manual)
+ * @version 1.0
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @param string
+ * @return string
+ */
+function smarty_modifier_nl2br($string)
+{
+ return nl2br($string);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.regex_replace.php b/wp-inst/wp-content/smarty-plugins/modifier.regex_replace.php
new file mode 100644
index 0000000..7eee497
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.regex_replace.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty regex_replace modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: regex_replace<br>
+ * Purpose: regular epxression search/replace
+ * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
+ * regex_replace (Smarty online manual)
+ * @param string
+ * @param string|array
+ * @param string|array
+ * @return string
+ */
+function smarty_modifier_regex_replace($string, $search, $replace)
+{
+ if (preg_match('!\W(\w+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
+ /* remove eval-modifier from $search */
+ $search = substr($search, 0, -strlen($match[1])) . str_replace('e', '', $match[1]);
+ }
+ return preg_replace($search, $replace, $string);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.replace.php b/wp-inst/wp-content/smarty-plugins/modifier.replace.php
new file mode 100644
index 0000000..2a43515
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.replace.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty replace modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: replace<br>
+ * Purpose: simple search/replace
+ * @link http://smarty.php.net/manual/en/language.modifier.replace.php
+ * replace (Smarty online manual)
+ * @param string
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_replace($string, $search, $replace)
+{
+ return str_replace($search, $replace, $string);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.spacify.php b/wp-inst/wp-content/smarty-plugins/modifier.spacify.php
new file mode 100644
index 0000000..dad057f
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.spacify.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty spacify modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: spacify<br>
+ * Purpose: add spaces between characters in a string
+ * @link http://smarty.php.net/manual/en/language.modifier.spacify.php
+ * spacify (Smarty online manual)
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_spacify($string, $spacify_char = ' ')
+{
+ return implode($spacify_char,
+ preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY));
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.string_format.php b/wp-inst/wp-content/smarty-plugins/modifier.string_format.php
new file mode 100644
index 0000000..efd6215
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.string_format.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty string_format modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: string_format<br>
+ * Purpose: format strings via sprintf
+ * @link http://smarty.php.net/manual/en/language.modifier.string.format.php
+ * string_format (Smarty online manual)
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_string_format($string, $format)
+{
+ return sprintf($format, $string);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.strip.php b/wp-inst/wp-content/smarty-plugins/modifier.strip.php
new file mode 100644
index 0000000..cc5c453
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.strip.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty strip modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: strip<br>
+ * Purpose: Replace all repeated spaces, newlines, tabs
+ * with a single space or supplied replacement string.<br>
+ * Example: {$var|strip} {$var|strip:"&nbsp;"}
+ * Date: September 25th, 2002
+ * @link http://smarty.php.net/manual/en/language.modifier.strip.php
+ * strip (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_strip($text, $replace = ' ')
+{
+ return preg_replace('!\s+!', $replace, $text);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.strip_tags.php b/wp-inst/wp-content/smarty-plugins/modifier.strip_tags.php
new file mode 100644
index 0000000..45f1ec1
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.strip_tags.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty strip_tags modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: strip_tags<br>
+ * Purpose: strip html tags from text
+ * @link http://smarty.php.net/manual/en/language.modifier.strip.tags.php
+ * strip_tags (Smarty online manual)
+ * @param string
+ * @param boolean
+ * @return string
+ */
+function smarty_modifier_strip_tags($string, $replace_with_space = true)
+{
+ if ($replace_with_space)
+ return preg_replace('!<[^>]*?>!', ' ', $string);
+ else
+ return strip_tags($string);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.truncate.php b/wp-inst/wp-content/smarty-plugins/modifier.truncate.php
new file mode 100644
index 0000000..15a26ba
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.truncate.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty truncate modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: truncate<br>
+ * Purpose: Truncate a string to a certain length if necessary,
+ * optionally splitting in the middle of a word, and
+ * appending the $etc string.
+ * @link http://smarty.php.net/manual/en/language.modifier.truncate.php
+ * truncate (Smarty online manual)
+ * @param string
+ * @param integer
+ * @param string
+ * @param boolean
+ * @return string
+ */
+function smarty_modifier_truncate($string, $length = 80, $etc = '...',
+ $break_words = false)
+{
+ if ($length == 0)
+ return '';
+
+ if (strlen($string) > $length) {
+ $length -= strlen($etc);
+ if (!$break_words)
+ $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
+
+ return substr($string, 0, $length).$etc;
+ } else
+ return $string;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.upper.php b/wp-inst/wp-content/smarty-plugins/modifier.upper.php
new file mode 100644
index 0000000..69960ae
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.upper.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty upper modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: upper<br>
+ * Purpose: convert string to uppercase
+ * @link http://smarty.php.net/manual/en/language.modifier.upper.php
+ * upper (Smarty online manual)
+ * @param string
+ * @return string
+ */
+function smarty_modifier_upper($string)
+{
+ return strtoupper($string);
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.wordwrap.php b/wp-inst/wp-content/smarty-plugins/modifier.wordwrap.php
new file mode 100644
index 0000000..b9a9fe9
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.wordwrap.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty wordwrap modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: wordwrap<br>
+ * Purpose: wrap a string of text at a given length
+ * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php
+ * wordwrap (Smarty online manual)
+ * @param string
+ * @param integer
+ * @param string
+ * @param boolean
+ * @return string
+ */
+function smarty_modifier_wordwrap($string,$length=80,$break="\n",$cut=false)
+{
+ return wordwrap($string,$length,$break,$cut);
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/outputfilter.protect_email.php b/wp-inst/wp-content/smarty-plugins/outputfilter.protect_email.php
new file mode 100644
index 0000000..bf38f9d
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/outputfilter.protect_email.php
@@ -0,0 +1,16 @@
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: outputfilter.protect_email.php
+ * Type: outputfilter
+ * Name: protect_email
+ * Purpose: Converts @ sign in email addresses to %40 as
+ * a simple protection against spambots
+ * -------------------------------------------------------------
+ */
+ function smarty_outputfilter_protect_email($output, &$smarty)
+ {
+ return preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!', '$1%40$2', $output);
+ }
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/outputfilter.trimwhitespace.php b/wp-inst/wp-content/smarty-plugins/outputfilter.trimwhitespace.php
new file mode 100644
index 0000000..01e35e0
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/outputfilter.trimwhitespace.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty trimwhitespace outputfilter plugin
+ *
+ * File: outputfilter.trimwhitespace.php<br>
+ * Type: outputfilter<br>
+ * Name: trimwhitespace<br>
+ * Date: Jan 25, 2003<br>
+ * Purpose: trim leading white space and blank lines from
+ * template source after it gets interpreted, cleaning
+ * up code and saving bandwidth. Does not affect
+ * <<PRE>></PRE> and <SCRIPT></SCRIPT> blocks.<br>
+ * Install: Drop into the plugin directory, call
+ * <code>$smarty->load_filter('output','trimwhitespace');</code>
+ * from application.
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author Contributions from Lars Noschinski <lars@usenet.noschinski.de>
+ * @version 1.3
+ * @param string
+ * @param Smarty
+ */
+function smarty_outputfilter_trimwhitespace($source, &$smarty)
+{
+ // Pull out the script blocks
+ preg_match_all("!<script[^>]+>.*?</script>!is", $source, $match);
+ $_script_blocks = $match[0];
+ $source = preg_replace("!<script[^>]+>.*?</script>!is",
+ '@@@SMARTY:TRIM:SCRIPT@@@', $source);
+
+ // Pull out the pre blocks
+ preg_match_all("!<pre>.*?</pre>!is", $source, $match);
+ $_pre_blocks = $match[0];
+ $source = preg_replace("!<pre>.*?</pre>!is",
+ '@@@SMARTY:TRIM:PRE@@@', $source);
+
+ // Pull out the textarea blocks
+ preg_match_all("!<textarea[^>]+>.*?</textarea>!is", $source, $match);
+ $_textarea_blocks = $match[0];
+ $source = preg_replace("!<textarea[^>]+>.*?</textarea>!is",
+ '@@@SMARTY:TRIM:TEXTAREA@@@', $source);
+
+ // remove all leading spaces, tabs and carriage returns NOT
+ // preceeded by a php close tag.
+ $source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source));
+
+ // replace script blocks
+ smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source);
+
+ // replace pre blocks
+ smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source);
+
+ // replace textarea blocks
+ smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source);
+
+ return $source;
+}
+
+function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) {
+ $_len = strlen($search_str);
+ $_pos = 0;
+ for ($_i=0, $_count=count($replace); $_i<$_count; $_i++)
+ if (($_pos=strpos($subject, $search_str, $_pos))!==false)
+ $subject = substr_replace($subject, $replace[$_i], $_pos, $_len);
+ else
+ break;
+
+}
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/shared.escape_special_chars.php b/wp-inst/wp-content/smarty-plugins/shared.escape_special_chars.php
new file mode 100644
index 0000000..515763a
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/shared.escape_special_chars.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Smarty shared plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * escape_special_chars common function
+ *
+ * Function: smarty_function_escape_special_chars<br>
+ * Purpose: used by other smarty functions to escape
+ * special chars except for already escaped ones
+ * @param string
+ * @return string
+ */
+function smarty_function_escape_special_chars($string)
+{
+ if(!is_array($string)) {
+ $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
+ $string = htmlspecialchars($string);
+ $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);
+ }
+ return $string;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/shared.make_timestamp.php b/wp-inst/wp-content/smarty-plugins/shared.make_timestamp.php
new file mode 100644
index 0000000..acdd777
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/shared.make_timestamp.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Smarty shared plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Function: smarty_make_timestamp<br>
+ * Purpose: used by other smarty functions to make a timestamp
+ * from a string.
+ * @param string
+ * @return string
+ */
+function smarty_make_timestamp($string)
+{
+ if(empty($string)) {
+ $string = "now";
+ }
+ $time = strtotime($string);
+ if (is_numeric($time) && $time != -1)
+ return $time;
+
+ // is mysql timestamp format of YYYYMMDDHHMMSS?
+ if (preg_match('/^\d{14}$/', $string)) {
+ $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),
+ substr($string,4,2),substr($string,6,2),substr($string,0,4));
+
+ return $time;
+ }
+
+ // couldn't recognize it, try to return a time
+ $time = (int) $string;
+ if ($time > 0)
+ return $time;
+ else
+ return time();
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/wp-inst/wp-content/smarty-plugins/wp_ozh_clickcounter.php b/wp-inst/wp-content/smarty-plugins/wp_ozh_clickcounter.php
new file mode 100644
index 0000000..2a3fe8c
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/wp_ozh_clickcounter.php
@@ -0,0 +1,504 @@
+<?php
+/*
+Plugin Name: Click Counter
+Plugin URI: http://frenchfragfactory.net/ozh/archives/2004/09/17/click-counter-plugin-for-wordpress/
+Description: Adds a click counter to links in your posts (<a href="../wp-content/plugins/wp_ozh_clickcounter.php">quick readme & manual</a>)
+Version: 1.0
+Author: Ozh
+Author URI: http://planetOzh.com
+*/
+// script called directly (or something global badly misconfigured :)
+if (!function_exists("get_settings")) {wp_ozh_click_readme();die;}
+
+
+/*************************************
+ * OPTIONAL EDIT BELOW *
+ * ~~ *
+ *************************************/
+
+// when specified "default value" it means it can be overridden on a per-link basis in each post
+
+// Core variables
+
+$wp_ozh_click['table'] = 'wp_linkclicks';
+ /* name of the table where stats will be stored. Look at the bottom or at plugin page to learn how to create this table */
+$wp_ozh_click['file'] = get_settings('siteurl') . "/go.php" ;
+ /* name of the click counter php file (provided with the plugin archive). A good place for it is your blog root. */
+
+
+// Basic features
+
+$wp_ozh_click['do_posts'] = 1;
+ /* 0 or 1, or true / false
+ * Add or not a link counter to links in your posts */
+
+$wp_ozh_click['do_comments'] = 1;
+ /* 0 or 1, or true / false
+ * Add or not a link counter to links in comments */
+
+ /* There is a quick editing needed if you also want to add a counter
+ * to commenters' website when specified, see plugin page. */
+
+$wp_ozh_click['track_all_links'] = 1 ;
+ /* 0 : adds a counter only when you add count="value" in your links html tag
+ * 1 : adds a counter to all external links in your posts (no need to add counter="1" if you plan to track them all)
+ * To keep track of internal links if set to 1, put absolute path (http://yourblog/link) instead of relative (/link) */
+
+$wp_ozh_click['in_title'] = 1 ;
+ /* 1 or 0 (or true / false)
+ * add number of hits in link title tag : <a href="http://site.com" title="X hits">site</a> */
+
+$wp_ozh_click['in_plain'] = 0 ;
+ /* 1 or 0 (or true / false)
+ * add number of hits in plain text : <a href="http://site.com">site</a> <span class="hitcounter">(XX hits)</span> */
+
+$wp_ozh_click['0click'] = 'No click';
+ /* default text for zero clicks. */
+
+$wp_ozh_click['1click'] = 'One hit';
+ /* default text for one click */
+
+$wp_ozh_click['clicks'] = '%% hits';
+ /* default text for several clicks, where %% will be replaced by a number */
+
+$wp_ozh_click['method'] = 3 ;
+ /* 1, 2 or 3
+ * There are 3 link 'href' modification modes available
+ * Each has advantages and drawbacks
+ * All validate any Doctype up to xhtml 1.1
+ *
+ * From input <a href="http://site.com">, each methods gives the following html :
+ *
+ * Method 1 :
+ * ^^^^^^^^^^
+ * <a href="http://site.com" onclick="window.location='/go.php?http://site.com'; return false">
+ * Cool : status bar shows real link without further trick.
+ * Less cool : doesnt work with "open link in new window"
+ *
+ * Method 2 :
+ * ^^^^^^^^^^
+ * <a href="/yourblog/go.php?http://site.com">
+ * Cool : works with "open in new window" and doesn't require Javascript enabled
+ * Less cool : shows ugly link "/blog/go.php?http://site.com" in status bar
+ *
+ * Method 3 :
+ * ^^^^^^^^^^
+ * like method 2 but also modify status bar to hide the "yoursite.com/blog/go.php?" part
+ * with an onmouseover="javascript:window.status='http://site.com'; return false"
+ * Cool : status bar shows real link.
+ * Less cool : adds a few bytes of html. But who cares :)
+ *
+ * I'd suggest you use preferably method 3, or at least method 2. Method 1 is really less
+ * accurate since it doesn't keep track of links opened in a new window */
+
+
+// Link title features
+// The plugin is able to retrieve a remote file title (from it's <title> html tag)
+
+$wp_ozh_click['get_title'] = 0;
+ /* 1 or 0 (or true / false)
+ * Get remote page title the first time a user clicks a link to store it along with hits in the table
+ * Will slow down a bit the first clicker (1 or 2 seconds, time for your website to retrieve the distant page)
+ * Titles stored are used for example when printing top clicked links
+ * !! Note : uses fopen(), check your host has enabled this !! */
+
+$wp_ozh_click['get_title_forcerefresh'] = 50;
+ /* Refresh remote page title every XX clicks ?
+ * Set to 0 if you don't want to check & refresh titles every XX clicks
+ * (the higher traffic - then clicks - you get, the higher you should set this
+ * To be honest this is really a gadget - almost totally useless :)
+ * Examples : 50 for Joe's blog, 3000 for Slashdottish blog */
+
+$wp_ozh_click['extensions'] = array (
+ "ace", "arj", "bin", "bz2", "dat", "deb", "gz", "hqx", "pak", "pk3", "rar", "rpm", "sea", "sit", "tar", "wsz", "zip",
+ "aif", "aiff", "au", "mid", "mod", "mp3", "ogg", "ram", "rm", "wav",
+ "ani", "bmp", "dwg", "eps", "eps2", "gif", "ico", "jpeg", "jpg", "png", "psd", "psp", "qt", "svg", "swf", "tga", "tiff", "wmf", "xcf",
+ "avi", "mov", "mpeg", "mpg",
+ "c", "class", "h", "java ", "jar", "js",
+ "bat", "chm", "cur", "dll", "exe", "hlp", "inf", "ocx", "pps", "ppt", "reg", "scr", "xls",
+ "css", "conf", "doc", "ini", "pdf", "rtf", "ttf", "txt"
+); /* Most common non html file extensions
+ * These are files that have no <title> html tag, so their link title will be $document.$ext */
+
+// Top links function features
+
+$wp_ozh_click['top_limit'] = 5;
+ /* default number of top links to be displayed by wp_ozh_click_topclicks() */
+
+$wp_ozh_click['top_pattern'] = '<li><a href="%%link_url%%" title="%%link_title%%">%%link_title_trim%%</a>: %%link_clicks%%</li>';
+ /* default pattern used to display top links
+ * Any %%tag%% where "tag" can be : link_id, link_url, link_clicks, link_date, link_title, link_title_trim (shortened, see below)
+ * Example : '%%link_title%% (%%link_url%%) = %%link_clicks%%' */
+
+$wp_ozh_click['trim'] = 15;
+ /* default maximum length of link titles
+ * When printing top links titles, trim long link titles output to XX characters (0 not to trim) */
+
+
+
+
+/*************************************
+ * DO NOT EDIT BELOW *
+ * ~~ *
+ *************************************/
+
+//**************************************************************************************************************************
+
+
+// inputs a URL, returns an integer (number of clicks for the URL)
+function wp_ozh_click_getcount ($url = "") {
+ global $wpdb, $wp_ozh_click, $wpblog;
+ $url = str_replace("&amp;", "&", $url);
+ $url = wp_ozh_click_getrealpath($url);
+ return $wpdb->get_var("SELECT link_clicks FROM $wp_ozh_click[table] WHERE blogID='$wpblog' AND link_url='$url'");
+}
+
+
+// inputs a URL, returns text
+function wp_ozh_click_getclicks ($url = '', $zeroclick = '',
+ $oneclick = '', $lotsaclicks = '' ) {
+ $result = wp_ozh_click_getcount ($url);
+ $result = wp_ozh_click_labelize ($result, $zeroclick, $oneclick, $lotsaclicks);
+ $wp_ozh_click['temp'] = "...".$url;
+ return $result;
+}
+
+// inputs a number, returns text like "<number> hits"
+function wp_ozh_click_labelize ($number = 0, $zeroclick = '',
+ $oneclick = '', $lotsaclicks = '' ) {
+ global $wp_ozh_click;
+ if (!$zeroclick) $zeroclick = $wp_ozh_click['0click'];
+ if (!$oneclick) $oneclick = $wp_ozh_click['1click'];
+ if (!$lotsaclicks) $lotsaclicks = $wp_ozh_click['clicks'];
+
+ switch ($number) :
+ case "":
+ return $zeroclick;
+ break;
+ case 1:
+ return $oneclick;
+ break;
+ default:
+ return (str_replace ("%%", $number, $lotsaclicks));
+ endswitch;
+}
+
+
+// parses string to detect and process pairs of tag="value"
+function wp_ozh_click_parse ($html="", $all=0) {
+ global $wp_ozh_click;
+
+ preg_match_all ('/[^=]{1,}="[^"]+"/', $html, $wp_ozh_click['link']);
+ foreach ($wp_ozh_click['link'][0] as $pair) {
+ list ($tag , $value) = explode ("=", $pair , 2);
+ $wp_ozh_click['link'][trim($tag)]=trim($value, '"');
+ }
+ unset ($wp_ozh_click['link'][0]);
+
+ $wp_ozh_click['modify_href'] = 0;
+ // do we want to display clicks ?
+ if ( !isset($wp_ozh_click['link']['count']) || $wp_ozh_click['link']['count'] != "0" ) {
+ if (
+ ( ($all == 1) && (eregi("^[a-z]+://", $wp_ozh_click['link']['href'])) )
+ ||
+ ( isset($wp_ozh_click['link']['count'] ) )
+ ) {
+ $wp_ozh_click['modify_href'] = 1;
+ }
+ }
+
+ if ($wp_ozh_click['modify_href']) {
+ if ( (!isset($wp_ozh_click['link']['count']) && $wp_ozh_click['track_all_links'] && $wp_ozh_click['in_title'] ) || ( $wp_ozh_click['in_title'] && $wp_ozh_click['link']['count']=="1" ) || stristr($wp_ozh_click['link']['count'],'title') ) {
+ if (isset($wp_ozh_click['link']['title'])) {
+ $wp_ozh_click['link']['title']= $wp_ozh_click['link']['title'] . " (" . wp_ozh_click_getclicks($wp_ozh_click['link']['href']) . ")";
+ } else {
+ $wp_ozh_click['link']['title']= "(" . wp_ozh_click_getclicks($wp_ozh_click['link']['href']) . ")";
+ }
+ }
+ if ( (!isset($wp_ozh_click['link']['count']) && $wp_ozh_click['track_all_links'] && $wp_ozh_click['in_plain'] ) || ( $wp_ozh_click['in_plain'] && $wp_ozh_click['link']['count']=="1" ) || stristr($wp_ozh_click['link']['count'],'inline') ) {
+ $wp_ozh_click['after'] = ' <span class="hitcounter">(' . wp_ozh_click_getclicks($wp_ozh_click['link']['href']) . ')</span>' ;
+ }
+
+ switch ($wp_ozh_click['method']) :
+ case 1 :
+ $wp_ozh_click['link']['onclick'] = "window.location='". $wp_ozh_click['file'] . "?" . $wp_ozh_click['link']['href'] . "'; return false";
+ break;
+ case 2 :
+ $wp_ozh_click['link']['href'] = $wp_ozh_click['file'] . "?" . $wp_ozh_click['link']['href'] ;
+ break;
+ case 3 :
+ $wp_ozh_click['link']['onmouseover']="javascript:window.status='". $wp_ozh_click['link']['href'] ."'; return true;" ;
+ $wp_ozh_click['link']['onmouseout']="javascript:window.status=''; return true;" ;
+ $wp_ozh_click['link']['href'] = $wp_ozh_click['file'] . "?" . $wp_ozh_click['link']['href'] ;
+ endswitch;
+
+
+ unset ($wp_ozh_click['link']['count']);
+ }
+
+ $html='';
+ foreach ($wp_ozh_click['link'] as $key => $value) {
+ $html .= $key . "=\"" . $value . "\" ";
+ }
+ $html=trim($html);
+ return '<a '. $html .'>';
+}
+
+// convert relative path ("/blog/dir/file" or "dir/this/file") into absolute (from blog's index.php)
+function wp_ozh_click_getrealpath ($url = "") {
+ $url = preg_replace ("/#.*$/",'',$url);
+
+ if (!eregi("^[a-z]+://", $url)) {
+ if (eregi("^/", $url)) {
+ $url = 'http://' . $_SERVER['HTTP_HOST'] . $url;
+ } else {
+ $url = get_settings('siteurl') . '/' . $url;
+ }
+ }
+ return $url;
+}
+
+
+// increments field link_click for a given URL
+function wp_ozh_click_increment ($url="") {
+ global $wpdb, $wp_ozh_click, $wpblog;
+ $url = wp_ozh_click_getrealpath($url);
+
+ // if (!get_magic_quotes_gpc()) {$url = add_magic_quotes($url);}
+
+ $result = $wpdb->get_var("SELECT link_clicks FROM $wp_ozh_click[table] WHERE blogID='$wpblog' AND link_url='$url'");
+
+ if ($result) {
+ $todo = 'link_clicks=(link_clicks + 1)';
+ if (($wp_ozh_click['get_title_forcerefresh']) && (($result % $wp_ozh_click['get_title_forcerefresh']) == 0)) {
+ $link_title=wp_ozh_click_gettitle($url);
+ if ($link_title) {
+ $todo .= ", link_title='$link_title'";
+ }
+ }
+ $return = $wpdb->query("UPDATE $wp_ozh_click[table] SET $todo WHERE blogID='$wpblog' AND link_url='$url'");
+ } else {
+ $link_date = gmdate('Y-m-d H:i:s', (time() + (get_settings('gmt_offset') * 3600)));
+ if ($wp_ozh_click['get_title']) {
+ $link_title=wp_ozh_click_gettitle($url);
+ } else {
+ $link_title='';
+ }
+ $return = $wpdb->query("INSERT INTO $wp_ozh_click[table] (blogID, link_url, link_clicks, link_date, link_title) VALUES ('$wpblog', '$url', 1, '$link_date', '$link_title')");
+ };
+ return $return;
+}
+
+
+// prints most clicked links
+function wp_ozh_click_topclicks ($limit = '', $trim = '', $pattern = '') {
+ global $wpdb, $wp_ozh_click, $wpblog;
+ if (!$limit) $limit = $wp_ozh_click['top_limit'];
+ if (!$pattern) $pattern = $wp_ozh_click['top_pattern'];
+ if (!$trim) $trim = $wp_ozh_click['trim'];
+
+ $results = $wpdb->get_results("select * from $wp_ozh_click[table] WHERE blogID='$wpblog' ORDER BY link_clicks DESC LIMIT $limit");
+ foreach ($results as $result) {
+ $html = $pattern;
+ $html = preg_replace ( "/%%link_url%%/i", $wp_ozh_click['file'] . "?" . "$result->link_url", $html);
+ $html = preg_replace ( "/%%link_clicks%%/i", wp_ozh_click_labelize($result->link_clicks), $html);
+ $html = preg_replace ( "/%%link_date%%/i", "$result->link_date", $html);
+ if (!$result->link_title) {
+ // prettyfies link_title for display : no "http://www." or trailing "/"
+ $result->link_title = preg_replace("/((ht)*f*tp:\/\/)*(www\.)*/", "", $result->link_url);
+ $result->link_title = preg_replace("/\/$/", "", $result->link_title);
+ }
+ if ($trim && (strlen($result->link_title) > $trim)) {
+ $result->link_title_trim = substr($result->link_title, 0, $trim) . '&#8230';
+ } else {
+ $result->link_title_trim = $result->link_title;
+ }
+ $html = preg_replace ( "/%%link_title_trim%%/i", "$result->link_title_trim", $html);
+ $html = preg_replace ( "/%%link_title%%/i", "$result->link_title", $html);
+ echo $html . "\n";
+ }
+}
+
+
+// prints number of links tracked
+function wp_ozh_click_linkcount ($display=1) {
+ global $wpdb, $wp_ozh_click;
+ if (!$wp_ozh_click['stats']) wp_ozh_click_getstats();
+ if ($display)
+ echo $wp_ozh_click['stats']->linkcount;
+ return $wp_ozh_click['stats']->linkcount;
+}
+
+
+// prints total number of clicks
+function wp_ozh_click_clickcount ($display=1) {
+ global $wpdb, $wp_ozh_click;
+ if (!$wp_ozh_click['stats']) wp_ozh_click_getstats();
+ if ($display)
+ echo $wp_ozh_click['stats']->clickcount;
+ return $wp_ozh_click['stats']->clickcount;
+
+}
+
+
+// retrieves various stats
+function wp_ozh_click_getstats () {
+ global $wpdb, $wp_ozh_click, $wpblog;
+ $wp_ozh_click['stats'] = $wpdb->get_row("SELECT count(*) AS linkcount, sum(link_clicks) AS clickcount FROM $wp_ozh_click[table] WHERE blogID='$wpblog'");
+ //echo $wp_ozh_click['stats']->clickcount;
+ //echo "<hr>";
+ //echo $wp_ozh_click['stats']->linkcount;
+ return $wp_ozh_click['stats'];
+}
+
+// return title of a (local or remote) webpage
+function wp_ozh_click_gettitle ($url = "") {
+ global $wp_ozh_click;
+ eregi("/([^#\?\/]+)\.([a-z0-9]+)$", $url, $file);
+ $ext = $file[2];
+ $file = $file[1];
+ $in_array = in_array($ext, $wp_ozh_click['extensions']);
+ switch ($in_array):
+ case true:
+ return "$file.$ext";
+ break;
+ case false:
+ if (function_exists('fopen')) {
+ $fp = fopen ($url, 'r');
+ while (! feof ($fp)){
+ $webpage .= fgets ($fp, 1024);
+ if (stristr($webpage, '<title>' )){
+ break;
+ }
+ }
+ if (eregi("<title>(.*)</title>", $webpage, $out)) {
+ return addslashes($out[1]);
+ }
+ else{
+ return "";
+ }
+ } else {
+ return "";
+ }
+ break;
+ endswitch;
+}
+
+
+// readme & check install
+function wp_ozh_click_readme() {
+ echo '<html><head>
+ <title>Click Counter Plugin for Wordpress - By Ozh</title>
+ <link rel="stylesheet" href="../../wp-admin/wp-admin.css" type="text/css" />
+ </head>
+ <body>
+ <div id="wphead" style="height: 4.5em">
+ <h1 align="right">Click Counter Plugin - By Ozh</h1>
+ </div>
+ <div class="wrap">
+ <h2>Thanks :)</h2>
+ <p>Thank you for installing this plugin !</p>
+ <h2>About this plugin</h2>
+ <p>This plugin adds a "tracker" to links in your posts and your comments, so that when someone clicks on them, the link\'s hit counter increments. The number of hits can also be displayed in a variety of flavours. You can choose to add a hit counter to all links (default) or only to chosen links</p>
+ <h2>2 steps installation and usage "out of the box"</h2>
+ <ol><li><p>First, create a new table in your WordPress MySQL database, named wp_linkclicks, using for example PHPMyAdmin with the following query :</p>
+ <pre class="updated">
+CREATE TABLE `wp_linkclicks` (
+ `link_id` INT NOT NULL AUTO_INCREMENT ,
+ `link_url` TEXT NOT NULL ,
+ `link_clicks` INT NOT NULL ,
+ `link_date` DATETIME NOT NULL ,
+ `link_title` TEXT NOT NULL ,
+ UNIQUE (
+ `link_id`
+ )
+);</pre></li>
+ <li><p>Then put the plugin file in <strong><em>yourblog</em>/wp-content/plugins/</strong> and <strong>activate it</strong>
+ from the <a href="../../wp-admin/plugins.php">admin interface</a>.</p></li></ol>
+ <p>The plugin should now work silently without further working. Get back to blogging and posting link as usual :)</p>
+ <h2>Optional Configuration</h2>
+ <p>You will find detailed information about how to configure the plugin in its source itself:
+ the section you can configure is well commented. You can do so from within the <a href="../../wp-admin/templates.php?file=wp-content/plugins/wp_ozh_clickcounter.php">admin interface</a> as well.
+ <p>You can also find detailed information and examples of use
+ at the <a href="http://frenchfragfactory.net/ozh/">plugin\'s homepage</a>.</p>
+ <h2>Feedback & Disclaimer</h2>
+ <p>I\'d appreciate your leaving a comment on the plugin page, to suggest any improvement, bug fix, or just to say if you like the plugin or not :)
+ By the way, you\'ll find on <a href="http://frenchfragfactory.net/ozh/archives/category/wordpress/">my site</a> a few other plugins (<a href="http://frenchfragfactory.net/ozh/archives/2004/08/27/ip-to-nation-plugin/">IP to Nation plugin</a> in particular) you may find of interest.</p>
+ <p>Any resemblance between this page and a well-known admin interface is purely coincidental :-P</p>
+ </div>
+ <div id="footer"><p><a href="http://planetOzh.com/"><img src="http://frenchfragfactory.net/ozh/wp-images/btn_planetozh.png" border="0" alt="planetOzh.com" /></a><br />
+ </div>
+ </body></html>
+ ';
+}
+
+// the one that starts it all
+function wp_ozh_click_modifyhrefs ($input) {
+ $input = preg_replace_callback ("/<a ([^>]{1,})>(.+?<\/a>)/", "wp_ozh_click_do_posts", $input);
+ // ** OMFG ** I finally understood what preg_replace_callback is ! :))
+ return $input;
+}
+
+// callback function
+function wp_ozh_click_do_posts($text) {
+ global $wp_ozh_click;
+ unset ($wp_ozh_click['after']);
+
+ $before = wp_ozh_click_parse($text[1],$wp_ozh_click['track_all_links']);
+ $text = $text[2];
+ return $before.$text.$wp_ozh_click['after'];
+}
+
+function wp_ozh_click_comment_author_link() {
+ global $comment;
+ $url = apply_filters('comment_url', $comment->comment_author_url);
+ $author = apply_filters('comment_author', $comment->comment_author);
+ if (!$author) $author = 'Anonymous';
+
+ if (empty($url)) :
+ echo $author;
+ else:
+ echo wp_ozh_click_modifyhrefs("<a href=\"$url\" rel=\"external\">$author</a>");
+ endif;
+}
+
+
+// Add per-post filtering:
+if ($wp_ozh_click['do_posts'])
+ add_filter('the_content', 'wp_ozh_click_modifyhrefs');
+if ($wp_ozh_click['do_comments'])
+ add_filter('comment_text', 'wp_ozh_click_modifyhrefs');
+
+
+// And that's it.
+
+
+/* Future enhancements ?
+ - handle malformed html tags like <a href=http://site.com count=1>site</a> (no "quotes")
+*/
+
+
+/* Example post :
+ Post this in your blog and watch how modifying the script configuration affects display of counters.
+
+--8<-----8<-----[cut & paste]-
+<strong>Tests with external links : href="http://external-link.com" </strong>
+<a href="http://external-link.com" count="0">count="0"</a> never shows click count
+<a href="http://external-link.com" count="1">count="1"</a> shows click count according to defaults as set in the plugin
+<a href="http://external-link.com" count="title">count="title"</a> always shows a count in link title (mouseover)
+<a href="http://external-link.com" count="inline">count="inline"</a> always shows a count next to title in plain text
+<a href="http://external-link.com" count="inline title">count="inline title"</a> always shows both
+<a href="http://external-link.com">count not specified</a> shows or not depending on defaults as set in the plugin (tracking all links or not)
+
+<strong>Tests with internal links : href="/local_dir/file"</strong>
+<a href="/local_dir/file" count="0">count="0"</a> never shows click count
+<a href="/local_dir/file" count="1">count="1"</a> always shows click count, according to defaults
+<a href="/local_dir/file" count="title">count="title"</a> always shows click count in link title
+<a href="/local_dir/file" count="inline">count="inline"</a> always shows click count next to title in plain text
+<a href="/local_dir/file" count="inline title">count="inline title"</a> always shows both
+<a href="/local_dir/file">count not specified</a> never shows click count
+--8<-----8<-----[cut & paste]-
+
+*/
+
+?>
diff --git a/wp-inst/wp-content/smarty-templates/blogroll.tpl b/wp-inst/wp-content/smarty-templates/blogroll.tpl
new file mode 100644
index 0000000..0cde746
--- /dev/null
+++ b/wp-inst/wp-content/smarty-templates/blogroll.tpl
@@ -0,0 +1,3 @@
+{foreach from=$links item=link}
+ <a href="{$link.url}">{$link.name}</a><br />
+{/foreach}
diff --git a/wp-inst/wp-content/smarty-templates/noblogroll.tpl b/wp-inst/wp-content/smarty-templates/noblogroll.tpl
new file mode 100644
index 0000000..c3f00e7
--- /dev/null
+++ b/wp-inst/wp-content/smarty-templates/noblogroll.tpl
@@ -0,0 +1 @@
+<div style='padding: 2px; border: 1px dashed #000'> <b>blo.gs favourites!</b><br><a href="http://blo.gs/signup.php">Signup</a> on <a href="http://blo.gs/">blo.gs</a> to track your favourite blogs on this site! Fill in your blogID and a teststring in your blog template!</div>
diff --git a/wp-inst/wp-content/themes/classic/comments-popup.php b/wp-inst/wp-content/themes/classic/comments-popup.php
new file mode 100644
index 0000000..4d22c93
--- /dev/null
+++ b/wp-inst/wp-content/themes/classic/comments-popup.php
@@ -0,0 +1,113 @@
+<?php
+/* Don't remove these lines. */
+add_filter('comment_text', 'popuplinks');
+foreach ($posts as $post) { start_wp();
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title><?php echo get_settings('blogname'); ?> - <?php echo sprintf(__("Comments on %s"), the_title('','',false)); ?></title>
+
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
+ <style type="text/css" media="screen">
+ @import url( <?php bloginfo('stylesheet_url'); ?> );
+ body { margin: 3px; }
+ </style>
+
+</head>
+<body id="commentspopup">
+
+<h1 id="header"><a href="" title="<?php echo get_settings('blogname'); ?>"><?php echo get_settings('blogname'); ?></a></h1>
+
+<h2 id="comments"><?php _e("Comments"); ?></h2>
+
+<p><a href="<?php echo get_settings('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><?php _e("<abbr title=\"Really Simple Syndication\">RSS</abbr> feed for comments on this post."); ?></a></p>
+
+<?php if ('open' == $post->ping_status) { ?>
+<p><?php _e("The <acronym title=\"Uniform Resource Identifier\">URI</acronym> to TrackBack this entry is:"); ?> <em><?php trackback_url() ?></em></p>
+<?php } ?>
+
+<?php
+// this line is WordPress' motor, do not delete it.
+$comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
+$comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
+$comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
+$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date");
+$commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $wpdb->posts WHERE ID = $id");
+if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) { // and it doesn't match the cookie
+ echo(get_the_password_form());
+} else { ?>
+
+<?php if ($comments) { ?>
+<ol id="commentlist">
+<?php foreach ($comments as $comment) { ?>
+ <li id="comment-<?php comment_ID() ?>">
+ <?php comment_text() ?>
+ <p><cite><?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?> <?php _e("by"); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
+ </li>
+
+<?php } // end for each comment ?>
+</ol>
+<?php } else { // this is displayed if there are no comments so far ?>
+ <p><?php _e("No comments yet."); ?></p>
+<?php } ?>
+
+<?php if ('open' == $commentstatus->comment_status) { ?>
+<h2><?php _e("Leave a comment"); ?></h2>
+<p><?php _e("Line and paragraph breaks automatic, e-mail address never displayed, <acronym title=\"Hypertext Markup Language\">HTML</acronym> allowed:"); ?> <code><?php echo allowed_tags(); ?></code></p>
+
+<form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
+ <p>
+ <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" />
+ <label for="author"><?php _e("Name"); ?></label>
+ <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
+ <input type="hidden" name="redirect_to" value="<?php echo wp_specialchars($_SERVER["REQUEST_URI"]); ?>" />
+ </p>
+
+ <p>
+ <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="28" tabindex="2" />
+ <label for="email"><?php _e("E-mail"); ?></label>
+ </p>
+
+ <p>
+ <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" />
+ <label for="url"><?php _e("<acronym title=\"Uniform Resource Identifier\">URI</acronym>"); ?></label>
+ </p>
+
+ <p>
+ <label for="comment"><?php _e("Your Comment"); ?></label>
+ <br />
+ <textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
+ </p>
+
+ <p>
+ <input name="submit" type="submit" tabindex="5" value="<?php _e("Say It!"); ?>" />
+ </p>
+ <?php do_action('comment_form', $post->ID); ?>
+</form>
+<?php } else { // comments are closed ?>
+<p><?php _e("Sorry, the comment form is closed at this time."); ?></p>
+<?php }
+} // end password check
+?>
+
+<div><strong><a href="javascript:window.close()"><?php _e("Close this window."); ?></a></strong></div>
+
+<?php // if you delete this the sky will fall on your head
+}
+?>
+
+<!-- // this is just the end of the motor - don't touch that line either :) -->
+<?php //} ?>
+<p class="credit"><?php timer_stop(1); ?> <?php echo sprintf(__("<cite>Powered by <a href=\"http://wordpress.org\" title=\"%s\"><strong>Wordpress</strong></a></cite>"),__("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?></p>
+<?php // Seen at http://www.mijnkopthee.nl/log2/archive/2003/05/28/esc(18) ?>
+<script type="text/javascript">
+<!--
+document.onkeypress = function esc(e) {
+ if(typeof(e) == "undefined") { e=event; }
+ if (e.keyCode == 27) { self.close(); }
+}
+// -->
+</script>
+</body>
+</html>
diff --git a/wp-inst/wp-content/themes/classic/comments.php b/wp-inst/wp-content/themes/classic/comments.php
new file mode 100644
index 0000000..6222f1a
--- /dev/null
+++ b/wp-inst/wp-content/themes/classic/comments.php
@@ -0,0 +1,75 @@
+<?php if ( !empty($post->post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) : ?>
+<p><?php _e('Enter your password to view comments.'); ?></p>
+<?php return; endif; ?>
+
+<h2 id="comments"><?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments')); ?>
+<?php if ( comments_open() ) : ?>
+ <a href="#postcomment" title="<?php _e("Leave a comment"); ?>">&raquo;</a>
+<?php endif; ?>
+</h2>
+
+<?php if ( $comments ) : ?>
+<ol id="commentlist">
+
+<?php foreach ($comments as $comment) : ?>
+ <li id="comment-<?php comment_ID() ?>">
+ <?php comment_text() ?>
+ <p><cite><?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
+ </li>
+
+<?php endforeach; ?>
+
+</ol>
+
+<?php else : // If there are no comments yet ?>
+ <p><?php _e('No comments yet.'); ?></p>
+<?php endif; ?>
+
+<p><?php comments_rss_link(__('<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.')); ?>
+<?php if ( pings_open() ) : ?>
+ <a href="<?php trackback_url() ?>" rel="trackback"><?php _e('TrackBack <abbr title="Uniform Resource Identifier">URI</abbr>'); ?></a>
+<?php endif; ?>
+</p>
+
+<?php if ( comments_open() ) : ?>
+<h2 id="postcomment"><?php _e('Leave a comment'); ?></h2>
+
+<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
+<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">logged in</a> to post a comment.</p>
+<?php else : ?>
+
+<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
+
+<?php if ( $user_ID ) : ?>
+
+<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>">Logout &raquo;</a></p>
+
+<?php else : ?>
+
+<p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
+<label for="author"><small>Name <?php if ($req) _e('(required)'); ?></small></label></p>
+
+<p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
+<label for="email"><small>Mail (will not be published) <?php if ($req) _e('(required)'); ?></small></label></p>
+
+<p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
+<label for="url"><small>Website</small></label></p>
+
+<?php endif; ?>
+
+<!--<p><small><strong>XHTML:</strong> You can use these tags: <?php echo allowed_tags(); ?></small></p>-->
+
+<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
+
+<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
+<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
+</p>
+<?php do_action('comment_form', $post->ID); ?>
+
+</form>
+
+<?php endif; // If registration required and not logged in ?>
+
+<?php else : // Comments are closed ?>
+<p><?php _e('Sorry, the comment form is closed at this time.'); ?></p>
+<?php endif; ?>
diff --git a/wp-inst/wp-content/themes/classic/footer.php b/wp-inst/wp-content/themes/classic/footer.php
new file mode 100644
index 0000000..b18b022
--- /dev/null
+++ b/wp-inst/wp-content/themes/classic/footer.php
@@ -0,0 +1,12 @@
+<!-- begin footer -->
+</div>
+
+<?php get_sidebar(); ?>
+
+<p class="credit"><!--<?php echo $wpdb->num_queries; ?> queries. <?php timer_stop(1); ?> seconds. --> <cite><?php echo sprintf(__("Powered by <a href='http://wordpress.org' title='%s'><strong>WordPress</strong></a>"), __("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?></cite></p>
+
+</div>
+
+<?php wp_footer(); ?>
+</body>
+</html> \ No newline at end of file
diff --git a/wp-inst/wp-content/themes/classic/header.php b/wp-inst/wp-content/themes/classic/header.php
new file mode 100644
index 0000000..2c1d7c4
--- /dev/null
+++ b/wp-inst/wp-content/themes/classic/header.php
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head profile="http://gmpg.org/xfn/11">
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
+
+ <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
+
+ <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats please -->
+
+ <style type="text/css" media="screen">
+ @import url( <?php bloginfo('stylesheet_url'); ?> );
+ </style>
+
+ <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
+ <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
+ <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
+
+ <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
+ <?php wp_get_archives('type=monthly&format=link'); ?>
+ <?php //comments_popup_script(); // off by default ?>
+ <?php wp_head(); ?>
+</head>
+
+<body>
+<div id="rap">
+<h1 id="header"><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
+
+<div id="content">
+<!-- end header --> \ No newline at end of file
diff --git a/wp-inst/wp-content/themes/classic/index.php b/wp-inst/wp-content/themes/classic/index.php
new file mode 100644
index 0000000..bbee16e
--- /dev/null
+++ b/wp-inst/wp-content/themes/classic/index.php
@@ -0,0 +1,32 @@
+<?php
+get_header();
+?>
+
+<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
+
+<?php the_date('','<h2>','</h2>'); ?>
+
+<div class="post" id="post-<?php the_ID(); ?>">
+ <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
+ <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> &#8212; <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
+
+ <div class="storycontent">
+ <?php the_content(__('(more...)')); ?>
+ </div>
+
+ <div class="feedback">
+ <?php wp_link_pages(); ?>
+ <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
+ </div>
+
+</div>
+
+<?php comments_template(); // Get wp-comments.php template ?>
+
+<?php endwhile; else: ?>
+<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
+<?php endif; ?>
+
+<?php posts_nav_link(' &#8212; ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?>
+
+<?php get_footer(); ?>
diff --git a/wp-inst/wp-content/themes/classic/sidebar.php b/wp-inst/wp-content/themes/classic/sidebar.php
new file mode 100644
index 0000000..46dee78
--- /dev/null
+++ b/wp-inst/wp-content/themes/classic/sidebar.php
@@ -0,0 +1,43 @@
+
+<!-- begin sidebar -->
+<div id="menu">
+
+<ul>
+ <?php wp_list_pages(); ?>
+ <?php get_links_list(); ?>
+ <li id="categories"><?php _e('Categories:'); ?>
+ <ul>
+ <?php wp_list_cats(); ?>
+ </ul>
+ </li>
+ <li id="search">
+ <label for="s"><?php _e('Search:'); ?></label>
+ <form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+ <div>
+ <input type="text" name="s" id="s" size="15" /><br />
+ <input type="submit" value="<?php _e('Search'); ?>" />
+ </div>
+ </form>
+ </li>
+ <li id="archives"><?php _e('Archives:'); ?>
+ <ul>
+ <?php wp_get_archives('type=monthly'); ?>
+ </ul>
+ </li>
+ <li id="meta"><?php _e('Meta:'); ?>
+ <ul>
+ <?php wp_register(); ?>
+ <li><?php wp_loginout(); ?></li>
+ <li><a href="feed:<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
+ <li><a href="feed:<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
+ <li><a href="http://validator.w3.org/check/referer" title="<?php _e('This page validates as XHTML 1.0 Transitional'); ?>"><?php _e('Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr>'); ?></a></li>
+ <li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>
+ <li><a href="http://wordpress.org/" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.'); ?>"><abbr title="WordPress">WP</abbr></a></li>
+ <?php wp_meta(); ?>
+ </ul>
+ </li>
+
+</ul>
+
+</div>
+<!-- end sidebar -->
diff --git a/wp-inst/wp-content/themes/classic/style.css b/wp-inst/wp-content/themes/classic/style.css
new file mode 100644
index 0000000..e09122d
--- /dev/null
+++ b/wp-inst/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-inst/wp-content/themes/default/404.php b/wp-inst/wp-content/themes/default/404.php
new file mode 100644
index 0000000..01a8e8a
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/404.php
@@ -0,0 +1,11 @@
+<?php get_header(); ?>
+
+ <div id="content" class="narrowcolumn">
+
+ <h2 class="center">Error 404 - Not Found</h2>
+
+ </div>
+
+<?php get_sidebar(); ?>
+
+<?php get_footer(); ?> \ No newline at end of file
diff --git a/wp-inst/wp-content/themes/default/archive.php b/wp-inst/wp-content/themes/default/archive.php
new file mode 100644
index 0000000..f6281db
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/archive.php
@@ -0,0 +1,68 @@
+<?php get_header(); ?>
+
+ <div id="content" class="narrowcolumn">
+
+ <?php if (have_posts()) : ?>
+
+ <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
+<?php /* If this is a category archive */ if (is_category()) { ?>
+ <h2 class="pagetitle">Archive for the '<?php echo single_cat_title(); ?>' Category</h2>
+
+ <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
+ <h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
+
+ <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
+ <h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
+
+ <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
+ <h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
+
+ <?php /* If this is a search */ } elseif (is_search()) { ?>
+ <h2 class="pagetitle">Search Results</h2>
+
+ <?php /* If this is an author archive */ } elseif (is_author()) { ?>
+ <h2 class="pagetitle">Author Archive</h2>
+
+ <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
+ <h2 class="pagetitle">Blog Archives</h2>
+
+ <?php } ?>
+
+
+ <div class="navigation">
+ <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
+ <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
+ </div>
+
+ <?php while (have_posts()) : the_post(); ?>
+ <div class="post">
+ <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
+ <small><?php the_time('l, F jS, Y') ?></small>
+
+ <div class="entry">
+ <?php the_excerpt() ?>
+ </div>
+
+ <p class="postmetadata">Posted in <?php the_category(', ') ?> <strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
+
+ </div>
+
+ <?php endwhile; ?>
+
+ <div class="navigation">
+ <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
+ <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
+ </div>
+
+ <?php else : ?>
+
+ <h2 class="center">Not Found</h2>
+ <?php include (TEMPLATEPATH . '/searchform.php'); ?>
+
+ <?php endif; ?>
+
+ </div>
+
+<?php get_sidebar(); ?>
+
+<?php get_footer(); ?> \ No newline at end of file
diff --git a/wp-inst/wp-content/themes/default/archives.php b/wp-inst/wp-content/themes/default/archives.php
new file mode 100644
index 0000000..ae9d8dd
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/archives.php
@@ -0,0 +1,25 @@
+<?php
+/*
+Template Name: Archives
+*/
+?>
+
+<?php get_header(); ?>
+
+<div id="content" class="widecolumn">
+
+<?php include (TEMPLATEPATH . '/searchform.php'); ?>
+
+<h2>Archives by Month:</h2>
+ <ul>
+ <?php wp_get_archives('type=monthly'); ?>
+ </ul>
+
+<h2>Archives by Subject:</h2>
+ <ul>
+ <?php wp_list_cats(); ?>
+ </ul>
+
+</div>
+
+<?php get_footer(); ?>
diff --git a/wp-inst/wp-content/themes/default/comments-popup.php b/wp-inst/wp-content/themes/default/comments-popup.php
new file mode 100644
index 0000000..f01e3eb
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/comments-popup.php
@@ -0,0 +1,113 @@
+<?php
+/* Don't remove these lines. */
+add_filter('comment_text', 'popuplinks');
+foreach ($posts as $post) { start_wp();
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title><?php echo get_settings('blogname'); ?> - Comments on <?php the_title(); ?></title>
+
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
+ <style type="text/css" media="screen">
+ @import url( <?php bloginfo('stylesheet_url'); ?> );
+ body { margin: 3px; }
+ </style>
+
+</head>
+<body id="commentspopup">
+
+<h1 id="header"><a href="" title="<?php echo get_settings('blogname'); ?>"><?php echo get_settings('blogname'); ?></a></h1>
+
+<h2 id="comments">Comments</h2>
+
+<p><a href="<?php echo get_settings('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.</a></p>
+
+<?php if ('open' == $post->ping_status) { ?>
+<p>The <acronym title="Uniform Resource Identifier">URI</acronym> to TrackBack this entry is: <em><?php trackback_url() ?></em></p>
+<?php } ?>
+
+<?php
+// this line is WordPress' motor, do not delete it.
+$comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
+$comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
+$comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
+$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date");
+$commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $wpdb->posts WHERE ID = $id");
+if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) { // and it doesn't match the cookie
+ echo(get_the_password_form());
+} else { ?>
+
+<?php if ($comments) { ?>
+<ol id="commentlist">
+<?php foreach ($comments as $comment) { ?>
+ <li id="comment-<?php comment_ID() ?>">
+ <?php comment_text() ?>
+ <p><cite><?php comment_type('Comment', 'Trackback', 'Pingback'); ?> by <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
+ </li>
+
+<?php } // end for each comment ?>
+</ol>
+<?php } else { // this is displayed if there are no comments so far ?>
+ <p>No comments yet.</p>
+<?php } ?>
+
+<?php if ('open' == $commentstatus->comment_status) { ?>
+<h2>Leave a comment</h2>
+<p>Line and paragraph breaks automatic, e-mail address never displayed, <acronym title="Hypertext Markup Language">HTML</acronym> allowed: <code><?php echo allowed_tags(); ?></code></p>
+
+<form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
+ <p>
+ <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" />
+ <label for="author">Name</label>
+ <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
+ <input type="hidden" name="redirect_to" value="<?php echo wp_specialchars($_SERVER["REQUEST_URI"]); ?>" />
+ </p>
+
+ <p>
+ <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="28" tabindex="2" />
+ <label for="email">E-mail</label>
+ </p>
+
+ <p>
+ <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" />
+ <label for="url"><acronym title="Uniform Resource Identifier">URI</acronym></label>
+ </p>
+
+ <p>
+ <label for="comment">Your Comment</label>
+ <br />
+ <textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
+ </p>
+
+ <p>
+ <input name="submit" type="submit" tabindex="5" value="Say It!" />
+ </p>
+ <?php do_action('comment_form', $post->ID); ?>
+</form>
+<?php } else { // comments are closed ?>
+<p>Sorry, the comment form is closed at this time.</p>
+<?php }
+} // end password check
+?>
+
+<div><strong><a href="javascript:window.close()">Close this window.</a></strong></div>
+
+<?php // if you delete this the sky will fall on your head
+}
+?>
+
+<!-- // this is just the end of the motor - don't touch that line either :) -->
+<?php //} ?>
+<p class="credit"><?php timer_stop(1); ?> <cite>Powered by <a href="http://wordpress.org" title="Powered by WordPress, state-of-the-art semantic personal publishing platform"><strong>Wordpress</strong></a></cite></p>
+<?php // Seen at http://www.mijnkopthee.nl/log2/archive/2003/05/28/esc(18) ?>
+<script type="text/javascript">
+<!--
+document.onkeypress = function esc(e) {
+ if(typeof(e) == "undefined") { e=event; }
+ if (e.keyCode == 27) { self.close(); }
+}
+// -->
+</script>
+</body>
+</html>
diff --git a/wp-inst/wp-content/themes/default/comments.php b/wp-inst/wp-content/themes/default/comments.php
new file mode 100644
index 0000000..dff40d8
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/comments.php
@@ -0,0 +1,104 @@
+<?php // Do not delete these lines
+ if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
+ die ('Please do not load this page directly. Thanks!');
+
+ 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
+ ?>
+
+ <p class="nocomments">This post is password protected. Enter the password to view comments.<p>
+
+ <?php
+ return;
+ }
+ }
+
+ /* This variable is for alternating comment background */
+ $oddcomment = 'alt';
+?>
+
+<!-- You can start editing here. -->
+
+<?php if ($comments) : ?>
+ <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h3>
+
+ <ol class="commentlist">
+
+ <?php foreach ($comments as $comment) : ?>
+
+ <li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
+ <cite><?php comment_author_link() ?></cite> Says:
+ <?php if ($comment->comment_approved == '0') : ?>
+ <em>Your comment is awaiting moderation.</em>
+ <?php endif; ?>
+ <br />
+
+ <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php edit_comment_link('e','',''); ?></small>
+
+ <?php comment_text() ?>
+
+ </li>
+
+ <?php /* Changes every other comment to a different class */
+ if ('alt' == $oddcomment) $oddcomment = '';
+ else $oddcomment = 'alt';
+ ?>
+
+ <?php endforeach; /* end for each comment */ ?>
+
+ </ol>
+
+ <?php else : // this is displayed if there are no comments so far ?>
+
+ <?php if ('open' == $post->comment_status) : ?>
+ <!-- If comments are open, but there are no comments. -->
+
+ <?php else : // comments are closed ?>
+ <!-- If comments are closed. -->
+ <p class="nocomments">Comments are closed.</p>
+
+ <?php endif; ?>
+<?php endif; ?>
+
+
+<?php if ('open' == $post->comment_status) : ?>
+
+<h3 id="respond">Leave a Reply</h3>
+
+<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
+<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">logged in</a> to post a comment.</p>
+<?php else : ?>
+
+<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
+
+<?php if ( $user_ID ) : ?>
+
+<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Logout &raquo;</a></p>
+
+<?php else : ?>
+
+<p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
+<label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
+
+<p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
+<label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>
+
+<p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
+<label for="url"><small>Website</small></label></p>
+
+<?php endif; ?>
+
+<!--<p><small><strong>XHTML:</strong> You can use these tags: <?php echo allowed_tags(); ?></small></p>-->
+
+<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
+
+<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
+<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
+</p>
+<?php do_action('comment_form', $post->ID); ?>
+
+</form>
+
+<?php endif; // If registration required and not logged in ?>
+
+<?php endif; // if you delete this the sky will fall on your head ?>
diff --git a/wp-inst/wp-content/themes/default/footer.php b/wp-inst/wp-content/themes/default/footer.php
new file mode 100644
index 0000000..9ee08e2
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/footer.php
@@ -0,0 +1,20 @@
+
+<hr />
+<div id="footer">
+ <p>
+ <?php bloginfo('name'); ?> is proudly powered by
+ <a href="http://wordpress.org">WordPress</a>
+ <br /><a href="feed:<?php bloginfo('rss2_url'); ?>">Entries (RSS)</a>
+ and <a href="feed:<?php bloginfo('comments_rss2_url'); ?>">Comments (RSS)</a>.
+ <!-- <?php echo $wpdb->num_queries; ?> queries. <?php timer_stop(1); ?> seconds. -->
+ </p>
+</div>
+</div>
+
+<!-- Gorgeous design by Michael Heilemann - http://binarybonsai.com/kubrick/ -->
+<?php /* "Just what do you think you're doing Dave?" */ ?>
+
+ <?php wp_footer(); ?>
+
+</body>
+</html> \ No newline at end of file
diff --git a/wp-inst/wp-content/themes/default/header.php b/wp-inst/wp-content/themes/default/header.php
new file mode 100644
index 0000000..99ff334
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/header.php
@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head profile="http://gmpg.org/xfn/11">
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
+
+<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>
+
+<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
+
+<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
+<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
+<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
+<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
+<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
+
+<style type="text/css" media="screen">
+/* To accomodate differing install paths of WordPress, images are referred only here,
+ and not in the wp-layout.css file. If you prefer to use only CSS for colors and what
+ not, then go right ahead and delete the following lines, and the image files. */
+
+ body { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgcolor.jpg"); }
+<?php /* Checks to see whether it needs a sidebar or not */ if ((! $withcomments) && (! is_single())) { ?>
+ #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg.jpg") repeat-y top; border: none; }
+<?php } else { // No sidebar ?>
+ #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; }
+<?php } ?>
+ #header { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickheader.jpg") no-repeat bottom center; }
+ #footer { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickfooter.jpg") no-repeat bottom; border: none;}
+
+/* Because the template is slightly different, size-wise, with images, this needs to be set here
+ If you don't want to use the template's images, you can also delete the following two lines. */
+
+ #header { margin: 0 !important; margin: 0 0 0 1px; padding: 1px; height: 198px; width: 758px; }
+ #headerimg { margin: 7px 9px 0; height: 192px; width: 740px; }
+
+/* To ease the insertion of a personal header image, I have done it in such a way,
+ that you simply drop in an image called 'personalheader.jpg' into your /images/
+ directory. Dimensions should be at least 760px x 200px. Anything above that will
+ get cropped off of the image. */
+ /*
+ #headerimg { background: url('<?php bloginfo('stylesheet_directory'); ?>/images/personalheader.jpg') no-repeat top;}
+ */
+</style>
+
+<?php wp_get_archives('type=monthly&format=link'); ?>
+
+<?php wp_head(); ?>
+</head>
+<body>
+
+<div id="page">
+
+
+<div id="header">
+ <div id="headerimg">
+ <h1><a href="<?php echo get_settings('home'); ?>"><?php bloginfo('name'); ?></a></h1>
+ <div class="description"><?php bloginfo('description'); ?></div>
+ </div>
+</div>
+<hr />
diff --git a/wp-inst/wp-content/themes/default/images/kubrickbg.jpg b/wp-inst/wp-content/themes/default/images/kubrickbg.jpg
new file mode 100644
index 0000000..dc74fb8
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/images/kubrickbg.jpg
Binary files differ
diff --git a/wp-inst/wp-content/themes/default/images/kubrickbgcolor.jpg b/wp-inst/wp-content/themes/default/images/kubrickbgcolor.jpg
new file mode 100644
index 0000000..4653b68
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/images/kubrickbgcolor.jpg
Binary files differ
diff --git a/wp-inst/wp-content/themes/default/images/kubrickbgwide.jpg b/wp-inst/wp-content/themes/default/images/kubrickbgwide.jpg
new file mode 100644
index 0000000..77096f2
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/images/kubrickbgwide.jpg
Binary files differ
diff --git a/wp-inst/wp-content/themes/default/images/kubrickfooter.jpg b/wp-inst/wp-content/themes/default/images/kubrickfooter.jpg
new file mode 100644
index 0000000..d7a4c65
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/images/kubrickfooter.jpg
Binary files differ
diff --git a/wp-inst/wp-content/themes/default/images/kubrickheader.jpg b/wp-inst/wp-content/themes/default/images/kubrickheader.jpg
new file mode 100644
index 0000000..69441ee
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/images/kubrickheader.jpg
Binary files differ
diff --git a/wp-inst/wp-content/themes/default/index.php b/wp-inst/wp-content/themes/default/index.php
new file mode 100644
index 0000000..0e76687
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/index.php
@@ -0,0 +1,39 @@
+<?php get_header(); ?>
+
+ <div id="content" class="narrowcolumn">
+
+ <?php if (have_posts()) : ?>
+
+ <?php while (have_posts()) : the_post(); ?>
+
+ <div class="post" id="post-<?php the_ID(); ?>">
+ <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
+ <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
+
+ <div class="entry">
+ <?php the_content('Read the rest of this entry &raquo;'); ?>
+ </div>
+
+ <p class="postmetadata">Posted in <?php the_category(', ') ?> <strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
+ </div>
+
+ <?php endwhile; ?>
+
+ <div class="navigation">
+ <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
+ <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
+ </div>
+
+ <?php else : ?>
+
+ <h2 class="center">Not Found</h2>
+ <p class="center">Sorry, but you are looking for something that isn't here.</p>
+ <?php include (TEMPLATEPATH . "/searchform.php"); ?>
+
+ <?php endif; ?>
+
+ </div>
+
+<?php get_sidebar(); ?>
+
+<?php get_footer(); ?>
diff --git a/wp-inst/wp-content/themes/default/links.php b/wp-inst/wp-content/themes/default/links.php
new file mode 100644
index 0000000..2970897
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/links.php
@@ -0,0 +1,18 @@
+<?php
+/*
+Template Name: Links
+*/
+?>
+
+<?php get_header(); ?>
+
+<div id="content" class="widecolumn">
+
+<h2>Links:</h2>
+<ul>
+<?php get_links_list(); ?>
+</ul>
+
+</div>
+
+<?php get_footer(); ?>
diff --git a/wp-inst/wp-content/themes/default/page.php b/wp-inst/wp-content/themes/default/page.php
new file mode 100644
index 0000000..5f914c1
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/page.php
@@ -0,0 +1,21 @@
+<?php get_header(); ?>
+
+ <div id="content" class="narrowcolumn">
+
+ <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
+ <div class="post" id="post-<?php the_ID(); ?>">
+ <h2><?php the_title(); ?></h2>
+ <div class="entrytext">
+ <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
+
+ <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
+
+ </div>
+ </div>
+ <?php endwhile; endif; ?>
+ <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
+ </div>
+
+<?php get_sidebar(); ?>
+
+<?php get_footer(); ?> \ No newline at end of file
diff --git a/wp-inst/wp-content/themes/default/search.php b/wp-inst/wp-content/themes/default/search.php
new file mode 100644
index 0000000..602a19d
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/search.php
@@ -0,0 +1,46 @@
+<?php get_header(); ?>
+
+ <div id="content" class="narrowcolumn">
+
+ <?php if (have_posts()) : ?>
+
+ <h2 class="pagetitle">Search Results</h2>
+
+ <div class="navigation">
+ <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
+ <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
+ </div>
+
+
+ <?php while (have_posts()) : the_post(); ?>
+
+ <div class="post">
+ <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
+ <small><?php the_time('l, F jS, Y') ?></small>
+
+ <div class="entry">
+ <?php the_excerpt() ?>
+ </div>
+
+ <p class="postmetadata">Posted in <?php the_category(', ') ?> <strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
+ </div>
+
+ <?php endwhile; ?>
+
+ <div class="navigation">
+ <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
+ <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
+ </div>
+
+ <?php else : ?>
+
+ <h2 class="center">Not Found</h2>
+ <?php include (TEMPLATEPATH . '/searchform.php'); ?>
+
+ <?php endif; ?>
+
+ </div>
+
+<?php get_sidebar(); ?>
+
+<?php get_footer(); ?> \ No newline at end of file
diff --git a/wp-inst/wp-content/themes/default/searchform.php b/wp-inst/wp-content/themes/default/searchform.php
new file mode 100644
index 0000000..340a34b
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/searchform.php
@@ -0,0 +1,5 @@
+<form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+<div><input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
+<input type="submit" id="searchsubmit" value="Search" />
+</div>
+</form> \ No newline at end of file
diff --git a/wp-inst/wp-content/themes/default/sidebar.php b/wp-inst/wp-content/themes/default/sidebar.php
new file mode 100644
index 0000000..e74ecf7
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/sidebar.php
@@ -0,0 +1,72 @@
+ <div id="sidebar">
+ <ul>
+
+ <li>
+ <?php include (TEMPLATEPATH . '/searchform.php'); ?>
+ </li>
+
+ <!-- Author information is disabled per default. Uncomment and fill in your details if you want to use it.
+ <li><h2>Author</h2>
+ <p>A little something about you, the author. Nothing lengthy, just an overview.</p>
+ </li>
+ -->
+
+ <li>
+ <?php /* If this is a 404 page */ if (is_404()) { ?>
+ <?php /* If this is a category archive */ } elseif (is_category()) { ?>
+ <p>You are currently browsing the archives for the <?php single_cat_title(''); ?> category.</p>
+
+ <?php /* If this is a yearly archive */ } elseif (is_day()) { ?>
+ <p>You are currently browsing the <a href="<?php echo get_settings('siteurl'); ?>"><?php echo bloginfo('name'); ?></a> weblog archives
+ for the day <?php the_time('l, F jS, Y'); ?>.</p>
+
+ <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
+ <p>You are currently browsing the <a href="<?php echo get_settings('siteurl'); ?>"><?php echo bloginfo('name'); ?></a> weblog archives
+ for <?php the_time('F, Y'); ?>.</p>
+
+ <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
+ <p>You are currently browsing the <a href="<?php echo get_settings('siteurl'); ?>"><?php echo bloginfo('name'); ?></a> weblog archives
+ for the year <?php the_time('Y'); ?>.</p>
+
+ <?php /* If this is a monthly archive */ } elseif (is_search()) { ?>
+ <p>You have searched the <a href="<?php echo get_settings('siteurl'); ?>"><?php echo bloginfo('name'); ?></a> weblog archives
+ for <strong>'<?php echo wp_specialchars($s); ?>'</strong>. If you are unable to find anything in these search results, you can try one of these links.</p>
+
+ <?php /* If this is a monthly archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
+ <p>You are currently browsing the <a href="<?php echo get_settings('siteurl'); ?>"><?php echo bloginfo('name'); ?></a> weblog archives.</p>
+
+ <?php } ?>
+ </li>
+
+ <?php wp_list_pages('title_li=<h2>Pages</h2>' ); ?>
+
+ <li><h2>Archives</h2>
+ <ul>
+ <?php wp_get_archives('type=monthly'); ?>
+ </ul>
+ </li>
+
+ <li><h2>Categories</h2>
+ <ul>
+ <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
+ </ul>
+ </li>
+
+ <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>
+ <?php get_links_list(); ?>
+
+ <li><h2>Meta</h2>
+ <ul>
+ <?php wp_register(); ?>
+ <li><?php wp_loginout(); ?></li>
+ <li><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a></li>
+ <li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>
+ <li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>
+ <?php wp_meta(); ?>
+ </ul>
+ </li>
+ <?php } ?>
+
+ </ul>
+ </div>
+
diff --git a/wp-inst/wp-content/themes/default/single.php b/wp-inst/wp-content/themes/default/single.php
new file mode 100644
index 0000000..1130d2f
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/single.php
@@ -0,0 +1,65 @@
+<?php get_header(); ?>
+
+ <div id="content" class="widecolumn">
+
+ <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
+
+ <div class="navigation">
+ <div class="alignleft"><?php previous_post_link('&laquo; %link') ?></div>
+ <div class="alignright"><?php next_post_link('%link &raquo;') ?></div>
+ </div>
+
+ <div class="post" id="post-<?php the_ID(); ?>">
+ <h2><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
+
+ <div class="entrytext">
+ <?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
+
+ <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
+
+ <p class="postmetadata alt">
+ <small>
+ This entry was posted
+ <?php /* This is commented, because it requires a little adjusting sometimes.
+ You'll need to download this plugin, and follow the instructions:
+ http://binarybonsai.com/archives/2004/08/17/time-since-plugin/ */
+ /* $entry_datetime = abs(strtotime($post->post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?>
+ on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?>
+ and is filed under <?php the_category(', ') ?>.
+ You can follow any responses to this entry through the <?php comments_rss_link('RSS 2.0'); ?> feed.
+
+ <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
+ // Both Comments and Pings are open ?>
+ You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(true); ?>" rel="trackback">trackback</a> from your own site.
+
+ <?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
+ // Only Pings are Open ?>
+ Responses are currently closed, but you can <a href="<?php trackback_url(true); ?> " rel="trackback">trackback</a> from your own site.
+
+ <?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
+ // Comments are open, Pings are not ?>
+ You can skip to the end and leave a response. Pinging is currently not allowed.
+
+ <?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
+ // Neither Comments, nor Pings are open ?>
+ Both comments and pings are currently closed.
+
+ <?php } edit_post_link('Edit this entry.','',''); ?>
+
+ </small>
+ </p>
+
+ </div>
+ </div>
+
+ <?php comments_template(); ?>
+
+ <?php endwhile; else: ?>
+
+ <p>Sorry, no posts matched your criteria.</p>
+
+<?php endif; ?>
+
+ </div>
+
+<?php get_footer(); ?>
diff --git a/wp-inst/wp-content/themes/default/style.css b/wp-inst/wp-content/themes/default/style.css
new file mode 100644
index 0000000..820c993
--- /dev/null
+++ b/wp-inst/wp-content/themes/default/style.css
@@ -0,0 +1,610 @@
+/*
+Theme Name: WordPress Default
+Theme URI: http://wordpress.org/
+Description: The default WordPress theme based on the famous <a href="http://binarybonsai.com/kubrick/">Kubrick</a>.
+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;
+ }
+
+.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, .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;
+ }
+
+#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;
+ }
+
+.description {
+ text-align: center;
+ }
+
+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-inst/wp-counter.php b/wp-inst/wp-counter.php
new file mode 100644
index 0000000..e0121d0
--- /dev/null
+++ b/wp-inst/wp-counter.php
@@ -0,0 +1,209 @@
+<?php
+
+/* $Id: wp-counter.php,v 1.5 2005/03/11 14:46:30 donncha Exp $ */
+
+require_once('wp-blog-header.php');
+
+function doCheckRef( $url )
+{
+ $check = true;
+ // Do we need to check the referer? If it's from a known site we can save some cycles.
+ $checklist = array( "direct", "http://www.technorati.com", "http://www.google", "http://www.yahoo", "http://www.linux.ie", "http://blogs.linux.ie", "http://blo.gs" );
+ reset( $checklist );
+ while( list( $key, $val ) = each( $checklist ) )
+ {
+ $p = strpos( strtolower( $url ), $val );
+ if( $p !== false )
+ {
+ $check = false;
+ }
+ }
+ return $check;
+}
+
+function getreferer()
+{
+ global $p, $m, $cat, $site, $wpdb, $wpblog, $referer, $loc;
+
+ $ref = $referer;
+
+ // delete tomorrow's referers today
+ $tomorrow = date( "j", mktime (0,0,0,date("m") ,date("d")+1,date("Y")) );
+ $sec = date( "s" );
+ $hour = date( "G" );
+ if( $sec == 30 && $hour < 2 )
+ {
+ $sql = "delete from referer_visitLog WHERE dayofmonth = '$tomorrow'"; // delete referers from a (month + 1 day) ago.
+ $wpdb->query($sql);
+ }
+
+ $ua = getenv( 'HTTP_USER_AGENT' );
+ $currentURL = str_replace( "http://".$_SERVER[ 'SERVER_NAME' ], '', $loc );
+ $fullCurrentURL = $loc;
+ if( $ref == '' )
+ {
+ $ref = "DIRECT";
+ }
+
+ $found = false;
+
+ if( $currentURL[ strlen( $currentURL ) -1 ] == '/' )
+ {
+ $found = true;
+ }
+ else
+ {
+ $count_files = array( "wp-admin" );
+ reset( $count_files );
+ while( list( $key, $val ) = each( $count_files ) )
+ {
+ $pos = strpos( $currentURL, $val );
+ if( $pos == true )
+ {
+ $found = true;
+ }
+ }
+ if( $found == true )
+ {
+ // Don't bother going further - no need to record request!
+ return;
+ }
+ }
+
+ if ($ref || $ref = strip_tags($ref) )
+ {
+
+ $realReferer = true;
+ $ignorePages = Array( 'lastupdated.php', 'b2rdf.php', 'b2rss2.php', 'b2bookmarklet.php', 'b2referers.php', 'b2commentspopup.php' );
+ foreach ($ignorePages as $ignoresite){
+ if (stristr($currentURL, $ignoresite)){
+ $realReferer = false;
+ }
+ }
+
+ $ignore = Array(
+ 'http://www.myelin.co.nz/ecosystem/bot.php',
+ 'http://radio.xmlstoragesystem.com/rcsPublic/',
+ 'http://blogdex.media.mit.edu//',
+ 'http://subhonker6.userland.com/rcsPublic/',
+ 'mastadonte.com',
+ 'http://blo.gs/ping.php'
+ );
+ foreach ($ignore as $ignoresite){
+ if (stristr($ref, $ignoresite)){
+ $realReferer = false;
+ }
+ }
+
+ $doubleCheckReferers = 0;
+
+ $checkRef = doCheckRef( $ref );
+
+ if( $realReferer && $checkRef && $ref != 'DIRECT' && $doubleCheckReferers)
+ {
+ //this is so that the page up until the call to
+ //logReferer will get shown before it tries to check
+ //back against the refering URL.
+ flush();
+
+ $goodReferer = 0;
+ $fp = @fopen ($ref, "r");
+ if ($fp){
+ socket_set_timeout($fp, 5);
+ $c = 0;
+ while (!feof ($fp) || $c > 5) {
+ $page .= trim(fgets($fp, 4096));
+ $c++;
+ }
+ fclose( $fp );
+ if (strstr($page,$fullCurrentURL)){
+ $goodReferer = 1;
+ }
+ }
+
+ if(!$goodReferer){
+ $realReferer = false;
+ }
+ }
+
+ if( $realReferer == true )
+ {
+ $query = "SELECT ID FROM referer_blacklist WHERE URL like '%$ref%'";
+ $result = $wpdb->get_var( $query );
+ if( $result )
+ {
+ $ref = "DIRECT";
+ }
+ }
+
+ $useragents = array( "http://www.syndic8.com", "http://dir.com/pompos.html", "NaverBot-1.0", "http://help.yahoo.com/help/us/ysearch/slurp", "http://www.google.com/bot.html", "http://www.blogdigger.com/", "http://search.msn.com/msnbot.htm", "Feedster, LLC.", "http://www.breakingblogs.com/timbo_bot.html", "fastbuzz.com", "http://www.pubsub.com/", "http://www.bloglines.com", "http://www.drupal.org/", "Ask Jeeves/Teoma", "ia_archiver", "http://minutillo.com/steve/feedonfeeds/", "larbin_2", "lmspider", "kinjabot", "lickBot 2.0", "Downes/Referrers", "daypopbot", "www.globalspec.com" );
+ reset( $useragents );
+ while( list( $key, $val ) = each( $useragents ) )
+ {
+ if( strpos( $ua, $val ) !== false )
+ {
+ $realReferer = false;
+ }
+ }
+
+ if( $realReferer )
+ {
+ if( $ref == 'DIRECT' )
+ {
+ $anchor = $ref;
+ }
+ else
+ {
+ $anchor = preg_replace("/http:\/\//i", "", $ref);
+ $anchor = preg_replace("/^www\./i", "", $anchor);
+ $anchor = preg_replace("/\/.*/i", "", $anchor);
+ }
+ $today = date( "d" );
+
+ $sql = "update referer_visitLog
+ set visitTimes = visitTimes + 1
+ where blogID = '$wpblog'
+ AND dayofmonth = '$today'
+ AND referingURL = '$ref'
+ AND visitURL = '$currentURL'";
+ $result = $wpdb->query( $sql );
+ if( $result == false )
+ {
+ $sql ="insert delayed into referer_visitLog (blogID,referingURL,visitURL,refpost, visitTimes, dayofmonth)
+ values ('$wpblog','$ref','$currentURL','$p','1', '$today')";
+ $result = $wpdb->query( $sql );
+ }
+ }
+ }
+}
+
+if( $_GET[ 'page' ] )
+{
+ if( $referer == '' )
+ if( $HTTP_GET_VARS[ 'referer' ] != '' )
+ {
+ $referer = $HTTP_GET_VARS[ 'referer' ];
+ }
+ getreferer();
+ header( "Content-type: IMAGE/PNG" );
+ readfile( get_settings( 'siteurl' ) . "/wp-images/wpminilogo.png" );
+}
+else
+{
+ ?>
+ <!--
+ if (document["referrer"] != null)
+ {
+ ref = document.referrer;
+ }
+ else
+ {
+ ref = 'DIRECT';
+ }
+ counterDate = new Date();
+ seconds = counterDate.getSeconds();
+ document.write("<a href='<?php print get_settings( 'siteurl' ) ?>/'><img width=1 height=1 src='<?php print get_settings( 'siteurl' ) ?>/wp-counter.php?page=img&loc="+document.location+"&referer="+escape(ref)+"&t="+seconds+"' border='0' title='Stats'></a>");
+ // -->
+ <?php
+}
+?>
diff --git a/wp-inst/wp-feed.php b/wp-inst/wp-feed.php
new file mode 100644
index 0000000..9305077
--- /dev/null
+++ b/wp-inst/wp-feed.php
@@ -0,0 +1,37 @@
+<?php
+
+if (empty($doing_rss)) {
+ $doing_rss = 1;
+ require(dirname(__FILE__) . '/wp-blog-header.php');
+}
+
+// Remove the pad, if present.
+$feed = preg_replace('/^_+/', '', $feed);
+
+if ($feed == '' || $feed == 'feed') {
+ $feed = 'rss2';
+}
+
+if ( is_single() || ($withcomments == 1) ) {
+ require(ABSPATH . 'wp-commentsrss2.php');
+} else {
+ switch ($feed) {
+ case 'atom':
+ require(ABSPATH . 'wp-atom.php');
+ break;
+ case 'rdf':
+ require(ABSPATH . 'wp-rdf.php');
+ break;
+ case 'rss':
+ require(ABSPATH . 'wp-rss.php');
+ break;
+ case 'rss2':
+ require(ABSPATH . 'wp-rss2.php');
+ break;
+ case 'comments-rss2':
+ require(ABSPATH . 'wp-commentsrss2.php');
+ break;
+ }
+}
+
+?>
diff --git a/wp-inst/wp-images/.htaccess b/wp-inst/wp-images/.htaccess
new file mode 100644
index 0000000..38dcd05
--- /dev/null
+++ b/wp-inst/wp-images/.htaccess
@@ -0,0 +1 @@
+RewriteEngine Off
diff --git a/wp-inst/wp-images/fade-butt.png b/wp-inst/wp-images/fade-butt.png
new file mode 100644
index 0000000..42f08b7
--- /dev/null
+++ b/wp-inst/wp-images/fade-butt.png
Binary files differ
diff --git a/wp-inst/wp-images/get-firefox.png b/wp-inst/wp-images/get-firefox.png
new file mode 100644
index 0000000..e0c78fd
--- /dev/null
+++ b/wp-inst/wp-images/get-firefox.png
Binary files differ
diff --git a/wp-inst/wp-images/header-shadow.png b/wp-inst/wp-images/header-shadow.png
new file mode 100644
index 0000000..5b6a644
--- /dev/null
+++ b/wp-inst/wp-images/header-shadow.png
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_arrow.gif b/wp-inst/wp-images/smilies/icon_arrow.gif
new file mode 100644
index 0000000..2880055
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_arrow.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_biggrin.gif b/wp-inst/wp-images/smilies/icon_biggrin.gif
new file mode 100644
index 0000000..d352772
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_biggrin.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_confused.gif b/wp-inst/wp-images/smilies/icon_confused.gif
new file mode 100644
index 0000000..0c49e06
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_confused.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_cool.gif b/wp-inst/wp-images/smilies/icon_cool.gif
new file mode 100644
index 0000000..cead030
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_cool.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_cry.gif b/wp-inst/wp-images/smilies/icon_cry.gif
new file mode 100644
index 0000000..7d54b1f
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_cry.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_eek.gif b/wp-inst/wp-images/smilies/icon_eek.gif
new file mode 100644
index 0000000..5d39781
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_eek.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_evil.gif b/wp-inst/wp-images/smilies/icon_evil.gif
new file mode 100644
index 0000000..ab1aa8e
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_evil.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_exclaim.gif b/wp-inst/wp-images/smilies/icon_exclaim.gif
new file mode 100644
index 0000000..6e50e2e
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_exclaim.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_idea.gif b/wp-inst/wp-images/smilies/icon_idea.gif
new file mode 100644
index 0000000..a40ae0d
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_idea.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_lol.gif b/wp-inst/wp-images/smilies/icon_lol.gif
new file mode 100644
index 0000000..374ba15
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_lol.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_mad.gif b/wp-inst/wp-images/smilies/icon_mad.gif
new file mode 100644
index 0000000..1f6c3c2
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_mad.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_mrgreen.gif b/wp-inst/wp-images/smilies/icon_mrgreen.gif
new file mode 100644
index 0000000..b54cd0f
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_mrgreen.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_neutral.gif b/wp-inst/wp-images/smilies/icon_neutral.gif
new file mode 100644
index 0000000..4f31156
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_neutral.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_question.gif b/wp-inst/wp-images/smilies/icon_question.gif
new file mode 100644
index 0000000..9d07226
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_question.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_razz.gif b/wp-inst/wp-images/smilies/icon_razz.gif
new file mode 100644
index 0000000..29da2a2
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_razz.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_redface.gif b/wp-inst/wp-images/smilies/icon_redface.gif
new file mode 100644
index 0000000..ad76283
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_redface.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_rolleyes.gif b/wp-inst/wp-images/smilies/icon_rolleyes.gif
new file mode 100644
index 0000000..d7f5f2f
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_rolleyes.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_sad.gif b/wp-inst/wp-images/smilies/icon_sad.gif
new file mode 100644
index 0000000..d2ac78c
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_sad.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_smile.gif b/wp-inst/wp-images/smilies/icon_smile.gif
new file mode 100644
index 0000000..7b1f6d3
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_smile.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_surprised.gif b/wp-inst/wp-images/smilies/icon_surprised.gif
new file mode 100644
index 0000000..cb21424
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_surprised.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_twisted.gif b/wp-inst/wp-images/smilies/icon_twisted.gif
new file mode 100644
index 0000000..502fe24
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_twisted.gif
Binary files differ
diff --git a/wp-inst/wp-images/smilies/icon_wink.gif b/wp-inst/wp-images/smilies/icon_wink.gif
new file mode 100644
index 0000000..d148288
--- /dev/null
+++ b/wp-inst/wp-images/smilies/icon_wink.gif
Binary files differ
diff --git a/wp-inst/wp-images/wordpress-mu.png b/wp-inst/wp-images/wordpress-mu.png
new file mode 100644
index 0000000..8dd6c04
--- /dev/null
+++ b/wp-inst/wp-images/wordpress-mu.png
Binary files differ
diff --git a/wp-inst/wp-images/wp-small.png b/wp-inst/wp-images/wp-small.png
new file mode 100644
index 0000000..b96f741
--- /dev/null
+++ b/wp-inst/wp-images/wp-small.png
Binary files differ
diff --git a/wp-inst/wp-images/wpminilogo.png b/wp-inst/wp-images/wpminilogo.png
new file mode 100644
index 0000000..12573ec
--- /dev/null
+++ b/wp-inst/wp-images/wpminilogo.png
Binary files differ
diff --git a/wp-inst/wp-includes/capabilities.php b/wp-inst/wp-includes/capabilities.php
new file mode 100644
index 0000000..af5fb58
--- /dev/null
+++ b/wp-inst/wp-includes/capabilities.php
@@ -0,0 +1,263 @@
+<?php
+
+class WP_Roles {
+ var $roles;
+
+ var $role_objects = array();
+ var $role_names = array();
+ var $role_key;
+
+ function WP_Roles() {
+ global $table_prefix;
+ $this->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, $capabilities, $display_name) {
+ $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;
+ }
+
+ 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) {
+ $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($caps)
+ {
+ return empty($this->role_names[$cap]);
+ }
+}
+
+class WP_Role {
+ var $name;
+ var $capabilities;
+
+ function WP_Role($role, $capabilities) {
+ $this->name = $role;
+ $this->capabilities = $capabilities;
+ }
+
+ function add_cap($cap, $grant) {
+ global $wp_roles;
+
+ $this->capabilities[$cap] = $grant;
+ $wp_roles->add_cap($this->name, $cap);
+ }
+
+ function remove_cap($cap) {
+ global $wp_roles;
+
+ unset($this->capabilities[$cap]);
+ $wp_roles->remove_cap($this->name, $cap);
+ }
+
+ function has_cap($cap) {
+ if ( !empty($this->capabilities[$cap]) )
+ return $this->capabilities[$cap];
+ else
+ return false;
+ }
+
+}
+
+class WP_User {
+ var $data;
+ var $id;
+ var $caps;
+ var $cap_key;
+ var $roles;
+ var $allcaps;
+
+ function WP_User($id) {
+ global $wp_roles, $table_prefix;
+ $this->id = $id;
+ $this->data = get_userdata($id);
+ $this->cap_key = $table_prefix . 'capabilities';
+ $this->caps = &$this->data->{$this->cap_key};
+ $this->get_role_caps();
+ }
+
+ function get_role_caps() {
+ global $wp_roles;
+ //Filter out caps that are not role names and assign to $this->roles
+ if(is_array($this->caps))
+ $this->roles = array_filter($this->caps, array(&$wp_roles, 'is_role'));
+
+ //Build $allcaps from role caps, overlay user's $caps
+ $this->allcaps = array();
+ foreach($this->roles as $role => $value) {
+ $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))
+ unset($this->caps[$cap]);
+ update_usermeta($this->id, $this->cap_key, $this->caps);
+ $this->get_role_caps();
+ }
+
+ function set_role($role) {
+ foreach($this->roles as $oldrole => $value)
+ 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->data->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0);
+ update_usermeta($this->id, $table_prefix.'user_level', $this->data->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->roles[$role])) 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) {
+ global $wp_roles;
+
+ 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
+ foreach ($caps as $cap) {
+ //echo "Checking cap $cap<br/>";
+ if(empty($this->allcaps[$cap]) || !$this->allcaps[$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]}<br/>";
+ $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 . "<br/>";
+ // 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 the post is draft...
+ $caps[] = 'edit_posts';
+ } else {
+ // 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;
+ 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);
+}
+
+?>
diff --git a/wp-inst/wp-includes/class-IXR.php b/wp-inst/wp-includes/class-IXR.php
new file mode 100644
index 0000000..01c3079
--- /dev/null
+++ b/wp-inst/wp-includes/class-IXR.php
@@ -0,0 +1,815 @@
+<?php
+/*
+ IXR - The Inutio XML-RPC Library - (c) Incutio Ltd 2002-2005
+ Version 1.7 (beta) - Simon Willison, 23rd May 2005
+ Site: http://scripts.incutio.com/xmlrpc/
+ Manual: http://scripts.incutio.com/xmlrpc/manual.php
+ Made available under the BSD License: http://www.opensource.org/licenses/bsd-license.php
+*/
+
+class IXR_Value {
+ var $data;
+ var $type;
+ function IXR_Value ($data, $type = false) {
+ $this->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 '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
+ break;
+ case 'int':
+ return '<int>'.$this->data.'</int>';
+ break;
+ case 'double':
+ return '<double>'.$this->data.'</double>';
+ break;
+ case 'string':
+ return '<string>'.htmlspecialchars($this->data).'</string>';
+ break;
+ case 'array':
+ $return = '<array><data>'."\n";
+ foreach ($this->data as $item) {
+ $return .= ' <value>'.$item->getXml()."</value>\n";
+ }
+ $return .= '</data></array>';
+ return $return;
+ break;
+ case 'struct':
+ $return = '<struct>'."\n";
+ foreach ($this->data as $name => $value) {
+ $name = htmlspecialchars($name);
+ $return .= " <member><name>$name</name><value>";
+ $return .= $value->getXml()."</value></member>\n";
+ }
+ $return .= '</struct>';
+ 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 = <<<EOD
+<methodResponse>
+ <params>
+ <param>
+ <value>
+ $resultxml
+ </value>
+ </param>
+ </params>
+</methodResponse>
+
+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 = '<?xml version="1.0"?>'."\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 = <<<EOD
+<?xml version="1.0"?>
+<methodCall>
+<methodName>{$this->method}</methodName>
+<params>
+
+EOD;
+ foreach ($this->args as $arg) {
+ $this->xml .= '<param><value>';
+ $v = new IXR_Value($arg);
+ $this->xml .= $v->getXml();
+ $this->xml .= "</value></param>\n";
+ }
+ $this->xml .= '</params></methodCall>';
+ }
+ 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 '<pre>'.htmlspecialchars($request)."\n</pre>\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 '<pre>'.htmlspecialchars($contents)."\n</pre>\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 = <<<EOD
+<methodResponse>
+ <fault>
+ <value>
+ <struct>
+ <member>
+ <name>faultCode</name>
+ <value><int>{$this->code}</int></value>
+ </member>
+ <member>
+ <name>faultString</name>
+ <value><string>{$this->message}</string></value>
+ </member>
+ </struct>
+ </value>
+ </fault>
+</methodResponse>
+
+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;
+ }
+ function getXml() {
+ return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
+ }
+ 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>'.base64_encode($this->data).'</base64>';
+ }
+}
+
+
+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-inst/wp-includes/class-pop3.php b/wp-inst/wp-includes/class-pop3.php
new file mode 100644
index 0000000..468ca8b
--- /dev/null
+++ b/wp-inst/wp-includes/class-pop3.php
@@ -0,0 +1,680 @@
+<?php
+
+ /**
+ * mail_fetch/setup.php
+ *
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ *
+ * Copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
+ * Modified by Philippe Mingo 2001 mingo@rotedic.com
+ * An RFC 1939 compliant wrapper class for the POP3 protocol.
+ *
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * pop3 class
+ *
+ * $Id: class-pop3.php 2066 2005-01-07 01:29:49Z saxmatt $
+ */
+
+class POP3 {
+ var $ERROR = ''; // Error string.
+
+ var $TIMEOUT = 60; // Default timeout before giving up on a
+ // network operation.
+
+ var $COUNT = -1; // Mailbox msg count
+
+ var $BUFFER = 512; // Socket buffer for socket fgets() calls.
+ // Per RFC 1939 the returned line a POP3
+ // server can send is 512 bytes.
+
+ var $FP = ''; // The connection to the server's
+ // file descriptor
+
+ var $MAILSERVER = ''; // Set this to hard code the server name
+
+ var $DEBUG = FALSE; // set to true to echo pop3
+ // commands and responses to error_log
+ // this WILL log passwords!
+
+ var $BANNER = ''; // Holds the banner returned by the
+ // pop server - used for apop()
+
+ var $RFC1939 = TRUE; // Set by noop(). See rfc1939.txt
+ //
+
+ var $ALLOWAPOP = FALSE; // Allow or disallow apop()
+ // This must be set to true
+ // manually
+
+ function POP3 ( $server = '', $timeout = '' ) {
+ settype($this->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-inst/wp-includes/class-smarty.php b/wp-inst/wp-includes/class-smarty.php
new file mode 100644
index 0000000..16aafd7
--- /dev/null
+++ b/wp-inst/wp-includes/class-smarty.php
@@ -0,0 +1,3867 @@
+<?php
+
+if( isset( $wpsmarty ) == false || is_object( $wpsmarty ) == false )
+{
+ if( defined( ABSPATH ) == false )
+ define( "ABSPATH", "../" );
+
+ require_once( ABSPATH . "Smarty.class.php" );
+ $wpsmarty = new Smarty;
+}
+
+/* get_the_category( $id = false ) */
+function smarty_get_the_category( $params, &$smarty )
+{
+ $id = false;
+
+ extract( $params );
+ return get_the_category( $id );
+}
+$wpsmarty->register_function( "get_the_category", "smarty_get_the_category" );
+
+/* get_category_link( $category_id ) */
+function smarty_get_category_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_category_link( $category_id );
+}
+$wpsmarty->register_function( "get_category_link", "smarty_get_category_link" );
+
+/* get_the_category_list( $separator = '', $parents='' ) */
+function smarty_get_the_category_list( $params, &$smarty )
+{
+ $separator = '';
+ $parents='';
+
+ extract( $params );
+ return get_the_category_list( $separator, $parents );
+}
+$wpsmarty->register_function( "get_the_category_list", "smarty_get_the_category_list" );
+
+/* the_category( $separator = '', $parents='' ) */
+function smarty_the_category( $params, &$smarty )
+{
+ $separator = '';
+ $parents='';
+
+ extract( $params );
+ return the_category( $separator, $parents );
+}
+$wpsmarty->register_function( "the_category", "smarty_the_category" );
+
+/* get_the_category_by_ID( $cat_ID ) */
+function smarty_get_the_category_by_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_category_by_ID( $cat_ID );
+}
+$wpsmarty->register_function( "get_the_category_by_ID", "smarty_get_the_category_by_ID" );
+
+/* get_category_parents( $id, $link = FALSE, $separat ) */
+function smarty_get_category_parents( $params, &$smarty )
+{
+ $link = FALSE;
+
+ extract( $params );
+ return get_category_parents( $id, $link, $separat );
+}
+$wpsmarty->register_function( "get_category_parents", "smarty_get_category_parents" );
+
+/* get_category_children( $id, $before = '/', $after = '' ) */
+function smarty_get_category_children( $params, &$smarty )
+{
+ $before = '/';
+ $after = '';
+
+ extract( $params );
+ return get_category_children( $id, $before, $after );
+}
+$wpsmarty->register_function( "get_category_children", "smarty_get_category_children" );
+
+/* the_category_ID( $echo = true ) */
+function smarty_the_category_ID( $params, &$smarty )
+{
+ $echo = true;
+
+ extract( $params );
+ return the_category_ID( $echo );
+}
+$wpsmarty->register_function( "the_category_ID", "smarty_the_category_ID" );
+
+/* the_category_head( $before='', $after='' ) */
+function smarty_the_category_head( $params, &$smarty )
+{
+ $before='';
+ $after='';
+
+ extract( $params );
+ return the_category_head( $before, $after );
+}
+$wpsmarty->register_function( "the_category_head", "smarty_the_category_head" );
+
+/* category_description( $category = 0 ) */
+function smarty_category_description( $params, &$smarty )
+{
+ $category = 0;
+
+ extract( $params );
+ return category_description( $category );
+}
+$wpsmarty->register_function( "category_description", "smarty_category_description" );
+
+/* dropdown_cats( $optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc',
+ $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE,
+ $selected=0, $hide=0 ) */
+function smarty_dropdown_cats( $params, &$smarty )
+{
+ $optionall = 1;
+ $all = 'All';
+ $sort_column = 'ID';
+ $sort_order = 'asc';
+ $optiondates = 0;
+ $optioncount = 0;
+ $hide_empty = 1;
+ $optionnone=FALSE;
+ $selected=0;
+ $hide=0;
+
+ extract( $params );
+ return dropdown_cats( $optionall, $all, $sort_column, $sort_order, $optiondates, $optioncount, $hide_empty, $optionnone, $selected, $hide );
+}
+$wpsmarty->register_function( "dropdown_cats", "smarty_dropdown_cats" );
+
+/* wp_list_cats( $args = '' ) */
+function smarty_wp_list_cats( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_list_cats( $args );
+}
+$wpsmarty->register_function( "wp_list_cats", "smarty_wp_list_cats" );
+
+/* list_cats( $optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE ) */
+function smarty_list_cats( $params, &$smarty )
+{
+ $optionall = 1;
+ $all = 'All';
+ $sort_column = 'ID';
+ $sort_order = 'asc';
+ $file = '';
+ $list = true;
+ $optiondates = 0;
+ $optioncount = 0;
+ $hide_empty = 1;
+ $use_desc_for_title = 1;
+ $children=FALSE;
+ $child_of=0;
+ $categories=0;
+ $recurse=0;
+ $feed = '';
+ $feed_image = '';
+ $exclude = '';
+ $hierarchical=FALSE;
+
+ extract( $params );
+ return list_cats( $optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $children, $child_of, $categories, $recurse, $feed, $feed_image, $exclude, $hierarchical );
+}
+$wpsmarty->register_function( "list_cats", "smarty_list_cats" );
+
+/* in_category( $category ) */
+function smarty_in_category( $params, &$smarty )
+{
+
+ extract( $params );
+ return in_category( $category );
+}
+$wpsmarty->register_function( "in_category", "smarty_in_category" );
+
+/* get_header( ) */
+function smarty_get_header( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_header( );
+}
+$wpsmarty->register_function( "get_header", "smarty_get_header" );
+
+/* get_footer( ) */
+function smarty_get_footer( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_footer( );
+}
+$wpsmarty->register_function( "get_footer", "smarty_get_footer" );
+
+/* get_sidebar( ) */
+function smarty_get_sidebar( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_sidebar( );
+}
+$wpsmarty->register_function( "get_sidebar", "smarty_get_sidebar" );
+
+/* wp_loginout( ) */
+function smarty_wp_loginout( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_loginout( );
+}
+$wpsmarty->register_function( "wp_loginout", "smarty_wp_loginout" );
+
+/* wp_register( $before = '<li>', $after = '</li>' ) */
+function smarty_wp_register( $params, &$smarty )
+{
+ $before = '<li>';
+ $after = '</li>';
+
+ extract( $params );
+ return wp_register( $before, $after );
+}
+$wpsmarty->register_function( "wp_register", "smarty_wp_register" );
+
+/* wp_meta( ) */
+function smarty_wp_meta( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_meta( );
+}
+$wpsmarty->register_function( "wp_meta", "smarty_wp_meta" );
+
+/* bloginfo( $show='' ) */
+function smarty_bloginfo( $params, &$smarty )
+{
+ $show='';
+
+ extract( $params );
+ return bloginfo( $show );
+}
+$wpsmarty->register_function( "bloginfo", "smarty_bloginfo" );
+
+/* get_bloginfo( $show='' ) */
+function smarty_get_bloginfo( $params, &$smarty )
+{
+ $show='';
+
+ extract( $params );
+ return get_bloginfo( $show );
+}
+$wpsmarty->register_function( "get_bloginfo", "smarty_get_bloginfo" );
+
+/* wp_title( $sep = '&raquo;', $display = true ) */
+function smarty_wp_title( $params, &$smarty )
+{
+ $sep = '&raquo;';
+ $display = true;
+
+ extract( $params );
+ return wp_title( $sep, $display );
+}
+$wpsmarty->register_function( "wp_title", "smarty_wp_title" );
+
+/* single_post_title( $prefix = '', $display = true ) */
+function smarty_single_post_title( $params, &$smarty )
+{
+ $prefix = '';
+ $display = true;
+
+ extract( $params );
+ return single_post_title( $prefix, $display );
+}
+$wpsmarty->register_function( "single_post_title", "smarty_single_post_title" );
+
+/* single_cat_title( $prefix = '', $display = true ) */
+function smarty_single_cat_title( $params, &$smarty )
+{
+ $prefix = '';
+ $display = true;
+
+ extract( $params );
+ return single_cat_title( $prefix, $display );
+}
+$wpsmarty->register_function( "single_cat_title", "smarty_single_cat_title" );
+
+/* single_month_title( $prefix = '', $display = true ) */
+function smarty_single_month_title( $params, &$smarty )
+{
+ $prefix = '';
+ $display = true;
+
+ extract( $params );
+ return single_month_title( $prefix, $display );
+}
+$wpsmarty->register_function( "single_month_title", "smarty_single_month_title" );
+
+/* get_archives_link( $url, $text, $format = 'html', $before = '', $after = '' ) */
+function smarty_get_archives_link( $params, &$smarty )
+{
+ $format = 'html';
+ $before = '';
+ $after = '';
+
+ extract( $params );
+ return get_archives_link( $url, $text, $format, $before, $after );
+}
+$wpsmarty->register_function( "get_archives_link", "smarty_get_archives_link" );
+
+/* wp_get_archives( $args = '' ) */
+function smarty_wp_get_archives( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_get_archives( $args );
+}
+$wpsmarty->register_function( "wp_get_archives", "smarty_wp_get_archives" );
+
+/* get_archives( $type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false ) */
+function smarty_get_archives( $params, &$smarty )
+{
+ $type='';
+ $limit='';
+ $format='html';
+ $before = '';
+ $after = '';
+ $show_post_count = false;
+
+ extract( $params );
+ return get_archives( $type, $limit, $format, $before, $after, $show_post_count );
+}
+$wpsmarty->register_function( "get_archives", "smarty_get_archives" );
+
+/* calendar_week_mod( $num ) */
+function smarty_calendar_week_mod( $params, &$smarty )
+{
+
+ extract( $params );
+ return calendar_week_mod( $num );
+}
+$wpsmarty->register_function( "calendar_week_mod", "smarty_calendar_week_mod" );
+
+/* get_calendar( $daylength = 1 ) */
+function smarty_get_calendar( $params, &$smarty )
+{
+ $daylength = 1;
+
+ extract( $params );
+ return get_calendar( $daylength );
+}
+$wpsmarty->register_function( "get_calendar", "smarty_get_calendar" );
+
+/* allowed_tags( ) */
+function smarty_allowed_tags( $params, &$smarty )
+{
+
+ extract( $params );
+ return allowed_tags( );
+}
+$wpsmarty->register_function( "allowed_tags", "smarty_allowed_tags" );
+
+/* the_date_xml( ) */
+function smarty_the_date_xml( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_date_xml( );
+}
+$wpsmarty->register_function( "the_date_xml", "smarty_the_date_xml" );
+
+/* the_date( $d='', $before='', $after='', $echo = true ) */
+function smarty_the_date( $params, &$smarty )
+{
+ $d='';
+ $before='';
+ $after='';
+ $echo = true;
+
+ extract( $params );
+ return the_date( $d, $before, $after, $echo );
+}
+$wpsmarty->register_function( "the_date", "smarty_the_date" );
+
+/* the_time( $d = '' ) */
+function smarty_the_time( $params, &$smarty )
+{
+ $d = '';
+
+ extract( $params );
+ return the_time( $d );
+}
+$wpsmarty->register_function( "the_time", "smarty_the_time" );
+
+/* get_the_time( $d = '' ) */
+function smarty_get_the_time( $params, &$smarty )
+{
+ $d = '';
+
+ extract( $params );
+ return get_the_time( $d );
+}
+$wpsmarty->register_function( "get_the_time", "smarty_get_the_time" );
+
+/* get_post_time( $d = 'U', $gmt = false ) */
+function smarty_get_post_time( $params, &$smarty )
+{
+ $d = 'U';
+ $gmt = false;
+
+ extract( $params );
+ return get_post_time( $d, $gmt );
+}
+$wpsmarty->register_function( "get_post_time", "smarty_get_post_time" );
+
+/* the_weekday( ) */
+function smarty_the_weekday( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_weekday( );
+}
+$wpsmarty->register_function( "the_weekday", "smarty_the_weekday" );
+
+/* the_weekday_date( $before='',$after='' ) */
+function smarty_the_weekday_date( $params, &$smarty )
+{
+ $before='';
+ $after='';
+
+ extract( $params );
+ return the_weekday_date( $before, $after );
+}
+$wpsmarty->register_function( "the_weekday_date", "smarty_the_weekday_date" );
+
+/* the_permalink( ) */
+function smarty_the_permalink( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_permalink( );
+}
+$wpsmarty->register_function( "the_permalink", "smarty_the_permalink" );
+
+/* permalink_link( ) */
+function smarty_permalink_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return permalink_link( );
+}
+$wpsmarty->register_function( "permalink_link", "smarty_permalink_link" );
+
+/* permalink_anchor( $mode = 'id' ) */
+function smarty_permalink_anchor( $params, &$smarty )
+{
+ $mode = 'id';
+
+ extract( $params );
+ return permalink_anchor( $mode );
+}
+$wpsmarty->register_function( "permalink_anchor", "smarty_permalink_anchor" );
+
+/* get_permalink( $id = 0 ) */
+function smarty_get_permalink( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return get_permalink( $id );
+}
+$wpsmarty->register_function( "get_permalink", "smarty_get_permalink" );
+
+/* get_page_link( $id = false ) */
+function smarty_get_page_link( $params, &$smarty )
+{
+ $id = false;
+
+ extract( $params );
+ return get_page_link( $id );
+}
+$wpsmarty->register_function( "get_page_link", "smarty_get_page_link" );
+
+/* get_year_link( $year ) */
+function smarty_get_year_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_year_link( $year );
+}
+$wpsmarty->register_function( "get_year_link", "smarty_get_year_link" );
+
+/* get_month_link( $year, $month ) */
+function smarty_get_month_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_month_link( $year, $month );
+}
+$wpsmarty->register_function( "get_month_link", "smarty_get_month_link" );
+
+/* get_day_link( $year, $month, $day ) */
+function smarty_get_day_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_day_link( $year, $month, $day );
+}
+$wpsmarty->register_function( "get_day_link", "smarty_get_day_link" );
+
+/* get_feed_link( $feed='rss2' ) */
+function smarty_get_feed_link( $params, &$smarty )
+{
+ $feed='rss2';
+
+ extract( $params );
+ return get_feed_link( $feed );
+}
+$wpsmarty->register_function( "get_feed_link", "smarty_get_feed_link" );
+
+/* edit_post_link( $link = 'Edit This', $before = '', $after = '' ) */
+function smarty_edit_post_link( $params, &$smarty )
+{
+ $link = 'Edit This';
+ $before = '';
+ $after = '';
+
+ extract( $params );
+ return edit_post_link( $link, $before, $after );
+}
+$wpsmarty->register_function( "edit_post_link", "smarty_edit_post_link" );
+
+/* edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) */
+function smarty_edit_comment_link( $params, &$smarty )
+{
+ $link = 'Edit This';
+ $before = '';
+ $after = '';
+
+ extract( $params );
+ return edit_comment_link( $link, $before, $after );
+}
+$wpsmarty->register_function( "edit_comment_link", "smarty_edit_comment_link" );
+
+/* get_previous_post( $in_same_cat = false, $excluded_categories = '' ) */
+function smarty_get_previous_post( $params, &$smarty )
+{
+ $in_same_cat = false;
+ $excluded_categories = '';
+
+ extract( $params );
+ return get_previous_post( $in_same_cat, $excluded_categories );
+}
+$wpsmarty->register_function( "get_previous_post", "smarty_get_previous_post" );
+
+/* get_next_post( $in_same_cat = false, $excluded_categories = '' ) */
+function smarty_get_next_post( $params, &$smarty )
+{
+ $in_same_cat = false;
+ $excluded_categories = '';
+
+ extract( $params );
+ return get_next_post( $in_same_cat, $excluded_categories );
+}
+$wpsmarty->register_function( "get_next_post", "smarty_get_next_post" );
+
+/* previous_post_link( $format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '' ) */
+function smarty_previous_post_link( $params, &$smarty )
+{
+ $format='&laquo; %link';
+ $link='%title';
+ $in_same_cat = false;
+ $excluded_categories = '';
+
+ extract( $params );
+ return previous_post_link( $format, $link, $in_same_cat, $excluded_categories );
+}
+$wpsmarty->register_function( "previous_post_link", "smarty_previous_post_link" );
+
+/* next_post_link( $format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '' ) */
+function smarty_next_post_link( $params, &$smarty )
+{
+ $format='%link &raquo;';
+ $link='%title';
+ $in_same_cat = false;
+ $excluded_categories = '';
+
+ extract( $params );
+ return next_post_link( $format, $link, $in_same_cat, $excluded_categories );
+}
+$wpsmarty->register_function( "next_post_link", "smarty_next_post_link" );
+
+/* previous_post( $format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='' ) */
+function smarty_previous_post( $params, &$smarty )
+{
+ $format='%';
+ $previous='previous post: ';
+ $title='yes';
+ $in_same_cat='no';
+ $limitprev=1;
+ $excluded_categories='';
+
+ extract( $params );
+ return previous_post( $format, $previous, $title, $in_same_cat, $limitprev, $excluded_categories );
+}
+$wpsmarty->register_function( "previous_post", "smarty_previous_post" );
+
+/* next_post( $format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='' ) */
+function smarty_next_post( $params, &$smarty )
+{
+ $format='%';
+ $next='next post: ';
+ $title='yes';
+ $in_same_cat='no';
+ $limitnext=1;
+ $excluded_categories='';
+
+ extract( $params );
+ return next_post( $format, $next, $title, $in_same_cat, $limitnext, $excluded_categories );
+}
+$wpsmarty->register_function( "next_post", "smarty_next_post" );
+
+/* get_pagenum_link( $pagenum = 1 ) */
+function smarty_get_pagenum_link( $params, &$smarty )
+{
+ $pagenum = 1;
+
+ extract( $params );
+ return get_pagenum_link( $pagenum );
+}
+$wpsmarty->register_function( "get_pagenum_link", "smarty_get_pagenum_link" );
+
+/* next_posts( $max_page = 0 ) */
+function smarty_next_posts( $params, &$smarty )
+{
+ $max_page = 0;
+
+ extract( $params );
+ return next_posts( $max_page );
+}
+$wpsmarty->register_function( "next_posts", "smarty_next_posts" );
+
+/* next_posts_link( $label='Next Page &raquo;', $max_page=0 ) */
+function smarty_next_posts_link( $params, &$smarty )
+{
+ $label='Next Page &raquo;';
+ $max_page=0;
+
+ extract( $params );
+ return next_posts_link( $label, $max_page );
+}
+$wpsmarty->register_function( "next_posts_link", "smarty_next_posts_link" );
+
+/* previous_posts( ) */
+function smarty_previous_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return previous_posts( );
+}
+$wpsmarty->register_function( "previous_posts", "smarty_previous_posts" );
+
+/* previous_posts_link( $label='&laquo; Previous Page' ) */
+function smarty_previous_posts_link( $params, &$smarty )
+{
+ $label='&laquo; Previous Page';
+
+ extract( $params );
+ return previous_posts_link( $label );
+}
+$wpsmarty->register_function( "previous_posts_link", "smarty_previous_posts_link" );
+
+/* posts_nav_link( $sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;' ) */
+function smarty_posts_nav_link( $params, &$smarty )
+{
+ $sep=' &#8212; ';
+ $prelabel='&laquo; Previous Page';
+ $nxtlabel='Next Page &raquo;';
+
+ extract( $params );
+ return posts_nav_link( $sep, $prelabel, $nxtlabel );
+}
+$wpsmarty->register_function( "posts_nav_link", "smarty_posts_nav_link" );
+
+/* get_the_password_form( ) */
+function smarty_get_the_password_form( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_password_form( );
+}
+$wpsmarty->register_function( "get_the_password_form", "smarty_get_the_password_form" );
+
+/* the_ID( ) */
+function smarty_the_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_ID( );
+}
+$wpsmarty->register_function( "the_ID", "smarty_the_ID" );
+
+/* the_title( $before = '', $after = '', $echo = true ) */
+function smarty_the_title( $params, &$smarty )
+{
+ $before = '';
+ $after = '';
+ $echo = true;
+
+ extract( $params );
+ return the_title( $before, $after, $echo );
+}
+$wpsmarty->register_function( "the_title", "smarty_the_title" );
+
+/* get_the_title( $id = 0 ) */
+function smarty_get_the_title( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return get_the_title( $id );
+}
+$wpsmarty->register_function( "get_the_title", "smarty_get_the_title" );
+
+/* get_the_guid( $id = 0 ) */
+function smarty_get_the_guid( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return get_the_guid( $id );
+}
+$wpsmarty->register_function( "get_the_guid", "smarty_get_the_guid" );
+
+/* the_guid( $id = 0 ) */
+function smarty_the_guid( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return the_guid( $id );
+}
+$wpsmarty->register_function( "the_guid", "smarty_the_guid" );
+
+/* the_content( $more_link_text = '(more...)', $stripteaser = 0, $more_file = '' ) */
+function smarty_the_content( $params, &$smarty )
+{
+ $more_link_text = '(more...)';
+ $stripteaser = 0;
+ $more_file = '';
+
+ extract( $params );
+ return the_content( $more_link_text, $stripteaser, $more_file );
+}
+$wpsmarty->register_function( "the_content", "smarty_the_content" );
+
+/* get_the_content( $more_link_text = '(more...)', $stripteaser = 0, $more_file = '' ) */
+function smarty_get_the_content( $params, &$smarty )
+{
+ $more_link_text = '(more...)';
+ $stripteaser = 0;
+ $more_file = '';
+
+ extract( $params );
+ return get_the_content( $more_link_text, $stripteaser, $more_file );
+}
+$wpsmarty->register_function( "get_the_content", "smarty_get_the_content" );
+
+/* the_excerpt( ) */
+function smarty_the_excerpt( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_excerpt( );
+}
+$wpsmarty->register_function( "the_excerpt", "smarty_the_excerpt" );
+
+/* get_the_excerpt( $fakeit = true ) */
+function smarty_get_the_excerpt( $params, &$smarty )
+{
+ $fakeit = true;
+
+ extract( $params );
+ return get_the_excerpt( $fakeit );
+}
+$wpsmarty->register_function( "get_the_excerpt", "smarty_get_the_excerpt" );
+
+/* wp_link_pages( $args = '' ) */
+function smarty_wp_link_pages( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_link_pages( $args );
+}
+$wpsmarty->register_function( "wp_link_pages", "smarty_wp_link_pages" );
+
+/* link_pages( $before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='' ) */
+function smarty_link_pages( $params, &$smarty )
+{
+ $before='<br />';
+ $after='<br />';
+ $next_or_number='number';
+ $nextpagelink='next page';
+ $previouspagelink='previous page';
+ $pagelink='%';
+ $more_file='';
+
+ extract( $params );
+ return link_pages( $before, $after, $next_or_number, $nextpagelink, $previouspagelink, $pagelink, $more_file );
+}
+$wpsmarty->register_function( "link_pages", "smarty_link_pages" );
+
+/* get_post_custom( $post_id = 0 ) */
+function smarty_get_post_custom( $params, &$smarty )
+{
+ $post_id = 0;
+
+ extract( $params );
+ return get_post_custom( $post_id );
+}
+$wpsmarty->register_function( "get_post_custom", "smarty_get_post_custom" );
+
+/* get_post_custom_keys( ) */
+function smarty_get_post_custom_keys( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_post_custom_keys( );
+}
+$wpsmarty->register_function( "get_post_custom_keys", "smarty_get_post_custom_keys" );
+
+/* get_post_custom_values( $key='' ) */
+function smarty_get_post_custom_values( $params, &$smarty )
+{
+ $key='';
+
+ extract( $params );
+ return get_post_custom_values( $key );
+}
+$wpsmarty->register_function( "get_post_custom_values", "smarty_get_post_custom_values" );
+
+/* post_custom( $key = '' ) */
+function smarty_post_custom( $params, &$smarty )
+{
+ $key = '';
+
+ extract( $params );
+ return post_custom( $key );
+}
+$wpsmarty->register_function( "post_custom", "smarty_post_custom" );
+
+/* the_meta( ) */
+function smarty_the_meta( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_meta( );
+}
+$wpsmarty->register_function( "the_meta", "smarty_the_meta" );
+
+/* &get_page_children( $page_id, $pages ) */
+function &smarty_get_page_children( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_page_children( $page_id, $pages );
+}
+$wpsmarty->register_function( "get_page_children", "smarty_get_page_children" );
+
+/* &get_pages( $args = '' ) */
+function &smarty_get_pages( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return get_pages( $args );
+}
+$wpsmarty->register_function( "get_pages", "smarty_get_pages" );
+
+/* wp_list_pages( $args = '' ) */
+function smarty_wp_list_pages( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_list_pages( $args );
+}
+$wpsmarty->register_function( "wp_list_pages", "smarty_wp_list_pages" );
+
+/* _page_level_out( $parent, $page_tree, $args, $depth = 0, $echo = true ) */
+function smarty__page_level_out( $params, &$smarty )
+{
+ $depth = 0;
+ $echo = true;
+
+ extract( $params );
+ return _page_level_out( $parent, $page_tree, $args, $depth, $echo );
+}
+$wpsmarty->register_function( "_page_level_out", "smarty__page_level_out" );
+
+/* get_the_author( $idmode = '' ) */
+function smarty_get_the_author( $params, &$smarty )
+{
+ $idmode = '';
+
+ extract( $params );
+ return get_the_author( $idmode );
+}
+$wpsmarty->register_function( "get_the_author", "smarty_get_the_author" );
+
+/* the_author( $idmode = '', $echo = true ) */
+function smarty_the_author( $params, &$smarty )
+{
+ $idmode = '';
+ $echo = true;
+
+ extract( $params );
+ return the_author( $idmode, $echo );
+}
+$wpsmarty->register_function( "the_author", "smarty_the_author" );
+
+/* get_the_author_description( ) */
+function smarty_get_the_author_description( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_description( );
+}
+$wpsmarty->register_function( "get_the_author_description", "smarty_get_the_author_description" );
+
+/* the_author_description( ) */
+function smarty_the_author_description( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_description( );
+}
+$wpsmarty->register_function( "the_author_description", "smarty_the_author_description" );
+
+/* get_the_author_login( ) */
+function smarty_get_the_author_login( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_login( );
+}
+$wpsmarty->register_function( "get_the_author_login", "smarty_get_the_author_login" );
+
+/* the_author_login( ) */
+function smarty_the_author_login( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_login( );
+}
+$wpsmarty->register_function( "the_author_login", "smarty_the_author_login" );
+
+/* get_the_author_firstname( ) */
+function smarty_get_the_author_firstname( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_firstname( );
+}
+$wpsmarty->register_function( "get_the_author_firstname", "smarty_get_the_author_firstname" );
+
+/* the_author_firstname( ) */
+function smarty_the_author_firstname( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_firstname( );
+}
+$wpsmarty->register_function( "the_author_firstname", "smarty_the_author_firstname" );
+
+/* get_the_author_lastname( ) */
+function smarty_get_the_author_lastname( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_lastname( );
+}
+$wpsmarty->register_function( "get_the_author_lastname", "smarty_get_the_author_lastname" );
+
+/* the_author_lastname( ) */
+function smarty_the_author_lastname( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_lastname( );
+}
+$wpsmarty->register_function( "the_author_lastname", "smarty_the_author_lastname" );
+
+/* get_the_author_nickname( ) */
+function smarty_get_the_author_nickname( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_nickname( );
+}
+$wpsmarty->register_function( "get_the_author_nickname", "smarty_get_the_author_nickname" );
+
+/* the_author_nickname( ) */
+function smarty_the_author_nickname( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_nickname( );
+}
+$wpsmarty->register_function( "the_author_nickname", "smarty_the_author_nickname" );
+
+/* get_the_author_ID( ) */
+function smarty_get_the_author_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_ID( );
+}
+$wpsmarty->register_function( "get_the_author_ID", "smarty_get_the_author_ID" );
+
+/* the_author_ID( ) */
+function smarty_the_author_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_ID( );
+}
+$wpsmarty->register_function( "the_author_ID", "smarty_the_author_ID" );
+
+/* get_the_author_email( ) */
+function smarty_get_the_author_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_email( );
+}
+$wpsmarty->register_function( "get_the_author_email", "smarty_get_the_author_email" );
+
+/* the_author_email( ) */
+function smarty_the_author_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_email( );
+}
+$wpsmarty->register_function( "the_author_email", "smarty_the_author_email" );
+
+/* get_the_author_url( ) */
+function smarty_get_the_author_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_url( );
+}
+$wpsmarty->register_function( "get_the_author_url", "smarty_get_the_author_url" );
+
+/* the_author_url( ) */
+function smarty_the_author_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_url( );
+}
+$wpsmarty->register_function( "the_author_url", "smarty_the_author_url" );
+
+/* get_the_author_icq( ) */
+function smarty_get_the_author_icq( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_icq( );
+}
+$wpsmarty->register_function( "get_the_author_icq", "smarty_get_the_author_icq" );
+
+/* the_author_icq( ) */
+function smarty_the_author_icq( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_icq( );
+}
+$wpsmarty->register_function( "the_author_icq", "smarty_the_author_icq" );
+
+/* get_the_author_aim( ) */
+function smarty_get_the_author_aim( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_aim( );
+}
+$wpsmarty->register_function( "get_the_author_aim", "smarty_get_the_author_aim" );
+
+/* the_author_aim( ) */
+function smarty_the_author_aim( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_aim( );
+}
+$wpsmarty->register_function( "the_author_aim", "smarty_the_author_aim" );
+
+/* get_the_author_yim( ) */
+function smarty_get_the_author_yim( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_yim( );
+}
+$wpsmarty->register_function( "get_the_author_yim", "smarty_get_the_author_yim" );
+
+/* the_author_yim( ) */
+function smarty_the_author_yim( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_yim( );
+}
+$wpsmarty->register_function( "the_author_yim", "smarty_the_author_yim" );
+
+/* get_the_author_msn( ) */
+function smarty_get_the_author_msn( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_msn( );
+}
+$wpsmarty->register_function( "get_the_author_msn", "smarty_get_the_author_msn" );
+
+/* the_author_msn( ) */
+function smarty_the_author_msn( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_msn( );
+}
+$wpsmarty->register_function( "the_author_msn", "smarty_the_author_msn" );
+
+/* get_the_author_posts( ) */
+function smarty_get_the_author_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_posts( );
+}
+$wpsmarty->register_function( "get_the_author_posts", "smarty_get_the_author_posts" );
+
+/* the_author_posts( ) */
+function smarty_the_author_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_posts( );
+}
+$wpsmarty->register_function( "the_author_posts", "smarty_the_author_posts" );
+
+/* the_author_posts_link( $idmode='' ) */
+function smarty_the_author_posts_link( $params, &$smarty )
+{
+ $idmode='';
+
+ extract( $params );
+ return the_author_posts_link( $idmode );
+}
+$wpsmarty->register_function( "the_author_posts_link", "smarty_the_author_posts_link" );
+
+/* get_author_link( $echo = false, $author_id, $author_nicename ) */
+function smarty_get_author_link( $params, &$smarty )
+{
+ $echo = false;
+
+ extract( $params );
+ return get_author_link( $echo, $author_id, $author_nicename );
+}
+$wpsmarty->register_function( "get_author_link", "smarty_get_author_link" );
+
+/* wp_list_authors( $args = '' ) */
+function smarty_wp_list_authors( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_list_authors( $args );
+}
+$wpsmarty->register_function( "wp_list_authors", "smarty_wp_list_authors" );
+
+/* list_authors( $optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '' ) */
+function smarty_list_authors( $params, &$smarty )
+{
+ $optioncount = false;
+ $exclude_admin = true;
+ $show_fullname = false;
+ $hide_empty = true;
+ $feed = '';
+ $feed_image = '';
+
+ extract( $params );
+ return list_authors( $optioncount, $exclude_admin, $show_fullname, $hide_empty, $feed, $feed_image );
+}
+$wpsmarty->register_function( "list_authors", "smarty_list_authors" );
+
+/* get_linksbyname( $cat_name = "noname", $before = '', $after = '<br />',
+ $between = " ", $show_images = true, $orderby = 'id',
+ $show_description = true, $show_rating = false,
+ $limit = -1, $show_updated = 0 ) */
+function smarty_get_linksbyname( $params, &$smarty )
+{
+ $cat_name = "noname";
+ $before = '';
+ $after = '<br />';
+ $between = " ";
+ $show_images = true;
+ $orderby = 'id';
+ $show_description = true;
+ $show_rating = false;
+ $limit = -1;
+ $show_updated = 0;
+
+ extract( $params );
+ return get_linksbyname( $cat_name, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated );
+}
+$wpsmarty->register_function( "get_linksbyname", "smarty_get_linksbyname" );
+
+/* bool_from_yn( $yn ) */
+function smarty_bool_from_yn( $params, &$smarty )
+{
+
+ extract( $params );
+ return bool_from_yn( $yn );
+}
+$wpsmarty->register_function( "bool_from_yn", "smarty_bool_from_yn" );
+
+/* wp_get_linksbyname( $category, $args = '' ) */
+function smarty_wp_get_linksbyname( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_get_linksbyname( $category, $args );
+}
+$wpsmarty->register_function( "wp_get_linksbyname", "smarty_wp_get_linksbyname" );
+
+/* wp_get_links( $args = '' ) */
+function smarty_wp_get_links( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_get_links( $args );
+}
+$wpsmarty->register_function( "wp_get_links", "smarty_wp_get_links" );
+
+/* get_links( $category = -1, $before = '', $after = '<br />',
+ $between = ' ', $show_images = true, $orderby = 'name',
+ $show_description = true, $show_rating = false,
+ $limit = -1, $show_updated = 1, $echo = true ) */
+function smarty_get_links( $params, &$smarty )
+{
+ $category = -1;
+ $before = '';
+ $after = '<br />';
+ $between = ' ';
+ $show_images = true;
+ $orderby = 'name';
+ $show_description = true;
+ $show_rating = false;
+ $limit = -1;
+ $show_updated = 1;
+ $echo = true;
+
+ extract( $params );
+ return get_links( $category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo );
+}
+$wpsmarty->register_function( "get_links", "smarty_get_links" );
+
+/* get_linkobjectsbyname( $cat_name = "noname" , $orderby = 'name', $limit = -1 ) */
+function smarty_get_linkobjectsbyname( $params, &$smarty )
+{
+ $cat_name = "noname";
+ $orderby = 'name';
+ $limit = -1;
+
+ extract( $params );
+ return get_linkobjectsbyname( $cat_name, $orderby, $limit );
+}
+$wpsmarty->register_function( "get_linkobjectsbyname", "smarty_get_linkobjectsbyname" );
+
+/* get_linkobjects( $category = -1, $orderby = 'name', $limit = -1 ) */
+function smarty_get_linkobjects( $params, &$smarty )
+{
+ $category = -1;
+ $orderby = 'name';
+ $limit = -1;
+
+ extract( $params );
+ return get_linkobjects( $category, $orderby, $limit );
+}
+$wpsmarty->register_function( "get_linkobjects", "smarty_get_linkobjects" );
+
+/* get_linkrating( $link ) */
+function smarty_get_linkrating( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_linkrating( $link );
+}
+$wpsmarty->register_function( "get_linkrating", "smarty_get_linkrating" );
+
+/* get_linksbyname_withrating( $cat_name = "noname", $before = '',
+ $after = '<br />', $between = " ",
+ $show_images = true, $orderby = 'id',
+ $show_description = true, $limit = -1, $show_updated = 0 ) */
+function smarty_get_linksbyname_withrating( $params, &$smarty )
+{
+ $cat_name = "noname";
+ $before = '';
+ $after = '<br />';
+ $between = " ";
+ $show_images = true;
+ $orderby = 'id';
+ $show_description = true;
+ $limit = -1;
+ $show_updated = 0;
+
+ extract( $params );
+ return get_linksbyname_withrating( $cat_name, $before, $after, $between, $show_images, $orderby, $show_description, $limit, $show_updated );
+}
+$wpsmarty->register_function( "get_linksbyname_withrating", "smarty_get_linksbyname_withrating" );
+
+/* get_links_withrating( $category = -1, $before = '', $after = '<br />',
+ $between = " ", $show_images = true,
+ $orderby = 'id', $show_description = true,
+ $limit = -1, $show_updated = 0 ) */
+function smarty_get_links_withrating( $params, &$smarty )
+{
+ $category = -1;
+ $before = '';
+ $after = '<br />';
+ $between = " ";
+ $show_images = true;
+ $orderby = 'id';
+ $show_description = true;
+ $limit = -1;
+ $show_updated = 0;
+
+ extract( $params );
+ return get_links_withrating( $category, $before, $after, $between, $show_images, $orderby, $show_description, $limit, $show_updated );
+}
+$wpsmarty->register_function( "get_links_withrating", "smarty_get_links_withrating" );
+
+/* get_linkcatname( $id = 0 ) */
+function smarty_get_linkcatname( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return get_linkcatname( $id );
+}
+$wpsmarty->register_function( "get_linkcatname", "smarty_get_linkcatname" );
+
+/* get_autotoggle( $id = 0 ) */
+function smarty_get_autotoggle( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return get_autotoggle( $id );
+}
+$wpsmarty->register_function( "get_autotoggle", "smarty_get_autotoggle" );
+
+/* links_popup_script( $text = 'Links', $width=400, $height=400,
+ $file='links.all.php', $count = true ) */
+function smarty_links_popup_script( $params, &$smarty )
+{
+ $text = 'Links';
+ $width=400;
+ $height=400;
+ $file='links.all.php';
+ $count = true;
+
+ extract( $params );
+ return links_popup_script( $text, $width, $height, $file, $count );
+}
+$wpsmarty->register_function( "links_popup_script", "smarty_links_popup_script" );
+
+/* get_links_list( $order = 'name', $hide_if_empty = 'obsolete' ) */
+function smarty_get_links_list( $params, &$smarty )
+{
+ $order = 'name';
+ $hide_if_empty = 'obsolete';
+
+ extract( $params );
+ return get_links_list( $order, $hide_if_empty );
+}
+$wpsmarty->register_function( "get_links_list", "smarty_get_links_list" );
+
+/* get_profile( $field, $user = false ) */
+function smarty_get_profile( $params, &$smarty )
+{
+ $user = false;
+
+ extract( $params );
+ return get_profile( $field, $user );
+}
+$wpsmarty->register_function( "get_profile", "smarty_get_profile" );
+
+/* mysql2date( $dateformatstring, $mysqlstring, $translate = true ) */
+function smarty_mysql2date( $params, &$smarty )
+{
+ $translate = true;
+
+ extract( $params );
+ return mysql2date( $dateformatstring, $mysqlstring, $translate );
+}
+$wpsmarty->register_function( "mysql2date", "smarty_mysql2date" );
+
+/* current_time( $type, $gmt = 0 ) */
+function smarty_current_time( $params, &$smarty )
+{
+ $gmt = 0;
+
+ extract( $params );
+ return current_time( $type, $gmt );
+}
+$wpsmarty->register_function( "current_time", "smarty_current_time" );
+
+/* date_i18n( $dateformatstring, $unixtimestamp ) */
+function smarty_date_i18n( $params, &$smarty )
+{
+
+ extract( $params );
+ return date_i18n( $dateformatstring, $unixtimestamp );
+}
+$wpsmarty->register_function( "date_i18n", "smarty_date_i18n" );
+
+/* get_weekstartend( $mysqlstring, $start_of_week ) */
+function smarty_get_weekstartend( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_weekstartend( $mysqlstring, $start_of_week );
+}
+$wpsmarty->register_function( "get_weekstartend", "smarty_get_weekstartend" );
+
+/* get_lastpostdate( $timezone = 'server' ) */
+function smarty_get_lastpostdate( $params, &$smarty )
+{
+ $timezone = 'server';
+
+ extract( $params );
+ return get_lastpostdate( $timezone );
+}
+$wpsmarty->register_function( "get_lastpostdate", "smarty_get_lastpostdate" );
+
+/* get_lastpostmodified( $timezone = 'server' ) */
+function smarty_get_lastpostmodified( $params, &$smarty )
+{
+ $timezone = 'server';
+
+ extract( $params );
+ return get_lastpostmodified( $timezone );
+}
+$wpsmarty->register_function( "get_lastpostmodified", "smarty_get_lastpostmodified" );
+
+/* user_pass_ok( $user_login,$user_pass ) */
+function smarty_user_pass_ok( $params, &$smarty )
+{
+
+ extract( $params );
+ return user_pass_ok( $user_login, $user_pass );
+}
+$wpsmarty->register_function( "user_pass_ok", "smarty_user_pass_ok" );
+
+/* get_usernumposts( $userid ) */
+function smarty_get_usernumposts( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_usernumposts( $userid );
+}
+$wpsmarty->register_function( "get_usernumposts", "smarty_get_usernumposts" );
+
+/* url_to_postid( $url ) */
+function smarty_url_to_postid( $params, &$smarty )
+{
+
+ extract( $params );
+ return url_to_postid( $url );
+}
+$wpsmarty->register_function( "url_to_postid", "smarty_url_to_postid" );
+
+/* get_settings( $setting ) */
+function smarty_get_settings( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_settings( $setting );
+}
+$wpsmarty->register_function( "get_settings", "smarty_get_settings" );
+
+/* get_option( $option ) */
+function smarty_get_option( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_option( $option );
+}
+$wpsmarty->register_function( "get_option", "smarty_get_option" );
+
+/* form_option( $option ) */
+function smarty_form_option( $params, &$smarty )
+{
+
+ extract( $params );
+ return form_option( $option );
+}
+$wpsmarty->register_function( "form_option", "smarty_form_option" );
+
+/* get_alloptions( ) */
+function smarty_get_alloptions( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_alloptions( );
+}
+$wpsmarty->register_function( "get_alloptions", "smarty_get_alloptions" );
+
+/* update_option( $option_name, $newvalue ) */
+function smarty_update_option( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_option( $option_name, $newvalue );
+}
+$wpsmarty->register_function( "update_option", "smarty_update_option" );
+
+/* add_option( $name, $value = '', $description = '', $autoload = 'yes' ) */
+function smarty_add_option( $params, &$smarty )
+{
+ $value = '';
+ $description = '';
+ $autoload = 'yes';
+
+ extract( $params );
+ return add_option( $name, $value, $description, $autoload );
+}
+$wpsmarty->register_function( "add_option", "smarty_add_option" );
+
+/* delete_option( $name ) */
+function smarty_delete_option( $params, &$smarty )
+{
+
+ extract( $params );
+ return delete_option( $name );
+}
+$wpsmarty->register_function( "delete_option", "smarty_delete_option" );
+
+/* add_post_meta( $post_id, $key, $value, $unique = false ) */
+function smarty_add_post_meta( $params, &$smarty )
+{
+ $unique = false;
+
+ extract( $params );
+ return add_post_meta( $post_id, $key, $value, $unique );
+}
+$wpsmarty->register_function( "add_post_meta", "smarty_add_post_meta" );
+
+/* delete_post_meta( $post_id, $key, $value = '' ) */
+function smarty_delete_post_meta( $params, &$smarty )
+{
+ $value = '';
+
+ extract( $params );
+ return delete_post_meta( $post_id, $key, $value );
+}
+$wpsmarty->register_function( "delete_post_meta", "smarty_delete_post_meta" );
+
+/* get_post_meta( $post_id, $key, $single = false ) */
+function smarty_get_post_meta( $params, &$smarty )
+{
+ $single = false;
+
+ extract( $params );
+ return get_post_meta( $post_id, $key, $single );
+}
+$wpsmarty->register_function( "get_post_meta", "smarty_get_post_meta" );
+
+/* update_post_meta( $post_id, $key, $value, $prev_value = '' ) */
+function smarty_update_post_meta( $params, &$smarty )
+{
+ $prev_value = '';
+
+ extract( $params );
+ return update_post_meta( $post_id, $key, $value, $prev_value );
+}
+$wpsmarty->register_function( "update_post_meta", "smarty_update_post_meta" );
+
+/* get_postdata( $postid ) */
+function smarty_get_postdata( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_postdata( $postid );
+}
+$wpsmarty->register_function( "get_postdata", "smarty_get_postdata" );
+
+/* &get_post( &$post, $output = OBJECT ) */
+function &smarty_get_post( $params, &$smarty )
+{
+ $output = OBJECT;
+
+ extract( $params );
+ return get_post( &$post, $output );
+}
+$wpsmarty->register_function( "get_post", "smarty_get_post" );
+
+/* &get_page( &$page, $output = OBJECT ) */
+function &smarty_get_page( $params, &$smarty )
+{
+ $output = OBJECT;
+
+ extract( $params );
+ return get_page( &$page, $output );
+}
+$wpsmarty->register_function( "get_page", "smarty_get_page" );
+
+/* &get_category( &$category, $output = OBJECT ) */
+function &smarty_get_category( $params, &$smarty )
+{
+ $output = OBJECT;
+
+ extract( $params );
+ return get_category( &$category, $output );
+}
+$wpsmarty->register_function( "get_category", "smarty_get_category" );
+
+/* &get_comment( &$comment, $output = OBJECT ) */
+function &smarty_get_comment( $params, &$smarty )
+{
+ $output = OBJECT;
+
+ extract( $params );
+ return get_comment( &$comment, $output );
+}
+$wpsmarty->register_function( "get_comment", "smarty_get_comment" );
+
+/* get_catname( $cat_ID ) */
+function smarty_get_catname( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_catname( $cat_ID );
+}
+$wpsmarty->register_function( "get_catname", "smarty_get_catname" );
+
+/* gzip_compression( ) */
+function smarty_gzip_compression( $params, &$smarty )
+{
+
+ extract( $params );
+ return gzip_compression( );
+}
+$wpsmarty->register_function( "gzip_compression", "smarty_gzip_compression" );
+
+/* timer_stop( $display = 0, $precision = 3 ) */
+function smarty_timer_stop( $params, &$smarty )
+{
+ $display = 0;
+ $precision = 3;
+
+ extract( $params );
+ return timer_stop( $display, $precision );
+}
+$wpsmarty->register_function( "timer_stop", "smarty_timer_stop" );
+
+/* weblog_ping( $server = '', $path = '' ) */
+function smarty_weblog_ping( $params, &$smarty )
+{
+ $server = '';
+ $path = '';
+
+ extract( $params );
+ return weblog_ping( $server, $path );
+}
+$wpsmarty->register_function( "weblog_ping", "smarty_weblog_ping" );
+
+/* generic_ping( $post_id = 0 ) */
+function smarty_generic_ping( $params, &$smarty )
+{
+ $post_id = 0;
+
+ extract( $params );
+ return generic_ping( $post_id );
+}
+$wpsmarty->register_function( "generic_ping", "smarty_generic_ping" );
+
+/* trackback( $trackback_url, $title, $excerpt, $ID ) */
+function smarty_trackback( $params, &$smarty )
+{
+
+ extract( $params );
+ return trackback( $trackback_url, $title, $excerpt, $ID );
+}
+$wpsmarty->register_function( "trackback", "smarty_trackback" );
+
+/* make_url_footnote( $content ) */
+function smarty_make_url_footnote( $params, &$smarty )
+{
+
+ extract( $params );
+ return make_url_footnote( $content );
+}
+$wpsmarty->register_function( "make_url_footnote", "smarty_make_url_footnote" );
+
+/* xmlrpc_getposttitle( $content ) */
+function smarty_xmlrpc_getposttitle( $params, &$smarty )
+{
+
+ extract( $params );
+ return xmlrpc_getposttitle( $content );
+}
+$wpsmarty->register_function( "xmlrpc_getposttitle", "smarty_xmlrpc_getposttitle" );
+
+/* xmlrpc_getpostcategory( $content ) */
+function smarty_xmlrpc_getpostcategory( $params, &$smarty )
+{
+
+ extract( $params );
+ return xmlrpc_getpostcategory( $content );
+}
+$wpsmarty->register_function( "xmlrpc_getpostcategory", "smarty_xmlrpc_getpostcategory" );
+
+/* xmlrpc_removepostdata( $content ) */
+function smarty_xmlrpc_removepostdata( $params, &$smarty )
+{
+
+ extract( $params );
+ return xmlrpc_removepostdata( $content );
+}
+$wpsmarty->register_function( "xmlrpc_removepostdata", "smarty_xmlrpc_removepostdata" );
+
+/* debug_fopen( $filename, $mode ) */
+function smarty_debug_fopen( $params, &$smarty )
+{
+
+ extract( $params );
+ return debug_fopen( $filename, $mode );
+}
+$wpsmarty->register_function( "debug_fopen", "smarty_debug_fopen" );
+
+/* debug_fwrite( $fp, $string ) */
+function smarty_debug_fwrite( $params, &$smarty )
+{
+
+ extract( $params );
+ return debug_fwrite( $fp, $string );
+}
+$wpsmarty->register_function( "debug_fwrite", "smarty_debug_fwrite" );
+
+/* debug_fclose( $fp ) */
+function smarty_debug_fclose( $params, &$smarty )
+{
+
+ extract( $params );
+ return debug_fclose( $fp );
+}
+$wpsmarty->register_function( "debug_fclose", "smarty_debug_fclose" );
+
+/* do_enclose( $content, $post_ID ) */
+function smarty_do_enclose( $params, &$smarty )
+{
+
+ extract( $params );
+ return do_enclose( $content, $post_ID );
+}
+$wpsmarty->register_function( "do_enclose", "smarty_do_enclose" );
+
+/* wp_get_http_headers( $url ) */
+function smarty_wp_get_http_headers( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_get_http_headers( $url );
+}
+$wpsmarty->register_function( "wp_get_http_headers", "smarty_wp_get_http_headers" );
+
+/* start_wp( ) */
+function smarty_start_wp( $params, &$smarty )
+{
+
+ extract( $params );
+ return start_wp( );
+}
+$wpsmarty->register_function( "start_wp", "smarty_start_wp" );
+
+/* setup_postdata( $post ) */
+function smarty_setup_postdata( $params, &$smarty )
+{
+
+ extract( $params );
+ return setup_postdata( $post );
+}
+$wpsmarty->register_function( "setup_postdata", "smarty_setup_postdata" );
+
+/* is_new_day( ) */
+function smarty_is_new_day( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_new_day( );
+}
+$wpsmarty->register_function( "is_new_day", "smarty_is_new_day" );
+
+/* merge_filters( $tag ) */
+function smarty_merge_filters( $params, &$smarty )
+{
+
+ extract( $params );
+ return merge_filters( $tag );
+}
+$wpsmarty->register_function( "merge_filters", "smarty_merge_filters" );
+
+/* apply_filters( $tag, $string ) */
+function smarty_apply_filters( $params, &$smarty )
+{
+
+ extract( $params );
+ return apply_filters( $tag, $string );
+}
+$wpsmarty->register_function( "apply_filters", "smarty_apply_filters" );
+
+/* add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) */
+function smarty_add_filter( $params, &$smarty )
+{
+ $priority = 10;
+ $accepted_args = 1;
+
+ extract( $params );
+ return add_filter( $tag, $function_to_add, $priority, $accepted_args );
+}
+$wpsmarty->register_function( "add_filter", "smarty_add_filter" );
+
+/* remove_filter( $tag, $function_to_remove, $priority = 10, $accepted_args = 1 ) */
+function smarty_remove_filter( $params, &$smarty )
+{
+ $priority = 10;
+ $accepted_args = 1;
+
+ extract( $params );
+ return remove_filter( $tag, $function_to_remove, $priority, $accepted_args );
+}
+$wpsmarty->register_function( "remove_filter", "smarty_remove_filter" );
+
+/* do_action( $tag, $arg = '' ) */
+function smarty_do_action( $params, &$smarty )
+{
+ $arg = '';
+
+ extract( $params );
+ return do_action( $tag, $arg );
+}
+$wpsmarty->register_function( "do_action", "smarty_do_action" );
+
+/* add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) */
+function smarty_add_action( $params, &$smarty )
+{
+ $priority = 10;
+ $accepted_args = 1;
+
+ extract( $params );
+ return add_action( $tag, $function_to_add, $priority, $accepted_args );
+}
+$wpsmarty->register_function( "add_action", "smarty_add_action" );
+
+/* remove_action( $tag, $function_to_remove, $priority = 10, $accepted_args = 1 ) */
+function smarty_remove_action( $params, &$smarty )
+{
+ $priority = 10;
+ $accepted_args = 1;
+
+ extract( $params );
+ return remove_action( $tag, $function_to_remove, $priority, $accepted_args );
+}
+$wpsmarty->register_function( "remove_action", "smarty_remove_action" );
+
+/* get_page_uri( $page_id ) */
+function smarty_get_page_uri( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_page_uri( $page_id );
+}
+$wpsmarty->register_function( "get_page_uri", "smarty_get_page_uri" );
+
+/* get_posts( $args ) */
+function smarty_get_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_posts( $args );
+}
+$wpsmarty->register_function( "get_posts", "smarty_get_posts" );
+
+/* &query_posts( $query ) */
+function &smarty_query_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return query_posts( $query );
+}
+$wpsmarty->register_function( "query_posts", "smarty_query_posts" );
+
+/* update_post_cache( &$posts ) */
+function smarty_update_post_cache( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_post_cache( &$posts );
+}
+$wpsmarty->register_function( "update_post_cache", "smarty_update_post_cache" );
+
+/* update_page_cache( &$pages ) */
+function smarty_update_page_cache( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_page_cache( &$pages );
+}
+$wpsmarty->register_function( "update_page_cache", "smarty_update_page_cache" );
+
+/* update_post_category_cache( $post_ids ) */
+function smarty_update_post_category_cache( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_post_category_cache( $post_ids );
+}
+$wpsmarty->register_function( "update_post_category_cache", "smarty_update_post_category_cache" );
+
+/* update_post_caches( &$posts ) */
+function smarty_update_post_caches( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_post_caches( &$posts );
+}
+$wpsmarty->register_function( "update_post_caches", "smarty_update_post_caches" );
+
+/* update_category_cache( ) */
+function smarty_update_category_cache( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_category_cache( );
+}
+$wpsmarty->register_function( "update_category_cache", "smarty_update_category_cache" );
+
+/* wp_head( ) */
+function smarty_wp_head( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_head( );
+}
+$wpsmarty->register_function( "wp_head", "smarty_wp_head" );
+
+/* wp_footer( ) */
+function smarty_wp_footer( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_footer( );
+}
+$wpsmarty->register_function( "wp_footer", "smarty_wp_footer" );
+
+/* is_single ( $post = '' ) */
+function smarty_is_single ( $params, &$smarty )
+{
+ $post = '';
+
+ extract( $params );
+ return is_single ( $post );
+}
+$wpsmarty->register_function( "is_single ", "smarty_is_single " );
+
+/* is_page ( $page = '' ) */
+function smarty_is_page ( $params, &$smarty )
+{
+ $page = '';
+
+ extract( $params );
+ return is_page ( $page );
+}
+$wpsmarty->register_function( "is_page ", "smarty_is_page " );
+
+/* is_archive ( ) */
+function smarty_is_archive ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_archive ( );
+}
+$wpsmarty->register_function( "is_archive ", "smarty_is_archive " );
+
+/* is_date ( ) */
+function smarty_is_date ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_date ( );
+}
+$wpsmarty->register_function( "is_date ", "smarty_is_date " );
+
+/* is_year ( ) */
+function smarty_is_year ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_year ( );
+}
+$wpsmarty->register_function( "is_year ", "smarty_is_year " );
+
+/* is_month ( ) */
+function smarty_is_month ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_month ( );
+}
+$wpsmarty->register_function( "is_month ", "smarty_is_month " );
+
+/* is_day ( ) */
+function smarty_is_day ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_day ( );
+}
+$wpsmarty->register_function( "is_day ", "smarty_is_day " );
+
+/* is_time ( ) */
+function smarty_is_time ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_time ( );
+}
+$wpsmarty->register_function( "is_time ", "smarty_is_time " );
+
+/* is_author ( $author = '' ) */
+function smarty_is_author ( $params, &$smarty )
+{
+ $author = '';
+
+ extract( $params );
+ return is_author ( $author );
+}
+$wpsmarty->register_function( "is_author ", "smarty_is_author " );
+
+/* is_category ( $category = '' ) */
+function smarty_is_category ( $params, &$smarty )
+{
+ $category = '';
+
+ extract( $params );
+ return is_category ( $category );
+}
+$wpsmarty->register_function( "is_category ", "smarty_is_category " );
+
+/* is_search ( ) */
+function smarty_is_search ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_search ( );
+}
+$wpsmarty->register_function( "is_search ", "smarty_is_search " );
+
+/* is_feed ( ) */
+function smarty_is_feed ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_feed ( );
+}
+$wpsmarty->register_function( "is_feed ", "smarty_is_feed " );
+
+/* is_trackback ( ) */
+function smarty_is_trackback ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_trackback ( );
+}
+$wpsmarty->register_function( "is_trackback ", "smarty_is_trackback " );
+
+/* is_admin ( ) */
+function smarty_is_admin ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_admin ( );
+}
+$wpsmarty->register_function( "is_admin ", "smarty_is_admin " );
+
+/* is_home ( ) */
+function smarty_is_home ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_home ( );
+}
+$wpsmarty->register_function( "is_home ", "smarty_is_home " );
+
+/* is_404 ( ) */
+function smarty_is_404 ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_404 ( );
+}
+$wpsmarty->register_function( "is_404 ", "smarty_is_404 " );
+
+/* is_comments_popup ( ) */
+function smarty_is_comments_popup ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_comments_popup ( );
+}
+$wpsmarty->register_function( "is_comments_popup ", "smarty_is_comments_popup " );
+
+/* is_paged ( ) */
+function smarty_is_paged ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_paged ( );
+}
+$wpsmarty->register_function( "is_paged ", "smarty_is_paged " );
+
+/* get_query_var( $var ) */
+function smarty_get_query_var( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_query_var( $var );
+}
+$wpsmarty->register_function( "get_query_var", "smarty_get_query_var" );
+
+/* have_posts( ) */
+function smarty_have_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return have_posts( );
+}
+$wpsmarty->register_function( "have_posts", "smarty_have_posts" );
+
+/* rewind_posts( ) */
+function smarty_rewind_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return rewind_posts( );
+}
+$wpsmarty->register_function( "rewind_posts", "smarty_rewind_posts" );
+
+/* the_post( ) */
+function smarty_the_post( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_post( );
+}
+$wpsmarty->register_function( "the_post", "smarty_the_post" );
+
+/* get_theme_root( ) */
+function smarty_get_theme_root( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_theme_root( );
+}
+$wpsmarty->register_function( "get_theme_root", "smarty_get_theme_root" );
+
+/* get_theme_root_uri( ) */
+function smarty_get_theme_root_uri( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_theme_root_uri( );
+}
+$wpsmarty->register_function( "get_theme_root_uri", "smarty_get_theme_root_uri" );
+
+/* get_stylesheet( ) */
+function smarty_get_stylesheet( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_stylesheet( );
+}
+$wpsmarty->register_function( "get_stylesheet", "smarty_get_stylesheet" );
+
+/* get_stylesheet_directory( ) */
+function smarty_get_stylesheet_directory( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_stylesheet_directory( );
+}
+$wpsmarty->register_function( "get_stylesheet_directory", "smarty_get_stylesheet_directory" );
+
+/* get_stylesheet_directory_uri( ) */
+function smarty_get_stylesheet_directory_uri( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_stylesheet_directory_uri( );
+}
+$wpsmarty->register_function( "get_stylesheet_directory_uri", "smarty_get_stylesheet_directory_uri" );
+
+/* get_stylesheet_uri( ) */
+function smarty_get_stylesheet_uri( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_stylesheet_uri( );
+}
+$wpsmarty->register_function( "get_stylesheet_uri", "smarty_get_stylesheet_uri" );
+
+/* get_template( ) */
+function smarty_get_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_template( );
+}
+$wpsmarty->register_function( "get_template", "smarty_get_template" );
+
+/* get_template_directory( ) */
+function smarty_get_template_directory( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_template_directory( );
+}
+$wpsmarty->register_function( "get_template_directory", "smarty_get_template_directory" );
+
+/* get_template_directory_uri( ) */
+function smarty_get_template_directory_uri( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_template_directory_uri( );
+}
+$wpsmarty->register_function( "get_template_directory_uri", "smarty_get_template_directory_uri" );
+
+/* get_theme_data( $theme_file ) */
+function smarty_get_theme_data( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_theme_data( $theme_file );
+}
+$wpsmarty->register_function( "get_theme_data", "smarty_get_theme_data" );
+
+/* get_themes( ) */
+function smarty_get_themes( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_themes( );
+}
+$wpsmarty->register_function( "get_themes", "smarty_get_themes" );
+
+/* get_theme( $theme ) */
+function smarty_get_theme( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_theme( $theme );
+}
+$wpsmarty->register_function( "get_theme", "smarty_get_theme" );
+
+/* get_current_theme( ) */
+function smarty_get_current_theme( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_current_theme( );
+}
+$wpsmarty->register_function( "get_current_theme", "smarty_get_current_theme" );
+
+/* get_query_template( $type ) */
+function smarty_get_query_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_query_template( $type );
+}
+$wpsmarty->register_function( "get_query_template", "smarty_get_query_template" );
+
+/* get_404_template( ) */
+function smarty_get_404_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_404_template( );
+}
+$wpsmarty->register_function( "get_404_template", "smarty_get_404_template" );
+
+/* get_archive_template( ) */
+function smarty_get_archive_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_archive_template( );
+}
+$wpsmarty->register_function( "get_archive_template", "smarty_get_archive_template" );
+
+/* get_author_template( ) */
+function smarty_get_author_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_author_template( );
+}
+$wpsmarty->register_function( "get_author_template", "smarty_get_author_template" );
+
+/* get_category_template( ) */
+function smarty_get_category_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_category_template( );
+}
+$wpsmarty->register_function( "get_category_template", "smarty_get_category_template" );
+
+/* get_date_template( ) */
+function smarty_get_date_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_date_template( );
+}
+$wpsmarty->register_function( "get_date_template", "smarty_get_date_template" );
+
+/* get_home_template( ) */
+function smarty_get_home_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_home_template( );
+}
+$wpsmarty->register_function( "get_home_template", "smarty_get_home_template" );
+
+/* get_page_template( ) */
+function smarty_get_page_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_page_template( );
+}
+$wpsmarty->register_function( "get_page_template", "smarty_get_page_template" );
+
+/* get_paged_template( ) */
+function smarty_get_paged_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_paged_template( );
+}
+$wpsmarty->register_function( "get_paged_template", "smarty_get_paged_template" );
+
+/* get_search_template( ) */
+function smarty_get_search_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_search_template( );
+}
+$wpsmarty->register_function( "get_search_template", "smarty_get_search_template" );
+
+/* get_single_template( ) */
+function smarty_get_single_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_single_template( );
+}
+$wpsmarty->register_function( "get_single_template", "smarty_get_single_template" );
+
+/* get_comments_popup_template( ) */
+function smarty_get_comments_popup_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comments_popup_template( );
+}
+$wpsmarty->register_function( "get_comments_popup_template", "smarty_get_comments_popup_template" );
+
+/* htmlentities2( $myHTML ) */
+function smarty_htmlentities2( $params, &$smarty )
+{
+
+ extract( $params );
+ return htmlentities2( $myHTML );
+}
+$wpsmarty->register_function( "htmlentities2", "smarty_htmlentities2" );
+
+/* is_plugin_page( ) */
+function smarty_is_plugin_page( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_plugin_page( );
+}
+$wpsmarty->register_function( "is_plugin_page", "smarty_is_plugin_page" );
+
+/* add_query_arg( ) */
+function smarty_add_query_arg( $params, &$smarty )
+{
+
+ extract( $params );
+ return add_query_arg( );
+}
+$wpsmarty->register_function( "add_query_arg", "smarty_add_query_arg" );
+
+/* remove_query_arg( $key, $query ) */
+function smarty_remove_query_arg( $params, &$smarty )
+{
+
+ extract( $params );
+ return remove_query_arg( $key, $query );
+}
+$wpsmarty->register_function( "remove_query_arg", "smarty_remove_query_arg" );
+
+/* load_template( $file ) */
+function smarty_load_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return load_template( $file );
+}
+$wpsmarty->register_function( "load_template", "smarty_load_template" );
+
+/* add_magic_quotes( $array ) */
+function smarty_add_magic_quotes( $params, &$smarty )
+{
+
+ extract( $params );
+ return add_magic_quotes( $array );
+}
+$wpsmarty->register_function( "add_magic_quotes", "smarty_add_magic_quotes" );
+
+/* wp_remote_fopen( $uri ) */
+function smarty_wp_remote_fopen( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_remote_fopen( $uri );
+}
+$wpsmarty->register_function( "wp_remote_fopen", "smarty_wp_remote_fopen" );
+
+/* wp( $query_vars = '' ) */
+function smarty_wp( $params, &$smarty )
+{
+ $query_vars = '';
+
+ extract( $params );
+ return wp( $query_vars );
+}
+$wpsmarty->register_function( "wp", "smarty_wp" );
+
+/* status_header( $header ) */
+function smarty_status_header( $params, &$smarty )
+{
+
+ extract( $params );
+ return status_header( $header );
+}
+$wpsmarty->register_function( "status_header", "smarty_status_header" );
+
+/* nocache_headers( ) */
+function smarty_nocache_headers( $params, &$smarty )
+{
+
+ extract( $params );
+ return nocache_headers( );
+}
+$wpsmarty->register_function( "nocache_headers", "smarty_nocache_headers" );
+
+/* get_usermeta( $user_id, $meta_key = '' ) */
+function smarty_get_usermeta( $params, &$smarty )
+{
+ $meta_key = '';
+
+ extract( $params );
+ return get_usermeta( $user_id, $meta_key );
+}
+$wpsmarty->register_function( "get_usermeta", "smarty_get_usermeta" );
+
+/* update_usermeta( $user_id, $meta_key, $meta_value ) */
+function smarty_update_usermeta( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_usermeta( $user_id, $meta_key, $meta_value );
+}
+$wpsmarty->register_function( "update_usermeta", "smarty_update_usermeta" );
+
+/* register_activation_hook( $file, $function ) */
+function smarty_register_activation_hook( $params, &$smarty )
+{
+
+ extract( $params );
+ return register_activation_hook( $file, $function );
+}
+$wpsmarty->register_function( "register_activation_hook", "smarty_register_activation_hook" );
+
+/* register_deactivation_hook( $file, $function ) */
+function smarty_register_deactivation_hook( $params, &$smarty )
+{
+
+ extract( $params );
+ return register_deactivation_hook( $file, $function );
+}
+$wpsmarty->register_function( "register_deactivation_hook", "smarty_register_deactivation_hook" );
+
+/* plugin_basename( $file ) */
+function smarty_plugin_basename( $params, &$smarty )
+{
+
+ extract( $params );
+ return plugin_basename( $file );
+}
+$wpsmarty->register_function( "plugin_basename", "smarty_plugin_basename" );
+
+/* get_locale( ) */
+function smarty_get_locale( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_locale( );
+}
+$wpsmarty->register_function( "get_locale", "smarty_get_locale" );
+
+/* __( $text, $domain = 'default' ) */
+function smarty___( $params, &$smarty )
+{
+ $domain = 'default';
+
+ extract( $params );
+ return __( $text, $domain );
+}
+$wpsmarty->register_function( "__", "smarty___" );
+
+/* _e( $text, $domain = 'default' ) */
+function smarty__e( $params, &$smarty )
+{
+ $domain = 'default';
+
+ extract( $params );
+ return _e( $text, $domain );
+}
+$wpsmarty->register_function( "_e", "smarty__e" );
+
+/* __ngettext( $single, $plural, $number, $domain = 'default' ) */
+function smarty___ngettext( $params, &$smarty )
+{
+ $domain = 'default';
+
+ extract( $params );
+ return __ngettext( $single, $plural, $number, $domain );
+}
+$wpsmarty->register_function( "__ngettext", "smarty___ngettext" );
+
+/* load_textdomain( $domain, $mofile ) */
+function smarty_load_textdomain( $params, &$smarty )
+{
+
+ extract( $params );
+ return load_textdomain( $domain, $mofile );
+}
+$wpsmarty->register_function( "load_textdomain", "smarty_load_textdomain" );
+
+/* load_default_textdomain( ) */
+function smarty_load_default_textdomain( $params, &$smarty )
+{
+
+ extract( $params );
+ return load_default_textdomain( );
+}
+$wpsmarty->register_function( "load_default_textdomain", "smarty_load_default_textdomain" );
+
+/* load_plugin_textdomain( $domain ) */
+function smarty_load_plugin_textdomain( $params, &$smarty )
+{
+
+ extract( $params );
+ return load_plugin_textdomain( $domain );
+}
+$wpsmarty->register_function( "load_plugin_textdomain", "smarty_load_plugin_textdomain" );
+
+/* load_theme_textdomain( $domain ) */
+function smarty_load_theme_textdomain( $params, &$smarty )
+{
+
+ extract( $params );
+ return load_theme_textdomain( $domain );
+}
+$wpsmarty->register_function( "load_theme_textdomain", "smarty_load_theme_textdomain" );
+
+/* wptexturize( $text ) */
+function smarty_wptexturize( $params, &$smarty )
+{
+
+ extract( $params );
+ return wptexturize( $text );
+}
+$wpsmarty->register_function( "wptexturize", "smarty_wptexturize" );
+
+/* clean_pre( $text ) */
+function smarty_clean_pre( $params, &$smarty )
+{
+
+ extract( $params );
+ return clean_pre( $text );
+}
+$wpsmarty->register_function( "clean_pre", "smarty_clean_pre" );
+
+/* wpautop( $pee, $br = 1 ) */
+function smarty_wpautop( $params, &$smarty )
+{
+ $br = 1;
+
+ extract( $params );
+ return wpautop( $pee, $br );
+}
+$wpsmarty->register_function( "wpautop", "smarty_wpautop" );
+
+/* seems_utf8( $Str ) */
+function smarty_seems_utf8( $params, &$smarty )
+{
+
+ extract( $params );
+ return seems_utf8( $Str );
+}
+$wpsmarty->register_function( "seems_utf8", "smarty_seems_utf8" );
+
+/* wp_specialchars( $text, $quotes = 0 ) */
+function smarty_wp_specialchars( $params, &$smarty )
+{
+ $quotes = 0;
+
+ extract( $params );
+ return wp_specialchars( $text, $quotes );
+}
+$wpsmarty->register_function( "wp_specialchars", "smarty_wp_specialchars" );
+
+/* utf8_uri_encode( $utf8_string ) */
+function smarty_utf8_uri_encode( $params, &$smarty )
+{
+
+ extract( $params );
+ return utf8_uri_encode( $utf8_string );
+}
+$wpsmarty->register_function( "utf8_uri_encode", "smarty_utf8_uri_encode" );
+
+/* remove_accents( $string ) */
+function smarty_remove_accents( $params, &$smarty )
+{
+
+ extract( $params );
+ return remove_accents( $string );
+}
+$wpsmarty->register_function( "remove_accents", "smarty_remove_accents" );
+
+/* sanitize_user( $username ) */
+function smarty_sanitize_user( $params, &$smarty )
+{
+
+ extract( $params );
+ return sanitize_user( $username );
+}
+$wpsmarty->register_function( "sanitize_user", "smarty_sanitize_user" );
+
+/* sanitize_title( $title, $fallback_title = '' ) */
+function smarty_sanitize_title( $params, &$smarty )
+{
+ $fallback_title = '';
+
+ extract( $params );
+ return sanitize_title( $title, $fallback_title );
+}
+$wpsmarty->register_function( "sanitize_title", "smarty_sanitize_title" );
+
+/* sanitize_title_with_dashes( $title ) */
+function smarty_sanitize_title_with_dashes( $params, &$smarty )
+{
+
+ extract( $params );
+ return sanitize_title_with_dashes( $title );
+}
+$wpsmarty->register_function( "sanitize_title_with_dashes", "smarty_sanitize_title_with_dashes" );
+
+/* convert_chars( $content, $flag = 'obsolete' ) */
+function smarty_convert_chars( $params, &$smarty )
+{
+ $flag = 'obsolete';
+
+ extract( $params );
+ return convert_chars( $content, $flag );
+}
+$wpsmarty->register_function( "convert_chars", "smarty_convert_chars" );
+
+/* funky_javascript_fix( $text ) */
+function smarty_funky_javascript_fix( $params, &$smarty )
+{
+
+ extract( $params );
+ return funky_javascript_fix( $text );
+}
+$wpsmarty->register_function( "funky_javascript_fix", "smarty_funky_javascript_fix" );
+
+/* balanceTags( $text, $is_comment = 0 ) */
+function smarty_balanceTags( $params, &$smarty )
+{
+ $is_comment = 0;
+
+ extract( $params );
+ return balanceTags( $text, $is_comment );
+}
+$wpsmarty->register_function( "balanceTags", "smarty_balanceTags" );
+
+/* format_to_edit( $content ) */
+function smarty_format_to_edit( $params, &$smarty )
+{
+
+ extract( $params );
+ return format_to_edit( $content );
+}
+$wpsmarty->register_function( "format_to_edit", "smarty_format_to_edit" );
+
+/* format_to_post( $content ) */
+function smarty_format_to_post( $params, &$smarty )
+{
+
+ extract( $params );
+ return format_to_post( $content );
+}
+$wpsmarty->register_function( "format_to_post", "smarty_format_to_post" );
+
+/* zeroise( $number,$threshold ) */
+function smarty_zeroise( $params, &$smarty )
+{
+
+ extract( $params );
+ return zeroise( $number, $threshold );
+}
+$wpsmarty->register_function( "zeroise", "smarty_zeroise" );
+
+/* backslashit( $string ) */
+function smarty_backslashit( $params, &$smarty )
+{
+
+ extract( $params );
+ return backslashit( $string );
+}
+$wpsmarty->register_function( "backslashit", "smarty_backslashit" );
+
+/* trailingslashit( $string ) */
+function smarty_trailingslashit( $params, &$smarty )
+{
+
+ extract( $params );
+ return trailingslashit( $string );
+}
+$wpsmarty->register_function( "trailingslashit", "smarty_trailingslashit" );
+
+/* addslashes_gpc( $gpc ) */
+function smarty_addslashes_gpc( $params, &$smarty )
+{
+
+ extract( $params );
+ return addslashes_gpc( $gpc );
+}
+$wpsmarty->register_function( "addslashes_gpc", "smarty_addslashes_gpc" );
+
+/* stripslashes_deep( ) */
+function smarty_stripslashes_deep( $params, &$smarty )
+{
+
+ extract( $params );
+ return stripslashes_deep( );
+}
+$wpsmarty->register_function( "stripslashes_deep", "smarty_stripslashes_deep" );
+
+/* antispambot( $emailaddy, $mailto=0 ) */
+function smarty_antispambot( $params, &$smarty )
+{
+ $mailto=0;
+
+ extract( $params );
+ return antispambot( $emailaddy, $mailto );
+}
+$wpsmarty->register_function( "antispambot", "smarty_antispambot" );
+
+/* make_clickable( $ret ) */
+function smarty_make_clickable( $params, &$smarty )
+{
+
+ extract( $params );
+ return make_clickable( $ret );
+}
+$wpsmarty->register_function( "make_clickable", "smarty_make_clickable" );
+
+/* wp_rel_nofollow( $text ) */
+function smarty_wp_rel_nofollow( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_rel_nofollow( $text );
+}
+$wpsmarty->register_function( "wp_rel_nofollow", "smarty_wp_rel_nofollow" );
+
+/* convert_smilies( $text ) */
+function smarty_convert_smilies( $params, &$smarty )
+{
+
+ extract( $params );
+ return convert_smilies( $text );
+}
+$wpsmarty->register_function( "convert_smilies", "smarty_convert_smilies" );
+
+/* is_email( $user_email ) */
+function smarty_is_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_email( $user_email );
+}
+$wpsmarty->register_function( "is_email", "smarty_is_email" );
+
+/* wp_iso_descrambler( $string ) */
+function smarty_wp_iso_descrambler( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_iso_descrambler( $string );
+}
+$wpsmarty->register_function( "wp_iso_descrambler", "smarty_wp_iso_descrambler" );
+
+/* get_gmt_from_date( $string ) */
+function smarty_get_gmt_from_date( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_gmt_from_date( $string );
+}
+$wpsmarty->register_function( "get_gmt_from_date", "smarty_get_gmt_from_date" );
+
+/* get_date_from_gmt( $string ) */
+function smarty_get_date_from_gmt( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_date_from_gmt( $string );
+}
+$wpsmarty->register_function( "get_date_from_gmt", "smarty_get_date_from_gmt" );
+
+/* iso8601_timezone_to_offset( $timezone ) */
+function smarty_iso8601_timezone_to_offset( $params, &$smarty )
+{
+
+ extract( $params );
+ return iso8601_timezone_to_offset( $timezone );
+}
+$wpsmarty->register_function( "iso8601_timezone_to_offset", "smarty_iso8601_timezone_to_offset" );
+
+/* iso8601_to_datetime( $date_string, $timezone = USER ) */
+function smarty_iso8601_to_datetime( $params, &$smarty )
+{
+ $timezone = USER;
+
+ extract( $params );
+ return iso8601_to_datetime( $date_string, $timezone );
+}
+$wpsmarty->register_function( "iso8601_to_datetime", "smarty_iso8601_to_datetime" );
+
+/* popuplinks( $text ) */
+function smarty_popuplinks( $params, &$smarty )
+{
+
+ extract( $params );
+ return popuplinks( $text );
+}
+$wpsmarty->register_function( "popuplinks", "smarty_popuplinks" );
+
+/* sanitize_email( $email ) */
+function smarty_sanitize_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return sanitize_email( $email );
+}
+$wpsmarty->register_function( "sanitize_email", "smarty_sanitize_email" );
+
+/* human_time_diff( $from, $to = '' ) */
+function smarty_human_time_diff( $params, &$smarty )
+{
+ $to = '';
+
+ extract( $params );
+ return human_time_diff( $from, $to );
+}
+$wpsmarty->register_function( "human_time_diff", "smarty_human_time_diff" );
+
+/* wp_trim_excerpt( $text ) */
+function smarty_wp_trim_excerpt( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_trim_excerpt( $text );
+}
+$wpsmarty->register_function( "wp_trim_excerpt", "smarty_wp_trim_excerpt" );
+
+/* ent2ncr( $text ) */
+function smarty_ent2ncr( $params, &$smarty )
+{
+
+ extract( $params );
+ return ent2ncr( $text );
+}
+$wpsmarty->register_function( "ent2ncr", "smarty_ent2ncr" );
+
+/* wp_insert_post( $postarr = array() ) */
+function smarty_wp_insert_post( $params, &$smarty )
+{
+ $postarr = array();
+
+ extract( $params );
+ return wp_insert_post( $postarr );
+}
+$wpsmarty->register_function( "wp_insert_post", "smarty_wp_insert_post" );
+
+/* wp_get_single_post( $postid = 0, $mode = OBJECT ) */
+function smarty_wp_get_single_post( $params, &$smarty )
+{
+ $postid = 0;
+ $mode = OBJECT;
+
+ extract( $params );
+ return wp_get_single_post( $postid, $mode );
+}
+$wpsmarty->register_function( "wp_get_single_post", "smarty_wp_get_single_post" );
+
+/* wp_get_recent_posts( $num = 10 ) */
+function smarty_wp_get_recent_posts( $params, &$smarty )
+{
+ $num = 10;
+
+ extract( $params );
+ return wp_get_recent_posts( $num );
+}
+$wpsmarty->register_function( "wp_get_recent_posts", "smarty_wp_get_recent_posts" );
+
+/* wp_update_post( $postarr = array() ) */
+function smarty_wp_update_post( $params, &$smarty )
+{
+ $postarr = array();
+
+ extract( $params );
+ return wp_update_post( $postarr );
+}
+$wpsmarty->register_function( "wp_update_post", "smarty_wp_update_post" );
+
+/* wp_get_post_cats( $blogid = '1', $post_ID = 0 ) */
+function smarty_wp_get_post_cats( $params, &$smarty )
+{
+ $blogid = '1';
+ $post_ID = 0;
+
+ extract( $params );
+ return wp_get_post_cats( $blogid, $post_ID );
+}
+$wpsmarty->register_function( "wp_get_post_cats", "smarty_wp_get_post_cats" );
+
+/* wp_set_post_cats( $blogid = '1', $post_ID = 0, $post_categories = array() ) */
+function smarty_wp_set_post_cats( $params, &$smarty )
+{
+ $blogid = '1';
+ $post_ID = 0;
+ $post_categories = array();
+
+ extract( $params );
+ return wp_set_post_cats( $blogid, $post_ID, $post_categories );
+}
+$wpsmarty->register_function( "wp_set_post_cats", "smarty_wp_set_post_cats" );
+
+/* wp_delete_post( $postid = 0 ) */
+function smarty_wp_delete_post( $params, &$smarty )
+{
+ $postid = 0;
+
+ extract( $params );
+ return wp_delete_post( $postid );
+}
+$wpsmarty->register_function( "wp_delete_post", "smarty_wp_delete_post" );
+
+/* post_permalink( $post_id = 0, $mode = '' ) */
+function smarty_post_permalink( $params, &$smarty )
+{
+ $post_id = 0;
+ $mode = '';
+
+ extract( $params );
+ return post_permalink( $post_id, $mode );
+}
+$wpsmarty->register_function( "post_permalink", "smarty_post_permalink" );
+
+/* get_cat_name( $cat_id ) */
+function smarty_get_cat_name( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_cat_name( $cat_id );
+}
+$wpsmarty->register_function( "get_cat_name", "smarty_get_cat_name" );
+
+/* get_cat_ID( $cat_name='General' ) */
+function smarty_get_cat_ID( $params, &$smarty )
+{
+ $cat_name='General';
+
+ extract( $params );
+ return get_cat_ID( $cat_name );
+}
+$wpsmarty->register_function( "get_cat_ID", "smarty_get_cat_ID" );
+
+/* get_author_name( $auth_id ) */
+function smarty_get_author_name( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_author_name( $auth_id );
+}
+$wpsmarty->register_function( "get_author_name", "smarty_get_author_name" );
+
+/* get_extended( $post ) */
+function smarty_get_extended( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_extended( $post );
+}
+$wpsmarty->register_function( "get_extended", "smarty_get_extended" );
+
+/* trackback_url_list( $tb_list, $post_id ) */
+function smarty_trackback_url_list( $params, &$smarty )
+{
+
+ extract( $params );
+ return trackback_url_list( $tb_list, $post_id );
+}
+$wpsmarty->register_function( "trackback_url_list", "smarty_trackback_url_list" );
+
+/* user_can_create_post( $user_id, $blog_id = 1, $category_id = 'None' ) */
+function smarty_user_can_create_post( $params, &$smarty )
+{
+ $blog_id = 1;
+ $category_id = 'None';
+
+ extract( $params );
+ return user_can_create_post( $user_id, $blog_id, $category_id );
+}
+$wpsmarty->register_function( "user_can_create_post", "smarty_user_can_create_post" );
+
+/* user_can_create_draft( $user_id, $blog_id = 1, $category_id = 'None' ) */
+function smarty_user_can_create_draft( $params, &$smarty )
+{
+ $blog_id = 1;
+ $category_id = 'None';
+
+ extract( $params );
+ return user_can_create_draft( $user_id, $blog_id, $category_id );
+}
+$wpsmarty->register_function( "user_can_create_draft", "smarty_user_can_create_draft" );
+
+/* user_can_edit_post( $user_id, $post_id, $blog_id = 1 ) */
+function smarty_user_can_edit_post( $params, &$smarty )
+{
+ $blog_id = 1;
+
+ extract( $params );
+ return user_can_edit_post( $user_id, $post_id, $blog_id );
+}
+$wpsmarty->register_function( "user_can_edit_post", "smarty_user_can_edit_post" );
+
+/* user_can_delete_post( $user_id, $post_id, $blog_id = 1 ) */
+function smarty_user_can_delete_post( $params, &$smarty )
+{
+ $blog_id = 1;
+
+ extract( $params );
+ return user_can_delete_post( $user_id, $post_id, $blog_id );
+}
+$wpsmarty->register_function( "user_can_delete_post", "smarty_user_can_delete_post" );
+
+/* user_can_set_post_date( $user_id, $blog_id = 1, $category_id = 'None' ) */
+function smarty_user_can_set_post_date( $params, &$smarty )
+{
+ $blog_id = 1;
+ $category_id = 'None';
+
+ extract( $params );
+ return user_can_set_post_date( $user_id, $blog_id, $category_id );
+}
+$wpsmarty->register_function( "user_can_set_post_date", "smarty_user_can_set_post_date" );
+
+/* user_can_edit_post_date( $user_id, $post_id, $blog_id = 1 ) */
+function smarty_user_can_edit_post_date( $params, &$smarty )
+{
+ $blog_id = 1;
+
+ extract( $params );
+ return user_can_edit_post_date( $user_id, $post_id, $blog_id );
+}
+$wpsmarty->register_function( "user_can_edit_post_date", "smarty_user_can_edit_post_date" );
+
+/* user_can_edit_post_comments( $user_id, $post_id, $blog_id = 1 ) */
+function smarty_user_can_edit_post_comments( $params, &$smarty )
+{
+ $blog_id = 1;
+
+ extract( $params );
+ return user_can_edit_post_comments( $user_id, $post_id, $blog_id );
+}
+$wpsmarty->register_function( "user_can_edit_post_comments", "smarty_user_can_edit_post_comments" );
+
+/* user_can_delete_post_comments( $user_id, $post_id, $blog_id = 1 ) */
+function smarty_user_can_delete_post_comments( $params, &$smarty )
+{
+ $blog_id = 1;
+
+ extract( $params );
+ return user_can_delete_post_comments( $user_id, $post_id, $blog_id );
+}
+$wpsmarty->register_function( "user_can_delete_post_comments", "smarty_user_can_delete_post_comments" );
+
+/* user_can_edit_user( $user_id, $other_user ) */
+function smarty_user_can_edit_user( $params, &$smarty )
+{
+
+ extract( $params );
+ return user_can_edit_user( $user_id, $other_user );
+}
+$wpsmarty->register_function( "user_can_edit_user", "smarty_user_can_edit_user" );
+
+/* wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent ) */
+function smarty_wp_blacklist_check( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent );
+}
+$wpsmarty->register_function( "wp_blacklist_check", "smarty_wp_blacklist_check" );
+
+/* wp_proxy_check( $ipnum ) */
+function smarty_wp_proxy_check( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_proxy_check( $ipnum );
+}
+$wpsmarty->register_function( "wp_proxy_check", "smarty_wp_proxy_check" );
+
+/* wp_new_comment( $commentdata, $spam = false ) */
+function smarty_wp_new_comment( $params, &$smarty )
+{
+ $spam = false;
+
+ extract( $params );
+ return wp_new_comment( $commentdata, $spam );
+}
+$wpsmarty->register_function( "wp_new_comment", "smarty_wp_new_comment" );
+
+/* wp_update_comment( $commentarr ) */
+function smarty_wp_update_comment( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_update_comment( $commentarr );
+}
+$wpsmarty->register_function( "wp_update_comment", "smarty_wp_update_comment" );
+
+/* do_trackbacks( $post_id ) */
+function smarty_do_trackbacks( $params, &$smarty )
+{
+
+ extract( $params );
+ return do_trackbacks( $post_id );
+}
+$wpsmarty->register_function( "do_trackbacks", "smarty_do_trackbacks" );
+
+/* get_pung( $post_id ) */
+function smarty_get_pung( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_pung( $post_id );
+}
+$wpsmarty->register_function( "get_pung", "smarty_get_pung" );
+
+/* get_enclosed( $post_id ) */
+function smarty_get_enclosed( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_enclosed( $post_id );
+}
+$wpsmarty->register_function( "get_enclosed", "smarty_get_enclosed" );
+
+/* get_to_ping( $post_id ) */
+function smarty_get_to_ping( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_to_ping( $post_id );
+}
+$wpsmarty->register_function( "get_to_ping", "smarty_get_to_ping" );
+
+/* add_ping( $post_id, $uri ) */
+function smarty_add_ping( $params, &$smarty )
+{
+
+ extract( $params );
+ return add_ping( $post_id, $uri );
+}
+$wpsmarty->register_function( "add_ping", "smarty_add_ping" );
+
+/* generate_page_rewrite_rules( ) */
+function smarty_generate_page_rewrite_rules( $params, &$smarty )
+{
+
+ extract( $params );
+ return generate_page_rewrite_rules( );
+}
+$wpsmarty->register_function( "generate_page_rewrite_rules", "smarty_generate_page_rewrite_rules" );
+
+/* get_bloginfo_rss( $show = '' ) */
+function smarty_get_bloginfo_rss( $params, &$smarty )
+{
+ $show = '';
+
+ extract( $params );
+ return get_bloginfo_rss( $show );
+}
+$wpsmarty->register_function( "get_bloginfo_rss", "smarty_get_bloginfo_rss" );
+
+/* bloginfo_rss( $show = '' ) */
+function smarty_bloginfo_rss( $params, &$smarty )
+{
+ $show = '';
+
+ extract( $params );
+ return bloginfo_rss( $show );
+}
+$wpsmarty->register_function( "bloginfo_rss", "smarty_bloginfo_rss" );
+
+/* the_title_rss( ) */
+function smarty_the_title_rss( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_title_rss( );
+}
+$wpsmarty->register_function( "the_title_rss", "smarty_the_title_rss" );
+
+/* the_content_rss( $more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0 ) */
+function smarty_the_content_rss( $params, &$smarty )
+{
+ $more_link_text='(more...)';
+ $stripteaser=0;
+ $more_file='';
+ $cut = 0;
+ $encode_html = 0;
+
+ extract( $params );
+ return the_content_rss( $more_link_text, $stripteaser, $more_file, $cut, $encode_html );
+}
+$wpsmarty->register_function( "the_content_rss", "smarty_the_content_rss" );
+
+/* the_excerpt_rss( ) */
+function smarty_the_excerpt_rss( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_excerpt_rss( );
+}
+$wpsmarty->register_function( "the_excerpt_rss", "smarty_the_excerpt_rss" );
+
+/* permalink_single_rss( $file = '' ) */
+function smarty_permalink_single_rss( $params, &$smarty )
+{
+ $file = '';
+
+ extract( $params );
+ return permalink_single_rss( $file );
+}
+$wpsmarty->register_function( "permalink_single_rss", "smarty_permalink_single_rss" );
+
+/* comment_link( ) */
+function smarty_comment_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_link( );
+}
+$wpsmarty->register_function( "comment_link", "smarty_comment_link" );
+
+/* comment_author_rss( ) */
+function smarty_comment_author_rss( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author_rss( );
+}
+$wpsmarty->register_function( "comment_author_rss", "smarty_comment_author_rss" );
+
+/* comment_text_rss( ) */
+function smarty_comment_text_rss( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_text_rss( );
+}
+$wpsmarty->register_function( "comment_text_rss", "smarty_comment_text_rss" );
+
+/* comments_rss_link( $link_text = 'Comments RSS', $commentsrssfilename = '' ) */
+function smarty_comments_rss_link( $params, &$smarty )
+{
+ $link_text = 'Comments RSS';
+ $commentsrssfilename = '';
+
+ extract( $params );
+ return comments_rss_link( $link_text, $commentsrssfilename );
+}
+$wpsmarty->register_function( "comments_rss_link", "smarty_comments_rss_link" );
+
+/* comments_rss( $commentsrssfilename = '' ) */
+function smarty_comments_rss( $params, &$smarty )
+{
+ $commentsrssfilename = '';
+
+ extract( $params );
+ return comments_rss( $commentsrssfilename );
+}
+$wpsmarty->register_function( "comments_rss", "smarty_comments_rss" );
+
+/* get_author_rss_link( $echo = false, $author_id, $author_nicename ) */
+function smarty_get_author_rss_link( $params, &$smarty )
+{
+ $echo = false;
+
+ extract( $params );
+ return get_author_rss_link( $echo, $author_id, $author_nicename );
+}
+$wpsmarty->register_function( "get_author_rss_link", "smarty_get_author_rss_link" );
+
+/* get_category_rss_link( $echo = false, $cat_ID, $category_nicename ) */
+function smarty_get_category_rss_link( $params, &$smarty )
+{
+ $echo = false;
+
+ extract( $params );
+ return get_category_rss_link( $echo, $cat_ID, $category_nicename );
+}
+$wpsmarty->register_function( "get_category_rss_link", "smarty_get_category_rss_link" );
+
+/* the_category_rss( $type = 'rss' ) */
+function smarty_the_category_rss( $params, &$smarty )
+{
+ $type = 'rss';
+
+ extract( $params );
+ return the_category_rss( $type );
+}
+$wpsmarty->register_function( "the_category_rss", "smarty_the_category_rss" );
+
+/* rss_enclosure( ) */
+function smarty_rss_enclosure( $params, &$smarty )
+{
+
+ extract( $params );
+ return rss_enclosure( );
+}
+$wpsmarty->register_function( "rss_enclosure", "smarty_rss_enclosure" );
+
+/* comments_template( $file = '/comments.php' ) */
+function smarty_comments_template( $params, &$smarty )
+{
+ $file = '/comments.php';
+
+ extract( $params );
+ return comments_template( $file );
+}
+$wpsmarty->register_function( "comments_template", "smarty_comments_template" );
+
+/* clean_url( $url ) */
+function smarty_clean_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return clean_url( $url );
+}
+$wpsmarty->register_function( "clean_url", "smarty_clean_url" );
+
+/* get_comments_number( $comment_id ) */
+function smarty_get_comments_number( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comments_number( $comment_id );
+}
+$wpsmarty->register_function( "get_comments_number", "smarty_get_comments_number" );
+
+/* comments_number( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $number = '' ) */
+function smarty_comments_number( $params, &$smarty )
+{
+ $zero = 'No Comments';
+ $one = '1 Comment';
+ $more = '% Comments';
+ $number = '';
+
+ extract( $params );
+ return comments_number( $zero, $one, $more, $number );
+}
+$wpsmarty->register_function( "comments_number", "smarty_comments_number" );
+
+/* get_comments_link( ) */
+function smarty_get_comments_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comments_link( );
+}
+$wpsmarty->register_function( "get_comments_link", "smarty_get_comments_link" );
+
+/* get_comment_link( ) */
+function smarty_get_comment_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_link( );
+}
+$wpsmarty->register_function( "get_comment_link", "smarty_get_comment_link" );
+
+/* comments_link( $file = '', $echo = true ) */
+function smarty_comments_link( $params, &$smarty )
+{
+ $file = '';
+ $echo = true;
+
+ extract( $params );
+ return comments_link( $file, $echo );
+}
+$wpsmarty->register_function( "comments_link", "smarty_comments_link" );
+
+/* comments_popup_script( $width=400, $height=400, $file='' ) */
+function smarty_comments_popup_script( $params, &$smarty )
+{
+ $width=400;
+ $height=400;
+ $file='';
+
+ extract( $params );
+ return comments_popup_script( $width, $height, $file );
+}
+$wpsmarty->register_function( "comments_popup_script", "smarty_comments_popup_script" );
+
+/* comments_popup_link( $zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off' ) */
+function smarty_comments_popup_link( $params, &$smarty )
+{
+ $zero='No Comments';
+ $one='1 Comment';
+ $more='% Comments';
+ $CSSclass='';
+ $none='Comments Off';
+
+ extract( $params );
+ return comments_popup_link( $zero, $one, $more, $CSSclass, $none );
+}
+$wpsmarty->register_function( "comments_popup_link", "smarty_comments_popup_link" );
+
+/* get_comment_ID( ) */
+function smarty_get_comment_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_ID( );
+}
+$wpsmarty->register_function( "get_comment_ID", "smarty_get_comment_ID" );
+
+/* comment_ID( ) */
+function smarty_comment_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_ID( );
+}
+$wpsmarty->register_function( "comment_ID", "smarty_comment_ID" );
+
+/* get_comment_author( ) */
+function smarty_get_comment_author( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_author( );
+}
+$wpsmarty->register_function( "get_comment_author", "smarty_get_comment_author" );
+
+/* comment_author( ) */
+function smarty_comment_author( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author( );
+}
+$wpsmarty->register_function( "comment_author", "smarty_comment_author" );
+
+/* get_comment_author_email( ) */
+function smarty_get_comment_author_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_author_email( );
+}
+$wpsmarty->register_function( "get_comment_author_email", "smarty_get_comment_author_email" );
+
+/* comment_author_email( ) */
+function smarty_comment_author_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author_email( );
+}
+$wpsmarty->register_function( "comment_author_email", "smarty_comment_author_email" );
+
+/* get_comment_author_link( ) */
+function smarty_get_comment_author_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_author_link( );
+}
+$wpsmarty->register_function( "get_comment_author_link", "smarty_get_comment_author_link" );
+
+/* comment_author_link( ) */
+function smarty_comment_author_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author_link( );
+}
+$wpsmarty->register_function( "comment_author_link", "smarty_comment_author_link" );
+
+/* get_comment_type( ) */
+function smarty_get_comment_type( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_type( );
+}
+$wpsmarty->register_function( "get_comment_type", "smarty_get_comment_type" );
+
+/* comment_type( $commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback' ) */
+function smarty_comment_type( $params, &$smarty )
+{
+ $commenttxt = 'Comment';
+ $trackbacktxt = 'Trackback';
+ $pingbacktxt = 'Pingback';
+
+ extract( $params );
+ return comment_type( $commenttxt, $trackbacktxt, $pingbacktxt );
+}
+$wpsmarty->register_function( "comment_type", "smarty_comment_type" );
+
+/* get_comment_author_url( ) */
+function smarty_get_comment_author_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_author_url( );
+}
+$wpsmarty->register_function( "get_comment_author_url", "smarty_get_comment_author_url" );
+
+/* comment_author_url( ) */
+function smarty_comment_author_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author_url( );
+}
+$wpsmarty->register_function( "comment_author_url", "smarty_comment_author_url" );
+
+/* comment_author_email_link( $linktext='', $before='', $after='' ) */
+function smarty_comment_author_email_link( $params, &$smarty )
+{
+ $linktext='';
+ $before='';
+ $after='';
+
+ extract( $params );
+ return comment_author_email_link( $linktext, $before, $after );
+}
+$wpsmarty->register_function( "comment_author_email_link", "smarty_comment_author_email_link" );
+
+/* get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) */
+function smarty_get_comment_author_url_link( $params, &$smarty )
+{
+ $linktext = '';
+ $before = '';
+ $after = '';
+
+ extract( $params );
+ return get_comment_author_url_link( $linktext, $before, $after );
+}
+$wpsmarty->register_function( "get_comment_author_url_link", "smarty_get_comment_author_url_link" );
+
+/* comment_author_url_link( $linktext = '', $before = '', $after = '' ) */
+function smarty_comment_author_url_link( $params, &$smarty )
+{
+ $linktext = '';
+ $before = '';
+ $after = '';
+
+ extract( $params );
+ return comment_author_url_link( $linktext, $before, $after );
+}
+$wpsmarty->register_function( "comment_author_url_link", "smarty_comment_author_url_link" );
+
+/* get_comment_author_IP( ) */
+function smarty_get_comment_author_IP( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_author_IP( );
+}
+$wpsmarty->register_function( "get_comment_author_IP", "smarty_get_comment_author_IP" );
+
+/* comment_author_IP( ) */
+function smarty_comment_author_IP( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author_IP( );
+}
+$wpsmarty->register_function( "comment_author_IP", "smarty_comment_author_IP" );
+
+/* get_comment_text( ) */
+function smarty_get_comment_text( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_text( );
+}
+$wpsmarty->register_function( "get_comment_text", "smarty_get_comment_text" );
+
+/* comment_text( ) */
+function smarty_comment_text( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_text( );
+}
+$wpsmarty->register_function( "comment_text", "smarty_comment_text" );
+
+/* get_comment_excerpt( ) */
+function smarty_get_comment_excerpt( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_excerpt( );
+}
+$wpsmarty->register_function( "get_comment_excerpt", "smarty_get_comment_excerpt" );
+
+/* comment_excerpt( ) */
+function smarty_comment_excerpt( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_excerpt( );
+}
+$wpsmarty->register_function( "comment_excerpt", "smarty_comment_excerpt" );
+
+/* get_comment_date( $d = '' ) */
+function smarty_get_comment_date( $params, &$smarty )
+{
+ $d = '';
+
+ extract( $params );
+ return get_comment_date( $d );
+}
+$wpsmarty->register_function( "get_comment_date", "smarty_get_comment_date" );
+
+/* comment_date( $d = '' ) */
+function smarty_comment_date( $params, &$smarty )
+{
+ $d = '';
+
+ extract( $params );
+ return comment_date( $d );
+}
+$wpsmarty->register_function( "comment_date", "smarty_comment_date" );
+
+/* get_comment_time( $d = '', $gmt = false ) */
+function smarty_get_comment_time( $params, &$smarty )
+{
+ $d = '';
+ $gmt = false;
+
+ extract( $params );
+ return get_comment_time( $d, $gmt );
+}
+$wpsmarty->register_function( "get_comment_time", "smarty_get_comment_time" );
+
+/* comment_time( $d = '' ) */
+function smarty_comment_time( $params, &$smarty )
+{
+ $d = '';
+
+ extract( $params );
+ return comment_time( $d );
+}
+$wpsmarty->register_function( "comment_time", "smarty_comment_time" );
+
+/* get_trackback_url( ) */
+function smarty_get_trackback_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_trackback_url( );
+}
+$wpsmarty->register_function( "get_trackback_url", "smarty_get_trackback_url" );
+
+/* trackback_url( $display = true ) */
+function smarty_trackback_url( $params, &$smarty )
+{
+ $display = true;
+
+ extract( $params );
+ return trackback_url( $display );
+}
+$wpsmarty->register_function( "trackback_url", "smarty_trackback_url" );
+
+/* trackback_rdf( $timezone = 0 ) */
+function smarty_trackback_rdf( $params, &$smarty )
+{
+ $timezone = 0;
+
+ extract( $params );
+ return trackback_rdf( $timezone );
+}
+$wpsmarty->register_function( "trackback_rdf", "smarty_trackback_rdf" );
+
+/* comments_open( ) */
+function smarty_comments_open( $params, &$smarty )
+{
+
+ extract( $params );
+ return comments_open( );
+}
+$wpsmarty->register_function( "comments_open", "smarty_comments_open" );
+
+/* pings_open( ) */
+function smarty_pings_open( $params, &$smarty )
+{
+
+ extract( $params );
+ return pings_open( );
+}
+$wpsmarty->register_function( "pings_open", "smarty_pings_open" );
+
+/* get_lastcommentmodified( $timezone = 'server' ) */
+function smarty_get_lastcommentmodified( $params, &$smarty )
+{
+ $timezone = 'server';
+
+ extract( $params );
+ return get_lastcommentmodified( $timezone );
+}
+$wpsmarty->register_function( "get_lastcommentmodified", "smarty_get_lastcommentmodified" );
+
+/* get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) */
+function smarty_get_commentdata( $params, &$smarty )
+{
+ $no_cache = 0;
+ $include_unapproved = false;
+
+ extract( $params );
+ return get_commentdata( $comment_ID, $no_cache, $include_unapproved );
+}
+$wpsmarty->register_function( "get_commentdata", "smarty_get_commentdata" );
+
+/* pingback( $content, $post_ID ) */
+function smarty_pingback( $params, &$smarty )
+{
+
+ extract( $params );
+ return pingback( $content, $post_ID );
+}
+$wpsmarty->register_function( "pingback", "smarty_pingback" );
+
+/* discover_pingback_server_uri( $url, $timeout_bytes = 2048 ) */
+function smarty_discover_pingback_server_uri( $params, &$smarty )
+{
+ $timeout_bytes = 2048;
+
+ extract( $params );
+ return discover_pingback_server_uri( $url, $timeout_bytes );
+}
+$wpsmarty->register_function( "discover_pingback_server_uri", "smarty_discover_pingback_server_uri" );
+
+/* wp_set_comment_status( $comment_id, $comment_status ) */
+function smarty_wp_set_comment_status( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_set_comment_status( $comment_id, $comment_status );
+}
+$wpsmarty->register_function( "wp_set_comment_status", "smarty_wp_set_comment_status" );
+
+/* wp_get_comment_status( $comment_id ) */
+function smarty_wp_get_comment_status( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_get_comment_status( $comment_id );
+}
+$wpsmarty->register_function( "wp_get_comment_status", "smarty_wp_get_comment_status" );
+
+/* check_comment( $author, $email, $url, $comment, $user_ip, $user_agent, $comment_type ) */
+function smarty_check_comment( $params, &$smarty )
+{
+
+ extract( $params );
+ return check_comment( $author, $email, $url, $comment, $user_ip, $user_agent, $comment_type );
+}
+$wpsmarty->register_function( "check_comment", "smarty_check_comment" );
+
+
+$wpsmarty->template_dir = ABSPATH."/wp-content/blogs/".$wpblog."/templates";
+$wpsmarty->compile_dir = ABSPATH."/wp-content/blogs/".$wpblog."/templates_c";
+$wpsmarty->cache_dir = ABSPATH."/wp-content/blogs/".$wpblog."/smartycache";
+$wpsmarty->plugins_dir = ABSPATH."/wp-content/smarty-plugins";
+$wpsmarty->cache_lifetime = -1;
+$wpsmarty->caching = true;
+$wpsmarty->security = 1;
+$wpsmarty->secure_dir = array( ABSPATH."/wp-content/blogs/".$wpblog."/templates", "wp-content/smarty-templates" );
+if( isset( $_GET[ "clear" ] ) )
+ $wpsmarty->clear_all_cache();
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/class-snoopy.php b/wp-inst/wp-includes/class-snoopy.php
new file mode 100644
index 0000000..9a9ac16
--- /dev/null
+++ b/wp-inst/wp-includes/class-snoopy.php
@@ -0,0 +1,901 @@
+<?php
+
+/*************************************************
+
+Snoopy - the PHP net client
+Author: Monte Ohrt <monte@ispi.net>
+Copyright (c): 1999-2000 ispi, all rights reserved
+Version: 1.0
+
+ * 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 $agent = "Snoopy v1.0"; // 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()
+ // or submitlinks()
+ 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 $curl_path = "/usr/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.
+
+ // send Accept-encoding: gzip?
+ var $use_gzip = true;
+
+ /**** 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"];
+
+ switch($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"].(isset($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 || (!is_executable($this->curl_path))) {
+ $this->error = "Bad curl ($this->curl_path), can't fetch HTTPS \n";
+ 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;
+ }
+
+
+
+/*======================================================================*\
+ 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 <a href=
+ ([\"\'])? # find single or double quote
+ (?(1) (.*?)\\1 | ([^\s\>]+)) # 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("'<script[^>]*?>.*?</script>'si", // strip out javascript
+ "'<[\/\!]*?[^<>]*?>'si", // strip out html tags
+ "'([\r\n])[\s]+'", // strip out white space
+ "'&(quote|#34);'i", // replace html entities
+ "'&(amp|#38);'i",
+ "'&(lt|#60);'i",
+ "'&(gt|#62);'i",
+ "'&(nbsp|#160);'i",
+ "'&(iexcl|#161);'i",
+ "'&(cent|#162);'i",
+ "'&(pound|#163);'i",
+ "'&(copy|#169);'i"
+ );
+ $replace = array( "",
+ "",
+ "\\1",
+ "\"",
+ "&",
+ "<",
+ ">",
+ " ",
+ chr(161),
+ chr(162),
+ chr(163),
+ chr(169));
+
+ $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]);
+
+ $search = array( "|^http://".preg_quote($this->host)."|i",
+ "|^(?!http://)(\/)?(?!mailto:)|i",
+ "|/\./|",
+ "|/[^\/]+/\.\./|"
+ );
+
+ $replace = array( "",
+ $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="")
+ {
+ 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."\r\n";
+ if(!empty($this->accept))
+ $headers .= "Accept: ".$this->accept."\r\n";
+
+ if($this->use_gzip) {
+ // make sure PHP was built with --with-zlib
+ // and we can handle gzipp'ed data
+ if ( function_exists(gzinflate) ) {
+ $headers .= "Accept-encoding: gzip\r\n";
+ }
+ else {
+ trigger_error(
+ "use_gzip is on, but PHP was built without zlib support.".
+ " Requesting file(s) without gzip encoding.",
+ E_USER_NOTICE);
+ }
+ }
+
+ 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";
+
+ $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);
+
+ // content was returned gzip encoded?
+ $is_gzipped = false;
+
+ while($currentHeader = fgets($fp,$this->_maxlinelen))
+ {
+ if ($this->read_timeout > 0 && $this->_check_timeout($fp))
+ {
+ $this->status=-100;
+ return false;
+ }
+
+ // if($currentHeader == "\r\n")
+ if(preg_match("/^\r?\n$/", $currentHeader) )
+ 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:)\s+(.*)/",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;
+ }
+
+ if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) {
+ $is_gzipped = true;
+ }
+
+ $this->headers[] = $currentHeader;
+ }
+
+ # $results = fread($fp, $this->maxlength);
+ $results = "";
+ while ( $data = fread($fp, $this->maxlength) ) {
+ $results .= $data;
+ if (
+ strlen($results) > $this->maxlength ) {
+ break;
+ }
+ }
+
+ // gunzip
+ if ( $is_gzipped ) {
+ // per http://www.php.net/manual/en/function.gzencode.php
+ $results = substr($results, 10);
+ $results = gzinflate($results);
+ }
+
+ 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("'<meta[\s]*http-equiv[^>]*?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("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
+ {
+ $this->results[] = $results;
+ for($x=0; $x<count($match[1]); $x++)
+ $this->_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))
+ $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++)
+ $cmdline_params .= " -H \"".$headers[$curr_header]."\"";
+
+ if(!empty($body))
+ $cmdline_params .= " -d \"$body\"";
+
+ if($this->read_timeout > 0)
+ $cmdline_params .= " -m ".$this->read_timeout;
+
+ $headerfile = uniqid(time());
+
+ # accept self-signed certs
+ $cmdline_params .= " -k";
+ exec($this->curl_path." -D \"/tmp/$headerfile\"".$cmdline_params." ".$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("/tmp/$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:)(.*)/",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];
+ if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$this->response_code, $match))
+ {
+ $this->status= $match[1];
+ }
+ }
+ $this->headers[] = $result_headers[$currentHeader];
+ }
+
+ // check if there is a a redirect meta tag
+
+ if(preg_match("'<meta[\s]*http-equiv[^>]*?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("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
+ {
+ $this->results[] = $results;
+ for($x=0; $x<count($match[1]); $x++)
+ $this->_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("/tmp/$headerfile");
+
+ return true;
+ }
+
+/*======================================================================*\
+ Function: setcookies()
+ Purpose: set cookies for a redirection
+\*======================================================================*/
+
+ function setcookies()
+ {
+ for($x=0; $x<count($this->headers); $x++)
+ {
+ if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match))
+ $this->cookies[$match[1]] = $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");
+
+ 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;
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/classes.php b/wp-inst/wp-includes/classes.php
new file mode 100644
index 0000000..ca4c082
--- /dev/null
+++ b/wp-inst/wp-includes/classes.php
@@ -0,0 +1,1526 @@
+<?php
+
+class WP_Query {
+ var $query;
+ var $query_vars;
+ var $queried_object;
+ var $queried_object_id;
+
+ var $posts;
+ var $post_count = 0;
+ var $current_post = -1;
+ var $post;
+
+ var $is_single = false;
+ var $is_page = false;
+ var $is_archive = false;
+ var $is_date = false;
+ var $is_year = false;
+ var $is_month = false;
+ var $is_day = false;
+ var $is_time = false;
+ var $is_author = false;
+ var $is_category = false;
+ var $is_search = false;
+ var $is_feed = false;
+ var $is_trackback = false;
+ var $is_home = false;
+ var $is_404 = false;
+ var $is_comments_popup = false;
+ var $is_admin = false;
+
+ function init () {
+ $this->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;
+
+ 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;
+ }
+
+ // 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;
+ }
+
+ $qv['m'] = (int) $qv['m'];
+ $qv['p'] = (int) $qv['p'];
+
+ if ('' != $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;
+ } 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 ('' != $qv['feed']) {
+ $this->is_feed = true;
+ }
+
+ if ('' != $qv['tb']) {
+ $this->is_trackback = true;
+ }
+
+ if ('404' == $qv['error']) {
+ $this->is_404 = true;
+ }
+
+ if ('' != $qv['paged']) {
+ $this->is_paged = true;
+ }
+
+ if ('' != $qv['comments_popup']) {
+ $this->is_comments_popup = true;
+ }
+
+ if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) {
+ $this->is_admin = true;
+ }
+
+ if ( ! ($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 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, $request, $user_ID;
+
+ // Shorthand.
+ $q = $this->query_vars;
+
+ // First let's clear some variables
+ $whichcat = '';
+ $whichauthor = '';
+ $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'] . "'";
+ }
+
+ if ('' != $q['name']) {
+ $q['name'] = sanitize_title($q['name']);
+ $where .= " AND post_name = '" . $q['name'] . "'";
+ } else if ('' != $q['pagename']) {
+ $q['pagename'] = sanitize_title(basename(str_replace('%2F', '/', urlencode($q['pagename']))));
+ $q['name'] = $q['pagename'];
+ $where .= " AND post_name = '" . $q['pagename'] . "'";
+ }
+
+
+ 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 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
+
+ if ('' != $q['category_name']) {
+ if (stristr($q['category_name'],'/')) {
+ $q['category_name'] = explode('/',$q['category_name']);
+ if ($q['category_name'][count($q['category_name'])-1]) {
+ $q['category_name'] = $q['category_name'][count($q['category_name'])-1]; // no trailing slash
+ } else {
+ $q['category_name'] = $q['category_name'][count($q['category_name'])-2]; // there was a trailling slash
+ }
+ }
+ $q['category_name'] = sanitize_title($q['category_name']);
+ $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_nicename = '" . $q['category_name'] . "'";
+ $q['cat'] = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '" . $q['category_name'] . "'");
+ $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');
+ $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');
+
+ if ($pagenow != 'post.php' && $pagenow != 'edit.php') {
+ $where .= " AND post_date_gmt <= '$now'";
+ $distinct = 'DISTINCT';
+ }
+
+ if ($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 .= ')';
+ }
+
+ // 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);
+ $where .= " GROUP BY $wpdb->posts.ID";
+ $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." ORDER BY " . $orderby . " $limits";
+
+ $this->posts = $wpdb->get_results($request);
+
+ // Check post status to determine if post should be displayed.
+ if ($this->is_single) {
+ if ('publish' != $this->posts[0]->post_status) {
+ if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) {
+ // User must be logged in to view unpublished posts.
+ $this->posts = array();
+ } else {
+ if ('draft' == $this->posts[0]->post_status) {
+ // User must have edit permissions on the draft to preview.
+ if (! user_can_edit_post($user_ID, $this->posts[0]->ID))
+ $this->posts = array();
+ } elseif ('private' == $this->posts[0]->post_status) {
+ if ($this->posts[0]->post_author != $user_ID)
+ $this->posts = array();
+ }
+ }
+ }
+ }
+
+ $this->posts = apply_filters('the_posts', $this->posts);
+ $this->post_count = count($this->posts);
+ if ($this->post_count > 0) {
+ $this->post = $this->posts[0];
+ }
+
+ update_post_caches($this->posts);
+
+ // 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;
+ $post = $this->next_post();
+ setup_postdata($post);
+ }
+
+ function have_posts() {
+ if ($this->current_post + 1 < $this->post_count) {
+ return true;
+ }
+
+ 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) {
+ global $cache_userdata;
+ if (isset($cache_userdata[$this->get('author')])) {
+ $this->queried_object = $cache_userdata[$this->get('author')];
+ $this->queried_object_id = $this->get('author');
+ }
+ }
+
+ 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 "<div class='updated'><p>$cnt comment";
+ if ($cnt != 1 ) echo "s";
+ echo " moved to the moderation queue.</p></div>\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 ) {
+ if ( empty( $word ) )
+ continue;
+ $fulltext = strtolower($comment->email.' '.$comment->url.' '.$comment->ip.' '.$comment->text);
+ if( strpos( $fulltext, strtolower(trim($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 = '<p>' . sprintf(__('Suspected spam comments: <strong>%s</strong>'), $numfound) . '</p>';
+
+ if ( count($counters[found]) > 0 ) {
+ $id_list = implode( ',', $counters[found] );
+ $body .= '<p><a href="options-discussion.php?action=retrospam&amp;move=true&amp;ids='.$id_list.'">'. __('Move suspect comments to moderation queue &raquo;') . '</a></p>';
+
+ }
+ $head = '<div class="wrap"><h2>' . __('Check Comments Results:') . '</h2>';
+
+ $foot .= '<p><a href="options-discussion.php">' . __('&laquo; Return to Discussion Options page.') . '</a></p></div>';
+
+ 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');
+
+ $rewrite_rules = array();
+ $page_structure = $this->get_page_permastruct();
+ if( is_array( $uris ) )
+ {
+ foreach ($uris as $uri => $pagename) {
+ $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
+ $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($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($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($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, $page = 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 ($page)
+ $rewrite = $rewrite + array($pagematch => $pagequery);
+
+ if ($num_toks) {
+ $post = 0;
+ 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 = 1;
+ $trackbackmatch = $match . $trackbackregex;
+ $trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
+ $match = rtrim($match, '/');
+ $match = $match . '(/[0-9]+)?/?$';
+ $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
+ } else {
+ $match .= '?$';
+ $query = $index . '?' . $query;
+ }
+
+ $rewrite = $rewrite + array($match => $query);
+
+ if ($post) {
+ $rewrite = array($trackbackmatch => $trackbackquery) + $rewrite;
+ }
+ }
+
+ $post_rewrite = $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);
+ $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 = $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->matches = 'matches';
+ return $this->rewrite_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 = "<IfModule mod_rewrite.c>\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}\n";
+ }
+
+ $rules .= "</IfModule>\n";
+
+ $rules = apply_filters('mod_rewrite_rules', $rules);
+ $rules = apply_filters('rewrite_rules', $rules); // Deprecated
+
+ return $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');
+
+ var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging');
+
+ var $query_vars;
+ var $query_string;
+ 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);
+
+ // Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
+ if ((isset($_GET['error']) && $_GET['error'] == '404') ||
+ ((! empty($_SERVER['PATH_INFO'])) &&
+ ('/' != $_SERVER['PATH_INFO']) &&
+ (false === strpos($_SERVER['PATH_INFO'], '.php'))
+ ) ||
+ (empty($_SERVER['QUERY_STRING']) &&
+ (false === strpos($_SERVER['REQUEST_URI'], '.php')) &&
+ ('/' != $_SERVER['REQUEST_URI']))
+ ) {
+
+ $this->did_permalink = true;
+
+ // If we match a rewrite rule, this will be cleared.
+ $error = '404';
+
+ // Fetch the rewrite rules.
+ $rewrite = $wp_rewrite->wp_rewrite_rules();
+
+ if (! empty($rewrite)) {
+ $pathinfo = $_SERVER['PATH_INFO'];
+ $req_uri = $_SERVER['REQUEST_URI'];
+ $home_path = parse_url(get_settings('home'));
+ $home_path = $home_path['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 = str_replace($home_path, '', $req_uri);
+ $req_uri = trim($req_uri, '/');
+ $pathinfo = trim($pathinfo, '/');
+
+ // The requested permalink is in $pathinfo for path info requests and
+ // $req_uri for other requests.
+ if (! empty($pathinfo)) {
+ $request = $pathinfo;
+ } else {
+ $request = $req_uri;
+ }
+
+ // 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)) {
+ $request_match = $req_uri . '/' . $request;
+ }
+
+ if (preg_match("!^$match!", $request_match, $matches)) {
+ // Got a match.
+ // Trim the query of everything up to the '?'.
+ $query = preg_replace("!^.+\?!", '', $query);
+
+ // Substitute the substring matches into the query.
+ eval("\$query = \"$query\";");
+
+ // 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;
+ }
+ }
+ }
+ }
+
+ $this->public_query_vars = apply_filters('query_vars', $this->public_query_vars);
+
+ for ($i=0; $i<count($this->public_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] = '';
+ }
+ }
+
+ function send_headers() {
+ @header('X-Pingback: '. get_bloginfo('pingback_url'));
+ 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;
+
+ if ( is_single() || is_page() ) {
+ $GLOBALS['more'] = 1;
+ $GLOBALS['single'] = 1;
+ }
+ }
+
+ function prime_caches() {
+ update_category_cache();
+ 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->is_404 = true;
+ status_header( 404 );
+ } else {
+ status_header( 200 );
+ }
+ }
+
+ function main($query_args = '') {
+ $this->parse_request($query_args);
+ $this->send_headers();
+ $this->prime_caches();
+ $this->query_posts();
+ $this->handle_404();
+ $this->register_globals();
+ }
+
+ function WP() {
+ // Empty.
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/comment-functions.php b/wp-inst/wp-includes/comment-functions.php
new file mode 100644
index 0000000..e1b426e
--- /dev/null
+++ b/wp-inst/wp-includes/comment-functions.php
@@ -0,0 +1,678 @@
+<?php
+
+// Template functions
+
+function comments_template( $file = '/comments.php' ) {
+ global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
+
+ if ( is_single() || is_page() || $withcomments ) :
+ $req = get_settings('require_name_email');
+ $comment_author = isset($_COOKIE['comment_author_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_'.COOKIEHASH])) : '';
+ $comment_author_email = isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_email_'.COOKIEHASH])) : '';
+ $comment_author_url = isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_url_'.COOKIEHASH])) : '';
+ if ( empty($comment_author) ) {
+ $comments = $wpdb->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 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};)/', '&#038;$1', $url);
+ return $url;
+}
+
+function get_comments_number( $comment_id ) {
+ global $wpdb, $comment_count_cache;
+ $comment_id = (int) $comment_id;
+ if (!isset($comment_count_cache[$comment_id]))
+ $comment_count_cache[$comment_id] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_id' AND comment_approved = '1'");
+
+ return apply_filters('get_comments_number', $comment_count_cache[$comment_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 = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\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 '<a href="';
+ if ($wpcommentsjavascript) {
+ if ( empty($wpcommentspopupfile) )
+ $home = get_settings('home');
+ else
+ $home = get_settings('siteurl');
+ echo $home . '/' . $wpcommentspopupfile.'?comments_popup='.$id;
+ echo '" onclick="wpopen(this.href); return false"';
+ } else { // if comments_popup_script() is not in the template, display simple comment link
+ if ( 0 == $number )
+ echo get_permalink() . '#respond';
+ else
+ comments_link();
+ echo '"';
+ }
+ if (!empty($CSSclass)) {
+ echo ' class="'.$CSSclass.'"';
+ }
+ echo '>';
+ comments_number($zero, $one, $more, $number);
+ echo '</a>';
+ }
+ }
+}
+
+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 ) )
+ $return = $author;
+ else
+ $return = "<a href='$url' rel='external nofollow'>$author</a>";
+ 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 "<a href='mailto:$email'>$display</a>";
+ echo $after;
+ }
+}
+
+function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
+ global $comment;
+ $url = get_comment_author_url();
+ $display = ($linktext != '') ? $linktext : $url;
+ $return = "$before<a href='$url' rel='external'>$display</a>$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 '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
+ <rdf:Description rdf:about="';
+ the_permalink();
+ echo '"'."\n";
+ echo ' dc:identifier="';
+ the_permalink();
+ echo '"'."\n";
+ echo ' dc:title="'.str_replace('--', '&#x2d;&#x2d;', wptexturize(strip_tags(get_the_title()))).'"'."\n";
+ echo ' trackback:ping="'.trackback_url(0).'"'." />\n";
+ echo '</rdf:RDF>';
+ }
+}
+
+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 $tablecomments, $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 $tablecomments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
+ break;
+ case 'blog':
+ $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $tablecomments 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 $tablecomments 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 <link/>
+
+ foreach($post_links_temp[0] as $link_test) :
+ if ( !in_array($link_test, $pung) ) : // If we haven't pung it already
+ $test = parse_url($link_test);
+ if (isset($test['query']))
+ $post_links[] = $link_test;
+ elseif(($test['path'] != '/') && ($test['path'] != ''))
+ $post_links[] = $link_test;
+ endif;
+ endforeach;
+
+ foreach ($post_links as $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', array($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 PHP/" . phpversion() . "\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 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':
+ $query = "DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
+ default:
+ return false;
+ }
+
+ if ($wpdb->query($query)) {
+ do_action('wp_set_comment_status', $comment_id, $comment_status);
+ 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 && false === strpos( $email, get_settings('moderation_keys')) )
+ return true;
+ else
+ return false;
+ } else {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+?>
diff --git a/wp-inst/wp-includes/create_smarty_template.php b/wp-inst/wp-includes/create_smarty_template.php
new file mode 100755
index 0000000..7556a68
--- /dev/null
+++ b/wp-inst/wp-includes/create_smarty_template.php
@@ -0,0 +1,144 @@
+#!/usr/bin/php -q
+<?php
+
+/* $Id: create_smarty_template.php,v 1.7 2005/03/12 20:17:52 donncha Exp $ */
+
+
+if (is_dir( "." ))
+{
+ if ($dh = opendir( "." ))
+ {
+ while (($file = readdir($dh)) !== false )
+ {
+ if( strpos( $file, "template-functions" ) !== false )
+ {
+ $files[] = $file;
+ }
+ }
+ closedir($dh);
+ }
+}
+$files[] = 'links.php';
+$files[] = 'functions.php';
+$files[] = 'wp-l10n.php';
+$files[] = 'functions-formatting.php';
+$files[] = 'functions-post.php';
+$files[] = 'functions-user.php';
+$files[] = 'feed-functions.php';
+$files[] = 'comment-functions.php';
+
+
+$buffer2 = '';
+reset( $files );
+while( list( $k, $file ) = each( $files ) )
+{
+ if( is_file( $file ) )
+ {
+ $fp = fopen( $file, "r" );
+ while (!feof ($fp))
+ {
+ $buffer = fgets($fp, 4096);
+ if( strpos( $buffer, "unction " ) == '1' )
+ {
+ if( strpos( $buffer, '{' ) === false )
+ {
+ // multi-line function call
+ $buffer2 .= $buffer;
+ while(!feof( $fp ) && strpos( $buffer, '{' ) === false )
+ {
+ $buffer = fgets($fp, 4096);
+ $buffer2 .= $buffer;
+ }
+ $line[] = $buffer2;
+ $buffer2 = '';
+ }
+ else
+ {
+ $line[] = $buffer;
+ $buffer2 = '';
+ }
+ }
+
+ }
+ fclose ($fp);
+ }
+}
+print '<'.'?'.'php'."\n".'
+if( isset( $wpsmarty ) == false || is_object( $wpsmarty ) == false )
+{
+ if( defined( ABSPATH ) == false )
+ define( "ABSPATH", "../" );
+
+ require_once( ABSPATH . "Smarty.class.php" );
+ $wpsmarty = new Smarty;
+}
+
+';
+
+reset( $line );
+while( list( $key, $val ) = each( $line ) )
+{
+ $function = substr( $val, 9, strpos( $val, "(" ) - 9 );
+ $bracket1 = strpos( $val, "(" ) + 1;
+ $origargs = substr( $val, $bracket1, strpos( $val, ') {' ) - $bracket1 );
+ $argslist = split( ",", $origargs );
+ $args = '';
+ $defineargs = '';
+ reset( $argslist );
+ while( list( $key, $val ) = each( $argslist ) )
+ {
+ if( strpos( $val, "=" ) )
+ {
+ $defineargs .= " ".trim( $val ).";\n";
+ $args .= trim( substr( $val, 0, strpos( $val, "=" ) ) ).", ";
+ }
+ else
+ {
+ $args .= $val.", ";
+ }
+ }
+ $args = substr( $args, 0, -2 );
+ print "/* $function( $origargs ) */\n";
+ if( $function[0] == '&' )
+ {
+ print "function &smarty_".substr( $function, 1 )."( \$params, &\$smarty )\n";
+ }
+ else
+ {
+ print "function smarty_".$function."( \$params, &\$smarty )\n";
+ }
+ print "{\n";
+ print "$defineargs\n";
+ print " extract( \$params );\n";
+ if( $function[0] == '&' )
+ {
+ print " return ".substr( $function, 1 )."( $args );\n";
+ }
+ else
+ {
+ print " return $function( $args );\n";
+ }
+ print "}\n";
+ if( $function[0] == '&' )
+ {
+ print '$wpsmarty->register_function( "'.substr( $function, 1 ).'", "smarty_'.substr( $function, 1 ).'" );'."\n\n";
+ }
+ else
+ {
+ print '$wpsmarty->register_function( "'.$function.'", "smarty_'.$function.'" );'."\n\n";
+ }
+}
+print '
+$wpsmarty->template_dir = ABSPATH."/wp-content/blogs/".$wpblog."/templates";
+$wpsmarty->compile_dir = ABSPATH."/wp-content/blogs/".$wpblog."/templates_c";
+$wpsmarty->cache_dir = ABSPATH."/wp-content/blogs/".$wpblog."/smartycache";
+$wpsmarty->plugins_dir = ABSPATH."/wp-content/smarty-plugins";
+$wpsmarty->cache_lifetime = -1;
+$wpsmarty->caching = true;
+$wpsmarty->security = 1;
+$wpsmarty->secure_dir = array( ABSPATH."/wp-content/blogs/".$wpblog."/templates", "wp-content/smarty-templates" );
+if( isset( $_GET[ "clear" ] ) )
+ $wpsmarty->clear_all_cache();
+';
+print "?".">";
+?>
diff --git a/wp-inst/wp-includes/default-filters.php b/wp-inst/wp-includes/default-filters.php
new file mode 100644
index 0000000..5b988a9
--- /dev/null
+++ b/wp-inst/wp-includes/default-filters.php
@@ -0,0 +1,88 @@
+<?php
+
+// Some default filters
+add_filter('bloginfo','wp_specialchars');
+add_filter('category_description', 'wptexturize');
+add_filter('list_cats', 'wptexturize');
+add_filter('comment_author', 'wptexturize');
+add_filter('comment_text', 'wptexturize');
+add_filter('single_post_title', 'wptexturize');
+add_filter('the_title', 'wptexturize');
+add_filter('the_content', 'wptexturize');
+add_filter('the_excerpt', 'wptexturize');
+add_filter('bloginfo', 'wptexturize');
+
+// Comments, trackbacks, pingbacks
+add_filter('pre_comment_author_name', 'strip_tags');
+add_filter('pre_comment_author_name', 'trim');
+add_filter('pre_comment_author_name', 'wp_specialchars', 30);
+
+add_filter('pre_comment_author_email', 'trim');
+add_filter('pre_comment_author_email', 'sanitize_email');
+
+add_filter('pre_comment_author_url', 'strip_tags');
+add_filter('pre_comment_author_url', 'trim');
+add_filter('pre_comment_author_url', 'clean_url');
+
+add_filter('pre_comment_content', 'stripslashes', 1);
+add_filter('pre_comment_content', 'wp_filter_kses');
+add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
+add_filter('pre_comment_content', 'balanceTags', 30);
+add_filter('pre_comment_content', 'addslashes', 50);
+
+add_filter('pre_comment_author_name', 'wp_filter_kses');
+add_filter('pre_comment_author_email', 'wp_filter_kses');
+add_filter('pre_comment_author_url', 'wp_filter_kses');
+
+// Default filters for these functions
+add_filter('comment_author', 'wptexturize');
+add_filter('comment_author', 'convert_chars');
+add_filter('comment_author', 'wp_specialchars');
+
+add_filter('comment_email', 'antispambot');
+
+add_filter('comment_url', 'clean_url');
+
+add_filter('comment_text', 'convert_chars');
+add_filter('comment_text', 'make_clickable');
+add_filter('comment_text', 'wpautop', 30);
+add_filter('comment_text', 'convert_smilies', 20);
+
+add_filter('comment_excerpt', 'convert_chars');
+
+// Places to balance tags on input
+add_filter('content_save_pre', 'balanceTags', 50);
+add_filter('excerpt_save_pre', 'balanceTags', 50);
+add_filter('comment_save_pre', 'balanceTags', 50);
+
+// Misc. title, content, and excerpt filters
+add_filter('the_title', 'convert_chars');
+add_filter('the_title', 'trim');
+
+add_filter('the_content', 'convert_smilies');
+add_filter('the_content', 'convert_chars');
+add_filter('the_content', 'wpautop');
+
+add_filter('the_excerpt', 'convert_smilies');
+add_filter('the_excerpt', 'convert_chars');
+add_filter('the_excerpt', 'wpautop');
+add_filter('get_the_excerpt', 'wp_trim_excerpt');
+
+add_filter('sanitize_title', 'sanitize_title_with_dashes');
+
+// RSS filters
+add_filter('the_title_rss', 'strip_tags');
+add_filter('the_title_rss', 'ent2ncr', 8);
+add_filter('the_content_rss', 'ent2ncr', 8);
+add_filter('the_excerpt_rss', 'convert_chars');
+add_filter('the_excerpt_rss', 'ent2ncr', 8);
+add_filter('comment_author_rss', 'ent2ncr', 8);
+add_filter('comment_text_rss', 'htmlspecialchars');
+add_filter('comment_text_rss', 'ent2ncr', 8);
+add_filter('bloginfo_rss', 'ent2ncr', 8);
+add_filter('the_author', 'ent2ncr', 8);
+
+// Actions
+add_action('publish_post', 'generic_ping');
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/feed-functions.php b/wp-inst/wp-includes/feed-functions.php
new file mode 100644
index 0000000..a9df4e7
--- /dev/null
+++ b/wp-inst/wp-includes/feed-functions.php
@@ -0,0 +1,158 @@
+<?php
+
+function get_bloginfo_rss($show = '') {
+ $info = strip_tags(get_bloginfo($show));
+ return convert_chars($info);
+}
+
+function bloginfo_rss($show = '') {
+ echo get_bloginfo_rss($show);
+}
+
+function the_title_rss() {
+ $title = get_the_title();
+ $title = apply_filters('the_title', $title);
+ $title = apply_filters('the_title_rss', $title);
+ echo $title;
+}
+
+function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
+ $content = get_the_content($more_link_text, $stripteaser, $more_file);
+ $content = apply_filters('the_content', $content);
+ if ($cut && !$encode_html) {
+ $encode_html = 2;
+ }
+ if ($encode_html == 1) {
+ $content = wp_specialchars($content);
+ $cut = 0;
+ } elseif ($encode_html == 0) {
+ $content = make_url_footnote($content);
+ } elseif ($encode_html == 2) {
+ $content = strip_tags($content);
+ }
+ if ($cut) {
+ $blah = explode(' ', $content);
+ if (count($blah) > $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(']]>', ']]&gt;', $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 comment_author_rss() {
+ $author = apply_filters('comment_author_rss', get_comment_author() );
+ echo $author;
+}
+
+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 "<a href='$url'>$link_text</a>";
+}
+
+function comments_rss($commentsrssfilename = '') {
+ global $id;
+
+ if ('' != get_settings('permalink_structure'))
+ $url = trailingslashit( get_permalink() ) . 'feed/';
+ else
+ $url = get_settings('home') . "/$commentsrssfilename?feed=rss2&amp;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&amp;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&amp;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<dc:subject>$category->cat_name</dc:subject>";
+ } else {
+ $the_list .= "\n\t<category>$category->cat_name</category>";
+ }
+ }
+ 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 "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
+ }
+ }
+ }
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/functions-compat.php b/wp-inst/wp-includes/functions-compat.php
new file mode 100644
index 0000000..5063ece
--- /dev/null
+++ b/wp-inst/wp-includes/functions-compat.php
@@ -0,0 +1,92 @@
+<?php
+
+/* Functions missing from older PHP versions */
+
+
+/* Added in PHP 4.2.0 */
+
+if (!function_exists('floatval')) {
+ function floatval($string) {
+ return ((float) $string);
+ }
+}
+
+if (!function_exists('is_a')) {
+ function is_a($object, $class) {
+ // by Aidan Lister <aidan@php.net>
+ 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 <aidan@php.net>
+ 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 "<pre>$code</pre>";
+ }
+ return $code;
+}
+
+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 <schst@php.net>
+ * @author Aidan Lister <aidan@php.net>
+ * @version $Revision: 2247 $
+ * @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;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/functions-formatting.php b/wp-inst/wp-includes/functions-formatting.php
new file mode 100644
index 0000000..3ad94f5
--- /dev/null
+++ b/wp-inst/wp-includes/functions-formatting.php
@@ -0,0 +1,996 @@
+<?php
+
+function wptexturize($text) {
+ $output = '';
+ // Capture tags and everything inside them
+ $textarr = preg_split("/(<.*>)/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('---', '&#8212;', $curl);
+ $curl = str_replace(' -- ', ' &#8212; ', $curl);
+ $curl = str_replace('--', '&#8211;', $curl);
+ $curl = str_replace('xn&#8211;', 'xn--', $curl);
+ $curl = str_replace('...', '&#8230;', $curl);
+ $curl = str_replace('``', '&#8220;', $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("&#8217;tain&#8217;t","&#8217;twere","&#8217;twas","&#8217;tis","&#8217;twill","&#8217;til","&#8217;bout","&#8217;nuff","&#8217;round","&#8217;cause");
+ $curl = str_replace($cockney, $cockneyreplace, $curl);
+
+ $curl = preg_replace("/'s/", '&#8217;s', $curl);
+ $curl = preg_replace("/'(\d\d(?:&#8217;|')?s)/", "&#8217;$1", $curl);
+ $curl = preg_replace('/(\s|\A|")\'/', '$1&#8216;', $curl);
+ $curl = preg_replace('/(\d+)"/', '$1&#8243;', $curl);
+ $curl = preg_replace("/(\d+)'/", '$1&#8242;', $curl);
+ $curl = preg_replace("/(\S)'([^'\s])/", "$1&#8217;$2", $curl);
+ $curl = preg_replace('/(\s|\A)"(?!\s)/', '$1&#8220;$2', $curl);
+ $curl = preg_replace('/"(\s|\S|\Z)/', '&#8221;$1', $curl);
+ $curl = preg_replace("/'([\s.]|\Z)/", '&#8217;$1', $curl);
+ $curl = preg_replace("/ \(tm\)/i", ' &#8482;', $curl);
+ $curl = str_replace("''", '&#8221;', $curl);
+
+ $curl = preg_replace('/(\d+)x(\d+)/', "$1&#215;$2", $curl);
+
+ } elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) {
+ // strstr is fast
+ $next = false;
+ } else {
+ $next = true;
+ }
+ $curl = preg_replace('/&([^#])(?![a-z12]{1,8};)/', '&#038;$1', $curl);
+ $output .= $curl;
+ }
+ return $output;
+}
+
+function clean_pre($text) {
+ $text = str_replace('<br />', '', $text);
+ $text = str_replace('<p>', "\n", $text);
+ $text = str_replace('</p>', '', $text);
+ return $text;
+}
+
+function wpautop($pee, $br = 1) {
+ $pee = $pee . "\n"; // just to make things a little easier, pad the end
+ $pee = preg_replace('|<br />\s*<br />|', "\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('!(</(?: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])>)!', "$1\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', "\t<p>$1</p>\n", $pee); // make paragraphs, including one at the end
+ $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
+ $pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
+ $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
+ $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
+ $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
+ $pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "$1", $pee);
+ $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])[^>]*>)\s*</p>!', "$1", $pee);
+ if ($br) $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
+ $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*<br />!', "$1", $pee);
+ $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)!', '$1', $pee);
+ $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . clean_pre('$2') . '</pre>' ", $pee);
+
+ return $pee;
+}
+
+
+function seems_utf8($Str) { # by bmorel at ssi dot fr
+ for ($i=0; $i<strlen($Str); $i++) {
+ if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb
+ elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb
+ elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb
+ elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb
+ elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb
+ elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b
+ else return false; # Does not match any model
+ for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
+ if ((++$i == strlen($Str)) || ((ord($Str[$i]) & 0xC0) != 0x80))
+ return false;
+ }
+ }
+ return true;
+}
+
+function wp_specialchars( $text, $quotes = 0 ) {
+ // Like htmlspecialchars except don't double-encode HTML entities
+ $text = preg_replace('/&([^#])(?![a-z12]{1,8};)/', '&#038;$1', $text);-
+ $text = str_replace('<', '&lt;', $text);
+ $text = str_replace('>', '&gt;', $text);
+ if ( $quotes ) {
+ $text = str_replace('"', '&quot;', $text);
+ $text = str_replace("'", '&#039;', $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(134) => '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(196).chr(129) => 'L',
+ chr(197).chr(130) => 'l', chr(196).chr(131) => 'N',
+ chr(197).chr(132) => 'n', chr(196).chr(133) => 'N',
+ chr(197).chr(134) => 'n', chr(196).chr(135) => 'N',
+ chr(197).chr(136) => 'n', chr(196).chr(137) => 'N',
+ chr(197).chr(138) => 'n', chr(196).chr(139) => 'N',
+ chr(197).chr(140) => 'O', chr(196).chr(141) => 'o',
+ chr(197).chr(142) => 'O', chr(196).chr(143) => 'o',
+ chr(197).chr(144) => 'O', chr(196).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 ) {
+ return preg_replace('|a-z0-9 _.-|i', '', $username);
+}
+
+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(
+ '&#128;' => '&#8364;', // the Euro sign
+ '&#129;' => '',
+ '&#130;' => '&#8218;', // these are Windows CP1252 specific characters
+ '&#131;' => '&#402;', // they would look weird on non-Windows browsers
+ '&#132;' => '&#8222;',
+ '&#133;' => '&#8230;',
+ '&#134;' => '&#8224;',
+ '&#135;' => '&#8225;',
+ '&#136;' => '&#710;',
+ '&#137;' => '&#8240;',
+ '&#138;' => '&#352;',
+ '&#139;' => '&#8249;',
+ '&#140;' => '&#338;',
+ '&#141;' => '',
+ '&#142;' => '&#382;',
+ '&#143;' => '',
+ '&#144;' => '',
+ '&#145;' => '&#8216;',
+ '&#146;' => '&#8217;',
+ '&#147;' => '&#8220;',
+ '&#148;' => '&#8221;',
+ '&#149;' => '&#8226;',
+ '&#150;' => '&#8211;',
+ '&#151;' => '&#8212;',
+ '&#152;' => '&#732;',
+ '&#153;' => '&#8482;',
+ '&#154;' => '&#353;',
+ '&#155;' => '&#8250;',
+ '&#156;' => '&#339;',
+ '&#157;' => '',
+ '&#158;' => '',
+ '&#159;' => '&#376;'
+ );
+
+ // Remove metadata tags
+ $content = preg_replace('/<title>(.+?)<\/title>/','',$content);
+ $content = preg_replace('/<category>(.+?)<\/category>/','',$content);
+
+ // Converts lone & characters into &#38; (a.k.a. &amp;)
+ $content = preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$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_settings('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})#', '&lt;$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) {
+ $content = apply_filters('format_to_edit', $content);
+ $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('@','&#64;',$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\-_.]+)@([^,< \n\r]+)#i", "$1<a href=\"mailto:$2@$3\">$2@$3</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(']]>', ']]&gt;', $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(
+ '&quot;' => '&#34;',
+ '&amp;' => '&#38;',
+ '&frasl;' => '&#47;',
+ '&lt;' => '&#60;',
+ '&gt;' => '&#62;',
+ '|' => '&#124;',
+ '&nbsp;' => '&#160;',
+ '&iexcl;' => '&#161;',
+ '&cent;' => '&#162;',
+ '&pound;' => '&#163;',
+ '&curren;' => '&#164;',
+ '&yen;' => '&#165;',
+ '&brvbar;' => '&#166;',
+ '&brkbar;' => '&#166;',
+ '&sect;' => '&#167;',
+ '&uml;' => '&#168;',
+ '&die;' => '&#168;',
+ '&copy;' => '&#169;',
+ '&ordf;' => '&#170;',
+ '&laquo;' => '&#171;',
+ '&not;' => '&#172;',
+ '&shy;' => '&#173;',
+ '&reg;' => '&#174;',
+ '&macr;' => '&#175;',
+ '&hibar;' => '&#175;',
+ '&deg;' => '&#176;',
+ '&plusmn;' => '&#177;',
+ '&sup2;' => '&#178;',
+ '&sup3;' => '&#179;',
+ '&acute;' => '&#180;',
+ '&micro;' => '&#181;',
+ '&para;' => '&#182;',
+ '&middot;' => '&#183;',
+ '&cedil;' => '&#184;',
+ '&sup1;' => '&#185;',
+ '&ordm;' => '&#186;',
+ '&raquo;' => '&#187;',
+ '&frac14;' => '&#188;',
+ '&frac12;' => '&#189;',
+ '&frac34;' => '&#190;',
+ '&iquest;' => '&#191;',
+ '&Agrave;' => '&#192;',
+ '&Aacute;' => '&#193;',
+ '&Acirc;' => '&#194;',
+ '&Atilde;' => '&#195;',
+ '&Auml;' => '&#196;',
+ '&Aring;' => '&#197;',
+ '&AElig;' => '&#198;',
+ '&Ccedil;' => '&#199;',
+ '&Egrave;' => '&#200;',
+ '&Eacute;' => '&#201;',
+ '&Ecirc;' => '&#202;',
+ '&Euml;' => '&#203;',
+ '&Igrave;' => '&#204;',
+ '&Iacute;' => '&#205;',
+ '&Icirc;' => '&#206;',
+ '&Iuml;' => '&#207;',
+ '&ETH;' => '&#208;',
+ '&Ntilde;' => '&#209;',
+ '&Ograve;' => '&#210;',
+ '&Oacute;' => '&#211;',
+ '&Ocirc;' => '&#212;',
+ '&Otilde;' => '&#213;',
+ '&Ouml;' => '&#214;',
+ '&times;' => '&#215;',
+ '&Oslash;' => '&#216;',
+ '&Ugrave;' => '&#217;',
+ '&Uacute;' => '&#218;',
+ '&Ucirc;' => '&#219;',
+ '&Uuml;' => '&#220;',
+ '&Yacute;' => '&#221;',
+ '&THORN;' => '&#222;',
+ '&szlig;' => '&#223;',
+ '&agrave;' => '&#224;',
+ '&aacute;' => '&#225;',
+ '&acirc;' => '&#226;',
+ '&atilde;' => '&#227;',
+ '&auml;' => '&#228;',
+ '&aring;' => '&#229;',
+ '&aelig;' => '&#230;',
+ '&ccedil;' => '&#231;',
+ '&egrave;' => '&#232;',
+ '&eacute;' => '&#233;',
+ '&ecirc;' => '&#234;',
+ '&euml;' => '&#235;',
+ '&igrave;' => '&#236;',
+ '&iacute;' => '&#237;',
+ '&icirc;' => '&#238;',
+ '&iuml;' => '&#239;',
+ '&eth;' => '&#240;',
+ '&ntilde;' => '&#241;',
+ '&ograve;' => '&#242;',
+ '&oacute;' => '&#243;',
+ '&ocirc;' => '&#244;',
+ '&otilde;' => '&#245;',
+ '&ouml;' => '&#246;',
+ '&divide;' => '&#247;',
+ '&oslash;' => '&#248;',
+ '&ugrave;' => '&#249;',
+ '&uacute;' => '&#250;',
+ '&ucirc;' => '&#251;',
+ '&uuml;' => '&#252;',
+ '&yacute;' => '&#253;',
+ '&thorn;' => '&#254;',
+ '&yuml;' => '&#255;',
+ '&OElig;' => '&#338;',
+ '&oelig;' => '&#339;',
+ '&Scaron;' => '&#352;',
+ '&scaron;' => '&#353;',
+ '&Yuml;' => '&#376;',
+ '&fnof;' => '&#402;',
+ '&circ;' => '&#710;',
+ '&tilde;' => '&#732;',
+ '&Alpha;' => '&#913;',
+ '&Beta;' => '&#914;',
+ '&Gamma;' => '&#915;',
+ '&Delta;' => '&#916;',
+ '&Epsilon;' => '&#917;',
+ '&Zeta;' => '&#918;',
+ '&Eta;' => '&#919;',
+ '&Theta;' => '&#920;',
+ '&Iota;' => '&#921;',
+ '&Kappa;' => '&#922;',
+ '&Lambda;' => '&#923;',
+ '&Mu;' => '&#924;',
+ '&Nu;' => '&#925;',
+ '&Xi;' => '&#926;',
+ '&Omicron;' => '&#927;',
+ '&Pi;' => '&#928;',
+ '&Rho;' => '&#929;',
+ '&Sigma;' => '&#931;',
+ '&Tau;' => '&#932;',
+ '&Upsilon;' => '&#933;',
+ '&Phi;' => '&#934;',
+ '&Chi;' => '&#935;',
+ '&Psi;' => '&#936;',
+ '&Omega;' => '&#937;',
+ '&alpha;' => '&#945;',
+ '&beta;' => '&#946;',
+ '&gamma;' => '&#947;',
+ '&delta;' => '&#948;',
+ '&epsilon;' => '&#949;',
+ '&zeta;' => '&#950;',
+ '&eta;' => '&#951;',
+ '&theta;' => '&#952;',
+ '&iota;' => '&#953;',
+ '&kappa;' => '&#954;',
+ '&lambda;' => '&#955;',
+ '&mu;' => '&#956;',
+ '&nu;' => '&#957;',
+ '&xi;' => '&#958;',
+ '&omicron;' => '&#959;',
+ '&pi;' => '&#960;',
+ '&rho;' => '&#961;',
+ '&sigmaf;' => '&#962;',
+ '&sigma;' => '&#963;',
+ '&tau;' => '&#964;',
+ '&upsilon;' => '&#965;',
+ '&phi;' => '&#966;',
+ '&chi;' => '&#967;',
+ '&psi;' => '&#968;',
+ '&omega;' => '&#969;',
+ '&thetasym;' => '&#977;',
+ '&upsih;' => '&#978;',
+ '&piv;' => '&#982;',
+ '&ensp;' => '&#8194;',
+ '&emsp;' => '&#8195;',
+ '&thinsp;' => '&#8201;',
+ '&zwnj;' => '&#8204;',
+ '&zwj;' => '&#8205;',
+ '&lrm;' => '&#8206;',
+ '&rlm;' => '&#8207;',
+ '&ndash;' => '&#8211;',
+ '&mdash;' => '&#8212;',
+ '&lsquo;' => '&#8216;',
+ '&rsquo;' => '&#8217;',
+ '&sbquo;' => '&#8218;',
+ '&ldquo;' => '&#8220;',
+ '&rdquo;' => '&#8221;',
+ '&bdquo;' => '&#8222;',
+ '&dagger;' => '&#8224;',
+ '&Dagger;' => '&#8225;',
+ '&bull;' => '&#8226;',
+ '&hellip;' => '&#8230;',
+ '&permil;' => '&#8240;',
+ '&prime;' => '&#8242;',
+ '&Prime;' => '&#8243;',
+ '&lsaquo;' => '&#8249;',
+ '&rsaquo;' => '&#8250;',
+ '&oline;' => '&#8254;',
+ '&frasl;' => '&#8260;',
+ '&euro;' => '&#8364;',
+ '&image;' => '&#8465;',
+ '&weierp;' => '&#8472;',
+ '&real;' => '&#8476;',
+ '&trade;' => '&#8482;',
+ '&alefsym;' => '&#8501;',
+ '&crarr;' => '&#8629;',
+ '&lArr;' => '&#8656;',
+ '&uArr;' => '&#8657;',
+ '&rArr;' => '&#8658;',
+ '&dArr;' => '&#8659;',
+ '&hArr;' => '&#8660;',
+ '&forall;' => '&#8704;',
+ '&part;' => '&#8706;',
+ '&exist;' => '&#8707;',
+ '&empty;' => '&#8709;',
+ '&nabla;' => '&#8711;',
+ '&isin;' => '&#8712;',
+ '&notin;' => '&#8713;',
+ '&ni;' => '&#8715;',
+ '&prod;' => '&#8719;',
+ '&sum;' => '&#8721;',
+ '&minus;' => '&#8722;',
+ '&lowast;' => '&#8727;',
+ '&radic;' => '&#8730;',
+ '&prop;' => '&#8733;',
+ '&infin;' => '&#8734;',
+ '&ang;' => '&#8736;',
+ '&and;' => '&#8743;',
+ '&or;' => '&#8744;',
+ '&cap;' => '&#8745;',
+ '&cup;' => '&#8746;',
+ '&int;' => '&#8747;',
+ '&there4;' => '&#8756;',
+ '&sim;' => '&#8764;',
+ '&cong;' => '&#8773;',
+ '&asymp;' => '&#8776;',
+ '&ne;' => '&#8800;',
+ '&equiv;' => '&#8801;',
+ '&le;' => '&#8804;',
+ '&ge;' => '&#8805;',
+ '&sub;' => '&#8834;',
+ '&sup;' => '&#8835;',
+ '&nsub;' => '&#8836;',
+ '&sube;' => '&#8838;',
+ '&supe;' => '&#8839;',
+ '&oplus;' => '&#8853;',
+ '&otimes;' => '&#8855;',
+ '&perp;' => '&#8869;',
+ '&sdot;' => '&#8901;',
+ '&lceil;' => '&#8968;',
+ '&rceil;' => '&#8969;',
+ '&lfloor;' => '&#8970;',
+ '&rfloor;' => '&#8971;',
+ '&lang;' => '&#9001;',
+ '&rang;' => '&#9002;',
+ '&larr;' => '&#8592;',
+ '&uarr;' => '&#8593;',
+ '&rarr;' => '&#8594;',
+ '&darr;' => '&#8595;',
+ '&harr;' => '&#8596;',
+ '&loz;' => '&#9674;',
+ '&spades;' => '&#9824;',
+ '&clubs;' => '&#9827;',
+ '&hearts;' => '&#9829;',
+ '&diams;' => '&#9830;'
+ );
+
+ foreach ($to_ncr as $entity => $ncr) {
+ $text = str_replace($entity, $ncr, $text);
+ }
+ return $text;
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/functions-post.php b/wp-inst/wp-includes/functions-post.php
new file mode 100644
index 0000000..c078ffd
--- /dev/null
+++ b/wp-inst/wp-includes/functions-post.php
@@ -0,0 +1,714 @@
+<?php
+
+/**** DB Functions ****/
+
+/*
+ * generic function for inserting data into the posts table.
+ */
+function wp_insert_post($postarr = array()) {
+ global $wpdb, $allowedtags, $user_ID;
+
+ // 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);
+
+ // 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;
+ } else {
+ $id_result = $wpdb->get_row("SHOW TABLE STATUS LIKE '$wpdb->posts'");
+ $post_ID = $id_result->Auto_increment;
+ }
+
+ // 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, $post_ID);
+ } else {
+ $post_name = sanitize_title($post_name, $post_ID);
+ }
+
+ 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))
+ $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 ('publish' == $post_status) {
+ $post_name_check = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'publish' AND ID != '$post_ID' LIMIT 1");
+ if ($post_name_check) {
+ $suffix = 2;
+ while ($post_name_check) {
+ $alt_post_name = $post_name . "-$suffix";
+ $post_name_check = $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");
+ $suffix++;
+ }
+ $post_name = $alt_post_name;
+ }
+ }
+
+ if ($update) {
+ $postquery =
+ "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',
+ post_modified = '$post_date',
+ post_modified_gmt = '$post_date_gmt',
+ post_parent = '$post_parent',
+ menu_order = '$menu_order'
+ WHERE ID = $post_ID";
+ } else {
+ $postquery =
+ "INSERT INTO $wpdb->posts
+ (ID, 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, post_modified, post_modified_gmt, post_parent, menu_order)
+ VALUES
+ ('$post_ID', '$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', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order')";
+ }
+
+ $result = $wpdb->query($postquery);
+ if ( $update )
+ $rval = $wpdb->rows_affected;
+ else
+ $rval = $wpdb->insert_id;
+
+ // Set GUID
+ if ( ! $update )
+ $wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'");
+
+ wp_set_post_cats('', $post_ID, $post_category);
+
+ if ( $update) {
+ if ($previous_status != 'publish' && $post_status == 'publish')
+ do_action('private_to_published', $post_ID);
+
+ do_action('edit_post', $post_ID);
+ }
+
+ if ($post_status == 'publish') {
+ do_action('publish_post', $post_ID);
+ if ($post_pingback)
+ pingback($post_content, $post_ID);
+ do_enclose( $post_content, $post_ID );
+ do_trackbacks($post_ID);
+ } else if ($post_status == 'static') {
+ generate_page_rewrite_rules();
+
+ if ( empty($page_template) )
+ $page_template = 'Default Template';
+
+ if ( ! update_post_meta($post_ID, '_wp_page_template', $page_template))
+ add_post_meta($post_ID, '_wp_page_template', $page_template, true);
+ }
+
+ return $rval;
+}
+
+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;
+
+ // 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'];
+
+ // Merge old and new fields with new fields overwriting old ones.
+ $postarr = array_merge($post, $postarr);
+ $postarr['post_category'] = $post_cats;
+
+ 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);
+ }
+
+
+ $oldies = printr($old_categories,1);
+ $newbies = printr($post_categories,1);
+
+ // 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)");
+ }
+ }
+} // wp_set_post_cats()
+
+function wp_delete_post($postid = 0) {
+ global $wpdb;
+ $postid = (int) $postid;
+
+ if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") )
+ return $post;
+
+ 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 )
+ generate_page_rewrite_rules();
+
+ do_action('delete_post', $postid);
+
+ 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);
+ }
+ }
+}
+
+
+// query user capabilities
+// rather simplistic. shall evolve with future permission system overhaul
+// $blog_id and $category_id are there for future usage
+
+/* 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;
+}
+
+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 wp_new_comment( $commentdata, $spam = false ) {
+ global $wpdb;
+
+ $commentdata = apply_filters('preprocess_comment', $commentdata);
+ extract($commentdata);
+
+ $comment_post_ID = (int) $comment_post_ID;
+
+ $user_id = apply_filters('pre_user_id', $user_ID);
+ $author = apply_filters('pre_comment_author_name', $comment_author);
+ $email = apply_filters('pre_comment_author_email', $comment_author_email);
+ $url = apply_filters('pre_comment_author_url', $comment_author_url);
+ $comment = apply_filters('pre_comment_content', $comment_content);
+ $comment = apply_filters('post_comment_text', $comment); // Deprecated
+ $comment = apply_filters('comment_content_presave', $comment); // Deprecated
+
+ $user_ip = apply_filters('pre_comment_user_ip', $_SERVER['REMOTE_ADDR']);
+ $user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($user_ip) );
+ $user_agent = apply_filters('pre_comment_user_agent', $_SERVER['HTTP_USER_AGENT']);
+
+ $now = current_time('mysql');
+ $now_gmt = current_time('mysql', 1);
+
+ if ( $user_id ) {
+ $userdata = get_userdata($user_id);
+ $post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1");
+ }
+
+ // Simple duplicate check
+ $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$author' ";
+ if ( $email ) $dupe .= "OR comment_author_email = '$email' ";
+ $dupe .= ") AND comment_content = '$comment' 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 = '$user_ip' OR comment_author_email = '$email' ORDER BY comment_date DESC LIMIT 1") ) {
+ $time_lastcomment = mysql2date('U', $lasttime);
+ $time_newcomment = mysql2date('U', $now_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 ( $userdata && ( $user_id == $post_author || $userdata->user_level >= 9 ) ) {
+ $approved = 1;
+ } else {
+ if ( check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) )
+ $approved = 1;
+ else
+ $approved = 0;
+ if ( wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) )
+ $approved = 'spam';
+ }
+
+ $approved = apply_filters('pre_comment_approved', $approved);
+
+ $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, user_id)
+ VALUES
+ ('$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$now_gmt', '$comment', '$approved', '$user_agent', '$comment_type', '$user_id')
+ ");
+
+ $comment_id = $wpdb->insert_id;
+ do_action('comment_post', $comment_id, $approved);
+
+ if ( 'spam' !== $approved ) { // If it's spam save it silently for later crunching
+ if ( '0' == $approved )
+ wp_notify_moderator($comment_id);
+
+ if ( get_settings('comments_notify') && $approved )
+ wp_notify_postauthor($comment_id, $comment_type);
+ }
+
+ return $result;
+}
+
+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;
+
+ do_action('edit_comment', $comment_ID);
+
+ return $rval;
+}
+
+function do_trackbacks($post_id) {
+ global $wpdb;
+
+ $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $post_id");
+ $to_ping = get_to_ping($post_id);
+ $pinged = get_pung($post_id);
+ if ( empty($to_ping) )
+ return;
+ if (empty($post->post_excerpt))
+ $excerpt = apply_filters('the_content', $post->post_content);
+ else
+ $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
+ $excerpt = str_replace(']]>', ']]&gt;', $excerpt);
+ $excerpt = strip_tags($excerpt);
+ $excerpt = substr($excerpt, 0, 252) . '...';
+
+ $post_title = apply_filters('the_title', $post->post_title);
+ $post_title = strip_tags($post_title);
+
+ if ($to_ping) : foreach ($to_ping as $tb_ping) :
+ $tb_ping = trim($tb_ping);
+ if ( !in_array($tb_ping, $pinged) )
+ trackback($tb_ping, $post_title, $excerpt, $post_id);
+ endforeach; endif;
+}
+
+function get_pung($post_id) { // Get URIs already pung for a post
+ global $wpdb;
+ $pung = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_id");
+ $pung = trim($pung);
+ $pung = preg_split('/\s/', $pung);
+ return $pung;
+}
+
+function get_enclosed($post_id) { // Get enclosures already enclosed for a post
+ global $wpdb;
+ $custom_fields = get_post_custom( $post_id );
+ $pung = array();
+ if( is_array( $custom_fields ) ) {
+ while( list( $key, $val ) = each( $custom_fields ) ) {
+ if( $key == 'enclosure' ) {
+ if (is_array($val)) {
+ foreach($val as $enc) {
+ $enclosure = split( "\n", $enc );
+ $pung[] = trim( $enclosure[ 0 ] );
+ }
+ }
+ }
+ }
+ }
+ return $pung;
+}
+
+function get_to_ping($post_id) { // Get any URIs in the todo list
+ global $wpdb;
+ $to_ping = $wpdb->get_var("SELECT to_ping FROM $wpdb->posts WHERE ID = $post_id");
+ $to_ping = trim($to_ping);
+ $to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY);
+ return $to_ping;
+}
+
+function add_ping($post_id, $uri) { // Add a URI to those already pung
+ global $wpdb;
+ $pung = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_id");
+ $pung = trim($pung);
+ $pung = preg_split('/\s/', $pung);
+ $pung[] = $uri;
+ $new = implode("\n", $pung);
+ return $wpdb->query("UPDATE $wpdb->posts SET pinged = '$new' WHERE ID = $post_id");
+}
+
+function generate_page_rewrite_rules() {
+ global $wpdb;
+ $posts = $wpdb->get_results("SELECT ID, post_name FROM $wpdb->posts WHERE post_status = 'static' ORDER BY post_parent DESC");
+
+ $page_rewrite_rules = array();
+
+ if ($posts) {
+ foreach ($posts as $post) {
+ // URI => page name
+ $uri = get_page_uri($post->ID);
+
+ $page_rewrite_rules[$uri] = $post->post_name;
+ }
+
+ update_option('page_uris', $page_rewrite_rules);
+
+ save_mod_rewrite_rules();
+ }
+}
+
+?>
diff --git a/wp-inst/wp-includes/functions.php b/wp-inst/wp-includes/functions.php
new file mode 100644
index 0000000..af027d7
--- /dev/null
+++ b/wp-inst/wp-includes/functions.php
@@ -0,0 +1,2000 @@
+<?php
+
+require_once(dirname(__FILE__).'/functions-compat.php');
+
+if (!function_exists('_')) {
+ function _($string) {
+ return $string;
+ }
+}
+
+function get_profile($field, $user = false) {
+ global $wpdb;
+ if (!$user)
+ $user = $wpdb->escape($_COOKIE['wordpressuser_' . COOKIEHASH]);
+ return $wpdb->get_var("SELECT $field FROM $wpdb->users WHERE user_login = '$user'");
+}
+
+function mysql2date($dateformatstring, $mysqlstring, $translate = true) {
+ global $month, $weekday, $month_abbrev, $weekday_abbrev;
+ $m = $mysqlstring;
+ if (empty($m)) {
+ return false;
+ }
+ $i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4));
+ if (!empty($month) && !empty($weekday) && $translate) {
+ $datemonth = $month[date('m', $i)];
+ $datemonth_abbrev = $month_abbrev[$datemonth];
+ $dateweekday = $weekday[date('w', $i)];
+ $dateweekday_abbrev = $weekday_abbrev[$dateweekday];
+ $dateformatstring = ' '.$dateformatstring;
+ $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
+
+ $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
+ }
+ $j = @date($dateformatstring, $i);
+ if (!$j) {
+ // for debug purposes
+ // echo $i." ".$mysqlstring;
+ }
+ return $j;
+}
+
+function current_time($type, $gmt = 0) {
+ switch ($type) {
+ case 'mysql':
+ if ($gmt) $d = gmdate('Y-m-d H:i:s');
+ else $d = gmdate('Y-m-d H:i:s', (time() + (get_settings('gmt_offset') * 3600)));
+ return $d;
+ break;
+ case 'timestamp':
+ if ($gmt) $d = time();
+ else $d = time() + (get_settings('gmt_offset') * 3600);
+ return $d;
+ break;
+ }
+}
+
+function date_i18n($dateformatstring, $unixtimestamp) {
+ global $month, $weekday, $month_abbrev, $weekday_abbrev;
+ $i = $unixtimestamp;
+ if ((!empty($month)) && (!empty($weekday))) {
+ $datemonth = $month[date('m', $i)];
+ $datemonth_abbrev = $month_abbrev[$datemonth];
+ $dateweekday = $weekday[date('w', $i)];
+ $dateweekday_abbrev = $weekday_abbrev[$dateweekday];
+ $dateformatstring = ' '.$dateformatstring;
+ $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
+ $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
+ }
+ $j = @date($dateformatstring, $i);
+ return $j;
+ }
+
+function get_weekstartend($mysqlstring, $start_of_week) {
+ $my = substr($mysqlstring,0,4);
+ $mm = substr($mysqlstring,8,2);
+ $md = substr($mysqlstring,5,2);
+ $day = mktime(0,0,0, $md, $mm, $my);
+ $weekday = date('w',$day);
+ $i = 86400;
+
+ if ($weekday < get_settings('start_of_week'))
+ $weekday = 7 - (get_settings('start_of_week') - $weekday);
+
+ while ($weekday > get_settings('start_of_week')) {
+ $weekday = date('w',$day);
+ if ($weekday < get_settings('start_of_week'))
+ $weekday = 7 - (get_settings('start_of_week') - $weekday);
+
+ $day = $day - 86400;
+ $i = 0;
+ }
+ $week['start'] = $day + 86400 - $i;
+ //$week['end'] = $day - $i + 691199;
+ $week['end'] = $week['start'] + 604799;
+ return $week;
+}
+
+function get_lastpostdate($timezone = 'server') {
+ global $cache_lastpostdate, $pagenow, $wpdb;
+ $add_seconds_blog = get_settings('gmt_offset') * 3600;
+ $add_seconds_server = date('Z');
+ $now = current_time('mysql', 1);
+ if ( !isset($cache_lastpostdate[$timezone]) ) {
+ switch(strtolower($timezone)) {
+ case 'gmt':
+ $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
+ break;
+ case 'blog':
+ $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
+ break;
+ case 'server':
+ $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
+ break;
+ }
+ $cache_lastpostdate[$timezone] = $lastpostdate;
+ } else {
+ $lastpostdate = $cache_lastpostdate[$timezone];
+ }
+ return $lastpostdate;
+}
+
+function get_lastpostmodified($timezone = 'server') {
+ global $cache_lastpostmodified, $pagenow, $wpdb;
+ $add_seconds_blog = get_settings('gmt_offset') * 3600;
+ $add_seconds_server = date('Z');
+ $now = current_time('mysql', 1);
+ if ( !isset($cache_lastpostmodified[$timezone]) ) {
+ switch(strtolower($timezone)) {
+ case 'gmt':
+ $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
+ break;
+ case 'blog':
+ $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
+ break;
+ case 'server':
+ $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
+ break;
+ }
+ $lastpostdate = get_lastpostdate($timezone);
+ if ($lastpostdate > $lastpostmodified) {
+ $lastpostmodified = $lastpostdate;
+ }
+ $cache_lastpostmodified[$timezone] = $lastpostmodified;
+ } else {
+ $lastpostmodified = $cache_lastpostmodified[$timezone];
+ }
+ return $lastpostmodified;
+}
+
+function user_pass_ok($user_login,$user_pass) {
+ global $cache_userdata;
+ if ( empty($cache_userdata[$user_login]) ) {
+ $userdata = get_userdatabylogin($user_login);
+ } else {
+ $userdata = $cache_userdata[$user_login];
+ }
+ return (md5($user_pass) == $userdata->user_pass);
+}
+
+
+function get_usernumposts($userid) {
+ global $wpdb;
+ return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_status = 'publish'");
+}
+
+
+// examine a url (supposedly from this blog) and try to
+// determine the post ID it represents.
+function url_to_postid($url) {
+ global $wp_rewrite;
+
+ // First, check to see if there is a 'p=N' or 'page_id=N' to match against
+ preg_match('#[?&](p|page_id)=(\d+)#', $url, $values);
+ $id = intval($values[2]);
+ if ($id) return $id;
+
+ // Check to see if we are using rewrite rules
+ $rewrite = $wp_rewrite->wp_rewrite_rules();
+
+ // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
+ if ( empty($rewrite) )
+ return 0;
+
+ // $url cleanup by Mark Jaquith
+ // This fixes things like #anchors, ?query=strings, missing 'www.',
+ // added 'www.', or added 'index.php/' that will mess up our WP_Query
+ // and return a false negative
+
+ // Get rid of the #anchor
+ $url_split = explode('#', $url);
+ $url = $url_split[0];
+
+ // Get rid of URI ?query=string
+ $url_split = explode('?', $url);
+ $url = $url_split[0];
+
+ // Add 'www.' if it is absent and should be there
+ if ( false !== strpos(get_settings('home'), '://www.') && false === strpos($url, '://www.') )
+ $url = str_replace('://', '://www.', $url);
+
+ // Strip 'www.' if it is present and shouldn't be
+ if ( false === strpos(get_settings('home'), '://www.') )
+ $url = str_replace('://www.', '://', $url);
+
+ // Strip 'index.php/' if we're not using path info permalinks
+ if ( false === strpos($rewrite, 'index.php/') )
+ $url = str_replace('index.php/', '', $url);
+
+ // Chop off http://domain.com
+ if ( false !== strpos($url, get_settings('home')) ) {
+ $url = str_replace(get_settings('home'), '', $url);
+ } else {
+ // Chop off /path/to/blog
+ $home_path = parse_url(get_settings('home'));
+ $home_path = $home_path['path'];
+ $url = str_replace($home_path, '', $url);
+ }
+
+ // Trim leading and lagging slashes
+ $url = trim($url, '/');
+
+ $request = $url;
+
+ // Done with cleanup
+
+ // Look for matches.
+ $request_match = $request;
+ foreach ($rewrite as $match => $query) {
+ // If the requesting file is the anchor of the match, prepend it
+ // to the path info.
+ if ((! empty($url)) && (strpos($match, $url) === 0)) {
+ $request_match = $url . '/' . $request;
+ }
+
+ if (preg_match("!^$match!", $request_match, $matches)) {
+ // Got a match.
+ // Trim the query of everything up to the '?'.
+ $query = preg_replace("!^.+\?!", '', $query);
+
+ // Substitute the substring matches into the query.
+ eval("\$query = \"$query\";");
+ $query = new WP_Query($query);
+ if ( $query->is_post || $query->is_page )
+ return $query->post->ID;
+ else
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
+
+/* Options functions */
+
+function get_settings($setting) {
+ global $wpdb, $cache_settings, $cache_nonexistantoptions;
+ if ( strstr($_SERVER['REQUEST_URI'], 'wp-admin/install.php') || defined('WP_INSTALLING') )
+ return false;
+
+ if ( empty($cache_settings) )
+ $cache_settings = get_alloptions();
+
+ if ( empty($cache_nonexistantoptions) )
+ $cache_nonexistantoptions = array();
+
+ if ('home' == $setting && '' == $cache_settings->home)
+ return apply_filters('option_' . $setting, $cache_settings->siteurl);
+
+ if ( isset($cache_settings->$setting) ) :
+ return apply_filters('option_' . $setting, $cache_settings->$setting);
+ else :
+ // for these cases when we're asking for an unknown option
+ if ( isset($cache_nonexistantoptions[$setting]) )
+ return false;
+
+ $option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
+
+ if (!$option) :
+ $cache_nonexistantoptions[$setting] = true;
+ return false;
+ endif;
+
+ @ $kellogs = unserialize($option);
+ if ($kellogs !== FALSE)
+ return apply_filters('option_' . $setting, $kellogs);
+ else return apply_filters('option_' . $setting, $option);
+ endif;
+}
+
+function get_option($option) {
+ return get_settings($option);
+}
+
+function form_option($option) {
+ echo htmlspecialchars( get_option($option), ENT_QUOTES );
+}
+
+function get_alloptions() {
+ global $wpdb, $wp_queries;
+ $wpdb->hide_errors();
+ if (!$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'")) {
+ $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
+ }
+ $wpdb->show_errors();
+
+ foreach ($options as $option) {
+ // "When trying to design a foolproof system,
+ // never underestimate the ingenuity of the fools :)" -- Dougal
+ if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ @ $value = unserialize($option->option_value);
+ if ($value === FALSE)
+ $value = $option->option_value;
+ $all_options->{$option->option_name} = apply_filters('pre_option_' . $option->option_name, $value);
+ }
+ return apply_filters('all_options', $all_options);
+}
+
+function update_option($option_name, $newvalue) {
+ global $wpdb, $cache_settings;
+ if ( is_array($newvalue) || is_object($newvalue) )
+ $newvalue = serialize($newvalue);
+
+ $newvalue = trim($newvalue); // I can't think of any situation we wouldn't want to trim
+
+ // If the new and old values are the same, no need to update.
+ if ($newvalue == get_option($option_name)) {
+ return true;
+ }
+
+ // If it's not there add it
+ if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$option_name'") )
+ add_option($option_name);
+
+ $newvalue = $wpdb->escape($newvalue);
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'");
+ $cache_settings = get_alloptions(); // Re cache settings
+ return true;
+}
+
+
+// thx Alex Stapleton, http://alex.vort-x.net/blog/
+function add_option($name, $value = '', $description = '', $autoload = 'yes') {
+ global $wpdb;
+ $original = $value;
+ if ( is_array($value) || is_object($value) )
+ $value = serialize($value);
+
+ if( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$name'") ) {
+ $name = $wpdb->escape($name);
+ $value = $wpdb->escape($value);
+ $description = $wpdb->escape($description);
+ $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, option_description, autoload) VALUES ('$name', '$value', '$description', '$autoload')");
+
+ if($wpdb->insert_id) {
+ global $cache_settings;
+ $cache_settings->{$name} = $original;
+ }
+ }
+ return;
+}
+
+function delete_option($name) {
+ global $wpdb;
+ // Get the ID, if no ID then return
+ $option_id = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = '$name'");
+ if (!$option_id) return false;
+ $wpdb->query("DELETE FROM $wpdb->options WHERE option_name = '$name'");
+ return true;
+}
+
+function add_post_meta($post_id, $key, $value, $unique = false) {
+ global $wpdb;
+
+ if ($unique) {
+ if( $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
+= '$key' AND post_id = '$post_id'") ) {
+ return false;
+ }
+ }
+
+ $wpdb->query("INSERT INTO $wpdb->postmeta
+ (post_id,meta_key,meta_value)
+ VALUES ('$post_id','$key','$value')
+ ");
+
+ return true;
+}
+
+function delete_post_meta($post_id, $key, $value = '') {
+ global $wpdb;
+
+ if (empty($value)) {
+ $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE
+post_id = '$post_id' AND meta_key = '$key'");
+ } else {
+ $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE
+post_id = '$post_id' AND meta_key = '$key' AND meta_value = '$value'");
+ }
+
+ if (!$meta_id) return false;
+
+ if (empty($value)) {
+ $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
+AND meta_key = '$key'");
+ } else {
+ $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
+AND meta_key = '$key' AND meta_value = '$value'");
+ }
+
+ return true;
+}
+
+function get_post_meta($post_id, $key, $single = false) {
+ global $wpdb, $post_meta_cache;
+
+ if (isset($post_meta_cache[$post_id][$key])) {
+ if ($single) {
+ return $post_meta_cache[$post_id][$key][0];
+ } else {
+ return $post_meta_cache[$post_id][$key];
+ }
+ }
+
+ $metalist = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = '$post_id' AND meta_key = '$key'", ARRAY_N);
+
+ $values = array();
+ if ($metalist) {
+ foreach ($metalist as $metarow) {
+ $values[] = $metarow[0];
+ }
+ }
+
+ if ($single) {
+ if (count($values)) {
+ return $values[0];
+ } else {
+ return '';
+ }
+ } else {
+ return $values;
+ }
+}
+
+function update_post_meta($post_id, $key, $value, $prev_value = '') {
+ global $wpdb, $post_meta_cache;
+
+ if(! $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
+= '$key' AND post_id = '$post_id'") ) {
+ return false;
+ }
+
+ if (empty($prev_value)) {
+ $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
+meta_key = '$key' AND post_id = '$post_id'");
+ } else {
+ $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
+meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'");
+ }
+
+ return true;
+}
+
+// Deprecated. Use get_post().
+function get_postdata($postid) {
+ $post = &get_post($postid);
+
+ $postdata = array (
+ 'ID' => $post->ID,
+ 'Author_ID' => $post->post_author,
+ 'Date' => $post->post_date,
+ 'Content' => $post->post_content,
+ 'Excerpt' => $post->post_excerpt,
+ 'Title' => $post->post_title,
+ 'Category' => $post->post_category,
+ 'post_status' => $post->post_status,
+ 'comment_status' => $post->comment_status,
+ 'ping_status' => $post->ping_status,
+ 'post_password' => $post->post_password,
+ 'to_ping' => $post->to_ping,
+ 'pinged' => $post->pinged,
+ 'post_name' => $post->post_name
+ );
+
+ return $postdata;
+}
+
+// Retrieves post data given a post ID or post object.
+// Handles post caching.
+function &get_post(&$post, $output = OBJECT) {
+ global $post_cache, $wpdb;
+
+ if ( empty($post) ) {
+ if ( isset($GLOBALS['post']) )
+ $_post = & $GLOBALS['post'];
+ else
+ $_post = null;
+ } elseif (is_object($post) ) {
+ if (! isset($post_cache[$post->ID]))
+ $post_cache[$post->ID] = &$post;
+ $_post = & $post_cache[$post->ID];
+ } else {
+ if (isset($post_cache[$post]))
+ $_post = & $post_cache[$post];
+ else {
+ $query = "SELECT * FROM $wpdb->posts WHERE ID = '$post'";
+ $post_cache[$post] = & $wpdb->get_row($query);
+ $_post = & $post_cache[$post];
+ }
+ }
+
+ if ( $output == OBJECT ) {
+ return $_post;
+ } elseif ( $output == ARRAY_A ) {
+ return get_object_vars($_post);
+ } elseif ( $output == ARRAY_N ) {
+ return array_values(get_object_vars($_post));
+ } else {
+ return $_post;
+ }
+}
+
+// Retrieves page data given a page ID or page object.
+// Handles page caching.
+function &get_page(&$page, $output = OBJECT) {
+ global $page_cache, $wpdb;
+
+ if ( empty($page) ) {
+ if ( isset($GLOBALS['page']) )
+ $_page = & $GLOBALS['page'];
+ else
+ $_page = null;
+ } elseif (is_object($page) ) {
+ if (! isset($page_cache[$page->ID]))
+ $page_cache[$page->ID] = &$page;
+ $_page = & $page_cache[$page->ID];
+ } else {
+ if ( isset($GLOBALS['page']) && ($page == $GLOBALS['page']->ID) )
+ $_page = & $GLOBALS['page'];
+ elseif (isset($page_cache[$page]))
+ $_page = & $page_cache[$page];
+ else {
+ $query = "SELECT * FROM $wpdb->posts WHERE ID= '$page'";
+ $page_cache[$page] = & $wpdb->get_row($query);
+ $_page = & $page_cache[$page];
+ }
+ }
+
+ if ( $output == OBJECT ) {
+ return $_page;
+ } elseif ( $output == ARRAY_A ) {
+ return get_object_vars($_page);
+ } elseif ( $output == ARRAY_N ) {
+ return array_values(get_object_vars($_page));
+ } else {
+ return $_page;
+ }
+}
+
+// Retrieves category data given a category ID or category object.
+// Handles category caching.
+function &get_category(&$category, $output = OBJECT) {
+ global $cache_categories, $wpdb;
+
+ if ( empty($category) )
+ return null;
+
+ if ( ! isset($cache_categories))
+ update_category_cache();
+
+ if (is_object($category)) {
+ if ( ! isset($cache_categories[$category->cat_ID]))
+ $cache_categories[$category->cat_ID] = &$category;
+ $_category = & $cache_categories[$category->cat_ID];
+ } else {
+ if ( !isset($cache_categories[$category]) ) {
+ $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category'");
+ $cache_categories[$category->cat_ID] = & $_category;
+ } else {
+ $_category = & $cache_categories[$category];
+ }
+ }
+
+ if ( $output == OBJECT ) {
+ return $_category;
+ } elseif ( $output == ARRAY_A ) {
+ return get_object_vars($_category);
+ } elseif ( $output == ARRAY_N ) {
+ return array_values(get_object_vars($_category));
+ } else {
+ return $_category;
+ }
+}
+
+// Retrieves comment data given a comment ID or comment object.
+// Handles comment caching.
+function &get_comment(&$comment, $output = OBJECT) {
+ global $comment_cache, $wpdb;
+
+ if ( empty($comment) )
+ return null;
+
+ if (is_object($comment)) {
+ if ( ! isset($comment_cache[$comment->comment_ID]))
+ $comment_cache[$comment->comment_ID] = &$comment;
+ $_comment = & $comment_cache[$comment->comment_ID];
+ } else {
+ if ( !isset($comment_cache[$comment]) ) {
+ $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment'");
+ $comment_cache[$comment->comment_ID] = & $_comment;
+ } else {
+ $_comment = & $comment_cache[$comment];
+ }
+ }
+
+ if ( $output == OBJECT ) {
+ return $_comment;
+ } elseif ( $output == ARRAY_A ) {
+ return get_object_vars($_comment);
+ } elseif ( $output == ARRAY_N ) {
+ return array_values(get_object_vars($_comment));
+ } else {
+ return $_comment;
+ }
+}
+
+function get_catname($cat_ID) {
+ $category = &get_category($cat_ID);
+ return $category->cat_name;
+}
+
+function gzip_compression() {
+ if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) return false;
+ if ( !get_settings('gzipcompression') ) return false;
+
+ if( extension_loaded('zlib') ) {
+ ob_start('ob_gzhandler');
+ }
+}
+
+
+// functions to count the page generation time (from phpBB2)
+// ( or just any time between timer_start() and timer_stop() )
+
+function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
+ global $timestart, $timeend;
+ $mtime = microtime();
+ $mtime = explode(' ',$mtime);
+ $mtime = $mtime[1] + $mtime[0];
+ $timeend = $mtime;
+ $timetotal = $timeend-$timestart;
+ if ($display)
+ echo number_format($timetotal,$precision);
+ return $timetotal;
+}
+
+function weblog_ping($server = '', $path = '') {
+ global $wp_version;
+ include_once (ABSPATH . WPINC . '/class-IXR.php');
+
+ // using a timeout of 3 seconds should be enough to cover slow servers
+ $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
+ $client->timeout = 3;
+ $client->useragent .= ' -- WordPress/'.$wp_version;
+
+ // when set to true, this outputs debug messages by itself
+ $client->debug = false;
+ $home = trailingslashit( get_option('home') );
+ if ( !$client->query('weblogUpdates.extendedPing', get_settings('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping
+ $client->query('weblogUpdates.ping', get_settings('blogname'), $home);
+}
+
+function generic_ping($post_id = 0) {
+ $services = get_settings('ping_sites');
+ $services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines
+ $services = trim($services);
+ if ('' != $services) {
+ $services = explode("\n", $services);
+ foreach ($services as $service) {
+ weblog_ping($service);
+ }
+ }
+
+ return $post_id;
+}
+
+// Send a Trackback
+function trackback($trackback_url, $title, $excerpt, $ID) {
+ global $wpdb, $wp_version;
+
+ if (empty($trackback_url))
+ return;
+
+ $title = urlencode($title);
+ $excerpt = urlencode($excerpt);
+ $blog_name = urlencode(get_settings('blogname'));
+ $tb_url = $trackback_url;
+ $url = urlencode(get_permalink($ID));
+ $query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
+ $trackback_url = parse_url($trackback_url);
+ $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'.$trackback_url['query'] : '') . " HTTP/1.0\r\n";
+ $http_request .= 'Host: '.$trackback_url['host']."\r\n";
+ $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n";
+ $http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
+ $http_request .= "User-Agent: WordPress/" . $wp_version;
+ $http_request .= "\r\n\r\n";
+ $http_request .= $query_string;
+ if ( '' == $trackback_url['port'] )
+ $trackback_url['port'] = 80;
+ $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
+ @fputs($fs, $http_request);
+/*
+ $debug_file = 'trackback.log';
+ $fp = fopen($debug_file, 'a');
+ fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n");
+ while(!@feof($fs)) {
+ fwrite($fp, @fgets($fs, 4096));
+ }
+ fwrite($fp, "\n\n");
+ fclose($fp);
+*/
+ @fclose($fs);
+
+ $wpdb->query("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'");
+ $wpdb->query("UPDATE $wpdb->posts SET to_ping = REPLACE(to_ping, '$tb_url', '') WHERE ID = '$ID'");
+ return $result;
+}
+
+function make_url_footnote($content) {
+ preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches);
+ $j = 0;
+ for ($i=0; $i<count($matches[0]); $i++) {
+ $links_summary = (!$j) ? "\n" : $links_summary;
+ $j++;
+ $link_match = $matches[0][$i];
+ $link_number = '['.($i+1).']';
+ $link_url = $matches[2][$i];
+ $link_text = $matches[4][$i];
+ $content = str_replace($link_match, $link_text.' '.$link_number, $content);
+ $link_url = (strtolower(substr($link_url,0,7)) != 'http://') ? get_settings('home') . $link_url : $link_url;
+ $links_summary .= "\n".$link_number.' '.$link_url;
+ }
+ $content = strip_tags($content);
+ $content .= $links_summary;
+ return $content;
+}
+
+
+function xmlrpc_getposttitle($content) {
+ global $post_default_title;
+ if (preg_match('/<title>(.+?)<\/title>/is', $content, $matchtitle)) {
+ $post_title = $matchtitle[0];
+ $post_title = preg_replace('/<title>/si', '', $post_title);
+ $post_title = preg_replace('/<\/title>/si', '', $post_title);
+ } else {
+ $post_title = $post_default_title;
+ }
+ return $post_title;
+}
+
+function xmlrpc_getpostcategory($content) {
+ global $post_default_category;
+ if (preg_match('/<category>(.+?)<\/category>/is', $content, $matchcat)) {
+ $post_category = trim($matchcat[1], ',');
+ $post_category = explode(',', $post_category);
+ } else {
+ $post_category = $post_default_category;
+ }
+ return $post_category;
+}
+
+function xmlrpc_removepostdata($content) {
+ $content = preg_replace('/<title>(.+?)<\/title>/si', '', $content);
+ $content = preg_replace('/<category>(.+?)<\/category>/si', '', $content);
+ $content = trim($content);
+ return $content;
+}
+
+function debug_fopen($filename, $mode) {
+ global $debug;
+ if ($debug == 1) {
+ $fp = fopen($filename, $mode);
+ return $fp;
+ } else {
+ return false;
+ }
+}
+
+function debug_fwrite($fp, $string) {
+ global $debug;
+ if ($debug == 1) {
+ fwrite($fp, $string);
+ }
+}
+
+function debug_fclose($fp) {
+ global $debug;
+ if ($debug == 1) {
+ fclose($fp);
+ }
+}
+
+function do_enclose( $content, $post_ID ) {
+ global $wp_version, $wpdb;
+ include_once (ABSPATH . WPINC . '/class-IXR.php');
+
+ $log = debug_fopen(ABSPATH . '/enclosures.log', 'a');
+ $post_links = array();
+ debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n");
+
+ $pung = get_enclosed( $post_ID );
+
+ $ltrs = '\w';
+ $gunk = '/#~:.?+=&%@!\-';
+ $punc = '.:?\-';
+ $any = $ltrs . $gunk . $punc;
+
+ preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
+
+ debug_fwrite($log, 'Post contents:');
+ debug_fwrite($log, $content."\n");
+
+ foreach($post_links_temp[0] as $link_test) :
+ if ( !in_array($link_test, $pung) ) : // If we haven't pung it already
+ $test = parse_url($link_test);
+ if (isset($test['query']))
+ $post_links[] = $link_test;
+ elseif(($test['path'] != '/') && ($test['path'] != ''))
+ $post_links[] = $link_test;
+ endif;
+ endforeach;
+
+ foreach ($post_links as $url) :
+ if ( $url != '' && !$wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE post_id = '$post_ID' AND meta_key = 'enclosure' AND meta_value LIKE ('$url%')") ) {
+ if ( $headers = wp_get_http_headers( $url) ) {
+ $len = (int) $headers['content-length'];
+ $type = $wpdb->escape( $headers['content-type'] );
+ $allowed_types = array( 'video', 'audio' );
+ if( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
+ $meta_value = "$url\n$len\n$type\n";
+ $wpdb->query( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` )
+ VALUES ( '$post_ID', 'enclosure' , '$meta_value')" );
+ }
+ }
+ }
+ endforeach;
+}
+
+function wp_get_http_headers( $url ) {
+ set_time_limit( 60 );
+ $parts = parse_url( $url );
+ $file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : '');
+ $host = $parts['host'];
+ if ( !isset( $parts['port'] ) )
+ $parts['port'] = 80;
+
+ $head = "HEAD $file HTTP/1.1\r\nHOST: $host\r\n\r\n";
+
+ $fp = @fsockopen($host, $parts['port'], $err_num, $err_msg, 3);
+ if ( !$fp )
+ return false;
+
+ $response = '';
+ fputs( $fp, $head );
+ while ( !feof( $fp ) && strpos( $response, "\r\n\r\n" ) == false )
+ $response .= fgets( $fp, 2048 );
+ fclose( $fp );
+ preg_match_all('/(.*?): (.*)\r/', $response, $matches);
+ $count = count($matches[1]);
+ for ( $i = 0; $i < $count; $i++) {
+ $key = strtolower($matches[1][$i]);
+ $headers["$key"] = $matches[2][$i];
+ }
+
+ preg_match('/.*([0-9]{3}).*/', $response, $return);
+ $headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404
+ return $headers;
+}
+
+// Deprecated. Use the new post loop.
+function start_wp() {
+ global $wp_query, $post;
+
+ // Since the old style loop is being used, advance the query iterator here.
+ $wp_query->next_post();
+
+ setup_postdata($post);
+}
+
+// Setup global post data.
+function setup_postdata($post) {
+ global $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages, $wp_query;
+ global $pagenow;
+
+ $id = $post->ID;
+
+ $authordata = get_userdata($post->post_author);
+
+ $day = mysql2date('d.m.y', $post->post_date);
+ $currentmonth = mysql2date('m', $post->post_date);
+ $numpages = 1;
+ $page = get_query_var('page');
+ if (!$page)
+ $page = 1;
+ if (is_single() || is_page())
+ $more = 1;
+ $content = $post->post_content;
+ if (preg_match('/<!--nextpage-->/', $content)) {
+ if ($page > 1)
+ $more = 1;
+ $multipage = 1;
+ $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
+ $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
+ $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
+ $pages = explode('<!--nextpage-->', $content);
+ $numpages = count($pages);
+ } else {
+ $pages[0] = $post->post_content;
+ $multipage = 0;
+ }
+ return true;
+}
+
+function is_new_day() {
+ global $day, $previousday;
+ if ($day != $previousday) {
+ return(1);
+ } else {
+ return(0);
+ }
+}
+
+// Filters: these are the core of WP's plugin architecture
+
+function merge_filters($tag) {
+ global $wp_filter;
+ if (isset($wp_filter['all'])) {
+ foreach ($wp_filter['all'] as $priority => $functions) {
+ if (isset($wp_filter[$tag][$priority]))
+ $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]);
+ else
+ $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], array());
+ $wp_filter[$tag][$priority] = array_unique($wp_filter[$tag][$priority]);
+ }
+ }
+
+ if ( isset($wp_filter[$tag]) )
+ ksort( $wp_filter[$tag] );
+}
+
+function apply_filters($tag, $string) {
+ global $wp_filter;
+
+ $args = array_slice(func_get_args(), 2);
+
+ merge_filters($tag);
+
+ if (!isset($wp_filter[$tag])) {
+ return $string;
+ }
+ foreach ($wp_filter[$tag] as $priority => $functions) {
+ if (!is_null($functions)) {
+ foreach($functions as $function) {
+
+ $all_args = array_merge(array($string), $args);
+ $function_name = $function['function'];
+ $accepted_args = $function['accepted_args'];
+
+ if($accepted_args == 1) {
+ $the_args = array($string);
+ } elseif ($accepted_args > 1) {
+ $the_args = array_slice($all_args, 0, $accepted_args);
+ } elseif($accepted_args == 0) {
+ $the_args = NULL;
+ } else {
+ $the_args = $all_args;
+ }
+
+ $string = call_user_func_array($function_name, $the_args);
+ }
+ }
+ }
+ return $string;
+}
+
+function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
+ global $wp_filter;
+
+ // check that we don't already have the same filter at the same priority
+ if (isset($wp_filter[$tag]["$priority"])) {
+ foreach($wp_filter[$tag]["$priority"] as $filter) {
+ // uncomment if we want to match function AND accepted_args
+ //if ($filter == array($function, $accepted_args)) {
+ if ($filter['function'] == $function_to_add) {
+ return true;
+ }
+ }
+ }
+
+ // So the format is wp_filter['tag']['array of priorities']['array of ['array (functions, accepted_args)]']
+ $wp_filter[$tag]["$priority"][] = array('function'=>$function_to_add, 'accepted_args'=>$accepted_args);
+ return true;
+}
+
+function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
+ global $wp_filter;
+
+ // rebuild the list of filters
+ if (isset($wp_filter[$tag]["$priority"])) {
+ foreach($wp_filter[$tag]["$priority"] as $filter) {
+ if ($filter['function'] != $function_to_remove) {
+ $new_function_list[] = $filter;
+ }
+ }
+ $wp_filter[$tag]["$priority"] = $new_function_list;
+ }
+ return true;
+}
+
+// The *_action functions are just aliases for the *_filter functions, they take special strings instead of generic content
+
+function do_action($tag, $arg = '') {
+ global $wp_filter;
+ $extra_args = array_slice(func_get_args(), 2);
+ if ( is_array($arg) )
+ $args = array_merge($arg, $extra_args);
+ else
+ $args = array_merge(array($arg), $extra_args);
+
+ merge_filters($tag);
+
+ if (!isset($wp_filter[$tag])) {
+ return;
+ }
+ foreach ($wp_filter[$tag] as $priority => $functions) {
+ if (!is_null($functions)) {
+ foreach($functions as $function) {
+
+ $function_name = $function['function'];
+ $accepted_args = $function['accepted_args'];
+
+ if($accepted_args == 1) {
+ if ( is_array($arg) )
+ $the_args = $arg;
+ else
+ $the_args = array($arg);
+ } elseif ($accepted_args > 1) {
+ $the_args = array_slice($args, 0, $accepted_args);
+ } elseif($accepted_args == 0) {
+ $the_args = NULL;
+ } else {
+ $the_args = $args;
+ }
+
+ $string = call_user_func_array($function_name, $the_args);
+ }
+ }
+ }
+}
+
+function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
+ add_filter($tag, $function_to_add, $priority, $accepted_args);
+}
+
+function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
+ remove_filter($tag, $function_to_remove, $priority, $accepted_args);
+}
+
+function get_page_uri($page_id) {
+ $page = get_page($page_id);
+ $uri = urldecode($page->post_name);
+
+ // A page cannot be it's own parent.
+ if ($page->post_parent == $page->ID) {
+ return $uri;
+ }
+
+ while ($page->post_parent != 0) {
+ $page = get_page($page->post_parent);
+ $uri = urldecode($page->post_name) . "/" . $uri;
+ }
+
+ return $uri;
+}
+
+function get_posts($args) {
+ global $wpdb;
+ parse_str($args, $r);
+ if (!isset($r['numberposts'])) $r['numberposts'] = 5;
+ if (!isset($r['offset'])) $r['offset'] = 0;
+ if (!isset($r['category'])) $r['category'] = '';
+ if (!isset($r['orderby'])) $r['orderby'] = 'post_date';
+ if (!isset($r['order'])) $r['order'] = 'DESC';
+
+ $now = current_time('mysql');
+
+ $posts = $wpdb->get_results(
+ "SELECT DISTINCT * FROM $wpdb->posts " .
+ ( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) .
+ " WHERE post_date <= '$now' AND (post_status = 'publish') ".
+ ( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) .
+ " GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
+
+ update_post_caches($posts);
+
+ return $posts;
+}
+
+function &query_posts($query) {
+ global $wp_query;
+ return $wp_query->query($query);
+}
+
+function update_post_cache(&$posts) {
+ global $post_cache;
+
+ if ( !$posts )
+ return;
+
+ for ($i = 0; $i < count($posts); $i++) {
+ $post_cache[$posts[$i]->ID] = &$posts[$i];
+ }
+}
+
+function update_page_cache(&$pages) {
+ global $page_cache;
+
+ if ( !$pages )
+ return;
+
+ for ($i = 0; $i < count($pages); $i++) {
+ $page_cache[$pages[$i]->ID] = &$pages[$i];
+ }
+}
+
+function update_post_category_cache($post_ids) {
+ global $wpdb, $category_cache, $cache_categories;
+
+ if (empty($post_ids))
+ return;
+
+ if (is_array($post_ids))
+ $post_ids = implode(',', $post_ids);
+
+ $dogs = $wpdb->get_results("SELECT DISTINCT
+ post_id, cat_ID FROM $wpdb->categories, $wpdb->post2cat
+ WHERE category_id = cat_ID AND post_id IN ($post_ids)");
+
+ if (! isset($cache_categories))
+ update_category_cache();
+
+ if ( !empty($dogs) ) {
+ foreach ($dogs as $catt) {
+ $category_cache[$catt->post_id][$catt->cat_ID] = &$cache_categories[$catt->cat_ID];
+ }
+ }
+}
+
+function update_post_caches(&$posts) {
+ global $post_cache, $category_cache, $comment_count_cache, $post_meta_cache;
+ global $wpdb;
+
+ // No point in doing all this work if we didn't match any posts.
+ if ( !$posts )
+ return;
+
+ // Get the categories for all the posts
+ for ($i = 0; $i < count($posts); $i++) {
+ $post_id_list[] = $posts[$i]->ID;
+ $post_cache[$posts[$i]->ID] = &$posts[$i];
+ }
+
+ $post_id_list = implode(',', $post_id_list);
+
+ update_post_category_cache($post_id_list);
+
+ // Do the same for comment numbers
+ $comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount
+ FROM $wpdb->posts
+ LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID AND comment_approved = '1')
+ WHERE ID IN ($post_id_list)
+ GROUP BY ID");
+
+ if ($comment_counts) {
+ foreach ($comment_counts as $comment_count)
+ $comment_count_cache["$comment_count->ID"] = $comment_count->ccount;
+ }
+
+ // Get post-meta info
+ if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
+ // Change from flat structure to hierarchical:
+ $post_meta_cache = array();
+ foreach ($meta_list as $metarow) {
+ $mpid = $metarow['post_id'];
+ $mkey = $metarow['meta_key'];
+ $mval = $metarow['meta_value'];
+
+ // Force subkeys to be array type:
+ if (!isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]))
+ $post_meta_cache[$mpid] = array();
+ if (!isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]))
+ $post_meta_cache[$mpid]["$mkey"] = array();
+
+ // Add a value to the current pid/key:
+ $post_meta_cache[$mpid][$mkey][] = $mval;
+ }
+ }
+}
+
+function update_category_cache() {
+ global $cache_categories, $wpdb;
+ if($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")):
+ foreach ($dogs as $catt)
+ $cache_categories[$catt->cat_ID] = $catt;
+ return true;
+ else:
+ return false;
+ endif;
+}
+
+function wp_head() {
+ do_action('wp_head');
+}
+
+function wp_footer() {
+ do_action('wp_footer');
+}
+
+function is_single ($post = '') {
+ global $wp_query;
+
+ if ( !$wp_query->is_single )
+ return false;
+
+ if ( empty( $post) )
+ return true;
+
+ $post_obj = $wp_query->get_queried_object();
+
+ if ( $post == $post_obj->ID )
+ return true;
+ elseif ( $post == $post_obj->post_title )
+ return true;
+ elseif ( $post == $post_obj->post_name )
+ return true;
+
+ return false;
+}
+
+function is_page ($page = '') {
+ global $wp_query;
+
+ if (! $wp_query->is_page) {
+ return false;
+ }
+
+ if (empty($page)) {
+ return true;
+ }
+
+ $page_obj = $wp_query->get_queried_object();
+
+ if ($page == $page_obj->ID) {
+ return true;
+ } else if ($page == $page_obj->post_title) {
+ return true;
+ } else if ($page == $page_obj->post_name) {
+ return true;
+ }
+
+ return false;
+}
+
+function is_archive () {
+ global $wp_query;
+
+ return $wp_query->is_archive;
+}
+
+function is_date () {
+ global $wp_query;
+
+ return $wp_query->is_date;
+}
+
+function is_year () {
+ global $wp_query;
+
+ return $wp_query->is_year;
+}
+
+function is_month () {
+ global $wp_query;
+
+ return $wp_query->is_month;
+}
+
+function is_day () {
+ global $wp_query;
+
+ return $wp_query->is_day;
+}
+
+function is_time () {
+ global $wp_query;
+
+ return $wp_query->is_time;
+}
+
+function is_author ($author = '') {
+ global $wp_query;
+
+ if (! $wp_query->is_author) {
+ return false;
+ }
+
+ if (empty($author)) {
+ return true;
+ }
+
+ $author_obj = $wp_query->get_queried_object();
+
+ if ($author == $author_obj->ID) {
+ return true;
+ } else if ($author == $author_obj->nickname) {
+ return true;
+ } else if ($author == $author_obj->user_nicename) {
+ return true;
+ }
+
+ return false;
+}
+
+function is_category ($category = '') {
+ global $wp_query;
+
+ if (! $wp_query->is_category) {
+ return false;
+ }
+
+ if (empty($category)) {
+ return true;
+ }
+
+ $cat_obj = $wp_query->get_queried_object();
+
+ if ($category == $cat_obj->cat_ID) {
+ return true;
+ } else if ($category == $cat_obj->cat_name) {
+ return true;
+ } else if ($category == $cat_obj->category_nicename) {
+ return true;
+ }
+
+ return false;
+}
+
+function is_search () {
+ global $wp_query;
+
+ return $wp_query->is_search;
+}
+
+function is_feed () {
+ global $wp_query;
+
+ return $wp_query->is_feed;
+}
+
+function is_trackback () {
+ global $wp_query;
+
+ return $wp_query->is_trackback;
+}
+
+function is_admin () {
+ global $wp_query;
+
+ return $wp_query->is_admin;
+}
+
+function is_home () {
+ global $wp_query;
+
+ return $wp_query->is_home;
+}
+
+function is_404 () {
+ global $wp_query;
+
+ return $wp_query->is_404;
+}
+
+function is_comments_popup () {
+ global $wp_query;
+
+ return $wp_query->is_comments_popup;
+}
+
+function is_paged () {
+ global $wp_query;
+
+ return $wp_query->is_paged;
+}
+
+function get_query_var($var) {
+ global $wp_query;
+
+ return $wp_query->get($var);
+}
+
+function have_posts() {
+ global $wp_query;
+
+ return $wp_query->have_posts();
+}
+
+function rewind_posts() {
+ global $wp_query;
+
+ return $wp_query->rewind_posts();
+}
+
+function the_post() {
+ global $wp_query;
+ $wp_query->the_post();
+}
+
+function get_theme_root() {
+ return apply_filters('theme_root', ABSPATH . "wp-content/themes");
+}
+
+function get_theme_root_uri() {
+ return apply_filters('theme_root_uri', get_settings('siteurl') . "/wp-content/themes", get_settings('siteurl'));
+}
+
+function get_stylesheet() {
+ return apply_filters('stylesheet', get_settings('stylesheet'));
+}
+
+function get_stylesheet_directory() {
+ $stylesheet = get_stylesheet();
+ $stylesheet_dir = get_theme_root() . "/$stylesheet";
+ return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet);
+}
+
+function get_stylesheet_directory_uri() {
+ $stylesheet = rawurlencode( get_stylesheet() );
+ $stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet";
+ return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet);
+}
+
+function get_stylesheet_uri() {
+ $stylesheet_dir_uri = get_stylesheet_directory_uri();
+ $stylesheet_uri = $stylesheet_dir_uri . "/style.css";
+ return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
+}
+
+function get_template() {
+ return apply_filters('template', get_settings('template'));
+}
+
+function get_template_directory() {
+ $template = get_template();
+ $template_dir = get_theme_root() . "/$template";
+ return apply_filters('template_directory', $template_dir, $template);
+}
+
+function get_template_directory_uri() {
+ $template = get_template();
+ $template_dir_uri = get_theme_root_uri() . "/$template";
+ return apply_filters('template_directory_uri', $template_dir_uri, $template);
+}
+
+function get_theme_data($theme_file) {
+ $theme_data = implode('', file($theme_file));
+ preg_match("|Theme Name:(.*)|i", $theme_data, $theme_name);
+ preg_match("|Theme URI:(.*)|i", $theme_data, $theme_uri);
+ preg_match("|Description:(.*)|i", $theme_data, $description);
+ preg_match("|Author:(.*)|i", $theme_data, $author_name);
+ preg_match("|Author URI:(.*)|i", $theme_data, $author_uri);
+ preg_match("|Template:(.*)|i", $theme_data, $template);
+ if ( preg_match("|Version:(.*)|i", $theme_data, $version) )
+ $version = $version[1];
+ else
+ $version ='';
+ if ( preg_match("|Status:(.*)|i", $theme_data, $status) )
+ $status = $status[1];
+ else
+ $status ='publish';
+
+ $description = wptexturize($description[1]);
+
+ $name = $theme_name[1];
+ $name = trim($name);
+ $theme = $name;
+ if ('' != $theme_uri[1] && '' != $name) {
+ $theme = '<a href="' . $theme_uri[1] . '" title="' . __('Visit theme homepage') . '">' . $theme . '</a>';
+ }
+
+ if ('' == $author_uri[1]) {
+ $author = $author_name[1];
+ } else {
+ $author = '<a href="' . $author_uri[1] . '" title="' . __('Visit author homepage') . '">' . $author_name[1] . '</a>';
+ }
+
+ return array('Name' => $name, 'Title' => $theme, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1], 'Status' => $status);
+}
+
+function get_themes() {
+ global $wp_themes;
+ global $wp_broken_themes;
+
+ if (isset($wp_themes)) {
+ return $wp_themes;
+ }
+
+ $themes = array();
+ $wp_broken_themes = array();
+ $theme_root = get_theme_root();
+ $theme_loc = str_replace(ABSPATH, '', $theme_root);
+
+ // Files in wp-content/themes directory
+ $themes_dir = @ dir($theme_root);
+ if ($themes_dir) {
+ while(($theme_dir = $themes_dir->read()) !== false) {
+ if (is_dir($theme_root . '/' . $theme_dir)) {
+ if ($theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS') {
+ continue;
+ }
+ $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
+ $found_stylesheet = false;
+ while(($theme_file = $stylish_dir->read()) !== false) {
+ if ( $theme_file == 'style.css' ) {
+ $theme_files[] = $theme_dir . '/' . $theme_file;
+ $found_stylesheet = true;
+ break;
+ }
+ }
+ if (!$found_stylesheet) {
+ $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
+ }
+ }
+ }
+ }
+
+ if (!$themes_dir || !$theme_files) {
+ return $themes;
+ }
+
+ sort($theme_files);
+
+ foreach($theme_files as $theme_file) {
+ $theme_data = get_theme_data("$theme_root/$theme_file");
+
+ $name = $theme_data['Name'];
+ $title = $theme_data['Title'];
+ $description = wptexturize($theme_data['Description']);
+ $version = $theme_data['Version'];
+ $author = $theme_data['Author'];
+ $template = $theme_data['Template'];
+ $stylesheet = dirname($theme_file);
+
+ if (empty($name)) {
+ $name = dirname($theme_file);
+ $title = $name;
+ }
+
+ if (empty($template)) {
+ if (file_exists(dirname("$theme_root/$theme_file/index.php"))) {
+ $template = dirname($theme_file);
+ } else {
+ continue;
+ }
+ }
+
+ $template = trim($template);
+
+ if (! file_exists("$theme_root/$template/index.php")) {
+ $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
+ continue;
+ }
+
+ $stylesheet_files = array();
+ $stylesheet_dir = @ dir("$theme_root/$stylesheet");
+ if ($stylesheet_dir) {
+ while(($file = $stylesheet_dir->read()) !== false) {
+ if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) )
+ $stylesheet_files[] = "$theme_loc/$stylesheet/$file";
+ }
+ }
+
+ $template_files = array();
+ $template_dir = @ dir("$theme_root/$template");
+ if ($template_dir) {
+ while(($file = $template_dir->read()) !== false) {
+ if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) )
+ $template_files[] = "$theme_loc/$template/$file";
+ }
+ }
+
+ $template_dir = dirname($template_files[0]);
+ $stylesheet_dir = dirname($stylesheet_files[0]);
+
+ if (empty($template_dir)) $template_dir = '/';
+ if (empty($stylesheet_dir)) $stylesheet_dir = '/';
+
+ // Check for theme name collision. This occurs if a theme is copied to
+ // a new theme directory and the theme header is not updated. Whichever
+ // theme is first keeps the name. Subsequent themes get a suffix applied.
+ // The Default and Classic themes always trump their pretenders.
+ if ( isset($themes[$name]) ) {
+ if ( ('WordPress Default' == $name || 'WordPress Classic' == $name) &&
+ ('default' == $stylesheet || 'classic' == $stylesheet) ) {
+ // If another theme has claimed to be one of our default themes, move
+ // them aside.
+ $suffix = $themes[$name]['Stylesheet'];
+ $new_name = "$name/$suffix";
+ $themes[$new_name] = $themes[$name];
+ $themes[$new_name]['Name'] = $new_name;
+ } else {
+ $name = "$name/$stylesheet";
+ }
+ }
+
+ $themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Stylesheet' => $stylesheet, 'Template Files' => $template_files, 'Stylesheet Files' => $stylesheet_files, 'Template Dir' => $template_dir, 'Stylesheet Dir' => $stylesheet_dir, 'Status' => $theme_data['Status']);
+ }
+
+ // Resolve theme dependencies.
+ $theme_names = array_keys($themes);
+
+ foreach ($theme_names as $theme_name) {
+ $themes[$theme_name]['Parent Theme'] = '';
+ if ($themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template']) {
+ foreach ($theme_names as $parent_theme_name) {
+ if (($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template'])) {
+ $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
+ break;
+ }
+ }
+ }
+ }
+
+ $wp_themes = $themes;
+
+ return $themes;
+}
+
+function get_theme($theme) {
+ $themes = get_themes();
+
+ if (array_key_exists($theme, $themes)) {
+ return $themes[$theme];
+ }
+
+ return NULL;
+}
+
+function get_current_theme() {
+ $themes = get_themes();
+ $theme_names = array_keys($themes);
+ $current_template = get_settings('template');
+ $current_stylesheet = get_settings('stylesheet');
+ $current_theme = 'WordPress Default';
+
+ if ($themes) {
+ foreach ($theme_names as $theme_name) {
+ if ($themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
+ $themes[$theme_name]['Template'] == $current_template) {
+ $current_theme = $themes[$theme_name]['Name'];
+ break;
+ }
+ }
+ }
+
+ return $current_theme;
+}
+
+function get_query_template($type) {
+ $template = '';
+ if ( file_exists(TEMPLATEPATH . "/{$type}.php") )
+ $template = TEMPLATEPATH . "/{$type}.php";
+
+ return apply_filters("{$type}_template", $template);
+}
+
+function get_404_template() {
+ return get_query_template('404');
+}
+
+function get_archive_template() {
+ return get_query_template('archive');
+}
+
+function get_author_template() {
+ return get_query_template('author');
+}
+
+function get_category_template() {
+ $template = '';
+ if ( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') )
+ $template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php';
+ else if ( file_exists(TEMPLATEPATH . "/category.php") )
+ $template = TEMPLATEPATH . "/category.php";
+
+ return apply_filters('category_template', $template);
+}
+
+function get_date_template() {
+ return get_query_template('date');
+}
+
+function get_home_template() {
+ $template = '';
+
+ if ( file_exists(TEMPLATEPATH . "/home.php") )
+ $template = TEMPLATEPATH . "/home.php";
+ else if ( file_exists(TEMPLATEPATH . "/index.php") )
+ $template = TEMPLATEPATH . "/index.php";
+
+ return apply_filters('home_template', $template);
+}
+
+function get_page_template() {
+ global $wp_query;
+
+ $id = $wp_query->post->ID;
+ $template = get_post_meta($id, '_wp_page_template', true);
+
+ if ( 'default' == $template )
+ $template = '';
+
+ if ( ! empty($template) && file_exists(TEMPLATEPATH . "/$template") )
+ $template = TEMPLATEPATH . "/$template";
+ else if ( file_exists(TEMPLATEPATH . "/page.php") )
+ $template = TEMPLATEPATH . "/page.php";
+ else
+ $template = '';
+
+ return apply_filters('page_template', $template);
+}
+
+function get_paged_template() {
+ return get_query_template('paged');
+}
+
+function get_search_template() {
+ return get_query_template('search');
+}
+
+function get_single_template() {
+ return get_query_template('single');
+}
+
+function get_comments_popup_template() {
+ if ( file_exists( TEMPLATEPATH . '/comments-popup.php') )
+ $template = TEMPLATEPATH . '/comments-popup.php';
+ else
+ $template = get_theme_root() . '/default/comments-popup.php';
+
+ return apply_filters('comments_popup_template', $template);
+}
+
+// Borrowed from the PHP Manual user notes. Convert entities, while
+// preserving already-encoded entities:
+function htmlentities2($myHTML) {
+ $translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES);
+ $translation_table[chr(38)] = '&';
+ return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" , strtr($myHTML, $translation_table));
+}
+
+
+function is_plugin_page() {
+ global $plugin_page;
+
+ if (isset($plugin_page)) {
+ return true;
+ }
+
+ return false;
+}
+
+/*
+add_query_arg: Returns a modified querystring by adding
+a single key & value or an associative array.
+Setting a key value to emptystring removes the key.
+Omitting oldquery_or_uri uses the $_SERVER value.
+
+Parameters:
+add_query_arg(newkey, newvalue, oldquery_or_uri) or
+add_query_arg(associative_array, oldquery_or_uri)
+*/
+function add_query_arg() {
+ $ret = '';
+ if(is_array(func_get_arg(0))) {
+ $uri = @func_get_arg(1);
+ }
+ else {
+ if (@func_num_args() < 3) {
+ $uri = $_SERVER['REQUEST_URI'];
+ } else {
+ $uri = @func_get_arg(2);
+ }
+ }
+
+ if (strstr($uri, '?')) {
+ $parts = explode('?', $uri, 2);
+ if (1 == count($parts)) {
+ $base = '?';
+ $query = $parts[0];
+ }
+ else {
+ $base = $parts[0] . '?';
+ $query = $parts[1];
+ }
+ }
+ else if (strstr($uri, '/')) {
+ $base = $uri . '?';
+ $query = '';
+ } else {
+ $base = '';
+ $query = $uri;
+ }
+
+ parse_str($query, $qs);
+ if (is_array(func_get_arg(0))) {
+ $kayvees = func_get_arg(0);
+ $qs = array_merge($qs, $kayvees);
+ }
+ else
+ {
+ $qs[func_get_arg(0)] = func_get_arg(1);
+ }
+
+ foreach($qs as $k => $v)
+ {
+ if($v != '')
+ {
+ if($ret != '') $ret .= '&';
+ $ret .= "$k=$v";
+ }
+ }
+ $ret = $base . $ret;
+ return trim($ret, '?');
+}
+
+function remove_query_arg($key, $query) {
+ return add_query_arg($key, '', $query);
+}
+
+function load_template($file) {
+ global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query,
+ $wp_rewrite, $wpdb;
+
+ extract($wp_query->query_vars);
+
+ require_once($file);
+}
+
+function add_magic_quotes($array) {
+ global $wpdb;
+
+ foreach ($array as $k => $v) {
+ if (is_array($v)) {
+ $array[$k] = add_magic_quotes($v);
+ } else {
+ $array[$k] = $wpdb->escape($v);
+ }
+ }
+ return $array;
+}
+
+function wp_remote_fopen( $uri ) {
+ if ( ini_get('allow_url_fopen') ) {
+ $fp = fopen( $uri, 'r' );
+ if ( !$fp )
+ return false;
+ $linea = '';
+ while( $remote_read = fread($fp, 4096) )
+ $linea .= $remote_read;
+ fclose($fp);
+ return $linea;
+ } else if ( function_exists('curl_init') ) {
+ $handle = curl_init();
+ curl_setopt ($handle, CURLOPT_URL, $uri);
+ curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1);
+ curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1);
+ $buffer = curl_exec($handle);
+ curl_close($handle);
+ return $buffer;
+ } else {
+ return false;
+ }
+}
+
+function wp($query_vars = '') {
+ global $wp;
+ $wp->main($query_vars);
+}
+
+function status_header( $header ) {
+ if ( 200 == $header ) {
+ $text = 'OK';
+ } elseif ( 301 == $header ) {
+ $text = 'Moved Permanently';
+ } elseif ( 302 == $header ) {
+ $text = 'Moved Temporarily';
+ } elseif ( 304 == $header ) {
+ $text = 'Not Modified';
+ } elseif ( 404 == $header ) {
+ $text = 'Not Found';
+ } elseif ( 410 == $header ) {
+ $text = 'Gone';
+ }
+ if ( preg_match('/cgi/',php_sapi_name()) ) {
+ @header("Status: $header $text");
+ } else {
+ if ( version_compare(phpversion(), '4.3.0', '>=') )
+ @header($text, TRUE, $header);
+ else
+ @header("HTTP/1.x $header $text");
+ }
+}
+
+function nocache_headers() {
+ @ header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
+ @ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+ @ header('Cache-Control: no-cache, must-revalidate, max-age=0');
+ @ header('Pragma: no-cache');
+}
+
+function get_usermeta( $user_id, $meta_key = '') {
+ global $wpdb;
+ $user_id = (int) $user_id;
+
+ if ( !empty($meta_key) ) {
+ $meta_key = preg_replace('|a-z0-9_|i', '', $meta_key);
+ $metas = $wpdb->get_results("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
+ } else {
+ $metas = $wpdb->get_results("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id'");
+ }
+
+ foreach ($metas as $index => $meta) {
+ @ $value = unserialize($meta->meta_key);
+ if ($value !== FALSE)
+ $metas[$index]->meta_key = $value;
+ }
+
+ if ( !empty($meta_key) )
+ return $metas[0];
+ else
+ return $metas;
+}
+
+function update_usermeta( $user_id, $meta_key, $meta_value ) {
+ global $wpdb;
+ if ( !is_numeric( $user_id ) )
+ return false;
+ $meta_key = preg_replace('|a-z0-9_|i', '', $meta_key);
+
+ if ( is_array($meta_value) || is_object($meta_value) )
+ $meta_value = serialize($meta_value);
+
+ $cur = $wpdb->get_row("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
+ if ( !$cur ) {
+ $wpdb->query("INSERT INTO $wpdb->usermeta ( user_id, meta_key, meta_value )
+ VALUES
+ ( '$user_id', '$meta_key', '$meta_value' )");
+ return true;
+ }
+ if ( $cur->meta_value != $meta_value )
+ $wpdb->query("UPDATE $wpdb->usermeta SET meta_value = '$meta_value' WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
+}
+
+function register_activation_hook($file, $function) {
+ $file = plugin_basename($file);
+
+ add_action('activate_' . $file, $function);
+}
+
+function register_deactivation_hook($file, $function) {
+ $file = plugin_basename($file);
+
+ add_action('deactivate_' . $file, $function);
+}
+
+function plugin_basename($file) {
+ return preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file);
+}
+
+?>
diff --git a/wp-inst/wp-includes/gettext.php b/wp-inst/wp-includes/gettext.php
new file mode 100644
index 0000000..45af0f6
--- /dev/null
+++ b/wp-inst/wp-includes/gettext.php
@@ -0,0 +1,358 @@
+<?php
+/*
+ Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
+ Copyright (c) 2005 Nico Kaiser <nico@siriux.net>
+
+ This file is part of PHP-gettext.
+
+ PHP-gettext is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ PHP-gettext is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with PHP-gettext; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+/**
+ * Provides a simple gettext replacement that works independently from
+ * the system's gettext abilities.
+ * It can read MO files and use them for translating strings.
+ * The files are passed to gettext_reader as a Stream (see streams.php)
+ *
+ * This version has the ability to cache all strings and translations to
+ * speed up the string lookup.
+ * While the cache is enabled by default, it can be switched off with the
+ * second parameter in the constructor (e.g. whenusing very large MO files
+ * that you don't want to keep in memory)
+ */
+class gettext_reader {
+ //public:
+ var $error = 0; // public variable that holds error code (0 if no error)
+
+ //private:
+ var $BYTEORDER = 0; // 0: low endian, 1: big endian
+ var $STREAM = NULL;
+ var $short_circuit = false;
+ var $enable_cache = false;
+ var $originals = NULL; // offset of original table
+ var $translations = NULL; // offset of translation table
+ var $pluralheader = NULL; // cache header field for plural forms
+ var $total = 0; // total string count
+ var $table_originals = NULL; // table for original strings (offsets)
+ var $table_translations = NULL; // table for translated strings (offsets)
+ var $cache_translations = NULL; // original -> translation mapping
+
+
+ /* Methods */
+
+
+ /**
+ * Reads a 32bit Integer from the Stream
+ *
+ * @access private
+ * @return Integer from the Stream
+ */
+ function readint() {
+ if ($this->BYTEORDER == 0) {
+ // low endian
+ return array_shift(unpack('V', $this->STREAM->read(4)));
+ } else {
+ // big endian
+ return array_shift(unpack('N', $this->STREAM->read(4)));
+ }
+ }
+
+ /**
+ * Reads an array of Integers from the Stream
+ *
+ * @param int count How many elements should be read
+ * @return Array of Integers
+ */
+ function readintarray($count) {
+ if ($this->BYTEORDER == 0) {
+ // low endian
+ return unpack('V'.$count, $this->STREAM->read(4 * $count));
+ } else {
+ // big endian
+ return unpack('N'.$count, $this->STREAM->read(4 * $count));
+ }
+ }
+
+ /**
+ * Constructor
+ *
+ * @param object Reader the StreamReader object
+ * @param boolean enable_cache Enable or disable caching of strings (default on)
+ */
+ function gettext_reader($Reader, $enable_cache = true) {
+ // If there isn't a StreamReader, turn on short circuit mode.
+ if (! $Reader) {
+ $this->short_circuit = true;
+ return;
+ }
+
+ // Caching can be turned off
+ $this->enable_cache = $enable_cache;
+
+ // $MAGIC1 = (int)0x950412de; //bug in PHP 5
+ $MAGIC1 = (int) - 1794895138;
+ // $MAGIC2 = (int)0xde120495; //bug
+ $MAGIC2 = (int) - 569244523;
+
+ $this->STREAM = $Reader;
+ $magic = $this->readint();
+ if ($magic == $MAGIC1) {
+ $this->BYTEORDER = 0;
+ } elseif ($magic == $MAGIC2) {
+ $this->BYTEORDER = 1;
+ } else {
+ $this->error = 1; // not MO file
+ return false;
+ }
+
+ // FIXME: Do we care about revision? We should.
+ $revision = $this->readint();
+
+ $this->total = $this->readint();
+ $this->originals = $this->readint();
+ $this->translations = $this->readint();
+ }
+
+ /**
+ * Loads the translation tables from the MO file into the cache
+ * If caching is enabled, also loads all strings into a cache
+ * to speed up translation lookups
+ *
+ * @access private
+ */
+ function load_tables() {
+ if (is_array($this->cache_translations) &&
+ is_array($this->table_originals) &&
+ is_array($this->table_translations))
+ return;
+
+ /* get original and translations tables */
+ $this->STREAM->seekto($this->originals);
+ $this->table_originals = $this->readintarray($this->total * 2);
+ $this->STREAM->seekto($this->translations);
+ $this->table_translations = $this->readintarray($this->total * 2);
+
+ if ($this->enable_cache) {
+ $this->cache_translations = array ();
+ /* read all strings in the cache */
+ for ($i = 0; $i < $this->total; $i++) {
+ $this->STREAM->seekto($this->table_originals[$i * 2 + 2]);
+ $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]);
+ $this->STREAM->seekto($this->table_translations[$i * 2 + 2]);
+ $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]);
+ $this->cache_translations[$original] = $translation;
+ }
+ }
+ }
+
+ /**
+ * Returns a string from the "originals" table
+ *
+ * @access private
+ * @param int num Offset number of original string
+ * @return string Requested string if found, otherwise ''
+ */
+ function get_original_string($num) {
+ $length = $this->table_originals[$num * 2 + 1];
+ $offset = $this->table_originals[$num * 2 + 2];
+ if (! $length)
+ return '';
+ $this->STREAM->seekto($offset);
+ $data = $this->STREAM->read($length);
+ return (string)$data;
+ }
+
+ /**
+ * Returns a string from the "translations" table
+ *
+ * @access private
+ * @param int num Offset number of original string
+ * @return string Requested string if found, otherwise ''
+ */
+ function get_translation_string($num) {
+ $length = $this->table_translations[$num * 2 + 1];
+ $offset = $this->table_translations[$num * 2 + 2];
+ if (! $length)
+ return '';
+ $this->STREAM->seekto($offset);
+ $data = $this->STREAM->read($length);
+ return (string)$data;
+ }
+
+ /**
+ * Binary search for string
+ *
+ * @access private
+ * @param string string
+ * @param int start (internally used in recursive function)
+ * @param int end (internally used in recursive function)
+ * @return int string number (offset in originals table)
+ */
+ function find_string($string, $start = -1, $end = -1) {
+ if (($start == -1) or ($end == -1)) {
+ // find_string is called with only one parameter, set start end end
+ $start = 0;
+ $end = $this->total;
+ }
+ if (abs($start - $end) <= 1) {
+ // We're done, now we either found the string, or it doesn't exist
+ $txt = $this->get_original_string($start);
+ if ($string == $txt)
+ return $start;
+ else
+ return -1;
+ } else if ($start > $end) {
+ // start > end -> turn around and start over
+ return $this->find_string($string, $end, $start);
+ } else {
+ // Divide table in two parts
+ $half = (int)(($start + $end) / 2);
+ $cmp = strcmp($string, $this->get_original_string($half));
+ if ($cmp == 0)
+ // string is exactly in the middle => return it
+ return $half;
+ else if ($cmp < 0)
+ // The string is in the upper half
+ return $this->find_string($string, $start, $half);
+ else
+ // The string is in the lower half
+ return $this->find_string($string, $half, $end);
+ }
+ }
+
+ /**
+ * Translates a string
+ *
+ * @access public
+ * @param string string to be translated
+ * @return string translated string (or original, if not found)
+ */
+ function translate($string) {
+ if ($this->short_circuit)
+ return $string;
+ $this->load_tables();
+
+ if ($this->enable_cache) {
+ // Caching enabled, get translated string from cache
+ if (array_key_exists($string, $this->cache_translations))
+ return $this->cache_translations[$string];
+ else
+ return $string;
+ } else {
+ // Caching not enabled, try to find string
+ $num = $this->find_string($string);
+ if ($num == -1)
+ return $string;
+ else
+ return $this->get_translation_string($num);
+ }
+ }
+
+ /**
+ * Get possible plural forms from MO header
+ *
+ * @access private
+ * @return string plural form header
+ */
+ function get_plural_forms() {
+ // lets assume message number 0 is header
+ // this is true, right?
+ $this->load_tables();
+
+ // cache header field for plural forms
+ if (! is_string($this->pluralheader)) {
+ if ($this->enable_cache) {
+ $header = $this->cache_translations[""];
+ } else {
+ $header = $this->get_translation_string(0);
+ }
+ if (eregi("plural-forms: (.*)\n", $header, $regs))
+ $expr = $regs[1];
+ else
+ $expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
+ $this->pluralheader = $expr;
+ }
+ return $this->pluralheader;
+ }
+
+ /**
+ * Detects which plural form to take
+ *
+ * @access private
+ * @param n count
+ * @return int array index of the right plural form
+ */
+ function select_string($n) {
+ $string = $this->get_plural_forms();
+ $string = str_replace('nplurals',"\$total",$string);
+ $string = str_replace("n",$n,$string);
+ $string = str_replace('plural',"\$plural",$string);
+
+ $total = 0;
+ $plural = 0;
+
+ eval("$string");
+ if ($plural >= $total) $plural = 0;
+ return $plural;
+ }
+
+ /**
+ * Plural version of gettext
+ *
+ * @access public
+ * @param string single
+ * @param string plural
+ * @param string number
+ * @return translated plural form
+ */
+ function ngettext($single, $plural, $number) {
+ if ($this->short_circuit) {
+ if ($number != 1)
+ return $plural;
+ else
+ return $single;
+ }
+
+ // find out the appropriate form
+ $select = $this->select_string($number);
+
+ // this should contains all strings separated by NULLs
+ $key = $single.chr(0).$plural;
+
+
+ if ($this->enable_cache) {
+ if (! array_key_exists($key, $this->cache_translations)) {
+ return ($number != 1) ? $plural : $single;
+ } else {
+ $result = $this->cache_translations[$key];
+ $list = explode(chr(0), $result);
+ return $list[$select];
+ }
+ } else {
+ $num = $this->find_string($key);
+ if ($num == -1) {
+ return ($number != 1) ? $plural : $single;
+ } else {
+ $result = $this->get_translation_string($num);
+ $list = explode(chr(0), $result);
+ return $list[$select];
+ }
+ }
+ }
+
+}
+
+?>
diff --git a/wp-inst/wp-includes/kses.php b/wp-inst/wp-includes/kses.php
new file mode 100644
index 0000000..93dbe3a
--- /dev/null
+++ b/wp-inst/wp-includes/kses.php
@@ -0,0 +1,563 @@
+<?php
+// Added wp_ prefix to avoid conflicts with existing kses users
+# kses 0.2.1 - HTML/XHTML filter that only allows some elements and attributes
+# Copyright (C) 2002, 2003 Ulf Harnhammar
+# *** CONTACT INFORMATION ***
+#
+# E-mail: metaur at users dot sourceforge dot net
+# Web page: http://sourceforge.net/projects/kses
+# Paper mail: (not at the moment)
+#
+# [kses strips evil scripts!]
+if (!defined('CUSTOM_TAGS'))
+ define('CUSTOM_TAGS', false);
+
+// You can override this in your my-hacks.php file
+if (!CUSTOM_TAGS) {
+$allowedtags = array(
+ 'a' => array(
+ 'href' => array(),
+ 'title' => array()
+ ),
+ 'abbr' => array('title' => array()),
+ 'acronym' => array('title' => array()),
+ 'b' => array(),
+ 'blockquote' => array('cite' => array()),
+// 'br' => array(),
+ 'code' => array(),
+// 'del' => array('datetime' => array()),
+// 'dd' => array(),
+// 'dl' => array(),
+// 'dt' => array(),
+ 'em' => array(),
+ 'i' => array(),
+// 'ins' => array('datetime' => array(), 'cite' => array()),
+// 'li' => array(),
+// 'ol' => array(),
+// 'p' => array(),
+// 'q' => array(),
+ 'strike' => array(),
+ 'strong' => array(),
+// 'sub' => array(),
+// 'sup' => array(),
+// 'u' => array(),
+// 'ul' => array(),
+ );
+}
+function wp_kses($string, $allowed_html, $allowed_protocols =
+ array('http', 'https', 'ftp', 'news', 'nntp', 'feed', 'gopher', 'mailto'))
+###############################################################################
+# This function makes sure that only the allowed HTML element names, attribute
+# names and attribute values plus only sane HTML entities will occur in
+# $string. You have to remove any slashes from PHP's magic quotes before you
+# call this function.
+###############################################################################
+{
+ $string = wp_kses_no_null($string);
+ $string = wp_kses_js_entities($string);
+ $string = wp_kses_normalize_entities($string);
+ $string = wp_kses_hook($string);
+ $allowed_html_fixed = wp_kses_array_lc($allowed_html);
+ return wp_kses_split($string, $allowed_html_fixed, $allowed_protocols);
+} # function wp_kses
+
+
+function wp_kses_hook($string)
+###############################################################################
+# You add any kses hooks here.
+###############################################################################
+{
+ return $string;
+} # function wp_kses_hook
+
+
+function wp_kses_version()
+###############################################################################
+# This function returns kses' version number.
+###############################################################################
+{
+ return '0.2.1';
+} # function wp_kses_version
+
+
+function wp_kses_split($string, $allowed_html, $allowed_protocols)
+###############################################################################
+# This function searches for HTML tags, no matter how malformed. It also
+# matches stray ">" characters.
+###############################################################################
+{
+ return preg_replace('%(<'. # EITHER: <
+ '[^>]*'. # things that aren't >
+ '(>|$)'. # > or end of string
+ '|>)%e', # OR: just a >
+ "wp_kses_split2('\\1', \$allowed_html, ".
+ '$allowed_protocols)',
+ $string);
+} # function wp_kses_split
+
+
+function wp_kses_split2($string, $allowed_html, $allowed_protocols)
+###############################################################################
+# This function does a lot of work. It rejects some very malformed things
+# like <:::>. It returns an empty string, if the element isn't allowed (look
+# ma, no strip_tags()!). Otherwise it splits the tag into an element and an
+# attribute list.
+###############################################################################
+{
+ $string = wp_kses_stripslashes($string);
+
+ if (substr($string, 0, 1) != '<')
+ return '&gt;';
+ # It matched a ">" character
+
+ if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches))
+ return '';
+ # It's seriously malformed
+
+ $slash = trim($matches[1]);
+ $elem = $matches[2];
+ $attrlist = $matches[3];
+
+ if (!is_array($allowed_html[strtolower($elem)]))
+ return '';
+ # They are using a not allowed HTML element
+
+ return wp_kses_attr("$slash$elem", $attrlist, $allowed_html,
+ $allowed_protocols);
+} # function wp_kses_split2
+
+
+function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols)
+###############################################################################
+# This function removes all attributes, if none are allowed for this element.
+# If some are allowed it calls wp_kses_hair() to split them further, and then it
+# builds up new HTML code from the data that kses_hair() returns. It also
+# removes "<" and ">" characters, if there are any left. One more thing it
+# does is to check if the tag has a closing XHTML slash, and if it does,
+# it puts one in the returned code as well.
+###############################################################################
+{
+# Is there a closing XHTML slash at the end of the attributes?
+
+ $xhtml_slash = '';
+ if (preg_match('%\s/\s*$%', $attr))
+ $xhtml_slash = ' /';
+
+# Are any attributes allowed at all for this element?
+
+ if (count($allowed_html[strtolower($element)]) == 0)
+ return "<$element$xhtml_slash>";
+
+# Split it
+
+ $attrarr = wp_kses_hair($attr, $allowed_protocols);
+
+# Go through $attrarr, and save the allowed attributes for this element
+# in $attr2
+
+ $attr2 = '';
+
+ foreach ($attrarr as $arreach)
+ {
+ $current = $allowed_html[strtolower($element)]
+ [strtolower($arreach['name'])];
+ if ($current == '')
+ continue; # the attribute is not allowed
+
+ if (!is_array($current))
+ $attr2 .= ' '.$arreach['whole'];
+ # there are no checks
+
+ else
+ {
+ # there are some checks
+ $ok = true;
+ foreach ($current as $currkey => $currval)
+ if (!wp_kses_check_attr_val($arreach['value'], $arreach['vless'],
+ $currkey, $currval))
+ { $ok = false; break; }
+
+ if ($ok)
+ $attr2 .= ' '.$arreach['whole']; # it passed them
+ } # if !is_array($current)
+ } # foreach
+
+# Remove any "<" or ">" characters
+
+ $attr2 = preg_replace('/[<>]/', '', $attr2);
+
+ return "<$element$attr2$xhtml_slash>";
+} # function wp_kses_attr
+
+
+function wp_kses_hair($attr, $allowed_protocols)
+###############################################################################
+# This function does a lot of work. It parses an attribute list into an array
+# with attribute data, and tries to do the right thing even if it gets weird
+# input. It will add quotes around attribute values that don't have any quotes
+# or apostrophes around them, to make it easier to produce HTML code that will
+# conform to W3C's HTML specification. It will also remove bad URL protocols
+# from attribute values.
+###############################################################################
+{
+ $attrarr = array();
+ $mode = 0;
+ $attrname = '';
+
+# Loop through the whole attribute list
+
+ while (strlen($attr) != 0)
+ {
+ $working = 0; # Was the last operation successful?
+
+ switch ($mode)
+ {
+ case 0: # attribute name, href for instance
+
+ if (preg_match('/^([-a-zA-Z]+)/', $attr, $match))
+ {
+ $attrname = $match[1];
+ $working = $mode = 1;
+ $attr = preg_replace('/^[-a-zA-Z]+/', '', $attr);
+ }
+
+ break;
+
+ case 1: # equals sign or valueless ("selected")
+
+ if (preg_match('/^\s*=\s*/', $attr)) # equals sign
+ {
+ $working = 1; $mode = 2;
+ $attr = preg_replace('/^\s*=\s*/', '', $attr);
+ break;
+ }
+
+ if (preg_match('/^\s+/', $attr)) # valueless
+ {
+ $working = 1; $mode = 0;
+ $attrarr[] = array
+ ('name' => $attrname,
+ 'value' => '',
+ 'whole' => $attrname,
+ 'vless' => 'y');
+ $attr = preg_replace('/^\s+/', '', $attr);
+ }
+
+ break;
+
+ case 2: # attribute value, a URL after href= for instance
+
+ if (preg_match('/^"([^"]*)"(\s+|$)/', $attr, $match))
+ # "value"
+ {
+ $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
+
+ $attrarr[] = array
+ ('name' => $attrname,
+ 'value' => $thisval,
+ 'whole' => "$attrname=\"$thisval\"",
+ 'vless' => 'n');
+ $working = 1; $mode = 0;
+ $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr);
+ break;
+ }
+
+ if (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match))
+ # 'value'
+ {
+ $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
+
+ $attrarr[] = array
+ ('name' => $attrname,
+ 'value' => $thisval,
+ 'whole' => "$attrname='$thisval'",
+ 'vless' => 'n');
+ $working = 1; $mode = 0;
+ $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr);
+ break;
+ }
+
+ if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match))
+ # value
+ {
+ $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
+
+ $attrarr[] = array
+ ('name' => $attrname,
+ 'value' => $thisval,
+ 'whole' => "$attrname=\"$thisval\"",
+ 'vless' => 'n');
+ # We add quotes to conform to W3C's HTML spec.
+ $working = 1; $mode = 0;
+ $attr = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr);
+ }
+
+ break;
+ } # switch
+
+ if ($working == 0) # not well formed, remove and try again
+ {
+ $attr = wp_kses_html_error($attr);
+ $mode = 0;
+ }
+ } # while
+
+ if ($mode == 1)
+ # special case, for when the attribute list ends with a valueless
+ # attribute like "selected"
+ $attrarr[] = array
+ ('name' => $attrname,
+ 'value' => '',
+ 'whole' => $attrname,
+ 'vless' => 'y');
+
+ return $attrarr;
+} # function wp_kses_hair
+
+
+function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue)
+###############################################################################
+# This function performs different checks for attribute values. The currently
+# implemented checks are "maxlen", "minlen", "maxval", "minval" and "valueless"
+# with even more checks to come soon.
+###############################################################################
+{
+ $ok = true;
+
+ switch (strtolower($checkname))
+ {
+ case 'maxlen':
+ # The maxlen check makes sure that the attribute value has a length not
+ # greater than the given value. This can be used to avoid Buffer Overflows
+ # in WWW clients and various Internet servers.
+
+ if (strlen($value) > $checkvalue)
+ $ok = false;
+ break;
+
+ case 'minlen':
+ # The minlen check makes sure that the attribute value has a length not
+ # smaller than the given value.
+
+ if (strlen($value) < $checkvalue)
+ $ok = false;
+ break;
+
+ case 'maxval':
+ # The maxval check does two things: it checks that the attribute value is
+ # an integer from 0 and up, without an excessive amount of zeroes or
+ # whitespace (to avoid Buffer Overflows). It also checks that the attribute
+ # value is not greater than the given value.
+ # This check can be used to avoid Denial of Service attacks.
+
+ if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value))
+ $ok = false;
+ if ($value > $checkvalue)
+ $ok = false;
+ break;
+
+ case 'minval':
+ # The minval check checks that the attribute value is a positive integer,
+ # and that it is not smaller than the given value.
+
+ if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value))
+ $ok = false;
+ if ($value < $checkvalue)
+ $ok = false;
+ break;
+
+ case 'valueless':
+ # The valueless check checks if the attribute has a value
+ # (like <a href="blah">) or not (<option selected>). If the given value
+ # is a "y" or a "Y", the attribute must not have a value.
+ # If the given value is an "n" or an "N", the attribute must have one.
+
+ if (strtolower($checkvalue) != $vless)
+ $ok = false;
+ break;
+ } # switch
+
+ return $ok;
+} # function wp_kses_check_attr_val
+
+
+function wp_kses_bad_protocol($string, $allowed_protocols)
+###############################################################################
+# This function removes all non-allowed protocols from the beginning of
+# $string. It ignores whitespace and the case of the letters, and it does
+# understand HTML entities. It does its work in a while loop, so it won't be
+# fooled by a string like "javascript:javascript:alert(57)".
+###############################################################################
+{
+ $string = wp_kses_no_null($string);
+ $string2 = $string.'a';
+
+ while ($string != $string2)
+ {
+ $string2 = $string;
+ $string = wp_kses_bad_protocol_once($string, $allowed_protocols);
+ } # while
+
+ return $string;
+} # function wp_kses_bad_protocol
+
+
+function wp_kses_no_null($string)
+###############################################################################
+# This function removes any NULL or chr(173) characters in $string.
+###############################################################################
+{
+ $string = preg_replace('/\0+/', '', $string);
+ $string = preg_replace('/(\\\\0)+/', '', $string);
+
+ return $string;
+} # function wp_kses_no_null
+
+
+function wp_kses_stripslashes($string)
+###############################################################################
+# This function changes the character sequence \" to just "
+# It leaves all other slashes alone. It's really weird, but the quoting from
+# preg_replace(//e) seems to require this.
+###############################################################################
+{
+ return preg_replace('%\\\\"%', '"', $string);
+} # function wp_kses_stripslashes
+
+
+function wp_kses_array_lc($inarray)
+###############################################################################
+# This function goes through an array, and changes the keys to all lower case.
+###############################################################################
+{
+ $outarray = array();
+
+ foreach ($inarray as $inkey => $inval)
+ {
+ $outkey = strtolower($inkey);
+ $outarray[$outkey] = array();
+
+ foreach ($inval as $inkey2 => $inval2)
+ {
+ $outkey2 = strtolower($inkey2);
+ $outarray[$outkey][$outkey2] = $inval2;
+ } # foreach $inval
+ } # foreach $inarray
+
+ return $outarray;
+} # function wp_kses_array_lc
+
+
+function wp_kses_js_entities($string)
+###############################################################################
+# This function removes the HTML JavaScript entities found in early versions of
+# Netscape 4.
+###############################################################################
+{
+ return preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string);
+} # function wp_kses_js_entities
+
+
+function wp_kses_html_error($string)
+###############################################################################
+# This function deals with parsing errors in wp_kses_hair(). The general plan is
+# to remove everything to and including some whitespace, but it deals with
+# quotes and apostrophes as well.
+###############################################################################
+{
+ return preg_replace('/^("[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*/', '', $string);
+} # function wp_kses_html_error
+
+
+function wp_kses_bad_protocol_once($string, $allowed_protocols)
+###############################################################################
+# This function searches for URL protocols at the beginning of $string, while
+# handling whitespace and HTML entities.
+###############################################################################
+{
+ return preg_replace('/^((&[^;]*;|[\sA-Za-z0-9])*)'.
+ '(:|&#58;|&#[Xx]3[Aa];)\s*/e',
+ 'wp_kses_bad_protocol_once2("\\1", $allowed_protocols)',
+ $string);
+} # function wp_kses_bad_protocol_once
+
+
+function wp_kses_bad_protocol_once2($string, $allowed_protocols)
+###############################################################################
+# This function processes URL protocols, checks to see if they're in the white-
+# list or not, and returns different data depending on the answer.
+###############################################################################
+{
+ $string2 = wp_kses_decode_entities($string);
+ $string2 = preg_replace('/\s/', '', $string2);
+ $string2 = wp_kses_no_null($string2);
+ $string2 = strtolower($string2);
+
+ $allowed = false;
+ foreach ($allowed_protocols as $one_protocol)
+ if (strtolower($one_protocol) == $string2)
+ {
+ $allowed = true;
+ break;
+ }
+
+ if ($allowed)
+ return "$string2:";
+ else
+ return '';
+} # function wp_kses_bad_protocol_once2
+
+
+function wp_kses_normalize_entities($string)
+###############################################################################
+# This function normalizes HTML entities. It will convert "AT&T" to the correct
+# "AT&amp;T", "&#00058;" to "&#58;", "&#XYZZY;" to "&amp;#XYZZY;" and so on.
+###############################################################################
+{
+# Disarm all entities by converting & to &amp;
+
+ $string = str_replace('&', '&amp;', $string);
+
+# Change back the allowed entities in our entity whitelist
+
+ $string = preg_replace('/&amp;([A-Za-z][A-Za-z0-9]{0,19});/',
+ '&\\1;', $string);
+ $string = preg_replace('/&amp;#0*([0-9]{1,5});/e',
+ 'wp_kses_normalize_entities2("\\1")', $string);
+ $string = preg_replace('/&amp;#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/',
+ '&#\\1\\2;', $string);
+
+ return $string;
+} # function wp_kses_normalize_entities
+
+
+function wp_kses_normalize_entities2($i)
+###############################################################################
+# This function helps wp_kses_normalize_entities() to only accept 16 bit values
+# and nothing more for &#number; entities.
+###############################################################################
+{
+ return (($i > 65535) ? "&amp;#$i;" : "&#$i;");
+} # function wp_kses_normalize_entities2
+
+
+function wp_kses_decode_entities($string)
+###############################################################################
+# This function decodes numeric HTML entities (&#65; and &#x41;). It doesn't
+# do anything with other entities like &auml;, but we don't need them in the
+# URL protocol whitelisting system anyway.
+###############################################################################
+{
+ $string = preg_replace('/&#([0-9]+);/e', 'chr("\\1")', $string);
+ $string = preg_replace('/&#[Xx]([0-9A-Fa-f]+);/e', 'chr(hexdec("\\1"))',
+ $string);
+
+ return $string;
+} # function wp_kses_decode_entities
+
+function wp_filter_kses( $string ) {
+ global $allowedtags;
+ return wp_kses($string, $allowedtags);
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/links.php b/wp-inst/wp-includes/links.php
new file mode 100644
index 0000000..52292ae
--- /dev/null
+++ b/wp-inst/wp-includes/links.php
@@ -0,0 +1,568 @@
+<?php
+
+/** function get_linksbyname()
+ ** Gets the links associated with category 'cat_name'.
+ ** Parameters:
+ ** cat_name (default 'noname') - The category name to use. If no
+ ** match is found uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and it's description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url', 'description' or 'rating'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined
+ ** show_rating (default false) - show rating stars/chars
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - whether to show last updated timestamp
+ */
+function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />',
+ $between = " ", $show_images = true, $orderby = 'id',
+ $show_description = true, $show_rating = false,
+ $limit = -1, $show_updated = 0) {
+ global $wpdb;
+ $cat_id = -1;
+ $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
+ if ($results) {
+ foreach ($results as $result) {
+ $cat_id = $result->cat_id;
+ }
+ }
+ get_links($cat_id, $before, $after, $between, $show_images, $orderby,
+ $show_description, $show_rating, $limit, $show_updated);
+}
+
+function bool_from_yn($yn) {
+ if ($yn == 'Y') return 1;
+ return 0;
+}
+
+/** function wp_get_linksbyname()
+ ** Gets the links associated with the named category.
+ ** Parameters:
+ ** category (no default) - The category to use.
+ **/
+function wp_get_linksbyname($category, $args = '') {
+ global $wpdb;
+
+ $cat = $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_name='$category'");
+
+ if (! $cat) {
+ return;
+ }
+
+ if (empty($args)) {
+ if ($cat->sort_desc == 'Y') {
+ $cat->sort_order = '_'.$cat->sort_order;
+ }
+ get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
+ $cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
+ bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
+ $cat->list_limit, bool_from_yn($cat->show_updated));
+ } else {
+ $args = add_query_arg('category', $cat->cat_id, $args);
+ wp_get_links($args);
+ }
+} // end wp_get_linksbyname
+
+/** function wp_get_links()
+ ** Gets the links associated with category n.
+ ** Parameters:
+ ** category (no default) - The category to use.
+ ** or:
+ ** a query string
+ **/
+function wp_get_links($args = '') {
+ global $wpdb;
+
+ if (!empty($args) && false === strpos($args, '=')) {
+ // If args is not a query string, it's a category id.
+ $category = $args;
+ $cat = $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=$category");
+ if ($cat) {
+ if ($cat->sort_desc == 'Y') {
+ $cat->sort_order = '_'.$cat->sort_order;
+ }
+ get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
+ $cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
+ bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
+ $cat->list_limit, bool_from_yn($cat->show_updated));
+ }
+ } else {
+ parse_str($args);
+
+ if (! isset($category)) $category = -1;
+ if (! isset($before)) $before = '';
+ if (! isset($after)) $after = '<br />';
+ if (! isset($between)) $between = ' ';
+ if (! isset($show_images)) $show_images = true;
+ if (! isset($orderby)) $orderby = 'name';
+ if (! isset($show_description)) $show_description = true;
+ if (! isset($show_rating)) $show_rating = false;
+ if (! isset($limit)) $limit = -1;
+ if (! isset($show_updated)) $show_updated = 1;
+ if (! isset($echo)) $echo = true;
+
+ return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
+ }
+} // end wp_get_links
+
+/** function get_links()
+ ** Gets the links associated with category n.
+ ** Parameters:
+ ** category (default -1) - The category to use. If no category supplied
+ ** uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and it's description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url', 'description', or 'rating'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined .
+ ** show_rating (default false) - show rating stars/chars
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - whether to show last updated timestamp
+ */
+function get_links($category = -1, $before = '', $after = '<br />',
+ $between = ' ', $show_images = true, $orderby = 'name',
+ $show_description = true, $show_rating = false,
+ $limit = -1, $show_updated = 1, $echo = true) {
+
+ global $wpdb;
+
+ $direction = ' ASC';
+ $category_query = "";
+ if ($category != -1) {
+ $category_query = " AND link_category = $category ";
+ }
+ if (get_settings('links_recently_updated_time')) {
+ $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL ".get_settings('links_recently_updated_time')." MINUTE) >= NOW(), 1,0) as recently_updated ";
+ } else {
+ $recently_updated_test = '';
+ }
+ if ($show_updated) {
+ $get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
+ }
+
+ $orderby=strtolower($orderby);
+ if ($orderby == '')
+ $orderby = 'id';
+ if (substr($orderby,0,1) == '_') {
+ $direction = ' DESC';
+ $orderby = substr($orderby,1);
+ }
+
+ switch($orderby) {
+ case 'length':
+ $length = ",CHAR_LENGTH(link_name) AS length";
+ break;
+ case 'rand':
+ $orderby = 'rand()';
+ break;
+ default:
+ $orderby = " link_" . $orderby;
+ }
+
+ if (!isset($length)) {
+ $length = "";
+ }
+
+ $sql = "SELECT link_url, link_name, link_image, link_target,
+ link_description, link_rating, link_rel $length $recently_updated_test $get_updated
+ FROM $wpdb->links
+ WHERE link_visible = 'Y' " .
+ $category_query;
+ $sql .= ' ORDER BY ' . $orderby;
+ $sql .= $direction;
+ /* The next 2 lines implement LIMIT TO processing */
+ if ($limit != -1)
+ $sql .= " LIMIT $limit";
+ //echo $sql;
+ $results = $wpdb->get_results($sql);
+ if (!$results) {
+ return;
+ }
+
+ $output = "";
+
+ foreach ($results as $row) {
+ if (!isset($row->recently_updated)) $row->recently_updated = false;
+ $output .= ($before);
+
+ if ($show_updated && $row->recently_updated) {
+ $output .= get_settings('links_recently_updated_prepend');
+ }
+
+ $the_link = '#';
+
+ if ( !empty($row->link_url) )
+ $the_link = wp_specialchars($row->link_url);
+ $rel = $row->link_rel;
+
+ if ($rel != '') {
+ $rel = " rel='$rel'";
+ }
+
+ $desc = wp_specialchars($row->link_description, ENT_QUOTES);
+ $name = wp_specialchars($row->link_name, ENT_QUOTES);
+
+ $title = $desc;
+
+ if ($show_updated) {
+ if (substr($row->link_updated_f,0,2) != '00') {
+ $title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $row->link_updated_f + (get_settings('gmt_offset') * 3600)) .')';
+ }
+ }
+
+ if ('' != $title) {
+ $title = " title='$title'";
+ }
+
+ $alt = " alt='$name'";
+
+ $target = $row->link_target;
+ if ('' != $target) {
+ $target = " target='$target'";
+ }
+
+ $output.= "<a href='$the_link'";
+ $output.= $rel . $title . $target;
+ $output.= '>';
+
+ if (($row->link_image != null) && $show_images) {
+ if (strstr($row->link_image, 'http'))
+ $output.= "<img src='$row->link_image' $alt $title />";
+ else // If it's a relative path
+ $output.= "<img src='" . get_settings('siteurl') . "$row->link_image' $alt $title />";
+ } else {
+ $output.= $name;
+ }
+
+ $output.= '</a>';
+
+ if ($show_updated && $row->recently_updated) {
+ $output.= get_settings('links_recently_updated_append');
+ }
+
+ if ($show_description && ($desc != '')) {
+ $output.= $between.$desc;
+ }
+ $output.= "$after\n";
+ } // end while
+
+ if($echo) {
+ echo $output;
+ } else {
+ return $output;
+ }
+}
+
+
+/** function get_linkobjectsbyname()
+ ** Gets an array of link objects associated with category 'cat_name'.
+ ** Parameters:
+ ** cat_name (default 'noname') - The category name to use. If no
+ ** match is found uses all
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url', 'description', or 'rating'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ **
+ ** Use this like:
+ ** $links = get_linkobjectsbyname('fred');
+ ** foreach ($links as $link) {
+ ** echo '<li>'.$link->link_name.'</li>';
+ ** }
+ **/
+function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
+ global $wpdb;
+ $cat_id = -1;
+ $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
+ if ($results) {
+ foreach ($results as $result) {
+ $cat_id = $result->cat_id;
+ }
+ }
+ return get_linkobjects($cat_id, $orderby, $limit);
+}
+
+/** function get_linkobjects()
+ ** Gets an array of link objects associated with category n.
+ ** Parameters:
+ ** category (default -1) - The category to use. If no category supplied
+ ** uses all
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url', 'description', or 'rating'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ **
+ ** Use this like:
+ ** $links = get_linkobjects(1);
+ ** if ($links) {
+ ** foreach ($links as $link) {
+ ** echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
+ ** }
+ ** }
+ ** Fields are:
+ ** link_id
+ ** link_url
+ ** link_name
+ ** link_image
+ ** link_target
+ ** link_category
+ ** link_description
+ ** link_visible
+ ** link_owner
+ ** link_rating
+ ** link_updated
+ ** link_rel
+ ** link_notes
+ **/
+function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
+ global $wpdb;
+
+ $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";
+ if ($category != -1) {
+ $sql .= " AND link_category = $category ";
+ }
+ if ($orderby == '')
+ $orderby = 'id';
+ if (substr($orderby,0,1) == '_') {
+ $direction = ' DESC';
+ $orderby = substr($orderby,1);
+ }
+ if (strcasecmp('rand',$orderby) == 0) {
+ $orderby = 'rand()';
+ } else {
+ $orderby = " link_" . $orderby;
+ }
+ $sql .= ' ORDER BY ' . $orderby;
+ $sql .= $direction;
+ /* The next 2 lines implement LIMIT TO processing */
+ if ($limit != -1)
+ $sql .= " LIMIT $limit";
+
+ $results = $wpdb->get_results($sql);
+ if ($results) {
+ foreach ($results as $result) {
+ $result->link_url = $result->link_url;
+ $result->link_name = $result->link_name;
+ $result->link_description = $result->link_description;
+ $result->link_notes = $result->link_notes;
+ $newresults[] = $result;
+ }
+ }
+ return $newresults;
+}
+
+function get_linkrating($link) {
+ return apply_filters('link_rating', $link->link_rating);
+}
+
+
+/** function get_linksbyname_withrating()
+ ** Gets the links associated with category 'cat_name' and display rating stars/chars.
+ ** Parameters:
+ ** cat_name (default 'noname') - The category name to use. If no
+ ** match is found uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and it's description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url' or 'description'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - whether to show last updated timestamp
+ */
+function get_linksbyname_withrating($cat_name = "noname", $before = '',
+ $after = '<br />', $between = " ",
+ $show_images = true, $orderby = 'id',
+ $show_description = true, $limit = -1, $show_updated = 0) {
+
+ get_linksbyname($cat_name, $before, $after, $between, $show_images,
+ $orderby, $show_description, true, $limit, $show_updated);
+}
+
+/** function get_links_withrating()
+ ** Gets the links associated with category n and display rating stars/chars.
+ ** Parameters:
+ ** category (default -1) - The category to use. If no category supplied
+ ** uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and it's description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url' or 'description'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined .
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - whether to show last updated timestamp
+ */
+function get_links_withrating($category = -1, $before = '', $after = '<br />',
+ $between = " ", $show_images = true,
+ $orderby = 'id', $show_description = true,
+ $limit = -1, $show_updated = 0) {
+
+ get_links($category, $before, $after, $between, $show_images, $orderby,
+ $show_description, true, $limit, $show_updated);
+}
+
+/** function get_linkcatname()
+ ** Gets the name of category n.
+ ** Parameters: id (default 0) - The category to get. If no category supplied
+ ** uses 0
+ */
+function get_linkcatname($id = 0) {
+ global $wpdb;
+ $cat_name = '';
+ if ('' != $id) {
+ $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->linkcategories WHERE cat_id=$id");
+ }
+ return $cat_name;
+}
+
+/** function get_get_autotoggle()
+ ** Gets the auto_toggle setting of category n.
+ ** Parameters: id (default 0) - The category to get. If no category supplied
+ ** uses 0
+ */
+function get_autotoggle($id = 0) {
+ global $wpdb;
+ $auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $wpdb->linkcategories WHERE cat_id=$id");
+ if ('' == $auto_toggle)
+ $auto_toggle = 'N';
+ return $auto_toggle;
+}
+
+/** function links_popup_script()
+ ** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/
+ ** Show the link to the links popup and the number of links
+ ** Parameters:
+ ** text (default Links) - the text of the link
+ ** width (default 400) - the width of the popup window
+ ** height (default 400) - the height of the popup window
+ ** file (default linkspopup.php) - the page to open in the popup window
+ ** count (default true) - the number of links in the db
+ */
+function links_popup_script($text = 'Links', $width=400, $height=400,
+ $file='links.all.php', $count = true) {
+ if ($count == true) {
+ $counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links");
+ }
+
+ $javascript = "<a href=\"#\" " .
+ " onclick=\"javascript:window.open('$file?popup=1', '_blank', " .
+ "'width=$width,height=$height,scrollbars=yes,status=no'); " .
+ " return false\">";
+ $javascript .= $text;
+
+ if ($count == true) {
+ $javascript .= " ($counts)";
+ }
+
+ $javascript .="</a>\n\n";
+ echo $javascript;
+}
+
+
+/*
+ * function get_links_list()
+ *
+ * added by Dougal
+ *
+ * Output a list of all links, listed by category, using the
+ * settings in $wpdb->linkcategories and output it as a nested
+ * HTML unordered list.
+ *
+ * Parameters:
+ * order (default 'name') - Sort link categories by 'name' or 'id'
+ * hide_if_empty (default true) - Supress listing empty link categories
+ */
+function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
+ global $wpdb;
+
+ $order = strtolower($order);
+
+ // Handle link category sorting
+ if (substr($order,0,1) == '_') {
+ $direction = ' DESC';
+ $order = substr($order,1);
+ }
+
+ // if 'name' wasn't specified, assume 'id':
+ $cat_order = ('name' == $order) ? 'cat_name' : 'cat_id';
+
+ if (!isset($direction)) $direction = '';
+ // Fetch the link category data as an array of hashesa
+ $cats = $wpdb->get_results("
+ SELECT DISTINCT link_category, cat_name, show_images,
+ show_description, show_rating, show_updated, sort_order,
+ sort_desc, list_limit
+ FROM `$wpdb->links`
+ LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id)
+ WHERE link_visible = 'Y'
+ AND list_limit <> 0
+ ORDER BY $cat_order $direction ", ARRAY_A);
+
+ // Display each category
+ if ($cats) {
+ foreach ($cats as $cat) {
+ // Handle each category.
+ // First, fix the sort_order info
+ $orderby = $cat['sort_order'];
+ $orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby;
+
+ // Display the category name
+ echo ' <li id="linkcat-' . $cat['link_category'] . '"><h2>' . $cat['cat_name'] . "</h2>\n\t<ul>\n";
+ // Call get_links() with all the appropriate params
+ get_links($cat['link_category'],
+ '<li>',"</li>","\n",
+ bool_from_yn($cat['show_images']),
+ $orderby,
+ bool_from_yn($cat['show_description']),
+ bool_from_yn($cat['show_rating']),
+ $cat['list_limit'],
+ bool_from_yn($cat['show_updated']));
+
+ // Close the last category
+ echo "\n\t</ul>\n</li>\n";
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/locale.php b/wp-inst/wp-includes/locale.php
new file mode 100644
index 0000000..7af4dea
--- /dev/null
+++ b/wp-inst/wp-includes/locale.php
@@ -0,0 +1,70 @@
+<?php
+// Date and Time
+
+// The Weekdays
+$weekday[0] = __('Sunday');
+$weekday[1] = __('Monday');
+$weekday[2] = __('Tuesday');
+$weekday[3] = __('Wednesday');
+$weekday[4] = __('Thursday');
+$weekday[5] = __('Friday');
+$weekday[6] = __('Saturday');
+
+// The first letter of each day. The _%day%_initial suffix is a hack to make
+// sure the day initials are unique. They should be translated to a one
+// letter initial.
+$weekday_initial[__('Sunday')] = __('S_Sunday_initial');
+$weekday_initial[__('Monday')] = __('M_Monday_initial');
+$weekday_initial[__('Tuesday')] = __('T_Tuesday_initial');
+$weekday_initial[__('Wednesday')] = __('W_Wednesday_initial');
+$weekday_initial[__('Thursday')] = __('T_Thursday_initial');
+$weekday_initial[__('Friday')] = __('F_Friday_initial');
+$weekday_initial[__('Saturday')] = __('S_Saturday_initial');
+
+foreach ($weekday_initial as $weekday_ => $weekday_initial_) {
+ $weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
+}
+
+// Abbreviations for each day.
+$weekday_abbrev[__('Sunday')] = __('Sun');
+$weekday_abbrev[__('Monday')] = __('Mon');
+$weekday_abbrev[__('Tuesday')] = __('Tue');
+$weekday_abbrev[__('Wednesday')] = __('Wed');
+$weekday_abbrev[__('Thursday')] = __('Thu');
+$weekday_abbrev[__('Friday')] = __('Fri');
+$weekday_abbrev[__('Saturday')] = __('Sat');
+
+// The Months
+$month['01'] = __('January');
+$month['02'] = __('February');
+$month['03'] = __('March');
+$month['04'] = __('April');
+$month['05'] = __('May');
+$month['06'] = __('June');
+$month['07'] = __('July');
+$month['08'] = __('August');
+$month['09'] = __('September');
+$month['10'] = __('October');
+$month['11'] = __('November');
+$month['12'] = __('December');
+
+// Abbreviations for each month. Uses the same hack as above to get around the
+// 'May' duplication.
+$month_abbrev[__('January')] = __('Jan_January_abbreviation');
+$month_abbrev[__('February')] = __('Feb_February_abbreviation');
+$month_abbrev[__('March')] = __('Mar_March_abbreviation');
+$month_abbrev[__('April')] = __('Apr_April_abbreviation');
+$month_abbrev[__('May')] = __('May_May_abbreviation');
+$month_abbrev[__('June')] = __('Jun_June_abbreviation');
+$month_abbrev[__('July')] = __('Jul_July_abbreviation');
+$month_abbrev[__('August')] = __('Aug_August_abbreviation');
+$month_abbrev[__('September')] = __('Sep_September_abbreviation');
+$month_abbrev[__('October')] = __('Oct_October_abbreviation');
+$month_abbrev[__('November')] = __('Nov_November_abbreviation');
+$month_abbrev[__('December')] = __('Dec_December_abbreviation');
+
+foreach ($month_abbrev as $month_ => $month_abbrev_) {
+ $month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/pluggable-functions.php b/wp-inst/wp-includes/pluggable-functions.php
new file mode 100644
index 0000000..4d25ffd
--- /dev/null
+++ b/wp-inst/wp-includes/pluggable-functions.php
@@ -0,0 +1,282 @@
+<?php
+
+ /* These functions can be replaced via plugins. They are loaded after
+ plugins are loaded. */
+
+
+if ( !function_exists('get_currentuserinfo') ) :
+function get_currentuserinfo() {
+ global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
+
+ if ( !isset($_COOKIE['wordpressuser_' . COOKIEHASH]))
+ return false;
+
+ $user_login = $_COOKIE['wordpressuser_' . COOKIEHASH];
+ $userdata = get_userdatabylogin($user_login);
+ $user_level = $userdata->user_level;
+ $user_ID = $userdata->ID;
+ $user_email = $userdata->user_email;
+ $user_url = $userdata->user_url;
+ $user_pass_md5 = md5($userdata->user_pass);
+ $user_identity = $userdata->display_name;
+
+ if ( empty($current_user) )
+ $current_user = new WP_User($user_ID);
+}
+endif;
+
+if ( !function_exists('get_userdata') ) :
+function get_userdata( $user_id ) {
+ global $wpdb, $cache_userdata;
+ $user_id = (int) $user_id;
+ if ( $user_id == 0 )
+ return false;
+
+ if ( isset( $cache_userdata[$user_id] ) )
+ return $cache_userdata[$user_id];
+
+ if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$user_id'") )
+ return $cache_userdata[$user_id] = false;
+
+ $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'");
+
+ foreach ( $metavalues as $meta ) {
+ @ $value = unserialize($meta->meta_value);
+ if ($value === FALSE)
+ $value = $meta->meta_value;
+ $user->{$meta->meta_key} = $value;
+
+ // We need to set user_level from meta, not row
+ if ( $wpdb->prefix . 'user_level' == $meta->meta_key )
+ $user->user_level = $meta->meta_value;
+ }
+
+ $cache_userdata[$user_id] = $user;
+
+ $cache_userdata[$cache_userdata[$userid]->user_login] =& $cache_userdata[$user_id];
+
+ return $cache_userdata[$user_id];
+}
+endif;
+
+if ( !function_exists('get_userdatabylogin') ) :
+function get_userdatabylogin($user_login) {
+ global $cache_userdata, $wpdb;
+ $user_login = sanitize_user( $user_login );
+ if ( empty( $user_login ) )
+ return false;
+ if ( isset( $cache_userdata[$user_login] ) )
+ return $cache_userdata[$user_login];
+
+ $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$user_login'");
+
+ return get_userdata( $user_id );
+}
+endif;
+
+if ( !function_exists('wp_mail') ) :
+function wp_mail($to, $subject, $message, $headers = '') {
+ if( $headers == '' ) {
+ $headers = "MIME-Version: 1.0\n" .
+ "From: " . get_settings('admin_email') . "\n" .
+ "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n";
+ }
+
+ return @mail($to, $subject, $message, $headers);
+}
+endif;
+
+if ( !function_exists('wp_login') ) :
+function wp_login($username, $password, $already_md5 = false) {
+ global $wpdb, $error;
+
+ if ( !$username )
+ return false;
+
+ if ( !$password ) {
+ $error = __('<strong>Error</strong>: The password field is empty.');
+ return false;
+ }
+
+ $login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'");
+
+ if (!$login) {
+ $error = __('<strong>Error</strong>: Wrong username.');
+ return false;
+ } else {
+ // If the password is already_md5, it has been double hashed.
+ // Otherwise, it is plain text.
+ if ( ($already_md5 && $login->user_login == $username && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) {
+ return true;
+ } else {
+ $error = __('<strong>Error</strong>: Incorrect password.');
+ $pwd = '';
+ return false;
+ }
+ }
+}
+endif;
+
+if ( !function_exists('auth_redirect') ) :
+function auth_redirect() {
+ // Checks if a user is logged in, if not redirects them to the login page
+ if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) &&
+ !wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) ||
+ (empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) {
+ nocache_headers();
+
+ header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
+ exit();
+ }
+}
+endif;
+
+// Cookie safe redirect. Works around IIS Set-Cookie bug.
+// http://support.microsoft.com/kb/q176113/
+if ( !function_exists('wp_redirect') ) :
+function wp_redirect($location) {
+ global $is_IIS;
+
+ if ($is_IIS)
+ header("Refresh: 0;url=$location");
+ else
+ header("Location: $location");
+}
+endif;
+
+if ( !function_exists('wp_setcookie') ) :
+function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '') {
+ if ( !$already_md5 )
+ $password = md5( md5($password) ); // Double hash the password in the cookie.
+
+ if ( empty($home) )
+ $cookiepath = COOKIEPATH;
+ else
+ $cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' );
+
+ if ( empty($siteurl) ) {
+ $sitecookiepath = SITECOOKIEPATH;
+ $cookiehash = COOKIEHASH;
+ } else {
+ $sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' );
+ $cookiehash = md5($siteurl);
+ }
+
+ setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $cookiepath);
+ setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $cookiepath);
+
+ if ( $cookiepath != $sitecookiepath ) {
+ setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $sitecookiepath);
+ setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $sitecookiepath);
+ }
+}
+endif;
+
+if ( !function_exists('wp_clearcookie') ) :
+function wp_clearcookie() {
+ setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH);
+ setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH);
+ setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH);
+ setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH);
+}
+endif;
+
+if ( ! function_exists('wp_notify_postauthor') ) :
+function wp_notify_postauthor($comment_id, $comment_type='') {
+ global $wpdb;
+
+ $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
+ $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
+ $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1");
+
+ if ('' == $user->user_email) return false; // If there's no email to send the comment to
+
+ $comment_author_domain = gethostbyaddr($comment->comment_author_IP);
+
+ $blogname = get_settings('blogname');
+
+ if ( empty( $comment_type ) ) $comment_type = 'comment';
+
+ if ('comment' == $comment_type) {
+ $notify_message = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
+ $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+ $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
+ $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";
+ $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
+ $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+ $notify_message .= __('You can see all comments on this post here: ') . "\r\n";
+ $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
+ } elseif ('trackback' == $comment_type) {
+ $notify_message = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
+ $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+ $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";
+ $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+ $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
+ $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
+ } elseif ('pingback' == $comment_type) {
+ $notify_message = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
+ $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+ $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";
+ $notify_message .= __('Excerpt: ') . "\r\n" . sprintf( __('[...] %s [...]'), $comment->comment_content ) . "\r\n\r\n";
+ $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
+ $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
+ }
+ $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
+ $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n";
+
+ if ('' == $comment->comment_author_email || '' == $comment->comment_author) {
+ $from = "From: \"$blogname\" <wordpress@" . $_SERVER['SERVER_NAME'] . '>';
+ } else {
+ $from = 'From: "' . $comment->comment_author . "\" <$comment->comment_author_email>";
+ }
+
+ $message_headers = "MIME-Version: 1.0\n"
+ . "$from\n"
+ . "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n";
+
+ @wp_mail($user->user_email, $subject, $notify_message, $message_headers);
+
+ return true;
+}
+endif;
+
+/* wp_notify_moderator
+ notifies the moderator of the blog (usually the admin)
+ about a new comment that waits for approval
+ always returns true
+ */
+if ( !function_exists('wp_notify_moderator') ) :
+function wp_notify_moderator($comment_id) {
+ global $wpdb;
+
+ if( get_settings( "moderation_notify" ) == 0 )
+ return true;
+
+ $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
+ $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
+
+ $comment_author_domain = gethostbyaddr($comment->comment_author_IP);
+ $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
+
+ $notify_message = sprintf( __('A new comment on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n";
+ $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
+ $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+ $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
+ $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";
+ $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
+ $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+ $notify_message .= sprintf( __('To approve this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=mailapprovecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n";
+ $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n";
+ $notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n";
+ $notify_message .= get_settings('siteurl') . "/wp-admin/moderation.php\r\n";
+
+ $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_settings('blogname'), $post->post_title );
+ $admin_email = get_settings("admin_email");
+
+ @wp_mail($admin_email, $subject, $notify_message);
+
+ return true;
+}
+endif;
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/registration-functions.php b/wp-inst/wp-includes/registration-functions.php
new file mode 100644
index 0000000..9299d01
--- /dev/null
+++ b/wp-inst/wp-includes/registration-functions.php
@@ -0,0 +1,32 @@
+<?php
+
+function username_exists( $username ) {
+ global $wpdb;
+ $username = sanitize_user( $username );
+ $query = "SELECT user_login FROM $wpdb->users WHERE user_login = '$username'";
+ $query = apply_filters('username_exists', $query);
+ return $wpdb->get_var( $query );
+}
+
+function create_user( $username, $password, $email, $user_level ) {
+ global $wpdb;
+ $username = $wpdb->escape( $username );
+ $email = $wpdb->escape( $email );
+ $password = md5( $password );
+ $user_nicename = sanitize_title( $username );
+ $now = gmdate('Y-m-d H:i:s');
+
+ $query = "INSERT INTO $wpdb->users
+ (user_login, user_pass, user_email, user_registered, user_nicename, display_name)
+ VALUES
+ ('$username', '$password', '$email', '$now', '$user_nicename', '$username')";
+ $query = apply_filters('create_user_query', $query);
+ $wpdb->query( $query );
+ $user_id = $wpdb->insert_id;
+
+ $user_level = (int) $user_level;
+ update_usermeta( $user_id, $wpdb->prefix . 'user_level', $user_level);
+ return $user_id;
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/rss-functions.php b/wp-inst/wp-includes/rss-functions.php
new file mode 100644
index 0000000..960c273
--- /dev/null
+++ b/wp-inst/wp-includes/rss-functions.php
@@ -0,0 +1,850 @@
+<?php
+/*
+ * Project: MagpieRSS: a simple RSS integration tool
+ * File: A compiled file for RSS syndication
+ * Author: Kellan Elliott-McCrea <kellan@protest.net>
+ * Version: 0.51
+ * License: GPL
+ */
+
+define('RSS', 'RSS');
+define('ATOM', 'Atom');
+define('MAGPIE_USER_AGENT', 'WordPress/' . $wp_version);
+
+class MagpieRSS {
+ var $parser;
+ var $current_item = array(); // item currently being parsed
+ var $items = array(); // collection of parsed items
+ var $channel = array(); // hash of channel fields
+ var $textinput = array();
+ var $image = array();
+ var $feed_type;
+ var $feed_version;
+
+ // parser variables
+ var $stack = array(); // parser stack
+ var $inchannel = false;
+ var $initem = false;
+ var $incontent = false; // if in Atom <content mode="xml"> field
+ var $intextinput = false;
+ var $inimage = false;
+ var $current_field = '';
+ var $current_namespace = false;
+
+ //var $ERROR = "";
+
+ var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
+
+ function MagpieRSS ($source) {
+
+ # if PHP xml isn't compiled in, die
+ #
+ if (!function_exists('xml_parser_create')) {
+ $this->error( "Failed to load PHP's XML Extension. " .
+ "http://www.php.net/manual/en/ref.xml.php",
+ E_USER_ERROR );
+ }
+
+ $parser = @xml_parser_create();
+
+ if (!is_resource($parser))
+ {
+ $this->error( "Failed to create an instance of PHP's XML parser. " .
+ "http://www.php.net/manual/en/ref.xml.php",
+ E_USER_ERROR );
+ }
+
+
+ $this->parser = $parser;
+
+ # pass in parser, and a reference to this object
+ # setup handlers
+ #
+ xml_set_object( $this->parser, $this );
+ xml_set_element_handler($this->parser,
+ 'feed_start_element', 'feed_end_element' );
+
+ xml_set_character_data_handler( $this->parser, 'feed_cdata' );
+
+ $status = xml_parse( $this->parser, $source );
+
+ if (! $status ) {
+ $errorcode = xml_get_error_code( $this->parser );
+ if ( $errorcode != XML_ERROR_NONE ) {
+ $xml_error = xml_error_string( $errorcode );
+ $error_line = xml_get_current_line_number($this->parser);
+ $error_col = xml_get_current_column_number($this->parser);
+ $errormsg = "$xml_error at line $error_line, column $error_col";
+
+ $this->error( $errormsg );
+ }
+ }
+
+ xml_parser_free( $this->parser );
+
+ $this->normalize();
+ }
+
+ function feed_start_element($p, $element, &$attrs) {
+ $el = $element = strtolower($element);
+ $attrs = array_change_key_case($attrs, CASE_LOWER);
+
+ // check for a namespace, and split if found
+ $ns = false;
+ if ( strpos( $element, ':' ) ) {
+ list($ns, $el) = split( ':', $element, 2);
+ }
+ if ( $ns and $ns != 'rdf' ) {
+ $this->current_namespace = $ns;
+ }
+
+ # if feed type isn't set, then this is first element of feed
+ # identify feed from root element
+ #
+ if (!isset($this->feed_type) ) {
+ if ( $el == 'rdf' ) {
+ $this->feed_type = RSS;
+ $this->feed_version = '1.0';
+ }
+ elseif ( $el == 'rss' ) {
+ $this->feed_type = RSS;
+ $this->feed_version = $attrs['version'];
+ }
+ elseif ( $el == 'feed' ) {
+ $this->feed_type = ATOM;
+ $this->feed_version = $attrs['version'];
+ $this->inchannel = true;
+ }
+ return;
+ }
+
+ if ( $el == 'channel' )
+ {
+ $this->inchannel = true;
+ }
+ elseif ($el == 'item' or $el == 'entry' )
+ {
+ $this->initem = true;
+ if ( isset($attrs['rdf:about']) ) {
+ $this->current_item['about'] = $attrs['rdf:about'];
+ }
+ }
+
+ // if we're in the default namespace of an RSS feed,
+ // record textinput or image fields
+ elseif (
+ $this->feed_type == RSS and
+ $this->current_namespace == '' and
+ $el == 'textinput' )
+ {
+ $this->intextinput = true;
+ }
+
+ elseif (
+ $this->feed_type == RSS and
+ $this->current_namespace == '' and
+ $el == 'image' )
+ {
+ $this->inimage = true;
+ }
+
+ # handle atom content constructs
+ elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
+ {
+ // avoid clashing w/ RSS mod_content
+ if ($el == 'content' ) {
+ $el = 'atom_content';
+ }
+
+ $this->incontent = $el;
+
+
+ }
+
+ // if inside an Atom content construct (e.g. content or summary) field treat tags as text
+ elseif ($this->feed_type == ATOM and $this->incontent )
+ {
+ // if tags are inlined, then flatten
+ $attrs_str = join(' ',
+ array_map('map_attrs',
+ array_keys($attrs),
+ array_values($attrs) ) );
+
+ $this->append_content( "<$element $attrs_str>" );
+
+ array_unshift( $this->stack, $el );
+ }
+
+ // Atom support many links per containging element.
+ // Magpie treats link elements of type rel='alternate'
+ // as being equivalent to RSS's simple link element.
+ //
+ elseif ($this->feed_type == ATOM and $el == 'link' )
+ {
+ if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
+ {
+ $link_el = 'link';
+ }
+ else {
+ $link_el = 'link_' . $attrs['rel'];
+ }
+
+ $this->append($link_el, $attrs['href']);
+ }
+ // set stack[0] to current element
+ else {
+ array_unshift($this->stack, $el);
+ }
+ }
+
+
+
+ function feed_cdata ($p, $text) {
+
+ if ($this->feed_type == ATOM and $this->incontent)
+ {
+ $this->append_content( $text );
+ }
+ else {
+ $current_el = join('_', array_reverse($this->stack));
+ $this->append($current_el, $text);
+ }
+ }
+
+ function feed_end_element ($p, $el) {
+ $el = strtolower($el);
+
+ if ( $el == 'item' or $el == 'entry' )
+ {
+ $this->items[] = $this->current_item;
+ $this->current_item = array();
+ $this->initem = false;
+ }
+ elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' )
+ {
+ $this->intextinput = false;
+ }
+ elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' )
+ {
+ $this->inimage = false;
+ }
+ elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
+ {
+ $this->incontent = false;
+ }
+ elseif ($el == 'channel' or $el == 'feed' )
+ {
+ $this->inchannel = false;
+ }
+ elseif ($this->feed_type == ATOM and $this->incontent ) {
+ // balance tags properly
+ // note: i don't think this is actually neccessary
+ if ( $this->stack[0] == $el )
+ {
+ $this->append_content("</$el>");
+ }
+ else {
+ $this->append_content("<$el />");
+ }
+
+ array_shift( $this->stack );
+ }
+ else {
+ array_shift( $this->stack );
+ }
+
+ $this->current_namespace = false;
+ }
+
+ function concat (&$str1, $str2="") {
+ if (!isset($str1) ) {
+ $str1="";
+ }
+ $str1 .= $str2;
+ }
+
+ function append_content($text) {
+ if ( $this->initem ) {
+ $this->concat( $this->current_item[ $this->incontent ], $text );
+ }
+ elseif ( $this->inchannel ) {
+ $this->concat( $this->channel[ $this->incontent ], $text );
+ }
+ }
+
+ // smart append - field and namespace aware
+ function append($el, $text) {
+ if (!$el) {
+ return;
+ }
+ if ( $this->current_namespace )
+ {
+ if ( $this->initem ) {
+ $this->concat(
+ $this->current_item[ $this->current_namespace ][ $el ], $text);
+ }
+ elseif ($this->inchannel) {
+ $this->concat(
+ $this->channel[ $this->current_namespace][ $el ], $text );
+ }
+ elseif ($this->intextinput) {
+ $this->concat(
+ $this->textinput[ $this->current_namespace][ $el ], $text );
+ }
+ elseif ($this->inimage) {
+ $this->concat(
+ $this->image[ $this->current_namespace ][ $el ], $text );
+ }
+ }
+ else {
+ if ( $this->initem ) {
+ $this->concat(
+ $this->current_item[ $el ], $text);
+ }
+ elseif ($this->intextinput) {
+ $this->concat(
+ $this->textinput[ $el ], $text );
+ }
+ elseif ($this->inimage) {
+ $this->concat(
+ $this->image[ $el ], $text );
+ }
+ elseif ($this->inchannel) {
+ $this->concat(
+ $this->channel[ $el ], $text );
+ }
+
+ }
+ }
+
+ function normalize () {
+ // if atom populate rss fields
+ if ( $this->is_atom() ) {
+ $this->channel['descripton'] = $this->channel['tagline'];
+ for ( $i = 0; $i < count($this->items); $i++) {
+ $item = $this->items[$i];
+ if ( isset($item['summary']) )
+ $item['description'] = $item['summary'];
+ if ( isset($item['atom_content']))
+ $item['content']['encoded'] = $item['atom_content'];
+
+ $this->items[$i] = $item;
+ }
+ }
+ elseif ( $this->is_rss() ) {
+ $this->channel['tagline'] = $this->channel['description'];
+ for ( $i = 0; $i < count($this->items); $i++) {
+ $item = $this->items[$i];
+ if ( isset($item['description']))
+ $item['summary'] = $item['description'];
+ if ( isset($item['content']['encoded'] ) )
+ $item['atom_content'] = $item['content']['encoded'];
+
+ $this->items[$i] = $item;
+ }
+ }
+ }
+
+ function is_rss () {
+ if ( $this->feed_type == RSS ) {
+ return $this->feed_version;
+ }
+ else {
+ return false;
+ }
+ }
+
+ function is_atom() {
+ if ( $this->feed_type == ATOM ) {
+ return $this->feed_version;
+ }
+ else {
+ return false;
+ }
+ }
+
+function map_attrs($k, $v) {
+ return "$k=\"$v\"";
+ }
+}
+require_once( dirname(__FILE__) . '/class-snoopy.php');
+
+function fetch_rss ($url) {
+ // initialize constants
+ init();
+
+ if ( !isset($url) ) {
+ error("fetch_rss called without a url");
+ return false;
+ }
+
+ // if cache is disabled
+ if ( !MAGPIE_CACHE_ON ) {
+ // fetch file, and parse it
+ $resp = _fetch_remote_file( $url );
+ if ( is_success( $resp->status ) ) {
+ return _response_to_rss( $resp );
+ }
+ else {
+ error("Failed to fetch $url and cache is off");
+ return false;
+ }
+ }
+ // else cache is ON
+ else {
+ // Flow
+ // 1. check cache
+ // 2. if there is a hit, make sure its fresh
+ // 3. if cached obj fails freshness check, fetch remote
+ // 4. if remote fails, return stale object, or error
+
+ $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
+
+ if (MAGPIE_DEBUG and $cache->ERROR) {
+ debug($cache->ERROR, E_USER_WARNING);
+ }
+
+
+ $cache_status = 0; // response of check_cache
+ $request_headers = array(); // HTTP headers to send with fetch
+ $rss = 0; // parsed RSS object
+ $errormsg = 0; // errors, if any
+
+ if (!$cache->ERROR) {
+ // return cache HIT, MISS, or STALE
+ $cache_status = $cache->check_cache( $url );
+ }
+
+ // if object cached, and cache is fresh, return cached obj
+ if ( $cache_status == 'HIT' ) {
+ $rss = $cache->get( $url );
+ if ( isset($rss) and $rss ) {
+ $rss->from_cache = 1;
+ if ( MAGPIE_DEBUG > 1) {
+ debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
+ }
+ return $rss;
+ }
+ }
+
+ // else attempt a conditional get
+
+ // setup headers
+ if ( $cache_status == 'STALE' ) {
+ $rss = $cache->get( $url );
+ if ( $rss->etag and $rss->last_modified ) {
+ $request_headers['If-None-Match'] = $rss->etag;
+ $request_headers['If-Last-Modified'] = $rss->last_modified;
+ }
+ }
+
+ $resp = _fetch_remote_file( $url, $request_headers );
+
+ if (isset($resp) and $resp) {
+ if ($resp->status == '304' ) {
+ // we have the most current copy
+ if ( MAGPIE_DEBUG > 1) {
+ debug("Got 304 for $url");
+ }
+ // reset cache on 304 (at minutillo insistent prodding)
+ $cache->set($url, $rss);
+ return $rss;
+ }
+ elseif ( is_success( $resp->status ) ) {
+ $rss = _response_to_rss( $resp );
+ if ( $rss ) {
+ if (MAGPIE_DEBUG > 1) {
+ debug("Fetch successful");
+ }
+ // add object to cache
+ $cache->set( $url, $rss );
+ return $rss;
+ }
+ }
+ else {
+ $errormsg = "Failed to fetch $url. ";
+ if ( $resp->error ) {
+ # compensate for Snoopy's annoying habbit to tacking
+ # on '\n'
+ $http_error = substr($resp->error, 0, -2);
+ $errormsg .= "(HTTP Error: $http_error)";
+ }
+ else {
+ $errormsg .= "(HTTP Response: " . $resp->response_code .')';
+ }
+ }
+ }
+ else {
+ $errormsg = "Unable to retrieve RSS file for unknown reasons.";
+ }
+
+ // else fetch failed
+
+ // attempt to return cached object
+ if ($rss) {
+ if ( MAGPIE_DEBUG ) {
+ debug("Returning STALE object for $url");
+ }
+ return $rss;
+ }
+
+ // else we totally failed
+ error( $errormsg );
+
+ return false;
+
+ } // end if ( !MAGPIE_CACHE_ON ) {
+} // end fetch_rss()
+
+function _fetch_remote_file ($url, $headers = "" ) {
+ // Snoopy is an HTTP client in PHP
+ $client = new Snoopy();
+ $client->agent = MAGPIE_USER_AGENT;
+ $client->read_timeout = MAGPIE_FETCH_TIME_OUT;
+ $client->use_gzip = MAGPIE_USE_GZIP;
+ if (is_array($headers) ) {
+ $client->rawheaders = $headers;
+ }
+
+ @$client->fetch($url);
+ return $client;
+
+}
+
+function _response_to_rss ($resp) {
+ $rss = new MagpieRSS( $resp->results );
+
+ // if RSS parsed successfully
+ if ( $rss and !$rss->ERROR) {
+
+ // find Etag, and Last-Modified
+ foreach($resp->headers as $h) {
+ // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
+ if (strpos($h, ": ")) {
+ list($field, $val) = explode(": ", $h, 2);
+ }
+ else {
+ $field = $h;
+ $val = "";
+ }
+
+ if ( $field == 'ETag' ) {
+ $rss->etag = $val;
+ }
+
+ if ( $field == 'Last-Modified' ) {
+ $rss->last_modified = $val;
+ }
+ }
+
+ return $rss;
+ } // else construct error message
+ else {
+ $errormsg = "Failed to parse RSS file.";
+
+ if ($rss) {
+ $errormsg .= " (" . $rss->ERROR . ")";
+ }
+ error($errormsg);
+
+ return false;
+ } // end if ($rss and !$rss->error)
+}
+
+/*=======================================================================*\
+ Function: init
+ Purpose: setup constants with default values
+ check for user overrides
+\*=======================================================================*/
+function init () {
+ if ( defined('MAGPIE_INITALIZED') ) {
+ return;
+ }
+ else {
+ define('MAGPIE_INITALIZED', 1);
+ }
+
+ if ( !defined('MAGPIE_CACHE_ON') ) {
+ define('MAGPIE_CACHE_ON', 1);
+ }
+
+ if ( !defined('MAGPIE_CACHE_DIR') ) {
+ define('MAGPIE_CACHE_DIR', './cache');
+ }
+
+ if ( !defined('MAGPIE_CACHE_AGE') ) {
+ define('MAGPIE_CACHE_AGE', 60*60); // one hour
+ }
+
+ if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) {
+ define('MAGPIE_CACHE_FRESH_ONLY', 0);
+ }
+
+ if ( !defined('MAGPIE_DEBUG') ) {
+ define('MAGPIE_DEBUG', 0);
+ }
+
+ if ( !defined('MAGPIE_USER_AGENT') ) {
+ $ua = 'WordPress/' . $wp_version;
+
+ if ( MAGPIE_CACHE_ON ) {
+ $ua = $ua . ')';
+ }
+ else {
+ $ua = $ua . '; No cache)';
+ }
+
+ define('MAGPIE_USER_AGENT', $ua);
+ }
+
+ if ( !defined('MAGPIE_FETCH_TIME_OUT') ) {
+ define('MAGPIE_FETCH_TIME_OUT', 2); // 2 second timeout
+ }
+
+ // use gzip encoding to fetch rss files if supported?
+ if ( !defined('MAGPIE_USE_GZIP') ) {
+ define('MAGPIE_USE_GZIP', true);
+ }
+}
+
+function is_info ($sc) {
+ return $sc >= 100 && $sc < 200;
+}
+
+function is_success ($sc) {
+ return $sc >= 200 && $sc < 300;
+}
+
+function is_redirect ($sc) {
+ return $sc >= 300 && $sc < 400;
+}
+
+function is_error ($sc) {
+ return $sc >= 400 && $sc < 600;
+}
+
+function is_client_error ($sc) {
+ return $sc >= 400 && $sc < 500;
+}
+
+function is_server_error ($sc) {
+ return $sc >= 500 && $sc < 600;
+}
+
+class RSSCache {
+ var $BASE_CACHE = 'wp-content/cache'; // where the cache files are stored
+ var $MAX_AGE = 43200; // when are files stale, default twelve hours
+ var $ERROR = ''; // accumulate error messages
+
+ function RSSCache ($base='', $age='') {
+ if ( $base ) {
+ $this->BASE_CACHE = $base;
+ }
+ if ( $age ) {
+ $this->MAX_AGE = $age;
+ }
+
+ }
+
+/*=======================================================================*\
+ Function: set
+ Purpose: add an item to the cache, keyed on url
+ Input: url from wich the rss file was fetched
+ Output: true on sucess
+\*=======================================================================*/
+ function set ($url, $rss) {
+ global $wpdb;
+ $cache_option = 'rss_' . $this->file_name( $url );
+ $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
+
+ if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$cache_option'") )
+ add_option($cache_option, '', '', 'no');
+ if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$cache_timestamp'") )
+ add_option($cache_timestamp, '', '', 'no');
+
+ update_option($cache_option, $rss);
+ update_option($cache_timestamp, time() );
+
+ return $cache_option;
+ }
+
+/*=======================================================================*\
+ Function: get
+ Purpose: fetch an item from the cache
+ Input: url from wich the rss file was fetched
+ Output: cached object on HIT, false on MISS
+\*=======================================================================*/
+ function get ($url) {
+ $this->ERROR = "";
+ $cache_option = 'rss_' . $this->file_name( $url );
+
+ if ( ! get_option( $cache_option ) ) {
+ $this->debug(
+ "Cache doesn't contain: $url (cache option: $cache_option)"
+ );
+ return 0;
+ }
+
+ $rss = get_option( $cache_option );
+
+ return $rss;
+ }
+
+/*=======================================================================*\
+ Function: check_cache
+ Purpose: check a url for membership in the cache
+ and whether the object is older then MAX_AGE (ie. STALE)
+ Input: url from wich the rss file was fetched
+ Output: cached object on HIT, false on MISS
+\*=======================================================================*/
+ function check_cache ( $url ) {
+ $this->ERROR = "";
+ $cache_option = $this->file_name( $url );
+ $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
+
+ if ( $mtime = get_option($cache_timestamp) ) {
+ // find how long ago the file was added to the cache
+ // and whether that is longer then MAX_AGE
+ $age = time() - $mtime;
+ if ( $this->MAX_AGE > $age ) {
+ // object exists and is current
+ return 'HIT';
+ }
+ else {
+ // object exists but is old
+ return 'STALE';
+ }
+ }
+ else {
+ // object does not exist
+ return 'MISS';
+ }
+ }
+
+/*=======================================================================*\
+ Function: serialize
+\*=======================================================================*/
+ function serialize ( $rss ) {
+ return serialize( $rss );
+ }
+
+/*=======================================================================*\
+ Function: unserialize
+\*=======================================================================*/
+ function unserialize ( $data ) {
+ return unserialize( $data );
+ }
+
+/*=======================================================================*\
+ Function: file_name
+ Purpose: map url to location in cache
+ Input: url from wich the rss file was fetched
+ Output: a file name
+\*=======================================================================*/
+ function file_name ($url) {
+ return md5( $url );
+ }
+
+/*=======================================================================*\
+ Function: error
+ Purpose: register error
+\*=======================================================================*/
+ function error ($errormsg, $lvl=E_USER_WARNING) {
+ // append PHP's error message if track_errors enabled
+ if ( isset($php_errormsg) ) {
+ $errormsg .= " ($php_errormsg)";
+ }
+ $this->ERROR = $errormsg;
+ if ( MAGPIE_DEBUG ) {
+ trigger_error( $errormsg, $lvl);
+ }
+ else {
+ error_log( $errormsg, 0);
+ }
+ }
+ function debug ($debugmsg, $lvl=E_USER_NOTICE) {
+ if ( MAGPIE_DEBUG ) {
+ $this->error("MagpieRSS [debug] $debugmsg", $lvl);
+ }
+ }
+}
+
+function parse_w3cdtf ( $date_str ) {
+
+ # regex to match wc3dtf
+ $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
+
+ if ( preg_match( $pat, $date_str, $match ) ) {
+ list( $year, $month, $day, $hours, $minutes, $seconds) =
+ array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
+
+ # calc epoch for current date assuming GMT
+ $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
+
+ $offset = 0;
+ if ( $match[10] == 'Z' ) {
+ # zulu time, aka GMT
+ }
+ else {
+ list( $tz_mod, $tz_hour, $tz_min ) =
+ array( $match[8], $match[9], $match[10]);
+
+ # zero out the variables
+ if ( ! $tz_hour ) { $tz_hour = 0; }
+ if ( ! $tz_min ) { $tz_min = 0; }
+
+ $offset_secs = (($tz_hour*60)+$tz_min)*60;
+
+ # is timezone ahead of GMT? then subtract offset
+ #
+ if ( $tz_mod == '+' ) {
+ $offset_secs = $offset_secs * -1;
+ }
+
+ $offset = $offset_secs;
+ }
+ $epoch = $epoch + $offset;
+ return $epoch;
+ }
+ else {
+ return -1;
+ }
+ }
+function wp_rss ($url, $num) {
+ //ini_set("display_errors", false); uncomment to suppress php errors thrown if the feed is not returned.
+ $num_items = $num;
+ $rss = fetch_rss($url);
+ if ( $rss ) {
+ echo "<ul>";
+ $rss->items = array_slice($rss->items, 0, $num_items);
+ foreach ($rss->items as $item ) {
+ echo "<li>\n";
+ echo "<a href='$item[link]' title='$item[description]'>";
+ echo htmlentities($item['title']);
+ echo "</a><br />\n";
+ echo "</li>\n";
+ }
+ echo "</ul>";
+ }
+ else {
+ echo "an error has occured the feed is probably down, try again later.";
+ }
+}
+
+function get_rss ($uri, $num = 5) { // Like get posts, but for RSS
+ $rss = fetch_rss($url);
+ if ( $rss ) {
+ $rss->items = array_slice($rss->items, 0, $num_items);
+ foreach ($rss->items as $item ) {
+ echo "<li>\n";
+ echo "<a href='$item[link]' title='$item[description]'>";
+ echo htmlentities($item['title']);
+ echo "</a><br />\n";
+ echo "</li>\n";
+ }
+ return $posts;
+ } else {
+ return false;
+ }
+}
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/streams.php b/wp-inst/wp-includes/streams.php
new file mode 100644
index 0000000..c69841e
--- /dev/null
+++ b/wp-inst/wp-includes/streams.php
@@ -0,0 +1,159 @@
+<?php
+/*
+ Copyright (c) 2003, 2005 Danilo Segan <danilo@kvota.net>.
+
+ This file is part of PHP-gettext.
+
+ PHP-gettext is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ PHP-gettext is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with PHP-gettext; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+
+// Simple class to wrap file streams, string streams, etc.
+// seek is essential, and it should be byte stream
+class StreamReader {
+ // should return a string [FIXME: perhaps return array of bytes?]
+ function read($bytes) {
+ return false;
+ }
+
+ // should return new position
+ function seekto($position) {
+ return false;
+ }
+
+ // returns current position
+ function currentpos() {
+ return false;
+ }
+
+ // returns length of entire stream (limit for seekto()s)
+ function length() {
+ return false;
+ }
+}
+
+class StringReader {
+ var $_pos;
+ var $_str;
+
+ function StringReader($str='') {
+ $this->_str = $str;
+ $this->_pos = 0;
+ }
+
+ function read($bytes) {
+ $data = substr($this->_str, $this->_pos, $bytes);
+ $this->_pos += $bytes;
+ if (strlen($this->_str)<$this->_pos)
+ $this->_pos = strlen($this->_str);
+
+ return $data;
+ }
+
+ function seekto($pos) {
+ $this->_pos = $pos;
+ if (strlen($this->_str)<$this->_pos)
+ $this->_pos = strlen($this->_str);
+ return $this->_pos;
+ }
+
+ function currentpos() {
+ return $this->_pos;
+ }
+
+ function length() {
+ return strlen($this->_str);
+ }
+
+}
+
+
+class FileReader {
+ var $_pos;
+ var $_fd;
+ var $_length;
+
+ function FileReader($filename) {
+ if (file_exists($filename)) {
+
+ $this->_length=filesize($filename);
+ $this->_pos = 0;
+ $this->_fd = fopen($filename,'rb');
+ if (!$this->_fd) {
+ $this->error = 3; // Cannot read file, probably permissions
+ return false;
+ }
+ } else {
+ $this->error = 2; // File doesn't exist
+ return false;
+ }
+ }
+
+ function read($bytes) {
+ if ($bytes) {
+ fseek($this->_fd, $this->_pos);
+ $data = fread($this->_fd, $bytes);
+ $this->_pos = ftell($this->_fd);
+
+ return $data;
+ } else return '';
+ }
+
+ function seekto($pos) {
+ fseek($this->_fd, $pos);
+ $this->_pos = ftell($this->_fd);
+ return $this->_pos;
+ }
+
+ function currentpos() {
+ return $this->_pos;
+ }
+
+ function length() {
+ return $this->_length;
+ }
+
+ function close() {
+ fclose($this->_fd);
+ }
+
+}
+
+// Preloads entire file in memory first, then creates a StringReader
+// over it (it assumes knowledge of StringReader internals)
+class CachedFileReader extends StringReader {
+ function CachedFileReader($filename) {
+ if (file_exists($filename)) {
+
+ $length=filesize($filename);
+ $fd = fopen($filename,'rb');
+
+ if (!$fd) {
+ $this->error = 3; // Cannot read file, probably permissions
+ return false;
+ }
+ $this->_str = fread($fd, $length);
+ fclose($fd);
+
+ } else {
+ $this->error = 2; // File doesn't exist
+ return false;
+ }
+ }
+}
+
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/template-functions-author.php b/wp-inst/wp-includes/template-functions-author.php
new file mode 100644
index 0000000..86aaa48
--- /dev/null
+++ b/wp-inst/wp-includes/template-functions-author.php
@@ -0,0 +1,211 @@
+<?php
+
+function get_the_author($idmode = '') {
+ global $authordata;
+ return $authordata->display_name;
+}
+
+function the_author($idmode = '', $echo = true) {
+ if ($echo) echo get_the_author($idmode);
+ return get_the_author($idmode);
+}
+
+function get_the_author_description() {
+ global $authordata;
+ return $authordata->user_description;
+}
+function the_author_description() {
+ echo get_the_author_description();
+}
+
+function get_the_author_login() {
+ global $id,$authordata; return $authordata->user_login;
+}
+function the_author_login() {
+ echo get_the_author_login();
+}
+
+function get_the_author_firstname() {
+ global $id,$authordata; return $authordata->first_name;
+}
+function the_author_firstname() {
+ echo get_the_author_firstname();
+}
+
+function get_the_author_lastname() {
+ global $id,$authordata; return $authordata->last_name;
+}
+function the_author_lastname() {
+ echo get_the_author_lastname();
+}
+
+function get_the_author_nickname() {
+ global $id,$authordata; return $authordata->nickname;
+}
+function the_author_nickname() {
+ echo get_the_author_nickname();
+}
+
+function get_the_author_ID() {
+ global $id,$authordata; return $authordata->ID;
+}
+function the_author_ID() {
+ echo get_the_author_id();
+}
+
+function get_the_author_email() {
+ global $authordata;
+ return $authordata->user_email;
+}
+
+function the_author_email() {
+ echo apply_filters('the_author_email', get_the_author_email() );
+}
+
+function get_the_author_url() {
+ global $id,$authordata; return $authordata->user_url;
+}
+function the_author_url() {
+ echo get_the_author_url();
+}
+
+function get_the_author_icq() {
+ global $id,$authordata; return $authordata->icq;
+}
+function the_author_icq() {
+ echo get_the_author_icq();
+}
+
+function get_the_author_aim() {
+ global $id,$authordata; return str_replace(' ', '+', $authordata->aim);
+}
+function the_author_aim() {
+ echo get_the_author_aim();
+}
+
+function get_the_author_yim() {
+ global $id,$authordata; return $authordata->yim;
+}
+function the_author_yim() {
+ echo get_the_author_yim();
+}
+
+function get_the_author_msn() {
+ global $id,$authordata; return $authordata->msn;
+}
+function the_author_msn() {
+ echo get_the_author_msn();
+}
+
+function get_the_author_posts() {
+ global $id,$post;
+ $posts=get_usernumposts($post->post_author);
+ return $posts;
+}
+function the_author_posts() {
+ echo get_the_author_posts();
+}
+
+/* the_author_posts_link() requires no get_, use get_author_link() */
+function the_author_posts_link($idmode='') {
+ global $id, $authordata;
+
+ echo '<a href="' . get_author_link(0, $authordata->ID, $authordata->user_nicename) . '" title="' . sprintf(__("Posts by %s"), wp_specialchars(the_author($idmode, false))) . '">' . the_author($idmode, false) . '</a>';
+}
+
+
+function get_author_link($echo = false, $author_id, $author_nicename) {
+ global $wpdb, $wp_rewrite, $post, $cache_userdata;
+ $auth_ID = $author_id;
+ $link = $wp_rewrite->get_author_permastruct();
+
+ if (empty($link)) {
+ $file = get_settings('home') . '/';
+ $link = $file . '?author=' . $auth_ID;
+ } else {
+ if ('' == $author_nicename) $author_nicename = $cache_userdata[$author_id]->user_nicename;
+ $link = str_replace('%author%', $author_nicename, $link);
+ $link = get_settings('home') . trailingslashit($link);
+ }
+
+ $link = apply_filters('author_link', $link, $author_id, $author_nicename);
+ if ($echo) echo $link;
+ return $link;
+}
+
+function wp_list_authors($args = '') {
+ parse_str($args, $r);
+ if (!isset($r['optioncount'])) $r['optioncount'] = false;
+ if (!isset($r['exclude_admin'])) $r['exclude_admin'] = true;
+ if (!isset($r['show_fullname'])) $r['show_fullname'] = false;
+ if (!isset($r['hide_empty'])) $r['hide_empty'] = true;
+ if (!isset($r['feed'])) $r['feed'] = '';
+ if (!isset($r['feed_image'])) $r['feed_image'] = '';
+
+ list_authors($r['optioncount'], $r['exclude_admin'], $r['show_fullname'], $r['hide_empty'], $r['feed'], $r['feed_image']);
+}
+
+function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
+ global $wpdb;
+
+ $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name";
+ $authors = $wpdb->get_results($query);
+
+ foreach($authors as $author) {
+ $author = get_userdata( $author->ID );
+ $posts = get_usernumposts($author->ID);
+ $name = $author->nickname;
+
+ if ($show_fullname && ($author->first_name != '' && $author->last_name != '')) {
+ $name = "$author->first_name $author->last_name";
+ }
+
+ if (! ($posts == 0 && $hide_empty)) echo "<li>";
+ if ($posts == 0) {
+ if ( !$hide_empty )
+ $link = $name;
+ } else {
+ $link = '<a href="' . get_author_link(0, $author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), wp_specialchars($author->display_name)) . '">' . $name . '</a>';
+
+ if ( (! empty($feed_image)) || (! empty($feed)) ) {
+
+ $link .= ' ';
+
+ if (empty($feed_image)) {
+ $link .= '(';
+ }
+
+ $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';
+
+ if (! empty($feed)) {
+ $title = ' title="' . $feed . '"';
+ $alt = ' alt="' . $feed . '"';
+ $name = $feed;
+ $link .= $title;
+ }
+
+ $link .= '>';
+
+ if (! empty($feed_image)) {
+ $link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />';
+ } else {
+ $link .= $name;
+ }
+
+ $link .= '</a>';
+
+ if (empty($feed_image)) {
+ $link .= ')';
+ }
+ }
+
+ if ($optioncount) {
+ $link .= ' ('. $posts . ')';
+ }
+ }
+
+ if (! ($posts == 0 && $hide_empty)) echo "$link</li>";
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/template-functions-category.php b/wp-inst/wp-includes/template-functions-category.php
new file mode 100644
index 0000000..d1d4fb8
--- /dev/null
+++ b/wp-inst/wp-includes/template-functions-category.php
@@ -0,0 +1,402 @@
+<?php
+
+function get_the_category($id = false) {
+ global $post, $category_cache;
+
+ if ( !$id )
+ $id = $post->ID;
+
+ if ( ! isset($category_cache[$id]) )
+ update_post_category_cache($id);
+
+ $categories = $category_cache[$id];
+
+ if (!empty($categories))
+ sort($categories);
+ else
+ $categories = array();
+
+ return $categories;
+}
+
+function get_category_link($category_id) {
+ global $wp_rewrite;
+ $catlink = $wp_rewrite->get_category_permastruct();
+
+ if ( empty($catlink) ) {
+ $file = get_settings('home') . '/' . get_settings('blogfilename');
+ $catlink = $file . '?cat=' . $category_id;
+ } else {
+ $category = &get_category($category_id);
+ $category_nicename = $category->category_nicename;
+
+ if ($parent = $category->category_parent)
+ $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/';
+
+ $catlink = str_replace('%category%', $category_nicename, $catlink);
+ $catlink = get_settings('home') . trailingslashit($catlink);
+ }
+ return apply_filters('category_link', $catlink, $category_id);
+}
+
+function get_the_category_list($separator = '', $parents='') {
+ $categories = get_the_category();
+ if (empty($categories)) {
+ return apply_filters('the_category', __('Uncategorized'), $separator, $parents);
+ }
+
+ $thelist = '';
+ if ('' == $separator) {
+ $thelist .= '<ul class="post-categories">';
+ foreach ($categories as $category) {
+ $category->cat_name = $category->cat_name;
+ $thelist .= "\n\t<li>";
+ switch(strtolower($parents)) {
+ case 'multiple':
+ if ($category->category_parent) {
+ $thelist .= get_category_parents($category->category_parent, TRUE);
+ }
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';
+ break;
+ case 'single':
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . ' rel="category tag">';
+ if ($category->category_parent) {
+ $thelist .= get_category_parents($category->category_parent, FALSE);
+ }
+ $thelist .= $category->cat_name.'</a></li>';
+ break;
+ case '':
+ default:
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';
+ }
+ }
+ $thelist .= '</ul>';
+ } else {
+ $i = 0;
+ foreach ($categories as $category) {
+ $category->cat_name = $category->cat_name;
+ if (0 < $i) $thelist .= $separator . ' ';
+ switch(strtolower($parents)) {
+ case 'multiple':
+ if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, TRUE);
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';
+ break;
+ case 'single':
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">';
+ if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, FALSE);
+ $thelist .= "$category->cat_name</a>";
+ break;
+ case '':
+ default:
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';
+ }
+ ++$i;
+ }
+ }
+ return apply_filters('the_category', $thelist, $separator, $parents);
+}
+
+function the_category($separator = '', $parents='') {
+ echo get_the_category_list($separator, $parents);
+}
+
+function get_the_category_by_ID($cat_ID) {
+ $cat_ID = (int) $cat_ID;
+ $category = &get_category($cat_ID);
+ return $category->cat_name;
+}
+
+function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
+ $chain = '';
+ $parent = &get_category($id);
+ if ($nicename) {
+ $name = $parent->category_nicename;
+ } else {
+ $name = $parent->cat_name;
+ }
+ if ($parent->category_parent) $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename);
+ if ($link) {
+ $chain .= '<a href="' . get_category_link($parent->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator;
+ } else {
+ $chain .= $name.$separator;
+ }
+ return $chain;
+}
+
+function get_category_children($id, $before = '/', $after = '') {
+ global $cache_categories;
+
+ if ( ! isset($cache_categories))
+ update_category_cache();
+
+ $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy
+ $chain = '';
+ foreach ($c_cache as $category){
+ if ($category->category_parent == $id){
+ $chain .= $before.$category->cat_ID.$after;
+ $chain .= get_category_children($category->cat_ID, $before, $after);
+ }
+ }
+ return $chain;
+}
+
+// Deprecated.
+function the_category_ID($echo = true) {
+ // Grab the first cat in the list.
+ $categories = get_the_category();
+ $cat = $categories[0]->cat_ID;
+
+ if ($echo) echo $cat;
+
+ return $cat;
+}
+
+// Deprecated.
+function the_category_head($before='', $after='') {
+ global $currentcat, $previouscat;
+ // Grab the first cat in the list.
+ $categories = get_the_category();
+ $currentcat = $categories[0]->category_id;
+ if ($currentcat != $previouscat) {
+ echo $before;
+ echo get_the_category_by_ID($currentcat);
+ echo $after;
+ $previouscat = $currentcat;
+ }
+}
+
+function category_description($category = 0) {
+ global $cat;
+ if (!$category) $category = $cat;
+ $category = & get_category($category);
+ return apply_filters('category_description', $category->category_description, $category->cat_ID);
+}
+
+// out of the WordPress loop
+function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc',
+ $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE,
+ $selected=0, $hide=0) {
+ global $wpdb;
+ if (($file == 'blah') || ($file == '')) $file = get_settings('home') . '/';
+ if (!$selected) $selected=$cat;
+ $sort_column = 'cat_'.$sort_column;
+
+ $query = "
+ SELECT cat_ID, cat_name, category_nicename,category_parent,
+ COUNT($wpdb->post2cat.post_id) AS cat_count,
+ DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
+ FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id)
+ LEFT JOIN $wpdb->posts ON (ID = post_id)
+ WHERE cat_ID > 0
+ ";
+ if ($hide) {
+ $query .= " AND cat_ID != $hide";
+ $query .= get_category_children($hide, " AND cat_ID != ");
+ }
+ $query .=" GROUP BY cat_ID";
+ if (intval($hide_empty) == 1) $query .= " HAVING cat_count > 0";
+ $query .= " ORDER BY $sort_column $sort_order, post_date DESC";
+
+ $categories = $wpdb->get_results($query);
+ echo "<select name='cat' class='postform'>\n";
+ if (intval($optionall) == 1) {
+ $all = apply_filters('list_cats', $all);
+ echo "\t<option value='0'>$all</option>\n";
+ }
+ if (intval($optionnone) == 1) echo "\t<option value='-1'>".__('None')."</option>\n";
+ if ($categories) {
+ foreach ($categories as $category) {
+ $cat_name = apply_filters('list_cats', $category->cat_name, $category);
+ echo "\t<option value=\"".$category->cat_ID."\"";
+ if ($category->cat_ID == $selected)
+ echo ' selected="selected"';
+ echo '>';
+ echo $cat_name;
+ if (intval($optioncount) == 1) echo '&nbsp;&nbsp;('.$category->cat_count.')';
+ if (intval($optiondates) == 1) echo '&nbsp;&nbsp;'.$category->lastday.'/'.$category->lastmonth;
+ echo "</option>\n";
+ }
+ }
+ echo "</select>\n";
+}
+
+// out of the WordPress loop
+function wp_list_cats($args = '') {
+ parse_str($args, $r);
+ if (!isset($r['optionall'])) $r['optionall'] = 0;
+ if (!isset($r['all'])) $r['all'] = 'All';
+ if (!isset($r['sort_column'])) $r['sort_column'] = 'ID';
+ if (!isset($r['sort_order'])) $r['sort_order'] = 'asc';
+ if (!isset($r['file'])) $r['file'] = '';
+ if (!isset($r['list'])) $r['list'] = true;
+ if (!isset($r['optiondates'])) $r['optiondates'] = 0;
+ if (!isset($r['optioncount'])) $r['optioncount'] = 0;
+ if (!isset($r['hide_empty'])) $r['hide_empty'] = 1;
+ if (!isset($r['use_desc_for_title'])) $r['use_desc_for_title'] = 1;
+ if (!isset($r['children'])) $r['children'] = true;
+ if (!isset($r['child_of'])) $r['child_of'] = 0;
+ if (!isset($r['categories'])) $r['categories'] = 0;
+ if (!isset($r['recurse'])) $r['recurse'] = 0;
+ if (!isset($r['feed'])) $r['feed'] = '';
+ if (!isset($r['feed_image'])) $r['feed_image'] = '';
+ if (!isset($r['exclude'])) $r['exclude'] = '';
+ if (!isset($r['hierarchical'])) $r['hierarchical'] = true;
+
+ return list_cats($r['optionall'], $r['all'], $r['sort_column'], $r['sort_order'], $r['file'], $r['list'], $r['optiondates'], $r['optioncount'], $r['hide_empty'], $r['use_desc_for_title'], $r['children'], $r['child_of'], $r['categories'], $r['recurse'], $r['feed'], $r['feed_image'], $r['exclude'], $r['hierarchical']);
+}
+
+function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE) {
+ global $wpdb, $category_posts;
+ // Optiondates now works
+ if ('' == $file) {
+ $file = get_settings('home') . '/';
+ }
+
+ $exclusions = '';
+ if (!empty($exclude)) {
+ $excats = preg_split('/[\s,]+/',$exclude);
+ if (count($excats)) {
+ foreach ($excats as $excat) {
+ $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
+ }
+ }
+ }
+
+ if (intval($categories)==0){
+ $sort_column = 'cat_'.$sort_column;
+
+ $query = "
+ SELECT cat_ID, cat_name, category_nicename, category_description, category_parent
+ FROM $wpdb->categories
+ WHERE cat_ID > 0 $exclusions
+ ORDER BY $sort_column $sort_order";
+
+ $categories = $wpdb->get_results($query);
+ }
+ if (!count($category_posts)) {
+ $now = current_time('mysql', 1);
+ $cat_counts = $wpdb->get_results(" SELECT cat_ID,
+ COUNT($wpdb->post2cat.post_id) AS cat_count
+ FROM $wpdb->categories
+ INNER JOIN $wpdb->post2cat ON (cat_ID = category_id)
+ INNER JOIN $wpdb->posts ON (ID = post_id)
+ WHERE post_status = 'publish'
+ AND post_date_gmt < '$now' $exclusions
+ GROUP BY category_id");
+ if (! empty($cat_counts)) {
+ foreach ($cat_counts as $cat_count) {
+ if (1 != intval($hide_empty) || $cat_count > 0) {
+ $category_posts["$cat_count->cat_ID"] = $cat_count->cat_count;
+ }
+ }
+ }
+ }
+
+ if ( $optiondates ) {
+ $cat_dates = $wpdb->get_results(" SELECT category_id,
+ UNIX_TIMESTAMP( MAX(post_date) ) AS ts
+ FROM $wpdb->posts, $wpdb->post2cat
+ WHERE post_status = 'publish' AND post_id = ID $exclusions
+ GROUP BY category_id");
+ foreach ($cat_dates as $cat_date) {
+ $category_timestamp["$cat_date->category_id"] = $cat_date->ts;
+ }
+ }
+
+ $num_found=0;
+ $thelist = "";
+
+ foreach ($categories as $category) {
+ if ((intval($hide_empty) == 0 || isset($category_posts["$category->cat_ID"])) && (!$hierarchical || $category->category_parent == $child_of) ) {
+ $num_found++;
+ $link = '<a href="'.get_category_link($category->cat_ID).'" ';
+ if ($use_desc_for_title == 0 || empty($category->category_description)) {
+ $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"';
+ } else {
+ $link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category)) . '"';
+ }
+ $link .= '>';
+ $link .= apply_filters('list_cats', $category->cat_name, $category).'</a>';
+
+ if ( (! empty($feed_image)) || (! empty($feed)) ) {
+
+ $link .= ' ';
+
+ if (empty($feed_image)) {
+ $link .= '(';
+ }
+
+ $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
+
+ if ( !empty($feed) ) {
+ $title = ' title="' . $feed . '"';
+ $alt = ' alt="' . $feed . '"';
+ $name = $feed;
+ $link .= $title;
+ }
+
+ $link .= '>';
+
+ if (! empty($feed_image)) {
+ $link .= "<img src='$feed_image' $alt$title" . ' />';
+ } else {
+ $link .= $name;
+ }
+
+ $link .= '</a>';
+
+ if (empty($feed_image)) {
+ $link .= ')';
+ }
+ }
+
+ if (intval($optioncount) == 1) {
+ $link .= ' ('.intval($category_posts["$category->cat_ID"]).')';
+ }
+ if ( $optiondates ) {
+ if ( $optiondates == 1 ) $optiondates = 'Y-m-d';
+ $link .= ' ' . gmdate($optiondates, $category_timestamp["$category->cat_ID"]);
+ }
+ if ($list) {
+ $thelist .= "\t<li>$link\n";
+ } else {
+ $thelist .= "\t$link<br />\n";
+ }
+ if ($hierarchical && $children) $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categories, 1, $feed, $feed_image, $exclude, $hierarchical);
+ if ($list) $thelist .= "</li>\n";
+ }
+ }
+ if (!$num_found && !$child_of){
+ if ($list) {
+ $before = '<li>';
+ $after = '</li>';
+ }
+ echo $before . __("No categories") . $after . "\n";
+ return;
+ }
+ if ($list && $child_of && $num_found && $recurse) {
+ $pre = "\t\t<ul class='children'>";
+ $post = "\t\t</ul>\n";
+ } else {
+ $pre = $post = '';
+ }
+ $thelist = $pre . $thelist . $post;
+ if ($recurse) {
+ return $thelist;
+ }
+ echo apply_filters('list_cats', $thelist);
+}
+
+function in_category($category) { // Check if the current post is in the given category
+ global $post, $category_cache;
+ $cats = '';
+ foreach ($category_cache[$post->ID] as $cat) :
+ $cats[] = $cat->cat_ID;
+ endforeach;
+
+ if ( in_array($category, $cats) )
+ return true;
+ else
+ return false;
+}
+?>
diff --git a/wp-inst/wp-includes/template-functions-general.php b/wp-inst/wp-includes/template-functions-general.php
new file mode 100644
index 0000000..340dc57
--- /dev/null
+++ b/wp-inst/wp-includes/template-functions-general.php
@@ -0,0 +1,644 @@
+<?php
+
+/* Note: these tags go anywhere in the template */
+
+function get_header() {
+ if ( file_exists( TEMPLATEPATH . '/header.php') )
+ load_template( TEMPLATEPATH . '/header.php');
+ else
+ load_template( ABSPATH . 'wp-content/themes/default/header.php');
+}
+
+function get_footer() {
+ if ( file_exists( TEMPLATEPATH . '/footer.php') )
+ load_template( TEMPLATEPATH . '/footer.php');
+ else
+ load_template( ABSPATH . 'wp-content/themes/default/footer.php');
+}
+
+function get_sidebar() {
+ if ( file_exists( TEMPLATEPATH . '/sidebar.php') )
+ load_template( TEMPLATEPATH . '/sidebar.php');
+ else
+ load_template( ABSPATH . 'wp-content/themes/default/sidebar.php');
+}
+
+
+function wp_loginout() {
+ global $user_ID;
+ get_currentuserinfo();
+
+ if ('' == $user_ID) :
+ $link = '<a href="' . get_settings('siteurl') . '/wp-login.php">' . __('Login') . '</a>';
+ else :
+ $link = '<a href="' . get_settings('siteurl') . '/wp-login.php?action=logout">' . __('Logout') . '</a>';
+ endif;
+
+ echo apply_filters('loginout', $link);
+}
+
+function wp_register( $before = '<li>', $after = '</li>' ) {
+ global $user_ID;
+
+ get_currentuserinfo();
+
+ if ('' == $user_ID && get_settings('users_can_register') ) :
+ $link = $before . '<a href="' . get_settings('siteurl') . '/wp-register.php">' . __('Register') . '</a>' . $after;
+ elseif ('' == $user_ID && !get_settings('users_can_register') ) :
+ $link = '';
+ else :
+ $link = $before . '<a href="' . get_settings('siteurl') . '/wp-admin/">' . __('Site Admin') . '</a>' . $after;
+ endif;
+
+ echo apply_filters('register', $link);
+}
+
+function wp_meta() {
+ do_action('wp_meta');
+}
+
+function bloginfo($show='') {
+ $info = get_bloginfo($show);
+ $info = apply_filters('bloginfo', $info, $show);
+ echo convert_chars($info);
+}
+
+function get_bloginfo($show='') {
+
+ switch($show) {
+ case 'url' :
+ case 'home' :
+ case 'siteurl' :
+ $output = get_settings('home');
+ break;
+ case 'wpurl' :
+ $output = get_settings('siteurl');
+ break;
+ case 'description':
+ $output = get_settings('blogdescription');
+ break;
+ case 'rdf_url':
+ $output = get_feed_link('rdf');
+ break;
+ case 'rss_url':
+ $output = get_feed_link('rss');
+ break;
+ case 'rss2_url':
+ $output = get_feed_link('rss2');
+ break;
+ case 'atom_url':
+ $output = get_feed_link('atom');
+ break;
+ case 'comments_rss2_url':
+ $output = get_feed_link('comments_rss2');
+ break;
+ case 'pingback_url':
+ $output = get_settings('siteurl') .'/xmlrpc.php';
+ break;
+ case 'stylesheet_url':
+ $output = get_stylesheet_uri();
+ break;
+ case 'stylesheet_directory':
+ $output = get_stylesheet_directory_uri();
+ break;
+ case 'template_directory':
+ case 'template_url':
+ $output = get_template_directory_uri();
+ break;
+ case 'admin_email':
+ $output = get_settings('admin_email');
+ break;
+ case 'charset':
+ $output = get_settings('blog_charset');
+ if ('' == $output) $output = 'UTF-8';
+ break;
+ case 'html_type' :
+ $output = get_option('html_type');
+ break;
+ case 'version':
+ global $wp_version;
+ $output = $wp_version;
+ break;
+ case 'name':
+ default:
+ $output = get_settings('blogname');
+ break;
+ }
+ return $output;
+}
+
+function wp_title($sep = '&raquo;', $display = true) {
+ global $wpdb;
+ global $m, $year, $monthnum, $day, $category_name, $month, $posts;
+
+ $cat = get_query_var('cat');
+ $p = get_query_var('p');
+ $name = get_query_var('name');
+ $category_name = get_query_var('category_name');
+
+ // If there's a category
+ if(!empty($cat)) {
+ if (!stristr($cat,'-')) { // category excluded
+ $title = get_the_category_by_ID($cat);
+ }
+ }
+ if (!empty($category_name)) {
+ if (stristr($category_name,'/')) {
+ $category_name = explode('/',$category_name);
+ if ($category_name[count($category_name)-1]) {
+ $category_name = $category_name[count($category_name)-1]; // no trailing slash
+ } else {
+ $category_name = $category_name[count($category_name)-2]; // there was a trailling slash
+ }
+ }
+ $title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'");
+ }
+
+ // If there's a month
+ if(!empty($m)) {
+ $my_year = substr($m, 0, 4);
+ $my_month = $month[substr($m, 4, 2)];
+ $title = "$my_year $sep $my_month";
+
+ }
+ if (!empty($year)) {
+ $title = $year;
+ if (!empty($monthnum)) {
+ $title .= " $sep ".$month[zeroise($monthnum, 2)];
+ }
+ if (!empty($day)) {
+ $title .= " $sep ".zeroise($day, 2);
+ }
+ }
+
+ // If there's a post
+ if (is_single() || is_page()) {
+ $title = strip_tags($posts[0]->post_title);
+ $title = apply_filters('single_post_title', $title);
+ }
+
+ // Send it out
+ if ($display && isset($title)) {
+ echo " $sep $title";
+ } elseif (!$display && isset($title)) {
+ return " $sep $title";
+ }
+}
+
+function single_post_title($prefix = '', $display = true) {
+ global $wpdb;
+ $p = get_query_var('p');
+ $name = get_query_var('name');
+ if (intval($p) || '' != $name) {
+ if (!$p) {
+ $p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$name'");
+ }
+ $post = & get_post($p);
+ $title = $post->post_title;
+ $title = apply_filters('single_post_title', $title);
+ if ($display) {
+ echo $prefix.strip_tags($title);
+ } else {
+ return strip_tags($title);
+ }
+ }
+}
+
+function single_cat_title($prefix = '', $display = true ) {
+ $cat = intval( get_query_var('cat') );
+ if( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
+ $my_cat_name = get_the_category_by_ID($cat);
+ if( !empty($my_cat_name) ) {
+ if ($display)
+ echo $prefix.strip_tags($my_cat_name);
+ else
+ return strip_tags($my_cat_name);
+ }
+ }
+}
+
+function single_month_title($prefix = '', $display = true ) {
+ global $m, $monthnum, $month, $year;
+ if(!empty($monthnum) && !empty($year)) {
+ $my_year = $year;
+ $my_month = $month[str_pad($monthnum, 2, '0', STR_PAD_LEFT)];
+ } elseif(!empty($m)) {
+ $my_year = substr($m, 0, 4);
+ $my_month = $month[substr($m, 4, 2)];
+ }
+
+ if (!empty($my_month) && $display) {
+ echo $prefix . $my_month . $prefix . $my_year;
+ } else {
+ return $monthnum;
+ }
+}
+
+/* link navigation hack by Orien http://icecode.com/ */
+function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
+ $text = wptexturize($text);
+ $title_text = wp_specialchars($text, 1);
+
+ if ('link' == $format) {
+ return "\t<link rel='archives' title='$title_text' href='$url' />\n";
+ } elseif ('option' == $format) {
+ return "\t<option value='$url'>$before $text $after</option>\n";
+ } elseif ('html' == $format) {
+ return "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";
+ } else { // custom
+ return "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";
+ }
+}
+
+function wp_get_archives($args = '') {
+ parse_str($args, $r);
+ if (!isset($r['type'])) $r['type'] = '';
+ if (!isset($r['limit'])) $r['limit'] = '';
+ if (!isset($r['format'])) $r['format'] = 'html';
+ if (!isset($r['before'])) $r['before'] = '';
+ if (!isset($r['after'])) $r['after'] = '';
+ if (!isset($r['show_post_count'])) $r['show_post_count'] = false;
+ get_archives($r['type'], $r['limit'], $r['format'], $r['before'], $r['after'], $r['show_post_count']);
+}
+
+function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
+ global $month, $wpdb;
+
+ if ('' == $type) {
+ $type = 'monthly';
+ }
+
+ if ('' != $limit) {
+ $limit = (int) $limit;
+ $limit = ' LIMIT '.$limit;
+ }
+ // this is what will separate dates on weekly archive links
+ $archive_week_separator = '&#8211;';
+
+ // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
+ $archive_date_format_over_ride = 0;
+
+ // options for daily archive (only if you over-ride the general date format)
+ $archive_day_date_format = 'Y/m/d';
+
+ // options for weekly archive (only if you over-ride the general date format)
+ $archive_week_start_date_format = 'Y/m/d';
+ $archive_week_end_date_format = 'Y/m/d';
+
+ if (!$archive_date_format_over_ride) {
+ $archive_day_date_format = get_settings('date_format');
+ $archive_week_start_date_format = get_settings('date_format');
+ $archive_week_end_date_format = get_settings('date_format');
+ }
+
+ $add_hours = intval(get_settings('gmt_offset'));
+ $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
+
+ $now = current_time('mysql');
+
+ if ('monthly' == $type) {
+ $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
+ if ($arcresults) {
+ $afterafter = $after;
+ foreach ($arcresults as $arcresult) {
+ $url = get_month_link($arcresult->year, $arcresult->month);
+ if ($show_post_count) {
+ $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
+ $after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
+ } else {
+ $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
+ }
+ echo get_archives_link($url, $text, $format, $before, $after);
+ }
+ }
+ } elseif ('daily' == $type) {
+ $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
+ if ($arcresults) {
+ foreach ($arcresults as $arcresult) {
+ $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
+ $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
+ $text = mysql2date($archive_day_date_format, $date);
+ echo get_archives_link($url, $text, $format, $before, $after);
+ }
+ }
+ } elseif ('weekly' == $type) {
+ $start_of_week = get_settings('start_of_week');
+ $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
+ $arc_w_last = '';
+ if ($arcresults) {
+ foreach ($arcresults as $arcresult) {
+ if ($arcresult->week != $arc_w_last) {
+ $arc_year = $arcresult->yr;
+ $arc_w_last = $arcresult->week;
+ $arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week'));
+ $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
+ $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
+ $url = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('home'), '', '?',
+ '=', $arc_year, '&amp;',
+ '=', $arcresult->week);
+ $text = $arc_week_start . $archive_week_separator . $arc_week_end;
+ echo get_archives_link($url, $text, $format, $before, $after);
+ }
+ }
+ }
+ } elseif ('postbypost' == $type) {
+ $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
+ if ($arcresults) {
+ foreach ($arcresults as $arcresult) {
+ if ($arcresult->post_date != '0000-00-00 00:00:00') {
+ $url = get_permalink($arcresult);
+ $arc_title = $arcresult->post_title;
+ if ($arc_title) {
+ $text = strip_tags($arc_title);
+ } else {
+ $text = $arcresult->ID;
+ }
+ echo get_archives_link($url, $text, $format, $before, $after);
+ }
+ }
+ }
+ }
+}
+
+// Used in get_calendar
+function calendar_week_mod($num) {
+ $base = 7;
+ return ($num - $base*floor($num/$base));
+}
+
+function get_calendar($daylength = 1) {
+ global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;
+
+ // Quick check. If we have no posts at all, abort!
+ if (!$posts) {
+ $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
+ if (!$gotsome)
+ return;
+ }
+
+ if (isset($_GET['w'])) {
+ $w = ''.intval($_GET['w']);
+ }
+
+ // week_begins = 0 stands for sunday
+ $week_begins = intval(get_settings('start_of_week'));
+ $add_hours = intval(get_settings('gmt_offset'));
+ $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
+
+ // Let's figure out when we are
+ if (!empty($monthnum) && !empty($year)) {
+ $thismonth = ''.zeroise(intval($monthnum), 2);
+ $thisyear = ''.intval($year);
+ } elseif (!empty($w)) {
+ // We need to get the month from MySQL
+ $thisyear = ''.intval(substr($m, 0, 4));
+ $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
+ $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
+ } elseif (!empty($m)) {
+ $calendar = substr($m, 0, 6);
+ $thisyear = ''.intval(substr($m, 0, 4));
+ if (strlen($m) < 6) {
+ $thismonth = '01';
+ } else {
+ $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
+ }
+ } else {
+ $thisyear = gmdate('Y', current_time('timestamp') + get_settings('gmt_offset') * 3600);
+ $thismonth = gmdate('m', current_time('timestamp') + get_settings('gmt_offset') * 3600);
+ }
+
+ $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
+
+ // Get the next and previous month and year with at least one post
+ $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
+ FROM $wpdb->posts
+ WHERE post_date < '$thisyear-$thismonth-01'
+ AND post_status = 'publish'
+ ORDER BY post_date DESC
+ LIMIT 1");
+ $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
+ FROM $wpdb->posts
+ WHERE post_date > '$thisyear-$thismonth-01'
+ AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
+ AND post_status = 'publish'
+ ORDER BY post_date ASC
+ LIMIT 1");
+
+ echo '<table id="wp-calendar">
+ <caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>
+ <thead>
+ <tr>';
+
+ $day_abbrev = $weekday_initial;
+ if ($daylength > 1) {
+ $day_abbrev = $weekday_abbrev;
+ }
+
+ $myweek = array();
+
+ for ($wdcount=0; $wdcount<=6; $wdcount++) {
+ $myweek[]=$weekday[($wdcount+$week_begins)%7];
+ }
+
+ foreach ($myweek as $wd) {
+ echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $day_abbrev[$wd] . '</th>';
+ }
+
+ echo '
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr>';
+
+ if ($previous) {
+ echo "\n\t\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' .
+ get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($previous->month, 2)], date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $month_abbrev[$month[zeroise($previous->month, 2)]] . '</a></td>';
+ } else {
+ echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
+ }
+
+ echo "\n\t\t".'<td class="pad">&nbsp;</td>';
+
+ if ($next) {
+ echo "\n\t\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .
+ get_month_link($next->year, $next->month) . '" title="View posts for ' . $month[zeroise($next->month, 2)] . ' ' .
+ date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . $month_abbrev[$month[zeroise($next->month, 2)]] . ' &raquo;</a></td>';
+ } else {
+ echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
+ }
+
+ echo '
+ </tr>
+ </tfoot>
+
+ <tbody>
+ <tr>';
+
+ // Get days with posts
+ $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
+ FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
+ AND YEAR(post_date) = $thisyear
+ AND post_status = 'publish'
+ AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
+ if ($dayswithposts) {
+ foreach ($dayswithposts as $daywith) {
+ $daywithpost[] = $daywith[0];
+ }
+ } else {
+ $daywithpost = array();
+ }
+
+
+
+ if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') ||
+ strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') ||
+ strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari')) {
+ $ak_title_separator = "\n";
+ } else {
+ $ak_title_separator = ', ';
+ }
+
+ $ak_titles_for_day = array();
+ $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
+ ."FROM $wpdb->posts "
+ ."WHERE YEAR(post_date) = '$thisyear' "
+ ."AND MONTH(post_date) = '$thismonth' "
+ ."AND post_date < '".current_time('mysql')."' "
+ ."AND post_status = 'publish'"
+ );
+ if ($ak_post_titles) {
+ foreach ($ak_post_titles as $ak_post_title) {
+ if (empty($ak_titles_for_day['day_'.$ak_post_title->dom])) {
+ $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
+ }
+ if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one
+ $ak_titles_for_day["$ak_post_title->dom"] = str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
+ } else {
+ $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
+ }
+ }
+ }
+
+
+ // See how much we should pad in the beginning
+ $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
+ if (0 != $pad) echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>';
+
+ $daysinmonth = intval(date('t', $unixmonth));
+ for ($day = 1; $day <= $daysinmonth; ++$day) {
+ if (isset($newrow) && $newrow)
+ echo "\n\t</tr>\n\t<tr>\n\t\t";
+ $newrow = false;
+
+ if ($day == gmdate('j', (time() + (get_settings('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_settings('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_settings('gmt_offset') * 3600)))
+ echo '<td id="today">';
+ else
+ echo '<td>';
+
+ if (in_array($day, $daywithpost)) { // any posts today?
+ echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
+ } else {
+ echo $day;
+ }
+ echo '</td>';
+
+ if (6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins))
+ $newrow = true;
+ }
+
+ $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
+ if ($pad != 0 && $pad != 7)
+ echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
+
+ echo "\n\t</tr>\n\t</tbody>\n\t</table>";
+}
+
+function allowed_tags() {
+ global $allowedtags;
+ $allowed = '';
+ foreach($allowedtags as $tag => $attributes) {
+ $allowed .= '<'.$tag;
+ if (0 < count($attributes)) {
+ foreach ($attributes as $attribute => $limits) {
+ $allowed .= ' '.$attribute.'=""';
+ }
+ }
+ $allowed .= '> ';
+ }
+ return htmlentities($allowed);
+}
+
+/***** Date/Time tags *****/
+
+function the_date_xml() {
+ global $post;
+ echo mysql2date('Y-m-d', $post->post_date);
+ //echo ""+$post->post_date;
+}
+
+function the_date($d='', $before='', $after='', $echo = true) {
+ global $id, $post, $day, $previousday, $newday;
+ $the_date = '';
+ if ($day != $previousday) {
+ $the_date .= $before;
+ if ($d=='') {
+ $the_date .= mysql2date(get_settings('date_format'), $post->post_date);
+ } else {
+ $the_date .= mysql2date($d, $post->post_date);
+ }
+ $the_date .= $after;
+ $previousday = $day;
+ }
+ $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
+ if ($echo) {
+ echo $the_date;
+ } else {
+ return $the_date;
+ }
+}
+
+function the_time( $d = '' ) {
+ echo apply_filters('the_time', get_the_time( $d ), $d);
+}
+
+function get_the_time( $d = '' ) {
+ if ( '' == $d )
+ $the_time = get_post_time(get_settings('time_format'));
+ else
+ $the_time = get_post_time($d);
+ return apply_filters('get_the_time', $the_time, $d);
+}
+
+function get_post_time( $d = 'U', $gmt = false ) { // returns timestamp
+ global $post;
+ if ( $gmt )
+ $time = $post->post_date_gmt;
+ else
+ $time = $post->post_date;
+
+ $time = mysql2date($d, $time);
+ return apply_filters('get_the_time', $time, $d, $gmt);
+}
+
+function the_weekday() {
+ global $weekday, $id, $post;
+ $the_weekday = $weekday[mysql2date('w', $post->post_date)];
+ $the_weekday = apply_filters('the_weekday', $the_weekday);
+ echo $the_weekday;
+}
+
+function the_weekday_date($before='',$after='') {
+ global $weekday, $id, $post, $day, $previousweekday;
+ $the_weekday_date = '';
+ if ($day != $previousweekday) {
+ $the_weekday_date .= $before;
+ $the_weekday_date .= $weekday[mysql2date('w', $post->post_date)];
+ $the_weekday_date .= $after;
+ $previousweekday = $day;
+ }
+ $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after);
+ echo $the_weekday_date;
+}
+
+?>
diff --git a/wp-inst/wp-includes/template-functions-links.php b/wp-inst/wp-includes/template-functions-links.php
new file mode 100644
index 0000000..6e29a1f
--- /dev/null
+++ b/wp-inst/wp-includes/template-functions-links.php
@@ -0,0 +1,492 @@
+<?php
+
+function the_permalink() {
+ echo apply_filters('the_permalink', get_permalink());
+}
+
+function permalink_link() { // For backwards compatibility
+ echo apply_filters('the_permalink', get_permalink());
+}
+
+function permalink_anchor($mode = 'id') {
+ global $id, $post;
+ switch(strtolower($mode)) {
+ case 'title':
+ $title = sanitize_title($post->post_title) . '-' . $id;
+ echo '<a id="'.$title.'"></a>';
+ break;
+ case 'id':
+ default:
+ echo '<a id="post-'.$id.'"></a>';
+ break;
+ }
+}
+
+function get_permalink($id = 0) {
+ $rewritecode = array(
+ '%year%',
+ '%monthnum%',
+ '%day%',
+ '%hour%',
+ '%minute%',
+ '%second%',
+ '%postname%',
+ '%post_id%',
+ '%category%',
+ '%author%',
+ '%pagename%'
+ );
+
+ $post = & get_post($id);
+ if ($post->post_status == 'static') {
+ return get_page_link($post->ID);
+ }
+
+ $permalink = get_settings('permalink_structure');
+
+ if ('' != $permalink && 'draft' != $post->post_status) {
+ $unixtime = strtotime($post->post_date);
+
+ $category = '';
+ if (strstr($permalink, '%category%')) {
+ $cats = get_the_category($post->ID);
+ $category = $cats[0]->category_nicename;
+ if ($parent=$cats[0]->category_parent) $category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
+ }
+
+ $authordata = get_userdata($post->post_author);
+ $author = $authordata->user_nicename;
+ $rewritereplace =
+ array(
+ date('Y', $unixtime),
+ date('m', $unixtime),
+ date('d', $unixtime),
+ date('H', $unixtime),
+ date('i', $unixtime),
+ date('s', $unixtime),
+ $post->post_name,
+ $post->ID,
+ $category,
+ $author,
+ $post->post_name,
+ );
+ return apply_filters('post_link', get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post);
+ } else { // if they're not using the fancy permalink option
+ $permalink = get_settings('home') . '/?p=' . $post->ID;
+ return apply_filters('post_link', $permalink, $post);
+ }
+}
+
+function get_page_link($id = false) {
+ global $post, $wp_rewrite;
+
+ if (! $id) {
+ $id = $post->ID;
+ }
+
+ $pagestruct = $wp_rewrite->get_page_permastruct();
+
+ if ('' != $pagestruct) {
+ $link = get_page_uri($id);
+ $link = str_replace('%pagename%', $link, $pagestruct);
+ $link = get_settings('home') . "/$link/";
+ } else {
+ $link = get_settings('home') . "/?page_id=$id";
+ }
+
+ return apply_filters('page_link', $link, $id);
+}
+
+function get_year_link($year) {
+ global $wp_rewrite;
+ if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
+ $yearlink = $wp_rewrite->get_year_permastruct();
+ if (!empty($yearlink)) {
+ $yearlink = str_replace('%year%', $year, $yearlink);
+ return apply_filters('year_link', get_settings('home') . trailingslashit($yearlink), $year);
+ } else {
+ return apply_filters('year_link', get_settings('home') . '/?m=' . $year, $year);
+ }
+}
+
+function get_month_link($year, $month) {
+ global $wp_rewrite;
+ if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
+ if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
+ $monthlink = $wp_rewrite->get_month_permastruct();
+ if (!empty($monthlink)) {
+ $monthlink = str_replace('%year%', $year, $monthlink);
+ $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
+ return apply_filters('month_link', get_settings('home') . trailingslashit($monthlink), $year, $month);
+ } else {
+ return apply_filters('month_link', get_settings('home') . '/?m=' . $year . zeroise($month, 2), $year, $month);
+ }
+}
+
+function get_day_link($year, $month, $day) {
+ global $wp_rewrite;
+ if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
+ if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
+ if (!$day) $day = gmdate('j', time()+(get_settings('gmt_offset') * 3600));
+
+ $daylink = $wp_rewrite->get_day_permastruct();
+ if (!empty($daylink)) {
+ $daylink = str_replace('%year%', $year, $daylink);
+ $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
+ $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
+ return apply_filters('day_link', get_settings('home') . trailingslashit($daylink), $year, $month, $day);
+ } else {
+ return apply_filters('day_link', get_settings('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day);
+ }
+}
+
+function get_feed_link($feed='rss2') {
+ global $wp_rewrite;
+ $do_perma = 0;
+ $feed_url = get_settings('siteurl');
+ $comment_feed_url = $feed_url;
+
+ $permalink = $wp_rewrite->get_feed_permastruct();
+ if ('' != $permalink) {
+ if ( false !== strpos($feed, 'comments_') ) {
+ $feed = str_replace('comments_', '', $feed);
+ $permalink = $wp_rewrite->get_comment_feed_permastruct();
+ }
+
+ if ( 'rss2' == $feed )
+ $feed = '';
+
+ $permalink = str_replace('%feed%', $feed, $permalink);
+ $permalink = preg_replace('#/+#', '/', "/$permalink/");
+ $output = get_settings('home') . $permalink;
+ } else {
+ if ( false !== strpos($feed, 'comments_') )
+ $feed = str_replace('comments_', 'comments-', $feed);
+
+ $output = get_settings('home') . "/?feed={$feed}";
+ }
+
+ return apply_filters('feed_link', $output, $feed);
+}
+
+function edit_post_link($link = 'Edit This', $before = '', $after = '') {
+ global $user_ID, $post;
+
+ get_currentuserinfo();
+
+ if (!user_can_edit_post($user_ID, $post->ID)) {
+ return;
+ }
+
+ $location = get_settings('siteurl') . "/wp-admin/post.php?action=edit&amp;post=$post->ID";
+ echo "$before <a href=\"$location\">$link</a> $after";
+}
+
+function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
+ global $user_ID, $post, $comment;
+
+ get_currentuserinfo();
+
+ if (!user_can_edit_post_comments($user_ID, $post->ID)) {
+ return;
+ }
+
+ $location = get_settings('siteurl') . "/wp-admin/post.php?action=editcomment&amp;comment=$comment->comment_ID";
+ echo "$before <a href='$location'>$link</a> $after";
+}
+
+// Navigation links
+
+function get_previous_post($in_same_cat = false, $excluded_categories = '') {
+ global $post, $wpdb;
+
+ if(! is_single()) {
+ return null;
+ }
+
+ $current_post_date = $post->post_date;
+
+ $join = '';
+ if ($in_same_cat) {
+ $join = " INNER JOIN $wpdb->post2cat ON $wpdb->posts.ID= $wpdb->post2cat.post_id ";
+ $cat_array = get_the_category($post->ID);
+ $join .= ' AND (category_id = ' . intval($cat_array[0]->cat_ID);
+ for ($i = 1; $i < (count($cat_array)); $i++) {
+ $join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID);
+ }
+ $join .= ')';
+ }
+
+ $sql_exclude_cats = '';
+ if (!empty($excluded_categories)) {
+ $blah = explode('and', $excluded_categories);
+ foreach($blah as $category) {
+ $category = intval($category);
+ $sql_exclude_cats .= " AND post_category != $category";
+ }
+ }
+
+ return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT 1");
+}
+
+function get_next_post($in_same_cat = false, $excluded_categories = '') {
+ global $post, $wpdb;
+
+ if(! is_single()) {
+ return null;
+ }
+
+ $current_post_date = $post->post_date;
+
+ $join = '';
+ if ($in_same_cat) {
+ $join = " INNER JOIN $wpdb->post2cat ON $wpdb->posts.ID= $wpdb->post2cat.post_id ";
+ $cat_array = get_the_category($post->ID);
+ $join .= ' AND (category_id = ' . intval($cat_array[0]->cat_ID);
+ for ($i = 1; $i < (count($cat_array)); $i++) {
+ $join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID);
+ }
+ $join .= ')';
+ }
+
+ $sql_exclude_cats = '';
+ if (!empty($excluded_categories)) {
+ $blah = explode('and', $excluded_categories);
+ foreach($blah as $category) {
+ $category = intval($category);
+ $sql_exclude_cats .= " AND post_category != $category";
+ }
+ }
+
+ $now = current_time('mysql');
+
+ return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT 1");
+}
+
+function previous_post_link($format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
+ $post = get_previous_post($in_same_cat, $excluded_categories);
+
+ if(! $post) {
+ return;
+ }
+
+ $title = apply_filters('the_title', $post->post_title, $post);
+
+ $string = '<a href="'.get_permalink($post->ID).'">';
+
+ $link = str_replace('%title', $title, $link);
+
+ $link = $string . $link . '</a>';
+
+ $format = str_replace('%link', $link, $format);
+
+ echo $format;
+}
+
+function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '') {
+ $post = get_next_post($in_same_cat, $excluded_categories);
+
+ if(! $post) {
+ return;
+ }
+
+ $title = apply_filters('the_title', $post->post_title, $post);
+
+ $string = '<a href="'.get_permalink($post->ID).'">';
+
+ $link = str_replace('%title', $title, $link);
+
+ $link = $string . $link . '</a>';
+
+ $format = str_replace('%link', $link, $format);
+
+ echo $format;
+}
+
+// Deprecated. Use previous_post_link().
+function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
+
+ if ( empty($in_same_cat) || 'no' == $in_same_cat )
+ $in_same_cat = false;
+ else
+ $in_same_cat = true;
+
+ $post = get_previous_post($in_same_cat, $excluded_categories);
+
+ if(! $post) {
+ return;
+ }
+
+ $string = '<a href="'.get_permalink($post->ID).'">'.$previous;
+ if ($title == 'yes') {
+ $string .= apply_filters('the_title', $post->post_title, $post);
+ }
+ $string .= '</a>';
+ $format = str_replace('%', $string, $format);
+ echo $format;
+}
+
+// Deprecated. Use next_post_link().
+function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
+
+ if ( empty($in_same_cat) || 'no' == $in_same_cat )
+ $in_same_cat = false;
+ else
+ $in_same_cat = true;
+
+ $post = get_next_post($in_same_cat, $excluded_categories);
+
+ if(! $post) {
+ return;
+ }
+
+ $string = '<a href="'.get_permalink($post->ID).'">'.$next;
+ if ($title=='yes') {
+ $string .= apply_filters('the_title', $post->post_title, $nextpost);
+ }
+ $string .= '</a>';
+ $format = str_replace('%', $string, $format);
+ echo $format;
+}
+
+function get_pagenum_link($pagenum = 1) {
+ global $wp_rewrite;
+
+ $qstr = $_SERVER['REQUEST_URI'];
+
+ $page_querystring = "paged";
+ $page_modstring = "page/";
+ $page_modregex = "page/?";
+ $permalink = 0;
+
+ $home_root = parse_url(get_settings('home'));
+ $home_root = $home_root['path'];
+ $home_root = trailingslashit($home_root);
+ $qstr = preg_replace('|^'. $home_root . '|', '', $qstr);
+ $qstr = preg_replace('|^/+|', '', $qstr);
+
+ $index = $_SERVER['PHP_SELF'];
+ $index = preg_replace('|^'. $home_root . '|', '', $index);
+ $index = preg_replace('|^/+|', '', $index);
+
+ // if we already have a QUERY style page string
+ if( stristr( $qstr, $page_querystring ) ) {
+ $replacement = "$page_querystring=$pagenum";
+ $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr);
+ // if we already have a mod_rewrite style page string
+ } elseif ( preg_match( '|'.$page_modregex.'\d+|', $qstr ) ){
+ $permalink = 1;
+ $qstr = preg_replace('|'.$page_modregex.'\d+|',"$page_modstring$pagenum",$qstr);
+
+ // if we don't have a page string at all ...
+ // lets see what sort of URL we have...
+ } else {
+ // we need to know the way queries are being written
+ // if there's a querystring_start (a "?" usually), it's definitely not mod_rewritten
+ if ( stristr( $qstr, '?' ) ){
+ // so append the query string (using &, since we already have ?)
+ $qstr .= '&amp;' . $page_querystring . '=' . $pagenum;
+ // otherwise, it could be rewritten, OR just the default index ...
+ } elseif( '' != get_settings('permalink_structure') && ! is_admin()) {
+ $permalink = 1;
+ $index = $wp_rewrite->index;
+ // If it's not a path info permalink structure, trim the index.
+ if (! $wp_rewrite->using_index_permalinks()) {
+ $qstr = preg_replace("#/*" . $index . "/*#", '/', $qstr);
+ } else {
+ // If using path info style permalinks, make sure the index is in
+ // the URI.
+ if (strpos($qstr, $index) === false) {
+ $qstr = '/' . $index . $qstr;
+ }
+ }
+
+ $qstr = trailingslashit($qstr) . $page_modstring . $pagenum;
+ } else {
+ $qstr = $index . '?' . $page_querystring . '=' . $pagenum;
+ }
+ }
+
+ $qstr = preg_replace('|^/+|', '', $qstr);
+ if ($permalink) $qstr = trailingslashit($qstr);
+ return preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', trailingslashit( get_settings('home') ) . $qstr );
+}
+
+function next_posts($max_page = 0) { // original by cfactor at cooltux.org
+ global $paged, $pagenow;
+
+ if (! is_single()) {
+ if (!$paged) $paged = 1;
+ $nextpage = intval($paged) + 1;
+ if (!$max_page || $max_page >= $nextpage) {
+ echo get_pagenum_link($nextpage);
+ }
+ }
+}
+
+function next_posts_link($label='Next Page &raquo;', $max_page=0) {
+ global $paged, $result, $request, $posts_per_page, $wpdb, $max_num_pages;
+ if (!$max_page) {
+ if ( isset($max_num_pages) ) {
+ $max_page = $max_num_pages;
+ } else {
+ preg_match('#FROM (.*) GROUP BY#', $request, $matches);
+ $fromwhere = $matches[1];
+ $numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere");
+ $max_page = $max_num_pages = ceil($numposts / $posts_per_page);
+ }
+ }
+ if (!$paged)
+ $paged = 1;
+ $nextpage = intval($paged) + 1;
+ if ((! is_single()) && (empty($paged) || $nextpage <= $max_page)) {
+ echo '<a href="';
+ next_posts($max_page);
+ echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
+ }
+}
+
+
+function previous_posts() { // original by cfactor at cooltux.org
+ global $_SERVER, $paged, $pagenow;
+
+ if (! is_single()) {
+ $nextpage = intval($paged) - 1;
+ if ($nextpage < 1) $nextpage = 1;
+ echo get_pagenum_link($nextpage);
+ }
+}
+
+function previous_posts_link($label='&laquo; Previous Page') {
+ global $paged;
+ if ((! is_single()) && ($paged > 1) ) {
+ echo '<a href="';
+ previous_posts();
+ echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
+ }
+}
+
+function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;') {
+ global $request, $posts_per_page, $wpdb, $max_num_pages;
+ if (! is_single()) {
+
+ if (get_query_var('what_to_show') == 'posts') {
+ if ( ! isset($max_num_pages) ) {
+ preg_match('#FROM (.*) GROUP BY#', $request, $matches);
+ $fromwhere = $matches[1];
+ $numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere");
+ $max_num_pages = ceil($numposts / $posts_per_page);
+ }
+ } else {
+ $max_num_pages = 999999;
+ }
+
+ if ($max_num_pages > 1) {
+ previous_posts_link($prelabel);
+ echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $sep);
+ next_posts_link($nxtlabel, $max_page);
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/template-functions-post.php b/wp-inst/wp-includes/template-functions-post.php
new file mode 100644
index 0000000..88cc3ac
--- /dev/null
+++ b/wp-inst/wp-includes/template-functions-post.php
@@ -0,0 +1,414 @@
+<?php
+
+function get_the_password_form() {
+ $output = '<form action="' . get_settings('siteurl') . '/wp-pass.php" method="post">
+ <p>' . __("This post is password protected. To view it please enter your password below:") . '</p>
+ <p><label>' . __("Password:") . ' <input name="post_password" type="password" size="20" /></label> <input type="submit" name="Submit" value="Submit" /></p>
+ </form>
+ ';
+ return $output;
+}
+
+function the_ID() {
+ global $id;
+ echo $id;
+}
+
+function the_title($before = '', $after = '', $echo = true) {
+ $title = get_the_title();
+ if ( strlen($title) > 0 ) {
+ $title = apply_filters('the_title', $before . $title . $after, $before, $after);
+ if ($echo)
+ echo $title;
+ else
+ return $title;
+ }
+}
+
+function get_the_title($id = 0) {
+ $post = &get_post($id);
+
+ $title = $post->post_title;
+ if (!empty($post->post_password))
+ $title = sprintf(__('Protected: %s'), $title);
+
+ return $title;
+}
+
+function get_the_guid( $id = 0 ) {
+ $post = &get_post($id);
+
+ return apply_filters('get_the_guid', $post->guid);
+}
+
+function the_guid( $id = 0 ) {
+ echo get_the_guid($id);
+}
+
+
+function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
+ $content = get_the_content($more_link_text, $stripteaser, $more_file);
+ $content = apply_filters('the_content', $content);
+ $content = str_replace(']]>', ']]&gt;', $content);
+ echo $content;
+}
+
+function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
+ global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages;
+ global $preview;
+ global $pagenow;
+ $output = '';
+
+ if (!empty($post->post_password)) { // if there's a password
+ if (stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) { // and it doesn't match the cookie
+ $output = get_the_password_form();
+ return $output;
+ }
+ }
+
+ if ($more_file != '') {
+ $file = $more_file;
+ } else {
+ $file = $pagenow; //$_SERVER['PHP_SELF'];
+ }
+ $content = $pages[$page-1];
+ $content = explode('<!--more-->', $content, 2);
+ if ((preg_match('/<!--noteaser-->/', $post->post_content) && ((!$multipage) || ($page==1))))
+ $stripteaser = 1;
+ $teaser = $content[0];
+ if (($more) && ($stripteaser))
+ $teaser = '';
+ $output .= $teaser;
+ if (count($content)>1) {
+ if ($more) {
+ $output .= '<a id="more-'.$id.'"></a>'.$content[1];
+ } else {
+ $output .= ' <a href="'. get_permalink() . "#more-$id\">$more_link_text</a>";
+ }
+ }
+ if ($preview) { // preview fix for javascript bug with foreign languages
+ $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output);
+ }
+ return $output;
+}
+
+function the_excerpt() {
+ echo apply_filters('the_excerpt', get_the_excerpt());
+}
+
+function get_the_excerpt($fakeit = true) {
+ global $id, $post;
+ $output = '';
+ $output = $post->post_excerpt;
+ if (!empty($post->post_password)) { // if there's a password
+ if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
+ $output = __('There is no excerpt because this is a protected post.');
+ return $output;
+ }
+ }
+
+ return apply_filters('get_the_excerpt', $output);
+}
+
+function wp_link_pages($args = '') {
+ parse_str($args, $r);
+ if (!isset($r['before'])) $r['before'] = '<p>' . __('Pages:');
+ if (!isset($r['after'])) $r['after'] = '</p>';
+ if (!isset($r['next_or_number'])) $r['next_or_number'] = 'number';
+ if (!isset($r['nextpagelink'])) $r['nextpagelink'] = 'Next page';
+ if (!isset($r['previouspagelink'])) $r['previouspagelink'] = 'Previous page';
+ if (!isset($r['pagelink'])) $r['pagelink'] = '%';
+ if (!isset($r['more_file'])) $r['more_file'] = '';
+ link_pages($r['before'], $r['after'], $r['next_or_number'], $r['nextpagelink'], $r['previouspagelink'], $r['pagelink'], $r['more_file']);
+}
+
+function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') {
+ global $id, $page, $numpages, $multipage, $more;
+ global $pagenow;
+ if ($more_file != '') {
+ $file = $more_file;
+ } else {
+ $file = $pagenow;
+ }
+ if (($multipage)) {
+ if ($next_or_number=='number') {
+ echo $before;
+ for ($i = 1; $i < ($numpages+1); $i = $i + 1) {
+ $j=str_replace('%',"$i",$pagelink);
+ echo ' ';
+ if (($i != $page) || ((!$more) && ($page==1))) {
+ if ('' == get_settings('permalink_structure')) {
+ echo '<a href="' . get_permalink() . '&amp;page=' . $i . '">';
+ } else {
+ echo '<a href="' . trailingslashit( get_permalink() ) . $i . '/">';
+ }
+ }
+ echo $j;
+ if (($i != $page) || ((!$more) && ($page==1)))
+ echo '</a>';
+ }
+ echo $after;
+ } else {
+ if ($more) {
+ echo $before;
+ $i=$page-1;
+ if ($i && $more) {
+ if ('' == get_settings('permalink_structure')) {
+ echo '<a href="' . get_permalink() . '&amp;page=' . $i . '">'.$previouspagelink.'</a>';
+ } else {
+ echo '<a href="' . get_permalink() . $i . '/">'.$previouspagelink.'</a>';
+ }
+ }
+ $i=$page+1;
+ if ($i<=$numpages && $more) {
+ if ('' == get_settings('permalink_structure')) {
+ echo '<a href="'.get_permalink() . '&amp;page=' . $i . '">'.$nextpagelink.'</a>';
+ } else {
+ echo '<a href="'.get_permalink().$i.'/">'.$nextpagelink.'</a>';
+ }
+ }
+ echo $after;
+ }
+ }
+ }
+}
+
+/*
+ * Post-meta: Custom per-post fields.
+ */
+
+function get_post_custom( $post_id = 0 ) {
+ global $id, $post_meta_cache, $wpdb;
+ if ( $post_id )
+ $id = $post_id;
+ if ( isset($post_meta_cache[$id]) ) {
+ return $post_meta_cache[$id];
+ } else {
+ if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = '$id' ORDER BY post_id, meta_key", ARRAY_A) ) {
+
+ // Change from flat structure to hierarchical:
+ $post_meta_cache = array();
+ foreach ($meta_list as $metarow) {
+ $mpid = $metarow['post_id'];
+ $mkey = $metarow['meta_key'];
+ $mval = $metarow['meta_value'];
+
+ // Force subkeys to be array type:
+ if (!isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]))
+ $post_meta_cache[$mpid] = array();
+ if (!isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]))
+ $post_meta_cache[$mpid]["$mkey"] = array();
+
+ // Add a value to the current pid/key:
+ $post_meta_cache[$mpid][$mkey][] = $mval;
+ }
+ return $post_meta_cache[$mpid];
+ }
+ }
+}
+
+function get_post_custom_keys() {
+ global $id, $post_meta_cache;
+
+ if (!is_array($post_meta_cache[$id]))
+ return;
+ if ($keys = array_keys($post_meta_cache[$id]))
+ return $keys;
+}
+
+function get_post_custom_values($key='') {
+ global $id, $post_meta_cache;
+
+ return $post_meta_cache[$id][$key];
+}
+
+function post_custom( $key = '' ) {
+ global $id, $post_meta_cache;
+
+ if ( 1 == count($post_meta_cache[$id][$key]) ) return $post_meta_cache[$id][$key][0];
+ else return $post_meta_cache[$id][$key];
+}
+
+// this will probably change at some point...
+function the_meta() {
+ global $id, $post_meta_cache;
+
+ if ($keys = get_post_custom_keys()) {
+ echo "<ul class='post-meta'>\n";
+ foreach ($keys as $key) {
+ $values = array_map('trim',$post_meta_cache[$id][$key]);
+ $value = implode($values,', ');
+
+ echo "<li><span class='post-meta-key'>$key:</span> $value</li>\n";
+ }
+ echo "</ul>\n";
+ }
+}
+
+
+//
+// Pages
+//
+
+function &get_page_children($page_id, $pages) {
+ global $page_cache;
+
+ if ( empty($pages) )
+ $pages = &$page_cache;
+
+ $page_list = array();
+ foreach ($pages as $page) {
+ if ($page->post_parent == $page_id) {
+ $page_list[] = $page;
+ if ( $children = get_page_children($page->ID, $pages)) {
+ $page_list = array_merge($page_list, $children);
+ }
+ }
+ }
+
+ return $page_list;
+}
+
+function &get_pages($args = '') {
+ global $wpdb;
+
+ parse_str($args, $r);
+
+ if (!isset($r['child_of'])) $r['child_of'] = 0;
+ if (!isset($r['sort_column'])) $r['sort_column'] = 'post_title';
+ if (!isset($r['sort_order'])) $r['sort_order'] = 'ASC';
+
+ $exclusions = '';
+ if (!empty($r['exclude'])) {
+ $expages = preg_split('/[\s,]+/',$r['exclude']);
+ if (count($expages)) {
+ foreach ($expages as $expage) {
+ $exclusions .= ' AND ID <> ' . intval($expage) . ' ';
+ }
+ }
+ }
+
+ $pages = $wpdb->get_results("SELECT * " .
+ "FROM $wpdb->posts " .
+ "WHERE post_status = 'static' " .
+ "$exclusions " .
+ "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);
+
+ if ( empty($pages) )
+ return array();
+
+ // Update cache.
+ update_page_cache($pages);
+
+ if ($r['child_of'])
+ $pages = & get_page_children($r['child_of'], $pages);
+
+ return $pages;
+}
+
+function wp_list_pages($args = '') {
+ parse_str($args, $r);
+ if ( !isset($r['depth']) ) $r['depth'] = 0;
+ if ( !isset($r['show_date']) ) $r['show_date'] = '';
+ if ( !isset($r['child_of']) ) $r['child_of'] = 0;
+ if ( !isset($r['title_li']) ) $r['title_li'] = __('Pages');
+ if ( !isset($r['echo']) ) $r['echo'] = 1;
+
+ $output = '';
+
+ // Query pages.
+ $pages = & get_pages($args);
+ if ( $pages ) :
+
+ if ( $r['title_li'] )
+ $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
+ // Now loop over all pages that were selected
+ $page_tree = Array();
+ foreach($pages as $page) {
+ // set the title for the current page
+ $page_tree[$page->ID]['title'] = $page->post_title;
+ $page_tree[$page->ID]['name'] = $page->post_name;
+
+ // set the selected date for the current page
+ // depending on the query arguments this is either
+ // the createtion date or the modification date
+ // as a unix timestamp. It will also always be in the
+ // ts field.
+ if (! empty($r['show_date'])) {
+ if ('modified' == $r['show_date'])
+ $page_tree[$page->ID]['ts'] = $page->post_modified;
+ else
+ $page_tree[$page->ID]['ts'] = $page->post_date;
+ }
+
+ // The tricky bit!!
+ // Using the parent ID of the current page as the
+ // array index we set the curent page as a child of that page.
+ // We can now start looping over the $page_tree array
+ // with any ID which will output the page links from that ID downwards.
+ if ( $page->post_parent != $page->ID)
+ $page_tree[$page->post_parent]['children'][] = $page->ID;
+ }
+ // Output of the pages starting with child_of as the root ID.
+ // child_of defaults to 0 if not supplied in the query.
+ $output .= _page_level_out($r['child_of'],$page_tree, $r, 0, false);
+ if ( $r['title_li'] )
+ $output .= '</ul></li>';
+ endif;
+
+ $output = apply_filters('wp_list_pages', $output);
+
+ if ( $r['echo'] )
+ echo $output;
+ else
+ return $output;
+}
+
+function _page_level_out($parent, $page_tree, $args, $depth = 0, $echo = true) {
+ global $wp_query;
+
+ $queried_obj = $wp_query->get_queried_object();
+
+ $output = '';
+
+ if($depth)
+ $indent = str_repeat("\t", $depth);
+ //$indent = join('', array_fill(0,$depth,"\t"));
+
+ foreach($page_tree[$parent]['children'] as $page_id) {
+ $cur_page = $page_tree[$page_id];
+ $title = $cur_page['title'];
+
+ $css_class = 'page_item';
+ if( $page_id == $queried_obj->ID) {
+ $css_class .= ' current_page_item';
+ }
+
+ $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>';
+
+ if(isset($cur_page['ts'])) {
+ $format = get_settings('date_format');
+ if(isset($args['date_format']))
+ $format = $args['date_format'];
+ $output .= " " . mysql2date($format, $cur_page['ts']);
+ }
+ $output .= "\n";
+
+ if(isset($cur_page['children']) && is_array($cur_page['children'])) {
+ $new_depth = $depth + 1;
+
+ if(!$args['depth'] || $depth < ($args['depth']-1)) {
+ $output .= "$indent<ul>\n";
+ $output .= _page_level_out($page_id, $page_tree, $args, $new_depth, false);
+ $output .= "$indent</ul>\n";
+ }
+ }
+ $output .= "$indent</li>\n";
+ }
+ if ( $echo )
+ echo $output;
+ else
+ return $output;
+}
+
+?>
diff --git a/wp-inst/wp-includes/template-loader.php b/wp-inst/wp-includes/template-loader.php
new file mode 100644
index 0000000..07bda7c
--- /dev/null
+++ b/wp-inst/wp-includes/template-loader.php
@@ -0,0 +1,59 @@
+<?php
+
+if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
+ do_action('template_redirect');
+ if ( is_feed() ) {
+ include(ABSPATH . '/wp-feed.php');
+ exit;
+ } else if ( is_trackback() ) {
+ include(ABSPATH . '/wp-trackback.php');
+ exit;
+ } else if ( is_404() && get_404_template() ) {
+ include(get_404_template());
+ exit;
+ } else if ( is_search() && get_search_template() ) {
+ include(get_search_template());
+ exit;
+ } else if ( is_home() && get_home_template() ) {
+ include(get_home_template());
+ exit;
+ } else if ( is_single() && get_single_template() ) {
+ include(get_single_template());
+ exit;
+ } else if ( is_page() && get_page_template() ) {
+ include(get_page_template());
+ exit;
+ } else if ( is_category() && get_category_template()) {
+ include(get_category_template());
+ exit;
+ } else if ( is_author() && get_author_template() ) {
+ include(get_author_template());
+ exit;
+ } else if ( is_date() && get_date_template() ) {
+ include(get_date_template());
+ exit;
+ } else if ( is_archive() && get_archive_template() ) {
+ include(get_archive_template());
+ exit;
+ } else if ( is_comments_popup() && get_comments_popup_template() ) {
+ include(get_comments_popup_template());
+ exit;
+ } else if ( is_paged() && get_paged_template() ) {
+ include(get_paged_template());
+ exit;
+ } else if ( file_exists(TEMPLATEPATH . "/index.php") ) {
+ include(TEMPLATEPATH . "/index.php");
+ exit;
+ }
+} else {
+ // Process feeds and trackbacks even if not using themes.
+ if ( is_feed() ) {
+ include(ABSPATH . '/wp-feed.php');
+ exit;
+ } else if ( is_trackback() ) {
+ include(ABSPATH . '/wp-trackback.php');
+ exit;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/vars.php b/wp-inst/wp-includes/vars.php
new file mode 100644
index 0000000..494f285
--- /dev/null
+++ b/wp-inst/wp-includes/vars.php
@@ -0,0 +1,113 @@
+<?php
+
+// On which page are we ?
+$PHP_SELF = $_SERVER['PHP_SELF'];
+if (preg_match('#([^/]+.php)#', $PHP_SELF, $self_matches)) {
+ $pagenow = $self_matches[1];
+} else if (strstr($PHP_SELF, '?')) {
+ $pagenow = explode('/', $PHP_SELF);
+ $pagenow = trim($pagenow[(sizeof($pagenow)-1)]);
+ $pagenow = explode('?', $pagenow);
+ $pagenow = $pagenow[0];
+} else {
+ $pagenow = 'index.php';
+}
+
+// Simple browser detection
+$is_lynx = 0; $is_gecko = 0; $is_winIE = 0; $is_macIE = 0; $is_opera = 0; $is_NS4 = 0;
+if (!isset($HTTP_USER_AGENT)) {
+ $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
+}
+if (preg_match('/Lynx/', $HTTP_USER_AGENT)) {
+ $is_lynx = 1;
+} elseif (preg_match('/Gecko/', $HTTP_USER_AGENT)) {
+ $is_gecko = 1;
+} elseif ((preg_match('/MSIE/', $HTTP_USER_AGENT)) && (preg_match('/Win/', $HTTP_USER_AGENT))) {
+ $is_winIE = 1;
+} elseif ((preg_match('/MSIE/', $HTTP_USER_AGENT)) && (preg_match('/Mac/', $HTTP_USER_AGENT))) {
+ $is_macIE = 1;
+} elseif (preg_match('/Opera/', $HTTP_USER_AGENT)) {
+ $is_opera = 1;
+} elseif ((preg_match('/Nav/', $HTTP_USER_AGENT) ) || (preg_match('/Mozilla\/4\./', $HTTP_USER_AGENT))) {
+ $is_NS4 = 1;
+}
+$is_IE = (($is_macIE) || ($is_winIE));
+
+// Server detection
+$is_apache = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? 1 : 0;
+$is_IIS = strstr($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') ? 1 : 0;
+
+// if the config file does not provide the smilies array, let's define it here
+if (!isset($wpsmiliestrans)) {
+ $wpsmiliestrans = array(
+ ' :)' => 'icon_smile.gif',
+ ' :D' => 'icon_biggrin.gif',
+ ' :-D' => 'icon_biggrin.gif',
+ ':grin:' => 'icon_biggrin.gif',
+ ' :)' => 'icon_smile.gif',
+ ' :-)' => 'icon_smile.gif',
+ ':smile:' => 'icon_smile.gif',
+ ' :(' => 'icon_sad.gif',
+ ' :-(' => 'icon_sad.gif',
+ ':sad:' => 'icon_sad.gif',
+ ' :o' => 'icon_surprised.gif',
+ ' :-o' => 'icon_surprised.gif',
+ ':eek:' => 'icon_surprised.gif',
+ ' 8O' => 'icon_eek.gif',
+ ' 8-O' => 'icon_eek.gif',
+ ':shock:' => 'icon_eek.gif',
+ ' :?' => 'icon_confused.gif',
+ ' :-?' => 'icon_confused.gif',
+ ' :???:' => 'icon_confused.gif',
+ ' 8)' => 'icon_cool.gif',
+ ' 8-)' => 'icon_cool.gif',
+ ':cool:' => 'icon_cool.gif',
+ ':lol:' => 'icon_lol.gif',
+ ' :x' => 'icon_mad.gif',
+ ' :-x' => 'icon_mad.gif',
+ ':mad:' => 'icon_mad.gif',
+ ' :P' => 'icon_razz.gif',
+ ' :-P' => 'icon_razz.gif',
+ ':razz:' => 'icon_razz.gif',
+ ':oops:' => 'icon_redface.gif',
+ ':cry:' => 'icon_cry.gif',
+ ':evil:' => 'icon_evil.gif',
+ ':twisted:' => 'icon_twisted.gif',
+ ':roll:' => 'icon_rolleyes.gif',
+ ':wink:' => 'icon_wink.gif',
+ ' ;)' => 'icon_wink.gif',
+ ' ;-)' => 'icon_wink.gif',
+ ':!:' => 'icon_exclaim.gif',
+ ':?:' => 'icon_question.gif',
+ ':idea:' => 'icon_idea.gif',
+ ':arrow:' => 'icon_arrow.gif',
+ ' :|' => 'icon_neutral.gif',
+ ' :-|' => 'icon_neutral.gif',
+ ':neutral:' => 'icon_neutral.gif',
+ ':mrgreen:' => 'icon_mrgreen.gif',
+ );
+}
+
+// sorts the smilies' array
+if (!function_exists('smiliescmp')) {
+function smiliescmp ($a, $b) {
+ if (strlen($a) == strlen($b)) {
+ return strcmp($a, $b);
+ }
+ return (strlen($a) > strlen($b)) ? -1 : 1;
+ }
+}
+uksort($wpsmiliestrans, 'smiliescmp');
+
+// generates smilies' search & replace arrays
+foreach($wpsmiliestrans as $smiley => $img) {
+ $wp_smiliessearch[] = $smiley;
+ $smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES);
+ $wp_smiliesreplace[] = " <img src='" . get_settings('siteurl') . "/wp-images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
+}
+
+// Path for cookies
+define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' ) );
+define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('siteurl') . '/' ) );
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/version.php b/wp-inst/wp-includes/version.php
new file mode 100644
index 0000000..53c9f16
--- /dev/null
+++ b/wp-inst/wp-includes/version.php
@@ -0,0 +1,7 @@
+<?php
+
+// This just holds the version number, in a separate file so we can bump it without cluttering the SVN
+
+$wp_version = '1.6-ALPHA-do-not-use';
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/wp-db.php b/wp-inst/wp-includes/wp-db.php
new file mode 100644
index 0000000..73d4be7
--- /dev/null
+++ b/wp-inst/wp-includes/wp-db.php
@@ -0,0 +1,362 @@
+<?php
+// WordPress DB Class
+
+// ORIGINAL CODE FROM:
+// Justin Vincent (justin@visunet.ie)
+// http://php.justinvincent.com
+
+define('EZSQL_VERSION', 'WP1.25');
+define('OBJECT', 'OBJECT', true);
+define('ARRAY_A', 'ARRAY_A', false);
+define('ARRAY_N', 'ARRAY_N', false);
+
+if (!defined('SAVEQUERIES'))
+ define('SAVEQUERIES', false);
+
+class wpdb {
+
+ var $show_errors = true;
+ var $num_queries = 0;
+ var $last_query;
+ var $col_info;
+ var $queries;
+
+ // Our tables
+ var $posts;
+ var $users;
+ var $categories;
+ var $post2cat;
+ var $comments;
+ var $links;
+ var $linkcategories;
+ var $options;
+ var $optiontypes;
+ var $optionvalues;
+ var $optiongroups;
+ var $optiongroup_options;
+ var $postmeta;
+
+ // ==================================================================
+ // DB Constructor - connects to the server and selects a database
+
+ function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
+ $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
+ if (!$this->dbh) {
+ $this->bail("
+<h1>Error establishing a database connection</h1>
+<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>$dbhost</code>. This could mean your host's database server is down.</p>
+<ul>
+ <li>Are you sure you have the correct username and password?</li>
+ <li>Are you sure that you have typed the correct hostname?</li>
+ <li>Are you sure that the database server is running?</li>
+</ul>
+<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>
+");
+ }
+
+ $this->select($dbname);
+ }
+
+ // ==================================================================
+ // Select a DB (if another one needs to be selected)
+
+ function select($db) {
+ if (!@mysql_select_db($db, $this->dbh)) {
+ $this->bail("
+<h1>Can&#8217;t select database</h1>
+<p>We were able to connect to the database server (which means your username and password is okay) but not able to select the <code>$db</code> database.</p>
+<ul>
+<li>Are you sure it exists?</li>
+<li>On some systems the name of your database is prefixed with your username, so it would be like username_wordpress. Could that be the problem?</li>
+</ul>
+<p>If you don't know how to setup a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>");
+ }
+ }
+
+ // ====================================================================
+ // Format a string correctly for safe insert under all PHP conditions
+
+ function escape($string) {
+ if( !$this->dbh || version_compare( phpversion(), '4.3.0' ) == '-1' )
+ return mysql_escape_string( $string );
+ else
+ return mysql_real_escape_string( $string, $this->dbh );
+ }
+
+ // ==================================================================
+ // Print SQL/DB error.
+
+ function print_error($str = '') {
+ global $EZSQL_ERROR;
+ if (!$str) $str = mysql_error();
+ $EZSQL_ERROR[] =
+ array ('query' => $this->last_query, 'error_str' => $str);
+
+ // Is error output turned on or not..
+ if ( $this->show_errors ) {
+ // If there is an error then take note of it
+ print "<div id='error'>
+ <p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
+ <code>$this->last_query</code></p>
+ </div>";
+ } else {
+ return false;
+ }
+ }
+
+ // ==================================================================
+ // Turn error handling on or off..
+
+ function show_errors() {
+ $this->show_errors = true;
+ }
+
+ function hide_errors() {
+ $this->show_errors = false;
+ }
+
+ // ==================================================================
+ // Kill cached query results
+
+ function flush() {
+ $this->last_result = null;
+ $this->col_info = null;
+ $this->last_query = null;
+ }
+
+ // ==================================================================
+ // Basic Query - see docs for more detail
+
+ function query($query) {
+ // initialise return
+ $return_val = 0;
+ $this->flush();
+
+ // Log how the function was called
+ $this->func_call = "\$db->query(\"$query\")";
+
+ // Keep track of the last query for debug..
+ $this->last_query = $query;
+
+ // Perform the query via std mysql_query function..
+ if (SAVEQUERIES)
+ $this->timer_start();
+
+ $this->result = @mysql_query($query, $this->dbh);
+ ++$this->num_queries;
+
+ if (SAVEQUERIES)
+ $this->queries[] = array( $query, $this->timer_stop() );
+
+ // If there is an error then take note of it..
+ if ( mysql_error() ) {
+ $this->print_error();
+ return false;
+ }
+
+ if ( preg_match("/^\\s*(insert|delete|update|replace) /i",$query) ) {
+ $this->rows_affected = mysql_affected_rows();
+ // Take note of the insert_id
+ if ( preg_match("/^\\s*(insert|replace) /i",$query) ) {
+ $this->insert_id = mysql_insert_id($this->dbh);
+ }
+ // Return number of rows affected
+ $return_val = $this->rows_affected;
+ } else {
+ $i = 0;
+ while ($i < @mysql_num_fields($this->result)) {
+ $this->col_info[$i] = @mysql_fetch_field($this->result);
+ $i++;
+ }
+ $num_rows = 0;
+ while ( $row = @mysql_fetch_object($this->result) ) {
+ $this->last_result[$num_rows] = $row;
+ $num_rows++;
+ }
+
+ @mysql_free_result($this->result);
+
+ // Log number of rows the query returned
+ $this->num_rows = $num_rows;
+
+ // Return number of rows selected
+ $return_val = $this->num_rows;
+ }
+
+ return $return_val;
+ }
+
+ // ==================================================================
+ // Get one variable from the DB - see docs for more detail
+
+ function get_var($query=null, $x = 0, $y = 0) {
+ $this->func_call = "\$db->get_var(\"$query\",$x,$y)";
+ if ( $query )
+ $this->query($query);
+
+ // Extract var out of cached results based x,y vals
+ if ( $this->last_result[$y] ) {
+ $values = array_values(get_object_vars($this->last_result[$y]));
+ }
+
+ // If there is a value return it else return null
+ return (isset($values[$x]) && $values[$x]!=='') ? $values[$x] : null;
+ }
+
+ // ==================================================================
+ // Get one row from the DB - see docs for more detail
+
+ function get_row($query = null, $output = OBJECT, $y = 0) {
+ $this->func_call = "\$db->get_row(\"$query\",$output,$y)";
+ if ( $query )
+ $this->query($query);
+
+ if ( $output == OBJECT ) {
+ return $this->last_result[$y] ? $this->last_result[$y] : null;
+ } elseif ( $output == ARRAY_A ) {
+ return $this->last_result[$y] ? get_object_vars($this->last_result[$y]) : null;
+ } elseif ( $output == ARRAY_N ) {
+ return $this->last_result[$y] ? array_values(get_object_vars($this->last_result[$y])) : null;
+ } else {
+ $this->print_error(" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N");
+ }
+ }
+
+ // ==================================================================
+ // Function to get 1 column from the cached result set based in X index
+ // se docs for usage and info
+
+ function get_col($query = null , $x = 0) {
+ if ( $query )
+ $this->query($query);
+
+ // Extract the column values
+ for ( $i=0; $i < count($this->last_result); $i++ ) {
+ $new_array[$i] = $this->get_var(null, $x, $i);
+ }
+ return $new_array;
+ }
+
+ // ==================================================================
+ // Return the the query as a result set - see docs for more details
+
+ function get_results($query = null, $output = OBJECT) {
+ $this->func_call = "\$db->get_results(\"$query\", $output)";
+
+ if ( $query )
+ $this->query($query);
+
+ // Send back array of objects. Each row is an object
+ if ( $output == OBJECT ) {
+ return $this->last_result;
+ } elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
+ if ( $this->last_result ) {
+ $i = 0;
+ foreach( $this->last_result as $row ) {
+ $new_array[$i] = (array) $row;
+ if ( $output == ARRAY_N ) {
+ $new_array[$i] = array_values($new_array[$i]);
+ }
+ $i++;
+ }
+ return $new_array;
+ } else {
+ return null;
+ }
+ }
+ }
+
+
+ // ==================================================================
+ // Function to get column meta data info pertaining to the last query
+ // see docs for more info and usage
+
+ function get_col_info($info_type = 'name', $col_offset = -1) {
+ if ( $this->col_info ) {
+ if ( $col_offset == -1 ) {
+ $i = 0;
+ foreach($this->col_info as $col ) {
+ $new_array[$i] = $col->{$info_type};
+ $i++;
+ }
+ return $new_array;
+ } else {
+ return $this->col_info[$col_offset]->{$info_type};
+ }
+ }
+ }
+
+ function timer_start() {
+ $mtime = microtime();
+ $mtime = explode(' ', $mtime);
+ $this->time_start = $mtime[1] + $mtime[0];
+ return true;
+ }
+
+ function timer_stop($precision = 3) {
+ $mtime = microtime();
+ $mtime = explode(' ', $mtime);
+ $time_end = $mtime[1] + $mtime[0];
+ $time_total = $time_end - $this->time_start;
+ return $time_total;
+ }
+
+ function bail($message) { // Just wraps errors in a nice header and footer
+ if ( !$this->show_errors )
+ return false;
+ header( 'Content-Type: text/html; charset=utf-8');
+ echo <<<HEAD
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>WordPress &rsaquo; Error</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <style media="screen" type="text/css">
+ <!--
+ html {
+ background: #eee;
+ }
+ body {
+ background: #fff;
+ color: #000;
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 25%;
+ margin-right: 25%;
+ padding: .2em 2em;
+ }
+
+ h1 {
+ color: #006;
+ font-size: 18px;
+ font-weight: lighter;
+ }
+
+ h2 {
+ font-size: 16px;
+ }
+
+ p, li, dt {
+ line-height: 140%;
+ padding-bottom: 2px;
+ }
+
+ ul, ol {
+ padding: 5px 5px 5px 20px;
+ }
+ #logo {
+ margin-bottom: 2em;
+ }
+ -->
+ </style>
+ </head>
+ <body>
+ <h1 id="logo"><img alt="WordPress" src="http://static.wordpress.org/logo.png" /></h1>
+HEAD;
+ echo $message;
+ echo "</body></html>";
+ die();
+ }
+}
+
+$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/wp-l10n.php b/wp-inst/wp-includes/wp-l10n.php
new file mode 100644
index 0000000..c051fda
--- /dev/null
+++ b/wp-inst/wp-includes/wp-l10n.php
@@ -0,0 +1,103 @@
+<?php
+
+if ( defined('WPLANG') && '' != constant('WPLANG') ) {
+ include_once(ABSPATH . 'wp-includes/streams.php');
+ include_once(ABSPATH . 'wp-includes/gettext.php');
+}
+
+function get_locale() {
+ global $locale;
+
+ if (isset($locale))
+ return $locale;
+
+ // WPLANG is defined in wp-config.
+ if (defined('WPLANG')) {
+ $locale = WPLANG;
+ }
+
+ if (empty($locale)) {
+ $locale = 'en_US';
+ }
+
+ $locale = apply_filters('locale', $locale);
+
+ return $locale;
+}
+
+// Return a translated string.
+function __($text, $domain = 'default') {
+ global $l10n;
+
+ if (isset($l10n[$domain])) {
+ return $l10n[$domain]->translate($text);
+ } else {
+ return $text;
+ }
+}
+
+// Echo a translated string.
+function _e($text, $domain = 'default') {
+ global $l10n;
+
+ if (isset($l10n[$domain])) {
+ echo $l10n[$domain]->translate($text);
+ } else {
+ echo $text;
+ }
+}
+
+// Return the plural form.
+function __ngettext($single, $plural, $number, $domain = 'default') {
+ global $l10n;
+
+ if (isset($l10n[$domain])) {
+ return $l10n[$domain]->ngettext($single, $plural, $number);
+ } else {
+ if ($number != 1)
+ return $plural;
+ else
+ return $single;
+ }
+}
+
+function load_textdomain($domain, $mofile) {
+ global $l10n;
+
+ if (isset($l10n[$domain])) {
+ return;
+ }
+
+ if ( is_readable($mofile)) {
+ $input = new CachedFileReader($mofile);
+ } else {
+ return;
+ }
+
+ $l10n[$domain] = new gettext_reader($input);
+}
+
+function load_default_textdomain() {
+ global $l10n;
+
+ $locale = get_locale();
+ $mofile = ABSPATH . "wp-includes/languages/$locale.mo";
+
+ load_textdomain('default', $mofile);
+}
+
+function load_plugin_textdomain($domain) {
+ $locale = get_locale();
+
+ $mofile = ABSPATH . "wp-content/plugins/$domain-$locale.mo";
+ load_textdomain($domain, $mofile);
+}
+
+function load_theme_textdomain($domain) {
+ $locale = get_locale();
+
+ $mofile = get_template_directory() . "/$locale.mo";
+ load_textdomain($domain, $mofile);
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/wpmu-functions.php b/wp-inst/wp-includes/wpmu-functions.php
new file mode 100644
index 0000000..c18fa89
--- /dev/null
+++ b/wp-inst/wp-includes/wpmu-functions.php
@@ -0,0 +1,807 @@
+<?PHP
+/*
+ Helper functions for WPMU
+ 4th March 2005
+
+ There are 2 types of helper functions; those that use hooks (do_action, apply_filters hooks) and those that support WPMU the Administration plugin.
+
+ Where possible - existing hooks have been used, but occasionally - extra hooks have been implemented in the WP Core.
+*/
+
+/**
+ * Retrieves a list of client blogs
+ *
+ * @return array
+ */
+function wpmu_getBlogs(){
+ $blogs = array();
+
+ $link = opendir(ABSPATH . 'wp-content/blogs.dir/');
+ while(false !== ($dir = readdir($link))){
+ if(is_dir(ABSPATH . 'wp-content/blogs.dir/' . $dir)) {
+ switch($dir){
+ case '.':
+ case '..':
+ case 'DEFAULT':
+ break;
+ case 'main':
+ array_unshift($blogs, $dir);
+ break;
+
+ default:
+ $blogs[] = $dir;
+ break;
+ }
+ }
+ }
+
+ closedir($link);
+
+ return $blogs;
+}
+
+
+// Cache clearing
+/**
+ * Clears the smarty cache when post/comments occur
+ *
+ */
+function wpmu_clear_cache() {
+ // for future use.
+}
+add_action('comment_post', 'wpmu_clear_cache');
+add_action('delete_post', 'wpmu_clear_cache');
+add_action('delete_comment', 'wpmu_clear_cache');
+add_action('private_to_published', 'wpmu_clear_cache');
+add_action('publish_phone', 'wpmu_clear_cache');
+add_action('publish_post', 'wpmu_clear_cache');
+add_action('trackback_post', 'wpmu_clear_cache');
+add_action('wp_set_comment_status', 'wpmu_clear_cache');
+
+function wpmu_update_blogs_date() {
+ global $wpdb;
+
+ $query = "UPDATE ".$wpdb->blogs."
+ SET last_updated = NOW()
+ WHERE blog_id = '".$wpdb->blogid."'";
+ $wpdb->query( $query );
+}
+add_action('comment_post', 'wpmu_update_blogs_date');
+add_action('delete_post', 'wpmu_update_blogs_date');
+add_action('delete_comment', 'wpmu_update_blogs_date');
+add_action('private_to_published', 'wpmu_update_blogs_date');
+add_action('publish_phone', 'wpmu_update_blogs_date');
+add_action('publish_post', 'wpmu_update_blogs_date');
+add_action('trackback_post', 'wpmu_update_blogs_date');
+add_action('wp_set_comment_status', 'wpmu_update_blogs_date');
+
+
+/**
+ * Cleans the passed path.
+ * Removes the wpmu & the blog name from the path
+ * This should only be used for display filters
+ *
+ * @param unknown $path
+ * @return unknown
+ */
+function wpmu_tidypath($path) {
+ global $wpblog;
+
+ $path = str_replace('/wpmu/','/',$path);
+ $path = str_replace("/{$wpblog}/",'/',$path);
+
+ return $path;
+}
+add_filter('wpmu_display_get_page_string','wpmu_tidypath',10);
+add_filter('wpmu_display_get_permalink','wpmu_tidypath',10);
+
+/**
+ * Wrapper for querying the databse
+ *
+ * @param string $query
+ * @return object
+ */
+function wpmu_adminDatabaseQuery($query) {
+ /* @var $wpdb wpdb */
+ global $wpdb;
+
+ $result = $wpdb->get_row($query);
+
+ return $result;
+}
+
+/**
+ * Set an option in the Master Blog 'main' options table
+ *
+ * @param string $optionName
+ * @param mixed $optionValue
+ */
+function wpmu_adminOptionSet($optionName, $optionValue) {
+ wpmu_blogOption_set('main',$optionName, $optionValue);
+}
+
+/**
+ * Retrieve a setting from the Master Blog Tables
+ *
+ * @param string $optionName
+ * @param mixed $default
+ * @return mixed
+ */
+function wpmu_adminOption_get($optionName, $default=null) {
+ return wpmu_blogOption_get('main',$optionName, $default);
+}
+
+/**
+ * Retrives a setting from a specific client blog
+ *
+ * @param string $blogName
+ * @param string $optionName
+ * @param mixed $default
+ * @return mixed
+ */
+function wpmu_blogOption_get($blogName, $optionName, $default=null) {
+ global $wpdb;
+
+ // check if options table exists
+ if( defined('WP_INSTALLING') )
+ return null;
+
+ $query = wpmu_adminDatabaseQuery("SELECT * FROM ".$wpdb->options." WHERE option_name = '{$optionName}'");
+ if (!isset($query) || is_null($query)) {
+ $result = $default;
+ } else {
+ $result = $query->option_value;
+ if (!(unserialize($result)===false)) {
+ $result = unserialize($result);
+ }
+ }
+
+ return $result;
+}
+
+
+/**
+ * Sets an option for a specific client blog
+ *
+ * @param string $blogName
+ * @param string $optionName
+ * @param mixed $optionValue
+ */
+function wpmu_blogOption_set($blogName, $optionName, $optionValue) {
+
+ global $wpdb;
+
+ $isExisting = wpmu_blogOption_get($blogName,$optionName,null);
+
+ if (is_array($optionValue) || is_object($optionValue)) {
+ $optionValue = serialize($optionValue);
+ }
+
+ if (is_null($isExisting)) {
+ wpmu_adminDatabaseQuery("INSERT INTO ".$wpdb->options." (option_name, option_value) values ('{$optionName}', '{$optionValue}')");
+ } else {
+ wpmu_adminDatabaseQuery("UPDATE ".$wpdb->options." set option_value = '{$optionValue}' where option_name = '{$optionName}'");
+ }
+}
+
+/*
+ Determines if the available space defined by the admin has been exceeded by the user
+*/
+/**
+ * Returns how much space is available (also shows a picture) for the current client blog, retrieving the value from the master blog 'main' option table
+ *
+ * @param string $action
+ * @return string
+ */
+function wpmu_checkAvailableSpace($action) {
+ // Using the action.
+ // Set the action to 'not-writable' to block the upload
+ global $wpblog, $blog_id;
+
+ // Default space allowed is 10 MB
+ $spaceAllowed = wpmu_adminOption_get("wpmu_space_allocated", 10485760 );
+
+ $dirName = ABSPATH."wp-content/blogs.dir/".$blog_id."/files/";
+
+ $dir = dir($dirName);
+ $size = 0;
+
+ while($file = $dir->read()) {
+ if ($file != '.' && $file != '..') {
+ if (is_dir($file)) {
+ $size += dirsize($dirName . '/' . $file);
+ } else {
+ $size += filesize($dirName . '/' . $file);
+ }
+ }
+ }
+ $dir->close();
+
+ ?>
+ <table align="center" width="20%" cellpadding="0" cellspacing="0">
+ <tr>
+ <td>Space Available (<?php print $spaceAllowed-$size ?><i>bytes)</i></td>
+ </tr>
+ <tr>
+ <td bgcolor="<?php echo ((($size/$spaceAllowed)*100)<70)?"Green":"Red"; ?>">&nbsp;</td><td bgcolor="Black" width="<?php echo (($size/$spaceAllowed)*100); ?>%"></td>
+ </tr>
+ </table>
+ <?
+
+ if (($spaceAllowed-$size)>0) {
+ return $action;
+ } else {
+ // No space left
+ return 'not-writable';
+ }
+}
+add_filter('fileupload_init','wpmu_checkAvailableSpace');
+
+
+/**
+ * Retrieves a list of all plugins - and flags those that have been enabled
+ *
+ * @param array $args ByRef Array of plugins
+ */
+function wpmu_allBlogPlugins_get($args) {
+
+ $allPlugins = get_plugins();
+
+ $enabledPlugins = wpmu_adminOption_get('wpmu_global_blog_plugins',array());
+ $enabledPlugins = unserialize($enabledPlugins);
+ if (!is_array($enabledPlugins)) {
+ $enabledPlugins = array();
+ }
+
+ foreach ($enabledPlugins as $thisPlugin) {
+ if (isset($allPlugins[$thisPlugin])) {
+ $allPlugins[$thisPlugin]['enabled']='1';
+ }
+ }
+
+ $args[] = array(
+ 'caption'=>'Plugins Enabled',
+ 'name'=>'wpmu_global_blog_plugins',
+ 'value'=>$allPlugins,
+ 'type'=>'checkbox'
+ );
+}
+add_action('wpmu_options_admin_get','wpmu_allBlogPlugins_get');
+
+/**
+ * Sets global plugins for all blogs
+ *
+ * @param array $args The plugins to configure
+ */
+function wpmu_allBlogPlugins_set($args) {
+
+ // obtain the list of Admin Plugins to work with
+ $activePlugins = $args['wpmu_global_blog_plugins'];
+
+ // Process the array - turn it into something that is similar to the active_plugins array
+ // and work out if the plugin has an installation phase
+ $adminPlugins = array();
+ $pluginsThatNeedInstalling = array();
+ foreach ($activePlugins as $filename => $value) {
+ $adminPlugins[] = $filename;
+ // Check if the plugin has an install stage - by looking for AutoInstall in the plugin header
+ if (wpmu_checkPluginForInstallStages($filename)) {
+ $pluginsThatNeedInstalling[$filename]=true;
+ } else {
+ //
+ }
+ }
+
+ // Store the setting first in the main blog settings for wpmu
+ wpmu_adminOptionSet('wpmu_global_blog_plugins',serialize($adminPlugins));
+
+ // Now rotate through the client blogs and apply the setting
+ $allBlogs = wpmu_getBlogs();
+ foreach ($allBlogs as $thisBlog) {
+ // Exclude the 'main' blog
+ if ($allBlogs!='main') {
+ $currentClientPlugings = wpmu_blogOption_get($thisBlog,'active_plugins',array());
+
+ if (!(unserialize($currentClientPlugings)===false)) {
+ $currentClientPlugings = unserialize($currentClientPlugings);
+ }
+
+ // Deal with the case when we don't get back a serialized array
+ if (!is_array($currentClientPlugings)) {
+ $currentClientPlugings = array();
+ }
+
+ // Work through the currently setup plugins for this blog
+ foreach ($adminPlugins as $thisAdminPlugin) {
+ // If the client blog doesn't already has the plugin
+ if (!in_array($thisAdminPlugin, $currentClientPlugings)) {
+ $currentClientPlugings[] = $thisAdminPlugin;
+ if (isset($pluginsThatNeedInstalling[$thisAdminPlugin])) {
+ $clientPluginsThatNeedInstalling[] = $thisAdminPlugin;
+ } else {
+ //
+ }
+ } else {
+ //
+ }
+ }
+
+ // Store the new plugins for this blog
+ wpmu_blogOption_set($thisBlog,'active_plugins',serialize($currentClientPlugings));
+ if (count($clientPluginsThatNeedInstalling)>0) {
+ wpmu_blogOption_set($thisBlog,'wpmu_plugins_pending',serialize($clientPluginsThatNeedInstalling));
+ }
+ }
+ }
+}
+add_action('wpmu_options_admin_set','wpmu_allBlogPlugins_set');
+
+/**
+ * Determines if a plugin contains auto-install instructions
+ *
+ * @param string $plugin_file
+ * @return string|false Returns the install instructions or false
+ */
+function wpmu_checkPluginForInstallStages($plugin_file) {
+
+ if (file_exists(ABSPATH.'wp-content/plugins/'.$plugin_file)) {
+ $plugin_file = ABSPATH.'wp-content/plugins/'.$plugin_file;
+ } else {
+ die("{$plugin_file}");
+ }
+
+ $plugin_data = implode('', file($plugin_file));
+ preg_match("|AutoInstall:(.*)|i", $plugin_data, $pluginAutoInstall);
+
+ if (is_array($pluginAutoInstall)) {
+ $pluginAutoInstall = $pluginAutoInstall[0];
+ } else {
+ $pluginAutoInstall = "";
+ }
+
+ if (isset($pluginAutoInstall) && !is_null($pluginAutoInstall)) {
+ $pluginAutoInstall = str_replace('AutoInstall:','',$pluginAutoInstall);
+ $pluginAutoInstall = str_replace('<code>','',$pluginAutoInstall);
+ $pluginAutoInstall = str_replace('</code>','',$pluginAutoInstall);
+ return $pluginAutoInstall;
+ }
+ return false;
+}
+
+/**
+ * Evaluates an expression
+ *
+ * @param unknown $string
+ * @return unknown
+ */
+function wpmu_eval($string) {
+
+ $result = eval($string);
+
+ if ($result===false || is_null($result)) {
+ return false;
+ }
+ return true;
+}
+
+/**
+ * Auto installs plugins
+ *
+ */
+function wpmu_autoInstallPlugins($pendingPlugins) {
+ global $wpblog;
+
+ foreach ($pendingPlugins as $key => $filename) {
+ $installOptions = wpmu_checkPluginForInstallStages($filename);
+ if ($installOptions) {
+ // Include the file
+ require_once(ABSPATH.'wp-content/plugins/'.$filename);
+ $result = wpmu_eval($installOptions);
+ } else {
+ $result = true;
+ }
+ if ($result==true) {
+ // Everything worked ok
+ unset($pendingPlugins[$key]);
+ } else {
+ // There was a problem - should be logged
+ }
+ }
+ wpmu_blogOption_set($wpblog,'wpmu_plugins_pending',serialize($pendingPlugins));
+}
+
+/*
+ Determine if there are any plugins that need installing or configuring
+ This will enable not just the auto install/configure of plugins - but updates (to plugins or plugin data) as well
+*/
+$pendingPlugins = wpmu_blogOption_get($wpblog,'wpmu_plugins_pending', null);
+
+if (is_null($pendingPlugins)) {
+ // If null is returned - then this is a brand new blog
+ $adminPlugins = wpmu_adminOption_get('wpmu_global_blog_plugins',null);
+ if (!is_null($adminPlugins)) {
+ // We've something to do
+ wpmu_autoInstallPlugins($adminPlugins);
+ }
+} else {
+ if (count($pendingPlugins)>0) {
+ wpmu_autoInstallPlugins($pendingPlugins);
+ }
+}
+
+function createBlog( $hostname, $domain, $path, $blogname, $weblog_title, $admin_email, $username='' ) {
+ global $wpdb, $table_prefix, $wp_queries, $wpmuBaseTablePrefix;
+
+ $blogname = addslashes( $blogname );
+ $weblog_title = addslashes( $weblog_title );
+ $admin_email = addslashes( $admin_email );
+ $username = addslashes( $username );
+
+ // Check if the username has been used already. We should return an error message.
+ if( $username == '' ) {
+ $query = "SELECT ID
+ FROM ".$wpdb->users."
+ WHERE user_login = '".$blogname."'";
+ $ID = $wpdb->get_var( $query );
+ if( $ID != false ) {
+ return "error: blogname used by user";
+ }
+ } else {
+ $query = "SELECT ID
+ FROM ".$wpdb->users."
+ WHERE user_login = '".$username."'";
+ $ID = $wpdb->get_var( $query );
+ if( $ID != false ) {
+ return "error: username used";
+ }
+ }
+
+ // Need to backup wpdb table names, and create a new wp_blogs entry for new blog.
+ // Need to get blog_id from wp_blogs, and create new table names.
+ // Must restore table names at the end of function.
+
+ $wpdb->hide_errors();
+ $query = "SELECT id
+ FROM ".$wpdb->site."
+ WHERE domain = '".$domain."'
+ AND path = '".$path."'";
+ $site_id = $wpdb->get_var( $query );
+
+ if( $site_id == false ) {
+ $query = "INSERT INTO `wp_site` ( `id` , `domain` , `path` )
+ VALUES ( NULL, '".$domain."', '".$path."')";
+ $wpdb->query( $query );
+ $site_id = $wpdb->insert_id;
+ }
+
+ $query = "SELECT blog_id
+ FROM ".$wpdb->blogs."
+ WHERE site_id = '".$site_id."'
+ AND blogname = '".$blogname."'";
+ $blog_id = $wpdb->get_var( $query );
+ if( $blog_id != false ) {
+ return "error: blogname used";
+ }
+ $query = "INSERT INTO ".$wpdb->blogs." ( blog_id, site_id, blogname, registered )
+ VALUES ( NULL, '".$site_id."', '".$blogname."', NOW( ))";
+ if( $wpdb->query( $query ) == false ) {
+ return "error: problem creating blog entry";
+ }
+ $blog_id = $wpdb->insert_id;
+
+ // backup
+ $tmp[ 'siteid' ] = $wpdb->siteid;
+ $tmp[ 'blogid' ] = $wpdb->blogid;
+ $tmp[ 'posts' ] = $wpdb->posts;
+ $tmp[ 'categories' ] = $wpdb->categories;
+ $tmp[ 'post2cat' ] = $wpdb->post2cat;
+ $tmp[ 'comments' ] = $wpdb->comments;
+ $tmp[ 'links' ] = $wpdb->links;
+ $tmp[ 'linkcategories' ] = $wpdb->linkcategories;
+ $tmp[ 'option' ] = $wpdb->option;
+ $tmp[ 'postmeta' ] = $wpdb->postmeta;
+ $tmptable_prefix = $table_prefix;
+
+ // fix the new prefix.
+ $table_prefix = $wpmuBaseTablePrefix . $blog_id . "_";
+ $wpdb->siteid = $site_id;
+ $wpdb->blogid = $blog_id;
+ $wpdb->posts = $table_prefix . 'posts';
+ $wpdb->categories = $table_prefix . 'categories';
+ $wpdb->post2cat = $table_prefix . 'post2cat';
+ $wpdb->comments = $table_prefix . 'comments';
+ $wpdb->links = $table_prefix . 'links';
+ $wpdb->linkcategories = $table_prefix . 'linkcategories';
+ $wpdb->options = $table_prefix . 'options';
+ $wpdb->postmeta = $table_prefix . 'postmeta';
+
+ @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id, 0777 );
+ @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id."/files", 0777 );
+
+ require_once( ABSPATH . 'wp-admin/upgrade-functions.php');
+ $wpdb->hide_errors();
+ $installed = $wpdb->get_results("SELECT * FROM $wpdb->posts");
+ if ($installed) die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
+ flush();
+
+ if( $path == '/' ) {
+ $slash = '';
+ } else {
+ $slash = $path;
+ }
+ if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ if( $blogname == 'main' ) {
+ $url = "http://".$hostname.$path.$slash;
+ } else {
+ $url = "http://".$blogname.".".$domain.$path.$slash;
+ }
+ } else {
+ if( $blogname == 'main' ) {
+ $url = "http://".$hostname.$path.$slash;
+ } else {
+ $url = "http://".$hostname.$path.$blogname.$slash;
+ }
+ }
+
+ // Set everything up
+ make_db_current_silent();
+ populate_options();
+
+ // fix url.
+ update_option('siteurl', $url);
+
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '".$weblog_title."' WHERE option_name = 'blogname'");
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '".$admin_email."' WHERE option_name = 'admin_email'");
+
+ // Now drop in some default links
+ $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".addslashes(__('Blogroll'))."')");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blog.carthik.net/index.php', 'Carthik', 1, 'http://blog.carthik.net/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) 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) 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) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) 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) 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) 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) 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) VALUES ('0', '".addslashes(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."')");
+
+ // Set up admin user
+ $random_password = substr(md5(uniqid(microtime())), 0, 6);
+ if( $username != '' ) {
+ $adminname = $username;
+ } else {
+ $adminname = $blogname;
+ }
+ $wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_registered, user_level, display_name) VALUES ( NULL, '".$adminname."', MD5('$random_password'), '".$admin_email."', NOW(), '10', 'Administrator' )");
+ $userID = $wpdb->insert_id;
+ $metavalues = array( "user_nickname" => addslashes(__('Administrator')), $table_prefix . "user_level" => 10, "source_domain" => $domain );
+ reset( $metavalues );
+ while( list( $key, $val ) = each ( $metavalues ) )
+ {
+ $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
+ VALUES ( NULL, '".$userID."', '".$key."' , '".$val."')";
+ $wpdb->query( $query );
+ }
+
+ // 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_title, post_category, post_name, post_modified, post_modified_gmt) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('Welcome to WordPress MU. This is your first post. Edit or delete it, then start blogging!'))."', '".addslashes(__('Hello world!'))."', '0', '".addslashes(__('hello-world'))."', '$now', '$now_gmt')");
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('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.'))."', '".addslashes(__('About'))."', '0', '".addslashes(__('about'))."', '$now', '$now_gmt', 'static')");
+
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (2, 2, 1)" );
+
+ // Default comment
+ $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) VALUES ('1', '".addslashes(__('Mr WordPress'))."', '', 'http://wordpress.org', '127.0.0.1', '$now', '$now_gmt', '".addslashes(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')");
+
+ $message_headers = 'From: ' . stripslashes($weblog_title) . ' <wordpress@' . $_SERVER[ 'SERVER_NAME' ] . '>';
+ $message = __("Dear User,\n\nYour new WordPressMU blog has been successfully set up at:\n".$url."\n\nYou can log in to the administrator account with the following information:\n Username: ".$adminname."\n Password: ".$random_password."\nLogin Here: ".$url."wp-login.php\n\nWe hope you enjoy your new weblog.\n Thanks!\n\n--The WordPressMU Team\nhttp://mu.wordpress.org/\n");
+ @mail($admin_email, __('New WordPress MU Blog').": ".stripslashes( $weblog_title ), $message, $message_headers);
+
+ upgrade_all();
+ // remove all perms except for the login user.
+ $query = "DELETE FROM ".$wpdb->usermeta."
+ WHERE user_id != '".$userID."'
+ AND meta_key = '".$table_prefix."user_level'";
+ $wpdb->query( $query );
+
+ // insert admin user into user table.
+ $adminusers = get_admin_users_for_domain();
+ if( is_array( $adminusers ) ) {
+ reset( $adminusers );
+ while( list( $key, $val ) = each( $adminusers ) ) {
+ $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
+ VALUES ( NULL, '".$val[ 'ID' ]."', '".$table_prefix."user_level' , '10')";
+ $wpdb->query( $query );
+ }
+ } else {
+ die( "Problem getting admin users!" );
+ }
+
+ // restore wpdb variables
+ reset( $tmp );
+ while( list( $key, $val ) = each( $tmp ) )
+ {
+ $wpdb->$key = $val;
+ }
+ $table_prefix = $tmptable_prefix;
+
+ $wpdb->show_errors();
+
+ return "ok";
+}
+
+function get_blogaddress_by_id( $blog_id ) {
+ global $hostname, $domain, $base, $wpdb;
+
+ // not current blog
+ $query = "SELECT *
+ FROM ".$wpdb->blogs."
+ WHERE blog_id = '".$blog_id."'";
+ $bloginfo = $wpdb->get_results( $query, ARRAY_A );
+ if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ return "http://".$bloginfo[ 'blogname' ].".".$domain.$base;
+ } else {
+ return "http://".$hostname.$base.$bloginfo[ 'blogname' ];
+ }
+}
+
+function get_blogaddress_by_name( $blogname ) {
+ global $domain, $base, $wpdb;
+
+ if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ if( $blogname == 'main' )
+ $blogname = 'www';
+ return "http://".$blogname.".".$domain.$base;
+ } else {
+ return "http://".$hostname.$base.$blogname;
+ }
+}
+
+function get_sitestats() {
+ global $wpdb, $basedomain, $base;
+
+ $query = "SELECT count(*) as c
+ FROM ".$wpdb->blogs."
+ WHERE site_id = '".$wpdb->siteid."'";
+ $blogs = $wpdb->get_var( $query );
+ $stats[ 'blogs' ] = $blogs;
+
+ $query = "SELECT count(*) as c
+ FROM ".$wpdb->users;
+ $users = $wpdb->get_var( $query );
+ $stats[ 'users' ] = $users;
+
+ return $stats;
+
+}
+function get_admin_users_for_domain( $sitedomain = '', $path = '' ) {
+ global $domain, $base, $basedomain, $wpdb, $wpmuBaseTablePrefix;
+ if( $sitedomain == '' ) {
+ $sitedomain = $basedomain;
+ $site_id = $wpdb->siteid;
+ } else {
+ $query = "SELECT id
+ FROM ".$wpdb->site."
+ WHERE domain = '".$domain."'
+ AND path = '".$base."'";
+ $site_id = $wpdb->get_var( $query );
+ }
+ if( $site_id != false ) {
+ $query = "SELECT ID, user_login, user_pass
+ FROM ".$wpdb->users.", ".$wpdb->sitemeta."
+ WHERE meta_key = 'admin_user_id'
+ AND ".$wpdb->users.".ID = ".$wpdb->sitemeta.".meta_value
+ AND site_id = '".$site_id."'";
+ $details = $wpdb->get_results( $query, ARRAY_A );
+ } else {
+ $details = false;
+ }
+
+ return $details;
+}
+
+function get_site_settings( $option ) {
+ global $wpdb;
+
+ $query = "SELECT meta_value
+ FROM $wpdb->sitemeta
+ WHERE meta_key = '$option'
+ AND site_id = '".$wpdb->siteid."'";
+ $option = $wpdb->get_var( $query );
+ @ $kellogs = unserialize($option);
+ if ($kellogs !== FALSE)
+ $option = $kellogs;
+
+ return $option;
+}
+
+function add_site_settings( $key, $value ) {
+ global $wpdb;
+ if( $value != get_site_settings( $key ) ) {
+ if ( is_array($value) || is_object($value) )
+ $value = serialize($value);
+ $query = "SELECT meta_value
+ FROM ".$wpdb->sitemeta."
+ WHERE meta_key = '$key'
+ AND site_id = '".$wpdb->siteid."'";
+ if( $wpdb->get_var( $query ) == false ) {
+ $query = "INSERT INTO wp_sitemeta ( meta_id , site_id , meta_key , meta_value )
+ VALUES ( NULL, '".$wpdb->siteid."', '".$key."', '".$wpdb->escape( $value )."')";
+ $wpdb->query( $query );
+ }
+ }
+}
+
+function update_site_settings( $key, $value ) {
+ global $wpdb;
+ if( $value != get_site_settings( $key ) ) {
+ if ( is_array($value) || is_object($value) )
+ $value = serialize($value);
+
+ $value = trim($value); // I can't think of any situation we wouldn't want to trim
+ $query = "SELECT meta_value
+ FROM ".$wpdb->sitemeta."
+ WHERE meta_key = '$key'
+ AND site_id = '".$wpdb->siteid."'";
+ if( $wpdb->get_var( $query ) == false ) {
+ add_site_settings( $key, $value );
+ } else {
+ $query = "UPDATE ".$wpdb->sitemeta."
+ SET meta_value = '".$wpdb->escape( $value )."'
+ WHERE meta_key = '".$key."'";
+ $wpdb->query( $query );
+ }
+ }
+}
+
+function switch_to_blogid( $blog_id ) {
+ global $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $cache_settings;
+
+ // FIXME
+
+ // backup
+ $tmpoldblogdetails[ 'blogid' ] = $wpdb->blogid;
+ $tmpoldblogdetails[ 'posts' ] = $wpdb->posts;
+ $tmpoldblogdetails[ 'categories' ] = $wpdb->categories;
+ $tmpoldblogdetails[ 'post2cat' ] = $wpdb->post2cat;
+ $tmpoldblogdetails[ 'comments' ] = $wpdb->comments;
+ $tmpoldblogdetails[ 'links' ] = $wpdb->links;
+ $tmpoldblogdetails[ 'linkcategories' ] = $wpdb->linkcategories;
+ $tmpoldblogdetails[ 'option' ] = $wpdb->option;
+ $tmpoldblogdetails[ 'postmeta' ] = $wpdb->postmeta;
+ $tmpoldblogdetails[ 'prefix' ] = $wpdb->prefix;
+
+ // fix the new prefix.
+ $table_prefix = $wpmuBaseTablePrefix . $blog_id . "_";
+ $wpdb->blogid = $blog_id;
+ $wpdb->posts = $table_prefix . 'posts';
+ $wpdb->categories = $table_prefix . 'categories';
+ $wpdb->post2cat = $table_prefix . 'post2cat';
+ $wpdb->comments = $table_prefix . 'comments';
+ $wpdb->links = $table_prefix . 'links';
+ $wpdb->linkcategories = $table_prefix . 'linkcategories';
+ $wpdb->options = $table_prefix . 'options';
+ $wpdb->postmeta = $table_prefix . 'postmeta';
+
+ unset( $cache_settings );
+}
+
+function restore_current_blogid() {
+ global $tmpoldblogdetails, $wpdb;
+ // backup
+ $wpdb->blogid = $tmpoldblogdetails[ 'blogid' ];
+ $wpdb->posts = $tmpoldblogdetails[ 'posts' ];
+ $wpdb->categories = $tmpoldblogdetails[ 'categories' ];
+ $wpdb->post2cat = $tmpoldblogdetails[ 'post2cat' ];
+ $wpdb->comments = $tmpoldblogdetails[ 'comments' ];
+ $wpdb->links = $tmpoldblogdetails[ 'links' ];
+ $wpdb->linkcategories = $tmpoldblogdetails[ 'linkcategories' ];
+ $wpdb->option = $tmpoldblogdetails[ 'option' ];
+ $wpdb->postmeta = $tmpoldblogdetails[ 'postmeta' ];
+ $wpdb->prefix = $tmpoldblogdetails[ 'prefix' ];
+}
+?>
diff --git a/wp-inst/wp-links-opml.php b/wp-inst/wp-links-opml.php
new file mode 100644
index 0000000..04d4ff0
--- /dev/null
+++ b/wp-inst/wp-links-opml.php
@@ -0,0 +1,58 @@
+<?php
+$doing_rss = 1;
+
+require('wp-blog-header.php');
+header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
+$link_cat = $_GET['link_cat'];
+if ((empty($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
+ $sql_cat = '';
+} else { // be safe
+ $link_cat = ''.urldecode($link_cat).'';
+ $link_cat = addslashes_gpc($link_cat);
+ $link_cat = intval($link_cat);
+ if ($link_cat != 0) {
+ $sql_cat = "AND $wpdb->links.link_category = $link_cat";
+ $cat_name = $wpdb->get_var("SELECT $wpdb->linkcategories.cat_name FROM $wpdb->linkcategories WHERE $wpdb->linkcategories.cat_id = $link_cat");
+ if (!empty($cat_name)) {
+ $cat_name = ": category $cat_name";
+ }
+ }
+}
+?><?php echo '<?xml version="1.0"?'.">\n"; ?>
+<!-- generator="wordpress/<?php echo $wp_version ?>" -->
+<opml version="1.0">
+ <head>
+ <title>Links for <?php echo get_bloginfo('name').$cat_name ?></title>
+ <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
+ </head>
+ <body>
+<?php $sql = "SELECT $wpdb->links.link_url, link_rss, $wpdb->links.link_name, $wpdb->links.link_category, $wpdb->linkcategories.cat_name, link_updated
+FROM $wpdb->links
+ JOIN $wpdb->linkcategories on $wpdb->links.link_category = $wpdb->linkcategories.cat_id
+ $sql_cat
+ ORDER BY $wpdb->linkcategories.cat_name, $wpdb->links.link_name \n";
+ //echo("<!-- $sql -->");
+ $prev_cat_id = 0;
+ $results = $wpdb->get_results($sql);
+ if ($results) {
+ foreach ($results as $result) {
+ if ($result->link_category != $prev_cat_id) { // new category
+ if ($prev_cat_id != 0) { // not first time
+?>
+ </outline>
+<?php
+ } // end if not first time
+?>
+ <outline type="category" title="<?php echo wp_specialchars($result->cat_name); ?>">
+<?php
+ $prev_cat_id = $result->link_category;
+ } // end if new category
+?>
+ <outline title="<?php echo wp_specialchars($result->link_name); ?>" type="link" xmlUrl="<?php echo wp_specialchars($result->link_rss); ?>" htmlUrl="<?php echo wp_specialchars($result->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $result->link_updated) echo $result->link_updated; ?>" />
+<?php
+ } // end foreach
+ } // end if
+?>
+ </outline>
+ </body>
+</opml> \ No newline at end of file
diff --git a/wp-inst/wp-login.php b/wp-inst/wp-login.php
new file mode 100644
index 0000000..31b2b6e
--- /dev/null
+++ b/wp-inst/wp-login.php
@@ -0,0 +1,248 @@
+<?php
+require( dirname(__FILE__) . '/wp-config.php' );
+
+$action = $_REQUEST['action'];
+$error = '';
+
+nocache_headers();
+
+header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
+
+if ( defined('RELOCATE') ) { // Move flag is set
+ if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
+ $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
+
+ if ( dirname('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_settings('siteurl') )
+ update_option('siteurl', dirname('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) );
+}
+
+switch($action) {
+
+case 'logout':
+
+ wp_clearcookie();
+ do_action('wp_logout');
+ nocache_headers();
+ wp_redirect('wp-login.php');
+ exit();
+
+break;
+
+case 'lostpassword':
+do_action('lost_password');
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>WordPress &raquo; <?php _e('Lost Password') ?></title>
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
+ <link rel="stylesheet" href="<?php echo get_settings('siteurl'); ?>/wp-admin/wp-admin.css" type="text/css" />
+ <script type="text/javascript">
+ function focusit() {
+ // focus on first input field
+ document.getElementById('user_login').focus();
+ }
+ window.onload = focusit;
+ </script>
+ <style type="text/css">
+ #user_login, #email, #submit {
+ font-size: 1.7em;
+ }
+ </style>
+</head>
+<body>
+<div id="login">
+<h1><a href="http://wordpress.org/">WordPress</a></h1>
+<p><?php _e('Please enter your information here. We will send you a new password.') ?></p>
+<?php
+if ($error)
+ echo "<div id='login_error'>$error</div>";
+?>
+
+<form name="lostpass" action="wp-login.php" method="post" id="lostpass">
+<p>
+<input type="hidden" name="action" value="retrievepassword" />
+<label><?php _e('Username:') ?><br />
+<input type="text" name="user_login" id="user_login" value="" size="20" tabindex="1" /></label></p>
+<p><label><?php _e('E-mail:') ?><br />
+<input type="text" name="email" id="email" value="" size="25" tabindex="2" /></label><br />
+</p>
+<p class="submit"><input type="submit" name="submit" id="submit" value="<?php _e('Retrieve Password'); ?> &raquo;" tabindex="3" /></p>
+</form>
+<ul>
+ <li><a href="<?php bloginfo('home'); ?>" title="<?php _e('Are you lost?') ?>">&laquo; <?php _e('Back to blog') ?></a></li>
+<?php if (get_settings('users_can_register')) : ?>
+ <li><a href="<?php bloginfo('wpurl'); ?>/wp-register.php"><?php _e('Register') ?></a></li>
+<?php endif; ?>
+ <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li>
+</ul>
+</div>
+</body>
+</html>
+<?php
+break;
+
+case 'retrievepassword':
+ $user_data = get_userdatabylogin($_POST['user_login']);
+ // redefining user_login ensures we return the right case in the email
+ $user_login = $user_data->user_login;
+ $user_email = $user_data->user_email;
+
+ if (!$user_email || $user_email != $_POST['email'])
+ die(sprintf(__('Sorry, that user does not seem to exist in our database. Perhaps you have the wrong username or e-mail address? <a href="%s">Try again</a>.'), 'wp-login.php?action=lostpassword'));
+
+do_action('retreive_password', $user_login); // Misspelled and deprecated.
+do_action('retrieve_password', $user_login);
+
+ // Generate something random for a password... md5'ing current time with a rand salt
+ $key = substr( md5( uniqid( microtime() ) ), 0, 50);
+ // now insert the new pass md5'd into the db
+ $wpdb->query("UPDATE $wpdb->users SET user_activation_key = '$key' WHERE user_login = '$user_login'");
+ $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
+ $message .= get_option('siteurl') . "\r\n\r\n";
+ $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
+ $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
+ $message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key=$key\r\n";
+
+ $m = wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_settings('blogname')), $message);
+
+ if ($m == false) {
+ echo '<p>' . __('The e-mail could not be sent.') . "<br />\n";
+ echo __('Possible reason: your host may have disabled the mail() function...') . "</p>";
+ die();
+ } else {
+ echo '<p>' . sprintf(__("The e-mail was sent successfully to %s's e-mail address."), $user_login) . '<br />';
+ echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course') . "'>" . __('Click here to login!') . '</a></p>';
+ die();
+ }
+
+break;
+
+case 'resetpass' :
+
+ // Generate something random for a password... md5'ing current time with a rand salt
+ $key = preg_replace('/a-z0-9/i', '', $_GET['key']);
+ if ( empty($key) )
+ die( __('Sorry, that key does not appear to be valid.') );
+ $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_activation_key = '$key'");
+ if ( !$user )
+ die( __('Sorry, that key does not appear to be valid.') );
+
+ do_action('password_reset');
+
+ $new_pass = substr( md5( uniqid( microtime() ) ), 0, 7);
+ $wpdb->query("UPDATE $wpdb->users SET user_pass = MD5('$new_pass'), user_activation_key = '' WHERE user_login = '$user->user_login'");
+ $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
+ $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
+ $message .= get_settings('siteurl') . "/wp-login.php\r\n";
+
+ $m = wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_settings('blogname')), $message);
+
+ if ($m == false) {
+ echo '<p>' . __('The e-mail could not be sent.') . "<br />\n";
+ echo __('Possible reason: your host may have disabled the mail() function...') . '</p>';
+ die();
+ } else {
+ echo '<p>' . sprintf(__('Your new password is in the mail.'), $user_login) . '<br />';
+ echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course') . "'>" . __('Click here to login!') . '</a></p>';
+ // send a copy of password change notification to the admin
+ $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
+ wp_mail(get_settings('admin_email'), sprintf(__('[%s] Password Lost/Change'), get_settings('blogname')), $message);
+ die();
+ }
+break;
+
+case 'login' :
+default:
+
+ $user_login = '';
+ $user_pass = '';
+ $redirect_to = 'wp-admin/';
+ $using_cookie = false;
+
+ if( !empty($_POST) ) {
+ $user_login = $_POST['log'];
+ $user_pass = $_POST['pwd'];
+ $redirect_to = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $_POST['redirect_to']);
+ } elseif ( !empty($_COOKIE) ) {
+ if (! empty($_COOKIE['wordpressuser_' . COOKIEHASH]) )
+ $user_login = $_COOKIE['wordpressuser_' . COOKIEHASH];
+ if (! empty($_COOKIE['wordpresspass_' . COOKIEHASH]) ) {
+ $user_pass = $_COOKIE['wordpresspass_' . COOKIEHASH];
+ $using_cookie = true;
+ }
+ }
+
+ do_action('wp_authenticate', array(&$user_login, &$user_pass));
+
+ if ($user_login && $user_pass) {
+ $user = get_userdatabylogin($user_login);
+ if ( 0 == $user->user_level )
+ $redirect_to = get_settings('siteurl') . '/wp-admin/profile.php';
+
+ if ( wp_login($user_login, $user_pass, $using_cookie) ) {
+ if (! $using_cookie) {
+ wp_setcookie($user_login, $user_pass);
+ }
+ do_action('wp_login', $user_login);
+ wp_redirect($redirect_to);
+ exit();
+ } else {
+ if ($using_cookie)
+ $error = __('Your session has expired.');
+ }
+ }
+ if ( isset($_REQUEST['redirect_to']) )
+ $redirect_to = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $_REQUEST['redirect_to']);
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>WordPress &rsaquo; <?php _e('Login') ?></title>
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
+ <link rel="stylesheet" href="<?php bloginfo('wpurl'); ?>/wp-admin/wp-admin.css" type="text/css" />
+ <script type="text/javascript">
+ function focusit() {
+ document.getElementById('log').focus();
+ }
+ window.onload = focusit;
+ </script>
+ <style type="text/css">
+ #log, #pwd, #submit {
+ font-size: 1.7em;
+ }
+ </style>
+</head>
+<body>
+
+<div id="login">
+<h1><a href="http://wordpress.org/">WordPress</a></h1>
+<?php
+if ( $error )
+ echo "<div id='login_error'>$error</div>";
+?>
+
+<form name="loginform" id="loginform" action="wp-login.php" method="post">
+<p><label><?php _e('Username:') ?><br /><input type="text" name="log" id="log" value="" size="20" tabindex="1" /></label></p>
+<p><label><?php _e('Password:') ?><br /> <input type="password" name="pwd" id="pwd" value="" size="20" tabindex="2" /></label></p>
+<p class="submit">
+ <input type="submit" name="submit" id="submit" value="<?php _e('Login'); ?> &raquo;" tabindex="3" />
+ <input type="hidden" name="redirect_to" value="<?php echo $redirect_to; ?>" />
+</p>
+</form>
+<ul>
+ <li><a href="<?php bloginfo('home'); ?>" title="<?php _e('Are you lost?') ?>">&laquo; <?php _e('Back to blog') ?></a></li>
+<?php if (get_settings('users_can_register')) : ?>
+ <li><a href="<?php bloginfo('wpurl'); ?>/wp-register.php"><?php _e('Register') ?></a></li>
+<?php endif; ?>
+ <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li>
+</ul>
+</div>
+
+</body>
+</html>
+<?php
+
+break;
+} // end action switch
+?>
diff --git a/wp-inst/wp-mail.php b/wp-inst/wp-mail.php
new file mode 100644
index 0000000..a106e66
--- /dev/null
+++ b/wp-inst/wp-mail.php
@@ -0,0 +1,182 @@
+<?php
+require(dirname(__FILE__) . '/wp-config.php');
+
+require_once(ABSPATH.WPINC.'/class-pop3.php');
+
+error_reporting(2037);
+
+$time_difference = get_settings('gmt_offset') * 3600;
+
+$phone_delim = '::';
+
+$pop3 = new POP3();
+
+if (!$pop3->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) :
+ echo "Ooops $pop3->ERROR <br />\n";
+ exit;
+endif;
+
+$count = $pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass'));
+if (0 == $count) die(__('There doesn&#8217;t seem to be any new mail.'));
+
+
+for ($i=1; $i <= $count; $i++) :
+
+ $message = $pop3->get($i);
+
+ $content = '';
+ $content_type = '';
+ $boundary = '';
+ $bodysignal = 0;
+ $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
+ foreach ($message as $line) :
+ if (strlen($line) < 3) $bodysignal = 1;
+
+ if ($bodysignal) {
+ $content .= $line;
+ } else {
+ if (preg_match('/Content-Type: /i', $line)) {
+ $content_type = trim($line);
+ $content_type = substr($content_type, 14, strlen($content_type)-14);
+ $content_type = explode(';', $content_type);
+ $content_type = $content_type[0];
+ }
+ if (($content_type == 'multipart/alternative') && (preg_match('/boundary="/', $line)) && ($boundary == '')) {
+ $boundary = trim($line);
+ $boundary = explode('"', $boundary);
+ $boundary = $boundary[1];
+ }
+ if (preg_match('/Subject: /i', $line)) {
+ $subject = trim($line);
+ $subject = substr($subject, 9, strlen($subject)-9);
+ if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $subject)) {
+ $subject = wp_iso_descrambler($subject);
+ }
+ // Captures any text in the subject before $phone_delim as the subject
+ $subject = explode($phone_delim, $subject);
+ $subject = $subject[0];
+ }
+
+ // Set the author using the email address (To or Reply-To, the last used)
+ // otherwise use the site admin
+ if (preg_match('/From: /', $line) | preg_match('Reply-To: /', $line)) {
+ $author=trim($line);
+ if ( ereg("([a-zA-Z0-9\_\-\.]+@[\a-zA-z0-9\_\-\.]+)", $author , $regs) ) {
+ echo "Author = {$regs[1]} <p>";
+ $result = $wpdb->get_row("SELECT ID FROM $tableusers WHERE user_email='$regs[1]' ORDER BY ID DESC LIMIT 1");
+ if (!$result)
+ $post_author = 1;
+ else
+ $post_author = $result->ID;
+ } else
+ $post_author = 1;
+ }
+
+ if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37'
+ $ddate = trim($line);
+ $ddate = str_replace('Date: ', '', $ddate);
+ if (strpos($ddate, ',')) {
+ $ddate = trim(substr($ddate, strpos($ddate, ',')+1, strlen($ddate)));
+ }
+ $date_arr = explode(' ', $ddate);
+ $date_time = explode(':', $date_arr[3]);
+
+ $ddate_H = $date_time[0];
+ $ddate_i = $date_time[1];
+ $ddate_s = $date_time[2];
+
+ $ddate_m = $date_arr[1];
+ $ddate_d = $date_arr[0];
+ $ddate_Y = $date_arr[2];
+ for ($j=0; $j<12; $j++) {
+ if ($ddate_m == $dmonths[$j]) {
+ $ddate_m = $j+1;
+ }
+ }
+
+ $time_zn = intval($date_arr[4]) * 36;
+ $ddate_U = gmmktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);
+ $ddate_U = $ddate_U - $time_zn;
+ $post_date = gmdate('Y-m-d H:i:s', $ddate_U + $time_difference);
+ $post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U);
+ }
+ }
+ endforeach;
+
+ $subject = trim(str_replace(get_settings('subjectprefix'), '', $subject));
+
+ if ($content_type == 'multipart/alternative') {
+ $content = explode('--'.$boundary, $content);
+ $content = $content[2];
+ $content = explode('Content-Transfer-Encoding: quoted-printable', $content);
+ $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div>');
+ }
+ $content = trim($content);
+ // Captures any text in the body after $phone_delim as the body
+ $content = explode($phone_delim, $content);
+ $content[1] ? $content = $content[1] : $content = $content[0];
+
+ echo "<p><b>Content-type:</b> $content_type, <b>boundary:</b> $boundary</p>\n";
+ echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>';
+
+ $content = trim($content);
+
+ $post_content = apply_filters('phone_content', $content);
+
+ $post_title = xmlrpc_getposttitle($content);
+
+ if ($post_title == '') $post_title = $subject;
+
+ if (empty($post_categories)) $post_categories[] = get_settings('default_email_category');
+
+ $post_category = $post_categories;
+
+ // or maybe we should leave the choice to email drafts? propose a way
+ $post_status = 'publish';
+
+ $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status');
+
+ $post_ID = wp_insert_post($post_data);
+
+ if (!$post_ID) {
+ // we couldn't post, for whatever reason. better move forward to the next email
+ continue;
+ }
+
+ do_action('publish_phone', $post_ID);
+
+ echo "\n<p><b>Author:</b> $post_author</p>";
+ echo "\n<p><b>Posted title:</b> $post_title<br />";
+ echo "\n<b>Posted content:</b><br /><pre>".$content.'</pre></p>';
+
+ if (!$post_categories) $post_categories[] = 1;
+ foreach ($post_categories as $post_category) :
+ $post_category = intval($post_category);
+
+ // Double check it's not there already
+ $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category");
+
+ if (!$exists && $result) {
+ $wpdb->query("
+ INSERT INTO $wpdb->post2cat
+ (post_id, category_id)
+ VALUES
+ ($post_ID, $post_category)
+ ");
+ }
+ endforeach;
+
+ if(!$pop3->delete($i)) {
+ echo '<p>Oops '.$pop3->ERROR.'</p></div>';
+ $pop3->reset();
+ exit;
+ } else {
+ echo "<p>Mission complete, message <strong>$i</strong> deleted.</p>";
+ }
+
+endfor;
+
+$pop3->quit();
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-newblog.php b/wp-inst/wp-newblog.php
new file mode 100644
index 0000000..25eed5f
--- /dev/null
+++ b/wp-inst/wp-newblog.php
@@ -0,0 +1,180 @@
+<?php
+require('wp-config.php');
+
+do_action( "newblogheader", "" );
+
+get_header();
+?>
+<div id="content" class="widecolumn">
+<style type="text/css">
+form { margin-top: 2em; }
+td input {
+ width: 90%;
+ font-size: 24px;
+}
+.error {
+ background-color: #FF6666;
+}
+</style>
+<?php
+
+function displayInitialForm( $weblog_id = '', $weblog_title = '', $admin_email = '', $admin_login = '', $form = '', $errormsg = '' ) {
+ print "<h2>Get your own blog</h2>";
+ if( is_array( $errormsg ) ) {
+ print "<p>There was a problem, please correct the form below and try again.</p>";
+ }
+ print '
+ <form name="setup" id="setup" method="post" action="wp-newblog.php">
+ <input type="hidden" name="stage" value="1">
+ <table border="0" width="100%">';
+ if( isset( $errormsg[ 'weblog_id' ] ) == true ) {
+ print '<tr class="error">';
+ } else {
+ print '<tr>';
+ }
+ print '
+ <th valign="top">Username:</th>
+ <td><input name="weblog_id" type="text" id="weblog_id" value="'.$weblog_id.'" maxlength="50" /><br />(This will also be your blog address. Letters and numbers only, please.)</td>
+ </tr>';
+ if( $errormsg[ 'weblog_title' ] != '' ) {
+ print '<tr class="error">';
+ } else {
+ print '<tr>';
+ }
+ print '
+ <th valign="top">Blog Name:</th>
+ <td><input name="weblog_title" type="text" id="weblog_title" value="'.wp_specialchars( $weblog_title, 1 ).'" /><br /> (Don\'t worry, you can change it later.)</td>
+ </tr>';
+ if( $errormsg[ 'admin_email' ] != '' ) {
+ print '<tr class="error">';
+ } else {
+ print '<tr>';
+ }
+ print '
+ <th valign="top">Email&nbsp;Address:</th>
+ <td><input name="admin_email" type="text" id="admin_email" value="'.wp_specialchars( $admin_email, 1 ).'" maxlength="200" /><br /> (We\'ll send a password to this address, so double-check it.)</td>
+ </tr>';
+ if( $form == 'adminform' ) {
+ print '
+ <tr class="error">
+ <th colspan="2">You have tried to setup a new domain. Please enter the administrator password for this site.</th>
+ </tr>
+ <tr>
+ <th>Admin Password:</th>
+ <td><input name="admin_pw" type="password" id="admin_pw" value="" /></td>
+ </tr>
+ ';
+ }
+ print '
+ <tr>
+ <th scope="row">&nbsp;</th>
+ <td><input type="submit" name="Submit" class="submit" value="Sign Up &raquo;" /></td>
+ </tr>';
+ do_action( "newblogform", "" );
+ print '
+ </table>
+ </form>';
+}
+
+function displaySecondForm() {
+ global $url;
+ print "<h2>You've got a new blog!</h2>";
+ print "<h3>Your new address is <a href='".$url."'>".$url."</a></h3>
+ <p>You should receive an email with the login details shortly.</p>";
+ print "<p>Visit: <a href='$url'>$url</a><br>";
+ print "Login: <a href='".$url."wp-login.php'>".$url."wp-login.php</a></p>";
+ do_action( "newblogfinished", "" );
+}
+
+/*
+ Determines the directory path - using the current script
+ */
+function determineDirPath() {
+ global $_SERVER;
+
+ $result = dirname( $_SERVER["SCRIPT_NAME"] );
+ $result = str_replace("wp-inst","",$result);
+ if( strlen( $result > 1 ) && substr($result, -1 ) == '/') {
+ $result = substr($result, 0, -1);
+ }
+
+ return $result;
+}
+
+switch( $_POST[ 'stage' ] )
+{
+ case "1":
+ $newBlogID = sanitize_title($_POST['weblog_id']);
+ $weblog_title = stripslashes( $_POST[ 'weblog_title' ] );
+ $admin_email = $_POST[ 'admin_email' ];
+
+ if( is_email( $admin_email ) == false )
+ $errormsg[ 'admin_email' ] = true;
+
+ if( empty( $newBlogID ) )
+ $errormsg[ 'weblog_id' ] = true;
+
+ if( empty( $weblog_title ) )
+ $errormsg[ 'weblog_title' ] = true;
+
+ if( is_array( $errormsg ) ) {
+ displayInitialForm( $_POST[ 'weblog_id' ], $weblog_title, $_POST[ 'admin_email' ], $_POST[ 'admin_login' ], 'userform', $errormsg );
+ } elseif( isset($newBlogID) && ($newBlogID !='' )) {
+ $scriptBaseName = determineDirPath();
+ $serverName = $_SERVER[ 'SERVER_NAME' ];
+ define( "WP_INSTALLING", true );
+ require_once('./wp-config.php');
+ // check if "main" being installed. ask for admin pw if not defined..
+ $setup = true;
+ if( $newBlogID == 'main' && isset( $_POST[ 'admin_pw' ] ) == false ) {
+ displayInitialForm( $_POST[ 'weblog_id' ], $weblog_title, $_POST[ 'admin_email' ], $_POST[ 'admin_login' ], 'adminform' );
+ $setup = false;
+ } elseif( $newBlogID == 'main' && isset( $_POST[ 'admin_pw' ] ) == true ) {
+ $query = "SELECT ID
+ FROM ".$wpdb->users."
+ WHERE user_pass = '".md5( $_POST[ 'admin_pw' ] )."'
+ AND user_login = 'admin'";
+ $admin_id = $wpdb->get_var( $query );
+ if( $admin_id != 1 ) {
+ displayInitialForm( $_POST[ 'weblog_id' ], $_POST[ 'weblog_title' ], $_POST[ 'admin_email' ], $_POST[ 'admin_login' ], 'adminform' );
+ $setup = false;
+ }
+ }
+
+
+ if( substr( $domain, 0, 4 ) == 'www.' )
+ $domain = substr( $domain, 4 );
+ if( $setup == true ) {
+ if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ if( $newBlogID == 'main' ) {
+ $url = 'http://www'.$domain.$scriptBaseName;
+ } else {
+ $url = 'http://'.$newBlogID.".".$domain.$scriptBaseName;
+ }
+ } else {
+ $url = 'http://'.$serverName.$scriptBaseName.$newBlogID."/";
+ }
+ $err = createBlog( $_SERVER[ 'HTTP_HOST' ], $domain, $scriptBaseName, $newBlogID, $weblog_title, $admin_email, $newBlogID );
+ if( $err == 'ok' ) {
+ displaySecondForm();
+ } else {
+ if( $err == 'error: username used' ) {
+ $errormsg[ 'weblog_id' ] = "Sorry, that blog already exists!";
+ } else {
+ $errormsg[ 'weblog_id' ] = "Sorry, that blog already exists!";
+ }
+ displayInitialForm( $_POST[ 'weblog_id' ], $weblog_title, $_POST[ 'admin_email' ], $_POST[ 'admin_login' ], 'userform', $errormsg );
+ }
+ }
+ } else {
+ $errormsg[ 'weblog_id' ] = "Sorry, your blog ID may only contain the characters a-z, A-Z, or 0-9!";
+ displayInitialForm( $_POST[ 'weblog_id' ], $weblog_title, $_POST[ 'admin_email' ], $_POST[ 'admin_login' ], 'userform', $errormsg );
+ }
+ break;
+ default:
+ displayInitialForm();
+ break;
+}
+?>
+</div>
+<?php get_footer(); ?>
diff --git a/wp-inst/wp-pass.php b/wp-inst/wp-pass.php
new file mode 100644
index 0000000..d7d23a6
--- /dev/null
+++ b/wp-inst/wp-pass.php
@@ -0,0 +1,11 @@
+<?php
+require( dirname(__FILE__) . '/wp-config.php');
+
+if ( get_magic_quotes_gpc() )
+ $_POST['post_password'] = stripslashes($_POST['post_password']);
+
+// 10 days
+setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH);
+
+wp_redirect($_SERVER['HTTP_REFERER']);
+?> \ No newline at end of file
diff --git a/wp-inst/wp-rdf.php b/wp-inst/wp-rdf.php
new file mode 100644
index 0000000..643ac13
--- /dev/null
+++ b/wp-inst/wp-rdf.php
@@ -0,0 +1,57 @@
+<?php /* RDF 1.0 generator, original version by garym@teledyn.com */
+
+if (empty($wp)) {
+ require_once('wp-config.php');
+ wp('feed=rdf');
+}
+
+header('Content-type: application/rdf+xml; charset=' . get_settings('blog_charset'), true);
+$more = 1;
+
+?>
+<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
+<!-- generator="wordpress/<?php echo $wp_version ?>" -->
+<rdf:RDF
+ xmlns="http://purl.org/rss/1.0/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
+ xmlns:admin="http://webns.net/mvcb/"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ <?php do_action('rdf_ns'); ?>
+>
+<channel rdf:about="<?php bloginfo_rss("url") ?>">
+ <title><?php bloginfo_rss('name') ?></title>
+ <link><?php bloginfo_rss('url') ?></link>
+ <description><?php bloginfo_rss('description') ?></description>
+ <dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date>
+ <admin:generatorAgent rdf:resource="http://wordpress.org/?v=<?php echo $wp_version ?>"/>
+ <sy:updatePeriod>hourly</sy:updatePeriod>
+ <sy:updateFrequency>1</sy:updateFrequency>
+ <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
+ <?php do_action('rdf_header'); ?>
+ <items>
+ <rdf:Seq>
+ <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+ <rdf:li rdf:resource="<?php permalink_single_rss() ?>"/>
+ <?php $wp_items[] = $row; $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
+ </rdf:Seq>
+ </items>
+</channel>
+<?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+<item rdf:about="<?php permalink_single_rss() ?>">
+ <title><?php the_title_rss() ?></title>
+ <link><?php permalink_single_rss() ?></link>
+ <dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_date_gmt, false); ?></dc:date>
+ <dc:creator><?php the_author() ?></dc:creator>
+ <?php the_category_rss('rdf') ?>
+<?php if (get_settings('rss_use_excerpt')) : ?>
+ <description><?php the_excerpt_rss() ?></description>
+<?php else : ?>
+ <description><?php the_content_rss('', 0, '', get_settings('rss_excerpt_length'), 2) ?></description>
+ <content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>
+<?php endif; ?>
+ <?php do_action('rdf_item'); ?>
+</item>
+<?php } } ?>
+</rdf:RDF> \ No newline at end of file
diff --git a/wp-inst/wp-register.php b/wp-inst/wp-register.php
new file mode 100644
index 0000000..4a3e0d3
--- /dev/null
+++ b/wp-inst/wp-register.php
@@ -0,0 +1,154 @@
+<?php
+require('./wp-config.php');
+require_once( ABSPATH . WPINC . '/registration-functions.php');
+
+$action = $_REQUEST['action'];
+if ( !get_settings('users_can_register') )
+ $action = 'disabled';
+
+header( 'Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset') );
+
+switch( $action ) {
+
+case 'register':
+
+ $user_login = sanitize_user( $_POST['user_login'] );
+ $user_email = $_POST['user_email'];
+
+ if ( $user_login == '' )
+ die (__('<strong>ERROR</strong>: Please enter a username.'));
+
+ /* checking e-mail address */
+ if ($user_email == '') {
+ die (__('<strong>ERROR</strong>: Please type your e-mail address.'));
+ } else if (!is_email($user_email)) {
+ die (__('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
+ }
+
+ if ( username_exists( $user_login ) )
+ die (__('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
+
+ $user_level = get_settings('new_users_can_blog');
+ $password = substr( md5( uniqid( microtime() ) ), 0, 7);
+
+ $user_id = create_user( $user_login, $password, $user_email, $user_level );
+
+ do_action('user_register', $user_id);
+
+ if ( !$user_id ) {
+ die (sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email')));
+ }
+
+ $stars = '';
+ for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
+ $stars .= '*';
+ }
+
+ $message = sprintf(__('Username: %s'), $user_login) . "\r\n";
+ $message .= sprintf(__('Password: %s'), $password) . "\r\n";
+ $message .= get_settings('siteurl') . "/wp-login.php\r\n";
+
+ wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
+
+ $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
+ $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
+ $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
+
+ @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
+
+ ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>WordPress &raquo; <?php _e('Registration Complete') ?></title>
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
+ <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
+ <style type="text/css">
+ .submit {
+ font-size: 1.7em;
+ }
+ </style>
+</head>
+<body>
+
+<div id="login">
+ <h2><?php _e('Registration Complete') ?></h2>
+ <p><?php printf(__('Username: %s'), "<strong>$user_login</strong>") ?><br />
+ <?php printf(__('Password: %s'), '<strong>' . __('emailed to you') . '</strong>') ?> <br />
+ <?php printf(__('E-mail: %s'), "<strong>$user_email</strong>") ?></p>
+ <p class="submit"><a href="wp-login.php"><?php _e('Login'); ?> &raquo;</a></p>
+</div>
+</body>
+</html>
+
+ <?php
+break;
+
+case 'disabled':
+
+ ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>WordPress &raquo; <?php _e('Registration Currently Disabled') ?></title>
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>">
+ <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css">
+</head>
+
+<body>
+
+<div id="login">
+ <h2><?php _e('Registration Disabled') ?></h2>
+ <p><?php _e('User registration is currently not allowed.') ?><br />
+ <a href="<?php echo get_settings('home') . '/'; ?>" title="<?php _e('Go back to the blog') ?>"><?php _e('Home') ?></a>
+ </p>
+</div>
+
+</body>
+</html>
+
+ <?php
+break;
+
+default:
+
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>WordPress &raquo; <?php _e('Registration Form') ?></title>
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
+ <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
+ <style type="text/css">
+ #user_email, #user_login, #submit {
+ font-size: 1.7em;
+ }
+ </style>
+</head>
+
+<body>
+<div id="login">
+<h1><a href="http://wordpress.org/">WordPress</a></h1>
+<h2><?php _e('Register for this blog') ?></h2>
+
+<form method="post" action="wp-register.php" id="registerform">
+ <p><input type="hidden" name="action" value="register" />
+ <label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" /><br /></p>
+ <p><label for="user_email"><?php _e('E-mail:') ?></label><br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" /></p>
+ <p>A password will be emailed to you.</p>
+ <p class="submit"><input type="submit" value="<?php _e('Register') ?> &raquo;" id="submit" name="submit" /></p>
+</form>
+<ul>
+ <li><a href="<?php bloginfo('home'); ?>" title="<?php _e('Are you lost?') ?>">&laquo; <?php _e('Back to blog') ?></a></li>
+ <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li>
+ <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li>
+</ul>
+</div>
+
+</body>
+</html>
+<?php
+
+break;
+}
+?> \ No newline at end of file
diff --git a/wp-inst/wp-rss.php b/wp-inst/wp-rss.php
new file mode 100644
index 0000000..aa4a636
--- /dev/null
+++ b/wp-inst/wp-rss.php
@@ -0,0 +1,37 @@
+<?php
+
+if (empty($wp)) {
+ require_once('wp-config.php');
+ wp('feed=rss');
+}
+
+header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
+$more = 1;
+
+?>
+<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
+<!-- generator="wordpress/<?php echo $wp_version ?>" -->
+<rss version="0.92">
+<channel>
+ <title><?php bloginfo_rss('name') ?></title>
+ <link><?php bloginfo_rss('url') ?></link>
+ <description><?php bloginfo_rss('description') ?></description>
+ <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
+ <docs>http://backend.userland.com/rss092</docs>
+ <language><?php echo get_option('rss_language'); ?></language>
+ <?php do_action('rss_head'); ?>
+
+<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+ <item>
+ <title><?php the_title_rss() ?></title>
+<?php if (get_settings('rss_use_excerpt')) { ?>
+ <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
+<?php } else { // use content ?>
+ <description><?php the_content_rss('', 0, '', get_settings('rss_excerpt_length')) ?></description>
+<?php } ?>
+ <link><?php permalink_single_rss() ?></link>
+ <?php do_action('rss_item'); ?>
+ </item>
+<?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
+</channel>
+</rss>
diff --git a/wp-inst/wp-rss2.php b/wp-inst/wp-rss2.php
new file mode 100644
index 0000000..4fc9150
--- /dev/null
+++ b/wp-inst/wp-rss2.php
@@ -0,0 +1,56 @@
+<?php
+
+if (empty($wp)) {
+ require_once('wp-config.php');
+ wp('feed=rss2');
+}
+
+header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
+$more = 1;
+
+?>
+<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
+
+<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" -->
+<rss version="2.0"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ <?php do_action('rss2_ns'); ?>
+>
+
+<channel>
+ <title><?php bloginfo_rss('name'); ?></title>
+ <link><?php bloginfo_rss('url') ?></link>
+ <description><?php bloginfo_rss("description") ?></description>
+ <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
+ <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
+ <language><?php echo get_option('rss_language'); ?></language>
+ <?php do_action('rss2_head'); ?>
+ <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+ <item>
+ <title><?php the_title_rss() ?></title>
+ <link><?php permalink_single_rss() ?></link>
+ <comments><?php comments_link(); ?></comments>
+ <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
+ <dc:creator><?php the_author() ?></dc:creator>
+ <?php the_category_rss() ?>
+
+ <guid><?php the_permalink($id); ?></guid>
+<?php if (get_settings('rss_use_excerpt')) : ?>
+ <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
+<?php else : ?>
+ <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
+ <?php if ( strlen( $post->post_content ) > 0 ) : ?>
+ <content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>
+ <?php else : ?>
+ <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
+ <?php endif; ?>
+<?php endif; ?>
+ <wfw:commentRSS><?php echo comments_rss(); ?></wfw:commentRSS>
+<?php rss_enclosure(); ?>
+ <?php do_action('rss2_item'); ?>
+ </item>
+ <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
+</channel>
+</rss>
diff --git a/wp-inst/wp-settings.php b/wp-inst/wp-settings.php
new file mode 100644
index 0000000..2ac3d38
--- /dev/null
+++ b/wp-inst/wp-settings.php
@@ -0,0 +1,220 @@
+<?php
+$HTTP_HOST = getenv('HTTP_HOST'); /* domain name */
+$REMOTE_ADDR = getenv('REMOTE_ADDR'); /* visitor's IP */
+$HTTP_USER_AGENT = getenv('HTTP_USER_AGENT'); /* visitor's browser */
+
+// Fix for IIS, which doesn't set REQUEST_URI
+if (! isset($_SERVER['REQUEST_URI'])) {
+ $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
+
+ // Append the query string if it exists and isn't null
+ if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
+ $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
+ }
+}
+
+if ( !(phpversion() >= '4.1') )
+ die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' );
+
+if ( !extension_loaded('mysql') )
+ die( 'Your PHP installation appears to be missing the MySQL which is required for WordPress.' );
+
+function timer_start() {
+ global $timestart;
+ $mtime = explode(' ', microtime() );
+ $mtime = $mtime[1] + $mtime[0];
+ $timestart = $mtime;
+ return true;
+}
+timer_start();
+
+// Change to E_ALL for development/debugging
+error_reporting(E_ALL ^ E_NOTICE);
+
+// For an advanced caching plugin to use, static because you would only want one
+if ( defined('WP_CACHE') )
+ require (ABSPATH . 'wp-content/advanced-cache.php');
+
+define('WPINC', 'wp-includes');
+require_once (ABSPATH . WPINC . '/wp-db.php');
+
+$wpdb->blogs = $table_prefix . 'blogs';
+$wpdb->users = $table_prefix . 'users';
+$wpdb->usermeta = $table_prefix . 'usermeta';
+$wpdb->site = $table_prefix . 'site';
+$wpdb->sitemeta = $table_prefix . 'sitemeta';
+
+// find out what tables to use from $wpblog
+$wpdb->hide_errors();
+$query = "SELECT id
+ FROM ".$wpdb->site."
+ WHERE domain = '".$domain."'
+ AND path = '".$base."'";
+$site_id = $wpdb->get_var( $query );
+
+$query = "SELECT blog_id, is_public
+ FROM ".$wpdb->blogs."
+ WHERE site_id = '".$site_id."'
+ AND blogname = '".$wpblog."'";
+$result = $wpdb->get_row( $query, ARRAY_A );
+$blog_id = $result[ 'blog_id' ];
+$is_public = $result[ 'is_public' ];
+if( $blog_id == false ) {
+ // no blog found, are we installing? Check if the table exists.
+ if ( defined('WP_INSTALLING') ) {
+ $query = "SELECT blog_id FROM ".$wpdb->blogs." limit 0,1";
+ $blog_id = $wpdb->get_var( $query );
+ if( $blog_id == false ) {
+ // table doesn't exist. This is the first blog
+ $blog_id = 1;
+ } else {
+ // table exists
+ // don't create record at this stage. we're obviously installing so it doesn't matter what the table vars below are like.
+ // default to using the "main" blog.
+ $blog_id = 1;
+ }
+ } else {
+ die( "No Blog by that name on this system." );
+ }
+}
+
+if( $is_public == 'no' ) {
+ // need to put checks in here?
+ // A hook?
+ die( "This blog is private." );
+}
+
+$wpdb->show_errors();
+
+$table_prefix = $table_prefix.$blog_id."_";
+
+// Table names
+$wpdb->siteid = $site_id;
+$wpdb->blogid = $blog_id;
+$wpdb->posts = $table_prefix . 'posts';
+$wpdb->categories = $table_prefix . 'categories';
+$wpdb->post2cat = $table_prefix . 'post2cat';
+$wpdb->comments = $table_prefix . 'comments';
+$wpdb->links = $table_prefix . 'links';
+$wpdb->linkcategories = $table_prefix . 'linkcategories';
+$wpdb->options = $table_prefix . 'options';
+$wpdb->postmeta = $table_prefix . 'postmeta';
+$wpdb->prefix = $table_prefix;
+
+if ( defined('CUSTOM_USER_TABLE') )
+ $wpdb->users = CUSTOM_USER_TABLE;
+if ( defined('CUSTOM_USER_META_TABLE') )
+ $wpdb->usermeta = CUSTOM_USER_META_TABLE;
+
+// We're going to need to keep this around for a few months even though we're not using it internally
+
+$tableposts = $wpdb->posts;
+$tableusers = $wpdb->users;
+$tablecategories = $wpdb->categories;
+$tablepost2cat = $wpdb->post2cat;
+$tablecomments = $wpdb->comments;
+$tablelinks = $wpdb->links;
+$tablelinkcategories = $wpdb->linkcategories;
+$tableoptions = $wpdb->options;
+$tablepostmeta = $wpdb->postmeta;
+
+require (ABSPATH . WPINC . '/functions.php');
+require (ABSPATH . WPINC . '/default-filters.php');
+require_once (ABSPATH . WPINC . '/wp-l10n.php');
+
+$wpdb->hide_errors();
+if ( !update_user_cache() && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) {
+ if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
+ $link = 'install.php';
+ else
+ $link = 'wp-admin/install.php';
+ die(sprintf(__("It doesn't look like you've installed WP yet. Try running <a href='%s'>install.php</a>."), $link));
+}
+$wpdb->show_errors();
+
+require (ABSPATH . WPINC . '/functions-formatting.php');
+require (ABSPATH . WPINC . '/functions-post.php');
+require (ABSPATH . WPINC . '/classes.php');
+require (ABSPATH . WPINC . '/template-functions-general.php');
+require (ABSPATH . WPINC . '/template-functions-links.php');
+require (ABSPATH . WPINC . '/template-functions-author.php');
+require (ABSPATH . WPINC . '/template-functions-post.php');
+require (ABSPATH . WPINC . '/template-functions-category.php');
+require (ABSPATH . WPINC . '/comment-functions.php');
+require (ABSPATH . WPINC . '/feed-functions.php');
+require (ABSPATH . WPINC . '/links.php');
+require (ABSPATH . WPINC . '/kses.php');
+require (ABSPATH . WPINC . '/version.php');
+
+$is_archived = get_settings( "is_archived" );
+if( $is_archived == 'yes' ) {
+ die( "This blog has been archived or suspended temporarily. Please check back later." );
+}
+
+if (!strstr($_SERVER['PHP_SELF'], 'install.php') && !strstr($_SERVER['PHP_SELF'], 'wp-admin/import')) :
+ // Used to guarantee unique hash cookies
+ $cookiehash = md5(get_settings('siteurl')); // Remove in 1.4
+ define('COOKIEHASH', $cookiehash);
+endif;
+
+require (ABSPATH . WPINC . '/vars.php');
+
+do_action('core_files_loaded');
+
+// Check for hacks file if the option is enabled
+if (get_settings('hack_file')) {
+ if (file_exists(ABSPATH . '/my-hacks.php'))
+ require(ABSPATH . '/my-hacks.php');
+}
+
+if ( get_settings('active_plugins') ) {
+ $current_plugins = get_settings('active_plugins');
+ if ( is_array($current_plugins) ) {
+ foreach ($current_plugins as $plugin) {
+ if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
+ include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
+ }
+ }
+}
+
+require (ABSPATH . WPINC . '/pluggable-functions.php');
+
+if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
+ wp_cache_postload();
+
+do_action('plugins_loaded');
+
+define('TEMPLATEPATH', get_template_directory());
+
+// Load the default text localization domain.
+load_default_textdomain();
+
+// Pull in locale data after loading text domain.
+require_once(ABSPATH . WPINC . '/locale.php');
+
+// If already slashed, strip.
+if ( get_magic_quotes_gpc() ) {
+ $_GET = stripslashes_deep($_GET );
+ $_POST = stripslashes_deep($_POST );
+ $_COOKIE = stripslashes_deep($_COOKIE);
+ $_SERVER = stripslashes_deep($_SERVER);
+}
+
+// Escape with wpdb.
+$_GET = add_magic_quotes($_GET );
+$_POST = add_magic_quotes($_POST );
+$_COOKIE = add_magic_quotes($_COOKIE);
+$_SERVER = add_magic_quotes($_SERVER);
+
+function shutdown_action_hook() {
+ do_action('shutdown');
+}
+register_shutdown_function('shutdown_action_hook');
+
+$wp_query = new WP_Query();
+$wp_rewrite = new WP_Rewrite();
+$wp = new WP();
+
+// Everything is loaded and initialized.
+do_action('init');
+?>
diff --git a/wp-inst/wp-trackback.php b/wp-inst/wp-trackback.php
new file mode 100644
index 0000000..e671710
--- /dev/null
+++ b/wp-inst/wp-trackback.php
@@ -0,0 +1,93 @@
+<?php
+
+if (empty($wp)) {
+ require_once('wp-config.php');
+ wp('tb=1');
+}
+
+function trackback_response($error = 0, $error_message = '') {
+ header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
+ if ($error) {
+ echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
+ echo "<response>\n";
+ echo "<error>1</error>\n";
+ echo "<message>$error_message</message>\n";
+ echo "</response>";
+ die();
+ } else {
+ echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
+ echo "<response>\n";
+ echo "<error>0</error>\n";
+ echo "</response>";
+ }
+}
+
+// trackback is done by a POST
+$request_array = 'HTTP_POST_VARS';
+
+if ( !$_GET['tb_id'] ) {
+ $tb_id = explode('/', $_SERVER['REQUEST_URI']);
+ $tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
+}
+
+$tb_url = $_POST['url'];
+$title = $_POST['title'];
+$excerpt = $_POST['excerpt'];
+$blog_name = $_POST['blog_name'];
+$charset = $_POST['charset'];
+
+if ($charset)
+ $charset = strtoupper( trim($charset) );
+else
+ $charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
+
+if ( function_exists('mb_convert_encoding') ) { // For international trackbacks
+ $title = mb_convert_encoding($title, get_settings('blog_charset'), $charset);
+ $excerpt = mb_convert_encoding($excerpt, get_settings('blog_charset'), $charset);
+ $blog_name = mb_convert_encoding($blog_name, get_settings('blog_charset'), $charset);
+}
+
+if ( is_single() || is_page() )
+ $tb_id = $posts[0]->ID;
+
+if ( !intval( $tb_id ) )
+ trackback_response(1, 'I really need an ID for this to work.');
+
+if (empty($title) && empty($tb_url) && empty($blog_name)) {
+ // If it doesn't look like a trackback at all...
+ header('Location: ' . get_permalink($tb_id));
+ exit;
+}
+
+if ( !empty($tb_url) && !empty($title) && !empty($tb_url) ) {
+ header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
+
+ $pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
+
+ if ( 'open' != $pingstatus )
+ trackback_response(1, 'Sorry, trackbacks are closed for this item.');
+
+ $title = wp_specialchars( strip_tags( $title ) );
+ $title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
+ $excerpt = strip_tags($excerpt);
+ $excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt;
+
+ $comment_post_ID = $tb_id;
+ $comment_author = $blog_name;
+ $comment_author_email = '';
+ $comment_author_url = $tb_url;
+ $comment_content = "<strong>$title</strong>\n\n$excerpt";
+ $comment_type = 'trackback';
+
+ $dupe = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_author_url = '$comment_author_url'");
+ if ( $dupe )
+ trackback_response(1, 'We already have a ping from that URI for this post.');
+
+ $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
+
+ wp_new_comment($commentdata);
+
+ do_action('trackback_post', $wpdb->insert_id);
+ trackback_response(0);
+}
+?> \ No newline at end of file
diff --git a/wp-inst/wp.php b/wp-inst/wp.php
new file mode 100644
index 0000000..336dd1c
--- /dev/null
+++ b/wp-inst/wp.php
@@ -0,0 +1,48 @@
+<?php
+// This is an example of a very simple template
+require_once('./wp-blog-header.php');
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml/DTD/xhtml-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
+ <meta name="generator" content="WordPress <?php $wp_version ?>" /> <!-- leave this for stats -->
+ <link rel="alternate" type="text/xml" title="RSS" href="<?php bloginfo('rss2_url'); ?>" />
+ <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
+</head>
+<body>
+<h1 id="header"><a href="<?php echo get_settings('home'); ?>" title="<?php bloginfo('name'); ?>"><?php bloginfo('name'); ?></a></h1>
+
+<!-- // loop start -->
+<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
+<?php the_date('d.m.y', '<h2>','</h2>'); ?>
+<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h3>
+
+<?php the_content(); ?>
+
+<?php link_pages('<br />Pages: ', '<br />', 'number') ?>
+
+<p><em>Posted by <strong><?php the_author() ?></strong> @ <a href="<?php the_permalink() ?>"><?php the_time() ?></a></em></p>
+<p>Filed under: <?php the_category(',') ?></p>
+
+<?php comments_popup_link('comments ?', '1 comment', '% comments') ?>
+
+<?php comments_template(); ?>
+
+
+<!-- // this is just the end of the motor - don't touch that line either :) -->
+<?php endwhile; else: ?>
+<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
+<?php endif; ?>
+
+<div align="right"><cite>Powered by <a href="http://wordpress.org"><strong>Wordpress</strong></a></cite><br />
+<br />
+<a href="wp-login.php">login</a><br />
+<a href="wp-register.php">register</a>
+</div>
+
+
+</body>
+</html> \ No newline at end of file
diff --git a/wp-inst/wpmu-settings.php.dist b/wp-inst/wpmu-settings.php.dist
new file mode 100644
index 0000000..2a571e9
--- /dev/null
+++ b/wp-inst/wpmu-settings.php.dist
@@ -0,0 +1,91 @@
+<?php
+
+ini_set( "safe_mode", 1 );
+
+$base="BASE";
+
+if( isset( $_REQUEST[ 'wpblog' ] ) ) $wpblog = $_REQUEST[ 'wpblog' ];
+
+if( isset( $wpblog ) == false )
+{
+ if( $base != '/' )
+ {
+ $wpblog = str_replace( $base, "", $_SERVER[ 'REQUEST_URI' ] );
+ }
+ else
+ {
+ $wpblog = substr( $_SERVER[ 'REQUEST_URI' ], 0, strrpos( $_SERVER[ 'REQUEST_URI' ], "/" ) );
+ }
+ if( strrpos( $wpblog, "/" ) > 0 )
+ {
+ $wpblog = substr( $wpblog, 0, strpos( substr( $wpblog, 1 ) , "/" )+1 );
+ }
+ $wpblog = str_replace( $base, "", $wpblog );
+}
+
+$hostname = $_SERVER[ 'HTTP_HOST' ];
+$domain = $_SERVER[ 'HTTP_HOST' ];
+if( substr_count( $domain, '.' ) > 1 ) {
+ $vhostblog = substr( $domain, 0, strpos( $domain, '.' ) );
+ $basedomain = str_replace( $vhostblog.".", "", $domain );
+ $domain = str_replace( $vhostblog.".", "", $domain );
+} else {
+ $basedomain = $domain;
+ $vhostblog = "main";
+}
+
+if( strpos( $wpblog, "?" ) ) {
+ $wpblog = substr( $wpblog, 0, strpos( $wpblog, "?" ) );
+}
+if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ if( $vhostblog != 'www' && $vhostblog != '' ) {
+ $wpblog = $vhostblog;
+ } else {
+ $wpblog = "main";
+ }
+} elseif( $wpblog == '' ) {
+ $wpblog = 'main';
+} elseif( $wpblog != 'main' && ( is_file( ABSPATH . $wpblog ) == true || is_dir( ABSPATH . $wpblog ) == true ) ) {
+ $wpblog = 'main';
+}
+
+require_once( ABSPATH.'wp-includes/class-smarty.php' );
+$wpmuBaseTablePrefix = $table_prefix;
+define ('WPLANG', '');
+$server = DB_HOST;
+$loginsql = DB_USER;
+$passsql = DB_PASSWORD;
+
+require_once( ABSPATH.'wp-settings.php' );
+require_once( ABSPATH.'wp-includes/wpmu-functions.php' );
+
+$plugins = glob( ABSPATH . 'wp-content/mu-plugins/*.php');
+
+if( $plugins ) {
+ foreach ( $plugins as $plugin ) {
+ include_once( $plugin );
+ }
+}
+
+
+if( $redirect )
+{
+ if( $p )
+ {
+ $url = get_permalink( $p );
+ }
+ elseif( $m )
+ {
+ $url = get_settings( 'siteurl' )."/".substr( $m, 0, 4 )."/".substr( $m, 4, 2 );
+ }
+ elseif( $cat )
+ {
+ $query = "SELECT cat_name FROM ".$wpdb->categories." WHERE cat_ID='$cat'";
+ $cat_name = $wpdb->get_var( $query );
+ $url = get_settings( 'siteurl' ). "/category/".$cat_name;
+ }
+ header("HTTP/1.0 301 Moved Permanently");
+ header( "Location: $url" );
+ exit;
+}
+?>
diff --git a/wp-inst/xmlrpc.php b/wp-inst/xmlrpc.php
new file mode 100644
index 0000000..a00abc0
--- /dev/null
+++ b/wp-inst/xmlrpc.php
@@ -0,0 +1,1313 @@
+<?php
+
+# fix for mozBlog and other cases where '<?xml' isn't on the very first line
+$HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
+
+include('./wp-config.php');
+include_once(ABSPATH . WPINC . '/class-IXR.php');
+
+// Turn off all warnings and errors.
+// error_reporting(0);
+
+$post_default_title = ""; // posts submitted via the xmlrpc interface get that title
+
+$xmlrpc_logging = 0;
+
+function logIO($io,$msg) {
+ global $xmlrpc_logging;
+ if ($xmlrpc_logging) {
+ $fp = fopen("../xmlrpc.log","a+");
+ $date = gmdate("Y-m-d H:i:s ");
+ $iot = ($io == "I") ? " Input: " : " Output: ";
+ fwrite($fp, "\n\n".$date.$iot.$msg);
+ fclose($fp);
+ }
+ return true;
+ }
+
+function starify($string) {
+ $i = strlen($string);
+ return str_repeat('*', $i);
+}
+
+logIO("I", $HTTP_RAW_POST_DATA);
+
+
+function mkdir_p($target) {
+ // from php.net/mkdir user contributed notes
+ if (file_exists($target)) {
+ if (!is_dir($target)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ // Attempting to create the directory may clutter up our display.
+ if (@mkdir($target)) {
+ return true;
+ }
+
+ // If the above failed, attempt to create the parent node, then try again.
+ if (mkdir_p(dirname($target))) {
+ return mkdir_p($target);
+ }
+
+ return false;
+}
+
+
+class wp_xmlrpc_server extends IXR_Server {
+
+ function wp_xmlrpc_server() {
+ $this->methods = array(
+ // Blogger API
+ 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
+ 'blogger.getUserInfo' => 'this:blogger_getUserInfo',
+ 'blogger.getPost' => 'this:blogger_getPost',
+ 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts',
+ 'blogger.getTemplate' => 'this:blogger_getTemplate',
+ 'blogger.setTemplate' => 'this:blogger_setTemplate',
+ 'blogger.newPost' => 'this:blogger_newPost',
+ 'blogger.editPost' => 'this:blogger_editPost',
+ 'blogger.deletePost' => 'this:blogger_deletePost',
+
+ // MetaWeblog API (with MT extensions to structs)
+ 'metaWeblog.newPost' => 'this:mw_newPost',
+ 'metaWeblog.editPost' => 'this:mw_editPost',
+ 'metaWeblog.getPost' => 'this:mw_getPost',
+ 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts',
+ 'metaWeblog.getCategories' => 'this:mw_getCategories',
+ 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject',
+
+ // MetaWeblog API aliases for Blogger API
+ // see http://www.xmlrpc.com/stories/storyReader$2460
+ 'metaWeblog.deletePost' => 'this:blogger_deletePost',
+ 'metaWeblog.getTemplate' => 'this:blogger_getTemplate',
+ 'metaWeblog.setTemplate' => 'this:blogger_setTemplate',
+ 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs',
+
+ // MovableType API
+ 'mt.getCategoryList' => 'this:mt_getCategoryList',
+ 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles',
+ 'mt.getPostCategories' => 'this:mt_getPostCategories',
+ 'mt.setPostCategories' => 'this:mt_setPostCategories',
+ 'mt.supportedMethods' => 'this:mt_supportedMethods',
+ 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters',
+ 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings',
+ 'mt.publishPost' => 'this:mt_publishPost',
+
+ // PingBack
+ 'pingback.ping' => 'this:pingback_ping',
+ 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',
+
+ 'demo.sayHello' => 'this:sayHello',
+ 'demo.addTwoNumbers' => 'this:addTwoNumbers'
+ );
+ $this->methods = apply_filters('xmlrpc_methods', $this->methods);
+ $this->IXR_Server($this->methods);
+ }
+
+ function sayHello($args) {
+ return 'Hello!';
+ }
+
+ function addTwoNumbers($args) {
+ $number1 = $args[0];
+ $number2 = $args[1];
+ return $number1 + $number2;
+ }
+
+ function login_pass_ok($user_login, $user_pass) {
+ if (!user_pass_ok($user_login, $user_pass)) {
+ $this->error = new IXR_Error(403, 'Bad login/pass combination.');
+ return false;
+ }
+ return true;
+ }
+
+ function escape(&$array) {
+ global $wpdb;
+
+ foreach ($array as $k => $v) {
+ if (is_array($v)) {
+ $this->escape($array[$k]);
+ } else if (is_object($v)) {
+ //skip
+ } else {
+ $array[$k] = $wpdb->escape($v);
+ }
+ }
+ }
+
+ /* Blogger API functions
+ * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
+ */
+
+
+ /* blogger.getUsersBlogs will make more sense once we support multiple blogs */
+ function blogger_getUsersBlogs($args) {
+
+ $this->escape($args);
+
+ $user_login = $args[1];
+ $user_pass = $args[2];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+ $is_admin = $user_data->user_level > 3;
+
+ $struct = array(
+ 'isAdmin' => $is_admin,
+ 'url' => get_settings('home') . '/',
+ 'blogid' => '1',
+ 'blogName' => get_settings('blogname')
+ );
+
+ return array($struct);
+ }
+
+
+ /* blogger.getUsersInfo gives your client some info about you, so you don't have to */
+ function blogger_getUserInfo($args) {
+
+ $this->escape($args);
+
+ $user_login = $args[1];
+ $user_pass = $args[2];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+
+ $struct = array(
+ 'nickname' => $user_data->nickname,
+ 'userid' => $user_data->ID,
+ 'url' => $user_data->user_url,
+ 'email' => $user_data->user_email,
+ 'lastname' => $user_data->last_name,
+ 'firstname' => $user_data->first_name
+ );
+
+ return $struct;
+ }
+
+
+ /* blogger.getPost ...gets a post */
+ function blogger_getPost($args) {
+
+ $this->escape($args);
+
+ $post_ID = $args[1];
+ $user_login = $args[2];
+ $user_pass = $args[3];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+ $post_data = wp_get_single_post($post_ID, ARRAY_A);
+
+ $categories = implode(',', wp_get_post_cats(1, $post_ID));
+
+ $content = '<title>'.stripslashes($post_data['post_title']).'</title>';
+ $content .= '<category>'.$categories.'</category>';
+ $content .= stripslashes($post_data['post_content']);
+
+ $struct = array(
+ 'userid' => $post_data['post_author'],
+ 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'])),
+ 'content' => $content,
+ 'postid' => $post_data['ID']
+ );
+
+ return $struct;
+ }
+
+
+ /* blogger.getRecentPosts ...gets recent posts */
+ function blogger_getRecentPosts($args) {
+
+ global $wpdb;
+
+ $this->escape($args);
+
+ $blog_ID = $args[1]; /* though we don't use it yet */
+ $user_login = $args[2];
+ $user_pass = $args[3];
+ $num_posts = $args[4];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $posts_list = wp_get_recent_posts($num_posts);
+
+ if (!$posts_list) {
+ $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
+ return $this->error;
+ }
+
+ foreach ($posts_list as $entry) {
+
+ $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
+ $categories = implode(',', wp_get_post_cats(1, $entry['ID']));
+
+ $content = '<title>'.stripslashes($entry['post_title']).'</title>';
+ $content .= '<category>'.$categories.'</category>';
+ $content .= stripslashes($entry['post_content']);
+
+ $struct[] = array(
+ 'userid' => $entry['post_author'],
+ 'dateCreated' => new IXR_Date($post_date),
+ 'content' => $content,
+ 'postid' => $entry['ID'],
+ );
+
+ }
+
+ $recent_posts = array();
+ for ($j=0; $j<count($struct); $j++) {
+ array_push($recent_posts, $struct[$j]);
+ }
+
+ return $recent_posts;
+ }
+
+
+ /* blogger.getTemplate returns your blog_filename */
+ function blogger_getTemplate($args) {
+
+ $this->escape($args);
+
+ $blog_ID = $args[1];
+ $user_login = $args[2];
+ $user_pass = $args[3];
+ $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+
+ if ($user_data->user_level < 3) {
+ return new IXR_Error(401, 'Sorry, users whose level is less than 3, can not edit the template.');
+ }
+
+ /* warning: here we make the assumption that the weblog's URI is on the same server */
+ $filename = get_settings('home') . '/';
+ $filename = preg_replace('#http://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
+
+ $f = fopen($filename, 'r');
+ $content = fread($f, filesize($filename));
+ fclose($f);
+
+ /* so it is actually editable with a windows/mac client */
+ // FIXME: (or delete me) do we really want to cater to bad clients at the expense of good ones by BEEPing up their line breaks? commented. $content = str_replace("\n", "\r\n", $content);
+
+ return $content;
+ }
+
+
+ /* blogger.setTemplate updates the content of blog_filename */
+ function blogger_setTemplate($args) {
+
+ $this->escape($args);
+
+ $blog_ID = $args[1];
+ $user_login = $args[2];
+ $user_pass = $args[3];
+ $content = $args[4];
+ $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+
+ if ($user_data->user_level < 3) {
+ return new IXR_Error(401, 'Sorry, users whose level is less than 3, can not edit the template.');
+ }
+
+ /* warning: here we make the assumption that the weblog's URI is on the same server */
+ $filename = get_settings('home') . '/';
+ $filename = preg_replace('#http://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
+
+ if ($f = fopen($filename, 'w+')) {
+ fwrite($f, $content);
+ fclose($f);
+ } else {
+ return new IXR_Error(500, 'Either the file is not writable, or something wrong happened. The file has not been updated.');
+ }
+
+ return true;
+ }
+
+
+ /* blogger.newPost ...creates a new post */
+ function blogger_newPost($args) {
+
+ global $wpdb;
+
+ $this->escape($args);
+
+ $blog_ID = $args[1]; /* though we don't use it yet */
+ $user_login = $args[2];
+ $user_pass = $args[3];
+ $content = $args[4];
+ $publish = $args[5];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+ if (!user_can_create_post($user_data->ID, $blog_ID)) {
+ return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
+ }
+
+ $post_status = ($publish) ? 'publish' : 'draft';
+
+ $post_author = $user_data->ID;
+
+ $post_title = xmlrpc_getposttitle($content);
+ $post_category = xmlrpc_getpostcategory($content);
+
+ $content = xmlrpc_removepostdata($content);
+ $post_content = apply_filters( 'content_save_pre', $content );
+
+ $post_date = current_time('mysql');
+ $post_date_gmt = current_time('mysql', 1);
+
+ $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status');
+
+ $post_ID = wp_insert_post($post_data);
+
+ if (!$post_ID) {
+ return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');
+ }
+
+ logIO('O', "Posted ! ID: $post_ID");
+
+ return $post_ID;
+ }
+
+
+ /* blogger.editPost ...edits a post */
+ function blogger_editPost($args) {
+
+ global $wpdb;
+
+ $this->escape($args);
+
+ $post_ID = $args[1];
+ $user_login = $args[2];
+ $user_pass = $args[3];
+ $new_content = $args[4];
+ $publish = $args[5];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $actual_post = wp_get_single_post($post_ID,ARRAY_A);
+
+ if (!$actual_post) {
+ return new IXR_Error(404, 'Sorry, no such post.');
+ }
+
+ $this->escape($actual_post);
+
+ $post_author_data = get_userdata($actual_post['post_author']);
+ $user_data = get_userdatabylogin($user_login);
+
+ if (!user_can_edit_post($user_data->ID, $post_ID)) {
+ return new IXR_Error(401, 'Sorry, you do not have the right to edit this post.');
+ }
+
+ extract($actual_post);
+
+ $content = $newcontent;
+
+ $post_title = xmlrpc_getposttitle($content);
+ $post_category = xmlrpc_getpostcategory($content);
+
+ $content = xmlrpc_removepostdata($content);
+ $post_content = apply_filters( 'content_save_pre', $content );
+
+ $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt');
+
+ $result = wp_update_post($postdata);
+
+ if (!$result) {
+ return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be edited.');
+ }
+
+ return true;
+ }
+
+
+ /* blogger.deletePost ...deletes a post */
+ function blogger_deletePost($args) {
+
+ global $wpdb;
+
+ $this->escape($args);
+
+ $post_ID = $args[1];
+ $user_login = $args[2];
+ $user_pass = $args[3];
+ $publish = $args[4];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $actual_post = wp_get_single_post($post_ID,ARRAY_A);
+
+ if (!$actual_post) {
+ return new IXR_Error(404, 'Sorry, no such post.');
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+
+ if (!user_can_delete_post($user_data->ID, $post_ID)) {
+ return new IXR_Error(401, 'Sorry, you do not have the right to delete this post.');
+ }
+
+ $result = wp_delete_post($post_ID);
+
+ if (!$result) {
+ return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be deleted.');
+ }
+
+ return true;
+ }
+
+
+
+ /* MetaWeblog API functions
+ * specs on wherever Dave Winer wants them to be
+ */
+
+ /* metaweblog.newPost creates a post */
+ function mw_newPost($args) {
+
+ global $wpdb, $post_default_category;
+
+ $this->escape($args);
+
+ $blog_ID = $args[0]; // we will support this in the near future
+ $user_login = $args[1];
+ $user_pass = $args[2];
+ $content_struct = $args[3];
+ $publish = $args[4];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+ if (!user_can_create_post($user_data->ID, $blog_ID)) {
+ return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
+ }
+
+ $post_author = $user_data->ID;
+
+ $post_title = $content_struct['title'];
+ $post_content = apply_filters( 'content_save_pre', $content_struct['description'] );
+ $post_status = $publish ? 'publish' : 'draft';
+
+ $post_excerpt = $content_struct['mt_excerpt'];
+ $post_more = $content_struct['mt_text_more'];
+
+ $comment_status = (empty($content_struct['mt_allow_comments'])) ?
+ get_settings('default_comment_status')
+ : $content_struct['mt_allow_comments'];
+
+ $ping_status = (empty($content_struct['mt_allow_pings'])) ?
+ get_settings('default_ping_status')
+ : $content_struct['mt_allow_pings'];
+
+ if ($post_more) {
+ $post_content = $post_content . "\n<!--more-->\n" . $post_more;
+ }
+
+ $to_ping = $content_struct['mt_tb_ping_urls'];
+
+ // Do some timestamp voodoo
+ $dateCreatedd = $content_struct['dateCreated'];
+ if (!empty($dateCreatedd)) {
+ $dateCreated = $dateCreatedd->getIso();
+ $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
+ $post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
+ } else {
+ $post_date = current_time('mysql');
+ $post_date_gmt = current_time('mysql', 1);
+ }
+
+ $catnames = $content_struct['categories'];
+ logIO('O', 'Post cats: ' . printr($catnames,true));
+ $post_category = array();
+
+ if (is_array($catnames)) {
+ foreach ($catnames as $cat) {
+ $post_category[] = get_cat_ID($cat);
+ }
+ }
+
+ // We've got all the data -- post it:
+ $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping');
+
+ $post_ID = wp_insert_post($postdata);
+
+ if (!$post_ID) {
+ return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');
+ }
+
+ logIO('O', "Posted ! ID: $post_ID");
+
+ return strval($post_ID);
+ }
+
+
+ /* metaweblog.editPost ...edits a post */
+ function mw_editPost($args) {
+
+ global $wpdb, $post_default_category;
+
+ $this->escape($args);
+
+ $post_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+ $content_struct = $args[3];
+ $publish = $args[4];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+ if (!user_can_edit_post($user_data->ID, $post_ID)) {
+ return new IXR_Error(401, 'Sorry, you can not edit this post.');
+ }
+
+ $postdata = wp_get_single_post($post_ID, ARRAY_A);
+ extract($postdata);
+ $this->escape($postdata);
+
+ $post_title = $content_struct['title'];
+ $post_content = apply_filters( 'content_save_pre', $content_struct['description'] );
+ $catnames = $content_struct['categories'];
+
+ $post_category = array();
+
+ if (is_array($catnames)) {
+ foreach ($catnames as $cat) {
+ $post_category[] = get_cat_ID($cat);
+ }
+ }
+
+ $post_excerpt = $content_struct['mt_excerpt'];
+ $post_more = $content_struct['mt_text_more'];
+ $post_status = $publish ? 'publish' : 'draft';
+
+ if ($post_more) {
+ $post_content = $post_content . "\n<!--more-->\n" . $post_more;
+ }
+
+ $to_ping = $content_struct['mt_tb_ping_urls'];
+
+ $comment_status = (empty($content_struct['mt_allow_comments'])) ?
+ get_settings('default_comment_status')
+ : $content_struct['mt_allow_comments'];
+
+ $ping_status = (empty($content_struct['mt_allow_pings'])) ?
+ get_settings('default_ping_status')
+ : $content_struct['mt_allow_pings'];
+
+ // Do some timestamp voodoo
+ $dateCreatedd = $content_struct['dateCreated'];
+ if (!empty($dateCreatedd)) {
+ $dateCreated = $dateCreatedd->getIso();
+ $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
+ $post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
+ } else {
+ $post_date = $postdata['post_date'];
+ $post_date_gmt = $postdata['post_date_gmt'];
+ }
+
+ // We've got all the data -- post it:
+ $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping');
+
+ $result = wp_update_post($newpost);
+ if (!$result) {
+ return new IXR_Error(500, 'Sorry, your entry could not be edited. Something wrong happened.');
+ }
+
+ logIO('O',"(MW) Edited ! ID: $post_ID");
+
+ return true;
+ }
+
+
+ /* metaweblog.getPost ...returns a post */
+ function mw_getPost($args) {
+
+ global $wpdb;
+
+ $this->escape($args);
+
+ $post_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $postdata = wp_get_single_post($post_ID, ARRAY_A);
+
+ if ($postdata['post_date'] != '') {
+
+ $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']);
+
+ $categories = array();
+ $catids = wp_get_post_cats('', $post_ID);
+ foreach($catids as $catid) {
+ $categories[] = get_cat_name($catid);
+ }
+
+ $post = get_extended($postdata['post_content']);
+ $link = post_permalink($postdata['ID']);
+
+ $allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0;
+ $allow_pings = ('open' == $postdata['ping_status']) ? 1 : 0;
+
+ $resp = array(
+ 'dateCreated' => new IXR_Date($post_date),
+ 'userid' => $postdata['post_author'],
+ 'postid' => $postdata['ID'],
+ 'description' => $post['main'],
+ 'title' => $postdata['post_title'],
+ 'link' => $link,
+ 'permaLink' => $link,
+// commented out because no other tool seems to use this
+// 'content' => $entry['post_content'],
+ 'categories' => $categories,
+ 'mt_excerpt' => $postdata['post_excerpt'],
+ 'mt_text_more' => $post['extended'],
+ 'mt_allow_comments' => $allow_comments,
+ 'mt_allow_pings' => $allow_pings
+ );
+
+ return $resp;
+ } else {
+ return new IXR_Error(404, 'Sorry, no such post.');
+ }
+ }
+
+
+ /* metaweblog.getRecentPosts ...returns recent posts */
+ function mw_getRecentPosts($args) {
+
+ $this->escape($args);
+
+ $blog_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+ $num_posts = $args[3];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $posts_list = wp_get_recent_posts($num_posts);
+
+ if (!$posts_list) {
+ $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
+ return $this->error;
+ }
+
+ foreach ($posts_list as $entry) {
+
+ $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
+ $categories = array();
+ $catids = wp_get_post_cats('', $entry['ID']);
+ foreach($catids as $catid) {
+ $categories[] = get_cat_name($catid);
+ }
+
+ $post = get_extended($entry['post_content']);
+ $link = post_permalink($entry['ID']);
+
+ $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0;
+ $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0;
+
+ $struct[] = array(
+ 'dateCreated' => new IXR_Date($post_date),
+ 'userid' => $entry['post_author'],
+ 'postid' => $entry['ID'],
+ 'description' => $post['main'],
+ 'title' => $entry['post_title'],
+ 'link' => $link,
+ 'permaLink' => $link,
+// commented out because no other tool seems to use this
+// 'content' => $entry['post_content'],
+ 'categories' => $categories,
+ 'mt_excerpt' => $entry['post_excerpt'],
+ 'mt_text_more' => $post['extended'],
+ 'mt_allow_comments' => $allow_comments,
+ 'mt_allow_pings' => $allow_pings
+ );
+
+ }
+
+ $recent_posts = array();
+ for ($j=0; $j<count($struct); $j++) {
+ array_push($recent_posts, $struct[$j]);
+ }
+
+ return $recent_posts;
+ }
+
+
+ /* metaweblog.getCategories ...returns the list of categories on a given weblog */
+ function mw_getCategories($args) {
+
+ global $wpdb;
+
+ $this->escape($args);
+
+ $blog_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $categories_struct = array();
+
+ // FIXME: can we avoid using direct SQL there?
+ if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name FROM $wpdb->categories", ARRAY_A)) {
+ foreach ($cats as $cat) {
+ $struct['categoryId'] = $cat['cat_ID'];
+ $struct['description'] = $cat['cat_name'];
+ $struct['categoryName'] = $cat['cat_name'];
+ $struct['htmlUrl'] = wp_specialchars(get_category_link($cat['cat_ID']));
+ $struct['rssUrl'] = wp_specialchars(get_category_rss_link(false, $cat['cat_ID'], $cat['cat_name']));
+
+ $categories_struct[] = $struct;
+ }
+ }
+
+ return $categories_struct;
+ }
+
+
+ /* metaweblog.newMediaObject uploads a file, following your settings */
+ function mw_newMediaObject($args) {
+ // adapted from a patch by Johann Richard
+ // http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/
+
+ global $wpdb;
+
+ $blog_ID = $wpdb->escape($args[0]);
+ $user_login = $wpdb->escape($args[1]);
+ $user_pass = $wpdb->escape($args[2]);
+ $data = $args[3];
+
+ $name = $data['name'];
+ $type = $data['type'];
+ $bits = $data['bits'];
+
+ $file_realpath = get_settings('fileupload_realpath');
+ $file_url = get_settings('fileupload_url');
+
+ logIO('O', '(MW) Received '.strlen($bits).' bytes');
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+
+ if(!get_settings('use_fileupload')) {
+ // Uploads not allowed
+ logIO('O', '(MW) Uploads not allowed');
+ $this->error = new IXR_Error(405, 'No uploads allowed for this site.');
+ return $this->error;
+ }
+
+ if(get_settings('fileupload_minlevel') > $user_data->user_level) {
+ // User has not enough privileges
+ logIO('O', '(MW) Not enough privilege: user level too low');
+ $this->error = new IXR_Error(401, 'You are not allowed to upload files to this site.');
+ return $this->error;
+ }
+
+ if(trim($file_realpath) == '' || trim($file_url) == '' ) {
+ // WordPress is not correctly configured
+ logIO('O', '(MW) Bad configuration. Real/URL path not defined');
+ $this->error = new IXR_Error(500, 'Please configure WordPress with valid paths for file upload.');
+ return $this->error;
+ }
+
+ $prefix = '/';
+
+ if(!empty($name)) {
+ // Create the path
+ $localpath = $file_realpath.$prefix.$name;
+ $url = $file_url.$prefix.$name;
+
+ if (mkdir_p(dirname($localpath))) {
+
+ /* encode & write data (binary) */
+ $ifp = fopen($localpath, 'wb');
+ $success = fwrite($ifp, $bits);
+ fclose($ifp);
+ @chmod($localpath, 0666);
+
+ if($success) {
+ $resp = array('url' => $url);
+ return $resp;
+ } else {
+ logIO('O', '(MW) Could not write file '.$name.' to '.$localpath);
+ return new IXR_Error(500, 'Could not write file '.$name);
+ }
+
+ } else {
+ return new IXR_Error(500, 'Could not create directories for '.$name);
+ }
+ }
+ }
+
+
+
+ /* MovableType API functions
+ * specs on http://www.movabletype.org/docs/mtmanual_programmatic.html
+ */
+
+ /* mt.getRecentPostTitles ...returns recent posts' titles */
+ function mt_getRecentPostTitles($args) {
+
+ $this->escape($args);
+
+ $blog_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+ $num_posts = $args[3];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $posts_list = wp_get_recent_posts($num_posts);
+
+ if (!$posts_list) {
+ $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
+ return $this->error;
+ }
+
+ foreach ($posts_list as $entry) {
+
+ $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
+
+ $struct[] = array(
+ 'dateCreated' => new IXR_Date($post_date),
+ 'userid' => $entry['post_author'],
+ 'postid' => $entry['ID'],
+ 'title' => $entry['post_title'],
+ );
+
+ }
+
+ $recent_posts = array();
+ for ($j=0; $j<count($struct); $j++) {
+ array_push($recent_posts, $struct[$j]);
+ }
+
+ return $recent_posts;
+ }
+
+
+ /* mt.getCategoryList ...returns the list of categories on a given weblog */
+ function mt_getCategoryList($args) {
+
+ global $wpdb;
+
+ $this->escape($args);
+
+ $blog_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $categories_struct = array();
+
+ // FIXME: can we avoid using direct SQL there?
+ if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) {
+ foreach ($cats as $cat) {
+ $struct['categoryId'] = $cat['cat_ID'];
+ $struct['categoryName'] = $cat['cat_name'];
+
+ $categories_struct[] = $struct;
+ }
+ }
+
+ return $categories_struct;
+ }
+
+
+ /* mt.getPostCategories ...returns a post's categories */
+ function mt_getPostCategories($args) {
+
+ $this->escape($args);
+
+ $post_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $categories = array();
+ $catids = wp_get_post_cats('', intval($post_ID));
+ // first listed category will be the primary category
+ $isPrimary = true;
+ foreach($catids as $catid) {
+ $categories[] = array(
+ 'categoryName' => get_cat_name($catid),
+ 'categoryId' => $catid,
+ 'isPrimary' => $isPrimary
+ );
+ $isPrimary = false;
+ }
+
+ return $categories;
+ }
+
+
+ /* mt.setPostCategories ...sets a post's categories */
+ function mt_setPostCategories($args) {
+
+ $this->escape($args);
+
+ $post_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+ $categories = $args[3];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+ if (!user_can_edit_post($user_data->ID, $post_ID)) {
+ return new IXR_Error(401, 'Sorry, you can not edit this post.');
+ }
+
+ foreach($categories as $cat) {
+ $catids[] = $cat['categoryId'];
+ }
+
+ wp_set_post_cats('', $post_ID, $catids);
+
+ return true;
+ }
+
+
+ /* mt.supportedMethods ...returns an array of methods supported by this server */
+ function mt_supportedMethods($args) {
+
+ $supported_methods = array();
+ foreach($this->methods as $key=>$value) {
+ $supported_methods[] = $key;
+ }
+
+ return $supported_methods;
+ }
+
+
+ /* mt.supportedTextFilters ...returns an empty array because we don't
+ support per-post text filters yet */
+ function mt_supportedTextFilters($args) {
+ return array();
+ }
+
+
+ /* mt.getTrackbackPings ...returns trackbacks sent to a given post */
+ function mt_getTrackbackPings($args) {
+
+ global $wpdb;
+
+ $post_ID = intval($args);
+
+ $actual_post = wp_get_single_post($post_ID, ARRAY_A);
+
+ if (!$actual_post) {
+ return new IXR_Error(404, 'Sorry, no such post.');
+ }
+
+ $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");
+
+ if (!$comments) {
+ return array();
+ }
+
+ $trackback_pings = array();
+ foreach($comments as $comment) {
+ if ( 'trackback' == $comment->comment_type ) {
+ $content = $comment->comment_content;
+ $title = substr($content, 8, (strpos($content, '</strong>') - 8));
+ $trackback_pings[] = array(
+ 'pingTitle' => $title,
+ 'pingURL' => $comment->comment_author_url,
+ 'pingIP' => $comment->comment_author_IP
+ );
+ }
+ }
+
+ return $trackback_pings;
+ }
+
+
+ /* mt.publishPost ...sets a post's publish status to 'publish' */
+ function mt_publishPost($args) {
+
+ $this->escape($args);
+
+ $post_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
+
+ $user_data = get_userdatabylogin($user_login);
+ if (!user_can_edit_post($user_data->ID, $post_ID)) {
+ return new IXR_Error(401, 'Sorry, you can not edit this post.');
+ }
+
+ $postdata = wp_get_single_post($post_ID,ARRAY_A);
+
+ $postdata['post_status'] = 'publish';
+
+ // retain old cats
+ $cats = wp_get_post_cats('',$post_ID);
+ $postdata['post_category'] = $cats;
+ $this->escape($postdata);
+
+ $result = wp_update_post($postdata);
+
+ return $result;
+ }
+
+
+
+ /* PingBack functions
+ * specs on www.hixie.ch/specs/pingback/pingback
+ */
+
+ /* pingback.ping gets a pingback and registers it */
+ function pingback_ping($args) {
+ global $wpdb, $wp_version;
+
+ $this->escape($args);
+
+ $pagelinkedfrom = $args[0];
+ $pagelinkedto = $args[1];
+
+ $title = '';
+
+ $pagelinkedfrom = str_replace('&amp;', '&', $pagelinkedfrom);
+ $pagelinkedto = preg_replace('#&([^amp\;])#is', '&amp;$1', $pagelinkedto);
+
+ $error_code = -1;
+
+ // Check if the page linked to is in our site
+ $pos1 = strpos($pagelinkedto, str_replace('http://', '', str_replace('www.', '', get_settings('home'))));
+ if( !$pos1 )
+ return new IXR_Error(0, 'Is there no link to us?');
+
+ // let's find which post is linked to
+ // FIXME: does url_to_postid() cover all these cases already?
+ // if so, then let's use it and drop the old code.
+ $urltest = parse_url($pagelinkedto);
+ if ($post_ID = url_to_postid($pagelinkedto)) {
+ $way = 'url_to_postid()';
+ } elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) {
+ // the path defines the post_ID (archives/p/XXXX)
+ $blah = explode('/', $match[0]);
+ $post_ID = $blah[1];
+ $way = 'from the path';
+ } elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) {
+ // the querystring defines the post_ID (?p=XXXX)
+ $blah = explode('=', $match[0]);
+ $post_ID = $blah[1];
+ $way = 'from the querystring';
+ } elseif (isset($urltest['fragment'])) {
+ // an #anchor is there, it's either...
+ if (intval($urltest['fragment'])) {
+ // ...an integer #XXXX (simpliest case)
+ $post_ID = $urltest['fragment'];
+ $way = 'from the fragment (numeric)';
+ } elseif (preg_match('/post-[0-9]+/',$urltest['fragment'])) {
+ // ...a post id in the form 'post-###'
+ $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']);
+ $way = 'from the fragment (post-###)';
+ } elseif (is_string($urltest['fragment'])) {
+ // ...or a string #title, a little more complicated
+ $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']);
+ $sql = "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE '$title'";
+ if (! ($post_ID = $wpdb->get_var($sql)) ) {
+ // returning unknown error '0' is better than die()ing
+ return new IXR_Error(0, '');
+ }
+ $way = 'from the fragment (title)';
+ }
+ } else {
+ // TODO: Attempt to extract a post ID from the given URL
+ return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
+ }
+ $post_ID = (int) $post_ID;
+
+
+ logIO("O","(PB) URI='$pagelinkedto' ID='$post_ID' Found='$way'");
+
+ $post = get_post($post_ID);
+
+ if ( !$post ) // Post_ID not found
+ return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
+
+ // Check if pings are on
+ if ( 'closed' == $post->ping_status )
+ return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
+
+ // Let's check that the remote site didn't already pingback this entry
+ $result = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_ID' AND comment_author_url = '$pagelinkedfrom'");
+
+ if ( $wpdb->num_rows ) // We already have a Pingback from this URL
+ return new IXR_Error(48, 'The pingback has already been registered.');
+
+ // very stupid, but gives time to the 'from' server to publish !
+ sleep(1);
+
+ // Let's check the remote site
+ $linea = wp_remote_fopen( $pagelinkedfrom );
+ if ( !$linea )
+ return new IXR_Error(16, 'The source URI does not exist.');
+
+ // Work around bug in strip_tags():
+ $linea = str_replace('<!DOC', '<DOC', $linea);
+ $linea = preg_replace( '/[\s\r\n\t]+/', ' ', $linea ); // normalize spaces
+ $linea = preg_replace( "/ <(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/", "\n\n", $linea );
+
+ preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
+ $title = $matchtitle[1];
+ if ( empty( $title ) )
+ return new IXR_Error(32, 'We cannot find a title on that page.');
+
+ $linea = strip_tags( $linea, '<a>' ); // just keep the tag we need
+
+ $p = explode( "\n\n", $linea );
+
+ $sem_regexp_pb = "/(\\/|\\\|\*|\?|\+|\.|\^|\\$|\(|\)|\[|\]|\||\{|\})/";
+ $sem_regexp_fix = "\\\\$1";
+ $link = preg_replace( $sem_regexp_pb, $sem_regexp_fix, $pagelinkedfrom );
+
+ $finished = false;
+ foreach ( $p as $para ) {
+ if ( $finished )
+ continue;
+ if ( strstr( $para, $pagelinkedto ) ) {
+ $context = preg_replace( "/.*<a[^>]+".$link."[^>]*>([^>]+)<\/a>.*/", "$1", $para );
+ $excerpt = strip_tags( $para );
+ $excerpt = trim( $excerpt );
+ $use = preg_quote( $context );
+ $excerpt = preg_replace("|.*?\s(.{0,100}$use.{0,100})\s|s", "$1", $excerpt);
+ $finished = true;
+ }
+ }
+
+ $pagelinkedfrom = preg_replace('#&([^amp\;])#is', '&amp;$1', $pagelinkedfrom);
+
+ $context = '[...] ' . wp_specialchars( $excerpt ) . ' [...]';
+ $original_pagelinkedfrom = $pagelinkedfrom;
+ $pagelinkedfrom = $wpdb->escape( $pagelinkedfrom );
+ $original_title = $title;
+
+ $comment_post_ID = $post_ID;
+ $comment_author = $title;
+ $comment_author_url = $pagelinkedfrom;
+ $comment_content = $context;
+ $comment_type = 'pingback';
+
+ $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_content', 'comment_type');
+
+ wp_new_comment($commentdata);
+ do_action('pingback_post', $wpdb->insert_id);
+
+ return "Pingback from $pagelinkedfrom to $pagelinkedto registered. Keep the web talking! :-)";
+ }
+
+
+ /* pingback.extensions.getPingbacks returns an array of URLs
+ that pingbacked the given URL
+ specs on http://www.aquarionics.com/misc/archives/blogite/0198.html */
+ function pingback_extensions_getPingbacks($args) {
+
+ global $wpdb;
+
+ $this->escape($args);
+
+ $url = $args;
+
+ $post_ID = url_to_postid($url);
+ if (!$post_ID) {
+ // We aren't sure that the resource is available and/or pingback enabled
+ return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
+ }
+
+ $actual_post = wp_get_single_post($post_ID, ARRAY_A);
+
+ if (!$actual_post) {
+ // No such post = resource not found
+ return new IXR_Error(32, 'The specified target URI does not exist.');
+ }
+
+ $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");
+
+ if (!$comments) {
+ return array();
+ }
+
+ $pingbacks = array();
+ foreach($comments as $comment) {
+ if ( 'pingback' == $comment->comment_type )
+ $pingbacks[] = $comment->comment_author_url;
+ }
+
+ return $pingbacks;
+ }
+}
+
+
+$wp_xmlrpc_server = new wp_xmlrpc_server();
+
+?> \ No newline at end of file