summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog-old.txt1382
-rw-r--r--README.txt13
-rw-r--r--htaccess.dist4
-rw-r--r--index.php198
-rwxr-xr-xrelease.sh73
-rw-r--r--wp-inst/index.php2
-rw-r--r--wp-inst/wp-activate.php77
-rw-r--r--wp-inst/wp-admin/admin-db.php237
-rw-r--r--wp-inst/wp-admin/admin-functions.php252
-rw-r--r--wp-inst/wp-admin/categories.js10
-rw-r--r--wp-inst/wp-admin/categories.php62
-rw-r--r--wp-inst/wp-admin/edit-link-form.php490
-rw-r--r--wp-inst/wp-admin/import.php124
-rw-r--r--wp-inst/wp-admin/link-add.php7
-rw-r--r--wp-inst/wp-admin/link-import.php18
-rw-r--r--wp-inst/wp-admin/link-manager.php559
-rw-r--r--wp-inst/wp-admin/upgrade-functions.php5
-rw-r--r--wp-inst/wp-admin/upgrade-schema.php47
-rw-r--r--wp-inst/wp-admin/wp-admin.css84
-rw-r--r--wp-inst/wp-admin/wpmu-upgrade.inc.php32
-rw-r--r--wp-inst/wp-config-sample.php4
-rw-r--r--wp-inst/wp-content/blogs.php100
-rw-r--r--wp-inst/wp-content/mu-plugins/blogs-header.php23
-rw-r--r--wp-inst/wp-content/mu-plugins/doc_referers.php712
-rw-r--r--wp-inst/wp-content/mu-plugins/invites.php357
-rw-r--r--wp-inst/wp-content/mu-plugins/wp-hashcash.php684
-rw-r--r--wp-inst/wp-content/themes/home/header.php122
-rw-r--r--wp-inst/wp-content/themes/home/home.php30
-rw-r--r--wp-inst/wp-includes/cache.php850
-rw-r--r--wp-inst/wp-includes/capabilities.php108
-rw-r--r--wp-inst/wp-includes/classes.php1716
-rw-r--r--wp-inst/wp-includes/comment-template.php374
-rw-r--r--wp-inst/wp-includes/comment.php566
-rw-r--r--wp-inst/wp-includes/cron.php212
-rw-r--r--wp-inst/wp-includes/default-filters.php8
-rw-r--r--wp-inst/wp-includes/deprecated.php455
-rw-r--r--wp-inst/wp-includes/functions-compat.php3
-rw-r--r--wp-inst/wp-includes/functions-formatting.php32
-rw-r--r--wp-inst/wp-includes/functions-post.php123
-rw-r--r--wp-inst/wp-includes/functions.php1153
-rw-r--r--wp-inst/wp-includes/kses.php8
-rw-r--r--wp-inst/wp-includes/locale.php189
-rw-r--r--wp-inst/wp-includes/pluggable-functions.php72
-rw-r--r--wp-inst/wp-includes/query.php2032
-rw-r--r--wp-inst/wp-includes/registration-functions.php7
-rw-r--r--wp-inst/wp-includes/rewrite.php1691
-rw-r--r--wp-inst/wp-includes/rss-functions.php67
-rw-r--r--wp-inst/wp-includes/template-functions-bookmarks.php776
-rw-r--r--wp-inst/wp-includes/template-functions-category.php429
-rw-r--r--wp-inst/wp-includes/template-functions-general.php80
-rw-r--r--wp-inst/wp-includes/template-functions-links.php101
-rw-r--r--wp-inst/wp-includes/template-functions-post.php214
-rw-r--r--wp-inst/wp-includes/template-loader.php4
-rw-r--r--wp-inst/wp-includes/theme.php378
-rw-r--r--wp-inst/wp-includes/vars.php26
-rw-r--r--wp-inst/wp-includes/version.php4
-rw-r--r--wp-inst/wp-includes/wpmu-functions.php977
-rw-r--r--wp-inst/wp-login.php2
-rw-r--r--wp-inst/wp-newblog.inc.php677
-rw-r--r--wp-inst/wp-newblog.php256
-rw-r--r--wp-inst/wp-settings.php151
-rw-r--r--wp-inst/wp-signup.php180
-rw-r--r--wp-inst/wpmu-settings.php106
-rw-r--r--wp-inst/wpmu-settings.php.dist59
64 files changed, 8189 insertions, 11605 deletions
diff --git a/Changelog-old.txt b/Changelog-old.txt
deleted file mode 100644
index bfd875f..0000000
--- a/Changelog-old.txt
+++ /dev/null
@@ -1,1382 +0,0 @@
-------------------------------------------------------------------------
-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
index a8573a8..46f8dea 100644
--- a/README.txt
+++ b/README.txt
@@ -2,12 +2,13 @@ WordPress Multi User
--------------------
WordPress MU is a multi user version of WordPress.
+
If you're not comfortable editing PHP code, taking care of a complex
webserver and database system and being pro-active about following
developments of this project then run, don't walk, to
http://wordpress.com/ and sign yourself and your friends up to free blogs.
It's easier in the long run and you'll save yourself a lot of pain
-and angst.
+and angst. ;)
Install
=======
@@ -32,13 +33,18 @@ and change it to
PHP
===
For security reasons, it's very important that PHP be configured as follows:
+
1. Don't display error messages to the browser. This is almost always
turned off but sometimes when you're testing you turn this on and forget
to reset it.
+
2. GLOBAL variables must be turned off. This is one of the first things
any security aware admin will do. These days the default is for it to
be off!
+3. If you want to restrict blog signups, set the restrict domain email
+setting in the admin.
+
The easiest way of configuring it is via the .htaccess file that is
created during the install. If you haven't installed WPMU yet then edit
the file htaccess.dist in this directory and add these two lines at the
@@ -59,11 +65,15 @@ php.ini. It's beyond the scope of this README to know exactly where it is
on your machine, but if you're on a shared hosted server you probably
don't have access to it as it requires root or administrator privileges
to change.
+
If you do have root access, try "locate php.ini" or check in:
+
/etc/php4/apache2/php.ini
/usr/local/lib/php.ini
+
Once you have opened your php.ini, look for the sections related to
register_globals and display_errors. Make sure both are Off like so:
+
display_errors = Off
register_globals = Off
@@ -71,6 +81,7 @@ You'll have to restart Apache after you modify your php.ini for the
settings to be updated.
Support Forum:
+
http://mu.wordpress.org/forums/
http://mu.wordpress.org/
diff --git a/htaccess.dist b/htaccess.dist
index 697e32f..cf52033 100644
--- a/htaccess.dist
+++ b/htaccess.dist
@@ -61,13 +61,15 @@ RewriteRule ^([_0-9a-zA-Z-]+)/wp-rss.php(.*) BASE/wp-inst/wp-rss.php [L]
RewriteRule ^([_0-9a-zA-Z-]+)/wp-rss2.php(.*) BASE/wp-inst/wp-rss2.php [L]
RewriteRule ^([_0-9a-zA-Z-]+)/wp-sidebar.php(.*) BASE/wp-inst/wp-sidebar.php [L]
RewriteRule ^([_0-9a-zA-Z-]+)/wp-trackback.php(.*) BASE/wp-inst/wp-trackback.php [L]
+RewriteRule ^([_0-9a-zA-Z-]+)/wp-cron.php(.*) BASE/wp-inst/wp-cron.php [L]
RewriteRule ^([_0-9a-zA-Z-]+)/xmlrpc.php(.*) BASE/wp-inst/xmlrpc.php [L]
RewriteRule ^([_0-9a-zA-Z-]+)/maintenance.php BASE/wp-inst/maintenance.php [L]
RewriteRule ^([_0-9a-zA-Z-]+)/favicon.ico BASE/wp-inst/favicon.ico [L]
RewriteRule ^([_0-9a-zA-Z-]+)/wp-includes/images/(.*) BASE/wp-inst/wp-includes/images/$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+)/wp-includes/js/(.*) BASE/wp-inst/wp-includes/js/$2 [L]
-RewriteRule ^wp-newblog.php$ BASE/wp-inst/wp-newblog.php [L]
+RewriteRule ^wp-signup.php$ BASE/wp-inst/wp-signup.php [L]
+RewriteRule ^wp-activate.php$ /wp-inst/wp-activate.php [L]
RewriteRule ^wp-login.php BASE/wp-inst/wp-login.php [L]
RewriteRule ^wp-admin/(.*) BASE/wp-inst/wp-admin/$1 [L]
RewriteRule ^wp-includes/images/(.*) BASE/wp-inst/wp-includes/images/$1 [L]
diff --git a/index.php b/index.php
index 32f0cbf..c63b4bc 100644
--- a/index.php
+++ b/index.php
@@ -22,16 +22,12 @@ function printheader() {
padding: .2em 2em;
}
- h1 {
+ h1, h2 {
color: #006;
font-size: 18px;
font-weight: lighter;
}
- h2 {
- font-size: 16px;
- }
-
p, li, dt {
line-height: 140%;
padding-bottom: 2px;
@@ -61,26 +57,18 @@ text-align: center; border-top: 1px solid #ccc; padding-top: 1em; font-style: it
</head>
<body>
-<div align="center"><img src="wp-inst/wp-includes/images/wordpress-mu.png"></div><br>
-Welcome to WordPress MU, the Multi User Weblog System built on WordPress.<br><br>
+<h1><img src="wp-inst/wp-includes/images/wordpress-mu.png" alt="WordPress MU" /></h1>
';
}
-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>";
+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 )
- {
+ } else {
+ if( $ret == true ) {
return true;
- }
- else
- {
+ } else {
return false;
}
}
@@ -137,9 +125,7 @@ function do_htaccess( $oldfilename, $newfilename, $realpath, $base, $url )
$htaccess .= fgets( $fp, 4096 );
}
fclose( $fp );
- $htaccess = str_replace( "REALPATH", $realpath, $htaccess );
$htaccess = str_replace( "BASE", $base, $htaccess );
- $htaccess = str_replace( "HOST", $url, $htaccess );
if( touch( $newfilename ) ) {
$fp = fopen( $newfilename, "w" );
if( $fp ) {
@@ -211,47 +197,28 @@ function checkdirs() {
}
function step1() {
- print "<h1>Welcome to WPMU</h1>";
- print "<p>Please make sure mod_rewrite is installed as it will be activated at the end of this install.</p><p>If mod_rewrite 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.</p>";
+ print "<h2>Installing WP&micro;</h2>";
+ print "<p>Please make sure <code>mod_rewrite</code> is installed as it will be activated at the end of this install.</p>
+ <p>If the <code>mod_rewrite</code> module 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.</p>
+ <p>WPMU <strong>must be installed in the root directory of a domain</strong>, otherwise it won't work.";
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 Blogs living area.
@mkdir( dirname(__FILE__) . "/wp-inst/wp-content/blogs.dir", 0777 );
- $url = "http://".$_SERVER["SERVER_NAME"] . dirname( $_SERVER[ "SCRIPT_NAME" ] );
+ $url = stripslashes( "http://".$_SERVER["SERVER_NAME"] . dirname( $_SERVER[ "SCRIPT_NAME" ] ) );
if( substr( $url, -1 ) == '/' )
$url = substr( $url, 0, -1 );
- $base = dirname( $_SERVER["SCRIPT_NAME"] );
+ $base = stripslashes( 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;
}
@@ -259,52 +226,33 @@ function printstep1form( $dbname = 'wordpress', $uname = 'username', $pwd = 'pas
print "
<form method='post' action='index.php'>
<input type='hidden' name='action' value='step2'>
- <h1>Virtual Server Support</h1>
- <p>Each blog on your site will have their own hostname or 'sub domain'. 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.</p>
- <p>Apache will have to have a <q>wildcard</q> alias configured in the virtual server definition of your server. You'll have to add a wildcard DNS record for your domain too. That's usually as easy as adding a <q>*</q> hostname in your online dns software.</p>
- <p>Virtual Server Support: <input type='radio' name='vhost' value='yes'> Yes&nbsp;&nbsp;<input type='radio' name='vhost' value='no' checked>No</p>
- <p>More: <ul><li> <a href='http://codewalkers.com/archives/general_admin/234.html'>Sub-domain catch-all with Apache</a> via <a href='http://www.google.com/search?q=apache+wildcard+alias'>Google Search: apache wildcard alias</a></li><li> <a href='http://photomatt.net/2003/10/10/wildcard-dns-and-sub-domains/'>Wildcard dns and sub domains</a> via <a href='http://www.google.com/search?q=dns+wildcard+sub+domain'>Google Search: dns wildcard sub domain</a></li><li><a href='http://mu.wordpress.org/forums/topic/126#post-677'>mu forums: how to setup vhosts</a></li></ul></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>
+ <h2>Blog Addresses</h2>
+ <p>Please choose whether you would like blogs for the MU install to use sub-domains or sub-directories. You can not change this later. We recommend sub-domains.</p>
+ <p><label><input type='radio' name='vhost' value='yes' /> Sub-domains (like <code>blog1.example.com</code>)</label><br />
+ <label><input type='radio' name='vhost' value='no' /> Sub-directories (like <code>example.com/blog1</code></label></p>
+
+ <h2>Database</h2>
<p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
- <table>
+ <table cellpadding='5'>
<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>
+ <th scope='row' width='33%'>Database Name</th>
+ <td><input name='dbname' type='text' size='45' value='$dbname' /></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>
+ <td><input name='uname' type='text' size='45' value='$uname' /></td>
</tr>
<tr>
<th scope='row'>Password</th>
- <td><input name='pwd' type='text' size='45' value='".$pwd."' /></td>
- <td>...and MySQL password.</td>
+ <td><input name='pwd' type='text' size='45' value='$pwd' /></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>
+ <td><input name='dbhost' type='text' size='45' value='$dbhost' /></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' />
+ <p class='submit'><input name='submit' type='submit' value='Submit' /> </p>
</form> ";
}
@@ -314,8 +262,8 @@ function step2() {
$passwrd = $_POST['pwd'];
$dbhost = $_POST['dbhost'];
$vhost = $_POST['vhost' ];
- $prefix = $_POST['prefix'];
- if (empty($prefix)) $prefix = 'wp_';
+ $prefix = 'wp_';
+ $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) );
// Test the db connection.
define('DB_NAME', $dbname);
@@ -358,6 +306,7 @@ function step2() {
default:
fwrite($handle, $line);
}
+ $line = str_replace( "BASE", $base, $line );
}
fclose($handle);
chmod('wp-inst/wp-config.php', 0666);
@@ -389,7 +338,7 @@ function printuserdetailsform( $weblog_title = 'My new Blog', $username = '', $e
function step3() {
global $wpdb;
- $base = dirname( $_SERVER["SCRIPT_NAME"] );
+ $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) );
if( $base != "/")
{
$base .= "/";
@@ -429,64 +378,47 @@ We hope you enjoy your new weblog.
--The Team @ SITE_NAME')" );
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'first_post', 'Welcome to <a href=\"SITE_URL\">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' )" );
- $res = createBlog( $domain, $base, 'admin', $weblog_title, $email );
- if( $res == 'ok' ) {
- $url = "http://".$_SERVER["HTTP_HOST"] . $base;
- update_option( "template", "home" );
- update_option( "stylesheet", "home" );
- add_site_option( "allowed_themes", 'a:2:{s:17:"WordPress Classic";b:1;s:17:"WordPress Default";b:1;}' );
- $realpath = dirname(__FILE__);
- do_htaccess( "htaccess.dist", ".htaccess", $realpath, $base, $url );
- do_htaccess( "wp-inst/htaccess.dist", "wp-inst/.htaccess", $realpath, $base, $url );
-
- $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator", "blog" );
- add_site_option( "illegal_names", $illegal_names );
-
- 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' ] );
- }
+ $pass = substr( md5( rand() ), 5, 12 );
+ $user_id = wpmu_create_user( 'admin', $pass, $email);
+ wpmu_create_blog( $domain, $base, $weblog_title, $user_id, array() );
+ update_blog_option( 1, 'template', 'home');
+ update_blog_option( 1, 'stylesheet', 'home');
+ print "<p>Congrats! Your blog has been set up and you have been sent details of your login and password in an email.</p>";
}
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;
+ 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();
+ do_htaccess( 'htaccess.dist', '.htaccess', '/', '/', '');
+ 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>
+<a href="http://mu.wordpress.org/">WordPress &micro;</a> | <a href="http://mu.wordpress.org/forums/">Support Forums</a>
</div>
</body>
</html>
diff --git a/release.sh b/release.sh
deleted file mode 100755
index 41d6867..0000000
--- a/release.sh
+++ /dev/null
@@ -1,73 +0,0 @@
-#
-# 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/index.php b/wp-inst/index.php
index 6199abc..3e3db40 100644
--- a/wp-inst/index.php
+++ b/wp-inst/index.php
@@ -2,4 +2,4 @@
/* Short and sweet */
define('WP_USE_THEMES', true);
require('./wp-blog-header.php');
-?>
+?> \ No newline at end of file
diff --git a/wp-inst/wp-activate.php b/wp-inst/wp-activate.php
new file mode 100644
index 0000000..345856c
--- /dev/null
+++ b/wp-inst/wp-activate.php
@@ -0,0 +1,77 @@
+<?php
+define( "WP_INSTALLING", true );
+require ('wp-config.php');
+require_once( ABSPATH . WPINC . '/registration-functions.php');
+
+
+do_action("activate_header");
+
+get_header();
+?>
+<div id="content" class="widecolumn">
+<style type="text/css">
+form { margin-top: 2em; }
+#submit, #key {
+ width: 90%;
+ font-size: 24px;
+}
+#language {
+ margin-top: .5em;
+}
+.error {
+ background-color: #f66;
+}
+</style>
+<?php
+ if ( empty($_GET['key']) && empty($_POST['key']) ) {
+?>
+<h2>Activation Key Required</h2>
+<form name="activateform" id="activateform" method="post" action="/wp-activate.php">
+<table border="0" width="100%" cellpadding="9">
+<tr>
+<th valign="top">Activation Key:</th>
+<td><input name="key" type="text" id="key" value="" /></td>
+</tr>
+<tr>
+<th scope="row" valign="top">&nbsp;</th>
+<td><input id="submit" type="submit" name="Submit" class="submit" value="Activate &raquo;" /></td>
+</tr>
+</table>
+</form>
+<?php
+ } else {
+ if ( ! empty($_GET['key']) )
+ $key = $_GET['key'];
+ else
+ $key = $_POST['key'];
+
+ $result = wpmu_activate_blog($key);
+ if ( is_wp_error($result) ) {
+ if ( 'already_active' == $result->get_error_code() )
+ echo __('The blog is already active. Please check your email inbox for your username, password, and login instructions.');
+ else
+ echo $result->get_error_message();
+ } else {
+ extract($result);
+ $url = get_blogaddress_by_id($blog_id);
+ $user = new WP_User($user_id);
+?>
+<h2><?php _e('All set!'); ?></h2>
+<table border="0" id="signup-welcome">
+<tr>
+<td width="50%" align="center">
+<h3><?php _e('Username'); ?>:</h3>
+<p><?php echo $user->user_login ?></p></td>
+<td width="50%" align="center">
+<h3><?php _e('Password'); ?>:</h3>
+<p><?php echo $password; ?></p>
+</td>
+</tr>
+</table>
+<h3 class="view"><?php printf(__('<a href="%1$s">View your site</a> or <a href="%2$s">Login</a>'), $url, 'http://wordpress.com/'); ?></h3>
+<?php
+ }
+ }
+?>
+</div>
+<?php get_footer(); ?>
diff --git a/wp-inst/wp-admin/admin-db.php b/wp-inst/wp-admin/admin-db.php
index 32b79f4..84d73fc 100644
--- a/wp-inst/wp-admin/admin-db.php
+++ b/wp-inst/wp-admin/admin-db.php
@@ -94,6 +94,9 @@ function wp_insert_category($catarr) {
$cat_name = wp_specialchars($cat_name);
+ if ( !$update && category_exists($cat_name) )
+ return 0;
+
if (empty ($category_nicename))
$category_nicename = sanitize_title($cat_name);
else
@@ -105,12 +108,22 @@ function wp_insert_category($catarr) {
if (empty ($category_parent))
$category_parent = 0;
+ if ( isset($posts_private) )
+ $posts_private = (int) $posts_private;
+ else
+ $posts_private = 0;
+
+ if ( isset($links_private) )
+ $links_private = (int) $links_private;
+ else
+ $links_private = 0;
+
if (!$update) {
$maxcat = $wpdb->get_var( "SELECT max(cat_ID) FROM {$wpdb->categories}" );
$cat_ID = mt_rand( $maxcat+100, $maxcat+4000 );
- $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('$cat_ID', '$cat_name', '$category_nicename', '$category_description', '$category_parent')");
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('$cat_ID', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
} else {
- $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'");
+ $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
}
if ( $category_nicename == '' ) {
@@ -129,8 +142,6 @@ function wp_insert_category($catarr) {
}
$cat_ID = apply_filters( "cat_id_filter", $cat_ID );
- update_option( 'categories_last_updated', time() );
-
return $cat_ID;
}
@@ -157,7 +168,10 @@ function wp_delete_category($cat_ID) {
$cat_ID = (int) $cat_ID;
// Don't delete the default cat.
- if (1 == $cat_ID)
+ if ( $cat_ID == get_option('default_category') )
+ return 0;
+
+ if ( $cat_ID == get_option('default_link_category') )
return 0;
$category = get_category($cat_ID);
@@ -165,17 +179,37 @@ function wp_delete_category($cat_ID) {
$parent = $category->category_parent;
// Delete the category.
- $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
+ if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") )
+ return 0;
// 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'");
+ // Only set posts and links to the default category if they're not in another category already.
+ $default_cat = get_option('default_category');
+ $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
+ if ( is_array($posts) ) foreach ($posts as $post_id) {
+ $cats = wp_get_post_cats('', $post_id);
+ if ( 1 == count($cats) )
+ $cats = array($default_cat);
+ else
+ $cats = array_diff($cats, array($cat_ID));
+ wp_set_post_cats('', $post_id, $cats);
+ }
+ $default_link_cat = get_option('default_link_category');
+ $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'");
+ if ( is_array($links) ) foreach ($links as $link_id) {
+ $cats = wp_get_link_cats($link_id);
+ if ( 1 == count($cats) )
+ $cats = array($default_link_cat);
+ else
+ $cats = array_diff($cats, array($cat_ID));
+ wp_set_link_cats($link_id, $cats);
+ }
+
wp_cache_delete($cat_ID, 'category');
wp_cache_delete('all_category_ids', 'category');
- update_option( 'categories_last_updated', time() );
do_action('delete_category', $cat_ID);
@@ -244,10 +278,18 @@ function wp_delete_user($id, $reassign = 'novalue') {
return true;
}
+function wp_revoke_user($id) {
+ $id = (int) $id;
+
+ $user = new WP_User($id);
+ $user->remove_all_caps();
+}
+
function get_link($link_id, $output = OBJECT) {
global $wpdb;
$link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$link_id'");
+ $link->link_category = wp_get_link_cats($link_id);
if ( $output == OBJECT ) {
return $link;
@@ -284,19 +326,26 @@ function wp_insert_link($linkdata) {
if ( empty($link_notes) )
$link_notes = '';
+ // Make sure we set a valid category
+ if (0 == count($link_category) || !is_array($link_category)) {
+ $link_category = array(get_option('default_link_category'));
+ }
+
if ( $update ) {
$wpdb->query("UPDATE $wpdb->links SET link_url='$link_url',
link_name='$link_name', link_image='$link_image',
- link_target='$link_target', link_category='$link_category',
+ link_target='$link_target',
link_visible='$link_visible', link_description='$link_description',
link_rating='$link_rating', link_rel='$link_rel',
link_notes='$link_notes', link_rss = '$link_rss'
WHERE link_id='$link_id'");
} else {
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_category', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
$link_id = $wpdb->insert_id;
}
+ wp_set_link_cats($link_id, $link_category);
+
if ( $update )
do_action('edit_link', $link_id);
else
@@ -315,8 +364,16 @@ function wp_update_link($linkdata) {
// Escape data pulled from DB.
$link = add_magic_quotes($link);
+ // Passed link category list overwrites existing category list if not empty.
+ if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])
+ && 0 != count($linkdata['link_category']) )
+ $link_cats = $linkdata['link_category'];
+ else
+ $link_cats = $link['link_category'];
+
// Merge old and new fields with new fields overwriting old ones.
$linkdata = array_merge($link, $linkdata);
+ $linkdata['link_category'] = $link_cats;
return wp_insert_link($linkdata);
}
@@ -325,9 +382,88 @@ function wp_delete_link($link_id) {
global $wpdb;
do_action('delete_link', $link_id);
+
+ $categories = wp_get_link_cats($link_id);
+ if( is_array( $categories ) ) {
+ foreach ( $categories as $category ) {
+ $wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'");
+ wp_cache_delete($category, 'category');
+ }
+ }
+
+ $wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'");
return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'");
}
+function wp_get_link_cats($link_ID = 0) {
+ global $wpdb;
+
+ $sql = "SELECT category_id
+ FROM $wpdb->link2cat
+ WHERE link_id = $link_ID
+ ORDER BY category_id";
+
+ $result = $wpdb->get_col($sql);
+
+ if ( !$result )
+ $result = array();
+
+ return array_unique($result);
+}
+
+function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
+ global $wpdb;
+ // If $link_categories isn't already an array, make it one:
+ if (!is_array($link_categories) || 0 == count($link_categories))
+ $link_categories = array(get_option('default_link_category'));
+
+ $link_categories = array_unique($link_categories);
+
+ // First the old categories
+ $old_categories = $wpdb->get_col("
+ SELECT category_id
+ FROM $wpdb->link2cat
+ WHERE link_id = $link_ID");
+
+ if (!$old_categories) {
+ $old_categories = array();
+ } else {
+ $old_categories = array_unique($old_categories);
+ }
+
+ // Delete any?
+ $delete_cats = array_diff($old_categories,$link_categories);
+
+ if ($delete_cats) {
+ foreach ($delete_cats as $del) {
+ $wpdb->query("
+ DELETE FROM $wpdb->link2cat
+ WHERE category_id = $del
+ AND link_id = $link_ID
+ ");
+ }
+ }
+
+ // Add any?
+ $add_cats = array_diff($link_categories, $old_categories);
+
+ if ($add_cats) {
+ foreach ($add_cats as $new_cat) {
+ $wpdb->query("
+ INSERT INTO $wpdb->link2cat (link_id, category_id)
+ VALUES ($link_ID, $new_cat)");
+ }
+ }
+
+ // Update category counts.
+ $all_affected_cats = array_unique(array_merge($link_categories, $old_categories));
+ foreach ( $all_affected_cats as $cat_id ) {
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
+ $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
+ wp_cache_delete($cat_id, 'category');
+ }
+} // wp_set_link_cats()
+
function post_exists($title, $content = '', $post_date = '') {
global $wpdb;
@@ -350,4 +486,83 @@ function comment_exists($comment_author, $comment_date) {
WHERE comment_author = '$comment_author' AND comment_date = '$comment_date'");
}
+function wpmu_delete_blog($blog_id, $drop = false) {
+ global $wpdb, $wpmuBaseTablePrefix;
+
+ if ( $blog_id != $wpdb->blogid ) {
+ $switch = true;
+ switch_to_blog($blog_id);
+ }
+
+ do_action('delete_blog', $blog_id, $drop);
+
+ $users = get_users_of_blog($blog_id);
+
+ // Remove users from this blog.
+ if ( !empty($users) ) foreach ($users as $user) {
+ remove_user_from_blog($user->user_id, $blog_id);
+ }
+
+ update_blog_status( $wpdb->blogid, 'deleted', 1 );
+
+ if ( $drop ) {
+ $drop_tables = array( $wpmuBaseTablePrefix . $blog_id . "_categories",
+ $wpmuBaseTablePrefix . $blog_id . "_comments",
+ $wpmuBaseTablePrefix . $blog_id . "_linkcategories",
+ $wpmuBaseTablePrefix . $blog_id . "_links",
+ $wpmuBaseTablePrefix . $blog_id . "_link2cat",
+ $wpmuBaseTablePrefix . $blog_id . "_options",
+ $wpmuBaseTablePrefix . $blog_id . "_post2cat",
+ $wpmuBaseTablePrefix . $blog_id . "_postmeta",
+ $wpmuBaseTablePrefix . $blog_id . "_posts",
+ $wpmuBaseTablePrefix . $blog_id . "_referer_visitLog",
+ $wpmuBaseTablePrefix . $blog_id . "_referer_blacklist" );
+ reset( $drop_tables );
+
+ while( list( $key, $val ) = each( $drop_tables ) )
+ $wpdb->query( "DROP TABLE IF EXISTS $val" );
+
+ $wpdb->query( "DELETE FROM $wpdb->blogs WHERE blog_id = '$blog_id'" );
+ }
+
+ if ( $switch )
+ restore_current_blog();
+}
+
+function wpmu_delete_user($id) {
+ global $wpdb;
+
+ $id = (int) $id;
+ $user = get_userdata($id);
+
+ do_action('wpmu_delete_user', $id);
+
+ $blogs = get_blogs_of_user($id);
+
+ if ( ! empty($blogs) ) foreach ($blogs as $blog) {
+ switch_to_blog($blog->userblog_id);
+ remove_user_from_blog($id, $blog->userblog_id);
+
+ $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
+
+ if ($post_ids) {
+ foreach ($post_ids as $post_id)
+ wp_delete_post($post_id);
+ }
+
+ // Clean links
+ $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
+
+ restore_current_blog();
+ }
+
+ $wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id");
+ $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$id'");
+
+ wp_cache_delete($id, 'users');
+ wp_cache_delete($user->user_login, 'userlogins');
+
+ return true;
+}
+
?>
diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php
index b33f94e..527df20 100644
--- a/wp-inst/wp-admin/admin-functions.php
+++ b/wp-inst/wp-admin/admin-functions.php
@@ -75,8 +75,8 @@ function write_post() {
$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");
+ $_POST['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss);
+ $_POST['post_date_gmt'] = get_gmt_from_date($_POST['post_date']);
}
// Create the post.
@@ -361,15 +361,38 @@ function get_category_to_edit($id) {
return $category;
}
+function wp_dropdown_roles( $default = false ) {
+ global $wp_roles;
+ $r = '';
+ foreach($wp_roles->role_names as $role => $name)
+ if ( $default == $role ) // Make default first in list
+ $p = "\n\t<option selected='selected' value='$role'>$name</option>";
+ else
+ $r .= "\n\t<option value='$role'>$name</option>";
+ echo $p . $r;
+}
+
+
// Creates a new user from the "Users" form using $_POST information.
function add_user() {
- return edit_user();
+ if ( func_num_args() ) { // The hackiest hack that ever did hack
+ global $current_user, $wp_roles;
+ $user_id = func_get_arg(0);
+ if (isset ($_POST['role'])) {
+ if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users')) {
+ $user = new WP_User($user_id);
+ $user->set_role($_POST['role']);
+ }
+ }
+ } else {
+ add_action('user_register', 'add_user'); // See above
+ return edit_user();
+ }
}
function edit_user($user_id = 0) {
global $current_user, $wp_roles, $wpdb;
-
if ($user_id != 0) {
$update = true;
$user->ID = $user_id;
@@ -417,49 +440,49 @@ function edit_user($user_id = 0) {
if (isset ($_POST['yim']))
$user->yim = wp_specialchars(trim($_POST['yim']));
- $errors = array ();
+ $errors = new WP_Error();
/* checking that username has been typed */
if ($user->user_login == '')
- $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
+ $errors->add('user_login', __('<strong>ERROR</strong>: Please enter a username.'));
/* checking the password has been typed twice */
do_action('check_passwords', array ($user->user_login, & $pass1, & $pass2));
if (!$update) {
if ($pass1 == '' || $pass2 == '')
- $errors['pass'] = __('<strong>ERROR</strong>: Please enter your password twice.');
+ $errors->add('pass', __('<strong>ERROR</strong>: Please enter your password twice.'));
} else {
if ((empty ($pass1) && !empty ($pass2)) || (empty ($pass2) && !empty ($pass1)))
- $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once.");
+ $errors->add('pass', __("<strong>ERROR</strong>: you typed your new password only once."));
}
/* Check for "\" in password */
if( strpos( " ".$pass1, "\\" ) )
- $errors['pass'] = __('<strong>ERROR</strong>: Passwords may not contain the character "\\".');
+ $errors->add('pass', __('<strong>ERROR</strong>: Passwords may not contain the character "\\".'));
/* checking the password has been typed twice the same */
if ($pass1 != $pass2)
- $errors['pass'] = __('<strong>ERROR</strong>: Please type the same password in the two password fields.');
+ $errors->add('pass', __('<strong>ERROR</strong>: Please type the same password in the two password fields.'));
if (!empty ($pass1))
$user->user_pass = $pass1;
if ( !validate_username($user->user_login) )
- $errors['user_login'] = __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.');
+ $errors->add('user_login', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'));
if (!$update && username_exists($user->user_login))
- $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
+ $errors->add('user_login', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
/* checking e-mail address */
if (empty ($user->user_email)) {
- $errors['user_email'] = __("<strong>ERROR</strong>: please type an e-mail address");
+ $errors->add('user_email', __("<strong>ERROR</strong>: please type an e-mail address"));
} else
if (!is_email($user->user_email)) {
- $errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct");
+ $errors->add('user_email', __("<strong>ERROR</strong>: the email address isn't correct"));
}
- if (count($errors) != 0)
+ if ( $errors->get_error_codes() )
return $errors;
if ($update) {
@@ -468,8 +491,7 @@ function edit_user($user_id = 0) {
$user_id = wp_insert_user(get_object_vars($user));
wp_new_user_notification($user_id);
}
-
- return $errors;
+ return $user_id;
}
@@ -481,6 +503,7 @@ function get_link_to_edit($link_id) {
$link->link_description = wp_specialchars($link->link_description);
$link->link_notes = wp_specialchars($link->link_notes);
$link->link_rss = wp_specialchars($link->link_rss);
+ $link->post_category = $link->link_category;
return $link;
}
@@ -514,14 +537,7 @@ function edit_link($link_id = '') {
$_POST['link_name'] = wp_specialchars($_POST['link_name']);
$_POST['link_image'] = wp_specialchars($_POST['link_image']);
$_POST['link_rss'] = wp_specialchars($_POST['link_rss']);
- $auto_toggle = get_autotoggle($_POST['link_category']);
-
- // if we are in an auto toggle category and this one is visible then we
- // need to make the others invisible before we add this new one.
- // FIXME Add category toggle func.
- //if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {
- // $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");
- //}
+ $_POST['link_category'] = $_POST['post_category'];
if ( !empty($link_id) ) {
$_POST['link_id'] = $link_id;
@@ -553,7 +569,7 @@ function checked($checked, $current) {
function return_categories_list($parent = 0) {
global $wpdb;
- return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC LIMIT 100");
+ return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC");
}
function sort_cats($cat1, $cat2) {
@@ -561,7 +577,7 @@ function sort_cats($cat1, $cat2) {
}
function get_nested_categories($default = 0, $parent = 0) {
- global $post_ID, $mode, $wpdb;
+ global $post_ID, $link_id, $mode, $wpdb;
if ($post_ID) {
$checked_categories = $wpdb->get_col("
@@ -574,7 +590,17 @@ function get_nested_categories($default = 0, $parent = 0) {
// No selected categories, strange
$checked_categories[] = $default;
}
+ } else if ($link_id) {
+ $checked_categories = $wpdb->get_col("
+ SELECT category_id
+ FROM $wpdb->categories, $wpdb->link2cat
+ WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
+ ");
+ if (count($checked_categories) == 0) {
+ // No selected categories, strange
+ $checked_categories[] = $default;
+ }
} else {
$checked_categories[] = $default;
}
@@ -584,6 +610,10 @@ function get_nested_categories($default = 0, $parent = 0) {
if (is_array($cats)) {
foreach ($cats as $cat) {
+ if ( $cat == 0 ) { // HACK, added 2006-05-13
+ $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0");
+ continue;
+ }
$result[$cat]['children'] = get_nested_categories($default, $cat);
$result[$cat]['cat_ID'] = $cat;
$result[$cat]['checked'] = in_array($cat, $checked_categories);
@@ -598,12 +628,12 @@ function get_nested_categories($default = 0, $parent = 0) {
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";
+ echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label></li>\n";
- if (isset ($category['children'])) {
- echo "\n<span class='cat-nest'>\n";
+ if ( $category['children'] ) {
+ echo "<ul>\n";
write_nested_categories($category['children']);
- echo "</span>\n";
+ echo "</ul>\n";
}
}
}
@@ -621,15 +651,20 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
if ($categories) {
foreach ($categories as $category) {
+ if ( $category->cat_ID == 0 ) { // HACK, added 2006-05-13
+ $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0");
+ continue;
+ }
if ($category->category_parent == $parent) {
- $category->cat_name = wp_specialchars($category->cat_name);
+ $category->cat_name = wp_specialchars($category->cat_name,'double');
$pad = str_repeat('&#8212; ', $level);
if ( current_user_can('manage_categories') ) {
$edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
$default_cat_id = get_option('default_category');
+ $default_link_cat_id = get_option('default_link_category');
- if ($category->cat_ID != $default_cat_id)
- $edit .= "<td><a href='categories.php?action=delete&amp;cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category &quot;%s&quot;. All of its posts will go to the default category.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>";
+ if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) )
+ $edit .= "<td><a href='categories.php?action=delete&amp;cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category &quot;%s&quot;.\\nAll of its posts will go into the default category of &quot;%s&quot;\\nAll of its bookmarks will go into the default category of &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes($category->cat_name), addslashes(wp_specialchars(get_catname($default_cat_id),'double')), addslashes(wp_specialchars(get_catname($default_link_cat_id),'double')))."' );\" class='delete'>".__('Delete')."</a>";
else
$edit .= "<td style='text-align:center'>".__("Default");
}
@@ -637,9 +672,13 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
$edit = '';
$class = ('alternate' == $class) ? '' : 'alternate';
+
+ $category->category_count = number_format( $category->category_count );
+ $category->link_count = number_format( $category->link_count );
echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td>
<td>$category->category_description</td>
- <td>$category->category_count</td>
+ <td align='center'>$category->category_count</td>
+ <td align='center'>$category->link_count</td>
<td>$edit</td>
</tr>";
cat_rows($category->cat_ID, $level +1, $categories);
@@ -678,7 +717,7 @@ function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) {
<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 ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
- <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td>
+ <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
</tr>
<?php
@@ -686,6 +725,33 @@ function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) {
}
}
+function user_row( $user_object, $style = '' ) {
+ if ( !(is_object($user_object) && is_a($user_object, 'WP_User')) )
+ $user_object = new WP_User( (int) $user_object );
+ $email = $user_object->user_email;
+ $url = $user_object->user_url;
+ $short_url = str_replace('http://', '', $url);
+ $short_url = str_replace('www.', '', $short_url);
+ if ('/' == substr($short_url, -1))
+ $short_url = substr($short_url, 0, -1);
+ if (strlen($short_url) > 35)
+ $short_url = substr($short_url, 0, 32).'...';
+ $numposts = get_usernumposts($user_object->ID);
+ if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_object->ID' title='" . __('View posts') . "'>$numposts</a>";
+ $r = "<tr id='user-$user_object->ID'$style>
+ <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
+ <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
+ <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></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>";
+ $r .= "\n\t\t<td align='right'>$numposts</td>";
+ $r .= "\n\t\t<td>";
+ if (current_user_can('edit_users'))
+ $r .= "<a href='user-edit.php?user_id=$user_object->ID' class='edit'>".__('Edit')."</a>";
+ $r .= "</td>\n\t</tr>";
+ return $r;
+}
+
function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {
global $wpdb, $bgcolor;
if (!$categories) {
@@ -694,7 +760,6 @@ function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $lev
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'";
@@ -709,21 +774,9 @@ function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $lev
}
}
-function link_category_dropdown($fieldname, $selected = 0) {
+function return_link_categories_list($parent = 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";
+ return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC");
}
function wp_create_thumbnail($file, $max_side, $effect = '') {
@@ -816,6 +869,7 @@ function wp_create_thumbnail($file, $max_side, $effect = '') {
if (!empty ($error)) {
return $error;
} else {
+ apply_filters( 'wp_create_thumbnail', $thumbpath );
return $thumbpath;
}
}
@@ -835,19 +889,21 @@ function has_meta($postid) {
function list_meta($meta) {
global $post_ID;
// Exit if no meta
- if (!$meta)
+ if (!$meta) {
+ echo '<tbody id="the-list"></tbody>'; //TBODY needed for list-manipulation JS
return;
+ }
$count = 0;
?>
-<table id='meta-list' cellpadding="3">
+ <thead>
<tr>
<th><?php _e('Key') ?></th>
<th><?php _e('Value') ?></th>
<th colspan='2'><?php _e('Action') ?></th>
</tr>
+ </thead>
<?php
-
-
+ $r ="\n\t<tbody id='the-list'>";
foreach ($meta as $entry) {
++ $count;
if ($count % 2)
@@ -856,18 +912,20 @@ function list_meta($meta) {
$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'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />
- <input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>
- </tr>
- ";
- }
- echo "
- </table>
- ";
+ $key_js = addslashes(wp_specialchars( $entry['meta_key'], 'double' ));
+ $entry['meta_key'] = wp_specialchars( $entry['meta_key'], true );
+ $entry['meta_value'] = wp_specialchars( $entry['meta_value'], true );
+ $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
+ $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>";
+ $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>";
+ $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />";
+ $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '";
+ $r .= sprintf(__("You are about to delete the &quot;%s&quot; custom field on this post.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), $key_js);
+ $r .= "' );\" class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>";
+ $r .= "\n\t</tr>";
+ }
+ echo $r;
+ echo "\n\t</tbody>";
}
// Get a list of previously defined keys
@@ -893,7 +951,7 @@ function meta_form() {
LIMIT 10");
?>
<h3><?php _e('Add a new custom field:') ?></h3>
-<table cellspacing="3" cellpadding="3">
+<table id="newmeta" cellspacing="3" cellpadding="3">
<tr>
<th colspan="2"><?php _e('Key') ?></th>
<th><?php _e('Value') ?></th>
@@ -917,13 +975,14 @@ function meta_form() {
</tr>
</table>
-<p class="submit"><input type="submit" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
+<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
<?php
}
function add_meta($post_ID) {
global $wpdb;
+ $post_ID = (int) $post_ID;
$metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect'])));
$metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput'])));
@@ -933,7 +992,7 @@ function add_meta($post_ID) {
// 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)
+ if ('#NONE#' != $metakeyselect)
$metakey = $metakeyselect;
if ($metakeyinput)
@@ -944,23 +1003,34 @@ function add_meta($post_ID) {
(post_id,meta_key,meta_value)
VALUES ('$post_ID','$metakey','$metavalue')
");
+ return $wpdb->insert_id;
}
+ return false;
} // add_meta
function delete_meta($mid) {
global $wpdb;
+ $mid = (int) $mid;
- $result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");
+ return $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");
}
function update_meta($mid, $mkey, $mvalue) {
global $wpdb;
+ $mid = (int) $mid;
return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");
}
+function get_post_meta_by_id($mid) {
+ global $wpdb;
+ $mid = (int) $mid;
+
+ return $wpdb->get_row("SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'");
+}
+
function touch_time($edit = 1, $for_post = 1) {
- global $month, $post, $comment;
+ global $wp_locale, $post, $comment;
if ( $for_post )
$edit = ( ('draft' == $post->post_status) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date) ) ? false : true;
@@ -976,29 +1046,25 @@ function touch_time($edit = 1, $for_post = 1) {
$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";
+ echo "<select name=\"mm\" onchange=\"edit_date.checked=true\">\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";
+ echo ' selected="selected"';
+ echo '>' . $wp_locale->get_month($i) . "</option>\n";
}
?>
</select>
-<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" />
-<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" /> @
-<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" /> :
-<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" />
-<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
+<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"/>
+<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true" /> @
+<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> :
+<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
+<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
<?php
if ( $edit ) {
_e('Existing timestamp');
- echo ": {$month[$mm]} $jj, $aa @ $hh:$mn";
+ //echo ': ' . $wp_locale->get_month($mm) . "$jj, $aa @ $hh:$mn";
+ echo sprintf(__(': %1$s %2$s, %3$s @ %4$s:%5$s'), $wp_locale->get_month($mm), $jj, $aa, $hh, $mn);
}
?>
</fieldset>
@@ -1023,11 +1089,15 @@ function insert_with_markers($filename, $marker, $insertion) {
$foundit = false;
if ($markerdata) {
$state = true;
- foreach ($markerdata as $markerline) {
+ foreach ($markerdata as $n => $markerline) {
if (strstr($markerline, "# BEGIN {$marker}"))
$state = false;
- if ($state)
- fwrite($f, "{$markerline}\n");
+ if ($state) {
+ if ( $n + 1 < count($markerdata) )
+ fwrite($f, "{$markerline}\n");
+ else
+ fwrite($f, "{$markerline}");
+ }
if (strstr($markerline, "# END {$marker}")) {
fwrite($f, "# BEGIN {$marker}\n");
if (is_array($insertion))
@@ -1829,8 +1899,10 @@ function wp_handle_upload(&$file, $overrides = false) {
// Compute the URL
$url = $uploads['url'] . "/$filename";
+
+ $return = apply_filters( 'wp_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $type) );
- return array('file' => $new_file, 'url' => $url, 'type' => $type);
+ return $return;
}
function wp_shrink_dimensions($width, $height, $wmax = 128, $hmax = 96) {
diff --git a/wp-inst/wp-admin/categories.js b/wp-inst/wp-admin/categories.js
index 5be5a62..46ae62f 100644
--- a/wp-inst/wp-admin/categories.js
+++ b/wp-inst/wp-admin/categories.js
@@ -1,5 +1,5 @@
-addLoadEvent(newCategoryAddIn);
-function newCategoryAddIn() {
- if (!theList.theList) return false;
- document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); };
-}
+addLoadEvent(newCategoryAddIn);
+function newCategoryAddIn() {
+ if (!theList.theList) return false;
+ document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); };
+}
diff --git a/wp-inst/wp-admin/categories.php b/wp-inst/wp-admin/categories.php
index 8a96872..28d6925 100644
--- a/wp-inst/wp-admin/categories.php
+++ b/wp-inst/wp-admin/categories.php
@@ -3,7 +3,6 @@ require_once('admin.php');
$title = __('Categories');
$parent_file = 'edit.php';
-$list_js = true;
$wpvarstoreset = array('action','cat');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
@@ -25,6 +24,8 @@ switch($action) {
case 'addcat':
+ check_admin_referer();
+
if ( !current_user_can('manage_categories') )
die (__('Cheatin&#8217; uh?'));
@@ -43,13 +44,12 @@ case 'delete':
$cat_ID = (int) $_GET['cat_ID'];
$cat_name = get_catname($cat_ID);
- $default_category = get_option( "default_category" );
- if ( $default_category == $cat_ID )
+ // Don't delete the default cats.
+ if ( $cat_ID == get_option('default_category') )
die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
- $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories");
- if( count( $categories ) == 1 )
- die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the only one"), $cat_name));
+ if ( $cat_ID == get_option('default_link_category') )
+ die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one for bookmarks"), $cat_name));
wp_delete_category($cat_ID);
@@ -69,27 +69,23 @@ case 'edit':
<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" id='cat_name' value="<?php echo wp_specialchars($category->cat_name ); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" />
+ <th width="33%" scope="row" valign="top"><label for="cat_name"><?php _e('Category name:') ?></label></th>
+ <td width="67%"><input name="cat_name" id="cat_name" type="text" value="<?php echo wp_specialchars($category->cat_name); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" />
<div style='display:none; height: 100px; width: 200px; overflow: auto; border: 1px solid #ccc; background: #eee; margin: 5px; padding: 5px;' id="searchresults"><?php _e( 'Search Results' ) ?></div>
<?php AJAX_search_box( "wpmu-edit.php?action=searchcategories&search=", "cat_name", "searchresults" ); ?>
<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'>
+ <select name='category_parent' id='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>
+ <th scope="row" valign="top"><label for="category_description"><?php _e('Description:') ?></label></th>
+ <td><textarea name="category_description" id="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>
@@ -101,13 +97,11 @@ case 'edit':
break;
case 'editedcat':
+ check_admin_referer();
+
if ( !current_user_can('manage_categories') )
die (__('Cheatin&#8217; uh?'));
- if( $_POST[ 'cat_ID' ] == get_option( 'default_category' ) ) {
- header( "Location: categories.php" );
- }
-
wp_update_category($_POST);
header('Location: categories.php?message=3');
@@ -115,6 +109,7 @@ break;
default:
+$list_js = true;
require_once ('admin-header.php');
$messages[1] = __('Category added.');
@@ -132,43 +127,49 @@ $messages[3] = __('Category updated.');
<?php else : ?>
<h2><?php _e('Categories') ?> </h2>
<?php endif; ?>
-<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
+<table width="100%" cellpadding="3" cellspacing="3">
+ <thead>
<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 scope="col" width="90"><?php _e('Posts') ?></th>
+ <th scope="col" width="90"><?php _e('Bookmarks') ?></th>
<th colspan="2"><?php _e('Action') ?></th>
</tr>
+ </thead>
+ <tbody id="the-list">
<?php
cat_rows();
?>
+ </tbody>
</table>
-<div id="ajax-response"></div>
-
</div>
<?php if ( current_user_can('manage_categories') ) : ?>
<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(get_option('default_category'))) ?></p>
+<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and bookmarks in that category. Instead, posts in the deleted category are set to the category <strong>%s</strong> and bookmarks are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>
+<p><?php _e('<strong>Also Note:</strong><br />Categories will appear on your blog once you have posted something in them. Empty categories remain invisible.'); ?></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" id='cat_name' value="" /></p>
+ <div class="alignleft"><?php _e('Name:') ?><br />
+ <input type="text" name="cat_name" id="cat_name" value="" /></p>
<div style='display:none; height: 100px; width: 200px; overflow: auto; border: 1px solid #ccc; background: #eee; margin: 5px; padding: 5px;' id="searchresults"><?php _e( 'Search Results' ) ?></div>
<?php AJAX_search_box( "wpmu-edit.php?action=searchcategories&search=", "cat_name", "searchresults" ); ?>
<p><?php _e('Category parent:') ?><br />
- <select name='category_parent' class='postform'>
+ <select name='category_parent' id='category_parent' class='postform'>
<option value='0'><?php _e('None') ?></option>
<?php wp_dropdown_cats(0); ?>
- </select></p>
+ </select>
+ </div>
+ <div id="ajax-response" class="alignleft"></div>
+ <br class="clear" />
<p><?php _e('Description: (optional)') ?> <br />
- <textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>
+ <textarea name="category_description" id="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>
@@ -179,4 +180,5 @@ break;
}
include('admin-footer.php');
+
?>
diff --git a/wp-inst/wp-admin/edit-link-form.php b/wp-inst/wp-admin/edit-link-form.php
index 8a049b7..b2d60c8 100644
--- a/wp-inst/wp-admin/edit-link-form.php
+++ b/wp-inst/wp-admin/edit-link-form.php
@@ -1,236 +1,254 @@
-<?php
-if ( ! empty($link_id) ) {
- $editing = true;
- $heading = __('Edit a link:');
- $submit_text = __('Save Changes &raquo;');
- $form = '<form action="" method="post" name="editlink" id="editlink">';
-} else {
- $editing = false;
- $heading = __('<strong>Add</strong> a link:');
- $submit_text = __('Add Link &raquo;');
- $form = '<form name="addlink" method="post" action="link-manager.php">';
-}
-
-function xfn_check($class, $value = '', $type = 'check') {
- global $link;
-
- $link_rel = $link->link_rel;
- $rels = preg_split('/\s+/', $link_rel);
-
- if ('' != $value && in_array($value, $rels) ) {
- echo ' checked="checked"';
- }
-
- if ('' == $value) {
- if ('family' == $class && !strstr($link_rel, 'child') && !strstr($link_rel, 'parent') && !strstr($link_rel, 'sibling') && !strstr($link_rel, 'spouse') && !strstr($link_rel, 'kin')) echo ' checked="checked"';
- if ('friendship' == $class && !strstr($link_rel, 'friend') && !strstr($link_rel, 'acquaintance') && !strstr($link_rel, 'contact') ) echo ' checked="checked"';
- if ('geographical' == $class && !strstr($link_rel, 'co-resident') && !strstr($link_rel, 'neighbor') ) echo ' checked="checked"';
- if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
- }
-}
-
-?>
-
-<div class="wrap">
- <?php echo $form ?>
- <h2><?php echo $heading ?></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="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%;" /></td>
- </tr>
- <tr>
- <th scope="row"><?php _e('Link Name:') ?></th>
- <td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
- </tr>
- <tr>
- <th scope="row"><?php _e('Short description:') ?></th>
- <td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
- </tr>
- <tr>
- <th scope="row"><?php _e('Category:') ?></th>
- <td><?php link_category_dropdown('link_category', $link->link_category); ?></td>
- </tr>
-</table>
-</fieldset>
- <p class="submit">
- <input type="submit" name="submit" value="<?php echo $submit_text ?>" />
- </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="link_rel" id="link_rel" size="50" value="<?php echo $link->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 echo $submit_text ?>" />
- </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="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
- </tr>
-<tr>
- <th scope="row"><?php _e('RSS URI:') ?> </th>
- <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
- </tr>
- <tr>
- <th scope="row"><?php _e('Notes:') ?></th>
- <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
- </tr>
- <tr>
- <th scope="row"><?php _e('Rating:') ?></th>
- <td><select name="link_rating" size="1">
-<?php
- for ($r = 0; $r < 10; $r++) {
- echo(' <option value="'.$r.'" ');
- if ($link->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="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
- <code>_blank</code></label><br />
-<label>
-<input type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
-<code>_top</code></label><br />
-<label>
-<input type="radio" name="link_target" value="" <?php echo(($link->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="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
-<?php _e('Yes') ?></label><br /><label>
-<input type="radio" name="link_visible" <?php if ($link->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 echo $submit_text ?>" /></p>
-<?php if ( $editing ) : ?>
- <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 ?>" />
-<?php else: ?>
- <input type="hidden" name="action" value="Add" />
-<?php endif; ?>
-</form>
-</div>
+<?php
+if ( ! empty($link_id) ) {
+ $heading = __('Edit Bookmark');
+ $submit_text = __('Save Changes &raquo;');
+ $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
+} else {
+ $heading = __('Create Bookmark');
+ $submit_text = __('Add Bookmark &raquo;');
+ $form = '<form name="addlink" id="addlink" method="post" action="link.php">';
+}
+
+function xfn_check($class, $value = '', $type = 'check') {
+ global $link;
+
+ $link_rel = $link->link_rel;
+ $rels = preg_split('/\s+/', $link_rel);
+
+ if ('' != $value && in_array($value, $rels) ) {
+ echo ' checked="checked"';
+ }
+
+ if ('' == $value) {
+ if ('family' == $class && !strstr($link_rel, 'child') && !strstr($link_rel, 'parent') && !strstr($link_rel, 'sibling') && !strstr($link_rel, 'spouse') && !strstr($link_rel, 'kin')) echo ' checked="checked"';
+ if ('friendship' == $class && !strstr($link_rel, 'friend') && !strstr($link_rel, 'acquaintance') && !strstr($link_rel, 'contact') ) echo ' checked="checked"';
+ if ('geographical' == $class && !strstr($link_rel, 'co-resident') && !strstr($link_rel, 'neighbor') ) echo ' checked="checked"';
+ if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
+ }
+}
+?>
+
+<div class="wrap">
+<h2><?php echo $heading ?></h2>
+<?php echo $form ?>
+
+<div id="poststuff">
+<div id="moremeta">
+<div id="grabit" class="dbx-group">
+
+<fieldset id="categorydiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
+<div class="dbx-content">
+<p id="jaxcat"></p>
+<ul id="categorychecklist"><?php dropdown_categories(get_settings('default_link_category')); ?></ul>
+</div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Target') ?></h3>
+<div class="dbx-content">
+<label for="link_target_blank" class="selectit">
+<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
+<code>_blank</code></label>
+<label for="link_target_top" class="selectit">
+<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
+<code>_top</code></label>
+<label for="link_target_none" class="selectit">
+<input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
+<?php _e('none') ?></label>
+</div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Visible') ?></h3>
+<div class="dbx-content">
+<label for="link_visible_yes" class="selectit">
+<input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
+<?php _e('Yes') ?></label>
+<label for="link_visible_no" class="selectit">
+<input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
+<?php _e('No') ?></label>
+</div>
+</fieldset>
+
+</div>
+</div>
+
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+<tr>
+<th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('URI:') ?></label></th>
+<td width="80%"><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%" /></td>
+</tr>
+<tr>
+<th scope="row" valign="top"><label for="link_name"><?php _e('Name:') ?></label></th>
+<td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
+</tr>
+<tr>
+<th scope="row" valign="top"><label for="link_description"><?php _e('Description:') ?></label></th>
+<td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
+</tr>
+</table>
+
+<p class="submit">
+<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
+</p>
+
+<div id="advancedstuff" class="dbx-group" >
+
+<fieldset id="xfn" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3>
+<div class="dbx-content">
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="20%" scope="row"><?php _e('rel:') ?></th>
+ <td width="80%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->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>
+</div>
+</fieldset>
+
+<fieldset id="advanced" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Advanced') ?></h3>
+<div class="dbx-content">
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="20%" scope="row"><?php _e('Image URI:') ?></th>
+ <td width="80%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('RSS URI:') ?> </th>
+ <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Notes:') ?></th>
+ <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Rating:') ?></th>
+ <td><select name="link_rating" size="1">
+ <?php
+ for ($r = 0; $r < 10; $r++) {
+ echo(' <option value="'.$r.'" ');
+ if ($link->link_rating == $r)
+ echo 'selected="selected"';
+ echo('>'.$r.'</option>');
+ }
+ ?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
+ </td>
+ </tr>
+</table>
+</fieldset>
+</div>
+
+<?php if ( $link_id ) : ?>
+<input type="hidden" name="action" value="save" />
+<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 ?>" />
+<?php else: ?>
+<input type="hidden" name="action" value="add" />
+<?php endif; ?>
+</div>
+</form>
+</div>
diff --git a/wp-inst/wp-admin/import.php b/wp-inst/wp-admin/import.php
index 2ed94ee..743da65 100644
--- a/wp-inst/wp-admin/import.php
+++ b/wp-inst/wp-admin/import.php
@@ -1,62 +1,62 @@
-<?php
-require_once ('admin.php');
-$title = __('Import');
-$parent_file = 'import.php';
-require_once ('admin-header.php');
-?>
-
-<div class="wrap">
-<h2><?php _e('Import'); ?></h2>
-<p><?php _e('If you have posts or comments in another system WordPress can import them into your current blog. To get started, choose a system to import from below:'); ?></p>
-
-<?php
-
-// Load all importers so that they can register.
-$import_loc = 'wp-admin/import';
-$import_root = ABSPATH.$import_loc;
-$imports_dir = @ dir($import_root);
-if ($imports_dir) {
- while (($file = $imports_dir->read()) !== false) {
- if (preg_match('|^\.+$|', $file))
- continue;
- if (preg_match('|\.php$|', $file))
- require_once("$import_root/$file");
- }
-}
-
-$importers = get_importers();
-
-if (empty ($importers)) {
- echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful
-} else {
-?>
-<table width="100%" cellpadding="3" cellspacing="3">
-
-<?php
- $style = '';
- foreach ($importers as $id => $data) {
- $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate';
- $action = "<a href='admin.php?import=$id' title='{$data[1]}'>{$data[0]}</a>";
-
- if ($style != '')
- $style = 'class="'.$style.'"';
- echo "
- <tr $style>
- <td class=\"togl\">$action</td>
- <td class=\"desc\">{$data[1]}</td>
- </tr>";
- }
-?>
-
-</table>
-<?php
-}
-?>
-
-</div>
-
-<?php
-
-include ('admin-footer.php');
-?>
-
+<?php
+require_once ('admin.php');
+$title = __('Import');
+$parent_file = 'import.php';
+require_once ('admin-header.php');
+?>
+
+<div class="wrap">
+<h2><?php _e('Import'); ?></h2>
+<p><?php _e('If you have posts or comments in another system WordPress can import them into your current blog. To get started, choose a system to import from below:'); ?></p>
+
+<?php
+
+// Load all importers so that they can register.
+$import_loc = 'wp-admin/import';
+$import_root = ABSPATH.$import_loc;
+$imports_dir = @ dir($import_root);
+if ($imports_dir) {
+ while (($file = $imports_dir->read()) !== false) {
+ if (preg_match('|^\.+$|', $file))
+ continue;
+ if (preg_match('|\.php$|', $file))
+ require_once("$import_root/$file");
+ }
+}
+
+$importers = get_importers();
+
+if (empty ($importers)) {
+ echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful
+} else {
+?>
+<table width="100%" cellpadding="3" cellspacing="3">
+
+<?php
+ $style = '';
+ foreach ($importers as $id => $data) {
+ $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate';
+ $action = "<a href='admin.php?import=$id' title='{$data[1]}'>{$data[0]}</a>";
+
+ if ($style != '')
+ $style = 'class="'.$style.'"';
+ echo "
+ <tr $style>
+ <td class=\"togl\">$action</td>
+ <td class=\"desc\">{$data[1]}</td>
+ </tr>";
+ }
+?>
+
+</table>
+<?php
+}
+?>
+
+</div>
+
+<?php
+
+include ('admin-footer.php');
+?>
+
diff --git a/wp-inst/wp-admin/link-add.php b/wp-inst/wp-admin/link-add.php
index 8a6553a..8f8f9f3 100644
--- a/wp-inst/wp-admin/link-add.php
+++ b/wp-inst/wp-admin/link-add.php
@@ -1,7 +1,7 @@
<?php
require_once('admin.php');
-$title = __('Add Link');
+$title = __('Add Bookmark');
$this_file = 'link-manager.php';
$parent_file = 'link-manager.php';
@@ -26,11 +26,12 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
$xfn_js = true;
+$editing = true;
require('admin-header.php');
?>
<?php if ($_GET['added']) : ?>
-<div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div>
+<div id="message" class="updated fade"><p><?php _e('Bookmark added.'); ?></p></div>
<?php endif; ?>
<?php
@@ -39,7 +40,7 @@ require('admin-header.php');
?>
<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();") ?>
+<?php printf(__('<p>You can drag <a href="%s" title="Bookmark 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 bookmarks! 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
diff --git a/wp-inst/wp-admin/link-import.php b/wp-inst/wp-admin/link-import.php
index 58e58f8..73a7ae1 100644
--- a/wp-inst/wp-admin/link-import.php
+++ b/wp-inst/wp-admin/link-import.php
@@ -25,7 +25,7 @@ switch ($step) {
<h2><?php _e('Import your blogroll from another system') ?> </h2>
<form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
-<p><?php _e('If a program or website you use allows you to export your links or subscriptions as OPML you may import them here.'); ?>
+<p><?php _e('If a program or website you use allows you to export your bookmarks or subscriptions as OPML you may import them here.'); ?>
<div style="width: 70%; margin: auto; height: 8em;">
<input type="hidden" name="step" value="1" />
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
@@ -42,13 +42,13 @@ switch ($step) {
</div>
-<p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these links in.') ?><br />
+<p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these bookmarks 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");
+$categories = get_categories('hide_empty=0');
foreach ($categories as $category) {
?>
-<option value="<?php echo $category->cat_id; ?>"><?php echo $category->cat_id.': '.$category->cat_name; ?></option>
+<option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars($category->cat_name); ?></option>
<?php
} // end foreach
?>
@@ -63,6 +63,8 @@ foreach ($categories as $category) {
} // end case 0
case 1: {
+ check_admin_referer();
+
include_once('admin-header.php');
if ( !current_user_can('manage_links') )
die (__("Cheatin' uh ?"));
@@ -103,14 +105,12 @@ foreach ($categories as $category) {
$titles[$i] = '';
if ('http' == substr($titles[$i], 0, 4))
$titles[$i] = '';
- // FIXME: Use wp_insert_link().
- $query = "INSERT INTO $wpdb->links (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss)
- VALUES('{$urls[$i]}', '".$wpdb->escape($names[$i])."', '', $cat_id, '".$wpdb->escape($descriptions[$i])."', $user_ID, '{$feeds[$i]}')\n";
- $result = $wpdb->query($query);
+ $link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]);
+ wp_insert_link($link);
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>
+ <p><?php printf(__('Inserted %1$d bookmarks into category %2$s. All done! Go <a href="%3$s">manage those bookmarks</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
<?php
} // end if got url
else
diff --git a/wp-inst/wp-admin/link-manager.php b/wp-inst/wp-admin/link-manager.php
index 9d86834..9ec047a 100644
--- a/wp-inst/wp-admin/link-manager.php
+++ b/wp-inst/wp-admin/link-manager.php
@@ -1,255 +1,65 @@
<?php
+
+
// Links
// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
-require_once('admin.php');
+require_once ('admin.php');
-$title = __('Manage Links');
+$title = __('Manage Bookmarks');
$this_file = $parent_file = 'link-manager.php';
$list_js = true;
-$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' ];
-
-update_option( 'links_last_updated', time() );
-
-switch ($action) {
- case 'assign':
- {
- check_admin_referer();
-
- // check the current user's level first.
- if ( !current_user_can('manage_links') )
- die (__("Cheatin' uh ?"));
-
- //for each link id (in $linkcheck[]): 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 FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)");
- foreach ($results as $row) {
- $ids_to_change[] = $row->link_id;
- }
-
- // should now have an array of links we can change
- $all_links = join(',', $ids_to_change);
- $q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)");
-
- header('Location: ' . $this_file);
- break;
- }
- case 'visibility':
- {
- check_admin_referer();
-
- // check the current user's level first.
- if ( !current_user_can('manage_links') )
- die (__("Cheatin' uh ?"));
-
- //for each link id (in $linkcheck[]): toggle the visibility
- if (count($linkcheck) == 0) {
- header('Location: ' . $this_file);
- exit;
- }
- $all_links = join(',', $linkcheck);
- $results = $wpdb->get_results("SELECT link_id, link_visible FROM $wpdb->links WHERE link_id in ($all_links)");
- foreach ($results as $row) {
- if ($row->link_visible == 'Y') { // ok to proceed
- $ids_to_turnoff[] = $row->link_id;
- } else {
- $ids_to_turnon[] = $row->link_id;
- }
- }
-
- // should now have two arrays of links to change
- if (count($ids_to_turnoff)) {
- $all_linksoff = join(',', $ids_to_turnoff);
- $q = $wpdb->query("update $wpdb->links SET link_visible='N' WHERE link_id IN ($all_linksoff)");
- }
-
- if (count($ids_to_turnon)) {
- $all_linkson = join(',', $ids_to_turnon);
- $q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)");
- }
-
- header('Location: ' . $this_file);
- break;
- }
- case 'move':
- {
- check_admin_referer();
-
- // check the current user's level first.
- if ( !current_user_can('manage_links') )
- die (__("Cheatin' uh ?"));
-
- //for each link id (in $linkcheck[]) change category to selected value
- if (count($linkcheck) == 0) {
- header('Location: ' . $this_file);
- exit;
- }
- $all_links = join(',', $linkcheck);
- // should now have an array of links we can change
- $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
-
- header('Location: ' . $this_file);
- break;
- }
-
- case 'Add':
- {
- check_admin_referer();
-
- add_link();
-
- header('Location: ' . $_SERVER['HTTP_REFERER'] . '?added=true');
- break;
- } // end Add
-
- case 'editlink':
- {
-
- check_admin_referer();
-
- if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
- $cat_id = $links_show_cat_id;
-
- if (!isset($cat_id) || ($cat_id == '')) {
- if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
- $cat_id = 'All';
+$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 = $cat_id;
-
- $link_id = (int) $_POST['link_id'];
- edit_link($link_id);
-
- setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
- wp_redirect($this_file);
- break;
- } // end Save
-
- case 'Delete':
- {
- check_admin_referer();
-
- if ( !current_user_can('manage_links') )
- die (__("Cheatin' uh ?"));
-
- $link_id = (int) $_GET['link_id'];
-
- wp_delete_link($link_id);
-
- if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
- $cat_id = $links_show_cat_id;
-
- if (!isset($cat_id) || ($cat_id == '')) {
- if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
- $cat_id = 'All';
- }
- $links_show_cat_id = $cat_id;
- setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
- wp_redirect($this_file);
- break;
- } // end Delete
-
- case 'linkedit': {
- $xfn_js = true;
- include_once ('admin-header.php');
- if ( !current_user_can('manage_links') )
- die(__('You do not have sufficient permissions to edit the links for this blog.'));
-
- $link_id = (int) $_GET['link_id'];
-
- if ( !$link = get_link_to_edit($link_id) )
- die( __('Link not found.') );
-
- include('edit-link-form.php');
- break;
- } // end linkedit
- case __("Show"):
- {
- if (!isset($cat_id) || ($cat_id == '')) {
- if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
- $cat_id = 'All';
- }
- $links_show_cat_id = $cat_id;
- if (!isset($order_by) || ($order_by == '')) {
- if (!isset($links_show_order) || ($links_show_order == ''))
- $order_by = 'order_name';
- }
- $links_show_order = $order_by;
- //break; fall through
- } // end Show
- case "popup":
- {
- $link_url = stripslashes($_GET["linkurl"]);
- $link_name = stripslashes($_GET["name"]);
- //break; fall through
- }
- default:
- {
- if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
- $cat_id = $links_show_cat_id;
-
- if (!isset($cat_id) || ($cat_id == '')) {
- if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
- $cat_id = 'All';
- }
- $links_show_cat_id = $cat_id;
- if (isset($links_show_order) && ($links_show_order != ''))
- $order_by = $links_show_order;
-
- if (!isset($order_by) || ($order_by == ''))
- $order_by = 'order_name';
- $links_show_order = $order_by;
-
- setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
- setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600);
- include_once ("./admin-header.php");
- if ( !current_user_can('manage_links') )
- die(__("You do not have sufficient permissions to edit the links for this blog."));
-
- switch ($order_by)
- {
- case 'order_id': $sqlorderby = 'id'; break;
- case 'order_url': $sqlorderby = 'url'; break;
- case 'order_desc': $sqlorderby = 'description'; break;
- case 'order_owner': $sqlorderby = 'owner'; break;
- case 'order_rating': $sqlorderby = 'rating'; break;
- case 'order_name':
- default: $sqlorderby = 'name'; break;
- }
+}
- if ($action != "popup") {
+if (empty ($cat_id))
+ $cat_id = 'all';
+
+if (empty ($order_by))
+ $order_by = 'order_name';
+
+$title = __('Manage Bookmarks');
+include_once ("./admin-header.php");
+
+if (!current_user_can('manage_links'))
+ die(__("You do not have sufficient permissions to edit the bookmarks 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;
+}
?>
<script type="text/javascript">
<!--
@@ -267,183 +77,134 @@ function checkAll(form)
//-->
</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";
+if ( isset($_GET['deleted']) ) {
+ echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
+ $deleted = (int) $_GET['deleted'];
+ printf(__('%s bookmarks deleted.'), $deleted);
+ echo '</p></div>';
+}
?>
- </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 id="the-list-x" 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
- // fix link owners!
- $wpdb->query( "UPDATE $wpdb->links SET link_owner='" . $current_user->data->ID . "' WHERE link_owner='0'" );
-
- $sql = "SELECT link_url, link_name, link_image, link_description, link_visible,
- link_category AS cat_id, cat_name AS category, link_id,
- link_rating, link_rel
- FROM $wpdb->links
- LEFT JOIN $wpdb->linkcategories ON $wpdb->links.link_category = $wpdb->linkcategories.cat_id
- WHERE link_owner = '".$current_user->data->ID."'";
- if (isset($cat_id) && ($cat_id != 'All')) {
- $sql .= " AND 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).'...';
+<h2><?php _e('Bookmark Management'); ?></h2>
+<p><?php _e('Here you add links to sites that you visit often and share them on your blog. When you have a list of links in your sidebar to other blogs, it&#8217;s called a &#8220;blogroll.&#8221;'); ?></p>
+<form id="cats" method="get" action="">
+<p>Currently showing
+<?php $categories = get_categories("hide_empty=1&type=link"); ?>
+<select name="cat_id">
+<option value="all" <?php echo ($cat_id == 'all') ? " selected='selected'" : ''; ?>><?php _e('All') ?></option>
+<?php foreach ($categories as $cat): ?>
+<option value="<?php echo $cat->cat_ID; ?>"<?php echo ($cat->cat_ID == $cat_id) ? " selected='selected'" : ''; ?>><?php echo wp_specialchars($cat->cat_name); ?>
+</option>
+<?php endforeach; ?>
+</select>
+bookmarks ordered by
+<select name="order_by">
+<option value="order_id" <?php if ($order_by == 'order_id') echo " selected='selected'";?>><?php _e('Bookmark 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>
+</select>
+<input type="submit" name="action" value="<?php _e('Update &raquo;') ?>" />
+</form>
- $image = ($link->link_image != null) ? __('Yes') : __('No');
- $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
- ++$i;
- $style = ($i % 2) ? '' : ' class="alternate"';
+<form id="links" method="post" action="link.php">
+<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">
+ <thead>
+ <tr>
+ <th width="15%"><?php _e('Name') ?></th>
+ <th><?php _e('URI') ?></th>
+ <th><?php _e('Categories') ?></th>
+ <th><?php _e('rel') ?></th>
+ <th><?php _e('Visible') ?></th>
+ <th colspan="2"><?php _e('Action') ?></th>
+ <th><input type="checkbox" onclick="checkAll(document.getElementById('links'));" /></th>
+ </tr>
+ </thead>
+ <tbody id="the-list">
+<?php
+if ( 'all' == $cat_id )
+ $cat_id = '';
+$links = get_bookmarks("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0");
+if ($links)
+ foreach ($links as $link) {
+ $link->link_name = wp_specialchars($link->link_name);
+ $link->link_description = wp_specialchars($link->link_description);
+ $link->link_url = wp_specialchars($link->link_url);
+ $link->link_category = wp_get_link_cats($link->link_id);
+ $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).'...';
+
+ $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
+ ++ $i;
+ $style = ($i % 2) ? '' : ' class="alternate"';
?>
- <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>
+ <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>
<td><strong><?php echo $link->link_name; ?></strong><br />
+ <?php
+
+
+ echo $link->link_description . "</td>";
+ echo "<td><a href=\"$link->link_url\" title=\"".sprintf(__('Visit %s'), $link->link_name)."\">$short_url</a></td>";
+ ?>
+ <td>
+ <?php
+
+ $cat_names = array();
+ foreach ($link->link_category as $category) {
+ $cat_name = get_the_category_by_ID($category);
+ $cat_name = wp_specialchars($cat_name);
+ if ( $cat_id != $category )
+ $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
+ $cat_names[] = $cat_name;
+ }
+ echo implode(', ', $cat_names);
+ ?>
+ </td>
+ <td><?php echo $link->link_rel; ?></td>
+ <td align='center'><?php echo $visible; ?></td>
<?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 ($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 deleteSomething( 'link', $link->link_id , '" . sprintf(__("You are about to delete the &quot;%s&quot; link to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($link->link_name,1), wp_specialchars($link->link_url)) . '\' );" 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 '<td><a href="link.php?link_id='.$link->link_id.'&amp;action=edit" class="edit">'.__('Edit').'</a></td>';
+ echo '<td><a href="link.php?link_id='.$link->link_id.'&amp;action=delete"'." class='delete' onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the &quot;%s&quot; bookmark to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($link->link_name, 1), wp_specialchars($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>';
+ echo '<td align="center"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>';
echo "\n </tr>\n";
- }
- }
+ }
?>
+ </tbody>
</table>
<div id="ajax-response"></div>
-</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 = get_users_of_blog( $wpdb->blogid );
- 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:'); link_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
-?>
+<p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Bookmarks') ?> &raquo;" onclick="return confirm('<?php _e("You are about to delete these bookmarks permanently \\n \'Cancel\' to stop, \'OK\' to delete.") ?>')" /></p>
</div>
</form>
-
<?php
- break;
- } // end default
-} // end case
+if( wp_cache_get( "checked_bookmarks_table", "options" ) == false ) {
+ if( is_backup_queue_full() == false ) {
+ $results = $wpdb->get_results( "SELECT link_id, category_id, count( * ) AS c FROM {$wpdb->link2cat} GROUP BY link_id, category_id" );
+ if( $results != null ) {
+ foreach( $results as $link ) {
+ if( $link->c > 1 ) {
+ $wpdb->query( "DELETE FROM {$wpdb->link2cat} WHERE link_id='{$link->link_id}' AND category_id='{$link->category_id}'" );
+ $wpdb->query( "INSERT INTO {$wpdb->link2cat} VALUES ( 0, '{$link->link_id}', '{$link->category_id}' )" );
+ }
+ }
+ }
+ wp_cache_set( "checked_bookmarks_table", "1", "options" );
+ }
+}
+
?>
<?php include('admin-footer.php'); ?>
diff --git a/wp-inst/wp-admin/upgrade-functions.php b/wp-inst/wp-admin/upgrade-functions.php
index 6850e3b..eb59d60 100644
--- a/wp-inst/wp-admin/upgrade-functions.php
+++ b/wp-inst/wp-admin/upgrade-functions.php
@@ -1,7 +1,7 @@
<?php
-require_once(ABSPATH . '/wp-admin/admin-functions.php');
-require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
+require_once(ABSPATH . 'wp-admin/admin-functions.php');
+require_once(ABSPATH . 'wp-admin/upgrade-schema.php');
define( "RESET_CAPS", true );
// Functions to be called in install and upgrade scripts
function upgrade_all() {
@@ -700,7 +700,6 @@ function dbDelta($queries, $execute = true) {
function make_db_current() {
global $wp_queries;
-
$alterations = dbDelta($wp_queries);
echo "<ol>\n";
foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
diff --git a/wp-inst/wp-admin/upgrade-schema.php b/wp-inst/wp-admin/upgrade-schema.php
index 1e7c201..ad2b1ab 100644
--- a/wp-inst/wp-admin/upgrade-schema.php
+++ b/wp-inst/wp-admin/upgrade-schema.php
@@ -1,13 +1,18 @@
<?php
// Here we keep the DB structure and option values
-$wp_queries="CREATE TABLE $wpdb->categories (
+global $wp_queries;
+
+$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',
category_count bigint(20) NOT NULL default '0',
+ link_count bigint(20) NOT NULL default '0',
+ posts_private tinyint(1) NOT NULL default '0',
+ links_private tinyint(1) NOT NULL default '0',
PRIMARY KEY (cat_ID),
KEY category_nicename (category_nicename)
);
@@ -31,21 +36,12 @@ CREATE TABLE $wpdb->comments (
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->link2cat (
+ rel_id bigint(20) NOT NULL auto_increment,
+ link_id bigint(20) NOT NULL default '0',
+ category_id bigint(20) NOT NULL default '0',
+ PRIMARY KEY (rel_id),
+ KEY link_id (link_id,category_id)
);
CREATE TABLE $wpdb->links (
link_id bigint(20) NOT NULL auto_increment,
@@ -119,11 +115,12 @@ CREATE TABLE $wpdb->posts (
post_parent bigint(20) NOT NULL default '0',
guid varchar(255) NOT NULL default '',
menu_order int(11) NOT NULL default '0',
- post_type varchar(100) NOT NULL default 'post',
+ post_type varchar(20) NOT NULL default 'post',
post_mime_type varchar(100) NOT NULL default '',
comment_count bigint(20) NOT NULL default '0',
PRIMARY KEY (ID),
- KEY post_name (post_name)
+ KEY post_name (post_name),
+ KEY type_status_date (post_type, post_status, post_date, ID)
);
CREATE TABLE $wpdb->users (
ID bigint(20) unsigned NOT NULL auto_increment,
@@ -189,6 +186,20 @@ CREATE TABLE $wpdb->sitecategories (
PRIMARY KEY (cat_ID),
KEY category_nicename (category_nicename)
);
+CREATE TABLE $wpdb->signups (
+ domain varchar(200) NOT NULL default '',
+ path varchar(100) NOT NULL default '',
+ title longtext NOT NULL,
+ user_login varchar(60) NOT NULL default '',
+ user_email varchar(100) NOT NULL default '',
+ registered datetime NOT NULL default '0000-00-00 00:00:00',
+ activation_key longtext NOT NULL,
+ meta longtext,
+ active bigint(20),
+ activated datetime NOT NULL default '0000-00-00 00:00:00',
+ PRIMARY KEY (domain),
+ KEY user_login (user_login)
+);
";
function populate_options() {
diff --git a/wp-inst/wp-admin/wp-admin.css b/wp-inst/wp-admin/wp-admin.css
index 1b9ecc6..7b27c63 100644
--- a/wp-inst/wp-admin/wp-admin.css
+++ b/wp-inst/wp-admin/wp-admin.css
@@ -40,6 +40,28 @@ a.delete:hover {
overflow: hidden;
}
+.widefat {
+ width: 100%;
+}
+
+.widefat td, .widefat th {
+ padding: 5px 6px;
+}
+
+.import-system {
+ font-size: 16px;
+}
+
+thead {
+ background: #dfdfdf
+}
+
+#import-upload-form {
+ width: 300px;
+ margin: auto;
+ text-align: center;
+}
+
a.edit, a.delete, a.edit:hover, a.delete:hover {
border-bottom: none;
display: block;
@@ -91,11 +113,6 @@ fieldset legend {
padding: .1em .3em;
}
-fieldset span.cat-nest {
- display: block;
- margin-left: 10px;
-}
-
fieldset.options {
padding: 1em;
}
@@ -241,8 +258,14 @@ form#upload #post_content {
}
.commentlist li {
- border-bottom: 1px solid #369;
- padding: .3em 1em;
+ border-bottom: 1px solid #ccc;
+ padding: 1em 1em .2em;
+ margin: 0;
+}
+
+.commentlist p {
+ padding: 0;
+ margin: 0 0 .8em;
}
.clear {
@@ -326,6 +349,18 @@ form#upload #post_content {
color: #009ef0;
}
+.approve {
+ display: none;
+}
+
+.unapproved .approve {
+ display: inline;
+}
+
+.unapproved .unapprove {
+ display: none;
+}
+
.updated {
background: #CFEBF7 url(images/notice.gif) no-repeat 1em ;
border: 1px solid #2580B2;
@@ -353,7 +388,7 @@ form#upload #post_content {
clear: both;
}
-table .vers, table .name {
+table .vers {
text-align: center;
}
@@ -461,7 +496,12 @@ table .vers, table .name {
width: 300px;
}
-#deletepost:hover {
+#deletepost:hover, #deletecomment:hover {
+ background: #ce0000;
+ color: #fff;
+}
+
+#deletebookmarks:hover {
background: #ce0000;
color: #fff;
}
@@ -615,7 +655,7 @@ table .vers, table .name {
width: 170px;
}
-#templateside h3, #postcustom p {
+#templateside h3, #postcustom p.submit {
margin: 0;
}
@@ -713,6 +753,14 @@ table .vers, table .name {
background: #8B8;
}
+#namediv, #emaildiv, #uridiv {
+ float: left;
+}
+
+#ajax-response {
+ padding: .5em;
+}
+
/* A handy div class for hiding controls.
Some browsers will disable them when you
set display:none; */
@@ -799,11 +847,20 @@ table .vers, table .name {
margin-top: .5em;
}
-#categorydiv div div {
+#categorydiv ul {
+ list-style: none;
+ padding: 0;
+ margin-left:10px;
+}
+#categorychecklist {
height: 12em;
overflow: auto;
+ margin-top: 8px;
+}
+#categorychecklist li {
+ margin: 0;
+ padding: 0;
}
-
#ajaxcat input {
border: 1px solid #ccc;
}
@@ -947,3 +1004,6 @@ input#catadd { background: #a4a4a4;
margin: 0;
padding: 0;
}
+#ajax-response.alignleft {
+ margin-left: 2em;
+}
diff --git a/wp-inst/wp-admin/wpmu-upgrade.inc.php b/wp-inst/wp-admin/wpmu-upgrade.inc.php
deleted file mode 100644
index 4146eca..0000000
--- a/wp-inst/wp-admin/wpmu-upgrade.inc.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-$row = $wpdb->get_row( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = 'first_post'" );
-if( $row == false )
- $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, '$wpdb->siteid', 'first_post', 'Welcome to <a href=\"SITE_URL\">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!'" );
-
-$row = $wpdb->get_row( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = 'welcome_email'" );
-if( $row == false )
- $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, '$wpdb->siteid', 'welcome_email',
-'Dear User,
-
-Your new SITE_NAME blog has been successfully set up at:
-BLOG_URL
-
-You can log in to the administrator account with the following information:
-Username: USERNAME
-Password: PASSWORD
-Login Here: BLOG_URLwp-login.php
-
-We hope you enjoy your new weblog.
-Thanks!
-
---The WordPress Team
-SITE_NAME' )" );
-
-$row = $wpdb->get_row( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = 'site_name'" );
-if( $row == false )
- $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, '$wpdb->siteid', 'site_name', '" . ucfirst( $current_site->domain ) . "')" );
-
-unset( $row );
-
-?>
diff --git a/wp-inst/wp-config-sample.php b/wp-inst/wp-config-sample.php
index d856deb..85c8a95 100644
--- a/wp-inst/wp-config-sample.php
+++ b/wp-inst/wp-config-sample.php
@@ -80,8 +80,10 @@ $global_db_list = array(
)
);
+$based = 'BASE';
+
/* Stop editing */
define('ABSPATH', dirname(__FILE__).'/');
-require_once(ABSPATH.'wpmu-settings.php');
+require_once(ABSPATH.'wp-settings.php');
?>
diff --git a/wp-inst/wp-content/blogs.php b/wp-inst/wp-content/blogs.php
index 8341e7d..e5d382f 100644
--- a/wp-inst/wp-content/blogs.php
+++ b/wp-inst/wp-content/blogs.php
@@ -1,51 +1,49 @@
-<?php
-define( "BLOGDEFINITION", true );
-require_once( "../wp-config.php" );
-
-// Referrer protection
-if( $_SERVER["HTTP_REFERER"] ) {
- if( strpos( $_SERVER["HTTP_REFERER"], $current_blog->domain ) == false ) {
- // do something against hot linking sites!
- }
-}
-$file = $_GET[ 'file' ];
-$file = ABSPATH . "wp-content/blogs.dir/" . $blog_id . '/files/' . $file;
-
-if( is_file( $file ) ) {
- $etag = md5( $file . filemtime( $file ) );
- $lastModified = date( "D, j M Y H:i:s ", filemtime( $file ) ) . "GMT";
- #$headers = apache_request_headers();
- // get mime type
- $ext = substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 );
- $ext_list = array( "jpg" => "image/jpeg", "mp3" => "audio/mpeg", "mov" => "video/quicktime" );
- if( $ext_list[ $ext ] ) {
- $mimetype = $ext_list[ $ext ];
- } else {
- $mimetype = "image/$ext";
- }
-
- // from http://blog.rd2inc.com/archives/2005/03/24/making-dynamic-php-pages-cacheable/
- //if( $headers[ 'If-Range' ] == '"' . $etag . '"' || $lastModified == $headers['If-Modified-Since']) {
- if( $_SERVER[ 'HTTP_IF_NONE_MATCH' ] == '"' . $etag . '"' || $lastModified == $_SERVER['HTTP_IF_MODIFIED_SINCE']) {
- // They already have an up to date copy so tell them
- header('HTTP/1.1 304 Not Modified');
- header('Cache-Control: private');
- header('Content-Type: $mimetype');
- header('ETag: "'.$etag.'"');
- } else {
- header("Content-type: $mimetype" );
- header( "Last-Modified: " . $lastModified );
- header( 'Accept-Ranges: bytes' );
- header( "Content-Length: " . filesize( $file ) );
- header( 'ETag: "' . $etag . '"' );
- readfile( $file );
- }
-} 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 "</body></html>";
-}
-?>
+<?php
+define( "BLOGDEFINITION", true );
+require_once( "../wp-config.php" );
+
+// Referrer protection
+if( $_SERVER["HTTP_REFERER"] ) {
+ if( strpos( $_SERVER["HTTP_REFERER"], $current_blog->domain ) == false ) {
+ // do something against hot linking sites!
+ }
+}
+$file = $_GET[ 'file' ];
+$file = ABSPATH . "wp-content/blogs.dir/" . $blog_id . '/files/' . $file;
+
+if( is_file( $file ) ) {
+ $etag = md5( $file . filemtime( $file ) );
+ $lastModified = date( "D, j M Y H:i:s ", filemtime( $file ) ) . "GMT";
+ #$headers = apache_request_headers();
+ // get mime type
+ $ext = substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 );
+ $ext_list = array( "jpg" => "image/jpeg", "mp3" => "audio/mpeg", "mov" => "video/quicktime" );
+ if( $ext_list[ $ext ] ) {
+ $mimetype = $ext_list[ $ext ];
+ } else {
+ $mimetype = "image/$ext";
+ }
+
+ if( $_SERVER[ 'HTTP_IF_NONE_MATCH' ] == '"' . $etag . '"' || $lastModified == $_SERVER['HTTP_IF_MODIFIED_SINCE']) {
+ // They already have an up to date copy so tell them
+ header('HTTP/1.1 304 Not Modified');
+ header('Cache-Control: private');
+ header('Content-Type: $mimetype');
+ header('ETag: "'.$etag.'"');
+ } else {
+ header("Content-type: $mimetype" );
+ header( "Last-Modified: " . $lastModified );
+ header( 'Accept-Ranges: bytes' );
+ header( "Content-Length: " . filesize( $file ) );
+ header( 'ETag: "' . $etag . '"' );
+ readfile( $file );
+ }
+} 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 "</body></html>";
+}
+?> \ No newline at end of file
diff --git a/wp-inst/wp-content/mu-plugins/blogs-header.php b/wp-inst/wp-content/mu-plugins/blogs-header.php
deleted file mode 100644
index a9ddc03..0000000
--- a/wp-inst/wp-content/mu-plugins/blogs-header.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-add_action('wp_head', "header_js" );
-
-function header_js() {
- ?>
-<script type="text/javascript">
-
-function addLoadEvent(func) {
- var oldonload = window.onload;
- if (typeof window.onload != 'function') {
- window.onload = func;
- } else {
- window.onload = function() {
- oldonload();
- func();
- }
- }
-}
-</script>
- <?php
-}
-
-?>
diff --git a/wp-inst/wp-content/mu-plugins/doc_referers.php b/wp-inst/wp-content/mu-plugins/doc_referers.php
deleted file mode 100644
index d923e37..0000000
--- a/wp-inst/wp-content/mu-plugins/doc_referers.php
+++ /dev/null
@@ -1,712 +0,0 @@
-<?php
-/*
-Plugin Name: Referers
-Plugin URI: http://mu.wordpress.org/
-Description: Display referers to your site
-Version: 0.1
-Author: Donncha O Caoimh
-Author URI: http://blogs.linux.ie/xeer/
-*/
-
-/* Copyright 2005 Donncha O Caoimh (email : donncha@linux.ie)
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-if( defined( "WP_INSTALLING" ) )
- return true;
-
-class DOC_Referers {
-
- var $table_version = 0.2;
-
- function DOC_Referers() {
- add_action('admin_menu', array(&$this, 'admin_menu'));
- add_action('admin_footer', array(&$this, 'admin_footer'));
- add_action('wp_footer', array(&$this, 'template_redirect'));
- $this->settings = get_settings('doc_referers');
- $this->wpdb_tables();
-
- if($this->settings['table_version'] != $this->table_version)
- {
- $this->make_tables();
- $this->added_tables = true;
- }
- }
-
- function admin_footer()
- {
- update_option('doc_referers', $this->settings);
- }
-
- function admin_menu()
- {
- $pfile = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
- add_submenu_page('edit.php', 'Referers', 'Referers', 0, $pfile, array(&$this, 'plugin_content'));
- }
-
- function wpdb_tables() {
- global $wpdb, $table_prefix;
-
- $wpdb->doc_referers = "{$table_prefix}referer_visitLog";
- $wpdb->doc_blacklist = "{$table_prefix}referer_blacklist";
- }
- 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.', 'DOC_Referers'));
- }
- $qry = "CREATE TABLE IF NOT EXISTS " . $wpdb->doc_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)
- );";
- $wpdb->query( $qry );
-
- $qry = "CREATE TABLE IF NOT EXISTS " . $wpdb->doc_referers . " (
- 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 )
- );";
- $wpdb->query( $qry );
-
- $this->settings['table_version'] = $this->table_version;
- update_option('doc_referers', $this->settings);
- }
-
-
- function makeHiddenVals( $day, $order, $num, $more, $ignoreDIRECT, $visitID, $internal )
- {
- $fields = array( "day", "order", "num", "more", "ignoreDIRECT", "visitID", "internal" );
- reset( $fields );
- while( list( $key, $field ) = each( $fields ) )
- {
- if( $field == 'action' )
- {
- $sep = '?';
- }
- else
- {
- $sep = '&';
- }
-
- if( $_GET[ $field ] != '' )
- $vals .= "<input type='hidden' name='".$field."' value='".htmlentities( $_GET[ $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 ) )
- {
- $sep = '&';
- if( $field != $var )
- {
- if( $_GET[ $field ] != '' )
- $url .= $sep.$field."=".htmlentities( $_GET[ $field ] );
- }
- else
- {
- $url .= $sep.$var."=".$val;
- }
- }
- return $url;
- }
-
- function plugin_content()
- {
- global $wpdb;
-
- $action = addslashes( $_GET[ 'action' ] );
- $day = intval( $_GET[ 'day' ] );
- $del = $_GET[ 'del' ];
- $num = intval( $_GET[ 'num' ] );
- $more = intval( $_GET[ 'more' ] );
- $order = addslashes( $_GET[ 'order' ] );
- $ignoreDIRECT = addslashes( $_GET[ 'ignoreDIRECT' ] );
- $internal = addslashes( $_GET[ 'internal' ] );
-
- if( $ignoreDIRECT == '' ) {
- $ignoreDIRECT = get_option( 'ignoreDIRECT' );
- } else {
- if( get_option( 'ignoreDIRECT' ) == false ) {
- add_option( 'ignoreDIRECT', $ignoreDIRECT );
- } else {
- update_option( 'ignoreDIRECT', $ignoreDIRECT );
- }
- }
- if( $internal == '' ) {
- $internal = get_option( 'doc_referers_internal' );
- } else {
- if( get_option( 'doc_referers_internal' ) == false ) {
- add_option( 'doc_referers_internal', $internal );
- } else {
- update_option( 'doc_referers_internal', $internal );
- }
- }
-
- if( $action == '' )
- {
- $action = 'listday';
- $day = date( 'j' );
- }
- if( $day == '' )
- $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 " . $wpdb->doc_referers . "
- WHERE visitID = '".intval( $val )."'";
- $result = $wpdb->query($query);
- }
- }
- $action = "listday";
- }
- elseif( $action == 'deletedirect' )
- {
- $query = "DELETE FROM " . $wpdb->doc_referers . " WHERE dayofmonth='".$day."' AND referingURL = 'DIRECT'";
- $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 " . $wpdb->doc_referers . " WHERE visitID = '".intval( $val )."'";
- $result=$wpdb->get_var( $query );
- if( $result )
- {
- $query = "INSERT INTO " . $wpdb->doc_blacklist . " VALUES( NULL, 0, '".$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 " . $wpdb->doc_blacklist . " WHERE ID='".intval( $val )."'";
- $result = $wpdb->query($query);
- }
- }
- $action = "blacklist";
- }
-
- switch( $action )
- {
- case "blacklist":
- $query = "SELECT * FROM " . $wpdb->doc_blacklist;
- $result = $wpdb->get_results($query, ARRAY_A );
- if( $result )
- {
- print "<h2>Referer Blacklist</h2>";
- print "<form method='get'>";
- print '<input type="hidden" name="page" value="' . $_GET['page'] .'"/>';
- 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>";
- }
- else
- {
- print "No URLs in blacklist yet!";
- }
- break;
- case "listday":
-
- $query = "select visitTimes,referingURL,date_format( visitTime, '%k:%i' ) as visitTime2, visitURL, visitID from " . $wpdb->doc_referers . " where dayofmonth='".$day."'";
-
- 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;
- print "<h2>Referers</h2>";
- 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='edit.php?page=" . $_GET[ 'page' ] . "&action=month'>Month View</a> | ";
- $nav .= "<a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "num", 0 )."'>Top</a>";
- if( $ignoreDIRECT == 'yes' )
- {
- $nav .= " | <a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "ignoreDIRECT", 'no' )."'>Display DIRECT requests</a>";
- }
- else
- {
- $nav .= " | <a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "ignoreDIRECT", 'yes' )."'>Hide DIRECT requests</a>";
- }
- if( $internal == 'yes' )
- {
- $nav .= " | <a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "internal", 'no' )."'>Display internal requests</a>";
- }
- else
- {
- $nav .= " | <a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "internal", 'yes' )."'>Hide internal requests</a>";
- }
-
- if( $num >= 10 )
- {
- if( $num > $more )
- {
- $nav .= " | <a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "num", ( $num - $more ) )."'>Previous $more</a>";
- }
- }
- else
- {
- $nav .= " | Previous";
- }
- if( $rows >= $more )
- {
- $nav .= " | <a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "num", ($num + $more) )."'>Next $more</a>";
- }
- else
- {
- $nav .= " | Next";
- }
- $nav .= " | <a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "more", ($more + 10) )."'>More Hits</a>";
- $nav .= " | <a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "more", ($more - 10) )."'>Less Hits</a>";
- $nav .= "<br />";
- 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 method='GET' name='deletedirect'>";
- print '<input type="hidden" name="page" value="' . $_GET['page'] .'"/>';
- print "<input type='hidden' name='action' value='deletedirect'>";
- print $this->makeHiddenVals( $day, $order, $num, $more, $ignoreDIRECT, $visitID, $internal );
- print "</form>";
- print "<form method='GET' name='referers'>";
- print '<input type="hidden" name="page" value="' . $_GET['page'] .'"/>';
- print $this->makeHiddenVals( $day, $order, $num, $more, $ignoreDIRECT, $visitID, $internal );
- //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><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";
- print "<tr><th>#</th><th>Refering URL</th>
- <th><a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "order", "hits" )."' title='order by hits'>Hits</a></th>
- <th><a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "order", "url" )."' title='order by entry page'>Entry Page</a></th>
- <th><a href='edit.php?page=" . $_GET[ 'page' ] . "".$this->makeURL( "order", "time" )."' title='order by time'>Last</a></th>
- <th>Selected</th>
- </tr>";
- 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>";
- }
- elseif( strstr( $row1[ 'referingURL' ], 'bloglines.com' ) )
- {
- $args = parse_url( $row1[ 'referingURL' ] );
- $url = "<a href='".$row1[ 'referingURL' ]."' title='".$row1[ 'referingURL' ]."'>Bloglines</a>";
- }
- elseif( strpos( $row1[ 'referingURL' ], 'wp-admin/' ) )
- {
- $args = parse_url( $row1[ 'referingURL' ] );
- $u = substr( $row1[ 'referingURL' ], 0, strpos( $row1[ 'referingURL' ], "wp-admin" ) );
- $url = "<a href='".$u."' title='".$row1[ 'referingURL' ]."'>wp-admin: $u</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>";
- } else {
- print "<p>No Referers found today!</p>";
- print "<ul><li><a href='edit.php?page=mu-plugins/doc_referers.php&action=month'>Month View</a> displays the last month of stats.</li>";
- if( $ignoreDIRECT == 'yes' )
- print "<li><a href='edit.php?page=mu-plugins/doc_referers.php".$this->makeURL( "ignoreDIRECT", 'no' )."'>Display DIRECT hits</a> - some browsers don't report what page they come from. You're hiding this information right now.</li>";
- if( $internal == 'yes' )
- print "<li><a href='edit.php?page=mu-plugins/doc_referers.php".$this->makeURL( "internal", 'no' )."'>Display internal hits</a> - it's not always very interesting where people wander around your blog. You're hiding this information right now.</li>";
- print "</ul>";
- }
- break;
- default:
- $query = "select sum( visitTimes ) as c, dayofmonth from " . $wpdb->doc_referers . " ";
- $query .= "group by " . $wpdb->doc_referers . ".dayofmonth";
- $result = $wpdb->get_results($query, ARRAY_A );
- if( $result )
- {
- $c = 0;
- $col = 'ccc';
- print "<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='edit.php?page=" . $_GET[ 'page' ] . "&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='edit.php?page=" . $_GET[ 'page' ] . "&action=blacklist'>View Blacklist</a>";
- }
- else
- {
- print "There are no referers for your site! Wait until Google indexes you!";
- }
- }
- print "</div>";
-
- }
-
- function template_redirect() {
- global $wpdb;
- $wpdb->hide_errors();
-
- // 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 " . $wpdb->doc_referers . " WHERE dayofmonth = '$tomorrow'"; // delete referers from a (month + 1 day) ago.
- $wpdb->query($sql);
- }
-
- $ref = $_SERVER["HTTP_REFERER"];
- $currentURL = addslashes( $_SERVER[ 'REQUEST_URI' ] );
- $fullCurrentURL = "http://" . addslashes( $_SERVER[ 'HTTP_HOST' ] ) . addslashes( $_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;
- }
- }
-
- $ref = $wpdb->escape($ref);
- if( $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;
- }
- }
-
- $checkRef = true;
- // Do we need to check the referer? If it's from a known site we can save some cycles.
- $checkReflist = array( "direct", "http://www.technorati.com", "http://www.google", "http://www.yahoo", "http://www.linux.ie", "http://blogs.linux.ie", "http://blo.gs" );
- reset( $checkReflist );
- while( list( $key, $val ) = each( $checkReflist ) )
- {
- $p = strpos( strtolower( $url ), $val );
- if( $p !== false )
- {
- $checkRef = false;
- }
- }
-
- $doubleCheckReferers = 0; // must make this an option
- 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 && $ref != 'DIRECT' )
- {
- $query = "SELECT ID FROM " . $wpdb->doc_blacklist . " WHERE URL like '%$ref%'";
- $result = $wpdb->get_var( $query );
- if( $result )
- {
- $ref = "DIRECT";
- }
- }
-
- $ua = addslashes( $_SERVER["HTTP_USER_AGENT"] );
- $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" );
-
- if( strstr( $ref, 'bloglines.com' ) )
- $ref = "http://www.bloglines.com/";
-
- $sql = "UPDATE " . $wpdb->doc_referers . "
- SET visitTimes = visitTimes + 1
- WHERE dayofmonth = '$today'
- AND referingURL = '$ref'
- AND visitURL = '$currentURL'";
- $result = $wpdb->query( $sql );
- if( $result == false )
- {
- $sql ="INSERT INTO " . $wpdb->doc_referers . " (referingURL,visitURL,refpost, visitTimes, dayofmonth)
- VALUES ('$ref','$currentURL','$p','1', '$today')";
- $result = $wpdb->query( $sql );
- }
- }
- }
- $wpdb->show_errors();
- }
-}
-
-$doc_referer = new DOC_Referers();
-
-?>
diff --git a/wp-inst/wp-content/mu-plugins/invites.php b/wp-inst/wp-content/mu-plugins/invites.php
deleted file mode 100644
index 5e58f66..0000000
--- a/wp-inst/wp-content/mu-plugins/invites.php
+++ /dev/null
@@ -1,357 +0,0 @@
-<?php
-if( substr( $_SERVER[ 'PHP_SELF' ], -14 ) == 'wpmu-admin.php' || substr( $_SERVER[ 'PHP_SELF' ], -11 ) == 'invites.php' ) {
- if( false == get_site_option( "invites_default_message" ) ) {
- $msg =
-"Dear FIRSTNAME LASTNAME,
----------------------------------------------
-PERSONALMESSAGE
----------------------------------------------
-You have been invited to open a free WordPress weblog.
-
-To accept this invitation and register for your weblog, visit
-REGURL
-Your visitor pass is: VISITORPASS
-
-This invitation can only be used to set up one weblog.
-
-Regards,
-The WordPress Team
-
-(If clicking the URLs in this message does not work, copy and paste them
-into the address bar of your browser).";
- update_site_option( "invites_default_message", $msg );
- }
-
- if( false == get_site_option( "invites_default_subject" ) ) {
- $subject = "FIRSTNAME, USERNAME has invited you to use WordPress";
- update_site_option( "invites_default_subject", $subject );
- }
-
-}
-
-$u = $wpdb->escape( $_REQUEST['u'] );
-
-function invites_check_user_hash() {
- global $wpdb, $u;
- if( $u == '' ) {
- header( "Location: ".get_option( "siteurl" ) );
- die( );
- } else {
- $query = "SELECT meta_value FROM ".$wpdb->usermeta." WHERE user_id = '0' AND meta_key = 'invite' AND meta_value = '".addslashes( $u )."'";
- $userhash = $wpdb->get_results( $query, ARRAY_A );
-
- if( $userhash == false ) {
- header( "Location: ".get_option( "siteurl" ) );
- die();
- }
- }
-}
-if( get_site_option( "check_reg_for_invite" ) == 'yes' ) {
- add_action('newblogheader', 'invites_check_user_hash');
-}
-
-function invites_admin_send_email() {
- global $wpdb;
- $msg = get_site_option( "invites_default_message" );
- if( $msg == '' ) {
- $msg = "Dear FIRSTNAME LASTNAME,
----------------------------------------------
-PERSONALMESSAGE
----------------------------------------------
-You have been invited to open a free WordPress weblog.
-
-To accept this invitation and register for your weblog, visit
-REGURL
-This invitation can only be used to set up one weblog.
-
-Regards,
-The WordPress Team
-
-(If clicking the URLs in this message does not work, copy and paste them
-into the address bar of your browser).";
- update_site_option( "invites_default_message", $msg );
- }
- if( $_GET[ 'action' ] == 'invite' ) {
- if( is_email( $_POST[ 'email' ] ) ) {
- $email = $_POST[ 'email' ];
- $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
- VALUES ( NULL, '0', 'invite' , '".md5( $email )."')";
- $wpdb->query( $query );
- $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
- VALUES ( NULL, '0', '".md5( strtolower( $email ) )."_invited_by' , 'admin')";
- $wpdb->query( $query );
- $msg = str_replace( "REGURL", get_option( "siteurl" ) . "/invite/".md5( $email ), $msg );
- mail( $_POST[ 'email' ], "Your " . $current_site->site_name . " Invitation", $msg, "From: " . $current_site->site_name . " <donotreply@".get_option( "siteurl" ).">" );
- header( "Location: wpmu-admin.php?result=invitesent" );
- die();
- } else {
- header( "Location: wpmu-admin.php?result=invitenotsent" );
- die();
- }
- }
-}
-add_action('wpmuadminedit', 'invites_admin_send_email');
-
-function invites_admin_send_form() {
- print "<h2>Invites</h2>";
- ?>
- <p>Invite a new user to use this site!</p>
- <form action='wpmu-edit.php?action=invite' method='POST'>
- Email: <input type='text' value='' name='email' size='40'><br />
- <input type='submit' value='Send Invite'>
- </form>
- <?php
- // must also list stats on current invites and drill down into specifics.
-}
-# add_action('wpmuadmindefaultpage', 'invites_admin_send_form');
-
-function invites_admin_result() {
- switch( $_GET[ 'result' ] ) {
- case "invitesent":
- ?><div class="updated"><p><strong><?php _e('Invite Sent.') ?></strong></p></div><?php
- break;
- case "invitenotsent":
- ?><div class="updated"><p><strong><?php _e('Invite Not Sent.') ?></strong></p></div><?php
- break;
- }
-}
-add_action('wpmuadminresult', 'invites_admin_result');
-
-function invites_add_field() {
- global $u;
-
- echo "<input type='hidden' name='u' value='".$u."'>\n";
-}
-add_action('newblogform', 'invites_add_field');
-
-function invites_cleanup_db( $val ) {
- global $wpdb, $wpmuBaseTablePrefix, $url, $weblog_title;
- if( isset( $_POST[ 'u' ] ) ) {
- $u = addslashes( $_POST[ 'u' ] );
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = 'invite' AND meta_value = '".$u."'" );
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = '{$u}_to_email'" );
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = '{$u}_to_name'" );
-
- $add_to_blogroll = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$u}_add_to_blogroll'" );
- if( $add_to_blogroll ) {
- $userdetails = @unserialize( $add_to_blogroll );
- if( is_array( $userdetails ) ) {
- $wpdb->query("INSERT INTO {$wpmuBaseTablePrefix}{$userdetails[ 'blogid' ]}_links (link_url, link_name, link_category, link_owner) VALUES('" . addslashes( $url ) . "','" . addslashes( $weblog_title ) . "', '1', '" . intval( $userdetails[ 'userid' ] ) . "' )" );
- }
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = '{$u}_add_to_blogroll'" );
- }
-
-
- $id = $wpdb->get_var( "SELECT ID FROM ".$wpdb->users." WHERE user_login = '" . addslashes( $weblog_id ) . "'" );
-
- if( $id ) {
- $wpdb->query( "UPDATE ".$wpdb->usermeta." SET user_id = '".$id."', meta_key = 'invited_by' WHERE meta_key = '".$u."_invited_by'" );
- $wpdb->query( "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '{$id}', 'invites_left' , '" . get_site_option( "invites_per_user" ) . "' )" );
- $wpdb->query( "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '{$id}', 'invite_hash' , '{$u}' )" );
- }
- }
-}
-add_action('newblogfinished', 'invites_cleanup_db');
-
-/* admin functions:
- Configure invites: sig, number per user, default message
- */
-
-add_action('admin_menu', 'invites_admin_menu');
-
-function invites_admin_menu() {
- $pfile = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
- if ( is_site_admin() )
- add_submenu_page('wpmu-admin.php', 'Invites', 'Invites', 0, $pfile, 'invites_admin_content');
-}
-
-add_action('admin_footer', 'timed_invites');
-
-function timed_invites() {
- global $wpdb, $current_user;
-
- $chance = mt_rand( 0, 20 );
- if( $chance == '5' ) {
- $invites_add_days = get_site_option( "invites_add_days", 7 );
- if( $invites_add_days != 0 ) {
- $days_registered = $wpdb->get_var( "SELECT TO_DAYS( NOW() ) - TO_DAYS( user_registered ) FROM $wpdb->users WHERE ID = '" . get_current_user_id() . "'" );
- if( $days_registered % get_site_option( "invites_add_days", 7 ) == 0 ) {
- $invite_day = get_user_option( "invite_day" );
- if( $invite_day != $days_registered ) {
- $invites_left = get_usermeta( $current_user->id, "invites_left" );
- if( $invites_left < get_site_option( "invites_per_user" ) ) {
- update_usermeta( get_current_user_id(), "invites_left", ($invites_left + get_site_option( "invites_add_number", 1 ) ) );
- }
- update_usermeta( get_current_user_id(), "invite_day", $days_registered );
- }
- }
- }
- }
-}
-
-add_action('admin_footer', 'expire_old_invites');
-
-function expire_old_invites() {
- global $wpdb;
-
- $chance = mt_rand( 0, 100 );
- if( $chance == '5' ) {
- $mutex = $wpdb->get_var( "SELECT meta_value FROM ".$wpdb->usermeta." WHERE meta_key = 'invite_mutex'" );
- if( $mutex == false ) {
- $wpdb->query( "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '0', 'invite_mutex' , '1' )" );
- $invites = $wpdb->get_results( "SELECT * FROM {$wpdb->usermeta} WHERE meta_key like '%_invite_timestamp' AND ( TO_DAYS( NOW() ) - TO_DAYS( FROM_UNIXTIME( meta_value ) ) ) >= " . intval( get_site_option( 'invite_time_limit', 31 ) ) );
- if( is_array( $invites ) ) {
- while( list( $key, $val ) = each( $invites ) ) {
- $email_md5 = substr( $val->meta_key, 0, strpos( $val->meta_key, "_invite_timestamp" ) );
- delete_invite( $email_md5 );
- $uid = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$email_md5}_invited_by'" );
- if( $uid ) {
- $invites_left = get_usermeta( $uid, "invites_left" );
- if( $invites_left < get_site_option( "invites_per_user" ) )
- update_usermeta( $uid, "invites_left", $invites_left++ );
- }
- }
- }
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = 'invite_mutex'" );
- } else {
- if( $mutex == '5' ) {
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = 'invite_mutex'" );
- } else {
- $wpdb->query( "UPDATE ".$wpdb->usermeta." SET meta_value = ".($mutex+1)." WHERE meta_key = 'invite_mutex'" );
- }
- }
- }
-
-}
-
-function delete_invite( $uid ) {
- global $wpdb;
-
- $uid = addslashes( $uid );
- $email = $wpdb->get_var( "SELECT meta_value FROM ".$wpdb->usermeta." WHERE meta_key = '{$uid}_to_email'" );
- if( $email ) {
- $invited_by = $wpdb->get_var( "SELECT meta_value FROM ".$wpdb->usermeta." WHERE meta_key = '{$uid}_invited_by'" );
- if( $invited_by ) {
- $invites_list = get_usermeta( $invited_by, "invites_list" );
- if( $invites_list ) {
- $invites_list = str_replace( $email . " ", "", $invites_list );
- update_usermeta( $invited_by, "invites_list", $invites_list );
- }
- $invites_left = get_usermeta( $invited_by, "invites_left" );
- update_usermeta( $invited_by, "invites_left", $invites_left + 1 );
- }
- }
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = 'invite' AND meta_value = '$uid'" );
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = '{$uid}_to_email'" );
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = '{$uid}_to_name'" );
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = '{$uid}_add_to_blogroll'" );
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = '{$uid}_invited_by'" );
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = '{$uid}_invite_timestamp'" );
-}
-
-function invites_admin_content() {
- global $wpdb;
-
- if( is_site_admin() == false ) {
- return;
- }
-
- switch( $_GET[ 'action' ] ) {
- case "updateinvitedefaults":
- update_site_option( "invites_per_user", intval( $_GET[ 'invites_per_user' ] ) );
- update_site_option( "invites_default_message", $_GET[ 'invites_default_message' ] );
- update_site_option( "invites_default_subject", $_GET[ 'invites_default_subject' ] );
- update_site_option( "invites_add_number", intval( $_GET[ 'invites_add_number' ] ) );
- update_site_option( "invites_add_days", intval( $_GET[ 'invites_add_days' ] ) );
- update_site_option( "invite_time_limit", intval( $_GET[ 'invite_time_limit' ] ) );
- if( $_GET[ 'check_reg_for_invite' ] == 'yes' ) {
- update_site_option( "check_reg_for_invite", 'yes' );
- } else {
- update_site_option( "check_reg_for_invite", 'no' );
- }
- ?><div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div><?php
-
- break;
- case "":
- break;
- default:
- break;
- }
- $invites_per_user = get_site_option( "invites_per_user" );
- if( $invites_per_user == '' ) {
- $invites_per_user = 5;
- update_site_option( "invites_per_user", $invites_per_user );
- }
- ?>
- <div class='wrap'>
- <h2>Invite Options</h2>
- <fieldset class="options">
- <form method='GET'>
- <input type="hidden" name="page" value="<?php echo $_GET['page'] ?>"/>
- <input type='hidden' name='action' value='updateinvitedefaults'>
- <table class='editform'>
- <tr><th scope='row' valign='top'>Invites Per User:</td><td><input type='text' size='2' maxlength='2' name='invites_per_user' value='<?php echo $invites_per_user ?>'></td></tr>
- <tr><th scope='row' valign='top'>Number of Invites To Add: </td><td><input type='text' size='2' maxlength='2' name='invites_add_number' value='<?php echo get_site_option( "invites_add_number", 1 ) ?>'> (This number of invites will be added to each user every X days.)</td></tr>
- <tr><th scope='row' valign='top'>Add Invites Every</td><td valign='top'><input type='text' size='2' maxlength='2' name='invites_add_days' value='<?php echo get_site_option( "invites_add_days", 7 ) ?>'> <strong>Days</strong> (0 to disable)</td></tr>
- <tr><th scope='row' valign='top'>Invites Expire After</td><td valign='top'><input type='text' size='2' maxlength='2' name='invite_time_limit' value='<?php echo get_site_option( "invite_time_limit", 31 ) ?>'> <strong>Days</strong></td></tr>
- <tr><th scope='row' valign='top'>Default Subject:</td><td><input type='text' size='70' maxlength='90' name='invites_default_subject' value='<?php echo get_site_option( "invites_default_subject" ) ?>'></td></tr>
- <tr><th scope='row' valign='top'>Default Message:</td><td><textarea rows="9" cols="70" name="invites_default_message" tabindex="5" id="defaultmessage"><?php echo str_replace( "\\r\\n", "\n", stripslashes( get_site_option( 'invites_default_message' ) ) ) ?></textarea></td></tr>
- <tr><th scope='row' valign='top'>Registration - check for invite: </td><td><input type='checkbox' name='check_reg_for_invite' value='yes'<?php if( get_site_option( 'check_reg_for_invite' ) == 'yes' ) echo " checked"; ?>></td></tr>
- <tr><td valign='top' colspan='2'><input type='submit'></td></tr>
- </table>
- </form>
- </fieldset>
- </div>
- <div class='wrap'>
- <h2>Invite Stats</h2>
- <ul>
- <li> Free Invites: <?php echo $wpdb->get_var( "SELECT sum( meta_value ) FROM $wpdb->usermeta WHERE meta_key = 'invites_left'" ); ?></li>
- <li> <?php echo $wpdb->get_var( "SELECT count(*) FROM $wpdb->usermeta WHERE meta_key LIKE '%invited_by'" ) ?> Invites sent, of which <?php echo $wpdb->get_var( "SELECT count(*) FROM $wpdb->usermeta WHERE meta_key='invite'" ); ?> are pending and have not been used yet.</li>
- <li> Invites Per User:<ul>
- <?php $invite_groups = $wpdb->get_results( "SELECT count(*) as c, meta_value FROM {$wpdb->usermeta} WHERE `meta_key` = 'invites_left' group by meta_value", ARRAY_A );
- while( list( $key, $val ) = each( $invite_groups ) )
- {
- print "<li> {$val[ 'c' ]} users have {$val[ 'meta_value' ]} invites.</li>";
- }
- ?>
- </ul></li>
- </ul>
- </div>
- <?php
-}
-if( get_usermeta( get_current_user_id(), 'invites_left' ) )
- add_action('admin_head', 'invites_link' );
-
-function invites_link() {
- ?>
-<script type="text/javascript">
-function invites_link() {
- inviteslink = document.createElement('a');
- inviteslink.id = 'inviteslink';
- inviteslink.innerHTML = 'Invites';
- inviteslink.href = 'invites.php';
- var userinfo = document.getElementById( 'footer' );
- userinfo.appendChild(inviteslink);
- var inviteslinkForm = document.getElementById('inviteslinkform');
-}
-
-// addLoadEvent from admin-header
-addLoadEvent( invites_link );
-
-</script>
-<style type="text/css">
-#inviteslink {
- position: absolute;
- top: 2.8em;
- right: 10em;
- display: block;
- padding: .3em .8em;
- background: #6da6d1;
- color: #fff;
- cursor: pointer;
-}
-</style>
-
-<?php
-}
-?>
diff --git a/wp-inst/wp-content/mu-plugins/wp-hashcash.php b/wp-inst/wp-content/mu-plugins/wp-hashcash.php
deleted file mode 100644
index 1853c71..0000000
--- a/wp-inst/wp-content/mu-plugins/wp-hashcash.php
+++ /dev/null
@@ -1,684 +0,0 @@
-<?php
-/*
-Plugin Name: WordPress Hashcash
-Plugin URI: http://elliottback.com/wp/archives/2005/05/11/wordpress-hashcash-20/
-Description: Client-side javascript computes an md5 code, server double checks. Blocks all spam bots. XHTML 1.1 compliant.
-Author: Elliott Back
-Author URI: http://elliottback.com
-Version: 2.3
-Hat tips: Cecil Coupe - http://ccdl.dyndns.biz/werehosed/
- C.S. - http://www.cimmanon.org/
- Denis de Bernardy - http://www.semiologic.com/
- Diego Sevilla - http://neuromancer.dif.um.es/blog/
- Gene Shepherd - http://www.imporium.org/
- John F. - http://www.stonegauge.com/
- Magenson - http://blog.magenson.de/
- Matt Mullenweg - http://photomatt.net/
- Matt Warden - http://www.mattwarden.com/
- Paul Andrew Johnston - http://pajhome.org.uk/crypt/md5/
-*/
-
-if( defined( "WP_INSTALLING" ) )
- return;
-
-if( strpos( $_SERVER[ 'SCRIPT_NAME' ], 'wp-inst/wp-newblog.php' ) == false ) {
-
-/* Start the session, if not started */
-$hashcash_session_id = session_id();
-if(empty($hashcash_session_id)){
- session_start();
-}
-
-/**
- * Type: bool
- * Purpose: If true, sends logs to the admin email address
- */
-define('HASHCASH_DEBUG', true);
-
-/**
- * Type: long
- * Purpose: Stores up to HASHCASH_LONG_SIZE characters before
- * sending logs to the admin email address
- */
-define('HASHCASH_LOG_SIZE', 64000);
-
-/**
- * Type: string
- * Purpose: Must be set to the name of your comments form action
- * for internal pattern matching purposes
- */
-define('HASHCASH_FORM_ACTION', 'wp-comments-post.php');
-
-/**
- * Type: string
- * Purpose: Must be set to the id of your comments form for
- * internal pattern matching purposes
- */
-define('HASHCASH_FORM_ID', 'commentform');
-
-/**
- * Type: bool
- * Purpose: If true, adds a "protected by" message to the form
- * that supports my work on this plugin, and my dedication to
- * supporting it.
- */
-define('HASHCASH_LINK', false);
-
-/**
- * Type: bool
- * Purpose: If true, writes user-specific information to the
- * form (default). Detects WP-Cache.
- */
-if(WP_CACHE){
- define('HASHCASH_PER_USER', false);
-} else {
- define('HASHCASH_PER_USER', true);
-}
-
-/**
- * Type: int
- * Purpose: An integer random to your installation, for use with
- * WP-Cache, a value only YOU can know. CHANGE IF USING WP 1.2!!
- */
-
-if(get_bloginfo('version') < 1.5){
- define('HASHCASH_PER_USER_RAND', 98246);
-} else {
- // Says Denis to save a query
- if (!get_option('wp_hashcash_version')){
- delete_option('wp_hashcash_rand');
- update_option('wp_hashcash_version', 2.3);
- }
-
- $curr = get_option('wp_hashcash_rand');
- if(empty($curr)){
- srand((double) microtime() * 1000000);
- update_option('wp_hashcash_rand', rand(10000000, 99999999));
- }
-}
-
-/**
- * Takes: An integer l and an array of strings exclude
- * Returns: A random unique string of length l
- */
-function hashcash_random_string($l, $exclude = array()) {
- // Sanity check
- if($l < 1){
- return '';
- }
-
- srand((double) microtime() * 1000000);
-
- $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $chars = preg_split('//', $alphabet, -1, PREG_SPLIT_NO_EMPTY);
- $len = count($chars) - 1;
-
- $str = '';
- while(in_array($str, $exclude) || strlen($str) < 1){
- $str = '';
- while(strlen($str) < $l){
- $str .= $chars[rand(0, $len)];
- }
- }
-
- return $str;
-}
-
-
-/**
- * Takes: A string md5_function_name to call the md5 function
- * Returns: md5 javascript bits to be randomly spliced into the header
- */
-function hashcash_get_md5_javascript($md5_function_name){
- $p = '';
- $s = '';
-
- $names = array();
- $excl = array('a', 's', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
- 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
- 'v', 'w', 'x', 'y', 'z', 'num', 'cnt', 'str', 'bin',
- 'length', 'len', 'var', 'Array', 'mask', 'return', 'msw',
- 'lsw', 'olda', 'oldb', 'oldc', 'oldd', 'function', 'new');
- for($i = 0; $i < 17; $i++){
- $t = hashcash_random_string(rand(1,6), $excl);
- $names [] = $t;
- $excl [] = $t;
- }
-
- $bits = array();
- $bits [] = $p . 'function ' . $md5_function_name . '(s){return ' . $names[5] . '(' . $names[6] . '(' . $names[7] . '(s),s.length*8));}' . $s;
- $bits [] = $p . 'function ' . $names[6] . '(x,len){x[len>>5]|=0x80<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;for(var i=0;i<x.length;i+=16){var olda=a;var oldb=b;var oldc=c;var oldd=d;a=' . $names[8] . '(a,b,c,d,x[i+0],7,-680876936);d=' . $names[8] . '(d,a,b,c,x[i+1],12,-389564586);c=' . $names[8] . '(c,d,a,b,x[i+2],17,606105819);b=' . $names[8] . '(b,c,d,a,x[i+3],22,-1044525330);a=' . $names[8] . '(a,b,c,d,x[i+4],7,-176418897);d=' . $names[8] . '(d,a,b,c,x[i+5],12,1200080426);c=' . $names[8] . '(c,d,a,b,x[i+6],17,-1473231341);b=' . $names[8] . '(b,c,d,a,x[i+7],22,-45705983);a=' . $names[8] . '(a,b,c,d,x[i+8],7,1770035416);d=' . $names[8] . '(d,a,b,c,x[i+9],12,-1958414417);c=' . $names[8] . '(c,d,a,b,x[i+10],17,-42063);b=' . $names[8] . '(b,c,d,a,x[i+11],22,-1990404162);a=' . $names[8] . '(a,b,c,d,x[i+12],7,1804603682);d=' . $names[8] . '(d,a,b,c,x[i+13],12,-40341101);c=' . $names[8] . '(c,d,a,b,x[i+14],17,-1502002290);b=' . $names[8] . '(b,c,d,a,x[i+15],22,1236535329);a=' . $names[9] . '(a,b,c,d,x[i+1],5,-165796510);d=' . $names[9] . '(d,a,b,c,x[i+6],9,-1069501632);c=' . $names[9] . '(c,d,a,b,x[i+11],14,643717713);b=' . $names[9] . '(b,c,d,a,x[i+0],20,-373897302);a=' . $names[9] . '(a,b,c,d,x[i+5],5,-701558691);d=' . $names[9] . '(d,a,b,c,x[i+10],9,38016083);c=' . $names[9] . '(c,d,a,b,x[i+15],14,-660478335);b=' . $names[9] . '(b,c,d,a,x[i+4],20,-405537848);a=' . $names[9] . '(a,b,c,d,x[i+9],5,568446438);d=' . $names[9] . '(d,a,b,c,x[i+14],9,-1019803690);c=' . $names[9] . '(c,d,a,b,x[i+3],14,-187363961);b=' . $names[9] . '(b,c,d,a,x[i+8],20,1163531501);a=' . $names[9] . '(a,b,c,d,x[i+13],5,-1444681467);d=' . $names[9] . '(d,a,b,c,x[i+2],9,-51403784);c=' . $names[9] . '(c,d,a,b,x[i+7],14,1735328473);b=' . $names[9] . '(b,c,d,a,x[i+12],20,-1926607734);a=' . $names[10] . '(a,b,c,d,x[i+5],4,-378558);d=' . $names[10] . '(d,a,b,c,x[i+8],11,-2022574463);c=' . $names[10] . '(c,d,a,b,x[i+11],16,1839030562);b=' . $names[10] . '(b,c,d,a,x[i+14],23,-35309556);a=' . $names[10] . '(a,b,c,d,x[i+1],4,-1530992060);d=' . $names[10] . '(d,a,b,c,x[i+4],11,1272893353);c=' . $names[10] . '(c,d,a,b,x[i+7],16,-155497632);b=' . $names[10] . '(b,c,d,a,x[i+10],23,-1094730640);a=' . $names[10] . '(a,b,c,d,x[i+13],4,681279174);d=' . $names[10] . '(d,a,b,c,x[i+0],11,-358537222);c=' . $names[10] . '(c,d,a,b,x[i+3],16,-722521979);b=' . $names[10] . '(b,c,d,a,x[i+6],23,76029189);a=' . $names[10] . '(a,b,c,d,x[i+9],4,-640364487);d=' . $names[10] . '(d,a,b,c,x[i+12],11,-421815835);c=' . $names[10] . '(c,d,a,b,x[i+15],16,530742520);b=' . $names[10] . '(b,c,d,a,x[i+2],23,-995338651);a=' . $names[11] . '(a,b,c,d,x[i+0],6,-198630844);d=' . $names[11] . '(d,a,b,c,x[i+7],10,1126891415);c=' . $names[11] . '(c,d,a,b,x[i+14],15,-1416354905);b=' . $names[11] . '(b,c,d,a,x[i+5],21,-57434055);a=' . $names[11] . '(a,b,c,d,x[i+12],6,1700485571);d=' . $names[11] . '(d,a,b,c,x[i+3],10,-1894986606);c=' . $names[11] . '(c,d,a,b,x[i+10],15,-1051523);b=' . $names[11] . '(b,c,d,a,x[i+1],21,-2054922799);a=' . $names[11] . '(a,b,c,d,x[i+8],6,1873313359);d=' . $names[11] . '(d,a,b,c,x[i+15],10,-30611744);c=' . $names[11] . '(c,d,a,b,x[i+6],15,-1560198380);b=' . $names[11] . '(b,c,d,a,x[i+13],21,1309151649);a=' . $names[11] . '(a,b,c,d,x[i+4],6,-145523070);d=' . $names[11] . '(d,a,b,c,x[i+11],10,-1120210379);c=' . $names[11] . '(c,d,a,b,x[i+2],15,718787259);b=' . $names[11] . '(b,c,d,a,x[i+9],21,-343485551);a=' . $names[13] . '(a,olda);b=' . $names[13] . '(b,oldb);c=' . $names[13] . '(c,oldc);d=' . $names[13] . '(d,oldd);}return Array(a,b,c,d);}' . $s;
- $bits [] = $p . 'function ' . $names[12] . '(q,a,b,x,s,t){return ' . $names[13] . '(' . $names[16] . '(' . $names[13] . '(' . $names[13] . '(a,q),' . $names[13] . '(x,t)),s),b);}function ' . $names[8] . '(a,b,c,d,x,s,t){return ' . $names[12] . '((b&c)|((~b)&d),a,b,x,s,t);}' . $s;
- $bits [] = $p . 'function ' . $names[9] . '(a,b,c,d,x,s,t){return ' . $names[12] . '((b&d)|(c&(~d)),a,b,x,s,t);}' . $s;
- $bits [] = $p . 'function ' . $names[10] . '(a,b,c,d,x,s,t){return ' . $names[12] . '(b ^ c ^ d,a,b,x,s,t);}' . $s;
- $bits [] = $p . 'function ' . $names[11] . '(a,b,c,d,x,s,t){return ' . $names[12] . '(c ^(b|(~d)),a,b,x,s,t);}' . $s;
- $bits [] = $p . 'function ' . $names[13] . '(x,y){var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF);}' . $s;
- $bits [] = $p . 'function ' . $names[16] . '(num,cnt){return(num<<cnt)|(num>>>(32-cnt));}' . $s;
- $bits [] = $p . 'function ' . $names[7] . '(str){var bin=Array();var mask=(1<<8)-1;for(var i=0;i<str.length*8;i+=8)bin[i>>5]|=(str.charCodeAt(i/8)&mask)<<(i%32);return bin;}' . $s;
- $bits [] = $p . 'function ' . $names[5] . '(' . $names[15] . '){var ' . $names[14] . '="0123456789abcdef";var str="";for(var i=0;i<' . $names[15] . '.length*4;i++){str+=' . $names[14] . '.charAt((' . $names[15] . '[i>>2]>>((i%4)*8+4))&0xF)+' . $names[14] . '.charAt((' . $names[15] . '[i>>2]>>((i%4)*8))&0xF);}return str;}' . $s;
-
- return $bits;
-}
-
-/**
- * Takes: <<void>>
- * Returns: the hashcash special code, based on the session or ip
- */
-function hashcash_special_code(){
- if(HASHCASH_PER_USER) {
- $key = strip_tags(session_id());
-
- if(!$key){
- $key = $_SERVER['REMOTE_ADDR'];
- }
-
- return md5($key . ABSPATH . $_SERVER['HTTP_USER_AGENT'] . date("F j, Y, g a"));
- } else {
- if(get_bloginfo('version') < 1.5){
- return md5(ABSPATH . get_bloginfo('version') . HASHCASH_PER_USER_RAND);
- } else {
- return md5(ABSPATH . get_bloginfo('version') . get_option('wp_hashcash_rand'));
- }
- }
-}
-
-/**
- * Takes: <<void>>
- * Returns: the hashcash special field value
- */
-function hashcash_field_value(){
- global $posts;
- return $posts[0]->ID * strlen(ABSPATH);
-}
-
-/**
- * Takes: String name of function
- * Returns: Javascript to compute field value
- */
-function hashcash_field_value_js($val_name){
- $js = 'function ' . $val_name . '(){';
-
- $type = rand(0, 5);
- switch($type){
- /* Addition of n times of field value / n, + modulus */
- case 0:
- $eax = hashcash_random_string(rand(8,10));
- $val = hashcash_field_value();
- $inc = rand(1, $val - 1);
- $n = floor($val / $inc);
- $r = $val % $inc;
-
- $js .= "var $eax = $inc; ";
- for($i = 0; $i < $n - 1; $i++){
- $js .= "$eax += $inc; ";
- }
-
- $js .= "$eax += $r; ";
- $js .= "return $eax; ";
-
- break;
-
- /* Conversion from binary */
- case 1:
- $eax = hashcash_random_string(rand(8,10));
- $ebx = hashcash_random_string(rand(8,10));
- $ecx = hashcash_random_string(rand(8,10));
- $val = hashcash_field_value();
- $binval = strrev(base_convert($val, 10, 2));
-
- $js .= "var $eax = \"$binval\"; ";
- $js .= "var $ebx = 0; ";
- $js .= "var $ecx = 0; ";
- $js .= "while($ecx < $eax.length){ ";
- $js .= "if($eax.charAt($ecx) == \"1\") { ";
- $js .= "$ebx += Math.pow(2, $ecx); ";
- $js .= "} ";
- $js .= "$ecx++; ";
- $js .= "} ";
- $js .= "return $ebx; ";
-
- break;
-
- /* Multiplication of square roots */
- case 2:
- $val = hashcash_field_value();
- $sqrt = floor(sqrt($val));
- $r = $val - ($sqrt * $sqrt);
- $js .= "return $sqrt * $sqrt + $r; ";
- break;
-
- /* Closest sum up to n */
- case 3:
- $val = hashcash_field_value();
- $n = floor((sqrt(8*$val+1)-1)/2);
- $sum = $n * ($n + 1) / 2;
- $r = $val - $sum;
- $eax = hashcash_random_string(rand(8,10));
-
- $js .= "var $eax = $r; ";
- for($i = 0; $i <= $n; $i++){
- $js .= "$eax += $i; ";
- }
- $js .= "return $eax; ";
- break;
-
- /* Closest sum up to n #2 */
- case 4:
- $val = hashcash_field_value();
- $n = floor((sqrt(8*$val+1)-1)/2);
- $sum = $n * ($n + 1) / 2;
- $r = $val - $sum;
-
- $js .= "return $r ";
- for($i = 0; $i <= $n; $i++){
- $js .= "+ $i ";
- }
- $js .= ";";
- break;
-
- /* Closest sum up to n #3 */
- case 5:
- $val = hashcash_field_value();
- $n = floor((sqrt(8*$val+1)-1)/2);
- $sum = $n * ($n + 1) / 2;
- $r = $val - $sum;
- $eax = hashcash_random_string(rand(8,10));
-
- $js .= "var $eax = $r; var i; ";
- $js .= "for(i = 0; i <= $n; i++){ ";
- $js .= "$eax += i; ";
- $js .= "} ";
- $js .= "return $eax; ";
- break;
- }
-
- $js .= "} ";
- return $js;
-}
-
-/**
- * Takes: An array matching the form
- * Returns: The form code, with input elements disabled
- */
-function hashcash_disable_callback($matches){
- $text = $matches[0];
- return preg_replace('/<input([^>]*?id="(submit|author|email|url)")/si', '<input disabled="disabled"$1', $text);
-}
-
-/**
- * Takes: An array matching the form
- * Returns: The form code, with a protected by link
- */
-function hashcash_link_callback($matches){
- $text = $matches[0];
- $r = rand(0, 4);
- switch($r){
- case 0:
- return str_replace('</form>', '<p>Protected by <a href="http://elliottback.com/" title="Elliott Back\'s Antispam Protection">WP-Hashcash</a>.</p>' . "\n" . '</form>', $text);
- break;
- case 1:
- return str_replace('</form>', '<p><a href="http://elliottback.com/" title="Elliott Back">WP-Hashcash</a>: protecting you from spam.</p>' . "\n" . '</form>', $text);
- break;
- case 2:
- return str_replace('</form>', '<p>Powered by <a href="http://elliottback.com/" title="Elliott Back, Spam Protection">WP-Hashcash</a>.</p>' . "\n" . '</form>', $text);
- break;
- case 3:
- return str_replace('</form>', '<p>I\'m <a href="http://elliottback.com/" title="Elliott Back">WP-Hashcash</a>. I eat spam.</p>' . "\n" . '</form>', $text);
- break;
- case 4:
- return str_replace('</form>', '<p>What\'s a blog without spam? <a href="http://elliottback.com/" title="Elliott Back + Spam Protection">WP-Hashcash</a>.</p>' . "\n" . '</form>', $text);
- break;
- }
-}
-
-/**
- * Takes: An array matching the form
- * Returns: The form code, with a noscript attribution
- */
-function hashcash_script_callback($matches){
- $text = $matches[0];
- return str_replace('<form', '<noscript><p>WP-Hashcash by <a href="http://elliottback.com/" title="Elliott Back\'s Blog">Elliott Back</a> protects <strong>you</strong> from spam. Please enable javascript and reload this page to add your comment.</p></noscript>' . "\n" . '<form', $text);
-}
-
-/**
- * Takes: An array matching the form
- * Returns: The form code, with appropriate javascript action
- */
-function hashcash_add_action_callback($matches){
- global $hashcash_form_action;
- return str_replace('<form', '<form onsubmit="' . $hashcash_form_action . '(\'' . hashcash_special_code() . '\');" ', $matches[0]);
-}
-
-/**
- * Takes: A WordPress single page
- * Returns: The same page with a random hidden field and others added.
- * This is the workhorse of WP-Hashcash
- */
-function hashcash_add_hidden_tag($page) {
- global $posts, $single, $hashcash_form_action, $post;
-
- if ($single && $post->comment_status == 'open'){
- $field_id = hashcash_random_string(rand(6,18));
- $field_name = hashcash_random_string(rand(6,18));
- $hashcash_form_action = hashcash_random_string(rand(6,18));
- $md5_name = hashcash_random_string(rand(6,18));
- $val_name = hashcash_random_string(rand(6,18));
- $eElement = hashcash_random_string(rand(6,18));
- $in_str = hashcash_random_string(rand(6,18));
- $fn_enable_name = hashcash_random_string(rand(6,18));
-
- /**
- * 1) Hidden hashcode
- */
-
- // Write in hidden field
- $page = str_replace('<input type="hidden" name="comment_post_ID"', '<input type="hidden" id="' . $field_id . '" name="' . $field_name . '" value="' . rand(100, 99999999) . '" /> <input type="hidden" name="comment_post_ID"', $page);
-
- // The form action
- $page = preg_replace_callback('/<form[^>]*?' . HASHCASH_FORM_ACTION . '.*?<\/form>/si', 'hashcash_add_action_callback', $page);
-
- // The javascript
- $hashcash_bits = hashcash_get_md5_javascript($md5_name);
- $hashcash_bits [] = "function $hashcash_form_action($in_str){ "
- . "$eElement = document.getElementById(\"$field_id\"); "
- . "if(!$eElement){ return false; } else { $eElement" . ".name = $md5_name($in_str); $eElement" . ".value = $val_name(); return true; }}";
-
- $hashcash_bits [] = hashcash_field_value_js($val_name);
-
- /**
- * 2) Javascript enabled form fields
- */
-
- // Disable form fields
- $page = preg_replace_callback('/<form[^>]*?' . HASHCASH_FORM_ACTION . '.*?<\/form>/si', 'hashcash_disable_callback', $page);
-
- // Try to enable all form fields from javascript
- $fields = array('submit', 'author', 'email', 'url');
- $page = str_replace('<body', '<script language="Javascript">addLoadEvent( ' . $fn_enable_name . ' );</script><body', $page);
-
- $script = 'function ' . $fn_enable_name . '(){';
- shuffle($fields);
- foreach($fields as $field){
- $field_temp = hashcash_random_string(rand(6,18));
- $script .= "$field_temp = document.getElementById('$field'); if(!$field_temp){} else { $field_temp.disabled = false; } ";
- }
-
- // Other things that happen onload()
- $script .= "document.getElementById('" . HASHCASH_FORM_ID . "').style.display = 'block';";
-
- // Terminator
- $script .= '}';
- $hashcash_bits [] = $script;
-
- /**
- * 3) Hide form for non-users of javascript
- */
-
- $page = preg_replace_callback('/<form[^>]*?' . HASHCASH_FORM_ACTION . '.*?<\/form>/si', 'hashcash_script_callback', $page);
- $page = str_replace('</head>', '<style type="text/css">#' . HASHCASH_FORM_ID . '{ display: none; }</style>' . "\n" . '</head>', $page);
-
- /**
- * 4) Write all the javascript bits to various lines of <head>
- */
-
- shuffle($hashcash_bits);
- $js = '<script type="text/javascript">' . "\n"
- . '<!--' . "\n"
- . implode(" ", $hashcash_bits) . "\n"
- . '-->' . "\n"
- . '</script>' . "\n";
- $page = str_replace('</head>', $js . '</head>', $page);
-
- /**
- * 5) Powered by WP-Hashcash
- */
-
- if(HASHCASH_LINK)
- $page = preg_replace_callback('/<form[^>]*?' . HASHCASH_FORM_ACTION . '.*?<\/form>/si', 'hashcash_link_callback', $page);
- }
-
- return $page;
-}
-
-/**
- * Takes: <<void>>
- * Returns: Buffered page output w/ hashcash inserted
- */
-function hashcash_call_stopgap() {
- ob_start('hashcash_add_hidden_tag');
-}
-
-add_action('wp_head', 'hashcash_call_stopgap');
-
-/**
- * Takes: The text of a comment
- * Returns: <<void>>, writes comment to log
- */
-function write_comment_log($comment){
-
- /* Information to write to log */
- $user = array();
- $user[] = date("F j, Y, g:i a");
- $user[] = $_SERVER['REMOTE_ADDR'];
- $user[] = $_SERVER['HTTP_USER_AGENT'];
- $user[] = $_SERVER['HTTP_REFERER'];
- $user[] = $_POST['author'];
- $user[] = $_POST['email'];
- $user[] = $_POST['url'];
- $user[] = preg_replace('/[\n\r]+/','<br />', $comment);
- $user[] = $_POST['comment_post_ID'];
-
- $lines = join($user, "\n");
-
- /* In 1.5, use options. */
- $path = ABSPATH . "wp-content/plugins/wp-hashcash.log";
- if(get_bloginfo('version') < 1.5){
- /* Open the file */
- $file = fopen($path, 'a+');
- if(!$file) die("File \"$path\" failed to open");
-
- /* Save the log */
- $status = fwrite($file, "\n" . $lines);
-
- /* Close the file */
- fclose($file);
- if(!status) die("Spam-log write failed...");
-
- /* Read the file */
- $new = file($path);
- } else {
- add_option('wp_hashcash_log', '', 'Log option for the wp-hashcash plugin', 'no');
- $current = get_option('wp_hashcash_log');
- $new = $current . "\n" . $lines;
- update_option('wp_hashcash_log', $new);
- }
-
- /* If we're here, the file exists. Check size, email every 64kb */
- if( strlen($new) > HASHCASH_LOG_SIZE ) {
- $header = "<html><head><style>tr { margin: 0px 0px 5px 20px; }</style></head><body><h2>Spam Report:</h2>";
- $footer = "</body></html>";
-
- // Process log
- $log = $header;
- $i = false;
-
- $temp = explode("\n", $new);
-
- $count = count($temp) / 9;
- $log .= "<p>There were $count spam...</p>";
-
- // Table
- $log .= "<table>";
- for ($j = 0; $j < count($temp) - 1; $j++) {
- if ($i)
- $log .= '<tr style="background-color: #eee">';
- else
- $log .= '<tr>';
-
- $log .= "<td>";
- $log .= $temp[$j]; $j++;
- $log .= "<blockquote>";
- $log .= "<strong>IP:</strong> $temp[$j]<br />"; $j++;
- $log .= "<strong>User-Agent:</strong> $temp[$j]<br />"; $j++;
- $log .= "<strong>Referer:</strong> <a href=\"$temp[$j]\">$temp[$j]</a><br />"; $j++;
- $log .= "<strong>Author:</strong> $temp[$j]<br />"; $j++;
- $log .= "<strong>Email:</strong> <a href=\"mailto:$temp[$j]\">$temp[$j]</a><br />"; $j++;
- $log .= "<strong>URL:</strong> <a href=\"$temp[$j]\">$temp[$j]</a><br />"; $j++;
- $log .= "<br />";
- $log .= $temp[$j]; $j++;
- $log .= "<br /><br />";
- $log .= "on post <a href=\"" . get_settings('siteurl') . "/index.php?p=" . $temp[$j] . "\">" . $temp[$j] . "</a>";
- $log .= "</blockquote>";
- $log .="</td>";
- $log .= "</tr>";
- $i = !$i;
- }
- $log .= "</table>";
-
- // Footer
- $log .= $footer;
-
- // Send email
- $headers = "Content-type: text/html; charset=" . get_settings('blog_charset') . "\r\n";
- mail(get_settings('admin_email'), '[' . get_settings('blogname') . '] Spam Report', $log, $headers);
-
- // Clear file
- if(get_bloginfo('version') < 1.5){
- $file = fopen($path, 'w');
- if(!file){
- die("Unable to truncate old log file");
- } else{
- fclose($file);
- }
- } else {
- update_option('wp_hashcash_log', '');
- }
- }
-}
-
-/**
- * Takes: The text of a comment
- * Returns: The comment iff it matches the hidden md5'ed tag
- */
-function hashcash_check_hidden_tag($comment) {
- // Our special codes, fixed to check the previous hour
- $special = array();
-
- if(HASHCASH_PER_USER){
- $special[] = md5($_SERVER['REMOTE_ADDR'] . ABSPATH . $_SERVER['HTTP_USER_AGENT'] . date("F j, Y, g a"));
- $special[] = md5($_SERVER['REMOTE_ADDR'] . ABSPATH . $_SERVER['HTTP_USER_AGENT'] . date("F j, Y, g a", time()-(60*60)));
- $special[] = md5(strip_tags(session_id()) . ABSPATH . $_SERVER['HTTP_USER_AGENT'] . date("F j, Y, g a"));
- $special[] = md5(strip_tags(session_id()) . ABSPATH . $_SERVER['HTTP_USER_AGENT'] . date("F j, Y, g a", time()-(60*60)));
- } else {
- if(get_bloginfo('version') < 1.5){
- $special[] = md5(ABSPATH . get_bloginfo('version') . HASHCASH_PER_USER_RAND);
- } else {
- $special[] = md5(ABSPATH . get_bloginfo('version') . get_option('wp_hashcash_rand'));
- }
- }
-
- foreach($special as $val){
- if($_POST[md5($val)] == ($_POST['comment_post_ID'] * strlen(ABSPATH))){
- return $comment;
- }
- }
-
- // If here, the comment has failed the check
- if( HASHCASH_DEBUG )
- write_comment_log($comment);
-
- // Be more user friendly if we detect spam, and it sends a referer
- if(strlen(trim($_SERVER['HTTP_REFERER'])) > 0 && preg_match('|' . get_bloginfo('url') . '|i', $_SERVER['HTTP_REFERER']))
- echo '
-<!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" lang="en">
- <head profile="http://gmpg.org/xfn/11">
- <title>WP-Hashcash Check Failed</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <style type="text/css">
- body {
- font-family: Arial, Verdana, Helvetica;
- color: #3F3F3F;
- }
-
- h1 {
- margin: 0px;
- color: #6A8E1C;
- font-size: 1.8em;
- }
-
- a:link {
- color: #78A515;
- font-weight: bold;
- text-decoration: none;
- }
-
- a:visited { color: #999; }
-
- a:hover, a:active {
- background: #78A515;
- color: #fff;
- text-decoration: none;
- }
- </style>
- </head>
-
- <body>
- <div style="margin: 0 auto; margin-top:50px; padding: 20px; text-align: left; width: 400px; border: 1px solid #78A515;">
- <h1>WP-Hashcash Check Failed</h1>
-
- <p>Your client has failed to compute the special javascript hashcode required to comment on this blog.
- If you believe this to be in error, please contact the blog administrator, and check for javascript,
- validation, or php errors. It is also possible that you are trying to spam this blog.</p>
-
- <p>If you are using Google Web Accelerator, a proxy, or some other caching system, WP-Hashcash may not let you comment.
- There are known issues with caching that are fundamentally insoluble, because the page being written to you must be generated freshly.
- Turn off your caching software and reload the page. If you are using a proxy, commenting should work, but it is untested.</p>';
-
-/* Possible sources of error */
-
-if(!session_id()){
- echo '<p style="border: 2px solid red; color:red; padding:4px;">Unable to generate you a Session ID, falling back on your remote address,
-which appears to be ' . $_SERVER['REMOTE_ADDR'] . '. If this is not your remote address, this is the cause of the error.</p>';
-}
-
-if(!session_id() && strlen($_SERVER['REMOTE_ADDR']) < 1){
- echo '<p style="border: 2px solid red; color:red; padding:4px;">Your remote address is null.</p>';
-}
-
-if(!in_array($_POST['comment_post_ID'] * strlen(ABSPATH), $_POST)){
- echo '<p style="border: 2px solid red; color:red; padding:4px;">The value you submitted (' . $_POST[md5($val)] . ')
- is incorrect. Check the javascript to assure that the value part of the (hash, value) pair is being correctly
- generated.</p>';
-}
-
-$hashash = false;
-foreach($special as $spec){
- if(array_key_exists($spec, $_POST))
- $hashash = true;
-}
-
-if($hashash) {
- echo '<p style="border: 2px solid red; color:red; padding:4px;">The hash does not exist.
- Check the javascript to assure that the md5 hash part of the (hash, value) pair is
- being correctly generated.</p>';
-}
-
-if(WP_CACHE && HASHCASH_PER_USER){
- echo '<p style="border: 2px solid red; color:red; padding:4px;">WP-Cache is detected, but for
- some reason, HASHCASH_PER_USER is set to true.</p>';
-}
-
-echo' <p>This comment has been logged, and will not be displayed on the blog.</p>
- </div>
- </body>
-</html>';
-
- die();
-}
-
-add_filter('post_comment_text', 'hashcash_check_hidden_tag');
-
-}
-
-?>
diff --git a/wp-inst/wp-content/themes/home/header.php b/wp-inst/wp-content/themes/home/header.php
index 99ff334..37a0326 100644
--- a/wp-inst/wp-content/themes/home/header.php
+++ b/wp-inst/wp-content/themes/home/header.php
@@ -1,61 +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 />
+<!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() && !is_home() ) { ?>
+ #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/home/home.php b/wp-inst/wp-content/themes/home/home.php
index f52d20b..7188264 100644
--- a/wp-inst/wp-content/themes/home/home.php
+++ b/wp-inst/wp-content/themes/home/home.php
@@ -1,15 +1,15 @@
-<?php get_header(); ?>
-
- <div id="content" class="widecolumn">
-
- <h2><?php echo $current_site->site_name ?></h2>
- <p>This is a <a href="http://mu.wordpress.org/">WordPress Mu</a> powered site.</p>
- <p>You can: <ul><li> <a href="wp-login.php">Login</a> </li><li> <a href="wp-newblog.php">Create a new blog</a></li><li> Edit this file at <code>wp-content/themes/home/home.php</code> with your favourite text editor and customize this screen.</li></ul></p>
- <?php if( constant( "VHOST" ) == 'no' ) :?>
- <h3>Virtual Hosts</h3>
- <p>As you are not using virtual hosts, it is not possible to post anything to this primary blog because the URLs of your posts could potentially conflict with weblogs living at this site. Please consider using virtual hosts as <a href="http://mu.wordpress.org/forums/topic/99">described here</a> instead so that your website will have http://blogname.<?php echo $_SERVER[ 'HTTP_HOST' ] ?>/ format addresses instead of http://<?php echo $_SERVER[ 'HTTP_HOST' ] ?>/blogname/ format.</p>
- <?php endif; ?>
-
- </div>
-
-<?php get_footer(); ?>
+<?php get_header(); ?>
+
+ <div id="content" class="widecolumn">
+
+ <h2>WordPress &micro;</h2>
+ <p>This is a <a href="http://mu.wordpress.org/">WordPress Mu</a> powered site.</p>
+ <p>You can: <ul><li> <a href="wp-login.php">Login</a> </li><li> <a href="wp-signup.php">Create a new blog</a></li><li> Edit this file at <code>wp-content/themes/home/home.php</code> with your favourite text editor and customize this screen.</li></ul></p>
+ <?php if( constant( 'VHOST' ) == 'no' ) :?>
+ <h3>Virtual Hosts</h3>
+ <p>As you are not using virtual hosts, it is not possible to post anything to this primary blog because the URLs of your posts could potentially conflict with weblogs living at this site.</p>
+ <?php endif; ?>
+
+ </div>
+
+<?php get_footer(); ?>
diff --git a/wp-inst/wp-includes/cache.php b/wp-inst/wp-includes/cache.php
index be3e348..0ec19e1 100644
--- a/wp-inst/wp-includes/cache.php
+++ b/wp-inst/wp-includes/cache.php
@@ -1,430 +1,420 @@
-<?php
-function wp_cache_add($key, $data, $flag = '', $expire = 0) {
- global $wp_object_cache;
-
- return $wp_object_cache->add($key, $data, $flag, $expire);
-}
-
-function wp_cache_close() {
- global $wp_object_cache;
-
- return $wp_object_cache->save();
-}
-
-function wp_cache_delete($id, $flag = '') {
- global $wp_object_cache;
-
- return $wp_object_cache->delete($id, $flag);
-}
-
-function wp_cache_flush() {
- global $wp_object_cache;
-
- return $wp_object_cache->flush();
-}
-
-function wp_cache_get($id, $flag = '') {
- global $wp_object_cache;
-
- return $wp_object_cache->get($id, $flag);
-}
-
-function wp_cache_init() {
- global $wp_object_cache;
-
- $wp_object_cache = new WP_Object_Cache();
-}
-
-function wp_cache_replace($key, $data, $flag = '', $expire = 0) {
- global $wp_object_cache;
-
- return $wp_object_cache->replace($key, $data, $flag, $expire);
-}
-
-function wp_cache_set($key, $data, $flag = '', $expire = 0) {
- global $wp_object_cache;
-
- return $wp_object_cache->set($key, $data, $flag, $expire);
-}
-
-define('CACHE_SERIAL_HEADER', "<?php\n//");
-define('CACHE_SERIAL_FOOTER', "\n?".">");
-
-class WP_Object_Cache {
- var $cache_dir;
- var $cache_enabled = false;
- var $expiration_time = 900;
- var $flock_filename = 'wp_object_cache.lock';
- var $mutex;
- var $cache = array ();
- var $dirty_objects = array ();
- var $non_existant_objects = array ();
- var $global_groups = array ('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details');
- var $blog_id;
- var $cold_cache_hits = 0;
- var $warm_cache_hits = 0;
- var $cache_misses = 0;
-
- function acquire_lock() {
- // Acquire a write lock.
- $this->mutex = @fopen($this->cache_dir.$this->flock_filename, 'w');
- if ( false == $this->mutex)
- return false;
- flock($this->mutex, LOCK_EX);
- return true;
- }
-
- function add($id, $data, $group = 'default', $expire = '') {
- if (empty ($group))
- $group = 'default';
-
- if (false !== $this->get($id, $group, false))
- return false;
-
- return $this->set($id, $data, $group, $expire);
- }
-
- function delete($id, $group = 'default', $force = false) {
- if (empty ($group))
- $group = 'default';
-
- if (!$force && false === $this->get($id, $group, false))
- return false;
-
- unset ($this->cache[$group][$id]);
- $this->non_existant_objects[$group][$id] = true;
- $this->dirty_objects[$group][] = $id;
- return true;
- }
-
- function flush() {
- if ( !$this->cache_enabled )
- return true;
-
- if ( ! $this->acquire_lock() )
- return false;
-
- $this->rm_cache_dir();
- $this->cache = array ();
- $this->dirty_objects = array ();
- $this->non_existant_objects = array ();
-
- $this->release_lock();
-
- return true;
- }
-
- function get($id, $group = 'default', $count_hits = true) {
- if (empty ($group))
- $group = 'default';
-
- if (isset ($this->cache[$group][$id])) {
- if ($count_hits)
- $this->warm_cache_hits += 1;
- return $this->cache[$group][$id];
- }
-
- if (isset ($this->non_existant_objects[$group][$id]))
- return false;
-
- // If caching is not enabled, we have to fall back to pulling from the DB.
- if (!$this->cache_enabled) {
- if (!isset ($this->cache[$group]))
- $this->load_group_from_db($group);
-
- if (isset ($this->cache[$group][$id])) {
- $this->cold_cache_hits += 1;
- return $this->cache[$group][$id];
- }
-
- $this->non_existant_objects[$group][$id] = true;
- $this->cache_misses += 1;
- return false;
- }
-
- $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".md5($id.DB_PASSWORD).'.php';
- if (!file_exists($cache_file)) {
- $this->non_existant_objects[$group][$id] = true;
- $this->cache_misses += 1;
- return false;
- }
-
- // If the object has expired, remove it from the cache and return false to force
- // a refresh.
- $now = time();
- if ((filemtime($cache_file) + $this->expiration_time) <= $now) {
- $this->cache_misses += 1;
- $this->delete($id, $group, true);
- return false;
- }
-
- $this->cache[$group][$id] = unserialize(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER)));
- if (false === $this->cache[$group][$id])
- $this->cache[$group][$id] = '';
-
- $this->cold_cache_hits += 1;
- return $this->cache[$group][$id];
- }
-
- function get_group_dir($group) {
- if (false !== array_search($group, $this->global_groups))
- return $group;
-
- return "{$this->blog_id}/$group";
- }
-
- function load_group_from_db($group) {
- global $wpdb;
-
- if ('category' == $group) {
- $this->cache['category'] = array ();
- if ($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")) {
- foreach ($dogs as $catt)
- $this->cache['category'][$catt->cat_ID] = $catt;
-
- foreach ($this->cache['category'] as $catt) {
- $curcat = $catt->cat_ID;
- $fullpath = '/'.$this->cache['category'][$catt->cat_ID]->category_nicename;
- while ($this->cache['category'][$curcat]->category_parent != 0) {
- $curcat = $this->cache['category'][$curcat]->category_parent;
- $fullpath = '/'.$this->cache['category'][$curcat]->category_nicename.$fullpath;
- }
- $this->cache['category'][$catt->cat_ID]->fullpath = $fullpath;
- }
- }
- } else
- if ('options' == $group) {
- $wpdb->hide_errors();
- if (!$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'")) {
- $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
- }
- $wpdb->show_errors();
-
- if ( ! $options )
- return;
-
- foreach ($options as $option) {
- $this->cache['options'][$option->option_name] = $option->option_value;
- }
- }
- }
-
- function make_group_dir($group, $perms) {
- $group_dir = $this->get_group_dir($group);
- $make_dir = '';
- foreach (split('/', $group_dir) as $subdir) {
- $make_dir .= "$subdir/";
- if (!file_exists($this->cache_dir.$make_dir)) {
- if (! @ mkdir($this->cache_dir.$make_dir))
- break;
- @ chmod($this->cache_dir.$make_dir, $perms);
- }
-
- if (!file_exists($this->cache_dir.$make_dir."index.php")) {
- $file_perms = $perms & 0000666;
- @ touch($this->cache_dir.$make_dir."index.php");
- @ chmod($this->cache_dir.$make_dir."index.php", $file_perms);
- }
- }
-
- return $this->cache_dir."$group_dir/";
- }
-
- function rm_cache_dir() {
- $dir = $this->cache_dir;
- $dir = rtrim($dir, DIRECTORY_SEPARATOR);
- $top_dir = $dir;
- $stack = array($dir);
- $index = 0;
-
- while ($index < count($stack)) {
- # Get indexed directory from stack
- $dir = $stack[$index];
-
- $dh = @ opendir($dir);
- if (!$dh)
- return false;
-
- while (($file = @ readdir($dh)) !== false) {
- if ($file == '.' or $file == '..')
- continue;
-
- if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
- $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
- else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file))
- @ unlink($dir . DIRECTORY_SEPARATOR . $file);
- }
-
- $index++;
- }
-
- $stack = array_reverse($stack); // Last added dirs are deepest
- foreach($stack as $dir) {
- if ( $dir != $top_dir)
- @ rmdir($dir);
- }
-
- }
-
- function release_lock() {
- // Release write lock.
- flock($this->mutex, LOCK_UN);
- fclose($this->mutex);
- }
-
- function replace($id, $data, $group = 'default', $expire = '') {
- if (empty ($group))
- $group = 'default';
-
- if (false === $this->get($id, $group, false))
- return false;
-
- return $this->set($id, $data, $group, $expire);
- }
-
- function set($id, $data, $group = 'default', $expire = '') {
- if (empty ($group))
- $group = 'default';
-
- if (NULL == $data)
- $data = '';
-
- $this->cache[$group][$id] = $data;
- unset ($this->non_existant_objects[$group][$id]);
- $this->dirty_objects[$group][] = $id;
-
- return true;
- }
-
- function save() {
- //$this->stats();
-
- if (!$this->cache_enabled)
- return true;
-
- if (empty ($this->dirty_objects))
- return true;
-
- // Give the new dirs the same perms as wp-content.
- $stat = stat(ABSPATH.'wp-content');
- $dir_perms = $stat['mode'] & 0007777; // Get the permission bits.
- $file_perms = $dir_perms & 0000666; // Remove execute bits for files.
-
- // Make the base cache dir.
- if (!file_exists($this->cache_dir)) {
- if (! @ mkdir($this->cache_dir))
- return false;
- @ chmod($this->cache_dir, $dir_perms);
- }
-
- if (!file_exists($this->cache_dir."index.php")) {
- @ touch($this->cache_dir."index.php");
- @ chmod($this->cache_dir."index.php", $file_perms);
- }
-
- if ( ! $this->acquire_lock() )
- return false;
-
- // Loop over dirty objects and save them.
- $errors = 0;
- foreach ($this->dirty_objects as $group => $ids) {
- $group_dir = $this->make_group_dir($group, $dir_perms);
-
- $ids = array_unique($ids);
- foreach ($ids as $id) {
- $cache_file = $group_dir.md5($id.DB_PASSWORD).'.php';
-
- // Remove the cache file if the key is not set.
- if (!isset ($this->cache[$group][$id])) {
- if (file_exists($cache_file))
- @ unlink($cache_file);
- continue;
- }
-
- $temp_file = tempnam($group_dir, 'tmp');
- $serial = CACHE_SERIAL_HEADER.serialize($this->cache[$group][$id]).CACHE_SERIAL_FOOTER;
- $fd = @fopen($temp_file, 'w');
- if ( false === $fd ) {
- $errors++;
- continue;
- }
- fputs($fd, $serial);
- fclose($fd);
- if (!@ rename($temp_file, $cache_file)) {
- if (@ copy($temp_file, $cache_file))
- @ unlink($temp_file);
- else
- $errors++;
- }
- @ chmod($cache_file, $file_perms);
- }
- }
-
- $this->dirty_objects = array();
-
- $this->release_lock();
-
- if ( $errors )
- return false;
-
- return true;
- }
-
- function stats() {
- echo "<p>";
- echo "<strong>Cold Cache Hits:</strong> {$this->cold_cache_hits}<br/>";
- echo "<strong>Warm Cache Hits:</strong> {$this->warm_cache_hits}<br/>";
- echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br/>";
- echo "</p>";
-
- foreach ($this->cache as $group => $cache) {
- echo "<p>";
- echo "<strong>Group:</strong> $group<br/>";
- echo "<strong>Cache:</strong>";
- echo "<pre>";
- print_r($cache);
- echo "</pre>";
- if (isset ($this->dirty_objects[$group])) {
- echo "<strong>Dirty Objects:</strong>";
- echo "<pre>";
- print_r(array_unique($this->dirty_objects[$group]));
- echo "</pre>";
- echo "</p>";
- }
- }
- }
-
- function WP_Object_Cache() {
- global $blog_id;
-
- if (defined('DISABLE_CACHE'))
- return;
-
- if ( ! defined('ENABLE_CACHE') )
- return;
-
- // Disable the persistent cache if safe_mode is on.
- if ( ini_get('safe_mode') && ! defined('ENABLE_CACHE') )
- return;
-
- if (defined('CACHE_PATH'))
- $this->cache_dir = CACHE_PATH;
- else
- // Using the correct separator eliminates some cache flush errors on Windows
- $this->cache_dir = ABSPATH.'wp-content'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;
-
- if (is_writable($this->cache_dir) && is_dir($this->cache_dir)) {
- $this->cache_enabled = true;
- } else {
- if (is_writable(ABSPATH.'wp-content')) {
- $this->cache_enabled = true;
- }
- }
-
- if (defined('CACHE_EXPIRATION_TIME'))
- $this->expiration_time = CACHE_EXPIRATION_TIME;
-
- $this->blog_id = md5($blog_id);
- }
-}
-?>
+<?php
+function wp_cache_add($key, $data, $flag = '', $expire = 0) {
+ global $wp_object_cache;
+
+ return $wp_object_cache->add($key, $data, $flag, $expire);
+}
+
+function wp_cache_close() {
+ global $wp_object_cache;
+
+ return $wp_object_cache->save();
+}
+
+function wp_cache_delete($id, $flag = '') {
+ global $wp_object_cache;
+
+ return $wp_object_cache->delete($id, $flag);
+}
+
+function wp_cache_flush() {
+ global $wp_object_cache;
+
+ return $wp_object_cache->flush();
+}
+
+function wp_cache_get($id, $flag = '') {
+ global $wp_object_cache;
+
+ return $wp_object_cache->get($id, $flag);
+}
+
+function wp_cache_init() {
+ global $wp_object_cache;
+
+ $wp_object_cache = new WP_Object_Cache();
+}
+
+function wp_cache_replace($key, $data, $flag = '', $expire = 0) {
+ global $wp_object_cache;
+
+ return $wp_object_cache->replace($key, $data, $flag, $expire);
+}
+
+function wp_cache_set($key, $data, $flag = '', $expire = 0) {
+ global $wp_object_cache;
+
+ return $wp_object_cache->set($key, $data, $flag, $expire);
+}
+
+define('CACHE_SERIAL_HEADER', "<?php\n//");
+define('CACHE_SERIAL_FOOTER', "\n?".">");
+
+class WP_Object_Cache {
+ var $cache_dir;
+ var $cache_enabled = false;
+ var $expiration_time = 900;
+ var $flock_filename = 'wp_object_cache.lock';
+ var $mutex;
+ var $cache = array ();
+ var $dirty_objects = array ();
+ var $non_existant_objects = array ();
+ var $global_groups = array ('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details');
+ var $blog_id;
+ var $cold_cache_hits = 0;
+ var $warm_cache_hits = 0;
+ var $cache_misses = 0;
+
+ function acquire_lock() {
+ // Acquire a write lock.
+ $this->mutex = @fopen($this->cache_dir.$this->flock_filename, 'w');
+ if ( false == $this->mutex)
+ return false;
+ flock($this->mutex, LOCK_EX);
+ return true;
+ }
+
+ function add($id, $data, $group = 'default', $expire = '') {
+ if (empty ($group))
+ $group = 'default';
+
+ if (false !== $this->get($id, $group, false))
+ return false;
+
+ return $this->set($id, $data, $group, $expire);
+ }
+
+ function delete($id, $group = 'default', $force = false) {
+ if (empty ($group))
+ $group = 'default';
+
+ if (!$force && false === $this->get($id, $group, false))
+ return false;
+
+ unset ($this->cache[$group][$id]);
+ $this->non_existant_objects[$group][$id] = true;
+ $this->dirty_objects[$group][] = $id;
+ return true;
+ }
+
+ function flush() {
+ if ( !$this->cache_enabled )
+ return true;
+
+ if ( ! $this->acquire_lock() )
+ return false;
+
+ $this->rm_cache_dir();
+ $this->cache = array ();
+ $this->dirty_objects = array ();
+ $this->non_existant_objects = array ();
+
+ $this->release_lock();
+
+ return true;
+ }
+
+ function get($id, $group = 'default', $count_hits = true) {
+ if (empty ($group))
+ $group = 'default';
+
+ if (isset ($this->cache[$group][$id])) {
+ if ($count_hits)
+ $this->warm_cache_hits += 1;
+ return $this->cache[$group][$id];
+ }
+
+ if (isset ($this->non_existant_objects[$group][$id]))
+ return false;
+
+ // If caching is not enabled, we have to fall back to pulling from the DB.
+ if (!$this->cache_enabled) {
+ if (!isset ($this->cache[$group]))
+ $this->load_group_from_db($group);
+
+ if (isset ($this->cache[$group][$id])) {
+ $this->cold_cache_hits += 1;
+ return $this->cache[$group][$id];
+ }
+
+ $this->non_existant_objects[$group][$id] = true;
+ $this->cache_misses += 1;
+ return false;
+ }
+
+ $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".md5($id.DB_PASSWORD).'.php';
+ if (!file_exists($cache_file)) {
+ $this->non_existant_objects[$group][$id] = true;
+ $this->cache_misses += 1;
+ return false;
+ }
+
+ // If the object has expired, remove it from the cache and return false to force
+ // a refresh.
+ $now = time();
+ if ((filemtime($cache_file) + $this->expiration_time) <= $now) {
+ $this->cache_misses += 1;
+ $this->delete($id, $group, true);
+ return false;
+ }
+
+ $this->cache[$group][$id] = unserialize(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER)));
+ if (false === $this->cache[$group][$id])
+ $this->cache[$group][$id] = '';
+
+ $this->cold_cache_hits += 1;
+ return $this->cache[$group][$id];
+ }
+
+ function get_group_dir($group) {
+ if (false !== array_search($group, $this->global_groups))
+ return $group;
+
+ return "{$this->blog_id}/$group";
+ }
+
+ function load_group_from_db($group) {
+ global $wpdb;
+
+ if ('category' == $group) {
+ $this->cache['category'] = array ();
+ if ($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")) {
+ foreach ($dogs as $catt)
+ $this->cache['category'][$catt->cat_ID] = $catt;
+ }
+ } else
+ if ('options' == $group) {
+ $wpdb->hide_errors();
+ if (!$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'")) {
+ $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
+ }
+ $wpdb->show_errors();
+
+ if ( ! $options )
+ return;
+
+ foreach ($options as $option) {
+ $this->cache['options'][$option->option_name] = $option->option_value;
+ }
+ }
+ }
+
+ function make_group_dir($group, $perms) {
+ $group_dir = $this->get_group_dir($group);
+ $make_dir = '';
+ foreach (split('/', $group_dir) as $subdir) {
+ $make_dir .= "$subdir/";
+ if (!file_exists($this->cache_dir.$make_dir)) {
+ if (! @ mkdir($this->cache_dir.$make_dir))
+ break;
+ @ chmod($this->cache_dir.$make_dir, $perms);
+ }
+
+ if (!file_exists($this->cache_dir.$make_dir."index.php")) {
+ $file_perms = $perms & 0000666;
+ @ touch($this->cache_dir.$make_dir."index.php");
+ @ chmod($this->cache_dir.$make_dir."index.php", $file_perms);
+ }
+ }
+
+ return $this->cache_dir."$group_dir/";
+ }
+
+ function rm_cache_dir() {
+ $dir = $this->cache_dir;
+ $dir = rtrim($dir, DIRECTORY_SEPARATOR);
+ $top_dir = $dir;
+ $stack = array($dir);
+ $index = 0;
+
+ while ($index < count($stack)) {
+ # Get indexed directory from stack
+ $dir = $stack[$index];
+
+ $dh = @ opendir($dir);
+ if (!$dh)
+ return false;
+
+ while (($file = @ readdir($dh)) !== false) {
+ if ($file == '.' or $file == '..')
+ continue;
+
+ if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
+ $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
+ else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file))
+ @ unlink($dir . DIRECTORY_SEPARATOR . $file);
+ }
+
+ $index++;
+ }
+
+ $stack = array_reverse($stack); // Last added dirs are deepest
+ foreach($stack as $dir) {
+ if ( $dir != $top_dir)
+ @ rmdir($dir);
+ }
+
+ }
+
+ function release_lock() {
+ // Release write lock.
+ flock($this->mutex, LOCK_UN);
+ fclose($this->mutex);
+ }
+
+ function replace($id, $data, $group = 'default', $expire = '') {
+ if (empty ($group))
+ $group = 'default';
+
+ if (false === $this->get($id, $group, false))
+ return false;
+
+ return $this->set($id, $data, $group, $expire);
+ }
+
+ function set($id, $data, $group = 'default', $expire = '') {
+ if (empty ($group))
+ $group = 'default';
+
+ if (NULL == $data)
+ $data = '';
+
+ $this->cache[$group][$id] = $data;
+ unset ($this->non_existant_objects[$group][$id]);
+ $this->dirty_objects[$group][] = $id;
+
+ return true;
+ }
+
+ function save() {
+ //$this->stats();
+
+ if (!$this->cache_enabled)
+ return true;
+
+ if (empty ($this->dirty_objects))
+ return true;
+
+ // Give the new dirs the same perms as wp-content.
+ $stat = stat(ABSPATH.'wp-content');
+ $dir_perms = $stat['mode'] & 0007777; // Get the permission bits.
+ $file_perms = $dir_perms & 0000666; // Remove execute bits for files.
+
+ // Make the base cache dir.
+ if (!file_exists($this->cache_dir)) {
+ if (! @ mkdir($this->cache_dir))
+ return false;
+ @ chmod($this->cache_dir, $dir_perms);
+ }
+
+ if (!file_exists($this->cache_dir."index.php")) {
+ @ touch($this->cache_dir."index.php");
+ @ chmod($this->cache_dir."index.php", $file_perms);
+ }
+
+ if ( ! $this->acquire_lock() )
+ return false;
+
+ // Loop over dirty objects and save them.
+ $errors = 0;
+ foreach ($this->dirty_objects as $group => $ids) {
+ $group_dir = $this->make_group_dir($group, $dir_perms);
+
+ $ids = array_unique($ids);
+ foreach ($ids as $id) {
+ $cache_file = $group_dir.md5($id.DB_PASSWORD).'.php';
+
+ // Remove the cache file if the key is not set.
+ if (!isset ($this->cache[$group][$id])) {
+ if (file_exists($cache_file))
+ @ unlink($cache_file);
+ continue;
+ }
+
+ $temp_file = tempnam($group_dir, 'tmp');
+ $serial = CACHE_SERIAL_HEADER.serialize($this->cache[$group][$id]).CACHE_SERIAL_FOOTER;
+ $fd = @fopen($temp_file, 'w');
+ if ( false === $fd ) {
+ $errors++;
+ continue;
+ }
+ fputs($fd, $serial);
+ fclose($fd);
+ if (!@ rename($temp_file, $cache_file)) {
+ if (@ copy($temp_file, $cache_file))
+ @ unlink($temp_file);
+ else
+ $errors++;
+ }
+ @ chmod($cache_file, $file_perms);
+ }
+ }
+
+ $this->dirty_objects = array();
+
+ $this->release_lock();
+
+ if ( $errors )
+ return false;
+
+ return true;
+ }
+
+ function stats() {
+ echo "<p>";
+ echo "<strong>Cold Cache Hits:</strong> {$this->cold_cache_hits}<br/>";
+ echo "<strong>Warm Cache Hits:</strong> {$this->warm_cache_hits}<br/>";
+ echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br/>";
+ echo "</p>";
+
+ foreach ($this->cache as $group => $cache) {
+ echo "<p>";
+ echo "<strong>Group:</strong> $group<br/>";
+ echo "<strong>Cache:</strong>";
+ echo "<pre>";
+ print_r($cache);
+ echo "</pre>";
+ if (isset ($this->dirty_objects[$group])) {
+ echo "<strong>Dirty Objects:</strong>";
+ echo "<pre>";
+ print_r(array_unique($this->dirty_objects[$group]));
+ echo "</pre>";
+ echo "</p>";
+ }
+ }
+ }
+
+ function WP_Object_Cache() {
+ global $blog_id;
+
+ if (defined('DISABLE_CACHE'))
+ return;
+
+ if ( ! defined('ENABLE_CACHE') )
+ return;
+
+ // Disable the persistent cache if safe_mode is on.
+ if ( ini_get('safe_mode') && ! defined('ENABLE_CACHE') )
+ return;
+
+ if (defined('CACHE_PATH'))
+ $this->cache_dir = CACHE_PATH;
+ else
+ // Using the correct separator eliminates some cache flush errors on Windows
+ $this->cache_dir = ABSPATH.'wp-content'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;
+
+ if (is_writable($this->cache_dir) && is_dir($this->cache_dir)) {
+ $this->cache_enabled = true;
+ } else {
+ if (is_writable(ABSPATH.'wp-content')) {
+ $this->cache_enabled = true;
+ }
+ }
+
+ if (defined('CACHE_EXPIRATION_TIME'))
+ $this->expiration_time = CACHE_EXPIRATION_TIME;
+
+ $this->blog_id = md5($blog_id);
+ }
+}
+?>
diff --git a/wp-inst/wp-includes/capabilities.php b/wp-inst/wp-includes/capabilities.php
index 4c8905a..ea571cb 100644
--- a/wp-inst/wp-includes/capabilities.php
+++ b/wp-inst/wp-includes/capabilities.php
@@ -8,14 +8,20 @@ class WP_Roles {
var $role_key;
function WP_Roles() {
- global $table_prefix;
- $this->role_key = $table_prefix . 'user_roles';
+ $this->_init();
+ }
+
+ function _init () {
+ global $wpdb;
+ $this->role_key = $wpdb->prefix . 'user_roles';
$this->roles = get_option($this->role_key);
if ( empty($this->roles) )
return;
+ $this->role_objects = array();
+ $this->role_names = array();
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'];
@@ -121,7 +127,7 @@ class WP_User {
var $allcaps = array();
function WP_User($id, $name = '') {
- global $table_prefix;
+ global $wpdb;
if ( empty($id) && empty($name) )
return;
@@ -144,7 +150,12 @@ class WP_User {
}
$this->id = $this->ID;
- $this->cap_key = $table_prefix . 'capabilities';
+ $this->_init_caps();
+ }
+
+ function _init_caps() {
+ global $wpdb;
+ $this->cap_key = $wpdb->prefix . 'capabilities';
$this->caps = &$this->{$this->cap_key};
if ( ! is_array($this->caps) )
$this->caps = array();
@@ -186,7 +197,7 @@ class WP_User {
}
function set_role($role) {
- foreach($this->roles as $oldrole)
+ foreach($this->roles as $oldrole)
unset($this->caps[$oldrole]);
$this->caps[$role] = true;
$this->roles = array($role => true);
@@ -205,9 +216,9 @@ class WP_User {
}
function update_user_level_from_caps() {
- global $table_prefix;
+ global $wpdb;
$this->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0);
- update_usermeta($this->id, $table_prefix.'user_level', $this->user_level);
+ update_usermeta($this->id, $wpdb->prefix.'user_level', $this->user_level);
}
function add_cap($cap, $grant = true) {
@@ -221,6 +232,14 @@ class WP_User {
update_usermeta($this->id, $this->cap_key, $this->caps);
}
+ function remove_all_caps() {
+ global $wpdb;
+ $this->caps = array();
+ update_usermeta($this->id, $this->cap_key, '');
+ update_usermeta($this->id, $wpdb->prefix.'user_level', '');
+ $this->get_role_caps();
+ }
+
//has_cap(capability_or_role_name) or
//has_cap('edit_post', post_id)
function has_cap($cap) {
@@ -395,7 +414,7 @@ function map_meta_cap($cap, $user_id) {
// Capability checking wrapper around the global $current_user object.
function current_user_can($capability) {
- global $current_user;
+ $current_user = wp_get_current_user();
$args = array_slice(func_get_args(), 1);
$args = array_merge(array($capability), $args);
@@ -434,77 +453,4 @@ function remove_role($role) {
return $wp_roles->remove_role($role);
}
-//
-// These are deprecated. Use current_user_can().
-//
-
-/* returns true if $user_id can create a new post */
-function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
- $author_data = get_userdata($user_id);
- return ($author_data->user_level > 1);
-}
-
-/* returns true if $user_id can create a new post */
-function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
- $author_data = get_userdata($user_id);
- return ($author_data->user_level >= 1);
-}
-
-/* returns true if $user_id can edit $post_id */
-function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
- if ( function_exists('is_site_admin') && !is_site_admin() && function_exists('is_blog_user') && !is_blog_user() )
- return false;
-
- $author_data = get_userdata($user_id);
- $post = get_post($post_id);
- $post_author_data = get_userdata($post->post_author);
-
- if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2))
- || ($author_data->user_level > $post_author_data->user_level)
- || ($author_data->user_level >= 10) ) {
- return true;
- } else {
- return false;
- }
-}
-
-/* returns true if $user_id can delete $post_id */
-function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
- // right now if one can edit, one can delete
- return user_can_edit_post($user_id, $post_id, $blog_id);
-}
-
-/* returns true if $user_id can set new posts' dates on $blog_id */
-function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
- $author_data = get_userdata($user_id);
- return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
-}
-
-/* returns true if $user_id can edit $post_id's date */
-function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
- $author_data = get_userdata($user_id);
- return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
-}
-
-/* returns true if $user_id can edit $post_id's comments */
-function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
- // right now if one can edit a post, one can edit comments made on it
- return user_can_edit_post($user_id, $post_id, $blog_id);
-}
-
-/* returns true if $user_id can delete $post_id's comments */
-function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
- // right now if one can edit comments, one can delete comments
- return user_can_edit_post_comments($user_id, $post_id, $blog_id);
-}
-
-function user_can_edit_user($user_id, $other_user) {
- $user = get_userdata($user_id);
- $other = get_userdata($other_user);
- if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID )
- return true;
- else
- return false;
-}
-
?>
diff --git a/wp-inst/wp-includes/classes.php b/wp-inst/wp-includes/classes.php
index 03d74bb..3952cb5 100644
--- a/wp-inst/wp-includes/classes.php
+++ b/wp-inst/wp-includes/classes.php
@@ -1,769 +1,5 @@
<?php
-class WP_Query {
- var $query;
- var $query_vars;
- var $queried_object;
- var $queried_object_id;
- var $request;
-
- var $posts;
- var $post_count = 0;
- var $current_post = -1;
- var $in_the_loop = false;
- var $post;
-
- var $is_single = false;
- var $is_preview = 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;
- var $is_attachment = false;
-
- function init_query_flags() {
- $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;
- $this->is_attachment = false;
- }
-
- function init () {
- unset($this->posts);
- unset($this->query);
- unset($this->query_vars);
- unset($this->queried_object);
- unset($this->queried_object_id);
- $this->post_count = 0;
- $this->current_post = -1;
- $this->in_the_loop = false;
-
- $this->init_query_flags();
- }
-
- // Reparse the query vars.
- function parse_query_vars() {
- $this->parse_query('');
- }
-
- // Parse a query string and set query type booleans.
- function parse_query ($query) {
- if ( !empty($query) || !isset($this->query) ) {
- $this->init();
- parse_str($query, $qv);
- $this->query = $query;
- $this->query_vars = $qv;
- }
-
- if ('404' == $qv['error']) {
- $this->is_404 = true;
- if ( !empty($query) ) {
- do_action('parse_query', array(&$this));
- }
- return;
- }
-
- $qv['m'] = (int) $qv['m'];
- $qv['p'] = (int) $qv['p'];
-
- // Compat. Map subpost to attachment.
- if ( '' != $qv['subpost'] )
- $qv['attachment'] = $qv['subpost'];
- if ( '' != $qv['subpost_id'] )
- $qv['attachment_id'] = $qv['subpost_id'];
-
- if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) {
- $this->is_single = true;
- $this->is_attachment = true;
- } elseif ('' != $qv['name']) {
- $this->is_single = true;
- } elseif ( $qv['p'] ) {
- $this->is_single = true;
- } elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
- // If year, month, day, hour, minute, and second are set, a single
- // post is being queried.
- $this->is_single = true;
- } elseif ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) {
- $this->is_page = true;
- $this->is_single = false;
- } elseif (!empty($qv['s'])) {
- $this->is_search = true;
- } 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 ('' != $qv['paged']) {
- $this->is_paged = true;
- }
-
- if ('' != $qv['comments_popup']) {
- $this->is_comments_popup = true;
- }
-
- //if we're previewing inside the write screen
- if ('' != $qv['preview']) {
- $this->is_preview = true;
- }
-
- if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) {
- $this->is_admin = true;
- }
-
- if ( ! ($this->is_attachment || $this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) {
- $this->is_home = true;
- }
-
- if ( !empty($query) ) {
- do_action('parse_query', array(&$this));
- }
- }
-
- function set_404() {
- $this->init_query_flags();
- $this->is_404 = true;
- }
-
- function get($query_var) {
- if (isset($this->query_vars[$query_var])) {
- return $this->query_vars[$query_var];
- }
-
- return '';
- }
-
- function set($query_var, $value) {
- $this->query_vars[$query_var] = $value;
- }
-
- function &get_posts() {
- global $wpdb, $pagenow, $user_ID;
-
- do_action('pre_get_posts', array(&$this));
-
- // Shorthand.
- $q = &$this->query_vars;
-
- // First let's clear some variables
- $whichcat = '';
- $whichauthor = '';
- $whichpage = '';
- $result = '';
- $where = '';
- $limits = '';
- $distinct = '';
- $join = '';
-
- if ( !isset($q['post_type']) )
- $q['post_type'] = 'post';
- $post_type = $q['post_type'];
- if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 )
- $q['posts_per_page'] = get_settings('posts_per_page');
- if ( !isset($q['what_to_show']) )
- $q['what_to_show'] = get_settings('what_to_show');
- if ( isset($q['showposts']) && $q['showposts'] ) {
- $q['showposts'] = (int) $q['showposts'];
- $q['posts_per_page'] = $q['showposts'];
- }
- if ( (isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search) )
- $q['posts_per_page'] = $q['posts_per_archive_page'];
- if ( !isset($q['nopaging']) ) {
- if ($q['posts_per_page'] == -1) {
- $q['nopaging'] = true;
- } else {
- $q['nopaging'] = false;
- }
- }
- if ( $this->is_feed ) {
- $q['posts_per_page'] = get_settings('posts_per_rss');
- $q['what_to_show'] = 'posts';
- }
-
- if (isset($q['page'])) {
- $q['page'] = trim($q['page'], '/');
- $q['page'] = (int) $q['page'];
- }
-
- $add_hours = intval(get_settings('gmt_offset'));
- $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
- $wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
-
- // If a month is specified in the querystring, load that month
- if ( (int) $q['m'] ) {
- $q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']);
- $where .= ' AND YEAR(post_date)=' . substr($q['m'], 0, 4);
- if (strlen($q['m'])>5)
- $where .= ' AND MONTH(post_date)=' . substr($q['m'], 4, 2);
- if (strlen($q['m'])>7)
- $where .= ' AND DAYOFMONTH(post_date)=' . substr($q['m'], 6, 2);
- if (strlen($q['m'])>9)
- $where .= ' AND HOUR(post_date)=' . substr($q['m'], 8, 2);
- if (strlen($q['m'])>11)
- $where .= ' AND MINUTE(post_date)=' . substr($q['m'], 10, 2);
- if (strlen($q['m'])>13)
- $where .= ' AND SECOND(post_date)=' . substr($q['m'], 12, 2);
- }
-
- if ( (int) $q['hour'] ) {
- $q['hour'] = '' . intval($q['hour']);
- $where .= " AND HOUR(post_date)='" . $q['hour'] . "'";
- }
-
- if ( (int) $q['minute'] ) {
- $q['minute'] = '' . intval($q['minute']);
- $where .= " AND MINUTE(post_date)='" . $q['minute'] . "'";
- }
-
- if ( (int) $q['second'] ) {
- $q['second'] = '' . intval($q['second']);
- $where .= " AND SECOND(post_date)='" . $q['second'] . "'";
- }
-
- if ( (int) $q['year'] ) {
- $q['year'] = '' . intval($q['year']);
- $where .= " AND YEAR(post_date)='" . $q['year'] . "'";
- }
-
- if ( (int) $q['monthnum'] ) {
- $q['monthnum'] = '' . intval($q['monthnum']);
- $where .= " AND MONTH(post_date)='" . $q['monthnum'] . "'";
- }
-
- if ( (int) $q['day'] ) {
- $q['day'] = '' . intval($q['day']);
- $where .= " AND DAYOFMONTH(post_date)='" . $q['day'] . "'";
- }
-
- // Compat. Map subpost to attachment.
- if ( '' != $q['subpost'] )
- $q['attachment'] = $q['subpost'];
- if ( '' != $q['subpost_id'] )
- $q['attachment_id'] = $q['subpost_id'];
-
- if ('' != $q['name']) {
- $q['name'] = sanitize_title($q['name']);
- $where .= " AND post_name = '" . $q['name'] . "'";
- } else if ('' != $q['pagename']) {
- $reqpage = get_page_by_path($q['pagename']);
- $q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename'])));
- $page_paths = '/' . trim($q['pagename'], '/');
- $q['pagename'] = sanitize_title(basename($page_paths));
- $q['name'] = $q['pagename'];
-
- $where .= " AND (ID = '$reqpage')";
- } elseif ('' != $q['attachment']) {
- $q['attachment'] = str_replace('%2F', '/', urlencode(urldecode($q['attachment'])));
- $attach_paths = '/' . trim($q['attachment'], '/');
- $q['attachment'] = sanitize_title(basename($attach_paths));
- $q['name'] = $q['attachment'];
- $where .= " AND post_name = '" . $q['attachment'] . "'";
- }
-
- if ( (int) $q['w'] ) {
- $q['w'] = ''.intval($q['w']);
- $where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'";
- }
-
- if ( intval($q['comments_popup']) )
- $q['p'] = intval($q['comments_popup']);
-
- // If a attachment is requested by number, let it supercede any post number.
- if ( ($q['attachment_id'] != '') && (intval($q['attachment_id']) != 0) )
- $q['p'] = (int) $q['attachment_id'];
-
- // If a post number is specified, load that post
- if (($q['p'] != '') && intval($q['p']) != 0) {
- $q['p'] = (int) $q['p'];
- $where = ' AND ID = ' . $q['p'];
- }
-
- if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) {
- $q['page_id'] = intval($q['page_id']);
- $q['p'] = $q['page_id'];
- $where = ' AND ID = '.$q['page_id'];
- }
-
- // If a search pattern is specified, load the posts that match
- if (!empty($q['s'])) {
- $q['s'] = addslashes_gpc($q['s']);
- $search = ' AND (';
- $q['s'] = preg_replace('/, +/', ' ', $q['s']);
- $q['s'] = str_replace(',', ' ', $q['s']);
- $q['s'] = str_replace('"', ' ', $q['s']);
- $q['s'] = trim($q['s']);
- if ($q['exact']) {
- $n = '';
- } else {
- $n = '%';
- }
- if (!$q['sentence']) {
- $s_array = explode(' ',$q['s']);
- $q['search_terms'] = $s_array;
- $search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))';
- for ( $i = 1; $i < count($s_array); $i = $i + 1) {
- $search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))';
- }
- $search .= ' OR (post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\')';
- $search .= ')';
- } else {
- $search = ' AND ((post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\'))';
- }
- }
-
- // Category stuff
-
- if ((empty($q['cat'])) || ($q['cat'] == '0') ||
- // Bypass cat checks if fetching specific posts
- ( $this->is_single || $this->is_page )) {
- $whichcat='';
- } else {
- $q['cat'] = ''.urldecode($q['cat']).'';
- $q['cat'] = addslashes_gpc($q['cat']);
- if (stristr($q['cat'],'-')) {
- // Note: if we have a negative, we ignore all the positives. It must
- // always mean 'everything /except/ this one'. We should be able to do
- // multiple negatives but we don't :-(
- $eq = '!=';
- $andor = 'AND';
- $q['cat'] = explode('-',$q['cat']);
- $q['cat'] = intval($q['cat'][1]);
- } else {
- $eq = '=';
- $andor = 'OR';
- }
- $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
- $cat_array = preg_split('/[,\s]+/', $q['cat']);
- $whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]);
- $whichcat .= get_category_children($cat_array[0], ' '.$andor.' category_id '.$eq.' ');
- for ($i = 1; $i < (count($cat_array)); $i = $i + 1) {
- $whichcat .= ' '.$andor.' category_id '.$eq.' '.intval($cat_array[$i]);
- $whichcat .= get_category_children($cat_array[$i], ' '.$andor.' category_id '.$eq.' ');
- }
- $whichcat .= ')';
- if ($eq == '!=') {
- $q['cat'] = '-'.$q['cat']; // Put back the knowledge that we are excluding a category.
- }
- }
-
- // Category stuff for nice URIs
-
- global $cache_categories;
- if ('' != $q['category_name']) {
- $cat_paths = '/' . trim(urldecode($q['category_name']), '/');
- $q['category_name'] = sanitize_title(basename($cat_paths));
- $cat_paths = explode('/', $cat_paths);
- foreach($cat_paths as $pathdir)
- $cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
-
- $all_cat_ids = get_all_category_ids();
- $q['cat'] = 0; $partial_match = 0;
- foreach ( $all_cat_ids as $cat_id ) {
- $cat = get_category($cat_id);
- if ( $cat->fullpath == $cat_path ) {
- $q['cat'] = $cat_id;
- break;
- } elseif ( $cat->category_nicename == $q['category_name'] ) {
- $partial_match = $cat_id;
- }
- }
-
- //if we don't match the entire hierarchy fallback on just matching the nicename
- if (!$q['cat'] && $partial_match) {
- $q['cat'] = $partial_match;
- }
-
- $tables = ", $wpdb->post2cat, $wpdb->categories";
- $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
- $whichcat = " AND (category_id = '" . $q['cat'] . "'";
- $whichcat .= get_category_children($q['cat'], " OR category_id = ");
- $whichcat .= ")";
- }
-
- // Author/user stuff
-
- if ((empty($q['author'])) || ($q['author'] == '0')) {
- $whichauthor='';
- } else {
- $q['author'] = ''.urldecode($q['author']).'';
- $q['author'] = addslashes_gpc($q['author']);
- if (stristr($q['author'], '-')) {
- $eq = '!=';
- $andor = 'AND';
- $q['author'] = explode('-', $q['author']);
- $q['author'] = ''.intval($q['author'][1]);
- } else {
- $eq = '=';
- $andor = 'OR';
- }
- $author_array = preg_split('/[,\s]+/', $q['author']);
- $whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);
- for ($i = 1; $i < (count($author_array)); $i = $i + 1) {
- $whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]);
- }
- $whichauthor .= ')';
- }
-
- // Author stuff for nice URIs
-
- if ('' != $q['author_name']) {
- if (stristr($q['author_name'],'/')) {
- $q['author_name'] = explode('/',$q['author_name']);
- if ($q['author_name'][count($q['author_name'])-1]) {
- $q['author_name'] = $q['author_name'][count($q['author_name'])-1];#no trailing slash
- } else {
- $q['author_name'] = $q['author_name'][count($q['author_name'])-2];#there was a trailling slash
- }
- }
- $q['author_name'] = sanitize_title($q['author_name']);
- $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'");
- $whichauthor .= ' AND (post_author = '.intval($q['author']).')';
- }
-
- $where .= $search.$whichcat.$whichauthor;
-
- if ((empty($q['order'])) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC'))) {
- $q['order']='DESC';
- }
-
- // Order by
- if (empty($q['orderby'])) {
- $q['orderby'] = 'post_date '.$q['order'];
- } else {
- // Used to filter values
- $allowed_keys = array('author', 'date', 'category', 'title', 'modified', 'menu_order');
- $q['orderby'] = urldecode($q['orderby']);
- $q['orderby'] = addslashes_gpc($q['orderby']);
- $orderby_array = explode(' ',$q['orderby']);
- if ( empty($orderby_array) )
- $orderby_array[] = $q['orderby'];
- $q['orderby'] = '';
- for ($i = 0; $i < count($orderby_array); $i++) {
- // Only allow certain values for safety
- $orderby = $orderby_array[$i];
- if ( 'menu_order' != $orderby )
- $orderby = 'post_' . $orderby;
- if ( in_array($orderby_array[$i], $allowed_keys) )
- $q['orderby'] .= (($i == 0) ? '' : ',') . "$orderby {$q['order']}";
- }
- if ( empty($q['orderby']) )
- $q['orderby'] = 'post_date '.$q['order'];
- }
-
- //$now = gmdate('Y-m-d H:i:59');
-
- //only select past-dated posts, except if a logged in user is viewing a single: then, if they
- //can edit the post, we let them through
- //if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) {
- // $where .= " AND post_date_gmt <= '$now'";
- // $distinct = 'DISTINCT';
- //}
-
- if ( $this->is_attachment ) {
- $where .= ' AND (post_type = "attachment")';
- } elseif ($this->is_page) {
- $where .= ' AND (post_type = "page")';
- } elseif ($this->is_single) {
- $where .= ' AND (post_type = "post")';
- } else {
- $where .= " AND (post_type = '$post_type' AND (post_status = 'publish'";
-
- if ( is_admin() )
- $where .= " OR post_status = 'future' OR post_status = 'draft'";
- else
- $distinct = 'DISTINCT';
-
- if ( is_user_logged_in() )
- $where .= " OR post_author = $user_ID AND post_status = 'private'))";
- 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);
- $groupby = " $wpdb->posts.ID ";
- $groupby = apply_filters('posts_groupby', $groupby);
- $join = apply_filters('posts_join_paged', $join);
- $orderby = apply_filters('posts_orderby', $q['orderby']);
- $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1" . $where . " GROUP BY " . $groupby . " ORDER BY " . $orderby . " $limits";
- $this->request = apply_filters('posts_request', $request);
-
- $this->posts = $wpdb->get_results($this->request);
-
- // Check post status to determine if post should be displayed.
- if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) {
- $status = get_post_status($this->posts[0]);
- //$type = get_post_type($this->posts[0]);
- if ( ('publish' != $status) ) {
- if ( ! is_user_logged_in() ) {
- // User must be logged in to view unpublished posts.
- $this->posts = array();
- } else {
- if ('draft' == $status) {
- // User must have edit permissions on the draft to preview.
- if (! current_user_can('edit_post', $this->posts[0]->ID)) {
- $this->posts = array();
- } else {
- $this->is_preview = true;
- $this->posts[0]->post_date = current_time('mysql');
- }
- } else if ('future' == $status) {
- $this->is_preview = true;
- if (!current_user_can('edit_post', $this->posts[0]->ID)) {
- $this->posts = array ( );
- }
- } else {
- if (! current_user_can('read_post', $this->posts[0]->ID))
- $this->posts = array();
- }
- }
- }
- }
-
- update_post_caches($this->posts);
-
- $this->posts = apply_filters('the_posts', $this->posts);
- $this->post_count = count($this->posts);
- if ($this->post_count > 0) {
- $this->post = $this->posts[0];
- }
-
- return $this->posts;
- }
-
- function next_post() {
-
- $this->current_post++;
-
- $this->post = $this->posts[$this->current_post];
- return $this->post;
- }
-
- function the_post() {
- global $post;
- $this->in_the_loop = true;
- $post = $this->next_post();
- setup_postdata($post);
-
- if ( $this->current_post == 0 ) // loop has just started
- do_action('loop_start');
- }
-
- function have_posts() {
- if ($this->current_post + 1 < $this->post_count) {
- return true;
- } elseif ($this->current_post + 1 == $this->post_count) {
- do_action('loop_end');
- // Do some cleaning up after the loop
- $this->rewind_posts();
- }
-
- $this->in_the_loop = false;
- return false;
- }
-
- function rewind_posts() {
- $this->current_post = -1;
- if ($this->post_count > 0) {
- $this->post = $this->posts[0];
- }
- }
-
- function &query($query) {
- $this->parse_query($query);
- return $this->get_posts();
- }
-
- function get_queried_object() {
- if (isset($this->queried_object)) {
- return $this->queried_object;
- }
-
- $this->queried_object = NULL;
- $this->queried_object_id = 0;
-
- if ($this->is_category) {
- $cat = $this->get('cat');
- $category = &get_category($cat);
- $this->queried_object = &$category;
- $this->queried_object_id = $cat;
- } else if ($this->is_single) {
- $this->queried_object = $this->post;
- $this->queried_object_id = $this->post->ID;
- } else if ($this->is_page) {
- $this->queried_object = $this->post;
- $this->queried_object_id = $this->post->ID;
- } else if ($this->is_author) {
- $author_id = $this->get('author');
- $author = get_userdata($author_id);
- $this->queried_object = $author;
- $this->queried_object_id = $author_id;
- }
-
- return $this->queried_object;
- }
-
- function get_queried_object_id() {
- $this->get_queried_object();
-
- if (isset($this->queried_object_id)) {
- return $this->queried_object_id;
- }
-
- return 0;
- }
-
- function WP_Query ($query = '') {
- if (! empty($query)) {
- $this->query($query);
- }
- }
-}
-
class retrospam_mgr {
var $spam_words;
var $comments_list;
@@ -804,7 +40,7 @@ class retrospam_mgr {
if ( empty( $word ) )
continue;
$fulltext = strtolower($comment->email.' '.$comment->url.' '.$comment->ip.' '.$comment->text);
- if( strpos( $fulltext, strtolower($word) ) != FALSE ) {
+ if( false !== strpos( $fulltext, strtolower($word) ) ) {
$this->found_comments[] = $comment->ID;
break;
}
@@ -836,606 +72,6 @@ class retrospam_mgr {
}
-class WP_Rewrite {
- var $permalink_structure;
- var $category_base;
- var $category_structure;
- var $author_base = 'author';
- var $author_structure;
- var $date_structure;
- var $page_structure;
- var $search_base = 'search';
- var $search_structure;
- var $comments_base = 'comments';
- var $feed_base = 'feed';
- var $comments_feed_structure;
- var $feed_structure;
- var $front;
- var $root = '';
- var $index = 'index.php';
- var $matches = '';
- var $rules;
- var $use_verbose_rules = false;
- var $rewritecode =
- array(
- '%year%',
- '%monthnum%',
- '%day%',
- '%hour%',
- '%minute%',
- '%second%',
- '%postname%',
- '%post_id%',
- '%category%',
- '%author%',
- '%pagename%',
- '%search%'
- );
-
- var $rewritereplace =
- array(
- '([0-9]{4})',
- '([0-9]{1,2})',
- '([0-9]{1,2})',
- '([0-9]{1,2})',
- '([0-9]{1,2})',
- '([0-9]{1,2})',
- '([^/]+)',
- '([0-9]+)',
- '(.+?)',
- '([^/]+)',
- '([^/]+)',
- '(.+)'
- );
-
- var $queryreplace =
- array (
- 'year=',
- 'monthnum=',
- 'day=',
- 'hour=',
- 'minute=',
- 'second=',
- 'name=',
- 'p=',
- 'category_name=',
- 'author_name=',
- 'pagename=',
- 's='
- );
-
- var $feeds = array ('feed', 'rdf', 'rss', 'rss2', 'atom');
-
- function using_permalinks() {
- if (empty($this->permalink_structure))
- return false;
- else
- return true;
- }
-
- function using_index_permalinks() {
- if (empty($this->permalink_structure)) {
- return false;
- }
-
- // If the index is not in the permalink, we're using mod_rewrite.
- if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
- return true;
- }
-
- return false;
- }
-
- function using_mod_rewrite_permalinks() {
- if ( $this->using_permalinks() && ! $this->using_index_permalinks())
- return true;
- else
- return false;
- }
-
- function preg_index($number) {
- $match_prefix = '$';
- $match_suffix = '';
-
- if (! empty($this->matches)) {
- $match_prefix = '$' . $this->matches . '[';
- $match_suffix = ']';
- }
-
- return "$match_prefix$number$match_suffix";
- }
-
- function page_rewrite_rules() {
- $uris = get_settings('page_uris');
- $attachment_uris = get_settings('page_attachment_uris');
-
- $rewrite_rules = array();
- $page_structure = $this->get_page_permastruct();
- if( is_array( $attachment_uris ) ) {
- foreach ($attachment_uris as $uri => $pagename) {
- $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
- $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure));
- }
- }
- if( is_array( $uris ) ) {
- foreach ($uris as $uri => $pagename) {
- $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
- $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure));
- }
- }
-
- return $rewrite_rules;
- }
-
- function get_date_permastruct() {
- if (isset($this->date_structure)) {
- return $this->date_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->date_structure = '';
- return false;
- }
-
- // The date permalink must have year, month, and day separated by slashes.
- $endians = array('%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%');
-
- $this->date_structure = '';
- $date_endian = '';
-
- foreach ($endians as $endian) {
- if (false !== strpos($this->permalink_structure, $endian)) {
- $date_endian= $endian;
- break;
- }
- }
-
- if ( empty($date_endian) )
- $date_endian = '%year%/%monthnum%/%day%';
-
- // Do not allow the date tags and %post_id% to overlap in the permalink
- // structure. If they do, move the date tags to $front/date/.
- $front = $this->front;
- preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
- $tok_index = 1;
- foreach ($tokens[0] as $token) {
- if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
- $front = $front . 'date/';
- break;
- }
- }
-
- $this->date_structure = $front . $date_endian;
-
- return $this->date_structure;
- }
-
- function get_year_permastruct() {
- $structure = $this->get_date_permastruct($this->permalink_structure);
-
- if (empty($structure)) {
- return false;
- }
-
- $structure = str_replace('%monthnum%', '', $structure);
- $structure = str_replace('%day%', '', $structure);
-
- $structure = preg_replace('#/+#', '/', $structure);
-
- return $structure;
- }
-
- function get_month_permastruct() {
- $structure = $this->get_date_permastruct($this->permalink_structure);
-
- if (empty($structure)) {
- return false;
- }
-
- $structure = str_replace('%day%', '', $structure);
-
- $structure = preg_replace('#/+#', '/', $structure);
-
- return $structure;
- }
-
- function get_day_permastruct() {
- return $this->get_date_permastruct($this->permalink_structure);
- }
-
- function get_category_permastruct() {
- if (isset($this->category_structure)) {
- return $this->category_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->category_structure = '';
- return false;
- }
-
- if (empty($this->category_base))
- $this->category_structure = $this->front . 'tag/';
- else
- $this->category_structure = $this->category_base . '/';
-
- $this->category_structure .= '%category%';
-
- return $this->category_structure;
- }
-
- function get_author_permastruct() {
- if (isset($this->author_structure)) {
- return $this->author_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->author_structure = '';
- return false;
- }
-
- $this->author_structure = $this->front . $this->author_base . '/%author%';
-
- return $this->author_structure;
- }
-
- function get_search_permastruct() {
- if (isset($this->search_structure)) {
- return $this->search_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->search_structure = '';
- return false;
- }
-
- $this->search_structure = $this->root . $this->search_base . '/%search%';
-
- return $this->search_structure;
- }
-
- function get_page_permastruct() {
- if (isset($this->page_structure)) {
- return $this->page_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->page_structure = '';
- return false;
- }
-
- $this->page_structure = $this->root . '%pagename%';
-
- return $this->page_structure;
- }
-
- function get_feed_permastruct() {
- if (isset($this->feed_structure)) {
- return $this->feed_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->feed_structure = '';
- return false;
- }
-
- $this->feed_structure = $this->root . $this->feed_base . '/%feed%';
-
- return $this->feed_structure;
- }
-
- function get_comment_feed_permastruct() {
- if (isset($this->comment_feed_structure)) {
- return $this->comment_feed_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->comment_feed_structure = '';
- return false;
- }
-
- $this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%';
-
- return $this->comment_feed_structure;
- }
-
- function add_rewrite_tag($tag, $pattern, $query) {
- // If the tag already exists, replace the existing pattern and query for
- // that tag, otherwise add the new tag, pattern, and query to the end of
- // the arrays.
- $position = array_search($tag, $this->rewritecode);
- if (FALSE !== $position && NULL !== $position) {
- $this->rewritereplace[$position] = $pattern;
- $this->queryreplace[$position] = $query;
- } else {
- $this->rewritecode[] = $tag;
- $this->rewritereplace[] = $pattern;
- $this->queryreplace[] = $query;
- }
- }
-
- function generate_rewrite_rules($permalink_structure, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true) {
- $feedregex2 = '';
- foreach ($this->feeds as $feed_name) {
- $feedregex2 .= $feed_name . '|';
- }
- $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$';
- $feedregex = $this->feed_base . '/' . $feedregex2;
-
- $trackbackregex = 'trackback/?$';
- $pageregex = 'page/?([0-9]{1,})/?$';
-
- $front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
- preg_match_all('/%.+?%/', $permalink_structure, $tokens);
-
- $num_tokens = count($tokens[0]);
-
- $index = $this->index;
- $feedindex = $index;
- $trackbackindex = $index;
- for ($i = 0; $i < $num_tokens; ++$i) {
- if (0 < $i) {
- $queries[$i] = $queries[$i - 1] . '&';
- }
-
- $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1);
- $queries[$i] .= $query_token;
- }
-
- $structure = $permalink_structure;
- if ($front != '/') {
- $structure = str_replace($front, '', $structure);
- }
- $structure = trim($structure, '/');
- if ($walk_dirs) {
- $dirs = explode('/', $structure);
- } else {
- $dirs[] = $structure;
- }
- $num_dirs = count($dirs);
-
- $front = preg_replace('|^/+|', '', $front);
-
- $post_rewrite = array();
- $struct = $front;
- for ($j = 0; $j < $num_dirs; ++$j) {
- $struct .= $dirs[$j] . '/';
- $struct = ltrim($struct, '/');
- $match = str_replace($this->rewritecode, $this->rewritereplace, $struct);
- $num_toks = preg_match_all('/%.+?%/', $struct, $toks);
- $query = $queries[$num_toks - 1];
-
- $pagematch = $match . $pageregex;
- $pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1);
-
- $feedmatch = $match . $feedregex;
- $feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
-
- $feedmatch2 = $match . $feedregex2;
- $feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
-
- if ($forcomments) {
- $feedquery .= '&withcomments=1';
- $feedquery2 .= '&withcomments=1';
- }
-
- $rewrite = array();
- if ($feed)
- $rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
- if ($paged)
- $rewrite = array_merge($rewrite, array($pagematch => $pagequery));
-
- if ($num_toks) {
- $post = false;
- $page = false;
- if (strstr($struct, '%postname%') || strstr($struct, '%post_id%')
- || strstr($struct, '%pagename%')
- || (strstr($struct, '%year%') && strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) {
- $post = true;
- if ( strstr($struct, '%pagename%') )
- $page = true;
- $trackbackmatch = $match . $trackbackregex;
- $trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
- $match = rtrim($match, '/');
- $submatchbase = str_replace(array('(',')'),'',$match);
- $sub1 = $submatchbase . '/([^/]+)/';
- $sub1tb = $sub1 . $trackbackregex;
- $sub1feed = $sub1 . $feedregex;
- $sub1feed2 = $sub1 . $feedregex2;
- $sub1 .= '?$';
- $sub2 = $submatchbase . '/attachment/([^/]+)/';
- $sub2tb = $sub2 . $trackbackregex;
- $sub2feed = $sub2 . $feedregex;
- $sub2feed2 = $sub2 . $feedregex2;
- $sub2 .= '?$';
- $subquery = $index . '?attachment=' . $this->preg_index(1);
- $subtbquery = $subquery . '&tb=1';
- $subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
- $match = $match . '(/[0-9]+)?/?$';
- $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
- } else {
- $match .= '?$';
- $query = $index . '?' . $query;
- }
-
- $rewrite = array_merge($rewrite, array($match => $query));
-
- if ($post) {
- $rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite);
- if ( ! $page )
- $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery));
- $rewrite = array_merge($rewrite, array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery));
- }
- }
- $post_rewrite = array_merge($rewrite, $post_rewrite);
- }
- return $post_rewrite;
- }
-
- function generate_rewrite_rule($permalink_structure, $walk_dirs = false) {
- return $this->generate_rewrite_rules($permalink_structure, false, false, false, $walk_dirs);
- }
-
- /* rewrite_rules
- * Construct rewrite matches and queries from permalink structure.
- * Returns an associate array of matches and queries.
- */
- function rewrite_rules() {
- $rewrite = array();
-
- if (empty($this->permalink_structure)) {
- return $rewrite;
- }
-
- // Post
- $post_rewrite = $this->generate_rewrite_rules($this->permalink_structure);
- $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
-
- // Date
- $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct());
- $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
-
- // Root
- $root_rewrite = $this->generate_rewrite_rules($this->root . '/');
- $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
-
- // Comments
- $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, true, true, true, false);
- $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
-
- // Search
- $search_structure = $this->get_search_permastruct();
- $search_rewrite = $this->generate_rewrite_rules($search_structure);
- $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
-
- // Categories
- $category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct());
- $category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite);
-
- // Authors
- $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct());
- $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
-
- // Pages
- $page_rewrite = $this->page_rewrite_rules();
- $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
-
- // Put them together.
- $this->rules = array_merge($page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite);
-
- do_action('generate_rewrite_rules', array(&$this));
- $this->rules = apply_filters('rewrite_rules_array', $this->rules);
-
- return $this->rules;
- }
-
- function wp_rewrite_rules() {
- $this->rules = get_option('rewrite_rules');
- if ( empty($this->rules) ) {
- $this->matches = 'matches';
- $this->rewrite_rules();
- update_option('rewrite_rules', $this->rules);
- }
-
- return $this->rules;
- }
-
- function mod_rewrite_rules() {
- if ( ! $this->using_permalinks()) {
- return '';
- }
-
- $site_root = parse_url(get_settings('siteurl'));
- $site_root = trailingslashit($site_root['path']);
-
- $home_root = parse_url(get_settings('home'));
- $home_root = trailingslashit($home_root['path']);
-
- $rules = "<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} [L]\n";
- }
-
- $rules .= "</IfModule>\n";
-
- $rules = apply_filters('mod_rewrite_rules', $rules);
- $rules = apply_filters('rewrite_rules', $rules); // Deprecated
-
- return $rules;
- }
-
- function flush_rules() {
- generate_page_uri_index();
- delete_option('rewrite_rules');
- $this->wp_rewrite_rules();
- if ( function_exists('save_mod_rewrite_rules') )
- save_mod_rewrite_rules();
- }
-
- function init() {
- $this->permalink_structure = get_settings('permalink_structure');
- $this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));
- $this->root = '';
- if ($this->using_index_permalinks()) {
- $this->root = $this->index . '/';
- }
- $this->category_base = get_settings('category_base');
- unset($this->category_structure);
- unset($this->author_structure);
- unset($this->date_structure);
- unset($this->page_structure);
- unset($this->search_structure);
- unset($this->feed_structure);
- unset($this->comment_feed_structure);
- }
-
- function set_permalink_structure($permalink_structure) {
- if ($permalink_structure != $this->permalink_structure) {
- update_option('permalink_structure', $permalink_structure);
- $this->init();
- }
- }
-
- function set_category_base($category_base) {
- if ($category_base != $this->category_base) {
- update_option('category_base', $category_base);
- $this->init();
- }
- }
-
- function WP_Rewrite() {
- $this->init();
- }
-}
-
class WP {
var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview');
@@ -1448,6 +84,10 @@ class WP {
var $matched_rule;
var $matched_query;
var $did_permalink = false;
+
+ function add_query_var($qv) {
+ $this->public_query_vars[] = $qv;
+ }
function parse_request($extra_query_vars = '') {
global $wp_rewrite;
@@ -1520,7 +160,7 @@ class WP {
preg_match("!^$match!", urldecode($request_match), $matches)) {
// Got a match.
$this->matched_rule = $match;
-
+
// Trim the query of everything up to the '?'.
$query = preg_replace("!^.+\?!", '', $query);
@@ -1605,7 +245,8 @@ class WP {
@header("ETag: $wp_etag");
// Support for Conditional GET
- if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
+ if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
+ $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
else $client_etag = false;
$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']);
@@ -1663,7 +304,7 @@ class WP {
}
function init() {
- get_currentuserinfo();
+ wp_get_current_user();
}
function query_posts() {
@@ -1699,4 +340,343 @@ class WP {
}
}
+class WP_Error {
+ var $errors = array();
+
+ function WP_Error($code = '', $message = '') {
+ if ( ! empty($code) )
+ $this->errors[$code][] = $message;
+ }
+
+ function get_error_codes() {
+ if ( empty($this->errors) )
+ return array();
+
+ return array_keys($this->errors);
+ }
+
+ function get_error_code() {
+ $codes = $this->get_error_codes();
+
+ if ( empty($codes) )
+ return '';
+
+ return $codes[0];
+ }
+
+ function get_error_messages($code = '') {
+ // Return all messages if no code specified.
+ if ( empty($code) ) {
+ $all_messages = array();
+ foreach ( $this->errors as $code => $messages )
+ $all_messages = array_merge($all_messages, $messages);
+
+ return $all_messages;
+ }
+
+ if ( isset($this->errors[$code]) )
+ return $this->errors[$code];
+ else
+ return array();
+ }
+
+ function get_error_message($code = '') {
+ if ( empty($code) )
+ $code = $this->get_error_code();
+ $messages = $this->get_error_messages($code);
+ if ( empty($messages) )
+ return '';
+ return $messages[0];
+ }
+
+ function add($code, $message) {
+ $this->errors[$code][] = $message;
+ }
+}
+
+function is_wp_error($thing) {
+ if ( is_object($thing) && is_a($thing, 'WP_Error') )
+ return true;
+ return false;
+}
+
+
+// A class for displaying various tree-like structures. Extend the Walker class to use it, see examples at the bottom
+
+class Walker {
+ var $tree_type;
+ var $db_fields;
+
+ //abstract callbacks
+ function start_lvl($output) { return $output; }
+ function end_lvl($output) { return $output; }
+ function start_el($output) { return $output; }
+ function end_el($output) { return $output; }
+
+ function walk($elements, $to_depth) {
+ $args = array_slice(func_get_args(), 2); $parents = array(); $depth = 1; $previous_element = ''; $output = '';
+
+ //padding at the end
+ $last_element->post_parent = 0;
+ $last_element->post_id = 0;
+ $elements[] = $last_element;
+
+ $id_field = $this->db_fields['id'];
+ $parent_field = $this->db_fields['parent'];
+
+ $flat = ($to_depth == -1) ? true : false;
+
+ foreach ( $elements as $element ) {
+ // If flat, start and end the element and skip the level checks.
+ if ( $flat) {
+ // Start the element.
+ if ( $element->$id_field != 0 ) {
+ $cb_args = array_merge( array($output, $element, $depth - 1), $args);
+ $output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
+ }
+
+ // End the element.
+ if ( $element->$id_field != 0 ) {
+ $cb_args = array_merge( array($output, $element, $depth - 1), $args);
+ $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
+ }
+
+ continue;
+ }
+
+ // Walk the tree.
+ if ( !empty($previous_element) && ($element->$parent_field == $previous_element->$id_field) ) {
+ // Previous element is my parent. Descend a level.
+ array_unshift($parents, $previous_element);
+ $depth++; //always do this so when we start the element further down, we know where we are
+ if ( !$to_depth || ($depth < $to_depth) ) { //only descend if we're below $to_depth
+ $cb_args = array_merge( array($output, $depth - 1), $args);
+ $output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
+ }
+ } else if ( $element->$parent_field == $previous_element->$parent_field) {
+ // On the same level as previous element.
+ if ( !$to_depth || ($depth <= $to_depth) ) {
+ $cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
+ $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
+ }
+ } else if ( $depth > 1 ) {
+ // Ascend one or more levels.
+ if ( !$to_depth || ($depth <= $to_depth) ) {
+ $cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
+ $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
+ }
+
+ while ( $parent = array_shift($parents) ) {
+ $depth--;
+ if ( !$to_depth || ($depth < $to_depth) ) {
+ $cb_args = array_merge( array($output, $depth - 1), $args);
+ $output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
+ $cb_args = array_merge( array($output, $parent, $depth - 1), $args);
+ $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
+ }
+ if ( $element->$parent_field == $parents[0]->$id_field ) {
+ break;
+ }
+ }
+ } else if ( !empty($previous_element) ) {
+ // Close off previous element.
+ if ( !$to_depth || ($depth <= $to_depth) ) {
+ $cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
+ $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
+ }
+ }
+
+ // Start the element.
+ if ( !$to_depth || ($depth <= $to_depth) ) {
+ if ( $element->$id_field != 0 ) {
+ $cb_args = array_merge( array($output, $element, $depth - 1), $args);
+ $output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
+ }
+ }
+
+ $previous_element = $element;
+ }
+
+ return $output;
+ }
+}
+
+class Walker_Page extends Walker {
+ var $tree_type = 'page';
+ var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
+
+ function start_lvl($output, $depth) {
+ $indent = str_repeat("\t", $depth);
+ $output .= "$indent<ul>\n";
+ return $output;
+ }
+
+ function end_lvl($output, $depth) {
+ $indent = str_repeat("\t", $depth);
+ $output .= "$indent</ul>\n";
+ return $output;
+ }
+
+ function start_el($output, $page, $depth, $current_page, $show_date, $date_format) {
+ if ( $depth )
+ $indent = str_repeat("\t", $depth);
+
+ $css_class = 'page_item';
+ if ( $page->ID == $current_page )
+ $css_class .= ' current_page_item';
+
+ $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . wp_specialchars($page->post_title) . '">' . $page->post_title . '</a>';
+
+ if ( !empty($show_date) ) {
+ if ( 'modified' == $show_date )
+ $time = $page->post_modified;
+ else
+ $time = $page->post_date;
+
+ $output .= " " . mysql2date($date_format, $time);
+ }
+
+ return $output;
+ }
+
+ function end_el($output, $page, $depth) {
+ $output .= "</li>\n";
+
+ return $output;
+ }
+
+}
+
+class Walker_PageDropdown extends Walker {
+ var $tree_type = 'page';
+ var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
+
+ function start_el($output, $page, $depth, $args) {
+ $pad = str_repeat('&nbsp;', $depth * 3);
+
+ $output .= "\t<option value=\"$page->ID\"";
+ if ( $page->ID == $args['selected'] )
+ $output .= ' selected="selected"';
+ $output .= '>';
+ $title = wp_specialchars($page->post_title);
+ $output .= "$pad$title";
+ $output .= "</option>\n";
+
+ return $output;
+ }
+}
+
+class Walker_Category extends Walker {
+ var $tree_type = 'category';
+ var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this
+
+ function start_lvl($output, $depth, $args) {
+ if ( 'list' != $args['style'] )
+ return $output;
+
+ $indent = str_repeat("\t", $depth);
+ $output .= "$indent<ul class='children'>\n";
+ return $output;
+ }
+
+ function end_lvl($output, $depth, $args) {
+ if ( 'list' != $args['style'] )
+ return $output;
+
+ $indent = str_repeat("\t", $depth);
+ $output .= "$indent</ul>\n";
+ return $output;
+ }
+
+ function start_el($output, $category, $depth, $args) {
+ extract($args);
+
+ $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 ( $show_count )
+ $link .= ' ('.intval($category->category_count).')';
+
+ if ( $show_date ) {
+ $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
+ }
+
+ if ( 'list' == $args['style'] ) {
+ $output .= "\t<li";
+ if ( ($category->cat_ID == $current_category) && is_category() )
+ $output .= ' class="current-cat"';
+ $output .= ">$link\n";
+ } else {
+ $output .= "\t$link<br />\n";
+ }
+
+ return $output;
+ }
+
+ function end_el($output, $page, $depth, $args) {
+ if ( 'list' != $args['style'] )
+ return $output;
+
+ $output .= "</li>\n";
+ return $output;
+ }
+
+}
+
+class Walker_CategoryDropdown extends Walker {
+ var $tree_type = 'category';
+ var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this
+
+ function start_el($output, $category, $depth, $args) {
+ $pad = str_repeat('&nbsp;', $depth * 3);
+
+ $cat_name = apply_filters('list_cats', $category->cat_name, $category);
+ $output .= "\t<option value=\"".$category->cat_ID."\"";
+ if ( $category->cat_ID == $args['selected'] )
+ $output .= ' selected="selected"';
+ $output .= '>';
+ $output .= $cat_name;
+ if ( $args['show_count'] )
+ $output .= '&nbsp;&nbsp;('. $category->category_count .')';
+ if ( $args['show_last_update'] ) {
+ $format = 'Y-m-d';
+ $output .= '&nbsp;&nbsp;' . gmdate($format, $category->last_update_timestamp);
+ }
+ $output .= "</option>\n";
+
+ return $output;
+ }
+}
+
?>
diff --git a/wp-inst/wp-includes/comment-template.php b/wp-inst/wp-includes/comment-template.php
new file mode 100644
index 0000000..1ed1dd6
--- /dev/null
+++ b/wp-inst/wp-includes/comment-template.php
@@ -0,0 +1,374 @@
+<?php
+/*
+ * Comment template functions.
+ */
+
+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 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_link() {
+ global $comment;
+ $url = get_comment_author_url();
+ $author = get_comment_author();
+
+ if ( empty( $url ) || 'http://' == $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_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_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 get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
+ global $comment;
+ $url = get_comment_author_url();
+ $display = ($linktext != '') ? $linktext : $url;
+ $display = str_replace( 'http://www.', '', $display );
+ $display = str_replace( 'http://', '', $display );
+ if ( '/' == substr($display, -1) )
+ $display = substr($display, 0, -1);
+ $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_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_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_ID() {
+ global $comment;
+ return apply_filters('get_comment_ID', $comment->comment_ID);
+}
+
+function comment_ID() {
+ echo get_comment_ID();
+}
+
+function get_comment_link() {
+ global $comment;
+ return get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID;
+}
+
+function get_comments_link() {
+ return get_permalink() . '#comments';
+}
+
+function comments_link( $file = '', $echo = true ) {
+ echo get_comments_link();
+}
+
+function get_comments_number( $post_id = 0 ) {
+ global $wpdb, $id;
+ $post_id = (int) $post_id;
+
+ if ( !$post_id )
+ $post_id = $id;
+
+ $post = get_post($post_id);
+ if ( ! isset($post->comment_count) )
+ $count = 0;
+ else
+ $count = $post->comment_count;
+
+ return apply_filters('get_comments_number', $count);
+}
+
+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_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_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_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_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;
+}
+
+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 = '';
+ if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
+ $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
+ $comment_author = stripslashes($comment_author);
+ $comment_author = wp_specialchars($comment_author, true);
+ }
+ $comment_author_email = '';
+ if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
+ $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
+ $comment_author_email = stripslashes($comment_author_email);
+ $comment_author_email = wp_specialchars($comment_author_email, true);
+ }
+ $comment_author_url = '';
+ if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
+ $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
+ $comment_author_url = stripslashes($comment_author_url);
+ $comment_author_url = wp_specialchars($comment_author_url, true);
+ }
+
+ // TODO: Use API instead of SELECTs.
+ 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");
+ }
+
+ 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 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;
+
+ if ( is_single() || is_page() )
+ return;
+
+ $number = get_comments_number($id);
+
+ if ( 0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status ) {
+ echo $none;
+ return;
+ }
+
+ 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 ' title="' . sprintf( __('Comment on %s'), $post->post_title ) .'">';
+ comments_number($zero, $one, $more, $number);
+ echo '</a>';
+}
+
+?>
diff --git a/wp-inst/wp-includes/comment.php b/wp-inst/wp-includes/comment.php
new file mode 100644
index 0000000..a5acdd3
--- /dev/null
+++ b/wp-inst/wp-includes/comment.php
@@ -0,0 +1,566 @@
+<?php
+
+function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
+ global $wpdb;
+
+ if (1 == get_settings('comment_moderation')) return false; // If moderation is set to manual
+
+ if ( (count(explode('http:', $comment)) - 1) >= get_settings('comment_max_links') )
+ return false; // Check # of external links
+
+ $mod_keys = trim( get_settings('moderation_keys') );
+ if ( !empty($mod_keys) ) {
+ $words = explode("\n", $mod_keys );
+
+ foreach ($words as $word) {
+ $word = trim($word);
+
+ // Skip empty lines
+ if (empty($word)) { continue; }
+
+ // Do some escaping magic so that '#' chars in the
+ // spam words don't break things:
+ $word = preg_quote($word, '#');
+
+ $pattern = "#$word#i";
+ if ( preg_match($pattern, $author) ) return false;
+ if ( preg_match($pattern, $email) ) return false;
+ if ( preg_match($pattern, $url) ) return false;
+ if ( preg_match($pattern, $comment) ) return false;
+ if ( preg_match($pattern, $user_ip) ) return false;
+ if ( preg_match($pattern, $user_agent) ) return false;
+ }
+ }
+
+ // Comment whitelisting:
+ if ( 1 == get_settings('comment_whitelist')) {
+ if ( 'trackback' == $comment_type || 'pingback' == $comment_type ) { // check if domain is in blogroll
+ $uri = parse_url($url);
+ $domain = $uri['host'];
+ $uri = parse_url( get_option('home') );
+ $home_domain = $uri['host'];
+ if ( $wpdb->get_var("SELECT link_id FROM $wpdb->links WHERE link_url LIKE ('%$domain%') LIMIT 1") || $domain == $home_domain )
+ return true;
+ else
+ return false;
+ } elseif( $author != '' && $email != '' ) {
+ $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1");
+ if ( ( 1 == $ok_to_comment ) &&
+ ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) )
+ return true;
+ else
+ return false;
+ } else {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+function get_approved_comments($post_id) {
+ global $wpdb;
+ return $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post_id AND comment_approved = '1' ORDER BY comment_date");
+}
+
+// Retrieves comment data given a comment ID or comment object.
+// Handles comment caching.
+function &get_comment(&$comment, $output = OBJECT) {
+ global $comment_cache, $wpdb;
+
+ if ( empty($comment) )
+ return null;
+
+ if ( is_object($comment) ) {
+ if ( !isset($comment_cache[$comment->comment_ID]) )
+ $comment_cache[$comment->comment_ID] = &$comment;
+ $_comment = & $comment_cache[$comment->comment_ID];
+ } else {
+ if ( !isset($comment_cache[$comment]) ) {
+ $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1");
+ $comment_cache[$comment->comment_ID] = & $_comment;
+ } else {
+ $_comment = & $comment_cache[$comment];
+ }
+ }
+
+ if ( $output == OBJECT ) {
+ return $_comment;
+ } elseif ( $output == ARRAY_A ) {
+ return get_object_vars($_comment);
+ } elseif ( $output == ARRAY_N ) {
+ return array_values(get_object_vars($_comment));
+ } else {
+ return $_comment;
+ }
+}
+
+// Deprecate in favor of get_comment()?
+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 get_lastcommentmodified($timezone = 'server') {
+ global $cache_lastcommentmodified, $pagenow, $wpdb;
+ $add_seconds_blog = get_settings('gmt_offset') * 3600;
+ $add_seconds_server = date('Z');
+ $now = current_time('mysql', 1);
+ if ( !isset($cache_lastcommentmodified[$timezone]) ) {
+ switch(strtolower($timezone)) {
+ case 'gmt':
+ $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
+ break;
+ case 'blog':
+ $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
+ break;
+ case 'server':
+ $lastcommentmodified = $wpdb->get_var("SELECT DATE_ADD(comment_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
+ break;
+ }
+ $cache_lastcommentmodified[$timezone] = $lastcommentmodified;
+ } else {
+ $lastcommentmodified = $cache_lastcommentmodified[$timezone];
+ }
+ return $lastcommentmodified;
+}
+
+function wp_allow_comment($commentdata) {
+ global $wpdb;
+ extract($commentdata);
+
+ $comment_user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($comment_author_IP) );
+
+ // Simple duplicate check
+ $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$comment_author' ";
+ if ( $comment_author_email )
+ $dupe .= "OR comment_author_email = '$comment_author_email' ";
+ $dupe .= ") AND comment_content = '$comment_content' LIMIT 1";
+ if ( $wpdb->get_var($dupe) )
+ die( __('Duplicate comment detected; it looks as though you\'ve already said that!') );
+
+ // Simple flood-protection
+ if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$comment_author_IP' OR comment_author_email = '$comment_author_email' ORDER BY comment_date DESC LIMIT 1") ) {
+ $time_lastcomment = mysql2date('U', $lasttime);
+ $time_newcomment = mysql2date('U', $comment_date_gmt);
+ if ( ($time_newcomment - $time_lastcomment) < 15 ) {
+ do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
+ die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') );
+ }
+ }
+
+ if ( $user_id ) {
+ $userdata = get_userdata($user_id);
+ $user = new WP_User($user_id);
+ $post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1");
+ }
+
+ // The author and the admins get respect.
+ if ( $userdata && ( $user_id == $post_author || $user->has_cap('level_9') ) ) {
+ $approved = 1;
+ }
+
+ // Everyone else's comments will be checked.
+ else {
+ if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) )
+ $approved = 1;
+ else
+ $approved = 0;
+ if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) )
+ $approved = 'spam';
+ }
+
+ $approved = apply_filters('pre_comment_approved', $approved);
+ return $approved;
+}
+
+function wp_delete_comment($comment_id) {
+ global $wpdb;
+ do_action('delete_comment', $comment_id);
+
+ $comment = get_comment($comment_id);
+
+ if ( ! $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1") )
+ return false;
+
+ $post_id = $comment->comment_post_ID;
+ if ( $post_id && $comment->comment_approved == 1 )
+ $wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count - 1 WHERE ID = '$post_id'" );
+
+ do_action('wp_set_comment_status', $comment_id, 'delete');
+ return true;
+}
+
+function 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 wp_insert_comment($commentdata) {
+ global $wpdb;
+ extract($commentdata);
+
+ if ( ! isset($comment_author_IP) )
+ $comment_author_IP = $_SERVER['REMOTE_ADDR'];
+ if ( ! isset($comment_date) )
+ $comment_date = current_time('mysql');
+ if ( ! isset($comment_date_gmt) )
+ $comment_date_gmt = gmdate('Y-m-d H:i:s', strtotime($comment_date) );
+ if ( ! isset($comment_parent) )
+ $comment_parent = 0;
+ if ( ! isset($comment_approved) )
+ $comment_approved = 1;
+ if ( ! isset($user_id) )
+ $user_id = 0;
+
+ $result = $wpdb->query("INSERT INTO $wpdb->comments
+ (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id)
+ VALUES
+ ('$comment_post_ID', '$comment_author', '$comment_author_email', '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content', '$comment_approved', '$comment_agent', '$comment_type', '$comment_parent', '$user_id')
+ ");
+
+ $id = $wpdb->insert_id;
+
+ if ( $comment_approved == 1) {
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'");
+ $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$comment_post_ID'" );
+ }
+ return $id;
+}
+
+function wp_filter_comment($commentdata) {
+ $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']);
+ $commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', $commentdata['comment_agent']);
+ $commentdata['comment_author'] = apply_filters('pre_comment_author_name', $commentdata['comment_author']);
+ $commentdata['comment_content'] = apply_filters('pre_comment_content', $commentdata['comment_content']);
+ $commentdata['comment_author_IP'] = apply_filters('pre_comment_user_ip', $commentdata['comment_author_IP']);
+ $commentdata['comment_author_url'] = apply_filters('pre_comment_author_url', $commentdata['comment_author_url']);
+ $commentdata['comment_author_email'] = apply_filters('pre_comment_author_email', $commentdata['comment_author_email']);
+ $commentdata['filtered'] = true;
+ return $commentdata;
+}
+
+function wp_new_comment( $commentdata ) {
+ $commentdata = apply_filters('preprocess_comment', $commentdata);
+
+ $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
+ $commentdata['user_ID'] = (int) $commentdata['user_ID'];
+
+ $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
+ $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'];
+
+ $commentdata['comment_date'] = current_time('mysql');
+ $commentdata['comment_date_gmt'] = current_time('mysql', 1);
+
+
+ $commentdata = wp_filter_comment($commentdata);
+
+ $commentdata['comment_approved'] = wp_allow_comment($commentdata);
+
+ $comment_ID = wp_insert_comment($commentdata);
+
+ do_action('comment_post', $comment_ID, $commentdata['comment_approved']);
+
+ if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching
+ if ( '0' == $commentdata['comment_approved'] )
+ wp_notify_moderator($comment_ID);
+
+ $post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment
+
+ if ( get_settings('comments_notify') && $commentdata['comment_approved'] && $post->post_author != $commentdata['user_ID'] )
+ wp_notify_postauthor($comment_ID, $commentdata['comment_type']);
+ }
+
+ return $comment_ID;
+}
+
+function wp_set_comment_status($comment_id, $comment_status) {
+ global $wpdb;
+
+ switch($comment_status) {
+ case 'hold':
+ $query = "UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
+ case 'approve':
+ $query = "UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
+ case 'spam':
+ $query = "UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
+ case 'delete':
+ return wp_delete_comment($comment_id);
+ break;
+ default:
+ return false;
+ }
+
+ if ($wpdb->query($query)) {
+ do_action('wp_set_comment_status', $comment_id, $comment_status);
+
+ $comment = get_comment($comment_id);
+ $comment_post_ID = $comment->comment_post_ID;
+ $c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" );
+ if( is_object( $c ) )
+ $wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" );
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function wp_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);
+
+ $commentarr = wp_filter_comment( $commentarr );
+
+ // Now extract the merged array.
+ extract($commentarr);
+
+ $comment_content = apply_filters('comment_save_pre', $comment_content);
+
+ $result = $wpdb->query(
+ "UPDATE $wpdb->comments SET
+ comment_content = '$comment_content',
+ comment_author = '$comment_author',
+ comment_author_email = '$comment_author_email',
+ comment_approved = '$comment_approved',
+ comment_author_url = '$comment_author_url',
+ comment_date = '$comment_date'
+ WHERE comment_ID = $comment_ID" );
+
+ $rval = $wpdb->rows_affected;
+
+ $c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" );
+ if( is_object( $c ) )
+ $wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" );
+
+ do_action('edit_comment', $comment_ID);
+
+ return $rval;
+}
+
+function 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) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
+ && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
+ $test = parse_url($link_test);
+ if (isset($test['query']))
+ $post_links[] = $link_test;
+ elseif(($test['path'] != '/') && ($test['path'] != ''))
+ $post_links[] = $link_test;
+ endif;
+ endforeach;
+
+ do_action('pre_ping', array(&$post_links, &$pung));
+
+ foreach ($post_links as $pagelinkedto){
+ debug_fwrite($log, "Processing -- $pagelinkedto\n");
+ $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
+
+ if ($pingback_server_url) {
+ @ set_time_limit( 60 );
+ // Now, the RPC call
+ debug_fwrite($log, "Page Linked To: $pagelinkedto \n");
+ debug_fwrite($log, 'Page Linked From: ');
+ $pagelinkedfrom = get_permalink($post_ID);
+ debug_fwrite($log, $pagelinkedfrom."\n");
+
+ // using a timeout of 3 seconds should be enough to cover slow servers
+ $client = new IXR_Client($pingback_server_url);
+ $client->timeout = 3;
+ $client->useragent .= ' -- WordPress/' . $wp_version;
+
+ // when set to true, this outputs debug messages by itself
+ $client->debug = false;
+
+ if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto ) )
+ add_ping( $post_ID, $pagelinkedto );
+ else
+ debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n");
+ }
+ }
+
+ debug_fwrite($log, "\nEND: ".time()."\n****************************\n");
+ debug_fclose($log);
+}
+
+function discover_pingback_server_uri($url, $timeout_bytes = 2048) {
+ global $wp_version;
+
+ $byte_count = 0;
+ $contents = '';
+ $headers = '';
+ $pingback_str_dquote = 'rel="pingback"';
+ $pingback_str_squote = 'rel=\'pingback\'';
+ $x_pingback_str = 'x-pingback: ';
+ $pingback_href_original_pos = 27;
+
+ extract(parse_url($url));
+
+ if (!isset($host)) {
+ // Not an URL. This should never happen.
+ return false;
+ }
+
+ $path = (!isset($path)) ? '/' : $path;
+ $path .= (isset($query)) ? '?'.$query : '';
+ $port = (isset($port)) ? $port : 80;
+
+ // Try to connect to the server at $host
+ $fp = @fsockopen($host, $port, $errno, $errstr, 2);
+ if (!$fp) {
+ // Couldn't open a connection to $host;
+ return false;
+ }
+
+ // Send the GET request
+ $request = "GET $path HTTP/1.1\r\nHost: $host\r\nUser-Agent: WordPress/$wp_version \r\n\r\n";
+// ob_end_flush();
+ fputs($fp, $request);
+
+ // Let's check for an X-Pingback header first
+ while (!feof($fp)) {
+ $line = fgets($fp, 512);
+ if (trim($line) == '') {
+ break;
+ }
+ $headers .= trim($line)."\n";
+ $x_pingback_header_offset = strpos(strtolower($headers), $x_pingback_str);
+ if ($x_pingback_header_offset) {
+ // We got it!
+ preg_match('#x-pingback: (.+)#is', $headers, $matches);
+ $pingback_server_url = trim($matches[1]);
+ return $pingback_server_url;
+ }
+ if(strpos(strtolower($headers), 'content-type: ')) {
+ preg_match('#content-type: (.+)#is', $headers, $matches);
+ $content_type = trim($matches[1]);
+ }
+ }
+
+ if (preg_match('#(image|audio|video|model)/#is', $content_type)) {
+ // Not an (x)html, sgml, or xml page, no use going further
+ return false;
+ }
+
+ while (!feof($fp)) {
+ $line = fgets($fp, 1024);
+ $contents .= trim($line);
+ $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
+ $pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
+ if ($pingback_link_offset_dquote || $pingback_link_offset_squote) {
+ $quote = ($pingback_link_offset_dquote) ? '"' : '\'';
+ $pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
+ $pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset);
+ $pingback_href_start = $pingback_href_pos+6;
+ $pingback_href_end = @strpos($contents, $quote, $pingback_href_start);
+ $pingback_server_url_len = $pingback_href_end - $pingback_href_start;
+ $pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len);
+ // We may find rel="pingback" but an incomplete pingback URI
+ if ($pingback_server_url_len > 0) {
+ // We got it!
+ return $pingback_server_url;
+ }
+ }
+ $byte_count += strlen($line);
+ if ($byte_count > $timeout_bytes) {
+ // It's no use going further, there probably isn't any pingback
+ // server to find in this file. (Prevents loading large files.)
+ return false;
+ }
+ }
+
+ // We didn't find anything.
+ return false;
+}
+
+function is_local_attachment($url) {
+ if ( !strstr($url, get_bloginfo('home') ) )
+ return false;
+ if ( strstr($url, get_bloginfo('home') . '/?attachment_id=') )
+ return true;
+ if ( $id = url_to_postid($url) ) {
+ $post = & get_post($id);
+ if ( 'attachment' == $post->post_type )
+ return true;
+ }
+ return false;
+}
+
+?>
diff --git a/wp-inst/wp-includes/cron.php b/wp-inst/wp-includes/cron.php
index 16cfef1..87aaa8c 100644
--- a/wp-inst/wp-includes/cron.php
+++ b/wp-inst/wp-includes/cron.php
@@ -1,107 +1,107 @@
-<?php
-
-function wp_schedule_single_event( $timestamp, $hook ) {
- $args = array_slice( func_get_args(), 2 );
- $crons = get_option( 'cron' );
- $crons[$timestamp][$hook] = array( 'schedule' => false, 'args' => $args );
- ksort( $crons );
- update_option( 'cron', $crons );
-}
-
-function wp_schedule_event( $timestamp, $recurrence, $hook ) {
- $args = array_slice( func_get_args(), 3 );
- $crons = get_option( 'cron' );
- $schedules = wp_get_schedules();
- if ( !isset( $schedules[$recurrence] ) )
- return false;
- $crons[$timestamp][$hook] = array( 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );
- ksort( $crons );
- update_option( 'cron', $crons );
-}
-
-function wp_reschedule_event( $timestamp, $recurrence, $hook ) {
- $args = array_slice( func_get_args(), 3 );
- $crons = get_option( 'cron' );
- $schedules = wp_get_schedules();
- $interval = 0;
-
- // First we try to get it from the schedule
- if ( 0 == $interval )
- $interval = $schedules[$recurrence]['interval'];
- // Now we try to get it from the saved interval in case the schedule disappears
- if ( 0 == $interval )
- $interval = $crons[$timestamp][$hook]['interval'];
- // Now we assume something is wrong and fail to schedule
- if ( 0 == $interval )
- return false;
-
- while ( $timestamp < time() + 1 )
- $timestamp += $interval;
-
- wp_schedule_event( $timestamp, $recurrence, $hook );
-}
-
-function wp_unschedule_event( $timestamp, $hook ) {
- $crons = get_option( 'cron' );
- unset( $crons[$timestamp][$hook] );
- if ( empty($crons[$timestamp]) )
- unset( $crons[$timestamp] );
- update_option( 'cron', $crons );
-}
-
-function wp_clear_scheduled_hook( $hook ) {
- while ( $timestamp = wp_next_scheduled( $hook ) )
- wp_unschedule_event( $timestamp, $hook );
-}
-
-function wp_next_scheduled( $hook ) {
- $crons = get_option( 'cron' );
- if ( empty($crons) )
- return false;
- foreach ( $crons as $timestamp => $cron )
- if ( isset( $cron[$hook] ) )
- return $timestamp;
- return false;
-}
-
-function spawn_cron() {
- if ( array_shift( array_keys( get_option( 'cron' ) ) ) > time() )
- return;
-
- $cron_url = get_settings( 'siteurl' ) . '/wp-cron.php';
- $parts = parse_url( $cron_url );
-
- $argyle = @ fsockopen( $parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01 );
- if ( $argyle )
- fputs( $argyle,
- "GET {$parts['path']}?check=" . md5(DB_PASS . '187425') . " HTTP/1.0\r\n"
- . "Host: {$_SERVER['HTTP_HOST']}\r\n\r\n"
- );
-}
-
-function wp_cron() {
- $crons = get_option( 'cron' );
- if ( !is_array($crons) || array_shift( array_keys( $crons ) ) > time() )
- return;
-
- $schedules = wp_get_schedules();
- foreach ( $crons as $timestamp => $cronhooks ) {
- if ( $timestamp > time() ) break;
- foreach ( $cronhooks as $hook => $args ) {
- if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
- continue;
- spawn_cron();
- break 2;
- }
- }
-}
-
-function wp_get_schedules() {
- $schedules = array(
- 'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ),
- 'daily' => array( 'interval' => 86400, 'display' => __('Once Daily') ),
- );
- return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
-}
-
+<?php
+
+function wp_schedule_single_event( $timestamp, $hook ) {
+ $args = array_slice( func_get_args(), 2 );
+ $crons = get_option( 'cron' );
+ $crons[$timestamp][$hook] = array( 'schedule' => false, 'args' => $args );
+ ksort( $crons );
+ update_option( 'cron', $crons );
+}
+
+function wp_schedule_event( $timestamp, $recurrence, $hook ) {
+ $args = array_slice( func_get_args(), 3 );
+ $crons = get_option( 'cron' );
+ $schedules = wp_get_schedules();
+ if ( !isset( $schedules[$recurrence] ) )
+ return false;
+ $crons[$timestamp][$hook] = array( 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );
+ ksort( $crons );
+ update_option( 'cron', $crons );
+}
+
+function wp_reschedule_event( $timestamp, $recurrence, $hook ) {
+ $args = array_slice( func_get_args(), 3 );
+ $crons = get_option( 'cron' );
+ $schedules = wp_get_schedules();
+ $interval = 0;
+
+ // First we try to get it from the schedule
+ if ( 0 == $interval )
+ $interval = $schedules[$recurrence]['interval'];
+ // Now we try to get it from the saved interval in case the schedule disappears
+ if ( 0 == $interval )
+ $interval = $crons[$timestamp][$hook]['interval'];
+ // Now we assume something is wrong and fail to schedule
+ if ( 0 == $interval )
+ return false;
+
+ while ( $timestamp < time() + 1 )
+ $timestamp += $interval;
+
+ wp_schedule_event( $timestamp, $recurrence, $hook );
+}
+
+function wp_unschedule_event( $timestamp, $hook ) {
+ $crons = get_option( 'cron' );
+ unset( $crons[$timestamp][$hook] );
+ if ( empty($crons[$timestamp]) )
+ unset( $crons[$timestamp] );
+ update_option( 'cron', $crons );
+}
+
+function wp_clear_scheduled_hook( $hook ) {
+ while ( $timestamp = wp_next_scheduled( $hook ) )
+ wp_unschedule_event( $timestamp, $hook );
+}
+
+function wp_next_scheduled( $hook ) {
+ $crons = get_option( 'cron' );
+ if ( empty($crons) )
+ return false;
+ foreach ( $crons as $timestamp => $cron )
+ if ( isset( $cron[$hook] ) )
+ return $timestamp;
+ return false;
+}
+
+function spawn_cron() {
+ if ( array_shift( array_keys( get_option( 'cron' ) ) ) > time() )
+ return;
+
+ $cron_url = get_settings( 'siteurl' ) . '/wp-cron.php';
+ $parts = parse_url( $cron_url );
+
+ $argyle = @ fsockopen( $parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01 );
+ if ( $argyle )
+ fputs( $argyle,
+ "GET {$parts['path']}?check=" . md5(DB_PASS . '187425') . " HTTP/1.0\r\n"
+ . "Host: {$_SERVER['HTTP_HOST']}\r\n\r\n"
+ );
+}
+
+function wp_cron() {
+ $crons = get_option( 'cron' );
+ if ( !is_array($crons) || array_shift( array_keys( $crons ) ) > time() )
+ return;
+
+ $schedules = wp_get_schedules();
+ foreach ( $crons as $timestamp => $cronhooks ) {
+ if ( $timestamp > time() ) break;
+ foreach ( $cronhooks as $hook => $args ) {
+ if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
+ continue;
+ spawn_cron();
+ break 2;
+ }
+ }
+}
+
+function wp_get_schedules() {
+ $schedules = array(
+ 'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ),
+ 'daily' => array( 'interval' => 86400, 'display' => __('Once Daily') ),
+ );
+ return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
+}
+
?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/default-filters.php b/wp-inst/wp-includes/default-filters.php
index 3d398c0..a3a4e20 100644
--- a/wp-inst/wp-includes/default-filters.php
+++ b/wp-inst/wp-includes/default-filters.php
@@ -86,5 +86,11 @@ add_filter('option_ping_sites', 'privacy_ping_filter');
add_action('wp_head', 'rsd_link');
add_action('publish_future_post', 'wp_publish_post', 10, 1);
add_action('wp_head', 'noindex', 1);
-add_action('init', 'wp_cron');
+if(!defined('DOING_CRON'))
+ add_action('init', 'wp_cron');
+add_action('do_feed_rdf', 'do_feed_rdf', 10, 1);
+add_action('do_feed_rss', 'do_feed_rss', 10, 1);
+add_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
+add_action('do_feed_atom', 'do_feed_atom', 10, 1);
+add_action('do_pings', 'do_all_pings', 10, 1);
?>
diff --git a/wp-inst/wp-includes/deprecated.php b/wp-inst/wp-includes/deprecated.php
new file mode 100644
index 0000000..8584932
--- /dev/null
+++ b/wp-inst/wp-includes/deprecated.php
@@ -0,0 +1,455 @@
+<?php
+/*
+ * Deprecated functios come here to die.
+ */
+
+// 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_type' => $post->post_type,
+ 'post_name' => $post->post_name
+ );
+
+ return $postdata;
+}
+
+// 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);
+}
+
+// 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;
+ }
+}
+
+// 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 ( 'yes' == $title )
+ $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 ( 'yes' == $title )
+ $string .= apply_filters('the_title', $post->post_title, $nextpost);
+ $string .= '</a>';
+ $format = str_replace('%', $string, $format);
+ echo $format;
+}
+
+//
+// These are deprecated. Use current_user_can().
+//
+
+/* returns true if $user_id can create a new post */
+function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
+ $author_data = get_userdata($user_id);
+ return ($author_data->user_level > 1);
+}
+
+/* returns true if $user_id can create a new post */
+function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
+ $author_data = get_userdata($user_id);
+ return ($author_data->user_level >= 1);
+}
+
+/* returns true if $user_id can edit $post_id */
+function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
+ $author_data = get_userdata($user_id);
+ $post = get_post($post_id);
+ $post_author_data = get_userdata($post->post_author);
+
+ if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2))
+ || ($author_data->user_level > $post_author_data->user_level)
+ || ($author_data->user_level >= 10) ) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/* returns true if $user_id can delete $post_id */
+function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
+ // right now if one can edit, one can delete
+ return user_can_edit_post($user_id, $post_id, $blog_id);
+}
+
+/* returns true if $user_id can set new posts' dates on $blog_id */
+function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
+ $author_data = get_userdata($user_id);
+ return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
+}
+
+/* returns true if $user_id can edit $post_id's date */
+function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
+ $author_data = get_userdata($user_id);
+ return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
+}
+
+/* returns true if $user_id can edit $post_id's comments */
+function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
+ // right now if one can edit a post, one can edit comments made on it
+ return user_can_edit_post($user_id, $post_id, $blog_id);
+}
+
+/* returns true if $user_id can delete $post_id's comments */
+function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
+ // right now if one can edit comments, one can delete comments
+ return user_can_edit_post_comments($user_id, $post_id, $blog_id);
+}
+
+function user_can_edit_user($user_id, $other_user) {
+ $user = get_userdata($user_id);
+ $other = get_userdata($other_user);
+ if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID )
+ return true;
+ else
+ return false;
+}
+
+/** 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->categories 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 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_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1");
+
+ if (! $cat_id)
+ return;
+
+ $args = add_query_arg('category', $cat_id, $args);
+ wp_get_links($args);
+} // end wp_get_linksbyname
+
+/** 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>';
+ ** }
+ **/
+// Deprecate in favor of get_linkz().
+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'");
+ // TODO: Fix me.
+ 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
+ **/
+// Deprecate in favor of get_linkz().
+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_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_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) {
+ return 0;
+}
+
+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) {
+ $query = "optionall=$optionall&all=$all&sort_column=$sort_column&sort_order=$sort_order&list=$list&optiondates=$optiondates&optioncount=$optioncount&hide_empty=$hide_empty&use_desc_for_title=$use_desc_for_title&child_of=$child_of&feed=$feed&feed_image=$feed_image&exclude=$exclude&hierarchical=$hierarchical";
+ return wp_list_cats($query);
+}
+
+function wp_list_cats($args = '') {
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ // Map to new names.
+ if ( isset($r['optionall']) && isset($r['all']))
+ $r['show_option_all'] = $r['all'];
+ if ( isset($r['sort_column']) )
+ $r['orderby'] = $r['sort_column'];
+ if ( isset($r['sort_order']) )
+ $r['order'] = $r['sort_order'];
+ if ( isset($r['optiondates']) )
+ $r['show_last_update'] = $r['optiondates'];
+ if ( isset($r['optioncount']) )
+ $r['show_count'] = $r['optioncount'];
+ if ( !empty($r['list']) )
+ $r['style'] = 'break';
+
+ return wp_list_categories($r);
+}
+
+function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc',
+ $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = FALSE,
+ $selected = 0, $exclude = 0) {
+
+ $show_option_all = '';
+ if ( $optionall )
+ $show_option_all = $all;
+
+ $show_option_none = '';
+ if ( $optionnone )
+ $show_option_none = __('None');
+
+ $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order',
+ 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude');
+ $query = add_query_arg($vars, '');
+ return wp_dropdown_categories($query);
+}
+
+?>
diff --git a/wp-inst/wp-includes/functions-compat.php b/wp-inst/wp-includes/functions-compat.php
index b6d706c..25bef35 100644
--- a/wp-inst/wp-includes/functions-compat.php
+++ b/wp-inst/wp-includes/functions-compat.php
@@ -44,6 +44,7 @@ function printr($var, $do_not_echo = false) {
if (!$do_not_echo) {
echo "<pre>$code</pre>";
}
+ ob_end_clean();
return $code;
}
@@ -72,7 +73,7 @@ if (!defined('CASE_UPPER')) {
* @link http://php.net/function.array_change_key_case
* @author Stephan Schmidt <schst@php.net>
* @author Aidan Lister <aidan@php.net>
- * @version $Revision: 3471 $
+ * @version $Revision: 3689 $
* @since PHP 4.2.0
* @require PHP 4.0.0 (user_error)
*/
diff --git a/wp-inst/wp-includes/functions-formatting.php b/wp-inst/wp-includes/functions-formatting.php
index feae447..8b4f9da 100644
--- a/wp-inst/wp-includes/functions-formatting.php
+++ b/wp-inst/wp-includes/functions-formatting.php
@@ -41,7 +41,7 @@ function wptexturize($text) {
} else {
$next = true;
}
- $curl = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&#038;$1', $curl);
+ $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&#038;$1', $curl);
$output .= $curl;
}
return $output;
@@ -98,10 +98,14 @@ function seems_utf8($Str) { # by bmorel at ssi dot fr
function wp_specialchars( $text, $quotes = 0 ) {
// Like htmlspecialchars except don't double-encode HTML entities
- $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&#038;$1', $text);-
+ $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&#038;$1', $text);
$text = str_replace('<', '&lt;', $text);
$text = str_replace('>', '&gt;', $text);
- if ( $quotes ) {
+ if ( 'double' === $quotes ) {
+ $text = str_replace('"', '&quot;', $text);
+ } elseif ( 'single' === $quotes ) {
+ $text = str_replace("'", '&#039;', $text);
+ } elseif ( $quotes ) {
$text = str_replace('"', '&quot;', $text);
$text = str_replace("'", '&#039;', $text);
}
@@ -1001,10 +1005,7 @@ function ent2ncr($text) {
'&diams;' => '&#9830;'
);
- foreach ($to_ncr as $entity => $ncr) {
- $text = str_replace($entity, $ncr, $text);
- }
- return $text;
+ return str_replace( array_keys($to_ncr), array_values($to_ncr), $text );
}
function wp_richedit_pre($text) {
@@ -1022,4 +1023,21 @@ function wp_richedit_pre($text) {
return apply_filters('richedit_pre', $output);
}
+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;
+}
+
+// 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));
+}
+
?>
diff --git a/wp-inst/wp-includes/functions-post.php b/wp-inst/wp-includes/functions-post.php
index edebffb..9513c62 100644
--- a/wp-inst/wp-includes/functions-post.php
+++ b/wp-inst/wp-includes/functions-post.php
@@ -199,7 +199,7 @@ function wp_insert_post($postarr = array()) {
(post_id,meta_key,meta_value)
VALUES ('$post_ID','_encloseme','1')
");
- spawn_pinger();
+ wp_schedule_single_event(time(), 'do_pings');
}
} else if ($post_type == 'page') {
wp_cache_delete('all_page_ids', 'pages');
@@ -210,9 +210,10 @@ function wp_insert_post($postarr = array()) {
add_post_meta($post_ID, '_wp_page_template', $page_template, true);
}
- if ( 'future' == $post_status )
- wp_schedule_event(mysql2date('U', $post_date), 'once', 'publish_future_post', $post_ID);
-
+ if ( 'future' == $post_status ) {
+ wp_schedule_single_event(mysql2date('U', $post_date), 'publish_future_post', $post_ID);
+ }
+
do_action('save_post', $post_ID);
do_action('wp_insert_post', $post_ID);
@@ -383,10 +384,15 @@ function wp_delete_attachment($postid) {
if ( ! empty($meta['thumb']) ) {
// Don't delete the thumb if another attachment uses it
- if (! $foo = $wpdb->get_row("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%".$wpdb->escape($meta['thumb'])."%' AND post_id <> $postid"))
- @ unlink(str_replace(basename($file), $meta['thumb'], $file));
+ if (! $wpdb->get_row("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%".$wpdb->escape($meta['thumb'])."%' AND post_id <> $postid")) {
+ $thumbfile = str_replace(basename($file), $meta['thumb'], $file);
+ $thumbfile = apply_filters('wp_delete_file', $thumbfile);
+ @ unlink($thumbfile);
+ }
}
+ $file = apply_filters('wp_delete_file', $file);
+
if ( ! empty($file) )
@ unlink($file);
@@ -1001,4 +1007,109 @@ function wp_upload_bits($name, $type, $bits) {
return array('file' => $new_file, 'url' => $url, 'error' => false);
}
+function do_all_pings() {
+ global $wpdb;
+
+ // Do pingbacks
+ while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
+ $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';");
+ pingback($ping->post_content, $ping->ID);
+ }
+
+ // Do Enclosures
+ while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
+ $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';");
+ do_enclose($enclosure->post_content, $enclosure->ID);
+ }
+
+ // Do Trackbacks
+ $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'");
+ if ( is_array($trackbacks) ) {
+ foreach ( $trackbacks as $trackback ) {
+ do_trackbacks($trackback->ID);
+ }
+ }
+
+ //Do Update Services/Generic Pings
+ generic_ping();
+}
+
+/**
+ * Places two script links in <head>: one to get tinyMCE (big), one to configure and start it (small)
+ */
+function tinymce_include() {
+ $ver = '04162006';
+ $src1 = get_settings('siteurl') . "/wp-includes/js/tinymce/tiny_mce_gzip.php?ver=$ver";
+ $src2 = get_settings('siteurl') . "/wp-includes/js/tinymce/tiny_mce_config.php?ver=$ver";
+
+ echo "<script type='text/javascript' src='$src1'></script>\n";
+ echo "<script type='text/javascript' src='$src2'></script>\n";
+}
+
+/**
+ * Places a textarea according to the current user's preferences, filled with $content.
+ * Also places a script block that enables tabbing between Title and Content.
+ *
+ * @param string Editor contents
+ * @param string (optional) Previous form field's ID (for tabbing support)
+ */
+function the_editor($content, $id = 'content', $prev_id = 'title') {
+ $rows = get_settings('default_post_edit_rows');
+ if (($rows < 3) || ($rows > 100))
+ $rows = 12;
+
+ $rows = "rows='$rows'";
+
+ the_quicktags();
+
+ if ( user_can_richedit() )
+ add_filter('the_editor_content', 'wp_richedit_pre');
+
+ $the_editor = apply_filters('the_editor', "<div><textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
+ $the_editor_content = apply_filters('the_editor_content', $content);
+
+ printf($the_editor, $the_editor_content);
+
+ ?>
+ <script type="text/javascript">
+ //<!--
+ edCanvas = document.getElementById('<?php echo $id; ?>');
+ <?php if ( user_can_richedit() ) : ?>
+ // This code is meant to allow tabbing from Title to Post (TinyMCE).
+ if ( tinyMCE.isMSIE )
+ document.getElementById('<?php echo $prev_id; ?>').onkeydown = function (e)
+ {
+ e = e ? e : window.event;
+ if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
+ var i = tinyMCE.selectedInstance;
+ if(typeof i == 'undefined')
+ return true;
+ tinyMCE.execCommand("mceStartTyping");
+ this.blur();
+ i.contentWindow.focus();
+ e.returnValue = false;
+ return false;
+ }
+ }
+ else
+ document.getElementById('<?php echo $prev_id; ?>').onkeypress = function (e)
+ {
+ e = e ? e : window.event;
+ if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
+ var i = tinyMCE.selectedInstance;
+ if(typeof i == 'undefined')
+ return true;
+ tinyMCE.execCommand("mceStartTyping");
+ this.blur();
+ i.contentWindow.focus();
+ e.returnValue = false;
+ return false;
+ }
+ }
+ <?php endif; ?>
+ //-->
+ </script>
+ <?php
+}
+
?>
diff --git a/wp-inst/wp-includes/functions.php b/wp-inst/wp-includes/functions.php
index 173b632..94536ff 100644
--- a/wp-inst/wp-includes/functions.php
+++ b/wp-inst/wp-includes/functions.php
@@ -16,26 +16,33 @@ function get_profile($field, $user = false) {
}
function mysql2date($dateformatstring, $mysqlstring, $translate = true) {
- global $month, $weekday, $month_abbrev, $weekday_abbrev;
+ global $wp_locale;
$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( 'U' == $dateformatstring )
+ return $i;
+
if ( -1 == $i || false == $i )
$i = 0;
- if ( !empty($month) && !empty($weekday) && $translate ) {
- $datemonth = $month[date('m', $i)];
- $datemonth_abbrev = $month_abbrev[$datemonth];
- $dateweekday = $weekday[date('w', $i)];
- $dateweekday_abbrev = $weekday_abbrev[$dateweekday];
+ if ( !empty($wp_locale->month) && !empty($wp_locale->weekday) && $translate ) {
+ $datemonth = $wp_locale->get_month(date('m', $i));
+ $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
+ $dateweekday = $wp_locale->get_weekday(date('w', $i));
+ $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
+ $datemeridiem = $wp_locale->get_meridiem(date('a', $i));
+ $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
$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 = 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 = preg_replace("/([^\\\])a/", "\${1}".backslashit($datemeridiem), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])A/", "\${1}".backslashit($datemeridiem_capital), $dateformatstring);
$dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
}
@@ -63,23 +70,28 @@ function current_time($type, $gmt = 0) {
}
function date_i18n($dateformatstring, $unixtimestamp) {
- global $month, $weekday, $month_abbrev, $weekday_abbrev;
+ global $wp_locale;
$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];
+ if ( (!empty($wp_locale->month)) && (!empty($wp_locale->weekday)) ) {
+ $datemonth = $wp_locale->get_month(date('m', $i));
+ $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
+ $dateweekday = $wp_locale->get_weekday(date('w', $i));
+ $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
+ $datemeridiem = $wp_locale->get_meridiem(date('a', $i));
+ $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
$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 = 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 = preg_replace("/([^\\\])a/", "\${1}".backslashit($datemeridiem), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])A/", "\${1}".backslashit($datemeridiem_capital), $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);
@@ -166,99 +178,11 @@ function user_pass_ok($user_login,$user_pass) {
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_type = 'post' AND post_status = 'publish'");
}
-
-// examine a url (supposedly from this blog) and try to
-// determine the post ID it represents.
-function url_to_postid($url) {
- global $wp_rewrite;
-
- // First, check to see if there is a 'p=N' or 'page_id=N' to match against
- preg_match('#[?&](p|page_id)=(\d+)#', $url, $values);
- $id = intval($values[2]);
- if ( $id ) return $id;
-
- // Check to see if we are using rewrite rules
- $rewrite = $wp_rewrite->wp_rewrite_rules();
-
- // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
- if ( empty($rewrite) )
- return 0;
-
- // $url cleanup by Mark Jaquith
- // This fixes things like #anchors, ?query=strings, missing 'www.',
- // added 'www.', or added 'index.php/' that will mess up our WP_Query
- // and return a false negative
-
- // Get rid of the #anchor
- $url_split = explode('#', $url);
- $url = $url_split[0];
-
- // Get rid of URI ?query=string
- $url_split = explode('?', $url);
- $url = $url_split[0];
-
- // Add 'www.' if it is absent and should be there
- if ( false !== strpos(get_settings('home'), '://www.') && false === strpos($url, '://www.') )
- $url = str_replace('://', '://www.', $url);
-
- // Strip 'www.' if it is present and shouldn't be
- if ( false === strpos(get_settings('home'), '://www.') )
- $url = str_replace('://www.', '://', $url);
-
- // Strip 'index.php/' if we're not using path info permalinks
- if ( false === strpos($rewrite, 'index.php/') )
- $url = str_replace('index.php/', '', $url);
-
- if ( false !== strpos($url, get_settings('home')) ) {
- // Chop off http://domain.com
- $url = str_replace(get_settings('home'), '', $url);
- } else {
- // Chop off /path/to/blog
- $home_path = parse_url(get_settings('home'));
- $home_path = $home_path['path'];
- $url = str_replace($home_path, '', $url);
- }
-
- // Trim leading and lagging slashes
- $url = trim($url, '/');
-
- $request = $url;
-
- // Done with cleanup
-
- // Look for matches.
- $request_match = $request;
- foreach ($rewrite as $match => $query) {
- // If the requesting file is the anchor of the match, prepend it
- // to the path info.
- if ( (! empty($url)) && (strpos($match, $url) === 0) ) {
- $request_match = $url . '/' . $request;
- }
-
- if ( preg_match("!^$match!", $request_match, $matches) ) {
- // Got a match.
- // Trim the query of everything up to the '?'.
- $query = preg_replace("!^.+\?!", '', $query);
-
- // Substitute the substring matches into the query.
- eval("\$query = \"$query\";");
- $query = new WP_Query($query);
- if ( $query->is_single || $query->is_page )
- return $query->post->ID;
- else
- return 0;
- }
- }
- return 0;
-}
-
-
function maybe_unserialize($original) {
if ( false !== $gm = @ unserialize($original) )
return $gm;
@@ -269,14 +193,30 @@ function maybe_unserialize($original) {
/* Options functions */
function get_settings($setting) {
- global $wpdb, $switched;
+ global $wpdb, $switched, $current_blog;
- if ( $switched == false && defined('WP_INSTALLING') == false ) {
+ if( ( $setting == 'siteurl' || $setting == 'home' ) && isset( $_SERVER[ 'HTTPS' ] ) == false && 1 == $current_blog->domain_mapping ) {
+ if( is_redirected_domain() ) {
+ return "http://" . $_SERVER[ 'HTTP_HOST' ];
+ }
+ }
+
+ if ( $switched == false && defined('WP_INSTALLING') == false && $_REQUEST['nomemcache'] != 'all' && $_REQUEST['nomemcache'] != $setting ) {
$value = wp_cache_get($setting, 'options');
} else {
$value = false;
+ wp_cache_delete($setting, 'options');
}
+// Uncomment if we get any page not found or rewrite errors
+// if( $setting == 'rewrite_rules' )
+// $value = false;
+
+ if ( $value == 'novalueindb' )
+ return false;
+ if ( $value == 'emptystringindb' )
+ return '';
+
if ( false === $value ) {
if ( defined('WP_INSTALLING') )
$wpdb->hide_errors();
@@ -286,8 +226,9 @@ function get_settings($setting) {
if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
$value = $row->option_value;
- wp_cache_set($setting, $value, 'options');
+ wp_cache_set($setting, ($value=='')?'emptystringindb':$value, 'options');
} else {
+ wp_cache_set($setting, 'novalueindb', 'options');
return false;
}
}
@@ -309,10 +250,10 @@ function get_option($option) {
}
function get_user_option( $option, $user = 0 ) {
- global $wpdb, $current_user;
+ global $wpdb;
if ( empty($user) )
- $user = $current_user;
+ $user = wp_get_current_user();
else
$user = get_userdata($user);
@@ -368,16 +309,17 @@ function update_option($option_name, $newvalue) {
return true;
}
+ $_newvalue = $newvalue;
if ( is_array($newvalue) || is_object($newvalue) )
$newvalue = serialize($newvalue);
- wp_cache_set($option_name, $newvalue, 'options');
+ wp_cache_delete($option_name, 'options');
$newvalue = $wpdb->escape($newvalue);
$option_name = $wpdb->escape($option_name);
$wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'");
if ( $wpdb->rows_affected == 1 ) {
- do_action("update_option_{$option_name}", $oldvalue, $newvalue);
+ do_action("update_option_{$option_name}", array('old'=>$oldvalue, 'new'=>$_newvalue));
return true;
}
return false;
@@ -401,7 +343,7 @@ function add_option($name, $value = '', $description = '', $autoload = 'yes') {
if ( is_array($value) || is_object($value) )
$value = serialize($value);
- wp_cache_set($name, $value, 'options');
+ wp_cache_delete($name, 'options');
$name = $wpdb->escape($name);
$value = $wpdb->escape($value);
@@ -543,31 +485,6 @@ 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_type' => $post->post_type,
- '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) {
@@ -656,21 +573,7 @@ function &get_children($post = 0, $output = OBJECT) {
}
}
-function set_page_path($page) {
- $page->fullpath = '/' . $page->post_name;
- $path = $page->fullpath;
- $curpage = $page;
- while ($curpage->post_parent != 0) {
- $curpage = get_page($curpage->post_parent);
- $path = '/' . $curpage->post_name . $path;
- }
-
- $page->fullpath = $path;
-
- return $page;
-}
-
-function get_page_by_path($page_path) {
+function get_page_by_path($page_path, $output = OBJECT) {
global $wpdb;
$page_path = rawurlencode(urldecode($page_path));
$page_path = str_replace('%2F', '/', $page_path);
@@ -684,7 +587,7 @@ function get_page_by_path($page_path) {
$pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = '$leaf_path' AND post_type='page'");
if ( empty($pages) )
- return 0;
+ return NULL;
foreach ($pages as $page) {
$path = '/' . $leaf_path;
@@ -695,10 +598,10 @@ function get_page_by_path($page_path) {
}
if ( $path == $full_path )
- return $page->ID;
+ return get_page($page->ID, $output);
}
- return 0;
+ return NULL;
}
// Retrieves page data given a page ID or page object.
@@ -735,11 +638,6 @@ function &get_page(&$page, $output = OBJECT) {
}
}
- if (!isset($_page->fullpath)) {
- $_page = set_page_path($_page);
- wp_cache_replace($_page->ID, $_page, 'pages');
- }
-
if ( $output == OBJECT ) {
return $_page;
} elseif ( $output == ARRAY_A ) {
@@ -751,18 +649,39 @@ function &get_page(&$page, $output = OBJECT) {
}
}
-function set_category_path($cat) {
- $cat->fullpath = '/' . $cat->category_nicename;
- $path = $cat->fullpath;
- $curcat = $cat;
- while ($curcat->category_parent != 0) {
- $curcat = get_category($curcat->category_parent);
- $path = '/' . $curcat->category_nicename . $path;
+function get_category_by_path($category_path, $full_match = true, $output = OBJECT) {
+ global $wpdb;
+ $category_path = rawurlencode(urldecode($category_path));
+ $category_path = str_replace('%2F', '/', $category_path);
+ $category_path = str_replace('%20', ' ', $category_path);
+ $category_paths = '/' . trim($category_path, '/');
+ $leaf_path = sanitize_title(basename($category_paths));
+ $category_paths = explode('/', $category_paths);
+ foreach($category_paths as $pathdir)
+ $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
+
+ $categories = $wpdb->get_results("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE category_nicename = '$leaf_path'");
+
+ if ( empty($categories) )
+ return NULL;
+
+ foreach ($categories as $category) {
+ $path = '/' . $leaf_path;
+ $curcategory = $category;
+ while ($curcategory->category_parent != 0) {
+ $curcategory = $wpdb->get_row("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE cat_ID = '$curcategory->category_parent'");
+ $path = '/' . $curcategory->category_nicename . $path;
+ }
+
+ if ( $path == $full_path )
+ return get_category($category->cat_ID, $output);
}
- $cat->fullpath = $path;
+ // If full matching is not required, return the first cat that matches the leaf.
+ if ( ! $full_match )
+ return get_category($categories[0]->cat_ID, $output);
- return $cat;
+ return NULL;
}
// Retrieves category data given a category ID or category object.
@@ -783,11 +702,6 @@ function &get_category(&$category, $output = OBJECT) {
}
}
- if ( !isset($_category->fullpath) ) {
- $_category = set_category_path($_category);
- wp_cache_replace($_category->cat_ID, $_category, 'category');
- }
-
if ( $output == OBJECT ) {
return $_category;
} elseif ( $output == ARRAY_A ) {
@@ -799,38 +713,6 @@ function &get_category(&$category, $output = OBJECT) {
}
}
-// Retrieves comment data given a comment ID or comment object.
-// Handles comment caching.
-function &get_comment(&$comment, $output = OBJECT) {
- global $comment_cache, $wpdb;
-
- if ( empty($comment) )
- return null;
-
- if ( is_object($comment) ) {
- if ( !isset($comment_cache[$comment->comment_ID]) )
- $comment_cache[$comment->comment_ID] = &$comment;
- $_comment = & $comment_cache[$comment->comment_ID];
- } else {
- if ( !isset($comment_cache[$comment]) ) {
- $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1");
- $comment_cache[$comment->comment_ID] = & $_comment;
- } else {
- $_comment = & $comment_cache[$comment];
- }
- }
-
- if ( $output == OBJECT ) {
- return $_comment;
- } elseif ( $output == ARRAY_A ) {
- return get_object_vars($_comment);
- } elseif ( $output == ARRAY_N ) {
- return array_values(get_object_vars($_comment));
- } else {
- return $_comment;
- }
-}
-
function get_catname($cat_ID) {
$category = &get_category($cat_ID);
return $category->cat_name;
@@ -1028,27 +910,6 @@ function debug_fclose($fp) {
}
}
-function spawn_pinger() {
- global $wpdb;
- $doping = false;
- if ( $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' LIMIT 1") )
- $doping = true;
-
- if ( $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_pingme' OR meta_key = '_encloseme' LIMIT 1") )
- $doping = true;
-
- if ( substr(php_sapi_name(), 0, 3) == 'cgi' )
- return $doping;
-
- if ( $doping ) {
- $ping_url = get_settings('siteurl') .'/wp-admin/execute-pings.php';
- $parts = parse_url($ping_url);
- $argyle = @ fsockopen($parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01);
- if ( $argyle )
- fputs($argyle, "GET {$parts['path']}?time=".time()." HTTP/1.0\r\nHost: {$_SERVER['HTTP_HOST']}\r\n\r\n");
- }
-}
-
function do_enclose( $content, $post_ID ) {
global $wp_version, $wpdb;
include_once (ABSPATH . WPINC . '/class-IXR.php');
@@ -1138,16 +999,6 @@ function wp_get_http_headers( $url, $red = 1 ) {
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;
@@ -1182,6 +1033,28 @@ function setup_postdata($post) {
return true;
}
+// Setup global user vars. Used by set_current_user() for back compat.
+function setup_userdata($user_id = '') {
+ global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity;
+
+ if ( '' == $user_id )
+ $user = wp_get_current_user();
+ else
+ $user = new WP_User($user_id);
+
+ if ( 0 == $user->ID )
+ return;
+
+ $userdata = $user->data;
+ $user_login = $user->user_login;
+ $user_level = $user->user_level;
+ $user_ID = $user->ID;
+ $user_email = $user->user_email;
+ $user_url = $user->user_url;
+ $user_pass_md5 = md5($user->user_pass);
+ $user_identity = $user->display_name;
+}
+
function is_new_day() {
global $day, $previousday;
if ( $day != $previousday ) {
@@ -1344,35 +1217,68 @@ function get_page_uri($page_id) {
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';
-
- $posts = $wpdb->get_results(
- "SELECT DISTINCT * FROM $wpdb->posts " .
- ( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) .
- " WHERE (post_type = 'post' 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'] );
+
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('numberposts' => 5, 'offset' => 0, 'category' => '',
+ 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' =>'');
+ $r = array_merge($defaults, $r);
+ extract($r);
+
+ $inclusions = '';
+ if ( !empty($include) ) {
+ $offset = 0; //ignore offset, category, exclude, meta_key, and meta_value params if using include
+ $category = '';
+ $exclude = '';
+ $meta_key = '';
+ $meta_value = '';
+ $incposts = preg_split('/[\s,]+/',$include);
+ $numberposts = count($incposts); // only the number of posts included
+ if ( count($incposts) ) {
+ foreach ( $incposts as $incpost ) {
+ if (empty($inclusions))
+ $inclusions = ' AND ( ID = ' . intval($incpost) . ' ';
+ else
+ $inclusions .= ' OR ID = ' . intval($incpost) . ' ';
+ }
+ }
+ }
+ if (!empty($inclusions))
+ $inclusions .= ')';
+
+ $exclusions = '';
+ if ( !empty($exclude) ) {
+ $exposts = preg_split('/[\s,]+/',$exclude);
+ if ( count($exposts) ) {
+ foreach ( $exposts as $expost ) {
+ if (empty($exclusions))
+ $exclusions = ' AND ( ID <> ' . intval($expost) . ' ';
+ else
+ $exclusions .= ' AND ID <> ' . intval($expost) . ' ';
+ }
+ }
+ }
+ if (!empty($exclusions))
+ $exclusions .= ')';
+
+ $query ="SELECT DISTINCT * FROM $wpdb->posts " ;
+ $query .= ( empty( $category ) ? "" : ", $wpdb->post2cat " ) ;
+ $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " ) ;
+ $query .= " WHERE (post_type = 'post' AND post_status = 'publish') $exclusions $inclusions " ;
+ $query .= ( empty( $category ) ? "" : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") " ) ;
+ $query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" ) ;
+ $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . " " . $order . " LIMIT " . $offset . ',' . $numberposts ;
+
+ $posts = $wpdb->get_results($query);
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;
@@ -1411,7 +1317,7 @@ function clean_page_cache($id) {
unset( $page_cache[$id] );
$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type='page'");
- wp_cache_set('all_page_ids', $page_ids, 'pages');
+ wp_cache_delete('all_page_ids','pages');
}
@@ -1434,7 +1340,7 @@ function update_post_category_cache($post_ids) {
}
function update_post_caches(&$posts) {
- global $post_cache, $category_cache, $comment_count_cache, $post_meta_cache;
+ global $post_cache, $category_cache, $post_meta_cache;
global $wpdb;
// No point in doing all this work if we didn't match any posts.
@@ -1445,7 +1351,6 @@ function update_post_caches(&$posts) {
for ($i = 0; $i < count($posts); $i++) {
$post_id_array[] = $posts[$i]->ID;
$post_cache[$posts[$i]->ID] = &$posts[$i];
- $comment_count_cache[$posts[$i]->ID] = $posts[$i]->comment_count;
}
$post_id_list = implode(',', $post_id_array);
@@ -1485,596 +1390,6 @@ function wp_footer() {
do_action('wp_footer');
}
-function is_single ($post = '') {
- global $wp_query;
-
- if ( !$wp_query->is_single )
- return false;
-
- if ( empty( $post) )
- return true;
-
- $post_obj = $wp_query->get_queried_object();
-
- if ( $post == $post_obj->ID )
- return true;
- elseif ( $post == $post_obj->post_title )
- return true;
- elseif ( $post == $post_obj->post_name )
- return true;
-
- return false;
-}
-
-function is_page ($page = '') {
- global $wp_query;
-
- if ( !$wp_query->is_page )
- return false;
-
- if ( empty($page) )
- return true;
-
- $page_obj = $wp_query->get_queried_object();
-
- if ( $page == $page_obj->ID )
- return true;
- elseif ( $page == $page_obj->post_title )
- return true;
- else if ( $page == $page_obj->post_name )
- return true;
-
- return false;
-}
-
-function is_attachment () {
- global $wp_query;
-
- return $wp_query->is_attachment;
-}
-
-function is_preview() {
- global $wp_query;
-
- return $wp_query->is_preview;
-}
-
-function is_archive () {
- global $wp_query;
-
- return $wp_query->is_archive;
-}
-
-function is_date () {
- global $wp_query;
-
- return $wp_query->is_date;
-}
-
-function is_year () {
- global $wp_query;
-
- return $wp_query->is_year;
-}
-
-function is_month () {
- global $wp_query;
-
- return $wp_query->is_month;
-}
-
-function is_day () {
- global $wp_query;
-
- return $wp_query->is_day;
-}
-
-function is_time () {
- global $wp_query;
-
- return $wp_query->is_time;
-}
-
-function is_author ($author = '') {
- global $wp_query;
-
- if ( !$wp_query->is_author )
- return false;
-
- if ( empty($author) )
- return true;
-
- $author_obj = $wp_query->get_queried_object();
-
- if ( $author == $author_obj->ID )
- return true;
- elseif ( $author == $author_obj->nickname )
- return true;
- elseif ( $author == $author_obj->user_nicename )
- return true;
-
- return false;
-}
-
-function is_category ($category = '') {
- global $wp_query;
-
- if ( !$wp_query->is_category )
- return false;
-
- if ( empty($category) )
- return true;
-
- $cat_obj = $wp_query->get_queried_object();
-
- if ( $category == $cat_obj->cat_ID )
- return true;
- else if ( $category == $cat_obj->cat_name )
- return true;
- elseif ( $category == $cat_obj->category_nicename )
- return true;
-
- return false;
-}
-
-function is_search () {
- global $wp_query;
-
- return $wp_query->is_search;
-}
-
-function is_feed () {
- global $wp_query;
-
- return $wp_query->is_feed;
-}
-
-function is_trackback () {
- global $wp_query;
-
- return $wp_query->is_trackback;
-}
-
-function is_admin () {
- global $wp_query;
-
- return ( $wp_query->is_admin || strstr($_SERVER['REQUEST_URI'], 'wp-admin/') );
-}
-
-function is_home () {
- global $wp_query;
-
- return $wp_query->is_home;
-}
-
-function is_404 () {
- global $wp_query;
-
- return $wp_query->is_404;
-}
-
-function is_comments_popup () {
- global $wp_query;
-
- return $wp_query->is_comments_popup;
-}
-
-function is_paged () {
- global $wp_query;
-
- return $wp_query->is_paged;
-}
-
-function in_the_loop() {
- global $wp_query;
-
- return $wp_query->in_the_loop;
-}
-
-function get_query_var($var) {
- global $wp_query;
-
- return $wp_query->get($var);
-}
-
-function have_posts() {
- global $wp_query;
-
- return $wp_query->have_posts();
-}
-
-function rewind_posts() {
- global $wp_query;
-
- return $wp_query->rewind_posts();
-}
-
-function the_post() {
- global $wp_query;
-
- $wp_query->the_post();
-}
-
-function get_theme_root() {
- return apply_filters('theme_root', ABSPATH . "wp-content/themes");
-}
-
-function get_theme_root_uri() {
- return apply_filters('theme_root_uri', get_settings('siteurl') . "/wp-content/themes", get_settings('siteurl'));
-}
-
-function get_stylesheet() {
- return apply_filters('stylesheet', get_settings('stylesheet'));
-}
-
-function get_stylesheet_directory() {
- $stylesheet = get_stylesheet();
- $stylesheet_dir = get_theme_root() . "/$stylesheet";
- return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet);
-}
-
-function get_stylesheet_directory_uri() {
- $stylesheet = rawurlencode( get_stylesheet() );
- $stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet";
- return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet);
-}
-
-function get_stylesheet_uri() {
- $stylesheet_dir_uri = get_stylesheet_directory_uri();
- $stylesheet_uri = $stylesheet_dir_uri . "/style.css";
- return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
-}
-
-function get_template() {
- $template = get_settings('template');
- if (!file_exists(get_theme_root() . "/$template")) { //works for dirs too
- update_option('template', 'default');
- update_option('stylesheet', 'default');
- }
- return apply_filters('template', get_settings('template'));
-}
-
-function get_template_directory() {
- $template = get_template();
- $template_dir = get_theme_root() . "/$template";
- return apply_filters('template_directory', $template_dir, $template);
-}
-
-function get_template_directory_uri() {
- $template = get_template();
- $template_dir_uri = get_theme_root_uri() . "/$template";
- return apply_filters('template_directory_uri', $template_dir_uri, $template);
-}
-
-function get_theme_data($theme_file) {
- $theme_data = implode('', file($theme_file));
- preg_match("|Theme Name:(.*)|i", $theme_data, $theme_name);
- preg_match("|Theme URI:(.*)|i", $theme_data, $theme_uri);
- preg_match("|Description:(.*)|i", $theme_data, $description);
- preg_match("|Author:(.*)|i", $theme_data, $author_name);
- preg_match("|Author URI:(.*)|i", $theme_data, $author_uri);
- preg_match("|Template:(.*)|i", $theme_data, $template);
- if ( preg_match("|Version:(.*)|i", $theme_data, $version) )
- $version = $version[1];
- else
- $version ='';
- if ( preg_match("|Status:(.*)|i", $theme_data, $status) )
- $status = $status[1];
- else
- $status ='publish';
-
- $description = wptexturize($description[1]);
-
- $name = $theme_name[1];
- $name = trim($name);
- $theme = $name;
-
- if ( '' == $author_uri[1] ) {
- $author = $author_name[1];
- } else {
- $author = '<a href="' . $author_uri[1] . '" title="' . __('Visit author homepage') . '">' . $author_name[1] . '</a>';
- }
-
- return array('Name' => $name, 'Title' => $theme, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1], 'Status' => $status);
-}
-
-function get_themes() {
- global $wp_themes;
- global $wp_broken_themes;
-
- if ( isset($wp_themes) )
- return $wp_themes;
-
- $themes = array();
- $wp_broken_themes = array();
- $theme_root = get_theme_root();
- $theme_loc = str_replace(ABSPATH, '', $theme_root);
-
- // Files in wp-content/themes directory
- $themes_dir = @ dir($theme_root);
- if ( $themes_dir ) {
- while(($theme_dir = $themes_dir->read()) !== false) {
- if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
- if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) {
- continue;
- }
- $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
- $found_stylesheet = false;
- while (($theme_file = $stylish_dir->read()) !== false) {
- if ( $theme_file == 'style.css' ) {
- $theme_files[] = $theme_dir . '/' . $theme_file;
- $found_stylesheet = true;
- break;
- }
- }
- if ( !$found_stylesheet ) {
- $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
- }
- }
- }
- }
-
- if ( !$themes_dir || !$theme_files ) {
- return $themes;
- }
-
- sort($theme_files);
-
- foreach($theme_files as $theme_file) {
- if ( ! is_readable("$theme_root/$theme_file") ) {
- $wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.'));
- continue;
- }
-
- $theme_data = get_theme_data("$theme_root/$theme_file");
-
- $name = $theme_data['Name'];
- $title = $theme_data['Title'];
- $description = wptexturize($theme_data['Description']);
- $version = $theme_data['Version'];
- $author = $theme_data['Author'];
- $template = $theme_data['Template'];
- $stylesheet = dirname($theme_file);
-
- foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext) {
- if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) {
- $screenshot = "screenshot.$ext";
- break;
- }
- }
-
- if ( empty($name) ) {
- $name = dirname($theme_file);
- $title = $name;
- }
-
- if ( empty($template) ) {
- if ( file_exists(dirname("$theme_root/$theme_file/index.php")) ) {
- $template = dirname($theme_file);
- } else {
- continue;
- }
- }
-
- $template = trim($template);
-
- if ( !file_exists("$theme_root/$template/index.php") ) {
- $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
- continue;
- }
-
- $stylesheet_files = array();
- $stylesheet_dir = @ dir("$theme_root/$stylesheet");
- if ( $stylesheet_dir ) {
- while(($file = $stylesheet_dir->read()) !== false) {
- if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) )
- $stylesheet_files[] = "$theme_loc/$stylesheet/$file";
- }
- }
-
- $template_files = array();
- $template_dir = @ dir("$theme_root/$template");
- if ( $template_dir ) {
- while(($file = $template_dir->read()) !== false) {
- if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) )
- $template_files[] = "$theme_loc/$template/$file";
- }
- }
-
- $template_dir = dirname($template_files[0]);
- $stylesheet_dir = dirname($stylesheet_files[0]);
-
- if ( empty($template_dir) )
- $template_dir = '/';
- if ( empty($stylesheet_dir) )
- $stylesheet_dir = '/';
-
- // Check for theme name collision. This occurs if a theme is copied to
- // a new theme directory and the theme header is not updated. Whichever
- // theme is first keeps the name. Subsequent themes get a suffix applied.
- // The Default and Classic themes always trump their pretenders.
- if ( isset($themes[$name]) ) {
- if ( ('WordPress Default' == $name || 'WordPress Classic' == $name) &&
- ('default' == $stylesheet || 'classic' == $stylesheet) ) {
- // If another theme has claimed to be one of our default themes, move
- // them aside.
- $suffix = $themes[$name]['Stylesheet'];
- $new_name = "$name/$suffix";
- $themes[$new_name] = $themes[$name];
- $themes[$new_name]['Name'] = $new_name;
- } else {
- $name = "$name/$stylesheet";
- }
- }
-
- $themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Stylesheet' => $stylesheet, 'Template Files' => $template_files, 'Stylesheet Files' => $stylesheet_files, 'Template Dir' => $template_dir, 'Stylesheet Dir' => $stylesheet_dir, 'Status' => $theme_data['Status'], 'Screenshot' => $screenshot);
- }
-
- // Resolve theme dependencies.
- $theme_names = array_keys($themes);
-
- foreach ($theme_names as $theme_name) {
- $themes[$theme_name]['Parent Theme'] = '';
- if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
- foreach ($theme_names as $parent_theme_name) {
- if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
- $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
- break;
- }
- }
- }
- }
-
- $wp_themes = $themes;
-
- return $themes;
-}
-
-function get_theme($theme) {
- $themes = get_themes();
-
- if ( array_key_exists($theme, $themes) )
- return $themes[$theme];
-
- return NULL;
-}
-
-function get_current_theme() {
- $themes = get_themes();
- $theme_names = array_keys($themes);
- $current_template = get_settings('template');
- $current_stylesheet = get_settings('stylesheet');
- $current_theme = 'WordPress Default';
-
- if ( $themes ) {
- foreach ($theme_names as $theme_name) {
- if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
- $themes[$theme_name]['Template'] == $current_template ) {
- $current_theme = $themes[$theme_name]['Name'];
- break;
- }
- }
- }
-
- return $current_theme;
-}
-
-function get_query_template($type) {
- $template = '';
- if ( file_exists(TEMPLATEPATH . "/{$type}.php") )
- $template = TEMPLATEPATH . "/{$type}.php";
-
- return apply_filters("{$type}_template", $template);
-}
-
-function get_404_template() {
- return get_query_template('404');
-}
-
-function get_archive_template() {
- return get_query_template('archive');
-}
-
-function get_author_template() {
- return get_query_template('author');
-}
-
-function get_category_template() {
- $template = '';
- if ( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') )
- $template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php';
- else if ( file_exists(TEMPLATEPATH . "/category.php") )
- $template = TEMPLATEPATH . "/category.php";
-
- return apply_filters('category_template', $template);
-}
-
-function get_date_template() {
- return get_query_template('date');
-}
-
-function get_home_template() {
- $template = '';
-
- if ( file_exists(TEMPLATEPATH . "/home.php") )
- $template = TEMPLATEPATH . "/home.php";
- else if ( file_exists(TEMPLATEPATH . "/index.php") )
- $template = TEMPLATEPATH . "/index.php";
-
- return apply_filters('home_template', $template);
-}
-
-function get_page_template() {
- global $wp_query;
-
- $id = $wp_query->post->ID;
- $template = get_post_meta($id, '_wp_page_template', true);
-
- if ( 'default' == $template )
- $template = '';
-
- if ( ! empty($template) && file_exists(TEMPLATEPATH . "/$template") )
- $template = TEMPLATEPATH . "/$template";
- else if ( file_exists(TEMPLATEPATH . "/page.php") )
- $template = TEMPLATEPATH . "/page.php";
- else
- $template = '';
-
- return apply_filters('page_template', $template);
-}
-
-function get_paged_template() {
- return get_query_template('paged');
-}
-
-function get_search_template() {
- return get_query_template('search');
-}
-
-function get_single_template() {
- return get_query_template('single');
-}
-
-function get_attachment_template() {
- global $posts;
- $type = explode('/', $posts[0]->post_mime_type);
- if ( $template = get_query_template($type[0]) )
- return $template;
- elseif ( $template = get_query_template($type[1]) )
- return $template;
- elseif ( $template = get_query_template("$type[0]_$type[1]") )
- return $template;
- else
- return get_query_template('attachment');
-}
-
-function get_comments_popup_template() {
- if ( file_exists( TEMPLATEPATH . '/comments-popup.php') )
- $template = TEMPLATEPATH . '/comments-popup.php';
- else
- $template = get_theme_root() . '/default/comments-popup.php';
-
- return apply_filters('comments_popup_template', $template);
-}
-
-// Borrowed from the PHP Manual user notes. Convert entities, while
-// preserving already-encoded entities:
-function htmlentities2($myHTML) {
- $translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES);
- $translation_table[chr(38)] = '&';
- return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&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.
@@ -2140,17 +1455,6 @@ 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;
-
- if( is_array( $wp_query->query_vars ) ) {
- extract($wp_query->query_vars);
- }
-
- require_once($file);
-}
-
function add_magic_quotes($array) {
global $wpdb;
@@ -2222,11 +1526,7 @@ function get_usermeta( $user_id, $meta_key = '') {
global $wpdb;
$user_id = (int) $user_id;
- if ( function_exists('get_userdata') ) {
- $user = get_userdata( $user_id );
- } else {
- $user = "";
- }
+ $user = get_userdata( $user_id );
if ( $meta_key && isset($user->{$meta_key}) )
return $user->{$meta_key};
@@ -2270,7 +1570,7 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
$meta_value = trim( $meta_value );
if (empty($meta_value)) {
- delete_usermeta($user_id, $meta_key);
+ return delete_usermeta($user_id, $meta_key);
}
$cur = $wpdb->get_row("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
@@ -2288,6 +1588,7 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
wp_cache_delete($user_id, 'users');
wp_cache_delete($user->user_login, 'userlogins');
wp_cache_delete( md5($user_id . $meta_key), 'usermeta' );
+
return true;
}
@@ -2337,76 +1638,64 @@ function get_num_queries() {
return $wpdb->num_queries;
}
-function wp_schedule_event($timestamp, $recurrence, $hook) {
- $args = array_slice(func_get_args(), 3);
- $crons = get_option('cron');
- $crons[$timestamp][$hook] = array('recur' => $recurrence, 'args' => $args);
- ksort($crons);
- update_option('cron', $crons);
+function privacy_ping_filter() {
+ global $current_blog;
+ if ( $current_blog->public )
+ return "http://rpc.pingomatic.com/\n";
+ else
+ return '';
}
-function wp_unschedule_event($timestamp, $hook) {
- $crons = get_option('cron');
- unset($crons[$timestamp][$hook]);
- if ( empty($crons[$timestamp]) )
- unset($crons[$timestamp]);
- update_option('cron', $crons);
+function bool_from_yn($yn) {
+ if ($yn == 'Y') return 1;
+ return 0;
}
-function wp_clear_scheduled_hook($hook) {
- while($timestamp = next_scheduled('scheduled_hook'))
- wp_unschedule_event($timestamp, 'scheduled_hook');
-}
+function do_feed() {
+ $feed = get_query_var('feed');
-function next_scheduled($hook) {
- $crons = get_option('cron');
- if ( empty($crons) )
- return false;
- foreach($crons as $timestamp => $cron) {
- //if($timestamp <= time()) continue;
- if(isset($cron[$hook])) return $timestamp;
- }
- return false;
-}
+ // Remove the pad, if present.
+ $feed = preg_replace('/^_+/', '', $feed);
+
+ if ($feed == '' || $feed == 'feed')
+ $feed = 'rss2';
-function spawn_cron() {
- if (array_shift(array_keys(get_option('cron'))) > time()) return;
+ $for_comments = false;
+ if ( is_single() || (get_query_var('withcomments') == 1) ) {
+ $feed = 'rss2';
+ $for_comments = true;
+ }
- $cron_url = get_settings('siteurl') . '/wp-cron.php';
- $parts = parse_url($cron_url);
- $argyle = @ fsockopen($parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01);
- if ( $argyle )
- fputs($argyle, "GET {$parts['path']}?time=" . time() . '&check='
- . md5(DB_PASS . '187425') . " HTTP/1.0\r\nHost: {$_SERVER['HTTP_HOST']}\r\n\r\n");
+ $hook = 'do_feed_' . $feed;
+ do_action($hook, $for_comments);
}
-function wp_cron() {
- $crons = get_option('cron');
- if (!is_array($crons) || array_shift(array_keys($crons)) > time())
- return;
+function do_feed_rdf() {
+ load_template(ABSPATH . 'wp-rdf.php');
+}
- foreach ($crons as $timestamp => $cronhooks) {
- if ($timestamp > current_time( 'timestamp' )) break;
- foreach($cronhooks as $hook => $args) {
- do_action($hook, $args['args']);
- $recurrence = $args['recur'];
- if ( 'hourly' == $recurrence ) {
- $args = array_merge( array($timestamp + 3600, $recurrence, $hook), $args['args']);
- call_user_func_array('wp_schedule_event', $args);
- } else if ( 'daily' == $recurrence ) {
- $args = array_merge( array($timestamp + 86400, $recurrence, $hook), $args['args']);
- call_user_func_array('wp_schedule_event', $args);
- }
+function do_feed_rss() {
+ load_template(ABSPATH . 'wp-rss.php');
+}
- wp_unschedule_event($timestamp, $hook);
- }
+function do_feed_rss2($for_comments) {
+ if ( $for_comments ) {
+ load_template(ABSPATH . 'wp-commentsrss2.php');
+ } else {
+ load_template(ABSPATH . 'wp-rss2.php');
}
}
-function privacy_ping_filter( $sites ) {
- if ( get_option('blog_public') )
- return $sites;
- else
- return '';
+function do_feed_atom() {
+ load_template(ABSPATH . 'wp-atom.php');
}
+
+function is_blog_installed() {
+ global $wpdb;
+ $wpdb->hide_errors();
+ $installed = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'");
+ $wpdb->show_errors();
+ return $installed;
+}
+
?>
diff --git a/wp-inst/wp-includes/kses.php b/wp-inst/wp-includes/kses.php
index 5b34efe..0fc416e 100644
--- a/wp-inst/wp-includes/kses.php
+++ b/wp-inst/wp-includes/kses.php
@@ -62,6 +62,7 @@ if (!CUSTOM_TAGS) {
'dd' => array (),
'div' => array (
'align' => array (),
+ 'class' => array (),
'dir' => array ()),
'dl' => array (),
'dt' => array (),
@@ -97,7 +98,7 @@ if (!CUSTOM_TAGS) {
'size' => array (),
'width' => array ()),
'i' => array (),
- 'iframe' => array (
+ 'iframe' => array ( // This is filtered to whitelisted domains later according to Andy
'longdesc' => array(),
'name' => array(),
'src' => array(),
@@ -127,8 +128,11 @@ if (!CUSTOM_TAGS) {
'for' => array ()),
'legend' => array (
'align' => array ()),
- 'li' => array (),
+ 'li' => array (
+ 'align' => array (),
+ 'class' => array ()),
'p' => array (
+ 'class' => array (),
'align' => array (),
'dir' => array()),
'pre' => array (
diff --git a/wp-inst/wp-includes/locale.php b/wp-inst/wp-includes/locale.php
index 7af4dea..9fc37a4 100644
--- a/wp-inst/wp-includes/locale.php
+++ b/wp-inst/wp-includes/locale.php
@@ -1,70 +1,131 @@
<?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_);
-}
+class WP_Locale {
+ var $weekday;
+ var $weekday_initial;
+ var $weekday_abbrev;
+
+ var $month;
+ var $month_abbrev;
+
+ var $meridiem;
+
+ function init() {
+ // The Weekdays
+ $this->weekday[0] = __('Sunday');
+ $this->weekday[1] = __('Monday');
+ $this->weekday[2] = __('Tuesday');
+ $this->weekday[3] = __('Wednesday');
+ $this->weekday[4] = __('Thursday');
+ $this->weekday[5] = __('Friday');
+ $this->weekday[6] = __('Saturday');
+
+ // The first letter of each day. The _%day%_initial suffix is a hack to make
+ // sure the day initials are unique.
+ $this->weekday_initial[__('Sunday')] = __('S_Sunday_initial');
+ $this->weekday_initial[__('Monday')] = __('M_Monday_initial');
+ $this->weekday_initial[__('Tuesday')] = __('T_Tuesday_initial');
+ $this->weekday_initial[__('Wednesday')] = __('W_Wednesday_initial');
+ $this->weekday_initial[__('Thursday')] = __('T_Thursday_initial');
+ $this->weekday_initial[__('Friday')] = __('F_Friday_initial');
+ $this->weekday_initial[__('Saturday')] = __('S_Saturday_initial');
+
+ foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) {
+ $this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
+ }
+
+ // Abbreviations for each day.
+ $this->weekday_abbrev[__('Sunday')] = __('Sun');
+ $this->weekday_abbrev[__('Monday')] = __('Mon');
+ $this->weekday_abbrev[__('Tuesday')] = __('Tue');
+ $this->weekday_abbrev[__('Wednesday')] = __('Wed');
+ $this->weekday_abbrev[__('Thursday')] = __('Thu');
+ $this->weekday_abbrev[__('Friday')] = __('Fri');
+ $this->weekday_abbrev[__('Saturday')] = __('Sat');
+
+ // The Months
+ $this->month['01'] = __('January');
+ $this->month['02'] = __('February');
+ $this->month['03'] = __('March');
+ $this->month['04'] = __('April');
+ $this->month['05'] = __('May');
+ $this->month['06'] = __('June');
+ $this->month['07'] = __('July');
+ $this->month['08'] = __('August');
+ $this->month['09'] = __('September');
+ $this->month['10'] = __('October');
+ $this->month['11'] = __('November');
+ $this->month['12'] = __('December');
+
+ // Abbreviations for each month. Uses the same hack as above to get around the
+ // 'May' duplication.
+ $this->month_abbrev[__('January')] = __('Jan_January_abbreviation');
+ $this->month_abbrev[__('February')] = __('Feb_February_abbreviation');
+ $this->month_abbrev[__('March')] = __('Mar_March_abbreviation');
+ $this->month_abbrev[__('April')] = __('Apr_April_abbreviation');
+ $this->month_abbrev[__('May')] = __('May_May_abbreviation');
+ $this->month_abbrev[__('June')] = __('Jun_June_abbreviation');
+ $this->month_abbrev[__('July')] = __('Jul_July_abbreviation');
+ $this->month_abbrev[__('August')] = __('Aug_August_abbreviation');
+ $this->month_abbrev[__('September')] = __('Sep_September_abbreviation');
+ $this->month_abbrev[__('October')] = __('Oct_October_abbreviation');
+ $this->month_abbrev[__('November')] = __('Nov_November_abbreviation');
+ $this->month_abbrev[__('December')] = __('Dec_December_abbreviation');
+
+ foreach ($this->month_abbrev as $month_ => $month_abbrev_) {
+ $this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
+ }
+
+ // The Meridiems
+ $this->meridiem['am'] = __('am');
+ $this->meridiem['pm'] = __('pm');
+ $this->meridiem['AM'] = __('AM');
+ $this->meridiem['PM'] = __('PM');
+ }
+
+ function get_weekday($weekday_number) {
+ return $this->weekday[$weekday_number];
+ }
+
+ function get_weekday_initial($weekday_name) {
+ return $this->weekday_initial[$weekday_name];
+ }
+
+ function get_weekday_abbrev($weekday_name) {
+ return $this->weekday_abbrev[$weekday_name];
+ }
+
+ function get_month($month_number) {
+ return $this->month[zeroise($month_number, 2)];
+ }
+
+ function get_month_initial($month_name) {
+ return $this->month_initial[$month_name];
+ }
+
+ function get_month_abbrev($month_name) {
+ return $this->month_abbrev[$month_name];
+ }
+
+ function get_meridiem($meridiem) {
+ return $this->meridiem[$meridiem];
+ }
+
+ // Global variables are deprecated. For backwards compatibility only.
+ function register_globals() {
+ $GLOBALS['weekday'] = $this->weekday;
+ $GLOBALS['weekday_initial'] = $this->weekday_initial;
+ $GLOBALS['weekday_abbrev'] = $this->weekday_abbrev;
+ $GLOBALS['month'] = $this->month;
+ $GLOBALS['month_abbrev'] = $this->month_abbrev;
+ }
-// 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_);
+ function WP_Locale() {
+ $this->init();
+ $this->register_globals();
+ }
}
-?> \ No newline at end of file
+?>
diff --git a/wp-inst/wp-includes/pluggable-functions.php b/wp-inst/wp-includes/pluggable-functions.php
index 2643342..b1b78f4 100644
--- a/wp-inst/wp-includes/pluggable-functions.php
+++ b/wp-inst/wp-includes/pluggable-functions.php
@@ -5,21 +5,20 @@
if ( !function_exists('set_current_user') ) :
function set_current_user($id, $name = '') {
- global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
+ return wp_set_current_user($id, $name);
+}
+endif;
- $current_user = '';
+if ( !function_exists('wp_set_current_user') ) :
+function wp_set_current_user($id, $name = '') {
+ global $current_user;
- $current_user = new WP_User($id, $name);
+ if ( isset($current_user) && ($id == $current_user->ID) )
+ return $current_user;
- $userdata = get_userdatabylogin($user_login);
+ $current_user = new WP_User($id, $name);
- $user_login = $userdata->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;
+ setup_userdata($current_user->ID);
do_action('set_current_user');
@@ -27,30 +26,34 @@ function set_current_user($id, $name = '') {
}
endif;
+if ( !function_exists('current_user') ) :
+function wp_get_current_user() {
+ global $current_user;
+
+ get_currentuserinfo();
+
+ return $current_user;
+}
+endif;
if ( !function_exists('get_currentuserinfo') ) :
function get_currentuserinfo() {
- global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
+ global $current_user;
if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
return false;
+ if ( ! empty($current_user) )
+ return;
+
if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) {
- $current_user = new WP_User(0);
+ wp_set_current_user(0);
return false;
}
- $user_login = $_COOKIE[USER_COOKIE];
- $userdata = get_userdatabylogin($user_login);
- $user_level = $userdata->user_level;
- $user_ID = $userdata->ID;
- $user_email = $userdata->user_email;
- $user_url = $userdata->user_url;
- $user_pass_md5 = md5($userdata->user_pass);
- $user_identity = $userdata->display_name;
-
- if ( empty($current_user) )
- $current_user = new WP_User($user_ID);
+
+ $user_login = $_COOKIE[USER_COOKIE];
+ wp_set_current_user(0, $user_login);
}
endif;
@@ -207,10 +210,11 @@ endif;
if ( !function_exists('is_user_logged_in') ) :
function is_user_logged_in() {
- global $current_user;
+ $user = wp_get_current_user();
- if ( $current_user->id == 0 )
+ if ( $user->id == 0 )
return false;
+
return true;
}
endif;
@@ -222,7 +226,6 @@ function auth_redirect() {
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) ||
(empty($_COOKIE[USER_COOKIE])) ) {
nocache_headers();
-
header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
exit();
}
@@ -239,6 +242,21 @@ function check_admin_referer() {
}
endif;
+if ( !function_exists('check_ajax_referer') ) :
+function check_ajax_referer() {
+ $cookie = explode(';', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie
+ foreach ( $cookie as $tasty ) {
+ if ( false !== strpos($tasty, USER_COOKIE) )
+ $user = substr(strstr($tasty, '='), 1);
+ if ( false !== strpos($tasty, PASS_COOKIE) )
+ $pass = substr(strstr($tasty, '='), 1);
+ }
+ if ( !wp_login( $user, $pass, true ) )
+ die('-1');
+ do_action('check_ajax_referer');
+}
+endif;
+
// Cookie safe redirect. Works around IIS Set-Cookie bug.
// http://support.microsoft.com/kb/q176113/
if ( !function_exists('wp_redirect') ) :
diff --git a/wp-inst/wp-includes/query.php b/wp-inst/wp-includes/query.php
index 240b51d..aa7069c 100644
--- a/wp-inst/wp-includes/query.php
+++ b/wp-inst/wp-includes/query.php
@@ -1,1016 +1,1016 @@
-<?php
-
-/*
- * The Big Query.
- */
-
-function get_query_var($var) {
- global $wp_query;
-
- return $wp_query->get($var);
-}
-
-function &query_posts($query) {
- global $wp_query;
- return $wp_query->query($query);
-}
-
-/*
- * Query type checks.
- */
-
-function is_admin () {
- global $wp_query;
-
- return ( $wp_query->is_admin || strstr($_SERVER['REQUEST_URI'], 'wp-admin/') );
-}
-
-function is_archive () {
- global $wp_query;
-
- return $wp_query->is_archive;
-}
-
-function is_attachment () {
- global $wp_query;
-
- return $wp_query->is_attachment;
-}
-
-function is_author ($author = '') {
- global $wp_query;
-
- if ( !$wp_query->is_author )
- return false;
-
- if ( empty($author) )
- return true;
-
- $author_obj = $wp_query->get_queried_object();
-
- if ( $author == $author_obj->ID )
- return true;
- elseif ( $author == $author_obj->nickname )
- return true;
- elseif ( $author == $author_obj->user_nicename )
- return true;
-
- return false;
-}
-
-function is_category ($category = '') {
- global $wp_query;
-
- if ( !$wp_query->is_category )
- return false;
-
- if ( empty($category) )
- return true;
-
- $cat_obj = $wp_query->get_queried_object();
-
- if ( $category == $cat_obj->cat_ID )
- return true;
- else if ( $category == $cat_obj->cat_name )
- return true;
- elseif ( $category == $cat_obj->category_nicename )
- return true;
-
- return false;
-}
-
-function is_comments_popup () {
- global $wp_query;
-
- return $wp_query->is_comments_popup;
-}
-
-function is_date () {
- global $wp_query;
-
- return $wp_query->is_date;
-}
-
-function is_day () {
- global $wp_query;
-
- return $wp_query->is_day;
-}
-
-function is_feed () {
- global $wp_query;
-
- return $wp_query->is_feed;
-}
-
-function is_home () {
- global $wp_query;
-
- return $wp_query->is_home;
-}
-
-function is_month () {
- global $wp_query;
-
- return $wp_query->is_month;
-}
-
-function is_page ($page = '') {
- global $wp_query;
-
- if ( !$wp_query->is_page )
- return false;
-
- if ( empty($page) )
- return true;
-
- $page_obj = $wp_query->get_queried_object();
-
- if ( $page == $page_obj->ID )
- return true;
- elseif ( $page == $page_obj->post_title )
- return true;
- else if ( $page == $page_obj->post_name )
- return true;
-
- return false;
-}
-
-function is_paged () {
- global $wp_query;
-
- return $wp_query->is_paged;
-}
-
-function is_plugin_page() {
- global $plugin_page;
-
- if ( isset($plugin_page) )
- return true;
-
- return false;
-}
-
-function is_preview() {
- global $wp_query;
-
- return $wp_query->is_preview;
-}
-
-function is_search () {
- global $wp_query;
-
- return $wp_query->is_search;
-}
-
-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_time () {
- global $wp_query;
-
- return $wp_query->is_time;
-}
-
-function is_trackback () {
- global $wp_query;
-
- return $wp_query->is_trackback;
-}
-
-function is_year () {
- global $wp_query;
-
- return $wp_query->is_year;
-}
-
-function is_404 () {
- global $wp_query;
-
- return $wp_query->is_404;
-}
-
-/*
- * The Loop. Post loop control.
- */
-
-function have_posts() {
- global $wp_query;
-
- return $wp_query->have_posts();
-}
-
-function in_the_loop() {
- global $wp_query;
-
- return $wp_query->in_the_loop;
-}
-
-function rewind_posts() {
- global $wp_query;
-
- return $wp_query->rewind_posts();
-}
-
-function the_post() {
- global $wp_query;
-
- $wp_query->the_post();
-}
-
-/*
- * WP_Query
- */
-
-class WP_Query {
- var $query;
- var $query_vars;
- var $queried_object;
- var $queried_object_id;
- var $request;
-
- var $posts;
- var $post_count = 0;
- var $current_post = -1;
- var $in_the_loop = false;
- var $post;
-
- var $is_single = false;
- var $is_preview = 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;
- var $is_attachment = false;
-
- function init_query_flags() {
- $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;
- $this->is_attachment = false;
- }
-
- function init () {
- unset($this->posts);
- unset($this->query);
- unset($this->query_vars);
- unset($this->queried_object);
- unset($this->queried_object_id);
- $this->post_count = 0;
- $this->current_post = -1;
- $this->in_the_loop = false;
-
- $this->init_query_flags();
- }
-
- // Reparse the query vars.
- function parse_query_vars() {
- $this->parse_query('');
- }
-
- // Parse a query string and set query type booleans.
- function parse_query ($query) {
- if ( !empty($query) || !isset($this->query) ) {
- $this->init();
- parse_str($query, $qv);
- $this->query = $query;
- $this->query_vars = $qv;
- }
-
- if ('404' == $qv['error']) {
- $this->is_404 = true;
- if ( !empty($query) ) {
- do_action('parse_query', array(&$this));
- }
- return;
- }
-
- $qv['m'] = (int) $qv['m'];
- $qv['p'] = (int) $qv['p'];
-
- // Compat. Map subpost to attachment.
- if ( '' != $qv['subpost'] )
- $qv['attachment'] = $qv['subpost'];
- if ( '' != $qv['subpost_id'] )
- $qv['attachment_id'] = $qv['subpost_id'];
-
- if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) {
- $this->is_single = true;
- $this->is_attachment = true;
- } elseif ('' != $qv['name']) {
- $this->is_single = true;
- } elseif ( $qv['p'] ) {
- $this->is_single = true;
- } elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
- // If year, month, day, hour, minute, and second are set, a single
- // post is being queried.
- $this->is_single = true;
- } elseif ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) {
- $this->is_page = true;
- $this->is_single = false;
- } elseif (!empty($qv['s'])) {
- $this->is_search = true;
- } 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 ('' != $qv['paged']) {
- $this->is_paged = true;
- }
-
- if ('' != $qv['comments_popup']) {
- $this->is_comments_popup = true;
- }
-
- //if we're previewing inside the write screen
- if ('' != $qv['preview']) {
- $this->is_preview = true;
- }
-
- if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) {
- $this->is_admin = true;
- }
-
- if ( ! ($this->is_attachment || $this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) {
- $this->is_home = true;
- }
-
- if ( !empty($query) ) {
- do_action('parse_query', array(&$this));
- }
- }
-
- function set_404() {
- $this->init_query_flags();
- $this->is_404 = true;
- }
-
- function get($query_var) {
- if (isset($this->query_vars[$query_var])) {
- return $this->query_vars[$query_var];
- }
-
- return '';
- }
-
- function set($query_var, $value) {
- $this->query_vars[$query_var] = $value;
- }
-
- function &get_posts() {
- global $wpdb, $pagenow, $user_ID;
-
- do_action('pre_get_posts', array(&$this));
-
- // Shorthand.
- $q = &$this->query_vars;
-
- // First let's clear some variables
- $whichcat = '';
- $whichauthor = '';
- $whichpage = '';
- $result = '';
- $where = '';
- $limits = '';
- $join = '';
-
- if ( !isset($q['post_type']) )
- $q['post_type'] = 'post';
- $post_type = $q['post_type'];
- 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 ( $this->is_home && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) {
- $this->is_page = true;
- $this->is_home = false;
- $q['page_id'] = get_option('page_on_front');
- }
-
- if (isset($q['page'])) {
- $q['page'] = trim($q['page'], '/');
- $q['page'] = (int) $q['page'];
- }
-
- $add_hours = intval(get_settings('gmt_offset'));
- $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
- $wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
-
- // If a month is specified in the querystring, load that month
- if ( (int) $q['m'] ) {
- $q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']);
- $where .= ' AND YEAR(post_date)=' . substr($q['m'], 0, 4);
- if (strlen($q['m'])>5)
- $where .= ' AND MONTH(post_date)=' . substr($q['m'], 4, 2);
- if (strlen($q['m'])>7)
- $where .= ' AND DAYOFMONTH(post_date)=' . substr($q['m'], 6, 2);
- if (strlen($q['m'])>9)
- $where .= ' AND HOUR(post_date)=' . substr($q['m'], 8, 2);
- if (strlen($q['m'])>11)
- $where .= ' AND MINUTE(post_date)=' . substr($q['m'], 10, 2);
- if (strlen($q['m'])>13)
- $where .= ' AND SECOND(post_date)=' . substr($q['m'], 12, 2);
- }
-
- if ( (int) $q['hour'] ) {
- $q['hour'] = '' . intval($q['hour']);
- $where .= " AND HOUR(post_date)='" . $q['hour'] . "'";
- }
-
- if ( (int) $q['minute'] ) {
- $q['minute'] = '' . intval($q['minute']);
- $where .= " AND MINUTE(post_date)='" . $q['minute'] . "'";
- }
-
- if ( (int) $q['second'] ) {
- $q['second'] = '' . intval($q['second']);
- $where .= " AND SECOND(post_date)='" . $q['second'] . "'";
- }
-
- if ( (int) $q['year'] ) {
- $q['year'] = '' . intval($q['year']);
- $where .= " AND YEAR(post_date)='" . $q['year'] . "'";
- }
-
- if ( (int) $q['monthnum'] ) {
- $q['monthnum'] = '' . intval($q['monthnum']);
- $where .= " AND MONTH(post_date)='" . $q['monthnum'] . "'";
- }
-
- if ( (int) $q['day'] ) {
- $q['day'] = '' . intval($q['day']);
- $where .= " AND DAYOFMONTH(post_date)='" . $q['day'] . "'";
- }
-
- // Compat. Map subpost to attachment.
- if ( '' != $q['subpost'] )
- $q['attachment'] = $q['subpost'];
- if ( '' != $q['subpost_id'] )
- $q['attachment_id'] = $q['subpost_id'];
-
- if ('' != $q['name']) {
- $q['name'] = sanitize_title($q['name']);
- $where .= " AND post_name = '" . $q['name'] . "'";
- } else if ('' != $q['pagename']) {
- $reqpage = get_page_by_path($q['pagename']);
- if ( !empty($reqpage) )
- $reqpage = $reqpage->ID;
- else
- $reqpage = 0;
-
- if ( ('page' == get_option('show_on_front') ) && ( $reqpage == get_option('page_for_posts') ) ) {
- $this->is_page = false;
- $this->is_home = true;
- } else {
- $q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename'])));
- $page_paths = '/' . trim($q['pagename'], '/');
- $q['pagename'] = sanitize_title(basename($page_paths));
- $q['name'] = $q['pagename'];
- $where .= " AND (ID = '$reqpage')";
- }
- } elseif ('' != $q['attachment']) {
- $q['attachment'] = str_replace('%2F', '/', urlencode(urldecode($q['attachment'])));
- $attach_paths = '/' . trim($q['attachment'], '/');
- $q['attachment'] = sanitize_title(basename($attach_paths));
- $q['name'] = $q['attachment'];
- $where .= " AND post_name = '" . $q['attachment'] . "'";
- }
-
- if ( (int) $q['w'] ) {
- $q['w'] = ''.intval($q['w']);
- $where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'";
- }
-
- if ( intval($q['comments_popup']) )
- $q['p'] = intval($q['comments_popup']);
-
- // If a attachment is requested by number, let it supercede any post number.
- if ( ($q['attachment_id'] != '') && (intval($q['attachment_id']) != 0) )
- $q['p'] = (int) $q['attachment_id'];
-
- // If a post number is specified, load that post
- if (($q['p'] != '') && intval($q['p']) != 0) {
- $q['p'] = (int) $q['p'];
- $where = ' AND ID = ' . $q['p'];
- }
-
- if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) {
- $q['page_id'] = intval($q['page_id']);
- if ( ('page' == get_option('show_on_front') ) && ( $q['page_id'] == get_option('page_for_posts') ) ) {
- $this->is_page = false;
- $this->is_home = true;
- } else {
- $q['p'] = $q['page_id'];
- $where = ' AND ID = '.$q['page_id'];
- }
- }
-
- // If a search pattern is specified, load the posts that match
- if (!empty($q['s'])) {
- $q['s'] = addslashes_gpc($q['s']);
- $search = ' AND (';
- $q['s'] = preg_replace('/, +/', ' ', $q['s']);
- $q['s'] = str_replace(',', ' ', $q['s']);
- $q['s'] = str_replace('"', ' ', $q['s']);
- $q['s'] = trim($q['s']);
- if ($q['exact']) {
- $n = '';
- } else {
- $n = '%';
- }
- if (!$q['sentence']) {
- $s_array = explode(' ',$q['s']);
- $q['search_terms'] = $s_array;
- $search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))';
- for ( $i = 1; $i < count($s_array); $i = $i + 1) {
- $search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))';
- }
- $search .= ' OR (post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\')';
- $search .= ')';
- } else {
- $search = ' AND ((post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\'))';
- }
- }
-
- // Category stuff
-
- if ((empty($q['cat'])) || ($q['cat'] == '0') ||
- // Bypass cat checks if fetching specific posts
- ( $this->is_single || $this->is_page )) {
- $whichcat='';
- } else {
- $q['cat'] = ''.urldecode($q['cat']).'';
- $q['cat'] = addslashes_gpc($q['cat']);
- if (stristr($q['cat'],'-')) {
- // Note: if we have a negative, we ignore all the positives. It must
- // always mean 'everything /except/ this one'. We should be able to do
- // multiple negatives but we don't :-(
- $eq = '!=';
- $andor = 'AND';
- $q['cat'] = explode('-',$q['cat']);
- $q['cat'] = intval($q['cat'][1]);
- } else {
- $eq = '=';
- $andor = 'OR';
- }
- $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
- $cat_array = preg_split('/[,\s]+/', $q['cat']);
- $whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]);
- $whichcat .= get_category_children($cat_array[0], ' '.$andor.' category_id '.$eq.' ');
- for ($i = 1; $i < (count($cat_array)); $i = $i + 1) {
- $whichcat .= ' '.$andor.' category_id '.$eq.' '.intval($cat_array[$i]);
- $whichcat .= get_category_children($cat_array[$i], ' '.$andor.' category_id '.$eq.' ');
- }
- $whichcat .= ')';
- if ($eq == '!=') {
- $q['cat'] = '-'.$q['cat']; // Put back the knowledge that we are excluding a category.
- }
- }
-
- // Category stuff for nice URIs
-
- global $cache_categories;
- if ('' != $q['category_name']) {
- $reqcat = get_category_by_path($q['category_name']);
- $q['category_name'] = str_replace('%2F', '/', urlencode(urldecode($q['category_name'])));
- $cat_paths = '/' . trim($q['category_name'], '/');
- $q['category_name'] = sanitize_title(basename($cat_paths));
-
- $cat_paths = '/' . trim(urldecode($q['category_name']), '/');
- $q['category_name'] = sanitize_title(basename($cat_paths));
- $cat_paths = explode('/', $cat_paths);
- foreach($cat_paths as $pathdir)
- $cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
-
- //if we don't match the entire hierarchy fallback on just matching the nicename
- if ( empty($reqcat) )
- $reqcat = get_category_by_path($q['category_name'], false);
-
- if ( !empty($reqcat) )
- $reqcat = $reqcat->cat_ID;
- else
- $reqcat = 0;
-
- $q['cat'] = $reqcat;
-
- $tables = ", $wpdb->post2cat, $wpdb->categories";
- $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
- $whichcat = " AND (category_id = '" . $q['cat'] . "'";
- $whichcat .= get_category_children($q['cat'], " OR category_id = ");
- $whichcat .= ")";
- }
-
- // Author/user stuff
-
- if ((empty($q['author'])) || ($q['author'] == '0')) {
- $whichauthor='';
- } else {
- $q['author'] = ''.urldecode($q['author']).'';
- $q['author'] = addslashes_gpc($q['author']);
- if (stristr($q['author'], '-')) {
- $eq = '!=';
- $andor = 'AND';
- $q['author'] = explode('-', $q['author']);
- $q['author'] = ''.intval($q['author'][1]);
- } else {
- $eq = '=';
- $andor = 'OR';
- }
- $author_array = preg_split('/[,\s]+/', $q['author']);
- $whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);
- for ($i = 1; $i < (count($author_array)); $i = $i + 1) {
- $whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]);
- }
- $whichauthor .= ')';
- }
-
- // Author stuff for nice URIs
-
- if ('' != $q['author_name']) {
- if (stristr($q['author_name'],'/')) {
- $q['author_name'] = explode('/',$q['author_name']);
- if ($q['author_name'][count($q['author_name'])-1]) {
- $q['author_name'] = $q['author_name'][count($q['author_name'])-1];#no trailing slash
- } else {
- $q['author_name'] = $q['author_name'][count($q['author_name'])-2];#there was a trailling slash
- }
- }
- $q['author_name'] = sanitize_title($q['author_name']);
- $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'");
- $whichauthor .= ' AND (post_author = '.intval($q['author']).')';
- }
-
- $where .= $search.$whichcat.$whichauthor;
-
- if ((empty($q['order'])) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC'))) {
- $q['order']='DESC';
- }
-
- // Order by
- if (empty($q['orderby'])) {
- $q['orderby'] = 'post_date '.$q['order'];
- } else {
- // Used to filter values
- $allowed_keys = array('author', 'date', 'category', 'title', 'modified', 'menu_order');
- $q['orderby'] = urldecode($q['orderby']);
- $q['orderby'] = addslashes_gpc($q['orderby']);
- $orderby_array = explode(' ',$q['orderby']);
- if ( empty($orderby_array) )
- $orderby_array[] = $q['orderby'];
- $q['orderby'] = '';
- for ($i = 0; $i < count($orderby_array); $i++) {
- // Only allow certain values for safety
- $orderby = $orderby_array[$i];
- if ( 'menu_order' != $orderby )
- $orderby = 'post_' . $orderby;
- if ( in_array($orderby_array[$i], $allowed_keys) )
- $q['orderby'] .= (($i == 0) ? '' : ',') . "$orderby {$q['order']}";
- }
- if ( empty($q['orderby']) )
- $q['orderby'] = 'post_date '.$q['order'];
- }
-
- if ( $this->is_attachment ) {
- $where .= ' AND (post_type = "attachment")';
- } elseif ($this->is_page) {
- $where .= ' AND (post_type = "page")';
- } elseif ($this->is_single) {
- $where .= ' AND (post_type = "post")';
- } else {
- $where .= " AND (post_type = '$post_type' AND (post_status = 'publish'";
-
- if ( is_admin() )
- $where .= " OR post_status = 'future' OR post_status = 'draft'";
-
- if ( is_user_logged_in() )
- $where .= " OR post_author = $user_ID AND post_status = 'private'))";
- 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 && ! $this->is_page) {
- $page = $q['paged'];
- if (empty($page)) {
- $page = 1;
- }
-
- if (($q['what_to_show'] == 'posts')) {
- $pgstrt = '';
- $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
- $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
- } elseif ($q['what_to_show'] == 'days') {
- $startrow = $q['posts_per_page'] * (intval($page)-1);
- $start_date = $wpdb->get_var("SELECT max(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $startrow,1");
- $endrow = $startrow + $q['posts_per_page'] - 1;
- $end_date = $wpdb->get_var("SELECT min(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $endrow,1");
-
- if ($page > 1) {
- $where .= " AND post_date >= '$end_date' AND post_date <= '$start_date'";
- } else {
- $where .= " AND post_date >= '$end_date'";
- }
- }
- }
-
- // Apply post-paging filters on where and join. Only plugins that
- // manipulate paging queries should use these hooks.
- $where = apply_filters('posts_where_paged', $where);
- $groupby = '';
- $groupby = apply_filters('posts_groupby', $groupby);
- if ( ! empty($groupby) )
- $groupby = 'GROUP BY ' . $groupby;
- $join = apply_filters('posts_join_paged', $join);
- $orderby = apply_filters('posts_orderby', $q['orderby']);
- $request = " SELECT * FROM $wpdb->posts $join WHERE 1=1 $where $groupby ORDER BY $orderby $limits";
- $this->request = apply_filters('posts_request', $request);
-
- $this->posts = $wpdb->get_results($this->request);
-
- // Check post status to determine if post should be displayed.
- if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) {
- $status = get_post_status($this->posts[0]);
- //$type = get_post_type($this->posts[0]);
- if ( ('publish' != $status) ) {
- if ( ! is_user_logged_in() ) {
- // User must be logged in to view unpublished posts.
- $this->posts = array();
- } else {
- if ('draft' == $status) {
- // User must have edit permissions on the draft to preview.
- if (! current_user_can('edit_post', $this->posts[0]->ID)) {
- $this->posts = array();
- } else {
- $this->is_preview = true;
- $this->posts[0]->post_date = current_time('mysql');
- }
- } else if ('future' == $status) {
- $this->is_preview = true;
- if (!current_user_can('edit_post', $this->posts[0]->ID)) {
- $this->posts = array ( );
- }
- } else {
- if (! current_user_can('read_post', $this->posts[0]->ID))
- $this->posts = array();
- }
- }
- }
- }
-
- update_post_caches($this->posts);
-
- $this->posts = apply_filters('the_posts', $this->posts);
- $this->post_count = count($this->posts);
- if ($this->post_count > 0) {
- $this->post = $this->posts[0];
- }
-
- return $this->posts;
- }
-
- function next_post() {
-
- $this->current_post++;
-
- $this->post = $this->posts[$this->current_post];
- return $this->post;
- }
-
- function the_post() {
- global $post;
- $this->in_the_loop = true;
- $post = $this->next_post();
- setup_postdata($post);
-
- if ( $this->current_post == 0 ) // loop has just started
- do_action('loop_start');
- }
-
- function have_posts() {
- if ($this->current_post + 1 < $this->post_count) {
- return true;
- } elseif ($this->current_post + 1 == $this->post_count) {
- do_action('loop_end');
- // Do some cleaning up after the loop
- $this->rewind_posts();
- }
-
- $this->in_the_loop = false;
- return false;
- }
-
- function rewind_posts() {
- $this->current_post = -1;
- if ($this->post_count > 0) {
- $this->post = $this->posts[0];
- }
- }
-
- function &query($query) {
- $this->parse_query($query);
- return $this->get_posts();
- }
-
- function get_queried_object() {
- if (isset($this->queried_object)) {
- return $this->queried_object;
- }
-
- $this->queried_object = NULL;
- $this->queried_object_id = 0;
-
- if ($this->is_category) {
- $cat = $this->get('cat');
- $category = &get_category($cat);
- $this->queried_object = &$category;
- $this->queried_object_id = $cat;
- } else if ($this->is_single) {
- $this->queried_object = $this->post;
- $this->queried_object_id = $this->post->ID;
- } else if ($this->is_page) {
- $this->queried_object = $this->post;
- $this->queried_object_id = $this->post->ID;
- } else if ($this->is_author) {
- $author_id = $this->get('author');
- $author = get_userdata($author_id);
- $this->queried_object = $author;
- $this->queried_object_id = $author_id;
- }
-
- return $this->queried_object;
- }
-
- function get_queried_object_id() {
- $this->get_queried_object();
-
- if (isset($this->queried_object_id)) {
- return $this->queried_object_id;
- }
-
- return 0;
- }
-
- function WP_Query ($query = '') {
- if (! empty($query)) {
- $this->query($query);
- }
- }
-}
-
-?>
+<?php
+
+/*
+ * The Big Query.
+ */
+
+function get_query_var($var) {
+ global $wp_query;
+
+ return $wp_query->get($var);
+}
+
+function &query_posts($query) {
+ global $wp_query;
+ return $wp_query->query($query);
+}
+
+/*
+ * Query type checks.
+ */
+
+function is_admin () {
+ global $wp_query;
+
+ return ( $wp_query->is_admin || strstr($_SERVER['REQUEST_URI'], 'wp-admin/') );
+}
+
+function is_archive () {
+ global $wp_query;
+
+ return $wp_query->is_archive;
+}
+
+function is_attachment () {
+ global $wp_query;
+
+ return $wp_query->is_attachment;
+}
+
+function is_author ($author = '') {
+ global $wp_query;
+
+ if ( !$wp_query->is_author )
+ return false;
+
+ if ( empty($author) )
+ return true;
+
+ $author_obj = $wp_query->get_queried_object();
+
+ if ( $author == $author_obj->ID )
+ return true;
+ elseif ( $author == $author_obj->nickname )
+ return true;
+ elseif ( $author == $author_obj->user_nicename )
+ return true;
+
+ return false;
+}
+
+function is_category ($category = '') {
+ global $wp_query;
+
+ if ( !$wp_query->is_category )
+ return false;
+
+ if ( empty($category) )
+ return true;
+
+ $cat_obj = $wp_query->get_queried_object();
+
+ if ( $category == $cat_obj->cat_ID )
+ return true;
+ else if ( $category == $cat_obj->cat_name )
+ return true;
+ elseif ( $category == $cat_obj->category_nicename )
+ return true;
+
+ return false;
+}
+
+function is_comments_popup () {
+ global $wp_query;
+
+ return $wp_query->is_comments_popup;
+}
+
+function is_date () {
+ global $wp_query;
+
+ return $wp_query->is_date;
+}
+
+function is_day () {
+ global $wp_query;
+
+ return $wp_query->is_day;
+}
+
+function is_feed () {
+ global $wp_query;
+
+ return $wp_query->is_feed;
+}
+
+function is_home () {
+ global $wp_query;
+
+ return $wp_query->is_home;
+}
+
+function is_month () {
+ global $wp_query;
+
+ return $wp_query->is_month;
+}
+
+function is_page ($page = '') {
+ global $wp_query;
+
+ if ( !$wp_query->is_page )
+ return false;
+
+ if ( empty($page) )
+ return true;
+
+ $page_obj = $wp_query->get_queried_object();
+
+ if ( $page == $page_obj->ID )
+ return true;
+ elseif ( $page == $page_obj->post_title )
+ return true;
+ else if ( $page == $page_obj->post_name )
+ return true;
+
+ return false;
+}
+
+function is_paged () {
+ global $wp_query;
+
+ return $wp_query->is_paged;
+}
+
+function is_plugin_page() {
+ global $plugin_page;
+
+ if ( isset($plugin_page) )
+ return true;
+
+ return false;
+}
+
+function is_preview() {
+ global $wp_query;
+
+ return $wp_query->is_preview;
+}
+
+function is_search () {
+ global $wp_query;
+
+ return $wp_query->is_search;
+}
+
+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_time () {
+ global $wp_query;
+
+ return $wp_query->is_time;
+}
+
+function is_trackback () {
+ global $wp_query;
+
+ return $wp_query->is_trackback;
+}
+
+function is_year () {
+ global $wp_query;
+
+ return $wp_query->is_year;
+}
+
+function is_404 () {
+ global $wp_query;
+
+ return $wp_query->is_404;
+}
+
+/*
+ * The Loop. Post loop control.
+ */
+
+function have_posts() {
+ global $wp_query;
+
+ return $wp_query->have_posts();
+}
+
+function in_the_loop() {
+ global $wp_query;
+
+ return $wp_query->in_the_loop;
+}
+
+function rewind_posts() {
+ global $wp_query;
+
+ return $wp_query->rewind_posts();
+}
+
+function the_post() {
+ global $wp_query;
+
+ $wp_query->the_post();
+}
+
+/*
+ * WP_Query
+ */
+
+class WP_Query {
+ var $query;
+ var $query_vars;
+ var $queried_object;
+ var $queried_object_id;
+ var $request;
+
+ var $posts;
+ var $post_count = 0;
+ var $current_post = -1;
+ var $in_the_loop = false;
+ var $post;
+
+ var $is_single = false;
+ var $is_preview = 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;
+ var $is_attachment = false;
+
+ function init_query_flags() {
+ $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;
+ $this->is_attachment = false;
+ }
+
+ function init () {
+ unset($this->posts);
+ unset($this->query);
+ unset($this->query_vars);
+ unset($this->queried_object);
+ unset($this->queried_object_id);
+ $this->post_count = 0;
+ $this->current_post = -1;
+ $this->in_the_loop = false;
+
+ $this->init_query_flags();
+ }
+
+ // Reparse the query vars.
+ function parse_query_vars() {
+ $this->parse_query('');
+ }
+
+ // Parse a query string and set query type booleans.
+ function parse_query ($query) {
+ if ( !empty($query) || !isset($this->query) ) {
+ $this->init();
+ parse_str($query, $qv);
+ $this->query = $query;
+ $this->query_vars = $qv;
+ }
+
+ if ('404' == $qv['error']) {
+ $this->is_404 = true;
+ if ( !empty($query) ) {
+ do_action('parse_query', array(&$this));
+ }
+ return;
+ }
+
+ $qv['m'] = (int) $qv['m'];
+ $qv['p'] = (int) $qv['p'];
+
+ // Compat. Map subpost to attachment.
+ if ( '' != $qv['subpost'] )
+ $qv['attachment'] = $qv['subpost'];
+ if ( '' != $qv['subpost_id'] )
+ $qv['attachment_id'] = $qv['subpost_id'];
+
+ if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) {
+ $this->is_single = true;
+ $this->is_attachment = true;
+ } elseif ('' != $qv['name']) {
+ $this->is_single = true;
+ } elseif ( $qv['p'] ) {
+ $this->is_single = true;
+ } elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
+ // If year, month, day, hour, minute, and second are set, a single
+ // post is being queried.
+ $this->is_single = true;
+ } elseif ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) {
+ $this->is_page = true;
+ $this->is_single = false;
+ } elseif (!empty($qv['s'])) {
+ $this->is_search = true;
+ } 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 ('' != $qv['paged']) {
+ $this->is_paged = true;
+ }
+
+ if ('' != $qv['comments_popup']) {
+ $this->is_comments_popup = true;
+ }
+
+ //if we're previewing inside the write screen
+ if ('' != $qv['preview']) {
+ $this->is_preview = true;
+ }
+
+ if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) {
+ $this->is_admin = true;
+ }
+
+ if ( ! ($this->is_attachment || $this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) {
+ $this->is_home = true;
+ }
+
+ if ( !empty($query) ) {
+ do_action('parse_query', array(&$this));
+ }
+ }
+
+ function set_404() {
+ $this->init_query_flags();
+ $this->is_404 = true;
+ }
+
+ function get($query_var) {
+ if (isset($this->query_vars[$query_var])) {
+ return $this->query_vars[$query_var];
+ }
+
+ return '';
+ }
+
+ function set($query_var, $value) {
+ $this->query_vars[$query_var] = $value;
+ }
+
+ function &get_posts() {
+ global $wpdb, $pagenow, $user_ID;
+
+ do_action('pre_get_posts', array(&$this));
+
+ // Shorthand.
+ $q = &$this->query_vars;
+
+ // First let's clear some variables
+ $distinct = '';
+ $whichcat = '';
+ $whichauthor = '';
+ $whichpage = '';
+ $result = '';
+ $where = '';
+ $limits = '';
+ $join = '';
+
+ if ( !isset($q['post_type']) )
+ $q['post_type'] = 'post';
+ $post_type = $q['post_type'];
+ 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 ( $this->is_home && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) {
+ $this->is_page = true;
+ $this->is_home = false;
+ $q['page_id'] = get_option('page_on_front');
+ }
+
+ if (isset($q['page'])) {
+ $q['page'] = trim($q['page'], '/');
+ $q['page'] = (int) $q['page'];
+ }
+
+ $add_hours = intval(get_settings('gmt_offset'));
+ $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
+ $wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
+
+ // If a month is specified in the querystring, load that month
+ if ( (int) $q['m'] ) {
+ $q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']);
+ $where .= ' AND YEAR(post_date)=' . substr($q['m'], 0, 4);
+ if (strlen($q['m'])>5)
+ $where .= ' AND MONTH(post_date)=' . substr($q['m'], 4, 2);
+ if (strlen($q['m'])>7)
+ $where .= ' AND DAYOFMONTH(post_date)=' . substr($q['m'], 6, 2);
+ if (strlen($q['m'])>9)
+ $where .= ' AND HOUR(post_date)=' . substr($q['m'], 8, 2);
+ if (strlen($q['m'])>11)
+ $where .= ' AND MINUTE(post_date)=' . substr($q['m'], 10, 2);
+ if (strlen($q['m'])>13)
+ $where .= ' AND SECOND(post_date)=' . substr($q['m'], 12, 2);
+ }
+
+ if ( (int) $q['hour'] ) {
+ $q['hour'] = '' . intval($q['hour']);
+ $where .= " AND HOUR(post_date)='" . $q['hour'] . "'";
+ }
+
+ if ( (int) $q['minute'] ) {
+ $q['minute'] = '' . intval($q['minute']);
+ $where .= " AND MINUTE(post_date)='" . $q['minute'] . "'";
+ }
+
+ if ( (int) $q['second'] ) {
+ $q['second'] = '' . intval($q['second']);
+ $where .= " AND SECOND(post_date)='" . $q['second'] . "'";
+ }
+
+ if ( (int) $q['year'] ) {
+ $q['year'] = '' . intval($q['year']);
+ $where .= " AND YEAR(post_date)='" . $q['year'] . "'";
+ }
+
+ if ( (int) $q['monthnum'] ) {
+ $q['monthnum'] = '' . intval($q['monthnum']);
+ $where .= " AND MONTH(post_date)='" . $q['monthnum'] . "'";
+ }
+
+ if ( (int) $q['day'] ) {
+ $q['day'] = '' . intval($q['day']);
+ $where .= " AND DAYOFMONTH(post_date)='" . $q['day'] . "'";
+ }
+
+ // Compat. Map subpost to attachment.
+ if ( '' != $q['subpost'] )
+ $q['attachment'] = $q['subpost'];
+ if ( '' != $q['subpost_id'] )
+ $q['attachment_id'] = $q['subpost_id'];
+
+ if ('' != $q['name']) {
+ $q['name'] = sanitize_title($q['name']);
+ $where .= " AND post_name = '" . $q['name'] . "'";
+ } else if ('' != $q['pagename']) {
+ $reqpage = get_page_by_path($q['pagename']);
+ if ( !empty($reqpage) )
+ $reqpage = $reqpage->ID;
+ else
+ $reqpage = 0;
+
+ if ( ('page' == get_option('show_on_front') ) && ( $reqpage == get_option('page_for_posts') ) ) {
+ $this->is_page = false;
+ $this->is_home = true;
+ } else {
+ $q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename'])));
+ $page_paths = '/' . trim($q['pagename'], '/');
+ $q['pagename'] = sanitize_title(basename($page_paths));
+ $q['name'] = $q['pagename'];
+ $where .= " AND (ID = '$reqpage')";
+ }
+ } elseif ('' != $q['attachment']) {
+ $q['attachment'] = str_replace('%2F', '/', urlencode(urldecode($q['attachment'])));
+ $attach_paths = '/' . trim($q['attachment'], '/');
+ $q['attachment'] = sanitize_title(basename($attach_paths));
+ $q['name'] = $q['attachment'];
+ $where .= " AND post_name = '" . $q['attachment'] . "'";
+ }
+
+ if ( (int) $q['w'] ) {
+ $q['w'] = ''.intval($q['w']);
+ $where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'";
+ }
+
+ if ( intval($q['comments_popup']) )
+ $q['p'] = intval($q['comments_popup']);
+
+ // If a attachment is requested by number, let it supercede any post number.
+ if ( ($q['attachment_id'] != '') && (intval($q['attachment_id']) != 0) )
+ $q['p'] = (int) $q['attachment_id'];
+
+ // If a post number is specified, load that post
+ if (($q['p'] != '') && intval($q['p']) != 0) {
+ $q['p'] = (int) $q['p'];
+ $where = ' AND ID = ' . $q['p'];
+ }
+
+ if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) {
+ $q['page_id'] = intval($q['page_id']);
+ if ( ('page' == get_option('show_on_front') ) && ( $q['page_id'] == get_option('page_for_posts') ) ) {
+ $this->is_page = false;
+ $this->is_home = true;
+ } else {
+ $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']);
+ $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
+ $cat_array = preg_split('/[,\s]+/', $q['cat']);
+ $in_cats = $out_cats = '';
+ foreach ( $cat_array as $cat ) {
+ $in = strstr($cat, '-') ? false : true;
+ $cat = trim($cat, '-');
+ if ( $in )
+ $in_cats .= "$cat, " . get_category_children($cat, '', ', ');
+ else
+ $out_cats .= "$cat, " . get_category_children($cat, '', ', ');
+ }
+ $in_cats = substr($in_cats, 0, -2);
+ $out_cats = substr($out_cats, 0, -2);
+ if ( strlen($in_cats) > 0 )
+ $in_cats = " AND category_id IN ($in_cats)";
+ if ( strlen($out_cats) > 0 )
+ $out_cats = " AND category_id NOT IN ($out_cats)";
+ $whichcat = $in_cats . $out_cats;
+ $distinct = 'DISTINCT';
+ }
+
+ // Category stuff for nice URIs
+
+ global $cache_categories;
+ if ('' != $q['category_name']) {
+ $reqcat = get_category_by_path($q['category_name']);
+ $q['category_name'] = str_replace('%2F', '/', urlencode(urldecode($q['category_name'])));
+ $cat_paths = '/' . trim($q['category_name'], '/');
+ $q['category_name'] = sanitize_title(basename($cat_paths));
+
+ $cat_paths = '/' . trim(urldecode($q['category_name']), '/');
+ $q['category_name'] = sanitize_title(basename($cat_paths));
+ $cat_paths = explode('/', $cat_paths);
+ foreach($cat_paths as $pathdir)
+ $cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
+
+ //if we don't match the entire hierarchy fallback on just matching the nicename
+ if ( empty($reqcat) )
+ $reqcat = get_category_by_path($q['category_name'], false);
+
+ if ( !empty($reqcat) )
+ $reqcat = $reqcat->cat_ID;
+ else
+ $reqcat = 0;
+
+ $q['cat'] = $reqcat;
+
+ $tables = ", $wpdb->post2cat, $wpdb->categories";
+ $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
+ $whichcat = " AND category_id IN ({$q['cat']}, ";
+ $whichcat .= get_category_children($q['cat'], '', ', ');
+ $whichcat = substr($whichcat, 0, -2);
+ $whichcat .= ")";
+ $distinct = 'DISTINCT';
+ }
+
+ // 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'] = 'post_date '.$q['order'];
+ } else {
+ // Used to filter values
+ $allowed_keys = array('author', 'date', 'category', 'title', 'modified', 'menu_order');
+ $q['orderby'] = urldecode($q['orderby']);
+ $q['orderby'] = addslashes_gpc($q['orderby']);
+ $orderby_array = explode(' ',$q['orderby']);
+ if ( empty($orderby_array) )
+ $orderby_array[] = $q['orderby'];
+ $q['orderby'] = '';
+ for ($i = 0; $i < count($orderby_array); $i++) {
+ // Only allow certain values for safety
+ $orderby = $orderby_array[$i];
+ if ( 'menu_order' != $orderby )
+ $orderby = 'post_' . $orderby;
+ if ( in_array($orderby_array[$i], $allowed_keys) )
+ $q['orderby'] .= (($i == 0) ? '' : ',') . "$orderby {$q['order']}";
+ }
+ if ( empty($q['orderby']) )
+ $q['orderby'] = 'post_date '.$q['order'];
+ }
+
+ if ( $this->is_attachment ) {
+ $where .= ' AND (post_type = "attachment")';
+ } elseif ($this->is_page) {
+ $where .= ' AND (post_type = "page")';
+ } elseif ($this->is_single) {
+ $where .= ' AND (post_type = "post")';
+ } else {
+ $where .= " AND (post_type = '$post_type' AND (post_status = 'publish'";
+
+ if ( is_admin() )
+ $where .= " OR post_status = 'future' OR post_status = 'draft'";
+
+ if ( is_user_logged_in() )
+ $where .= " OR post_author = $user_ID AND post_status = 'private'))";
+ 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 && ! $this->is_page) {
+ $page = $q['paged'];
+ if (empty($page)) {
+ $page = 1;
+ }
+
+ if (($q['what_to_show'] == 'posts')) {
+ $pgstrt = '';
+ $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
+ $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
+ } elseif ($q['what_to_show'] == 'days') {
+ $startrow = $q['posts_per_page'] * (intval($page)-1);
+ $start_date = $wpdb->get_var("SELECT max(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $startrow,1");
+ $endrow = $startrow + $q['posts_per_page'] - 1;
+ $end_date = $wpdb->get_var("SELECT min(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $endrow,1");
+
+ if ($page > 1) {
+ $where .= " AND post_date >= '$end_date' AND post_date <= '$start_date'";
+ } else {
+ $where .= " AND post_date >= '$end_date'";
+ }
+ }
+ }
+
+ // Apply post-paging filters on where and join. Only plugins that
+ // manipulate paging queries should use these hooks.
+ $where = apply_filters('posts_where_paged', $where);
+ $groupby = '';
+ $groupby = apply_filters('posts_groupby', $groupby);
+ if ( ! empty($groupby) )
+ $groupby = 'GROUP BY ' . $groupby;
+ $join = apply_filters('posts_join_paged', $join);
+ $orderby = apply_filters('posts_orderby', $q['orderby']);
+ $distinct = apply_filters('posts_distinct', $distinct);
+ $fields = apply_filters('posts_fields', "$wpdb->posts.*");
+ $request = " SELECT $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby ORDER BY $orderby $limits";
+ $this->request = apply_filters('posts_request', $request);
+
+ $this->posts = $wpdb->get_results($this->request);
+
+ // Check post status to determine if post should be displayed.
+ if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) {
+ $status = get_post_status($this->posts[0]);
+ //$type = get_post_type($this->posts[0]);
+ if ( ('publish' != $status) ) {
+ if ( ! is_user_logged_in() ) {
+ // User must be logged in to view unpublished posts.
+ $this->posts = array();
+ } else {
+ if ('draft' == $status) {
+ // User must have edit permissions on the draft to preview.
+ if (! current_user_can('edit_post', $this->posts[0]->ID)) {
+ $this->posts = array();
+ } else {
+ $this->is_preview = true;
+ $this->posts[0]->post_date = current_time('mysql');
+ }
+ } else if ('future' == $status) {
+ $this->is_preview = true;
+ if (!current_user_can('edit_post', $this->posts[0]->ID)) {
+ $this->posts = array ( );
+ }
+ } else {
+ if (! current_user_can('read_post', $this->posts[0]->ID))
+ $this->posts = array();
+ }
+ }
+ }
+ }
+
+ update_post_caches($this->posts);
+
+ $this->posts = apply_filters('the_posts', $this->posts);
+ $this->post_count = count($this->posts);
+ if ($this->post_count > 0) {
+ $this->post = $this->posts[0];
+ }
+
+ return $this->posts;
+ }
+
+ function next_post() {
+
+ $this->current_post++;
+
+ $this->post = $this->posts[$this->current_post];
+ return $this->post;
+ }
+
+ function the_post() {
+ global $post;
+ $this->in_the_loop = true;
+ $post = $this->next_post();
+ setup_postdata($post);
+
+ if ( $this->current_post == 0 ) // loop has just started
+ do_action('loop_start');
+ }
+
+ function have_posts() {
+ if ($this->current_post + 1 < $this->post_count) {
+ return true;
+ } elseif ($this->current_post + 1 == $this->post_count) {
+ do_action('loop_end');
+ // Do some cleaning up after the loop
+ $this->rewind_posts();
+ }
+
+ $this->in_the_loop = false;
+ return false;
+ }
+
+ function rewind_posts() {
+ $this->current_post = -1;
+ if ($this->post_count > 0) {
+ $this->post = $this->posts[0];
+ }
+ }
+
+ function &query($query) {
+ $this->parse_query($query);
+ return $this->get_posts();
+ }
+
+ function get_queried_object() {
+ if (isset($this->queried_object)) {
+ return $this->queried_object;
+ }
+
+ $this->queried_object = NULL;
+ $this->queried_object_id = 0;
+
+ if ($this->is_category) {
+ $cat = $this->get('cat');
+ $category = &get_category($cat);
+ $this->queried_object = &$category;
+ $this->queried_object_id = $cat;
+ } else if ($this->is_single) {
+ $this->queried_object = $this->post;
+ $this->queried_object_id = $this->post->ID;
+ } else if ($this->is_page) {
+ $this->queried_object = $this->post;
+ $this->queried_object_id = $this->post->ID;
+ } else if ($this->is_author) {
+ $author_id = $this->get('author');
+ $author = get_userdata($author_id);
+ $this->queried_object = $author;
+ $this->queried_object_id = $author_id;
+ }
+
+ return $this->queried_object;
+ }
+
+ function get_queried_object_id() {
+ $this->get_queried_object();
+
+ if (isset($this->queried_object_id)) {
+ return $this->queried_object_id;
+ }
+
+ return 0;
+ }
+
+ function WP_Query ($query = '') {
+ if (! empty($query)) {
+ $this->query($query);
+ }
+ }
+}
+
+?>
diff --git a/wp-inst/wp-includes/registration-functions.php b/wp-inst/wp-includes/registration-functions.php
index 26f0a80..59849e3 100644
--- a/wp-inst/wp-includes/registration-functions.php
+++ b/wp-inst/wp-includes/registration-functions.php
@@ -13,9 +13,7 @@ function username_exists( $username ) {
function email_exists( $email ) {
global $wpdb;
$email = addslashes( $email );
- $email_exists = $wpdb->get_row("SELECT user_email FROM $wpdb->users WHERE user_email = '$email'");
- if ( $email_exists)
- return true;
+ return $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '$email'");
}
function validate_username( $username ) {
@@ -101,7 +99,7 @@ function wp_insert_user($userdata) {
}
function wp_update_user($userdata) {
- global $wpdb, $current_user;
+ global $wpdb;
$ID = (int) $userdata['ID'];
@@ -122,6 +120,7 @@ function wp_update_user($userdata) {
$user_id = wp_insert_user($userdata);
// Update the cookies if the password changed.
+ $current_user = wp_get_current_user();
if( $current_user->id == $ID ) {
if ( isset($plaintext_pass) ) {
wp_clearcookie();
diff --git a/wp-inst/wp-includes/rewrite.php b/wp-inst/wp-includes/rewrite.php
index 921a256..f46de2a 100644
--- a/wp-inst/wp-includes/rewrite.php
+++ b/wp-inst/wp-includes/rewrite.php
@@ -1,803 +1,888 @@
-<?php
-
-/* WP_Rewrite API
-*******************************************************************************/
-
-//Add a straight rewrite rule
-function add_rewrite_rule($regex, $redirect) {
- global $wp_rewrite;
- $wp_rewrite->add_rule($regex, $redirect);
-}
-
-//Add a new tag (like %postname%)
-//warning: you must call this on init or earlier, otherwise the query var addition stuff won't work
-function add_rewrite_tag($tagname, $regex) {
- //validation
- if (strlen($tagname) < 3 || $tagname{0} != '%' || $tagname{strlen($tagname)-1} != '%') {
- return;
- }
-
- $qv = trim($tagname, '%');
-
- global $wp_rewrite, $wp;
- $wp->add_query_var($qv);
- $wp_rewrite->add_rewrite_tag($tagname, $regex, $qv . '=');
-}
-
-//Add a new feed type like /atom1/
-function add_feed($feedname, $function) {
- global $wp_rewrite;
- if (!in_array($feedname, $wp_rewrite->feeds)) { //override the file if it is
- $wp_rewrite->feeds[] = $feedname;
- }
- $hook = 'do_feed_' . $feedname;
- remove_action($hook, $function, 10, 1);
- add_action($hook, $function, 10, 1);
- return $hook;
-}
-
-define('EP_PERMALINK', 1 );
-define('EP_ATTACHMENT', 2 );
-define('EP_DATE', 4 );
-define('EP_YEAR', 8 );
-define('EP_MONTH', 16 );
-define('EP_DAY', 32 );
-define('EP_ROOT', 64 );
-define('EP_COMMENTS', 128 );
-define('EP_SEARCH', 256 );
-define('EP_CATEGORIES', 512 );
-define('EP_AUTHORS', 1024);
-define('EP_PAGES', 2048);
-//pseudo-places
-define('EP_NONE', 0 );
-define('EP_ALL', 255);
-
-//and an endpoint, like /trackback/
-function add_rewrite_endpoint($name, $places) {
- global $wp_rewrite;
- $wp_rewrite->add_endpoint($name, $places);
-}
-
-/* WP_Rewrite class
-*******************************************************************************/
-
-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 $extra_rules; //those not generated by the class, see add_rewrite_rule()
- var $non_wp_rules; //rules that don't redirect to WP's index.php
- var $endpoints;
- var $use_verbose_rules = false;
- var $rewritecode =
- array(
- '%year%',
- '%monthnum%',
- '%day%',
- '%hour%',
- '%minute%',
- '%second%',
- '%postname%',
- '%post_id%',
- '%category%',
- '%author%',
- '%pagename%',
- '%search%'
- );
-
- var $rewritereplace =
- array(
- '([0-9]{4})',
- '([0-9]{1,2})',
- '([0-9]{1,2})',
- '([0-9]{1,2})',
- '([0-9]{1,2})',
- '([0-9]{1,2})',
- '([^/]+)',
- '([0-9]+)',
- '(.+?)',
- '([^/]+)',
- '([^/]+)',
- '(.+)'
- );
-
- var $queryreplace =
- array (
- 'year=',
- 'monthnum=',
- 'day=',
- 'hour=',
- 'minute=',
- 'second=',
- 'name=',
- 'p=',
- 'category_name=',
- 'author_name=',
- 'pagename=',
- 's='
- );
-
- var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
-
- function using_permalinks() {
- if (empty($this->permalink_structure))
- return false;
- else
- return true;
- }
-
- function using_index_permalinks() {
- if (empty($this->permalink_structure)) {
- return false;
- }
-
- // If the index is not in the permalink, we're using mod_rewrite.
- if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
- return true;
- }
-
- return false;
- }
-
- function using_mod_rewrite_permalinks() {
- if ( $this->using_permalinks() && ! $this->using_index_permalinks())
- return true;
- else
- return false;
- }
-
- function preg_index($number) {
- $match_prefix = '$';
- $match_suffix = '';
-
- if (! empty($this->matches)) {
- $match_prefix = '$' . $this->matches . '[';
- $match_suffix = ']';
- }
-
- return "$match_prefix$number$match_suffix";
- }
-
- function page_rewrite_rules() {
- $uris = get_settings('page_uris');
- $attachment_uris = get_settings('page_attachment_uris');
-
- $rewrite_rules = array();
- $page_structure = $this->get_page_permastruct();
- if( is_array( $attachment_uris ) ) {
- foreach ($attachment_uris as $uri => $pagename) {
- $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
- $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
- }
- }
- if( is_array( $uris ) ) {
- foreach ($uris as $uri => $pagename) {
- $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
- $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
- }
- }
-
- return $rewrite_rules;
- }
-
- function get_date_permastruct() {
- if (isset($this->date_structure)) {
- return $this->date_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->date_structure = '';
- return false;
- }
-
- // The date permalink must have year, month, and day separated by slashes.
- $endians = array('%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%');
-
- $this->date_structure = '';
- $date_endian = '';
-
- foreach ($endians as $endian) {
- if (false !== strpos($this->permalink_structure, $endian)) {
- $date_endian= $endian;
- break;
- }
- }
-
- if ( empty($date_endian) )
- $date_endian = '%year%/%monthnum%/%day%';
-
- // Do not allow the date tags and %post_id% to overlap in the permalink
- // structure. If they do, move the date tags to $front/date/.
- $front = $this->front;
- preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
- $tok_index = 1;
- foreach ($tokens[0] as $token) {
- if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
- $front = $front . 'date/';
- break;
- }
- }
-
- $this->date_structure = $front . $date_endian;
-
- return $this->date_structure;
- }
-
- function get_year_permastruct() {
- $structure = $this->get_date_permastruct($this->permalink_structure);
-
- if (empty($structure)) {
- return false;
- }
-
- $structure = str_replace('%monthnum%', '', $structure);
- $structure = str_replace('%day%', '', $structure);
-
- $structure = preg_replace('#/+#', '/', $structure);
-
- return $structure;
- }
-
- function get_month_permastruct() {
- $structure = $this->get_date_permastruct($this->permalink_structure);
-
- if (empty($structure)) {
- return false;
- }
-
- $structure = str_replace('%day%', '', $structure);
-
- $structure = preg_replace('#/+#', '/', $structure);
-
- return $structure;
- }
-
- function get_day_permastruct() {
- return $this->get_date_permastruct($this->permalink_structure);
- }
-
- function get_category_permastruct() {
- if (isset($this->category_structure)) {
- return $this->category_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->category_structure = '';
- return false;
- }
-
- if (empty($this->category_base))
- $this->category_structure = $this->front . 'category/';
- else
- $this->category_structure = $this->category_base . '/';
-
- $this->category_structure .= '%category%';
-
- return $this->category_structure;
- }
-
- function get_author_permastruct() {
- if (isset($this->author_structure)) {
- return $this->author_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->author_structure = '';
- return false;
- }
-
- $this->author_structure = $this->front . $this->author_base . '/%author%';
-
- return $this->author_structure;
- }
-
- function get_search_permastruct() {
- if (isset($this->search_structure)) {
- return $this->search_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->search_structure = '';
- return false;
- }
-
- $this->search_structure = $this->root . $this->search_base . '/%search%';
-
- return $this->search_structure;
- }
-
- function get_page_permastruct() {
- if (isset($this->page_structure)) {
- return $this->page_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->page_structure = '';
- return false;
- }
-
- $this->page_structure = $this->root . '%pagename%';
-
- return $this->page_structure;
- }
-
- function get_feed_permastruct() {
- if (isset($this->feed_structure)) {
- return $this->feed_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->feed_structure = '';
- return false;
- }
-
- $this->feed_structure = $this->root . $this->feed_base . '/%feed%';
-
- return $this->feed_structure;
- }
-
- function get_comment_feed_permastruct() {
- if (isset($this->comment_feed_structure)) {
- return $this->comment_feed_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->comment_feed_structure = '';
- return false;
- }
-
- $this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%';
-
- return $this->comment_feed_structure;
- }
-
- function add_rewrite_tag($tag, $pattern, $query) {
- // If the tag already exists, replace the existing pattern and query for
- // that tag, otherwise add the new tag, pattern, and query to the end of
- // the arrays.
- $position = array_search($tag, $this->rewritecode);
- if (FALSE !== $position && NULL !== $position) {
- $this->rewritereplace[$position] = $pattern;
- $this->queryreplace[$position] = $query;
- } else {
- $this->rewritecode[] = $tag;
- $this->rewritereplace[] = $pattern;
- $this->queryreplace[] = $query;
- }
- }
-
- //the main WP_Rewrite function. generate the rules from permalink structure
- function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
- //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
- $feedregex2 = '';
- foreach ($this->feeds as $feed_name) {
- $feedregex2 .= $feed_name . '|';
- }
- $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$';
- //$feedregex is identical but with /feed/ added on as well, so URLs like <permalink>/feed/atom
- //and <permalink>/atom are both possible
- $feedregex = $this->feed_base . '/' . $feedregex2;
-
- //build a regex to match the trackback and page/xx parts of URLs
- $trackbackregex = 'trackback/?$';
- $pageregex = 'page/?([0-9]{1,})/?$';
-
- //build up an array of endpoint regexes to append => queries to append
- if ($endpoints) {
- $ep_query_append = array ();
- foreach ($this->endpoints as $endpoint) {
- //match everything after the endpoint name, but allow for nothing to appear there
- $epmatch = $endpoint[1] . '(/(.*))?/?$';
- //this will be appended on to the rest of the query for each dir
- $epquery = '&' . $endpoint[1] . '=';
- $ep_query_append[$epmatch] = array ( $endpoint[0], $epquery );
- }
- }
-
- //get everything up to the first rewrite tag
- $front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
- //build an array of the tags (note that said array ends up being in $tokens[0])
- preg_match_all('/%.+?%/', $permalink_structure, $tokens);
-
- $num_tokens = count($tokens[0]);
-
- $index = $this->index; //probably 'index.php'
- $feedindex = $index;
- $trackbackindex = $index;
- //build a list from the rewritecode and queryreplace arrays, that will look something like
- //tagname=$matches[i] where i is the current $i
- 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;
- }
-
- //get the structure, minus any cruft (stuff that isn't tags) at the front
- $structure = $permalink_structure;
- if ($front != '/') {
- $structure = str_replace($front, '', $structure);
- }
- //create a list of dirs to walk over, making rewrite rules for each level
- //so for example, a $structure of /%year%/%month%/%postname% would create
- //rewrite rules for /%year%/, /%year%/%month%/ and /%year%/%month%/%postname%
- $structure = trim($structure, '/');
- if ($walk_dirs) {
- $dirs = explode('/', $structure);
- } else {
- $dirs[] = $structure;
- }
- $num_dirs = count($dirs);
-
- //strip slashes from the front of $front
- $front = preg_replace('|^/+|', '', $front);
-
- //the main workhorse loop
- $post_rewrite = array();
- $struct = $front;
- for ($j = 0; $j < $num_dirs; ++$j) {
- //get the struct for this dir, and trim slashes off the front
- $struct .= $dirs[$j] . '/'; //accumulate. see comment near explode('/', $structure) above
- $struct = ltrim($struct, '/');
- //replace tags with regexes
- $match = str_replace($this->rewritecode, $this->rewritereplace, $struct);
- //make a list of tags, and store how many there are in $num_toks
- $num_toks = preg_match_all('/%.+?%/', $struct, $toks);
- //get the 'tagname=$matches[i]'
- $query = $queries[$num_toks - 1];
-
- //set up $ep_mask_specific which is used to match more specific URL types
- switch ($dirs[$j]) {
- case '%year%': $ep_mask_specific = EP_YEAR; break;
- case '%monthnum%': $ep_mask_specific = EP_MONTH; break;
- case '%day%': $ep_mask_specific = EP_DAY; break;
- }
-
- //create query for /page/xx
- $pagematch = $match . $pageregex;
- $pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1);
-
- //create query for /feed/(feed|atom|rss|rss2|rdf)
- $feedmatch = $match . $feedregex;
- $feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
-
- //create query for /(feed|atom|rss|rss2|rdf) (see comment near creation of $feedregex)
- $feedmatch2 = $match . $feedregex2;
- $feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
-
- //if asked to, turn the feed queries into comment feed ones
- if ($forcomments) {
- $feedquery .= '&withcomments=1';
- $feedquery2 .= '&withcomments=1';
- }
-
- //start creating the array of rewrites for this dir
- $rewrite = array();
- if ($feed) //...adding on /feed/ regexes => queries
- $rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
- if ($paged) //...and /page/xx ones
- $rewrite = array_merge($rewrite, array($pagematch => $pagequery));
-
- //if we've got some tags in this dir
- if ($num_toks) {
- $post = false;
- $page = false;
-
- //check to see if this dir is permalink-level: i.e. the structure specifies an
- //individual post. Do this by checking it contains at least one of 1) post name,
- //2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and
- //minute all present). Set these flags now as we need them for the endpoints.
- if (strstr($struct, '%postname%') || strstr($struct, '%post_id%')
- || strstr($struct, '%pagename%')
- || (strstr($struct, '%year%') && strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) {
- $post = true;
- if ( strstr($struct, '%pagename%') )
- $page = true;
- }
-
- //do endpoints
- if ($endpoints) {
- foreach ($ep_query_append as $regex => $ep) {
- //add the endpoints on if the mask fits
- if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
- $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
- }
- }
- }
-
- //if we're creating rules for a permalink, do all the endpoints like attachments etc
- if ($post) {
- $post = true;
- //create query and regex for trackback
- $trackbackmatch = $match . $trackbackregex;
- $trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
- //trim slashes from the end of the regex for this dir
- $match = rtrim($match, '/');
- //get rid of brackets
- $submatchbase = str_replace(array('(',')'),'',$match);
-
- //add a rule for at attachments, which take the form of <permalink>/some-text
- $sub1 = $submatchbase . '/([^/]+)/';
- $sub1tb = $sub1 . $trackbackregex; //add trackback regex <permalink>/trackback/...
- $sub1feed = $sub1 . $feedregex; //and <permalink>/feed/(atom|...)
- $sub1feed2 = $sub1 . $feedregex2; //and <permalink>/(feed|atom...)
- //add an ? as we don't have to match that last slash, and finally a $ so we
- //match to the end of the URL
-
- //add another rule to match attachments in the explicit form:
- //<permalink>/attachment/some-text
- $sub2 = $submatchbase . '/attachment/([^/]+)/';
- $sub2tb = $sub2 . $trackbackregex; //and add trackbacks <permalink>/attachment/trackback
- $sub2feed = $sub2 . $feedregex; //feeds, <permalink>/attachment/feed/(atom|...)
- $sub2feed2 = $sub2 . $feedregex2; //and feeds again on to this <permalink>/attachment/(feed|atom...)
-
- //create queries for these extra tag-ons we've just dealt with
- $subquery = $index . '?attachment=' . $this->preg_index(1);
- $subtbquery = $subquery . '&tb=1';
- $subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
-
- //do endpoints for attachments
- if ($endpoint) { foreach ($ep_query_append as $regex => $ep) {
- if ($ep[0] & EP_ATTACHMENT) {
- $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
- $rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
- }
- } }
-
- //now we've finished with endpoints, finish off the $sub1 and $sub2 matches
- $sub1 .= '?$';
- $sub2 .= '?$';
-
- //allow URLs like <permalink>/2 for <permalink>/page/2
- $match = $match . '(/[0-9]+)?/?$';
- $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
- } else { //not matching a permalink so this is a lot simpler
- //close the match and finalise the query
- $match .= '?$';
- $query = $index . '?' . $query;
- }
-
- //create the final array for this dir by joining the $rewrite array (which currently
- //only contains rules/queries for trackback, pages etc) to the main regex/query for
- //this dir
- $rewrite = array_merge($rewrite, array($match => $query));
-
- //if we're matching a permalink, add those extras (attachments etc) on
- if ($post) {
- //add trackback
- $rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite);
-
- //add regexes/queries for attachments, attachment trackbacks and so on
- if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
- $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery));
- $rewrite = array_merge($rewrite, array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery));
- }
- } //if($num_toks)
- //add the rules for this dir to the accumulating $post_rewrite
- $post_rewrite = array_merge($rewrite, $post_rewrite);
- } //foreach ($dir)
- return $post_rewrite; //the finished rules. phew!
- }
-
- function generate_rewrite_rule($permalink_structure, $walk_dirs = false) {
- return $this->generate_rewrite_rules($permalink_structure, EP_NONE, 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, EP_PERMALINK);
- $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
-
- // Date
- $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE);
- $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
-
- // Root
- $root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT);
- $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
-
- // Comments
- $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, true, true, true, false);
- $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
-
- // Search
- $search_structure = $this->get_search_permastruct();
- $search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH);
- $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
-
- // Categories
- $category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct(), EP_CATEGORIES);
- $category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite);
-
- // Authors
- $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
- $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
-
- // Pages
- $page_rewrite = $this->page_rewrite_rules();
- $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
-
- // Put them together.
- $this->rules = array_merge($page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
-
- do_action('generate_rewrite_rules', array(&$this));
- $this->rules = apply_filters('rewrite_rules_array', $this->rules);
-
- return $this->rules;
- }
-
- function wp_rewrite_rules() {
- $this->rules = get_option('rewrite_rules');
- if ( empty($this->rules) ) {
- $this->matches = 'matches';
- $this->rewrite_rules();
- update_option('rewrite_rules', $this->rules);
- }
-
- return $this->rules;
- }
-
- function mod_rewrite_rules() {
- if ( ! $this->using_permalinks()) {
- return '';
- }
-
- $site_root = parse_url(get_settings('siteurl'));
- $site_root = trailingslashit($site_root['path']);
-
- $home_root = parse_url(get_settings('home'));
- $home_root = trailingslashit($home_root['path']);
-
- $rules = "<IfModule mod_rewrite.c>\n";
- $rules .= "RewriteEngine On\n";
- $rules .= "RewriteBase $home_root\n";
-
- //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
- foreach ($this->non_wp_rules 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.
- }
-
- $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
- }
-
- if ($this->use_verbose_rules) {
- $this->matches = '';
- $rewrite = $this->rewrite_rules();
- $num_rules = count($rewrite);
- $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
- "RewriteCond %{REQUEST_FILENAME} -d\n" .
- "RewriteRule ^.*$ - [S=$num_rules]\n";
-
- foreach ($rewrite as $match => $query) {
- // Apache 1.3 does not support the reluctant (non-greedy) modifier.
- $match = str_replace('.+?', '.+', $match);
-
- // If the match is unanchored and greedy, prepend rewrite conditions
- // to avoid infinite redirects and eclipsing of real files.
- if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
- //nada.
- }
-
- if (strstr($query, $this->index)) {
- $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
- } else {
- $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
- }
- }
- } else {
- $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
- "RewriteCond %{REQUEST_FILENAME} !-d\n" .
- "RewriteRule . {$home_root}{$this->index} [L]\n";
- }
-
- $rules .= "</IfModule>\n";
-
- $rules = apply_filters('mod_rewrite_rules', $rules);
- $rules = apply_filters('rewrite_rules', $rules); // Deprecated
-
- return $rules;
- }
-
- //Add a straight rewrite rule
- function add_rule($regex, $redirect) {
- //get everything up to the first ?
- $index = (strpos($redirect, '?') == false ? strlen($redirect) : strpos($redirect, '?'));
- $front = substr($redirect, 0, $index);
- if ($front != $this->index) { //it doesn't redirect to WP's index.php
- $this->add_external_rule($regex, $redirect);
- } else {
- $this->extra_rules[$regex] = $redirect;
- }
- }
-
- //add a rule that doesn't redirect to index.php
- function add_external_rule($regex, $redirect) {
- $this->non_wp_rules[$regex] = $redirect;
- }
-
- //add an endpoint, like /trackback/, to be inserted after certain URL types (specified in $places)
- function add_endpoint($name, $places) {
- global $wp;
- $this->endpoints[] = array ( $places, $name );
- $wp->add_query_var($name);
- }
-
- function flush_rules() {
- generate_page_uri_index();
- delete_option('rewrite_rules');
- $this->wp_rewrite_rules();
- if ( function_exists('save_mod_rewrite_rules') )
- save_mod_rewrite_rules();
- }
-
- function init() {
- $this->extra_rules = $this->non_wp_rules = $this->endpoints = array();
- $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();
- }
-}
-
-?> \ No newline at end of file
+<?php
+
+/* WP_Rewrite API
+*******************************************************************************/
+
+//Add a straight rewrite rule
+function add_rewrite_rule($regex, $redirect) {
+ global $wp_rewrite;
+ $wp_rewrite->add_rule($regex, $redirect);
+}
+
+//Add a new tag (like %postname%)
+//warning: you must call this on init or earlier, otherwise the query var addition stuff won't work
+function add_rewrite_tag($tagname, $regex) {
+ //validation
+ if (strlen($tagname) < 3 || $tagname{0} != '%' || $tagname{strlen($tagname)-1} != '%') {
+ return;
+ }
+
+ $qv = trim($tagname, '%');
+
+ global $wp_rewrite, $wp;
+ $wp->add_query_var($qv);
+ $wp_rewrite->add_rewrite_tag($tagname, $regex, $qv . '=');
+}
+
+//Add a new feed type like /atom1/
+function add_feed($feedname, $function) {
+ global $wp_rewrite;
+ if (!in_array($feedname, $wp_rewrite->feeds)) { //override the file if it is
+ $wp_rewrite->feeds[] = $feedname;
+ }
+ $hook = 'do_feed_' . $feedname;
+ remove_action($hook, $function, 10, 1);
+ add_action($hook, $function, 10, 1);
+ return $hook;
+}
+
+define('EP_PERMALINK', 1 );
+define('EP_ATTACHMENT', 2 );
+define('EP_DATE', 4 );
+define('EP_YEAR', 8 );
+define('EP_MONTH', 16 );
+define('EP_DAY', 32 );
+define('EP_ROOT', 64 );
+define('EP_COMMENTS', 128 );
+define('EP_SEARCH', 256 );
+define('EP_CATEGORIES', 512 );
+define('EP_AUTHORS', 1024);
+define('EP_PAGES', 2048);
+//pseudo-places
+define('EP_NONE', 0 );
+define('EP_ALL', 255);
+
+//and an endpoint, like /trackback/
+function add_rewrite_endpoint($name, $places) {
+ global $wp_rewrite;
+ $wp_rewrite->add_endpoint($name, $places);
+}
+
+// examine a url (supposedly from this blog) and try to
+// determine the post ID it represents.
+function url_to_postid($url) {
+ global $wp_rewrite;
+
+ // First, check to see if there is a 'p=N' or 'page_id=N' to match against
+ preg_match('#[?&](p|page_id)=(\d+)#', $url, $values);
+ $id = intval($values[2]);
+ if ( $id ) return $id;
+
+ // Check to see if we are using rewrite rules
+ $rewrite = $wp_rewrite->wp_rewrite_rules();
+
+ // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
+ if ( empty($rewrite) )
+ return 0;
+
+ // $url cleanup by Mark Jaquith
+ // This fixes things like #anchors, ?query=strings, missing 'www.',
+ // added 'www.', or added 'index.php/' that will mess up our WP_Query
+ // and return a false negative
+
+ // Get rid of the #anchor
+ $url_split = explode('#', $url);
+ $url = $url_split[0];
+
+ // Get rid of URI ?query=string
+ $url_split = explode('?', $url);
+ $url = $url_split[0];
+
+ // Add 'www.' if it is absent and should be there
+ if ( false !== strpos(get_settings('home'), '://www.') && false === strpos($url, '://www.') )
+ $url = str_replace('://', '://www.', $url);
+
+ // Strip 'www.' if it is present and shouldn't be
+ if ( false === strpos(get_settings('home'), '://www.') )
+ $url = str_replace('://www.', '://', $url);
+
+ // Strip 'index.php/' if we're not using path info permalinks
+ if ( false === strpos($rewrite, 'index.php/') )
+ $url = str_replace('index.php/', '', $url);
+
+ if ( false !== strpos($url, get_settings('home')) ) {
+ // Chop off http://domain.com
+ $url = str_replace(get_settings('home'), '', $url);
+ } else {
+ // Chop off /path/to/blog
+ $home_path = parse_url(get_settings('home'));
+ $home_path = $home_path['path'];
+ $url = str_replace($home_path, '', $url);
+ }
+
+ // Trim leading and lagging slashes
+ $url = trim($url, '/');
+
+ $request = $url;
+
+ // Done with cleanup
+
+ // Look for matches.
+ $request_match = $request;
+ foreach ($rewrite as $match => $query) {
+ // If the requesting file is the anchor of the match, prepend it
+ // to the path info.
+ if ( (! empty($url)) && (strpos($match, $url) === 0) ) {
+ $request_match = $url . '/' . $request;
+ }
+
+ if ( preg_match("!^$match!", $request_match, $matches) ) {
+ // Got a match.
+ // Trim the query of everything up to the '?'.
+ $query = preg_replace("!^.+\?!", '', $query);
+
+ // Substitute the substring matches into the query.
+ eval("\$query = \"$query\";");
+ $query = new WP_Query($query);
+ if ( $query->is_single || $query->is_page )
+ return $query->post->ID;
+ else
+ return 0;
+ }
+ }
+ return 0;
+}
+
+/* WP_Rewrite class
+*******************************************************************************/
+
+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 $extra_rules; //those not generated by the class, see add_rewrite_rule()
+ var $non_wp_rules; //rules that don't redirect to WP's index.php
+ var $endpoints;
+ var $use_verbose_rules = false;
+ var $rewritecode =
+ array(
+ '%year%',
+ '%monthnum%',
+ '%day%',
+ '%hour%',
+ '%minute%',
+ '%second%',
+ '%postname%',
+ '%post_id%',
+ '%category%',
+ '%author%',
+ '%pagename%',
+ '%search%'
+ );
+
+ var $rewritereplace =
+ array(
+ '([0-9]{4})',
+ '([0-9]{1,2})',
+ '([0-9]{1,2})',
+ '([0-9]{1,2})',
+ '([0-9]{1,2})',
+ '([0-9]{1,2})',
+ '([^/]+)',
+ '([0-9]+)',
+ '(.+?)',
+ '([^/]+)',
+ '([^/]+)',
+ '(.+)'
+ );
+
+ var $queryreplace =
+ array (
+ 'year=',
+ 'monthnum=',
+ 'day=',
+ 'hour=',
+ 'minute=',
+ 'second=',
+ 'name=',
+ 'p=',
+ 'category_name=',
+ 'author_name=',
+ 'pagename=',
+ 's='
+ );
+
+ var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
+
+ function using_permalinks() {
+ if (empty($this->permalink_structure))
+ return false;
+ else
+ return true;
+ }
+
+ function using_index_permalinks() {
+ if (empty($this->permalink_structure)) {
+ return false;
+ }
+
+ // If the index is not in the permalink, we're using mod_rewrite.
+ if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ function using_mod_rewrite_permalinks() {
+ if ( $this->using_permalinks() && ! $this->using_index_permalinks())
+ return true;
+ else
+ return false;
+ }
+
+ function preg_index($number) {
+ $match_prefix = '$';
+ $match_suffix = '';
+
+ if (! empty($this->matches)) {
+ $match_prefix = '$' . $this->matches . '[';
+ $match_suffix = ']';
+ }
+
+ return "$match_prefix$number$match_suffix";
+ }
+
+ function page_rewrite_rules() {
+ $uris = get_settings('page_uris');
+ $attachment_uris = get_settings('page_attachment_uris');
+
+ $rewrite_rules = array();
+ $page_structure = $this->get_page_permastruct();
+ if( is_array( $attachment_uris ) ) {
+ foreach ($attachment_uris as $uri => $pagename) {
+ $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
+ $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
+ }
+ }
+ if( is_array( $uris ) ) {
+ foreach ($uris as $uri => $pagename) {
+ $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
+ $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
+ }
+ }
+
+ return $rewrite_rules;
+ }
+
+ function get_date_permastruct() {
+ if (isset($this->date_structure)) {
+ return $this->date_structure;
+ }
+
+ if (empty($this->permalink_structure)) {
+ $this->date_structure = '';
+ return false;
+ }
+
+ // The date permalink must have year, month, and day separated by slashes.
+ $endians = array('%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%');
+
+ $this->date_structure = '';
+ $date_endian = '';
+
+ foreach ($endians as $endian) {
+ if (false !== strpos($this->permalink_structure, $endian)) {
+ $date_endian= $endian;
+ break;
+ }
+ }
+
+ if ( empty($date_endian) )
+ $date_endian = '%year%/%monthnum%/%day%';
+
+ // Do not allow the date tags and %post_id% to overlap in the permalink
+ // structure. If they do, move the date tags to $front/date/.
+ $front = $this->front;
+ preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
+ $tok_index = 1;
+ foreach ($tokens[0] as $token) {
+ if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
+ $front = $front . 'date/';
+ break;
+ }
+ }
+
+ $this->date_structure = $front . $date_endian;
+
+ return $this->date_structure;
+ }
+
+ function get_year_permastruct() {
+ $structure = $this->get_date_permastruct($this->permalink_structure);
+
+ if (empty($structure)) {
+ return false;
+ }
+
+ $structure = str_replace('%monthnum%', '', $structure);
+ $structure = str_replace('%day%', '', $structure);
+
+ $structure = preg_replace('#/+#', '/', $structure);
+
+ return $structure;
+ }
+
+ function get_month_permastruct() {
+ $structure = $this->get_date_permastruct($this->permalink_structure);
+
+ if (empty($structure)) {
+ return false;
+ }
+
+ $structure = str_replace('%day%', '', $structure);
+
+ $structure = preg_replace('#/+#', '/', $structure);
+
+ return $structure;
+ }
+
+ function get_day_permastruct() {
+ return $this->get_date_permastruct($this->permalink_structure);
+ }
+
+ function get_category_permastruct() {
+ if (isset($this->category_structure)) {
+ return $this->category_structure;
+ }
+
+ if (empty($this->permalink_structure)) {
+ $this->category_structure = '';
+ return false;
+ }
+
+ if (empty($this->category_base))
+ $this->category_structure = $this->front . 'tag/';
+ 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;
+ }
+ }
+
+ //the main WP_Rewrite function. generate the rules from permalink structure
+ function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
+ //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
+ $feedregex2 = '';
+ foreach ($this->feeds as $feed_name) {
+ $feedregex2 .= $feed_name . '|';
+ }
+ $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$';
+ //$feedregex is identical but with /feed/ added on as well, so URLs like <permalink>/feed/atom
+ //and <permalink>/atom are both possible
+ $feedregex = $this->feed_base . '/' . $feedregex2;
+
+ //build a regex to match the trackback and page/xx parts of URLs
+ $trackbackregex = 'trackback/?$';
+ $pageregex = 'page/?([0-9]{1,})/?$';
+
+ //build up an array of endpoint regexes to append => queries to append
+ if ($endpoints) {
+ $ep_query_append = array ();
+ foreach ($this->endpoints as $endpoint) {
+ //match everything after the endpoint name, but allow for nothing to appear there
+ $epmatch = $endpoint[1] . '(/(.*))?/?$';
+ //this will be appended on to the rest of the query for each dir
+ $epquery = '&' . $endpoint[1] . '=';
+ $ep_query_append[$epmatch] = array ( $endpoint[0], $epquery );
+ }
+ }
+
+ //get everything up to the first rewrite tag
+ $front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
+ //build an array of the tags (note that said array ends up being in $tokens[0])
+ preg_match_all('/%.+?%/', $permalink_structure, $tokens);
+
+ $num_tokens = count($tokens[0]);
+
+ $index = $this->index; //probably 'index.php'
+ $feedindex = $index;
+ $trackbackindex = $index;
+ //build a list from the rewritecode and queryreplace arrays, that will look something like
+ //tagname=$matches[i] where i is the current $i
+ 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;
+ }
+
+ //get the structure, minus any cruft (stuff that isn't tags) at the front
+ $structure = $permalink_structure;
+ if ($front != '/') {
+ $structure = str_replace($front, '', $structure);
+ }
+ //create a list of dirs to walk over, making rewrite rules for each level
+ //so for example, a $structure of /%year%/%month%/%postname% would create
+ //rewrite rules for /%year%/, /%year%/%month%/ and /%year%/%month%/%postname%
+ $structure = trim($structure, '/');
+ if ($walk_dirs) {
+ $dirs = explode('/', $structure);
+ } else {
+ $dirs[] = $structure;
+ }
+ $num_dirs = count($dirs);
+
+ //strip slashes from the front of $front
+ $front = preg_replace('|^/+|', '', $front);
+
+ //the main workhorse loop
+ $post_rewrite = array();
+ $struct = $front;
+ for ($j = 0; $j < $num_dirs; ++$j) {
+ //get the struct for this dir, and trim slashes off the front
+ $struct .= $dirs[$j] . '/'; //accumulate. see comment near explode('/', $structure) above
+ $struct = ltrim($struct, '/');
+ //replace tags with regexes
+ $match = str_replace($this->rewritecode, $this->rewritereplace, $struct);
+ //make a list of tags, and store how many there are in $num_toks
+ $num_toks = preg_match_all('/%.+?%/', $struct, $toks);
+ //get the 'tagname=$matches[i]'
+ $query = $queries[$num_toks - 1];
+
+ //set up $ep_mask_specific which is used to match more specific URL types
+ switch ($dirs[$j]) {
+ case '%year%': $ep_mask_specific = EP_YEAR; break;
+ case '%monthnum%': $ep_mask_specific = EP_MONTH; break;
+ case '%day%': $ep_mask_specific = EP_DAY; break;
+ }
+
+ //create query for /page/xx
+ $pagematch = $match . $pageregex;
+ $pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1);
+
+ //create query for /feed/(feed|atom|rss|rss2|rdf)
+ $feedmatch = $match . $feedregex;
+ $feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
+
+ //create query for /(feed|atom|rss|rss2|rdf) (see comment near creation of $feedregex)
+ $feedmatch2 = $match . $feedregex2;
+ $feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
+
+ //if asked to, turn the feed queries into comment feed ones
+ if ($forcomments) {
+ $feedquery .= '&withcomments=1';
+ $feedquery2 .= '&withcomments=1';
+ }
+
+ //start creating the array of rewrites for this dir
+ $rewrite = array();
+ if ($feed) //...adding on /feed/ regexes => queries
+ $rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
+ if ($paged) //...and /page/xx ones
+ $rewrite = array_merge($rewrite, array($pagematch => $pagequery));
+
+ //if we've got some tags in this dir
+ if ($num_toks) {
+ $post = false;
+ $page = false;
+
+ //check to see if this dir is permalink-level: i.e. the structure specifies an
+ //individual post. Do this by checking it contains at least one of 1) post name,
+ //2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and
+ //minute all present). Set these flags now as we need them for the endpoints.
+ if (strstr($struct, '%postname%') || strstr($struct, '%post_id%')
+ || strstr($struct, '%pagename%')
+ || (strstr($struct, '%year%') && strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) {
+ $post = true;
+ if ( strstr($struct, '%pagename%') )
+ $page = true;
+ }
+
+ //do endpoints
+ if ($endpoints) {
+ foreach ($ep_query_append as $regex => $ep) {
+ //add the endpoints on if the mask fits
+ if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
+ $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
+ }
+ }
+ }
+
+ //if we're creating rules for a permalink, do all the endpoints like attachments etc
+ if ($post) {
+ $post = true;
+ //create query and regex for trackback
+ $trackbackmatch = $match . $trackbackregex;
+ $trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
+ //trim slashes from the end of the regex for this dir
+ $match = rtrim($match, '/');
+ //get rid of brackets
+ $submatchbase = str_replace(array('(',')'),'',$match);
+
+ //add a rule for at attachments, which take the form of <permalink>/some-text
+ $sub1 = $submatchbase . '/([^/]+)/';
+ $sub1tb = $sub1 . $trackbackregex; //add trackback regex <permalink>/trackback/...
+ $sub1feed = $sub1 . $feedregex; //and <permalink>/feed/(atom|...)
+ $sub1feed2 = $sub1 . $feedregex2; //and <permalink>/(feed|atom...)
+ //add an ? as we don't have to match that last slash, and finally a $ so we
+ //match to the end of the URL
+
+ //add another rule to match attachments in the explicit form:
+ //<permalink>/attachment/some-text
+ $sub2 = $submatchbase . '/attachment/([^/]+)/';
+ $sub2tb = $sub2 . $trackbackregex; //and add trackbacks <permalink>/attachment/trackback
+ $sub2feed = $sub2 . $feedregex; //feeds, <permalink>/attachment/feed/(atom|...)
+ $sub2feed2 = $sub2 . $feedregex2; //and feeds again on to this <permalink>/attachment/(feed|atom...)
+
+ //create queries for these extra tag-ons we've just dealt with
+ $subquery = $index . '?attachment=' . $this->preg_index(1);
+ $subtbquery = $subquery . '&tb=1';
+ $subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
+
+ //do endpoints for attachments
+ if ($endpoint) { foreach ($ep_query_append as $regex => $ep) {
+ if ($ep[0] & EP_ATTACHMENT) {
+ $rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
+ $rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
+ }
+ } }
+
+ //now we've finished with endpoints, finish off the $sub1 and $sub2 matches
+ $sub1 .= '?$';
+ $sub2 .= '?$';
+
+ //allow URLs like <permalink>/2 for <permalink>/page/2
+ $match = $match . '(/[0-9]+)?/?$';
+ $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
+ } else { //not matching a permalink so this is a lot simpler
+ //close the match and finalise the query
+ $match .= '?$';
+ $query = $index . '?' . $query;
+ }
+
+ //create the final array for this dir by joining the $rewrite array (which currently
+ //only contains rules/queries for trackback, pages etc) to the main regex/query for
+ //this dir
+ $rewrite = array_merge($rewrite, array($match => $query));
+
+ //if we're matching a permalink, add those extras (attachments etc) on
+ if ($post) {
+ //add trackback
+ $rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite);
+
+ //add regexes/queries for attachments, attachment trackbacks and so on
+ if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
+ $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery));
+ $rewrite = array_merge($rewrite, array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery));
+ }
+ } //if($num_toks)
+ //add the rules for this dir to the accumulating $post_rewrite
+ $post_rewrite = array_merge($rewrite, $post_rewrite);
+ } //foreach ($dir)
+ return $post_rewrite; //the finished rules. phew!
+ }
+
+ function generate_rewrite_rule($permalink_structure, $walk_dirs = false) {
+ return $this->generate_rewrite_rules($permalink_structure, EP_NONE, 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, EP_PERMALINK);
+ $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
+
+ // Date
+ $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE);
+ $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
+
+ // Root
+ $root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT);
+ $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
+
+ // Comments
+ $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, true, true, true, false);
+ $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
+
+ // Search
+ $search_structure = $this->get_search_permastruct();
+ $search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH);
+ $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
+
+ // Categories
+ $category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct(), EP_CATEGORIES);
+ $category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite);
+
+ // Authors
+ $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
+ $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
+
+ // Pages
+ $page_rewrite = $this->page_rewrite_rules();
+ $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
+
+ // Put them together.
+ $this->rules = array_merge($page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
+
+ do_action('generate_rewrite_rules', array(&$this));
+ $this->rules = apply_filters('rewrite_rules_array', $this->rules);
+
+ return $this->rules;
+ }
+
+ function wp_rewrite_rules() {
+ $this->rules = get_option('rewrite_rules');
+ if ( empty($this->rules) ) {
+ $this->matches = 'matches';
+ $this->rewrite_rules();
+ update_option('rewrite_rules', $this->rules);
+ }
+
+ return $this->rules;
+ }
+
+ function mod_rewrite_rules() {
+ if ( ! $this->using_permalinks()) {
+ return '';
+ }
+
+ $site_root = parse_url(get_settings('siteurl'));
+ $site_root = trailingslashit($site_root['path']);
+
+ $home_root = parse_url(get_settings('home'));
+ $home_root = trailingslashit($home_root['path']);
+
+ $rules = "<IfModule mod_rewrite.c>\n";
+ $rules .= "RewriteEngine On\n";
+ $rules .= "RewriteBase $home_root\n";
+
+ //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
+ foreach ($this->non_wp_rules 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.
+ }
+
+ $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
+ }
+
+ if ($this->use_verbose_rules) {
+ $this->matches = '';
+ $rewrite = $this->rewrite_rules();
+ $num_rules = count($rewrite);
+ $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
+ "RewriteCond %{REQUEST_FILENAME} -d\n" .
+ "RewriteRule ^.*$ - [S=$num_rules]\n";
+
+ foreach ($rewrite as $match => $query) {
+ // Apache 1.3 does not support the reluctant (non-greedy) modifier.
+ $match = str_replace('.+?', '.+', $match);
+
+ // If the match is unanchored and greedy, prepend rewrite conditions
+ // to avoid infinite redirects and eclipsing of real files.
+ if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
+ //nada.
+ }
+
+ if (strstr($query, $this->index)) {
+ $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
+ } else {
+ $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
+ }
+ }
+ } else {
+ $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
+ "RewriteCond %{REQUEST_FILENAME} !-d\n" .
+ "RewriteRule . {$home_root}{$this->index} [L]\n";
+ }
+
+ $rules .= "</IfModule>\n";
+
+ $rules = apply_filters('mod_rewrite_rules', $rules);
+ $rules = apply_filters('rewrite_rules', $rules); // Deprecated
+
+ return $rules;
+ }
+
+ //Add a straight rewrite rule
+ function add_rule($regex, $redirect) {
+ //get everything up to the first ?
+ $index = (strpos($redirect, '?') == false ? strlen($redirect) : strpos($redirect, '?'));
+ $front = substr($redirect, 0, $index);
+ if ($front != $this->index) { //it doesn't redirect to WP's index.php
+ $this->add_external_rule($regex, $redirect);
+ } else {
+ $this->extra_rules[$regex] = $redirect;
+ }
+ }
+
+ //add a rule that doesn't redirect to index.php
+ function add_external_rule($regex, $redirect) {
+ $this->non_wp_rules[$regex] = $redirect;
+ }
+
+ //add an endpoint, like /trackback/, to be inserted after certain URL types (specified in $places)
+ function add_endpoint($name, $places) {
+ global $wp;
+ $this->endpoints[] = array ( $places, $name );
+ $wp->add_query_var($name);
+ }
+
+ function flush_rules() {
+ generate_page_uri_index();
+ delete_option('rewrite_rules');
+ $this->wp_rewrite_rules();
+ if ( function_exists('save_mod_rewrite_rules') )
+ save_mod_rewrite_rules();
+ }
+
+ function init() {
+ $this->extra_rules = $this->non_wp_rules = $this->endpoints = array();
+ $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();
+ }
+}
+
+?>
diff --git a/wp-inst/wp-includes/rss-functions.php b/wp-inst/wp-includes/rss-functions.php
index 0c37c5a..94aa1d7 100644
--- a/wp-inst/wp-includes/rss-functions.php
+++ b/wp-inst/wp-includes/rss-functions.php
@@ -373,6 +373,11 @@ class MagpieRSS {
}
}
+
+function map_attrs($k, $v) {
+ return "$k=\"$v\"";
+}
+
require_once( dirname(__FILE__) . '/class-snoopy.php');
function fetch_rss ($url) {
@@ -384,6 +389,13 @@ function fetch_rss ($url) {
return false;
}
+ $parts = parse_url($url);
+ if ( strstr($parts['host'], 'wordpress.com') && !preg_match('!/(feed|atom|rss|rss2)/?$|/feed/(feed|atom|rss|rss2)/?$|\.xml$!i', $parts['path']) )
+ $url = trim($url, '/') . '/feed/';
+
+ if ( $rss = wp_cache_get($url, 'rss') )
+ return $rss;
+
// if cache is disabled
if ( !MAGPIE_CACHE_ON ) {
// fetch file, and parse it
@@ -464,6 +476,7 @@ function fetch_rss ($url) {
}
// add object to cache
$cache->set( $url, $rss );
+ wp_cache_set($url, $rss, 'rss', 3600);
return $rss;
}
}
@@ -478,10 +491,12 @@ function fetch_rss ($url) {
else {
$errormsg .= "(HTTP Response: " . $resp->response_code .')';
}
+ wp_cache_set($url, $errormsg, 'rss', 3600);
}
}
else {
$errormsg = "Unable to retrieve RSS file for unknown reasons.";
+ wp_cache_set($url, $errormsg, 'rss', 3600);
}
// else fetch failed
@@ -491,6 +506,7 @@ function fetch_rss ($url) {
if ( MAGPIE_DEBUG ) {
debug("Returning STALE object for $url");
}
+ wp_cache_set($url, $rss, 'rss', 7200);
return $rss;
}
@@ -505,6 +521,7 @@ function fetch_rss ($url) {
function _fetch_remote_file ($url, $headers = "" ) {
// Snoopy is an HTTP client in PHP
$client = new Snoopy();
+ $client->referer = 'http'.($_SERVER['HTTPS']?'s':'').'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$client->agent = MAGPIE_USER_AGENT;
$client->read_timeout = MAGPIE_FETCH_TIME_OUT;
$client->use_gzip = MAGPIE_USE_GZIP;
@@ -660,20 +677,15 @@ class RSSCache {
\*=======================================================================*/
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 meta_key FROM $wpdb->sitemeta WHERE meta_key = '$cache_option'") )
- add_site_option($cache_option, '');
- if ( !$wpdb->get_var("SELECT meta_key FROM $wpdb->sitemeta WHERE meta_key = '$cache_timestamp'") )
- add_site_option($cache_timestamp, '');
-
- update_site_option($cache_option, $rss);
- update_site_option($cache_timestamp, time() );
-
- return $cache_option;
- }
+ $file = $this->file_name( $url );
+ $f = fopen( $file, 'w' );
+ fwrite( $f, serialize( $rss ) );
+ fclose( $f );
+
+ return true;
+ }
+
/*=======================================================================*\
Function: get
Purpose: fetch an item from the cache
@@ -682,17 +694,17 @@ class RSSCache {
\*=======================================================================*/
function get ($url) {
$this->ERROR = "";
- $cache_option = 'rss_' . $this->file_name( $url );
-
- if ( ! get_site_option( $cache_option ) ) {
+ $file = $this->file_name( $url );
+
+ if ( ! $contents = file_get_contents( $file ) ) {
$this->debug(
"Cache doesn't contain: $url (cache option: $cache_option)"
);
return 0;
}
-
- $rss = get_site_option( $cache_option );
-
+
+ $rss = unserialize( $contents );
+
return $rss;
}
@@ -705,26 +717,23 @@ class RSSCache {
\*=======================================================================*/
function check_cache ( $url ) {
$this->ERROR = "";
- $cache_option = $this->file_name( $url );
- $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
+ $file = $this->file_name( $url );
+
+ if ( !file_exists( $file ) )
+ return 'MISS';
- if ( $mtime = get_site_option($cache_timestamp) ) {
+ if ( $mtime = filemtime($file) ) {
// 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 {
+ } else {
// object exists but is old
return 'STALE';
}
}
- else {
- // object does not exist
- return 'MISS';
- }
}
/*=======================================================================*\
@@ -748,7 +757,7 @@ class RSSCache {
Output: a file name
\*=======================================================================*/
function file_name ($url) {
- return md5( $url );
+ return '/home/wpcom/cache/rss/' . md5( $url );
}
/*=======================================================================*\
diff --git a/wp-inst/wp-includes/template-functions-bookmarks.php b/wp-inst/wp-includes/template-functions-bookmarks.php
index 3ec3364..e74b494 100644
--- a/wp-inst/wp-includes/template-functions-bookmarks.php
+++ b/wp-inst/wp-includes/template-functions-bookmarks.php
@@ -1,389 +1,389 @@
-<?php
-
-/** 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) )
- return;
-
- if ( false === strpos($args, '=') ) {
- $cat_id = $args;
- $args = add_query_arg('category', $cat_id, $args);
- }
-
- 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 its 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
- ** echo (default true) - whether to echo the results, or return them instead
- */
-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;
-
- $order = 'ASC';
- if (substr($orderby, 0, 1) == '_') {
- $order = 'DESC';
- $orderby = substr($orderby, 1);
- }
-
- if ($category == -1) { //get_bookmarks uses '' to signify all categories
- $category = '';
- }
-
- $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit");
-
- 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 . '"' . $rel . $title . $target. '>';
-
- 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_linkrating($link) {
- return apply_filters('link_rating', $link->link_rating);
-}
-
-/** 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) {
- if ( empty($id) )
- return '';
-
- $cats = wp_get_link_cats($id);
-
- if ( empty($cats) || ! is_array($cats) )
- return '';
-
- $cat_id = $cats[0]; // Take the first cat.
-
- $cat = get_category($cat_id);
- return $cat->cat_name;
-}
-
-/** 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') {
- $order = strtolower($order);
-
- // Handle link category sorting
- $direction = 'ASC';
- if (substr($order,0,1) == '_') {
- $direction = 'DESC';
- $order = substr($order,1);
- }
-
- if (!isset($direction)) $direction = '';
-
- $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0");
-
- // Display each category
- if ($cats) {
- foreach ($cats as $cat) {
- // Handle each category.
-
- // Display the category name
- echo ' <li id="linkcat-' . $cat->cat_ID . '"><h2>' . $cat->cat_name . "</h2>\n\t<ul>\n";
- // Call get_links() with all the appropriate params
- get_links($cat->cat_ID,
- '<li>',"</li>","\n");
-
- // Close the last category
- echo "\n\t</ul>\n</li>\n";
- }
- }
-}
-
-function wp_list_bookmarks($args = '') {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => 0, 'category' => 0,
- 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' =>1,
- 'categorize' => 1, 'title_li' => __('Bookmarks'));
- $r = array_merge($defaults, $r);
- extract($r);
-
- // TODO: The rest of it.
- // If $categorize, group links by category with the category name being the
- // title of each li, otherwise just list them with title_li as the li title.
- // If $categorize and $category or $category_name, list links for the given category
- // with the category name as the title li. If not $categorize, use title_li.
- // When using each category's name as a title li, use before and after args for specifying
- // any markup. We don't want to hardcode h2.
-}
-
-function get_bookmarks($args = '') {
- global $wpdb;
-
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '',
- 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => '');
- $r = array_merge($defaults, $r);
- extract($r);
-
- $inclusions = '';
- if ( !empty($include) ) {
- $exclude = ''; //ignore exclude, category, and category_name params if using include
- $category = '';
- $category_name = '';
- $inclinks = preg_split('/[\s,]+/',$include);
- if ( count($inclinks) ) {
- foreach ( $inclinks as $inclink ) {
- if (empty($inclusions))
- $inclusions = ' AND ( link_id = ' . intval($inclink) . ' ';
- else
- $inclusions .= ' OR link_id = ' . intval($inclink) . ' ';
- }
- }
- }
- if (!empty($inclusions))
- $inclusions .= ')';
-
- $exclusions = '';
- if ( !empty($exclude) ) {
- $exlinks = preg_split('/[\s,]+/',$exclude);
- if ( count($exlinks) ) {
- foreach ( $exlinks as $exlink ) {
- if (empty($exclusions))
- $exclusions = ' AND ( link_id <> ' . intval($exlink) . ' ';
- else
- $exclusions .= ' AND link_id <> ' . intval($exlink) . ' ';
- }
- }
- }
- if (!empty($exclusions))
- $exclusions .= ')';
-
- if ( ! empty($category_name) ) {
- if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") )
- $category = $cat_id;
- }
-
- $category_query = '';
- $join = '';
- if ( !empty($category) ) {
- $incategories = preg_split('/[\s,]+/',$category);
- if ( count($incategories) ) {
- foreach ( $incategories as $incat ) {
- if (empty($category_query))
- $category_query = ' AND ( category_id = ' . intval($incat) . ' ';
- else
- $category_query .= ' OR category_id = ' . intval($incat) . ' ';
- }
- }
- }
- if (!empty($category_query)) {
- $category_query .= ')';
- $join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) ";
- }
-
- 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);
- $length = '';
- switch ($orderby) {
- case 'length':
- $length = ", CHAR_LENGTH(link_name) AS length";
- break;
- case 'rand':
- $orderby = 'rand()';
- break;
- default:
- $orderby = "link_" . $orderby;
- }
-
- if ( 'link_id' == $orderby )
- $orderby = "$wpdb->links.link_id";
-
- $visible = '';
- if ( $hide_invisible )
- $visible = "AND link_visible = 'Y'";
-
- $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
- $query .= " $exclusions $inclusions";
- $query .= " ORDER BY $orderby $order";
- if ($limit != -1)
- $query .= " LIMIT $limit";
-
- $results = $wpdb->get_results($query);
- return apply_filters('get_bookmarks', $results, $r);
-}
+<?php
+
+/** 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) )
+ return;
+
+ if ( false === strpos($args, '=') ) {
+ $cat_id = $args;
+ $args = add_query_arg('category', $cat_id, $args);
+ }
+
+ 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 its 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
+ ** echo (default true) - whether to echo the results, or return them instead
+ */
+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;
+
+ $order = 'ASC';
+ if (substr($orderby, 0, 1) == '_') {
+ $order = 'DESC';
+ $orderby = substr($orderby, 1);
+ }
+
+ if ($category == -1) { //get_bookmarks uses '' to signify all categories
+ $category = '';
+ }
+
+ $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit");
+
+ 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 . '"' . $rel . $title . $target. '>';
+
+ 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_linkrating($link) {
+ return apply_filters('link_rating', $link->link_rating);
+}
+
+/** 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) {
+ if ( empty($id) )
+ return '';
+
+ $cats = wp_get_link_cats($id);
+
+ if ( empty($cats) || ! is_array($cats) )
+ return '';
+
+ $cat_id = $cats[0]; // Take the first cat.
+
+ $cat = get_category($cat_id);
+ return $cat->cat_name;
+}
+
+/** 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') {
+ $order = strtolower($order);
+
+ // Handle link category sorting
+ $direction = 'ASC';
+ if (substr($order,0,1) == '_') {
+ $direction = 'DESC';
+ $order = substr($order,1);
+ }
+
+ if (!isset($direction)) $direction = '';
+
+ $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0");
+
+ // Display each category
+ if ($cats) {
+ foreach ($cats as $cat) {
+ // Handle each category.
+
+ // Display the category name
+ echo ' <li id="linkcat-' . $cat->cat_ID . '"><h2>' . $cat->cat_name . "</h2>\n\t<ul>\n";
+ // Call get_links() with all the appropriate params
+ get_links($cat->cat_ID,
+ '<li>',"</li>","\n", true, 'name', false);
+
+ // Close the last category
+ echo "\n\t</ul>\n</li>\n";
+ }
+ }
+}
+
+function wp_list_bookmarks($args = '') {
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => 0, 'category' => 0,
+ 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' =>1,
+ 'categorize' => 1, 'title_li' => __('Bookmarks'));
+ $r = array_merge($defaults, $r);
+ extract($r);
+
+ // TODO: The rest of it.
+ // If $categorize, group links by category with the category name being the
+ // title of each li, otherwise just list them with title_li as the li title.
+ // If $categorize and $category or $category_name, list links for the given category
+ // with the category name as the title li. If not $categorize, use title_li.
+ // When using each category's name as a title li, use before and after args for specifying
+ // any markup. We don't want to hardcode h2.
+}
+
+function get_bookmarks($args = '') {
+ global $wpdb;
+
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '',
+ 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => '');
+ $r = array_merge($defaults, $r);
+ extract($r);
+
+ $inclusions = '';
+ if ( !empty($include) ) {
+ $exclude = ''; //ignore exclude, category, and category_name params if using include
+ $category = '';
+ $category_name = '';
+ $inclinks = preg_split('/[\s,]+/',$include);
+ if ( count($inclinks) ) {
+ foreach ( $inclinks as $inclink ) {
+ if (empty($inclusions))
+ $inclusions = ' AND ( link_id = ' . intval($inclink) . ' ';
+ else
+ $inclusions .= ' OR link_id = ' . intval($inclink) . ' ';
+ }
+ }
+ }
+ if (!empty($inclusions))
+ $inclusions .= ')';
+
+ $exclusions = '';
+ if ( !empty($exclude) ) {
+ $exlinks = preg_split('/[\s,]+/',$exclude);
+ if ( count($exlinks) ) {
+ foreach ( $exlinks as $exlink ) {
+ if (empty($exclusions))
+ $exclusions = ' AND ( link_id <> ' . intval($exlink) . ' ';
+ else
+ $exclusions .= ' AND link_id <> ' . intval($exlink) . ' ';
+ }
+ }
+ }
+ if (!empty($exclusions))
+ $exclusions .= ')';
+
+ if ( ! empty($category_name) ) {
+ if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") )
+ $category = $cat_id;
+ }
+
+ $category_query = '';
+ $join = '';
+ if ( !empty($category) ) {
+ $incategories = preg_split('/[\s,]+/',$category);
+ if ( count($incategories) ) {
+ foreach ( $incategories as $incat ) {
+ if (empty($category_query))
+ $category_query = ' AND ( category_id = ' . intval($incat) . ' ';
+ else
+ $category_query .= ' OR category_id = ' . intval($incat) . ' ';
+ }
+ }
+ }
+ if (!empty($category_query)) {
+ $category_query .= ')';
+ $join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) ";
+ }
+
+ 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);
+ $length = '';
+ switch ($orderby) {
+ case 'length':
+ $length = ", CHAR_LENGTH(link_name) AS length";
+ break;
+ case 'rand':
+ $orderby = 'rand()';
+ break;
+ default:
+ $orderby = "link_" . $orderby;
+ }
+
+ if ( 'link_id' == $orderby )
+ $orderby = "$wpdb->links.link_id";
+
+ $visible = '';
+ if ( $hide_invisible )
+ $visible = "AND link_visible = 'Y'";
+
+ $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
+ $query .= " $exclusions $inclusions";
+ $query .= " ORDER BY $orderby $order";
+ if ($limit != -1)
+ $query .= " LIMIT $limit";
+
+ $results = $wpdb->get_results($query);
+ return apply_filters('get_bookmarks', $results, $r);
+}
?> \ 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
index 1c9e4a2..a269e69 100644
--- a/wp-inst/wp-includes/template-functions-category.php
+++ b/wp-inst/wp-includes/template-functions-category.php
@@ -1,5 +1,17 @@
<?php
+function walk_category_tree() {
+ $walker = new Walker_Category;
+ $args = func_get_args();
+ return call_user_func_array(array(&$walker, 'walk'), $args);
+}
+
+function walk_category_dropdown_tree() {
+ $walker = new Walker_CategoryDropdown;
+ $args = func_get_args();
+ return call_user_func_array(array(&$walker, 'walk'), $args);
+}
+
function get_the_category($id = false) {
global $post, $category_cache;
@@ -141,32 +153,6 @@ function get_category_children($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 )
@@ -175,251 +161,206 @@ function category_description($category = 0) {
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";
+function wp_dropdown_categories($args = '') {
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('show_option_all' => '', 'show_option_none' => '', 'orderby' => 'ID',
+ 'order' => 'ASC', 'show_last_update' => 0, 'show_count' => 0,
+ 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1,
+ 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat',
+ 'class' => 'postform');
+ $r = array_merge($defaults, $r);
+ $r['include_last_update_time'] = $r['show_last_update'];
+ extract($r);
+
+ $categories = get_categories($r);
+
+ $output = '';
+ if ( ! empty($categories) ) {
+ $output = "<select name='$name' class='$class'>\n";
+
+ if ( $show_option_all ) {
+ $show_option_all = apply_filters('list_cats', $show_option_all);
+ $output .= "\t<option value='0'>$show_option_all</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, $wp_query;
- // Optiondates now works
- if ( '' == $file )
- $file = get_settings('home') . '/';
- $exclusions = '';
- if ( !empty($exclude) ) {
- $excats = preg_split('/[\s,]+/',$exclude);
- if ( count($excats) ) {
- foreach ( $excats as $excat ) {
- $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
- }
+ if ( $show_option_none) {
+ $show_option_none = apply_filters('list_cats', $show_option_none);
+ $output .= "\t<option value='-1'>$show_option_none</option>\n";
}
- }
- $exclusions = apply_filters('list_cats_exclusions', $exclusions );
+ if ( $hierarchical )
+ $depth = 0; // Walk the full depth.
+ else
+ $depth = -1; // Flat.
- if ( intval($categories) == 0 ) {
- $sort_column = 'cat_'.$sort_column;
-
- $query = "
- SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, category_count
- FROM $wpdb->categories
- WHERE cat_ID > 0 $exclusions
- ORDER BY $sort_column $sort_order";
-
- $cached_results = wp_cache_get( md5( $query ), 'general');
- if ( is_array( $cached_results ) == false || ( is_array( $cached_results ) == true && ( get_option( 'categories_last_updated' ) != false && $cached_results[ 'time' ] < get_option( 'categories_last_updated' ) ) ) ) {
- $categories = $wpdb->get_results($query);
- wp_cache_set( md5( $query ), array( 'results' => $categories, 'time' => time() ), 'general', 360 );
- } else {
- $categories = $cached_results[ 'results' ];
- }
- $cached_results = wp_cache_get( md5( $query), 'general');
- $categories = $cached_results[ 'results' ];
- if ( !$categories ) {
- $categories = $wpdb->get_results($query);
- wp_cache_set( md5( $query ), array( 'results' => $categories, 'time' => time() ), 'general', 360);
- }
+ $output .= walk_category_dropdown_tree($categories, $depth, $r);
+ $output .= "</select>\n";
}
- if ( $optiondates ) {
- $cat_dates = $wpdb->get_results(" SELECT category_id,
- UNIX_TIMESTAMP( MAX(post_date) ) AS ts
- FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories
- WHERE post_type = 'post' AND 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;
- }
- }
+ $output = apply_filters('wp_dropdown_cats', $output);
- $num_found=0;
- $thelist = "";
-
- foreach ( $categories as $category ) {
- if ( ( intval($hide_empty) == 0 || $category->category_count) && (!$hierarchical || $category->category_parent == $child_of) ) {
- $num_found++;
- $link = '<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)) ) {
+ if ( $echo )
+ echo $output;
- $link .= ' ';
+ return $output;
+}
- if ( empty($feed_image) )
- $link .= '(';
+function wp_list_categories($args = '') {
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('show_option_all' => '', 'orderby' => 'ID',
+ 'order' => 'asc', 'style' => 'list', 'show_last_update' => 0,
+ 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1,
+ 'child_of' => 0, 'feed' => '', 'feed_image' => '', 'exclude' => '',
+ 'hierarchical' => true, 'title_li' => '');
+ $r = array_merge($defaults, $r);
+ $r['include_last_update_time'] = $r['show_date'];
+ extract($r);
+
+ $categories = get_categories($r);
+
+ $output = '';
+ if ( $title_li && $list )
+ $output = '<li class="categories">' . $r['title_li'] . '<ul>';
+
+ if ( empty($categories) ) {
+ if ( $list)
+ $output .= '<li>' . __("No categories") . '</li>';
+ else
+ $output .= __("No categories");
+ } else {
+ global $wp_query;
+ $r['current_category'] = $wp_query->get_queried_object_id();
+ if ( $hierarchical )
+ $depth = 0; // Walk the full depth.
+ else
+ $depth = -1; // Flat.
+
+ $output .= walk_category_tree($categories, $depth, $r);
+ }
- $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
+ if ( $title_li && $list )
+ $output .= '</ul></li>';
+
+ echo apply_filters('list_cats', $output);
+}
- if ( !empty($feed) ) {
- $title = ' title="' . $feed . '"';
- $alt = ' alt="' . $feed . '"';
- $name = $feed;
- $link .= $title;
- }
+function in_category($category) { // Check if the current post is in the given category
+ global $category_cache, $post;
- $link .= '>';
+ if ( isset( $category_cache[$post->ID][$category] ) )
+ return true;
+ else
+ return false;
+}
- if ( !empty($feed_image) )
- $link .= "<img src='$feed_image' $alt$title" . ' />';
- else
- $link .= $name;
+function &_get_cat_children($category_id, $categories) {
+ if ( empty($categories) )
+ return array();
- $link .= '</a>';
+ $category_list = array();
+ foreach ( $categories as $category ) {
+ if ( $category->category_parent == $category_id ) {
+ $category_list[] = $category;
+ if ( $children = _get_cat_children($category->cat_ID, $categories) )
+ $category_list = array_merge($category_list, $children);
+ }
+ }
- if (empty($feed_image))
- $link .= ')';
- }
+ return $category_list;
+}
- if ( intval($optioncount) == 1 )
- $link .= ' ('.intval($category->category_count).')';
+function &get_categories($args = '') {
+ global $wpdb, $category_links;
- if ( $optiondates ) {
- if ( $optiondates == 1 )
- $optiondates = 'Y-m-d';
- $link .= ' ' . gmdate($optiondates, $category_timestamp["$category->cat_ID"]);
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC',
+ 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, $exclude => '', $include => '');
+ $r = array_merge($defaults, $r);
+ $r['orderby'] = "cat_" . $r['orderby']; // restricts order by to cat_ID and cat_name fields
+ extract($r);
+
+ $where = 'cat_ID > 0';
+ $inclusions = '';
+ if ( !empty($include) ) {
+ $child_of = 0; //ignore child_of and exclude params if using include
+ $exclude = '';
+ $incategories = preg_split('/[\s,]+/',$include);
+ if ( count($incategories) ) {
+ foreach ( $incategories as $incat ) {
+ if (empty($inclusions))
+ $inclusions = ' AND ( cat_ID = ' . intval($incat) . ' ';
+ else
+ $inclusions .= ' OR cat_ID = ' . intval($incat) . ' ';
}
+ }
+ }
+ if (!empty($inclusions))
+ $inclusions .= ')';
+ $where .= $inclusions;
- if ( $list ) {
- $thelist .= "\t<li";
- if (($category->cat_ID == $wp_query->get_queried_object_id()) && is_category()) {
- $thelist .= ' class="current-cat"';
- }
- $thelist .= ">$link\n";
- } else {
- $thelist .= "\t$link<br />\n";
+ $exclusions = '';
+ if ( !empty($exclude) ) {
+ $excategories = preg_split('/[\s,]+/',$exclude);
+ if ( count($excategories) ) {
+ foreach ( $excategories as $excat ) {
+ if (empty($exclusions))
+ $exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' ';
+ else
+ $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
+ // TODO: Exclude children of excluded cats? Note: children are getting excluded
}
-
- 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 (!empty($exclusions))
+ $exclusions .= ')';
+ $exclusions = apply_filters('list_cats_exclusions', $exclusions );
+ $where .= $exclusions;
+
+ $having = '';
+ if ( $hide_empty ) {
+ if ( 'link' == $type )
+ $having = 'HAVING link_count > 0';
+ else
+ $having = 'HAVING category_count > 0';
}
- if ( $list && $child_of && $num_found && $recurse ) {
- $pre = "\t\t<ul class='children'>";
- $post = "\t\t</ul>\n";
- } else {
- $pre = $post = '';
+
+ $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where $having ORDER BY $orderby $order");
+
+ if ( empty($categories) )
+ return array();
+
+ // TODO: Integrate this into the main query.
+ if ( $include_last_update_time ) {
+ $stamps = $wpdb->get_results("SELECT category_id, UNIX_TIMESTAMP( MAX(post_date) ) AS ts FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories
+ WHERE post_status = 'publish' AND post_id = ID AND $where GROUP BY category_id");
+ global $cat_stamps;
+ foreach ($stamps as $stamp)
+ $cat_stamps[$stamp->category_id] = $stamp->ts;
+ function stamp_cat($cat) {
+ global $cat_stamps;
+ $cat->last_update_timestamp = $cat_stamps[$cat->cat_ID];
+ return $cat;
+ }
+ $categories = array_map('stamp_cat', $categories);
+ unset($cat_stamps);
}
- $thelist = $pre . $thelist . $post;
- if ( $recurse )
- return $thelist;
- echo apply_filters('list_cats', $thelist);
-}
-function in_category($category) { // Check if the current post is in the given category
- global $category_cache, $post;
+ if ( $child_of || $hierarchical )
+ $categories = & _get_cat_children($child_of, $categories);
- if ( isset( $category_cache[$post->ID][$category] ) )
- return true;
- else
- return false;
+ return apply_filters('get_categories', $categories);
}
?>
diff --git a/wp-inst/wp-includes/template-functions-general.php b/wp-inst/wp-includes/template-functions-general.php
index fd91eff..ef74e9b 100644
--- a/wp-inst/wp-includes/template-functions-general.php
+++ b/wp-inst/wp-includes/template-functions-general.php
@@ -27,10 +27,7 @@ function get_sidebar() {
function wp_loginout() {
- global $user_ID;
- get_currentuserinfo();
-
- if ('' == $user_ID)
+ if ( ! is_user_logged_in() )
$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>';
@@ -40,16 +37,15 @@ function wp_loginout() {
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
+ if ( ! is_user_logged_in() ) {
+ if ( get_settings('users_can_register') )
+ $link = $before . '<a href="' . get_settings('siteurl') . '/wp-register.php">' . __('Register') . '</a>' . $after;
+ else
+ $link = '';
+ } else {
$link = $before . '<a href="' . get_settings('siteurl') . '/wp-admin/">' . __('Site Admin') . '</a>' . $after;
+ }
echo apply_filters('register', $link);
}
@@ -62,7 +58,9 @@ function wp_meta() {
function bloginfo($show='') {
$info = get_bloginfo($show);
- if ( ! (strstr($info, 'url') || strstr($info, 'directory')) ) {
+ if (!strstr($show, 'url') && //don't filter URLs
+ !strstr($show, 'directory') &&
+ !strstr($show, 'home')) {
$info = apply_filters('bloginfo', $info, $show);
$info = convert_chars($info);
}
@@ -138,7 +136,7 @@ function get_bloginfo($show='') {
function wp_title($sep = '&raquo;', $display = true) {
global $wpdb;
- global $m, $year, $monthnum, $day, $category_name, $month, $posts;
+ global $m, $year, $monthnum, $day, $category_name, $wp_locale, $posts;
$cat = get_query_var('cat');
$p = get_query_var('p');
@@ -177,14 +175,14 @@ function wp_title($sep = '&raquo;', $display = true) {
// If there's a month
if ( !empty($m) ) {
$my_year = substr($m, 0, 4);
- $my_month = $month[substr($m, 4, 2)];
+ $my_month = $wp_locale->get_month($m);
$title = "$my_year $sep $my_month";
}
if ( !empty($year) ) {
$title = $year;
if ( !empty($monthnum) )
- $title .= " $sep ".$month[zeroise($monthnum, 2)];
+ $title .= " $sep ".$wp_locale->get_month($monthnum);
if ( !empty($day) )
$title .= " $sep ".zeroise($day, 2);
}
@@ -244,13 +242,13 @@ function single_cat_title($prefix = '', $display = true ) {
function single_month_title($prefix = '', $display = true ) {
- global $m, $monthnum, $month, $year;
+ global $m, $monthnum, $wp_locale, $year;
if ( !empty($monthnum) && !empty($year) ) {
$my_year = $year;
- $my_month = $month[str_pad($monthnum, 2, '0', STR_PAD_LEFT)];
+ $my_month = $wp_locale->get_month($monthnum);
} elseif ( !empty($m) ) {
$my_year = substr($m, 0, 4);
- $my_month = $month[substr($m, 4, 2)];
+ $my_month = $wp_locale->get_month($m);
}
if ( !empty($my_month) && $display )
@@ -296,7 +294,7 @@ function wp_get_archives($args = '') {
function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
- global $month, $wpdb;
+ global $wp_locale, $wpdb;
if ( '' == $type )
$type = 'monthly';
@@ -338,10 +336,10 @@ function get_archives($type='', $limit='', $format='html', $before = '', $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);
+ $text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year);
$after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
} else {
- $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
+ $text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year);
}
echo get_archives_link($url, $text, $format, $before, $after);
}
@@ -401,8 +399,8 @@ function calendar_week_mod($num) {
}
-function get_calendar($daylength = 1) {
- global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;
+function get_calendar($initial = true) {
+ global $wpdb, $m, $monthnum, $year, $timedifference, $wp_locale, $posts;
// Quick check. If we have no posts at all, abort!
if ( !$posts ) {
@@ -458,22 +456,19 @@ function get_calendar($daylength = 1) {
LIMIT 1");
echo '<table id="wp-calendar">
- <caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>
+ <caption>' . $wp_locale->get_month($thismonth) . ' ' . 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];
+ $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
}
foreach ( $myweek as $wd ) {
- echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $day_abbrev[$wd] . '</th>';
+ $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
+ echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
}
echo '
@@ -484,9 +479,9 @@ function get_calendar($daylength = 1) {
<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>';
+ echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .
+ get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month),
+ date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
} else {
echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
}
@@ -494,9 +489,9 @@ function get_calendar($daylength = 1) {
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="' . sprintf(__('View posts for %1$s %2$s'), $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>';
+ echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .
+ get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month),
+ date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>';
} else {
echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
}
@@ -683,19 +678,19 @@ function get_post_modified_time( $d = 'U', $gmt = false ) { // returns timestamp
function the_weekday() {
- global $weekday, $id, $post;
- $the_weekday = $weekday[mysql2date('w', $post->post_date)];
+ global $wp_locale, $id, $post;
+ $the_weekday = $wp_locale->get_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;
+ global $wp_locale, $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 .= $wp_locale->get_weekday(mysql2date('w', $post->post_date));
$the_weekday_date .= $after;
$previousweekday = $day;
}
@@ -708,8 +703,9 @@ function rsd_link() {
}
function noindex() {
+ global $current_blog;
// If the blog is not public, tell robots to go away.
- if ( ! get_option('blog_public') )
+ if ( 0 == $current_blog->public )
echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
}
?>
diff --git a/wp-inst/wp-includes/template-functions-links.php b/wp-inst/wp-includes/template-functions-links.php
index 5432c73..16126b1 100644
--- a/wp-inst/wp-includes/template-functions-links.php
+++ b/wp-inst/wp-includes/template-functions-links.php
@@ -92,7 +92,7 @@ function get_page_link($id = false) {
$pagestruct = $wp_rewrite->get_page_permastruct();
- if ( '' != $pagestruct ) {
+ if ( '' != $pagestruct && 'draft' != $post->post_status ) {
$link = get_page_uri($id);
$link = str_replace('%pagename%', $link, $pagestruct);
$link = get_settings('home') . "/$link/";
@@ -228,12 +228,13 @@ function edit_post_link($link = 'Edit This', $before = '', $after = '') {
function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
global $post, $comment;
- if( $post->post_type == 'page' )
+ if( $post->post_type == 'page' ){
if ( ! current_user_can('edit_page', $post->ID) )
return;
- else
+ } else {
if ( ! current_user_can('edit_post', $post->ID) )
return;
+ }
$location = get_settings('siteurl') . "/wp-admin/comment.php?action=editcomment&amp;comment=$comment->comment_ID";
echo $before . "<a href='$location'>$link</a>" . $after;
@@ -343,49 +344,6 @@ function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat =
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 ( 'yes' == $title )
- $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 ( 'yes' == $title )
- $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;
@@ -469,16 +427,9 @@ function next_posts($max_page = 0) { // original by cfactor at cooltux.org
}
function next_posts_link($label='Next Page &raquo;', $max_page=0) {
- global $paged, $result, $request, $posts_per_page, $wpdb, $max_num_pages;
+ global $paged, $wpdb;
if ( !$max_page ) {
- if ( isset($max_num_pages) ) {
- $max_page = $max_num_pages;
- } else {
- preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
- $fromwhere = $matches[1];
- $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
- $max_page = $max_num_pages = ceil($numposts / $posts_per_page);
- }
+ $max_page = _max_num_pages();
}
if ( !$paged )
$paged = 1;
@@ -512,25 +463,41 @@ function previous_posts_link($label='&laquo; Previous Page') {
}
}
+function _max_num_pages() {
+ static $max_num_pages;
+ global $wpdb, $wp_query;
+
+ if (isset($max_num_pages)) return $max_num_pages;
+
+ if ( 'posts' == get_query_var('what_to_show') ) {
+ preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
+ $fromwhere = $matches[1];
+ $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
+ $max_num_pages = ceil($numposts / get_option('posts_per_page'));
+ } else {
+ preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
+ $fromwhere = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]);
+ $num_days = $wpdb->query("SELECT DISTINCT post_date FROM $fromwhere GROUP BY year(post_date), month(post_date), dayofmonth(post_date)");
+ $max_num_pages = ceil($num_days / get_option('posts_per_page'));
+ }
+
+ return $max_num_pages;
+}
+
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 ( 'posts' == get_query_var('what_to_show') ) {
- if ( !isset($max_num_pages) ) {
- preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
- $fromwhere = $matches[1];
- $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
- $max_num_pages = ceil($numposts / $posts_per_page);
- }
- } else {
- $max_num_pages = 999999;
+ $max_num_pages = _max_num_pages();
+ $paged = get_query_var('paged');
+
+ //only have sep if there's both prev and next results
+ if ($paged < 2 || $paged >= $max_num_pages) {
+ $sep = '';
}
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);
+ next_posts_link($nxtlabel);
}
}
}
diff --git a/wp-inst/wp-includes/template-functions-post.php b/wp-inst/wp-includes/template-functions-post.php
index ed06b74..461d6e5 100644
--- a/wp-inst/wp-includes/template-functions-post.php
+++ b/wp-inst/wp-includes/template-functions-post.php
@@ -15,6 +15,10 @@ function the_ID() {
echo $id;
}
+function get_the_ID() {
+ global $id;
+ return $id;
+}
function the_title($before = '', $after = '', $echo = true) {
$title = get_the_title();
@@ -274,6 +278,17 @@ function the_meta() {
Pages
*/
+function walk_page_tree() {
+ $walker = new Walker_Page;
+ $args = func_get_args();
+ return call_user_func_array(array(&$walker, 'walk'), $args);
+}
+
+function walk_page_dropdown_tree() {
+ $walker = new Walker_PageDropdown;
+ $args = func_get_args();
+ return call_user_func_array(array(&$walker, 'walk'), $args);
+}
function &get_page_children($page_id, $pages) {
global $page_cache;
@@ -296,38 +311,58 @@ function &get_page_children($page_id, $pages) {
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';
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title',
+ 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '');
+ $r = array_merge($defaults, $r);
+ extract($r);
+
+ $inclusions = '';
+ if ( !empty($include) ) {
+ $child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include
+ $exclude = '';
+ $meta_key = '';
+ $meta_value = '';
+ $incpages = preg_split('/[\s,]+/',$include);
+ if ( count($incpages) ) {
+ foreach ( $incpages as $incpage ) {
+ if (empty($inclusions))
+ $inclusions = ' AND ( ID = ' . intval($incpage) . ' ';
+ else
+ $inclusions .= ' OR ID = ' . intval($incpage) . ' ';
+ }
+ }
+ }
+ if (!empty($inclusions))
+ $inclusions .= ')';
$exclusions = '';
- if ( !empty($r['exclude']) ) {
- $expages = preg_split('/[\s,]+/',$r['exclude']);
+ if ( !empty($exclude) ) {
+ $expages = preg_split('/[\s,]+/',$exclude);
if ( count($expages) ) {
foreach ( $expages as $expage ) {
- $exclusions .= ' AND ID <> ' . intval($expage) . ' ';
+ if (empty($exclusions))
+ $exclusions = ' AND ( ID <> ' . intval($expage) . ' ';
+ else
+ $exclusions .= ' AND ID <> ' . intval($expage) . ' ';
}
}
}
+ if (!empty($exclusions))
+ $exclusions .= ')';
- $q = "SELECT * " .
- "FROM $wpdb->posts " .
- "WHERE post_type = 'page' AND post_status = 'publish' " .
- "$exclusions " .
- "ORDER BY " . $r['sort_column'] . " " . $r['sort_order'];
+ $query = "SELECT * FROM $wpdb->posts " ;
+ $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " ) ;
+ $query .= " WHERE (post_type = 'page' AND post_status = 'publish') $exclusions $inclusions " ;
+ $query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" ) ;
+ $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
- $cached_pages = wp_cache_get( md5( $q ), 'general');
- if ( is_array( $cached_pages ) == false || ( is_array( $cached_pages ) == true && ( get_option( 'pages_last_updated' ) != false && $cached_pages[ 'time' ] < get_option( 'pages_last_updated' ) ) ) ) {
- $pages = $wpdb->get_results($q);
- wp_cache_set( md5( $q ), array( 'pages' => $pages, 'time' => time() ), 'general', 600 );
- } else {
- $pages = $cached_pages[ 'pages' ];
- }
+ $pages = $wpdb->get_results($query);
+ $pages = apply_filters('get_pages', $pages, $r);
if ( empty($pages) )
return array();
@@ -335,119 +370,70 @@ function &get_pages($args = '') {
// Update cache.
update_page_cache($pages);
- if ( $r['child_of'] )
- $pages = & get_page_children($r['child_of'], $pages);
+ if ( $child_of || $hierarchical )
+ $pages = & get_page_children($child_of, $pages);
return $pages;
}
+function wp_dropdown_pages($args = '') {
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
-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;
+ $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1,
+ 'name' => 'page_id');
+ $r = array_merge($defaults, $r);
+ extract($r);
+ $pages = get_pages($r);
$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>';
+ if ( ! empty($pages) ) {
+ $output = "<select name='$name'>\n";
+ $output .= walk_page_dropdown_tree($pages, $depth, $r);
+ $output .= "</select>\n";
}
- $output = apply_filters('wp_list_pages', $output);
+ $output = apply_filters('wp_dropdown_pages', $output);
- if ( $r['echo'] )
+ if ( $echo )
echo $output;
- else
- return $output;
-}
+ 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 = '';
+function wp_list_pages($args = '') {
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
- if ( $depth )
- $indent = str_repeat("\t", $depth);
- //$indent = join('', array_fill(0,$depth,"\t"));
+ $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_settings('date_format'),
+ 'child_of' => 0, 'title_li' => __('Pages'), 'echo' => 1);
+ $r = array_merge($defaults, $r);
- if ( !is_array($page_tree[$parent]['children']) )
- return false;
+ $output = '';
- foreach ( $page_tree[$parent]['children'] as $page_id ) {
- $cur_page = $page_tree[$page_id];
- $title = $cur_page['title'];
+ // Query pages.
+ $pages = get_pages($r);
- $css_class = 'page_item';
- if ( $page_id == $queried_obj->ID )
- $css_class .= ' current_page_item';
+ if ( !empty($pages) ) {
+ if ( $r['title_li'] )
+ $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
- $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>';
+ global $wp_query;
+ $current_page = $wp_query->get_queried_object_id();
+ $output .= walk_page_tree($pages, $r['depth'], $current_page, $r['show_date'], $r['date_format']);
- if ( isset($cur_page['ts']) ) {
- $format = get_settings('date_format');
- if ( isset($args['date_format']) )
- $format = $args['date_format'];
- $output .= " " . mysql2date($format, $cur_page['ts']);
- }
+ if ( $r['title_li'] )
+ $output .= '</ul></li>';
+ }
- if ( isset($cur_page['children']) && is_array($cur_page['children']) ) {
- $new_depth = $depth + 1;
+ $output = apply_filters('wp_list_pages', $output);
- 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 )
+ if ( $r['echo'] )
echo $output;
else
return $output;
diff --git a/wp-inst/wp-includes/template-loader.php b/wp-inst/wp-includes/template-loader.php
index e3160f7..3f799e1 100644
--- a/wp-inst/wp-includes/template-loader.php
+++ b/wp-inst/wp-includes/template-loader.php
@@ -2,7 +2,7 @@
if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
do_action('template_redirect');
if ( is_feed() ) {
- include(ABSPATH . '/wp-feed.php');
+ do_feed();
exit;
} else if ( is_trackback() ) {
include(ABSPATH . '/wp-trackback.php');
@@ -56,7 +56,7 @@ if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
} else {
// Process feeds and trackbacks even if not using themes.
if ( is_feed() ) {
- include(ABSPATH . '/wp-feed.php');
+ do_feed();
exit;
} else if ( is_trackback() ) {
include(ABSPATH . '/wp-trackback.php');
diff --git a/wp-inst/wp-includes/theme.php b/wp-inst/wp-includes/theme.php
new file mode 100644
index 0000000..182d148
--- /dev/null
+++ b/wp-inst/wp-includes/theme.php
@@ -0,0 +1,378 @@
+<?php
+/*
+ * Theme/template/stylesheet functions.
+ */
+
+function get_stylesheet() {
+ return apply_filters('stylesheet', get_settings('stylesheet'));
+}
+
+function get_stylesheet_directory() {
+ $stylesheet = get_stylesheet();
+ $stylesheet_dir = get_theme_root() . "/$stylesheet";
+ return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet);
+}
+
+function get_stylesheet_directory_uri() {
+ $stylesheet = rawurlencode( get_stylesheet() );
+ $stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet";
+ return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet);
+}
+
+function get_stylesheet_uri() {
+ $stylesheet_dir_uri = get_stylesheet_directory_uri();
+ $stylesheet_uri = $stylesheet_dir_uri . "/style.css";
+ return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
+}
+
+function get_template() {
+ $template = get_settings('template');
+ if (!file_exists(get_theme_root() . "/$template")) { //works for dirs too
+ update_option('template', 'default');
+ update_option('stylesheet', 'default');
+ }
+ return apply_filters('template', get_settings('template'));
+}
+
+function get_template_directory() {
+ $template = get_template();
+ $template_dir = get_theme_root() . "/$template";
+ return apply_filters('template_directory', $template_dir, $template);
+}
+
+function get_template_directory_uri() {
+ $template = get_template();
+ $template_dir_uri = get_theme_root_uri() . "/$template";
+ return apply_filters('template_directory_uri', $template_dir_uri, $template);
+}
+
+function get_theme_data($theme_file) {
+ $theme_data = implode('', file($theme_file));
+ preg_match("|Theme Name:(.*)|i", $theme_data, $theme_name);
+ preg_match("|Theme URI:(.*)|i", $theme_data, $theme_uri);
+ preg_match("|Description:(.*)|i", $theme_data, $description);
+ preg_match("|Author:(.*)|i", $theme_data, $author_name);
+ preg_match("|Author URI:(.*)|i", $theme_data, $author_uri);
+ preg_match("|Template:(.*)|i", $theme_data, $template);
+ if ( preg_match("|Version:(.*)|i", $theme_data, $version) )
+ $version = $version[1];
+ else
+ $version ='';
+ if ( preg_match("|Status:(.*)|i", $theme_data, $status) )
+ $status = $status[1];
+ else
+ $status ='publish';
+
+ $description = wptexturize($description[1]);
+
+ $name = $theme_name[1];
+ $name = trim($name);
+ $theme = $name;
+
+ if ( '' == $author_uri[1] ) {
+ $author = $author_name[1];
+ } else {
+ $author = '<a href="' . $author_uri[1] . '" title="' . __('Visit author homepage') . '">' . $author_name[1] . '</a>';
+ }
+
+ return array('Name' => $name, 'Title' => $theme, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1], 'Status' => $status);
+}
+
+function get_themes() {
+ global $wp_themes;
+ global $wp_broken_themes;
+
+ if ( isset($wp_themes) )
+ return $wp_themes;
+
+ $themes = array();
+ $wp_broken_themes = array();
+ $theme_root = get_theme_root();
+ $theme_loc = str_replace(ABSPATH, '', $theme_root);
+
+ // Files in wp-content/themes directory
+ $themes_dir = @ dir($theme_root);
+ if ( $themes_dir ) {
+ while(($theme_dir = $themes_dir->read()) !== false) {
+ if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
+ if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) {
+ continue;
+ }
+ $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
+ $found_stylesheet = false;
+ while (($theme_file = $stylish_dir->read()) !== false) {
+ if ( $theme_file == 'style.css' ) {
+ $theme_files[] = $theme_dir . '/' . $theme_file;
+ $found_stylesheet = true;
+ break;
+ }
+ }
+ if ( !$found_stylesheet ) {
+ $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
+ }
+ }
+ }
+ }
+
+ if ( !$themes_dir || !$theme_files ) {
+ return $themes;
+ }
+
+ sort($theme_files);
+
+ foreach($theme_files as $theme_file) {
+ if ( ! is_readable("$theme_root/$theme_file") ) {
+ $wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.'));
+ continue;
+ }
+
+ $theme_data = get_theme_data("$theme_root/$theme_file");
+
+ $name = $theme_data['Name'];
+ $title = $theme_data['Title'];
+ $description = wptexturize($theme_data['Description']);
+ $version = $theme_data['Version'];
+ $author = $theme_data['Author'];
+ $template = $theme_data['Template'];
+ $stylesheet = dirname($theme_file);
+
+ foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext) {
+ if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) {
+ $screenshot = "screenshot.$ext";
+ break;
+ }
+ }
+
+ if ( empty($name) ) {
+ $name = dirname($theme_file);
+ $title = $name;
+ }
+
+ if ( empty($template) ) {
+ if ( file_exists(dirname("$theme_root/$theme_file/index.php")) ) {
+ $template = dirname($theme_file);
+ } else {
+ continue;
+ }
+ }
+
+ $template = trim($template);
+
+ if ( !file_exists("$theme_root/$template/index.php") ) {
+ $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
+ continue;
+ }
+
+ $stylesheet_files = array();
+ $stylesheet_dir = @ dir("$theme_root/$stylesheet");
+ if ( $stylesheet_dir ) {
+ while(($file = $stylesheet_dir->read()) !== false) {
+ if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) )
+ $stylesheet_files[] = "$theme_loc/$stylesheet/$file";
+ }
+ }
+
+ $template_files = array();
+ $template_dir = @ dir("$theme_root/$template");
+ if ( $template_dir ) {
+ while(($file = $template_dir->read()) !== false) {
+ if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) )
+ $template_files[] = "$theme_loc/$template/$file";
+ }
+ }
+
+ $template_dir = dirname($template_files[0]);
+ $stylesheet_dir = dirname($stylesheet_files[0]);
+
+ if ( empty($template_dir) )
+ $template_dir = '/';
+ if ( empty($stylesheet_dir) )
+ $stylesheet_dir = '/';
+
+ // Check for theme name collision. This occurs if a theme is copied to
+ // a new theme directory and the theme header is not updated. Whichever
+ // theme is first keeps the name. Subsequent themes get a suffix applied.
+ // The Default and Classic themes always trump their pretenders.
+ if ( isset($themes[$name]) ) {
+ if ( ('WordPress Default' == $name || 'WordPress Classic' == $name) &&
+ ('default' == $stylesheet || 'classic' == $stylesheet) ) {
+ // If another theme has claimed to be one of our default themes, move
+ // them aside.
+ $suffix = $themes[$name]['Stylesheet'];
+ $new_name = "$name/$suffix";
+ $themes[$new_name] = $themes[$name];
+ $themes[$new_name]['Name'] = $new_name;
+ } else {
+ $name = "$name/$stylesheet";
+ }
+ }
+
+ $themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Stylesheet' => $stylesheet, 'Template Files' => $template_files, 'Stylesheet Files' => $stylesheet_files, 'Template Dir' => $template_dir, 'Stylesheet Dir' => $stylesheet_dir, 'Status' => $theme_data['Status'], 'Screenshot' => $screenshot);
+ }
+
+ // Resolve theme dependencies.
+ $theme_names = array_keys($themes);
+
+ foreach ($theme_names as $theme_name) {
+ $themes[$theme_name]['Parent Theme'] = '';
+ if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
+ foreach ($theme_names as $parent_theme_name) {
+ if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
+ $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
+ break;
+ }
+ }
+ }
+ }
+
+ $wp_themes = $themes;
+
+ return $themes;
+}
+
+function get_theme($theme) {
+ $themes = get_themes();
+
+ if ( array_key_exists($theme, $themes) )
+ return $themes[$theme];
+
+ return NULL;
+}
+
+function get_current_theme() {
+ $themes = get_themes();
+ $theme_names = array_keys($themes);
+ $current_template = get_settings('template');
+ $current_stylesheet = get_settings('stylesheet');
+ $current_theme = 'WordPress Default';
+
+ if ( $themes ) {
+ foreach ($theme_names as $theme_name) {
+ if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
+ $themes[$theme_name]['Template'] == $current_template ) {
+ $current_theme = $themes[$theme_name]['Name'];
+ break;
+ }
+ }
+ }
+
+ return $current_theme;
+}
+
+function get_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_query_template($type) {
+ $template = '';
+ if ( file_exists(TEMPLATEPATH . "/{$type}.php") )
+ $template = TEMPLATEPATH . "/{$type}.php";
+
+ return apply_filters("{$type}_template", $template);
+}
+
+function get_404_template() {
+ return get_query_template('404');
+}
+
+function get_archive_template() {
+ return get_query_template('archive');
+}
+
+function get_author_template() {
+ return get_query_template('author');
+}
+
+function get_category_template() {
+ $template = '';
+ if ( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') )
+ $template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php';
+ else if ( file_exists(TEMPLATEPATH . "/category.php") )
+ $template = TEMPLATEPATH . "/category.php";
+
+ return apply_filters('category_template', $template);
+}
+
+function get_date_template() {
+ return get_query_template('date');
+}
+
+function get_home_template() {
+ $template = '';
+
+ if ( file_exists(TEMPLATEPATH . "/home.php") )
+ $template = TEMPLATEPATH . "/home.php";
+ else if ( file_exists(TEMPLATEPATH . "/index.php") )
+ $template = TEMPLATEPATH . "/index.php";
+
+ return apply_filters('home_template', $template);
+}
+
+function get_page_template() {
+ global $wp_query;
+
+ $id = $wp_query->post->ID;
+ $template = get_post_meta($id, '_wp_page_template', true);
+
+ if ( 'default' == $template )
+ $template = '';
+
+ if ( ! empty($template) && file_exists(TEMPLATEPATH . "/$template") )
+ $template = TEMPLATEPATH . "/$template";
+ else if ( file_exists(TEMPLATEPATH . "/page.php") )
+ $template = TEMPLATEPATH . "/page.php";
+ else
+ $template = '';
+
+ return apply_filters('page_template', $template);
+}
+
+function get_paged_template() {
+ return get_query_template('paged');
+}
+
+function get_search_template() {
+ return get_query_template('search');
+}
+
+function get_single_template() {
+ return get_query_template('single');
+}
+
+function get_attachment_template() {
+ global $posts;
+ $type = explode('/', $posts[0]->post_mime_type);
+ if ( $template = get_query_template($type[0]) )
+ return $template;
+ elseif ( $template = get_query_template($type[1]) )
+ return $template;
+ elseif ( $template = get_query_template("$type[0]_$type[1]") )
+ return $template;
+ else
+ return get_query_template('attachment');
+}
+
+function get_comments_popup_template() {
+ if ( file_exists( TEMPLATEPATH . '/comments-popup.php') )
+ $template = TEMPLATEPATH . '/comments-popup.php';
+ else
+ $template = get_theme_root() . '/default/comments-popup.php';
+
+ return apply_filters('comments_popup_template', $template);
+}
+
+function load_template($file) {
+ global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query,
+ $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment;
+
+ if( is_array( $wp_query->query_vars ) )
+ extract($wp_query->query_vars);
+
+ require_once($file);
+}
+
+?>
diff --git a/wp-inst/wp-includes/vars.php b/wp-inst/wp-includes/vars.php
index 705d8b2..ef7e7a0 100644
--- a/wp-inst/wp-includes/vars.php
+++ b/wp-inst/wp-includes/vars.php
@@ -14,20 +14,18 @@ if (preg_match('#([^/]+.php)#', $PHP_SELF, $self_matches)) {
// 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)) {
+
+if (preg_match('/Lynx/', $_SERVER['HTTP_USER_AGENT'])) {
$is_lynx = 1;
-} elseif (preg_match('/Gecko/', $HTTP_USER_AGENT)) {
+} elseif (preg_match('/Gecko/', $_SERVER['HTTP_USER_AGENT'])) {
$is_gecko = 1;
-} elseif ((preg_match('/MSIE/', $HTTP_USER_AGENT)) && (preg_match('/Win/', $HTTP_USER_AGENT))) {
+} elseif ((preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) && (preg_match('/Win/', $_SERVER['HTTP_USER_AGENT']))) {
$is_winIE = 1;
-} elseif ((preg_match('/MSIE/', $HTTP_USER_AGENT)) && (preg_match('/Mac/', $HTTP_USER_AGENT))) {
+} elseif ((preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) && (preg_match('/Mac/', $_SERVER['HTTP_USER_AGENT']))) {
$is_macIE = 1;
-} elseif (preg_match('/Opera/', $HTTP_USER_AGENT)) {
+} elseif (preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT'])) {
$is_opera = 1;
-} elseif ((preg_match('/Nav/', $HTTP_USER_AGENT) ) || (preg_match('/Mozilla\/4\./', $HTTP_USER_AGENT))) {
+} elseif ((preg_match('/Nav/', $_SERVER['HTTP_USER_AGENT']) ) || (preg_match('/Mozilla\/4\./', $_SERVER['HTTP_USER_AGENT']))) {
$is_NS4 = 1;
}
$is_IE = (($is_macIE) || ($is_winIE));
@@ -92,16 +90,6 @@ if (!isset($wpsmiliestrans)) {
);
}
-// 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) {
diff --git a/wp-inst/wp-includes/version.php b/wp-inst/wp-includes/version.php
index c0f1f9e..0f08c70 100644
--- a/wp-inst/wp-includes/version.php
+++ b/wp-inst/wp-includes/version.php
@@ -2,7 +2,7 @@
// This just holds the version number, in a separate file so we can bump it without cluttering the SVN
-$wp_version = 'MU'; // Let's just avoid confusion
-$wp_db_version = 3548;
+$wp_version = 'wordpress-mu-1.0'; // Let's just avoid confusion
+$wp_db_version = 3673;
?>
diff --git a/wp-inst/wp-includes/wpmu-functions.php b/wp-inst/wp-includes/wpmu-functions.php
index 64aa404..e708d65 100644
--- a/wp-inst/wp-includes/wpmu-functions.php
+++ b/wp-inst/wp-includes/wpmu-functions.php
@@ -69,249 +69,6 @@ function wpmu_checkAvailableSpace($action) {
}
add_filter('fileupload_init','wpmu_checkAvailableSpace');
-function createBlog( $domain, $path, $username, $weblog_title, $admin_email, $source = 'regpage', $site_id = 1 ) {
- global $wpdb, $table_prefix, $wp_queries, $wpmuBaseTablePrefix, $current_site, $wp_roles, $new_user_id, $new_blog_id, $wp_rewrite;
-
- $domain = addslashes( $domain );
- $weblog_title = addslashes( $weblog_title );
- $admin_email = addslashes( $admin_email );
- $username = addslashes( $username );
-
- if( empty($path) )
- $path = '/';
-
- $limited_email_domains = get_site_option( 'limited_email_domains' );
- if( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
- $emaildomain = substr( $admin_email, 1 + strpos( $admin_email, '@' ) );
- if( in_array( $emaildomain, $limited_email_domains ) == false ) {
- return "error: email domain not allowed";
- }
- }
- // Check if the domain has been used already. We should return an error message.
- if( $wpdb->get_var("SELECT blog_id FROM $wpdb->blogs WHERE domain = '$domain' AND path = '$path'" ) )
- return 'error: Blog URL already taken.';
-
- // Check if the username has been used already. We should return an error message.
- if( $wpdb->get_var( "SELECT ID FROM ".$wpdb->users." WHERE user_login = '".$username."'" ) == true )
- return "error: username used";
-
- // Check if the username has been used already. We should return an error message.
- if( $wpdb->get_var( "SELECT ID FROM ".$wpdb->users." WHERE user_email = '".$admin_email."'" ) == true )
- return "error: email used";
- if( strpos( " " . $username, "_" ) != false )
- return "error: username must not contain _";
-
- // all numeric?
- preg_match( '/[0-9]*/', $username, $match );
- if( $match[0] == $username )
- return "error: username must not be all numeric";
-
- $errmsg = false ;
- $errmsg = apply_filters( "createBlog_check", $errmsg );
- if( $errmsg != false )
- return "error: $errmsg";
-
- $wpdb->hide_errors();
-
- $query = "SELECT blog_id FROM ".$wpdb->blogs." WHERE site_id = '".$site_id."' AND domain = '".$domain."' AND path = '".$path."'";
- $blog_id = $wpdb->get_var( $query );
- if( $blog_id != false ) {
- return "error: blogname used";
- }
- $query = "INSERT INTO $wpdb->blogs ( blog_id, site_id, domain, path, registered ) VALUES ( NULL, '$site_id', '$domain', '$path', 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[ 'options' ] = $wpdb->options;
- $tmp[ 'postmeta' ] = $wpdb->postmeta;
- $tmptable_prefix = $table_prefix;
- if( is_object( $wp_roles ) )
- $tmprolekey = $wp_roles->role_key;
-
- // 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';
- if( is_object( $wp_roles ) )
- $wp_roles->role_key = $table_prefix . 'user_roles';
- wp_cache_flush();
-
- @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id, 0777 );
- @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id."/files", 0777 );
-
- include_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( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
- $url = "http://".$domain.$path;
- } else {
- if( $domain != $_SERVER[ 'HTTP_HOST' ] ) {
- $blogname = substr( $domain, 0, strpos( $domain, '.' ) );
- if( $blogname != 'www.' ) {
- $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path . $blogname . '/';
- } else { // we're installing the main blog
- $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
- }
- } else { // we're installing the main blog
- $url = 'http://' . $domain . $path;
- }
- }
-
- // Set everything up
- make_db_current_silent();
- populate_options();
-
- // fix url.
- update_option('siteurl', $url);
- update_option('home', $url);
- update_option('fileupload_url', $url . "files" );
-
- $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'");
-
- // Default category
- $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count) VALUES ('0', '".addslashes(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1')");
-
- // First post
- $now = date('Y-m-d H:i:s');
- $now_gmt = gmdate('Y-m-d H:i:s');
-
- // Set up admin user
- $random_password = substr(md5(uniqid(microtime())), 0, 6);
- $GLOBALS['random_password'] = $random_password;
- $wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_url, user_registered, display_name) VALUES ( NULL, '".$username."', MD5('$random_password'), '$admin_email', '$url', '$now_gmt', '$username' )");
- $userID = $wpdb->insert_id;
- $new_user_id = $userID;
- $new_blog_id = $blog_id;
- $metavalues = array(
- 'user_nickname' => addslashes($username),
- $table_prefix . 'user_level' => 10,
- 'source_domain' => $domain,
- 'primary_blog' => $blog_id,
- $table_prefix . 'capabilities' => serialize(array('administrator' => true)),
- 'source' => $source
- );
- $metavalues = apply_filters('newblog_metavalues', $metavalues);
- foreach ( $metavalues as $key => $val ) {
- if ( empty( $val ) ) // No more annoying empty values bloating the usermeta table
- continue;
- $wpdb->query( "INSERT INTO $wpdb->usermeta ( `user_id` , `meta_key` , `meta_value` ) VALUES ( '$userID', '$key' , '$val')" );
- }
-
- // 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_owner, link_rss) VALUES ('http://wordpress.com/', 'WordPress.com', 1, '$userID', 'http://wordpress.com/feed/');");
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_owner, link_rss) VALUES ('http://wordpress.org/', 'WordPress.org', 1, '$userID', 'http://wordpress.org/development/feed/');");
-
- $invitee_id = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$_POST[ 'u' ]}_invited_by' AND user_id = '0'" );
- if( $invitee_id ) {
- $invitee_user_login = $wpdb->get_row( "SELECT user_login, user_email FROM {$wpdb->users} WHERE ID = '$invitee_id'" );
- $invitee_blog = $wpdb->get_row( "SELECT blog_id, meta_value from {$wpdb->blogs}, {$wpdb->usermeta} WHERE user_id = '$invitee_id' AND meta_key = 'source_domain' AND {$wpdb->usermeta}.meta_value = {$wpdb->blogs}.domain" );
- if( $invitee_blog )
- $invitee_siteurl = $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$invitee_blog->blog_id}_options WHERE option_name = 'siteurl'" );
- }
-
- if( $invitee_siteurl && $invitee_user_login )
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_owner, link_rss) VALUES ('{$invitee_siteurl}', '" . ucfirst( $invitee_user_login->user_login ) . "', 1, '$userID', '');");
-
- $first_post = get_site_option( 'first_post' );
- if( $first_post == false )
- $first_post = stripslashes( __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ) );
- $welcome_email = stripslashes( get_site_option( 'welcome_email' ) );
- if( $welcome_email == false )
- $welcome_email = stripslashes( __( "Dear User,
-
-Your new SITE_NAME blog has been successfully set up at:
-BLOG_URL
-
-You can log in to the administrator account with the following information:
-Username: USERNAME
-Password: PASSWORD
-Login Here: BLOG_URLwp-login.php
-
-We hope you enjoy your new weblog.
-Thanks!
-
---The WordPress Team
-SITE_NAME" ) );
-
-
- $welcome_email = str_replace( "SITE_NAME", $current_site->site_name, $welcome_email );
- $welcome_email = str_replace( "BLOG_URL", $url, $welcome_email );
- $welcome_email = str_replace( "USERNAME", $username, $welcome_email );
- $welcome_email = str_replace( "PASSWORD", $random_password, $welcome_email );
-
- $first_post = str_replace( "SITE_URL", "http://" . $current_site->domain . $current_site->path, $first_post );
- $first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
- $first_post = stripslashes( $first_post );
-
- $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, comment_count) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes($first_post)."', '".addslashes(__('Hello world!'))."', '0', '".addslashes(__('hello-world'))."', '$now', '$now_gmt', '1')");
- $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ('$userID', '$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', 'publish', 'page', '', '', '')");
-
- $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)" );
- update_option( "post_count", 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://" . $current_site->domain . $current_site->path . "', '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.'))."')");
-
-
- // remove all perms except for the login user.
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE user_id != '".$userID."' AND meta_key = '".$table_prefix."user_level'" );
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE user_id != '".$userID."' AND meta_key = '".$table_prefix."capabilities'" );
- if( $userID != 1 )
- $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE user_id = '".$userID."' AND meta_key = '" . $wpmuBaseTablePrefix . "1_capabilities'" );
-
- do_action( "wpmu_new_blog", $blog_id, $userID );
-
- $welcome_email = apply_filters( "update_welcome_email", $welcome_email );
- $message_headers = 'From: ' . stripslashes($weblog_title) . ' <wordpress@' . $_SERVER[ 'SERVER_NAME' ] . '>';
- $message = $welcome_email;
- if( empty( $current_site->site_name ) )
- $current_site->site_name = "WordPress MU";
- @mail($admin_email, __('New ' . $current_site->site_name . ' Blog').": ".stripslashes( $weblog_title ), $message, $message_headers);
-
- $wp_rewrite->init();
- $wp_rewrite->flush_rules();
-
- // restore wpdb variables
- reset( $tmp );
- while( list( $key, $val ) = each( $tmp ) )
- {
- $wpdb->$key = $val;
- }
- $table_prefix = $tmptable_prefix;
- if( $tmprolekey )
- $wp_roles->role_key = $tmprolekey;
-
- $wpdb->show_errors();
- wp_cache_flush();
-
- return "ok";
-}
-
if( defined( "WP_INSTALLING" ) == false ) {
header( "X-totalblogs: " . get_blog_count() );
header( "X-rootblog: http://" . $current_site->domain . $current_site->path );
@@ -325,18 +82,17 @@ if( defined( "WP_INSTALLING" ) == false ) {
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 );
+ $bloginfo = get_blog_details( $blog_id );
+
if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
- return "http://".$bloginfo[ 'blogname' ].".".$domain.$base;
+ return "http://" . $bloginfo->domain . $bloginfo->path;
} else {
- return "http://".$hostname.$base.$bloginfo[ 'blogname' ];
+ return get_blogaddress_by_domain($bloginfo->domain, $bloginfo->path);
}
}
function get_blogaddress_by_name( $blogname ) {
- global $domain, $base, $wpdb;
+ global $hostname, $domain, $base, $wpdb;
if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
if( $blogname == 'main' )
@@ -347,6 +103,25 @@ function get_blogaddress_by_name( $blogname ) {
}
}
+function get_blogaddress_by_domain( $domain, $path ){
+ if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ $url = "http://".$domain.$path;
+ } else {
+ if( $domain != $_SERVER[ 'HTTP_HOST' ] ) {
+ $blogname = substr( $domain, 0, strpos( $domain, '.' ) );
+ if( $blogname != 'www.' ) {
+ $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path . $blogname . '/';
+ } else { // we're installing the main blog
+ $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
+ }
+ } else { // main blog
+ $url = 'http://' . $domain . $path;
+ }
+ }
+
+ return $url;
+}
+
function get_sitestats() {
global $wpdb, $basedomain, $base;
@@ -393,12 +168,17 @@ function get_user_details( $username ) {
function get_blog_details( $id ) {
global $wpdb, $wpmuBaseTablePrefix;
+
$details = wp_cache_get( $id, 'blog-details' );
if ( $details )
return unserialize( $details );
- $details = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE blog_id = '$id'" );
+ $details = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE blog_id = '$id' /* get_blog_details */" );
+
+ if ( !$details )
+ return false;
+
$details->blogname = stripslashes( $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'blogname'" ) );
$details->siteurl = $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'siteurl'" );
wp_cache_set( $id, serialize( $details ), 'blog-details' );
@@ -412,13 +192,16 @@ function get_blog_details( $id ) {
function refresh_blog_details( $id ) {
global $wpdb, $wpmuBaseTablePrefix;
- $details = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE blog_id = '$id'" );
+ if ( defined('WP_INSTALLING') )
+ return;
+
+ $details = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE blog_id = '$id' /* refresh_blog_details */" );
$details->blogname = stripslashes( $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'blogname'" ) );
$details->siteurl = $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'siteurl'" );
- wp_cache_set( $id , serialize( $details ), 'blog-details' );
+ wp_cache_delete( $id , 'blog-details' );
$key = md5( $details->domain . $details->path );
- wp_cache_set( $key , serialize( $details ), 'blog-lookup' );
+ wp_cache_delete( $key , 'blog-lookup' );
return $details;
}
@@ -485,7 +268,7 @@ function add_site_option( $key, $value ) {
if ( is_array($value) || is_object($value) )
$value = serialize($value);
$value = $wpdb->escape( $value );
- wp_cache_set($key, $value, 'site-options');
+ wp_cache_delete($key, 'site-options');
$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id , meta_key , meta_value ) VALUES ( '$wpdb->siteid', '$key', '$value')" );
return $wpdb->insert_id;
}
@@ -504,33 +287,19 @@ function update_site_option( $key, $value ) {
add_site_option( $key, $value );
$wpdb->query( "UPDATE $wpdb->sitemeta SET meta_value = '".$wpdb->escape( $value )."' WHERE meta_key = '$key'" );
- wp_cache_replace($key, $value, "site-options");
+ wp_cache_delete( $key, 'site-options' );
}
-function get_blog_option( $blog_id, $key, $default='na' ) {
- global $wpdb, $wpmuBaseTablePrefix;
- $cache = wpmu_get_cache( $blog_id."-".$key, "get_blog_option" );
- if( is_array( $cache ) && ( time() - $cache[ 'time' ] ) < 30 ) {
- $opt = $cache[ 'value' ];
- } else {
- $option = $wpdb->get_row( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$blog_id}_options WHERE option_name = '$key'" );
- if( $option == false ) {
- if( $default != 'na' ) {
- $opt = $default;
- } else {
- $opt = false;
- }
- } else {
- @ $kellogs = unserialize($option->option_value);
- if ($kellogs !== FALSE) {
- $option_value = $kellogs;
- } else {
- $option_value = $option->option_value;
- }
- $opt = $option_value;
- }
- wpmu_update_cache( $blog_id."-".$key, $opt, "get_blog_option" );
- }
+function get_blog_option( $id, $key, $default='na' ) {
+ global $wpdb, $wpmuBaseTablePrefix, $blog_id;
+
+ $current_blog_id = $blog_id;
+ $current_options_table = $wpdb->options;
+ $wpdb->options = $wpmuBaseTablePrefix . $id . "_options";
+ $blog_id = $id;
+ $opt = get_option( $key );
+ $blog_id = $current_blog_id;
+ $wpdb->options = $current_options_table;
return $opt;
}
@@ -538,47 +307,31 @@ function get_blog_option( $blog_id, $key, $default='na' ) {
function add_blog_option( $id, $key, $value ) {
global $wpdb, $wpmuBaseTablePrefix, $blog_id;
- if( $value != get_blog_option( $id, $key ) ) {
- if ( is_array($value) || is_object($value) )
- $value = serialize($value);
- $query = "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = '$key'";
- if( $wpdb->get_row( $query ) == false ) {
- $wpdb->query( "INSERT INTO {$wpmuBaseTablePrefix}{$id}_options ( `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', '{$value}', '20', '8', '', '10', 'yes')" );
- $current_blog_id = $blog_id;
- $blog_id = $id;
- wp_cache_set( $key, $value );
- $blog_id = $current_blog_id;
- } else {
- update_blog_option( $id, $key, $value );
- }
- }
+ $current_blog_id = $blog_id;
+ $current_options_table = $wpdb->options;
+ $wpdb->options = $wpmuBaseTablePrefix . $id . "_options";
+ $blog_id = $id;
+ $opt = add_option( $key, $value );
+ $blog_id = $current_blog_id;
+ $wpdb->options = $current_options_table;
}
function update_blog_option( $id, $key, $value ) {
global $wpdb, $wpmuBaseTablePrefix, $blog_id;
- if( $value != get_blog_option( $id, $key ) ) {
- if ( is_array($value) || is_object($value) )
- $value = serialize($value);
-
- if ( is_string($newvalue) )
- $value = trim($value);
- $query = "SELECT option_name, option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = '$key'";
- if( $wpdb->get_row( $query ) == false ) {
- add_blog_option( $id, $key, $value );
- } else {
- $wpdb->query( "UPDATE {$wpmuBaseTablePrefix}{$id}_options SET option_value = '".$wpdb->escape( $value )."' WHERE option_name = '".$key."'" );
- $current_blog_id = $blog_id;
- $blog_id = $id;
- wp_cache_set( $key, $value );
- $blog_id = $current_blog_id;
- }
- }
+ $current_blog_id = $blog_id;
+ $current_options_table = $wpdb->options;
+ $wpdb->options = $wpmuBaseTablePrefix . $id . "_options";
+ $blog_id = $id;
+ $opt = update_option( $key, $value );
+ $blog_id = $current_blog_id;
+ $wpdb->options = $current_options_table;
+ refresh_blog_details( $id );
}
function switch_to_blog( $new_blog ) {
- global $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $cache_settings, $category_cache, $cache_categories, $post_cache, $wp_object_cache, $blog_id, $switched;
+ global $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $table_prefix, $cache_settings, $category_cache, $cache_categories, $post_cache, $wp_object_cache, $blog_id, $switched, $wp_roles;
// backup
$tmpoldblogdetails[ 'blogid' ] = $wpdb->blogid;
@@ -587,6 +340,7 @@ function switch_to_blog( $new_blog ) {
$tmpoldblogdetails[ 'post2cat' ] = $wpdb->post2cat;
$tmpoldblogdetails[ 'comments' ] = $wpdb->comments;
$tmpoldblogdetails[ 'links' ] = $wpdb->links;
+ $tmpoldblogdetails[ 'link2cat' ] = $wpdb->link2cat;
$tmpoldblogdetails[ 'linkcategories' ] = $wpdb->linkcategories;
$tmpoldblogdetails[ 'options' ] = $wpdb->options;
$tmpoldblogdetails[ 'postmeta' ] = $wpdb->postmeta;
@@ -601,12 +355,14 @@ function switch_to_blog( $new_blog ) {
// fix the new prefix.
$table_prefix = $wpmuBaseTablePrefix . $new_blog . "_";
+ $wpdb->prefix = $table_prefix;
$wpdb->blogid = $new_blog;
$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->link2cat = $table_prefix . 'link2cat';
$wpdb->linkcategories = $table_prefix . 'linkcategories';
$wpdb->options = $table_prefix . 'options';
$wpdb->postmeta = $table_prefix . 'postmeta';
@@ -617,14 +373,21 @@ function switch_to_blog( $new_blog ) {
unset( $category_cache );
unset( $cache_categories );
unset( $post_cache );
- unset( $wp_object_cache );
- $wp_object_cache = new WP_Object_Cache();
- $wp_object_cache->cache_enabled = false;
+ //unset( $wp_object_cache );
+ //$wp_object_cache = new WP_Object_Cache();
+ //$wp_object_cache->cache_enabled = false;
+ wp_cache_flush();
+ wp_cache_close();
+ $wp_roles->_init();
+ wp_cache_init();
+
+ do_action('switch_blog', $blog_id, $tmpoldblogdetails[ 'blog_id' ]);
+
$switched = true;
}
function restore_current_blog() {
- global $table_prefix, $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $cache_settings, $category_cache, $cache_categories, $post_cache, $wp_object_cache, $blog_id, $switched;
+ global $table_prefix, $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $cache_settings, $category_cache, $cache_categories, $post_cache, $wp_object_cache, $blog_id, $switched, $wp_roles;
// backup
$wpdb->blogid = $tmpoldblogdetails[ 'blogid' ];
$wpdb->posts = $tmpoldblogdetails[ 'posts' ];
@@ -632,6 +395,7 @@ function restore_current_blog() {
$wpdb->post2cat = $tmpoldblogdetails[ 'post2cat' ];
$wpdb->comments = $tmpoldblogdetails[ 'comments' ];
$wpdb->links = $tmpoldblogdetails[ 'links' ];
+ $wpdb->link2cat = $tmpoldblogdetails[ 'link2cat' ];
$wpdb->linkcategories = $tmpoldblogdetails[ 'linkcategories' ];
$wpdb->options = $tmpoldblogdetails[ 'options' ];
$wpdb->postmeta = $tmpoldblogdetails[ 'postmeta' ];
@@ -642,21 +406,48 @@ function restore_current_blog() {
$table_prefix = $tmpoldblogdetails[ 'table_prefix' ];
$post_cache = $tmpoldblogdetails[ 'post_cache' ];
$wp_object_cache = $tmpoldblogdetails[ 'wp_object_cache' ];
+ $prev_blog_id = $blog_id;
$blog_id = $tmpoldblogdetails[ 'blog_id' ];
unset( $tmpoldblogdetails );
- $wp_object_cache->cache_enabled = true;
+ wp_cache_flush();
+ wp_cache_close();
+ $wp_roles->_init();
+ wp_cache_init();
+
+ do_action('switch_blog', $blog_id, $prev_blog_id);
+
$switched = false;
}
-function get_users_of_blog( $id ) {
+function get_users_of_blog( $id = '' ) {
global $wpdb, $wpmuBaseTablePrefix;
- $users = $wpdb->get_results( "SELECT user_id, user_login, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE " . $wpdb->users . ".ID = " . $wpdb->usermeta . ".user_id AND meta_key = '" . $wpmuBaseTablePrefix . $id . "_capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
+ if ( empty($id) )
+ $id = $wpdb->blogid;
+ $users = $wpdb->get_results( "SELECT user_id, user_login, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE " . $wpdb->users . ".ID = " . $wpdb->usermeta . ".user_id AND meta_key = '" . $wpmuBaseTablePrefix . $id . "_capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
return $users;
}
function get_blogs_of_user( $id ) {
global $wpdb, $wpmuBaseTablePrefix;
- $blogs = $wpdb->get_results( "SELECT domain, REPLACE( REPLACE( meta_key, '$wpmuBaseTablePrefix', '' ), '_capabilities', '' ) as userblog_id FROM $wpdb->blogs, $wpdb->usermeta WHERE $wpdb->blogs.blog_id = REPLACE( REPLACE( $wpdb->usermeta.meta_key, '$wpmuBaseTablePrefix', '' ), '_capabilities', '' ) AND user_id = '$id' AND meta_key LIKE '%capabilities'" );
+
+ $user = get_userdata( $id );
+
+ $i = 0;
+ foreach ( $user as $key => $value ) {
+ $i++;;
+
+ if ( strstr( $key, '_capabilities') && strstr( $key, 'wp_') ) {
+ preg_match('/wp_(\d+)_capabilities/', $key, $match);
+ $blog = get_blog_details( $match[1] );
+ if ( $blog && isset( $blog->domain ) ) {
+ $blogs[$i]->userblog_id = $match[1];
+ $blogs[$i]->domain = $blog->domain;
+ } else { // Temporary fix for people who don't get usermeta cleaned up when a blog is deleted
+ delete_usermeta( $id, "wp_{$match[1]}_capabilities" );
+ delete_usermeta( $id, "wp_{$match[1]}_user_level" );
+ }
+ }
+ }
return $blogs;
}
@@ -804,17 +595,22 @@ function get_blog_list( $start = 0, $num = 10, $display = true ) {
function get_blog_count( $id = 0 ) {
global $wpdb;
+
+/*
if( $id == 0 )
$id = $wpdb->siteid;
$count_ts = get_site_option( "blog_count_ts" );
if( time() - $count_ts > 86400 ) {
- $count = $wpdb->get_var( "SELECT count(*) as c FROM $wpdb->blogs WHERE site_id = '$id'" );
+ $count = $wpdb->get_var( "SELECT count(*) as c FROM $wpdb->blogs WHERE site_id = '$id' AND spam='0' AND deleted='0' and archived='0'" );
update_site_option( "blog_count", $count );
update_site_option( "blog_count_ts", time() );
} else {
- $count = get_site_option( "blog_count" );
- }
+
+ }
+*/
+
+ $count = get_site_option( "blog_count" );
return $count;
}
@@ -835,12 +631,120 @@ function get_blog_post( $blog_id, $post_id ) {
}
function add_user_to_blog( $blog_id, $user_id, $role ) {
- global $wpdb, $wpmuBaseTablePrefix;
+ global $wpdb;
+
+ $switch = false;
+
+ if ( empty($blog_id) )
+ $blog_id = $wpdb->blogid;
+
+ if ( $blog_id != $wpdb->blogid ) {
+ $switch = true;
+ switch_to_blog($blog_id);
+ }
+
+ $user = new WP_User($user_id);
+
+ if ( empty($user) )
+ return new WP_Error('user_does_not_exist', __('That user does not exist.'));
+
+ if ( !get_usermeta($user_id, 'primary_blog') ) {
+ update_usermeta($user_id, 'primary_blog', $blog_id);
+ $details = get_blog_details($blog_id);
+ update_usermeta($user_id, 'source_domain', $details->domain);
+ }
+
+ if ( empty($user->user_url) ) {
+ $userdata = array();
+ $userdata['ID'] = $user->id;
+ $userdata['user_url'] = get_blogaddress_by_id($blog_id);
+ wp_update_user($userdata);
+ }
+
+ $user->set_role($role);
+
+ do_action('add_user_to_blog', $user_id, $role, $blog_id);
+
+ if ( $switch )
+ restore_current_blog();
+}
+
+function remove_user_from_blog($user_id, $blog_id = '') {
+ global $wpdb;
+ if ( empty($blog_id) )
+ $blog_id = $wpdb->blogid;
+
+ $blog_id = (int) $blog_id;
+
+ if ( $blog_id != $wpdb->blogid ) {
+ $switch = true;
+ switch_to_blog($blog_id);
+ }
- $wpdb->query( "INSERT INTO " . $wpdb->usermeta . "( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '$user_id', '" . $wpmuBaseTablePrefix . $blog_id . "_capabilities', 'a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}')" );
+ $user_id = (int) $user_id;
+
+ do_action('remove_user_from_blog', $user_id, $blog_id);
+
+ // If being removed from the primary blog, set a new primary if the user is assigned
+ // to multiple blogs.
+ $primary_blog = get_usermeta($user_id, 'primary_blog');
+ if ( $primary_blog == $blog_id ) {
+ $new_id = '';
+ $new_domain = '';
+ $blogs = get_blogs_of_user($user_id);
+ if ( count($blogs) > 1 ) {
+ foreach ( $blogs as $blog ) {
+ if ( $blog->userblog_id == $blog_id )
+ continue;
+ $new_id = $blog->userblog_id;
+ $new_domain = $blog->domain;
+ break;
+ }
+ }
+ update_usermeta($user_id, 'primary_blog', $new_id);
+ update_usermeta($user_id, 'source_domain', $new_domain);
+ }
+
+ wp_revoke_user($user_id);
+ $blogs = get_blogs_of_user($user_id);
+ if ( count($blogs) == 0 ) {
+ update_usermeta($user_id, 'primary_blog', '');
+ update_usermeta($user_id, 'source_domain', '');
+ }
+
+ if ( $switch )
+ restore_current_blog();
}
+function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {
+ global $wpdb, $table_prefix, $wp_queries, $wpmuBaseTablePrefix, $current_site;
+
+ $domain = addslashes( $domain );
+ $weblog_title = addslashes( $weblog_title );
+
+ if( empty($path) )
+ $path = '/';
+
+ // Check if the domain has been used already. We should return an error message.
+ if ( domain_exists($domain, $path, $site_id) )
+ return 'error: Blog URL already taken.';
+
+ // 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.
+
+ if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
+ return "error: problem creating blog entry";
+
+ switch_to_blog($blog_id);
+
+ install_blog($blog_id);
+
+ restore_current_blog();
+
+ return true;
+}
function get_blog_permalink( $blog_id, $post_id ) {
global $wpdb, $cache_settings;
@@ -928,4 +832,429 @@ function is_blog_user() {
return false;
}
+function validate_email( $email, $check_domain = true) {
+ if (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.
+ '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
+ '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $email))
+ {
+ if ($check_domain && function_exists('checkdnsrr')) {
+ list (, $domain) = explode('@', $email);
+
+ if (checkdnsrr($domain.'.', 'MX') || checkdnsrr($domain.'.', 'A')) {
+ return true;
+ }
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+function wpmu_validate_signup($blog_id, $blog_title, $user_name, $user_email) {
+ global $wpdb, $domain, $base;
+
+ $errors = new WP_Error();
+ $illegal_names = get_site_option( "illegal_names" );
+ if( $illegal_names == false ) {
+ $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" );
+ add_site_option( "illegal_names", $illegal_names );
+ }
+
+ // Validate username and email unless a user object was passed in.
+ if ( ! is_object($user_name) ) {
+ $user_name = sanitize_title($user_name);
+
+ if ( empty( $user_name ) )
+ $errors->add('user_name', __("Please enter a username"));
+
+ preg_match( "/[a-zA-Z0-9]+/", $user_name, $maybe );
+
+ if( $blog_id != $maybe[0] ) {
+ $errors->add('user_name', __("Only letters and numbers allowed"));
+ }
+
+ if( in_array( $blog_id, $illegal_names ) == true ) {
+ $errors->add('user_name', __("That username is not allowed"));
+ }
+
+ if( strlen( $blog_id ) < 4 ) {
+ $errors->add('user_name', __("Username must be at least 4 characters"));
+ }
+
+ if ( strpos( " " . $user_name, "_" ) != false )
+ $errors->add('user_name', __("Sorry, usernames may not contain the character '_'!"));
+
+ // all numeric?
+ preg_match( '/[0-9]*/', $user_name, $match );
+ if ( $match[0] == $user_name )
+ $errors->add('user_name', __("Sorry, usernames must have letters too!"));
+
+ if ( !is_email( $user_email ) )
+ $errors->add('user_email', __("Please enter a correct email address"));
+
+ if ( !validate_email( $user_email ) )
+ $errors->add('user_email', __("Please check your email address."));
+
+ $limited_email_domains = get_site_option( 'limited_email_domains' );
+ if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
+ $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
+ if( in_array( $emaildomain, $limited_email_domains ) == false ) {
+ $errors->add('user_email', __("Sorry, that email address is not allowed!"));
+ }
+ }
+
+ // Check if the username has been used already.
+ if ( username_exists($user_name) )
+ $errors->add('user_name', __("Sorry, that username already exists!"));
+
+ // Check if the email address has been used already.
+ //if ( email_exists($user_email) )
+ // $errors->add('user_email', __("Sorry, that email address is already used!"));
+
+ }
+
+ $blog_id = sanitize_title($blog_id);
+
+ if ( empty( $blog_id ) )
+ $errors->add('blog_id', __("Please enter a blog name"));
+
+ preg_match( "/[a-zA-Z0-9]+/", $blog_id, $maybe );
+ if( $blog_id != $maybe[0] ) {
+ $errors->add('blog_id', __("Only letters and numbers allowed"));
+ }
+ if( in_array( $blog_id, $illegal_names ) == true ) {
+ $errors->add('blog_id', __("That name is not allowed"));
+ }
+ if( strlen( $blog_id ) < 4 ) {
+ $errors->add('blog_id', __("Blog name must be at least 4 characters"));
+ }
+
+ if ( strpos( " " . $blog_id, "_" ) != false )
+ $errors->add('blog_id', __("Sorry, blog names may not contain the character '_'!"));
+
+ // all numeric?
+ preg_match( '/[0-9]*/', $blog_id, $match );
+ if ( $match[0] == $blog_id )
+ $errors->add('blog_id', __("Sorry, blog names must have letters too!"));
+
+ $blog_id = apply_filters( "newblog_id", $blog_id );
+
+ $blog_title = stripslashes( $blog_title );
+
+ if ( empty( $blog_title ) )
+ $errors->add('blog_title', __("Please enter a blog title"));
+
+ // Check if the domain has been used already.
+ if ( constant( 'VHOST' ) == 'yes' ) {
+ $mydomain = "$blog_id.$domain";
+ $base = '/';
+ } else {
+ $mydomain = $domain;
+ $base = "/$blog_id/";
+ }
+ if ( domain_exists($mydomain, $base) )
+ $errors->add('blog_id', __("Sorry, that blog already exists!"));
+
+ // Has someone already signed up for this domain?
+ // TODO: Check email too?
+ $signup = $wpdb->get_row("SELECT * FROM $wpdb->signups WHERE domain = '$mydomain'");
+ if ( ! empty($signup) ) {
+ $registered_at = mysql2date('U', $signup->registered);
+ $now = current_time( 'timestamp', true );
+ $diff = $now - $registered_at;
+ // If registered more than two days ago, cancel registration and let this signup go through.
+ if ( $diff > 172800 ) {
+ $wpdb->query("DELETE FROM $wpdb->signups WHERE domain = '$mydomain'");
+ } else {
+ $errors->add('blog_id', __("That blog is currently reserved but may be available in a couple days."));
+ }
+ }
+
+ $result = array('domain' => $mydomain, 'path' => $base, 'blog_id' => $blog_id, 'blog_title' => $blog_title, 'user_name' => $user_name, 'user_email' => $user_email,
+ 'errors' => $errors);
+
+ return apply_filters('wpmu_validate_signup', $result);
+}
+
+// Record signup information for future activation. wpmu_validate_signup() should be run
+// on the inputs before calling wpmu_signup().
+function wpmu_signup($domain, $path, $title, $user, $user_email, $meta = '') {
+ global $wpdb;
+
+ $key = substr( md5( time() . rand() . $domain ), 0, 16 );
+ $registered = current_time('mysql', true);
+ $meta = serialize($meta);
+ $domain = $wpdb->escape($domain);
+ $path = $wpdb->escape($path);
+ $title = $wpdb->escape($title);
+ $wpdb->query( "INSERT INTO $wpdb->signups ( domain, path, title, user_login, user_email, registered, activation_key, meta )
+ VALUES ( '$domain', '$path', '$title', '$user', '$user_email', '$registered', '$key', '$meta' )" );
+
+ wpmu_signup_notification($domain, $path, $title, $user, $user_email, $key, $meta);
+}
+
+// Notify user of signup success.
+function wpmu_signup_notification($domain, $path, $title, $user, $user_email, $key, $meta = '') {
+ // Send email with activation link.
+ $message_headers = 'From: ' . stripslashes($title) . ' <support@' . $_SERVER[ 'SERVER_NAME' ] . '>';
+ $message = sprintf(__("To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your blog here:\n\n%s\n\nAnd you can login on the home page:\n\nhttp://wordpress.com/"),
+ "http://wordpress.com/activate/$key", "http://$domain");
+ // TODO: Don't hard code activation link.
+ $subject = sprintf(__('Activate %s'), $domain);
+ wp_mail($user_email, $subject, $message, $message_headers);
+}
+
+function wpmu_activate_blog($key) {
+ global $wpdb;
+
+ $result = array();
+ $signup = $wpdb->get_row("SELECT * FROM $wpdb->signups WHERE activation_key = '$key'");
+
+ if ( empty($signup) )
+ return new WP_Error('invalid_key', __('Invalid activation key.'));
+
+ if ( $signup->active )
+ return new WP_Error('already_active', __('The blog is already active.'));
+
+ $user_login = $wpdb->escape($signup->user_login);
+ $user_email = $wpdb->escape($signup->user_email);
+ $password = generate_random_password();
+
+ $user_id = username_exists($user_login);
+
+ if ( ! $user_id )
+ $user_id = wpmu_create_user($user_login, $user_email, $password);
+
+ if ( ! $user_id )
+ return new WP_Error('create_user', __('Could not create user'));
+
+ $meta = unserialize($signup->meta);
+
+ $blog_id = wpmu_create_blog($signup->domain, $signup->path, $signup->title, $user_id, $meta);
+
+ // TODO: What to do if we create a user but cannot create a blog?
+ if ( is_wp_error($blog_id) )
+ return $blog_id;
+
+ //$wpdb->query("DELETE FROM $wpdb->signups WHERE activation_key = '$key'");
+ $now = current_time('mysql', true);
+ $wpdb->query("UPDATE $wpdb->signups SET active = '1', activated = '$now' WHERE activation_key = '$key'");
+
+ wpmu_welcome_notification($blog_id, $user_id, $password, $signup->title, $meta);
+
+ do_action('wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta);
+
+ return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta);
+}
+
+function generate_random_password() {
+ $random_password = substr(md5(uniqid(microtime())), 0, 6);
+ $random_password = apply_filters('random_password', $random_password);
+ return $random_password;
+}
+
+function wpmu_create_user( $user_name, $password, $email) {
+ if ( username_exists($user_name) )
+ return false;
+ // Check email too?
+
+ $user_id = wp_create_user( $user_name, $email, $password);
+ $user = new WP_User($user_id);
+ // Newly created users have no roles or caps until they are added to a blog.
+ update_user_option($user_id, 'capabilities', '');
+ update_user_option($user_id, 'user_level', '');
+
+ return $user_id;
+}
+
+function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1) {
+ global $wp_queries;
+ $domain = addslashes( $domain );
+ $title = addslashes( $title );
+ $user_id = (int) $user_id;
+
+ if( empty($path) )
+ $path = '/';
+
+ // Check if the domain has been used already. We should return an error message.
+ if ( domain_exists($domain, $path, $site_id) )
+ return new WP_Error('blog_taken', __('Blog already exists.'));
+
+ // 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.
+
+ if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
+ return new WP_Error('insert_blog', __('Could not create blog.'));
+
+ //define( "WP_INSTALLING", true );
+ switch_to_blog($blog_id);
+
+ install_blog($blog_id, $title);
+
+ install_blog_defaults($blog_id, $user_id);
+
+ add_user_to_blog($blog_id, $user_id, 'administrator');
+
+ restore_current_blog();
+
+ if ( is_array($meta) ) foreach ($meta as $key => $value)
+ update_blog_option( $blog_id, $key, $value );
+
+ do_action( 'wpmu_new_blog', $blog_id, $user_id );
+
+ return $blog_id;
+}
+
+function domain_exists($domain, $path, $site_id = 1) {
+ global $wpdb;
+ return $wpdb->get_var("SELECT blog_id FROM $wpdb->blogs WHERE domain = '$domain' AND path = '$path' AND site_id = '$site_id'" );
+}
+
+function insert_blog($domain, $path, $site_id) {
+ global $wpdb;
+ $query = "INSERT INTO $wpdb->blogs ( blog_id, site_id, domain, path, registered ) VALUES ( NULL, '$site_id', '$domain', '$path', NOW( ))";
+ $result = $wpdb->query( $query );
+ if ( ! $result )
+ return false;
+
+ $id = $wpdb->insert_id;
+ refresh_blog_details($id);
+ return $id;
+}
+
+// Install an empty blog. wpdb should already be switched.
+function install_blog($blog_id, $blog_title = '') {
+ global $wpdb, $table_prefix, $wp_queries;
+ $wpdb->hide_errors();
+
+ require_once( ABSPATH . 'wp-admin/upgrade-functions.php');
+ $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>');
+
+ $url = get_blogaddress_by_id($blog_id);
+ error_log("install_blog - ID: $blog_id URL: $url Title: $blog_title ", 0);
+
+ // Set everything up
+ make_db_current_silent();
+ //make_db_current();
+ populate_options();
+
+ // fix url.
+ update_option('siteurl', $url);
+ update_option('home', $url);
+ update_option('fileupload_url', $url . "files" );
+ update_option('blogname', $blog_title);
+
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '".$blog_title."' WHERE option_name = 'blogname'");
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '' WHERE option_name = 'admin_email'");
+
+ // Default category
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename) VALUES ('0', '".addslashes(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."')");
+
+ // remove all perms
+ $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = '".$table_prefix."user_level'" );
+ $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE meta_key = '".$table_prefix."capabilities'" );
+
+ $wpdb->show_errors();
+}
+
+function install_blog_defaults($blog_id, $user_id) {
+ global $wpdb, $wp_rewrite, $current_site, $table_prefix, $wpmuBaseTablePrefix;
+
+ $wpdb->hide_errors();
+
+ // 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_owner, link_rss) VALUES ('http://wordpress.com/', 'WordPress.com', 1, '$user_id', 'http://wordpress.com/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_owner, link_rss) VALUES ('http://wordpress.org/', 'WordPress.org', 1, '$user_id', 'http://wordpress.org/development/feed/');");
+
+ // Invite
+ $invitee_id = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$_POST[ 'u' ]}_invited_by' AND user_id = '0'" );
+ if( $invitee_id ) {
+ $invitee_user_login = $wpdb->get_row( "SELECT user_login, user_email FROM {$wpdb->users} WHERE ID = '$invitee_id'" );
+ $invitee_blog = $wpdb->get_row( "SELECT blog_id, meta_value from {$wpdb->blogs}, {$wpdb->usermeta} WHERE user_id = '$invitee_id' AND meta_key = 'source_domain' AND {$wpdb->usermeta}.meta_value = {$wpdb->blogs}.domain" );
+ if( $invitee_blog )
+ $invitee_siteurl = $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$invitee_blog->blog_id}_options WHERE option_name = 'siteurl'" );
+ }
+
+ if( $invitee_siteurl && $invitee_user_login )
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_owner, link_rss) VALUES ('{$invitee_siteurl}', '" . ucfirst( $invitee_user_login->user_login ) . "', 1, '$user_id', '');");
+
+ // First post
+ $now = date('Y-m-d H:i:s');
+ $now_gmt = gmdate('Y-m-d H:i:s');
+ $first_post = get_site_option( 'first_post' );
+ if( $first_post == false )
+ $first_post = stripslashes( __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ) );
+
+ $first_post = str_replace( "SITE_URL", "http://" . $current_site->domain . $current_site->path, $first_post );
+ $first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
+ $first_post = stripslashes( $first_post );
+
+ $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, comment_count) VALUES ('".$user_id."', '$now', '$now_gmt', '".addslashes($first_post)."', '".addslashes(__('Hello world!'))."', '0', '".addslashes(__('hello-world'))."', '$now', '$now_gmt', '1')");
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
+ update_option( "post_count", 1 );
+
+ // First page
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ('$user_id', '$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', 'publish', 'page', '', '', '')");
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (2, 2, 1)" );
+ // Flush rules to pick up the new page.
+ $wp_rewrite->init();
+ $wp_rewrite->flush_rules();
+
+ // 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://" . $current_site->domain . $current_site->path . "', '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.'))."')");
+
+ $user = new WP_User($user_id);
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '$user->user_email' WHERE option_name = 'admin_email'");
+
+ // Remove all perms except for the login user.
+ $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE user_id != '".$user_id."' AND meta_key = '".$table_prefix."user_level'" );
+ $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE user_id != '".$user_id."' AND meta_key = '".$table_prefix."capabilities'" );
+ // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
+ if ( $user_id != 1 )
+ $wpdb->query( "DELETE FROM ".$wpdb->usermeta." WHERE user_id = '".$user_id."' AND meta_key = '" . $wpmuBaseTablePrefix . "1_capabilities'" );
+
+ $wpdb->show_errors();
+}
+
+function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta = '') {
+ global $current_site;
+
+ $welcome_email = stripslashes( get_site_option( 'welcome_email' ) );
+ if( $welcome_email == false )
+ $welcome_email = stripslashes( __( "Dear User,
+
+Your new SITE_NAME blog has been successfully set up at:
+BLOG_URL
+
+You can log in to the administrator account with the following information:
+Username: USERNAME
+Password: PASSWORD
+Login Here: BLOG_URLwp-login.php
+
+We hope you enjoy your new weblog.
+Thanks!
+
+--The WordPress Team
+SITE_NAME" ) );
+
+ $url = get_blogaddress_by_id($blog_id);
+ $user = new WP_User($user_id);
+
+ $welcome_email = str_replace( "SITE_NAME", $current_site->site_name, $welcome_email );
+ $welcome_email = str_replace( "BLOG_URL", $url, $welcome_email );
+ $welcome_email = str_replace( "USERNAME", $user->user_login, $welcome_email );
+ $welcome_email = str_replace( "PASSWORD", $password, $welcome_email );
+
+ $welcome_email = apply_filters( "update_welcome_email", $welcome_email, $blog_id, $user_id, $password, $title, $meta);
+ $message_headers = 'From: ' . $title . ' <wordpress@' . $_SERVER[ 'SERVER_NAME' ] . '>';
+ $message = $welcome_email;
+ if( empty( $current_site->site_name ) )
+ $current_site->site_name = "WordPress MU";
+ $subject = sprintf(__('New %s Blog: %s'), $current_site->site_name, $title);
+ wp_mail($user->user_email, $subject, $message, $message_headers);
+}
+
?>
diff --git a/wp-inst/wp-login.php b/wp-inst/wp-login.php
index be7522a..4ee8d50 100644
--- a/wp-inst/wp-login.php
+++ b/wp-inst/wp-login.php
@@ -227,7 +227,7 @@ default:
<?php
if ( $error ) {
echo "<div id='login_error'>$error</div>";
- echo "<p align='center'><strong>Note:</strong> You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.com.</p>";
+ echo "<p align='center'><strong>Note:</strong> You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.</p>";
}
?>
diff --git a/wp-inst/wp-newblog.inc.php b/wp-inst/wp-newblog.inc.php
deleted file mode 100644
index d14b830..0000000
--- a/wp-inst/wp-newblog.inc.php
+++ /dev/null
@@ -1,677 +0,0 @@
-<?php
-/*
-Plugin Name: WordPress Hashcash
-Plugin URI: http://elliottback.com/wp/archives/2005/05/11/wordpress-hashcash-20/
-Description: Client-side javascript computes an md5 code, server double checks. Blocks all spam bots. XHTML 1.1 compliant.
-Author: Elliott Back
-Author URI: http://elliottback.com
-Version: 2.3
-Hat tips: Cecil Coupe - http://ccdl.dyndns.biz/werehosed/
- C.S. - http://www.cimmanon.org/
- Denis de Bernardy - http://www.semiologic.com/
- Diego Sevilla - http://neuromancer.dif.um.es/blog/
- Gene Shepherd - http://www.imporium.org/
- John F. - http://www.stonegauge.com/
- Magenson - http://blog.magenson.de/
- Matt Mullenweg - http://photomatt.net/
- Matt Warden - http://www.mattwarden.com/
- Paul Andrew Johnston - http://pajhome.org.uk/crypt/md5/
-*/
-
-/* Start the session, if not started */
-$hashcash_session_id = session_id();
-if(empty($hashcash_session_id)){
- session_start();
-}
-
-/**
- * Type: bool
- * Purpose: If true, sends logs to the admin email address
- */
-define('HASHCASH_DEBUG', true);
-
-/**
- * Type: long
- * Purpose: Stores up to HASHCASH_LONG_SIZE characters before
- * sending logs to the admin email address
- */
-define('HASHCASH_LOG_SIZE', 64000);
-
-/**
- * Type: string
- * Purpose: Must be set to the name of your comments form action
- * for internal pattern matching purposes
- */
-define('HASHCASH_FORM_ACTION', 'wp-newblog.php');
-
-/**
- * Type: string
- * Purpose: Must be set to the id of your comments form for
- * internal pattern matching purposes
- */
-define('HASHCASH_FORM_ID', 'setupform');
-
-/**
- * Type: bool
- * Purpose: If true, adds a "protected by" message to the form
- * that supports my work on this plugin, and my dedication to
- * supporting it.
- */
-define('HASHCASH_LINK', false);
-
-/**
- * Type: bool
- * Purpose: If true, writes user-specific information to the
- * form (default). Detects WP-Cache.
- */
-if(WP_CACHE){
- define('HASHCASH_PER_USER', false);
-} else {
- define('HASHCASH_PER_USER', true);
-}
-
-/**
- * Type: int
- * Purpose: An integer random to your installation, for use with
- * WP-Cache, a value only YOU can know. CHANGE IF USING WP 1.2!!
- */
-
-if(get_bloginfo('version') < 1.5){
- define('HASHCASH_PER_USER_RAND', 98246);
-} else {
- // Says Denis to save a query
- if (!get_option('wp_hashcash_version')){
- delete_option('wp_hashcash_rand');
- update_option('wp_hashcash_version', 2.3);
- }
-
- $curr = get_option('wp_hashcash_rand');
- if(empty($curr)){
- srand((double) microtime() * 1000000);
- update_option('wp_hashcash_rand', rand(10000000, 99999999));
- }
-}
-
-/**
- * Takes: An integer l and an array of strings exclude
- * Returns: A random unique string of length l
- */
-function hashcash_random_string($l, $exclude = array()) {
- // Sanity check
- if($l < 1){
- return '';
- }
-
- srand((double) microtime() * 1000000);
-
- $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $chars = preg_split('//', $alphabet, -1, PREG_SPLIT_NO_EMPTY);
- $len = count($chars) - 1;
-
- $str = '';
- while(in_array($str, $exclude) || strlen($str) < 1){
- $str = '';
- while(strlen($str) < $l){
- $str .= $chars[rand(0, $len)];
- }
- }
-
- return $str;
-}
-
-
-/**
- * Takes: A string md5_function_name to call the md5 function
- * Returns: md5 javascript bits to be randomly spliced into the header
- */
-function hashcash_get_md5_javascript($md5_function_name){
- $p = '';
- $s = '';
-
- $names = array();
- $excl = array('a', 's', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
- 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
- 'v', 'w', 'x', 'y', 'z', 'num', 'cnt', 'str', 'bin',
- 'length', 'len', 'var', 'Array', 'mask', 'return', 'msw',
- 'lsw', 'olda', 'oldb', 'oldc', 'oldd', 'function', 'new');
- for($i = 0; $i < 17; $i++){
- $t = hashcash_random_string(rand(1,6), $excl);
- $names [] = $t;
- $excl [] = $t;
- }
-
- $bits = array();
- $bits [] = $p . 'function ' . $md5_function_name . '(s){return ' . $names[5] . '(' . $names[6] . '(' . $names[7] . '(s),s.length*8));}' . $s;
- $bits [] = $p . 'function ' . $names[6] . '(x,len){x[len>>5]|=0x80<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;for(var i=0;i<x.length;i+=16){var olda=a;var oldb=b;var oldc=c;var oldd=d;a=' . $names[8] . '(a,b,c,d,x[i+0],7,-680876936);d=' . $names[8] . '(d,a,b,c,x[i+1],12,-389564586);c=' . $names[8] . '(c,d,a,b,x[i+2],17,606105819);b=' . $names[8] . '(b,c,d,a,x[i+3],22,-1044525330);a=' . $names[8] . '(a,b,c,d,x[i+4],7,-176418897);d=' . $names[8] . '(d,a,b,c,x[i+5],12,1200080426);c=' . $names[8] . '(c,d,a,b,x[i+6],17,-1473231341);b=' . $names[8] . '(b,c,d,a,x[i+7],22,-45705983);a=' . $names[8] . '(a,b,c,d,x[i+8],7,1770035416);d=' . $names[8] . '(d,a,b,c,x[i+9],12,-1958414417);c=' . $names[8] . '(c,d,a,b,x[i+10],17,-42063);b=' . $names[8] . '(b,c,d,a,x[i+11],22,-1990404162);a=' . $names[8] . '(a,b,c,d,x[i+12],7,1804603682);d=' . $names[8] . '(d,a,b,c,x[i+13],12,-40341101);c=' . $names[8] . '(c,d,a,b,x[i+14],17,-1502002290);b=' . $names[8] . '(b,c,d,a,x[i+15],22,1236535329);a=' . $names[9] . '(a,b,c,d,x[i+1],5,-165796510);d=' . $names[9] . '(d,a,b,c,x[i+6],9,-1069501632);c=' . $names[9] . '(c,d,a,b,x[i+11],14,643717713);b=' . $names[9] . '(b,c,d,a,x[i+0],20,-373897302);a=' . $names[9] . '(a,b,c,d,x[i+5],5,-701558691);d=' . $names[9] . '(d,a,b,c,x[i+10],9,38016083);c=' . $names[9] . '(c,d,a,b,x[i+15],14,-660478335);b=' . $names[9] . '(b,c,d,a,x[i+4],20,-405537848);a=' . $names[9] . '(a,b,c,d,x[i+9],5,568446438);d=' . $names[9] . '(d,a,b,c,x[i+14],9,-1019803690);c=' . $names[9] . '(c,d,a,b,x[i+3],14,-187363961);b=' . $names[9] . '(b,c,d,a,x[i+8],20,1163531501);a=' . $names[9] . '(a,b,c,d,x[i+13],5,-1444681467);d=' . $names[9] . '(d,a,b,c,x[i+2],9,-51403784);c=' . $names[9] . '(c,d,a,b,x[i+7],14,1735328473);b=' . $names[9] . '(b,c,d,a,x[i+12],20,-1926607734);a=' . $names[10] . '(a,b,c,d,x[i+5],4,-378558);d=' . $names[10] . '(d,a,b,c,x[i+8],11,-2022574463);c=' . $names[10] . '(c,d,a,b,x[i+11],16,1839030562);b=' . $names[10] . '(b,c,d,a,x[i+14],23,-35309556);a=' . $names[10] . '(a,b,c,d,x[i+1],4,-1530992060);d=' . $names[10] . '(d,a,b,c,x[i+4],11,1272893353);c=' . $names[10] . '(c,d,a,b,x[i+7],16,-155497632);b=' . $names[10] . '(b,c,d,a,x[i+10],23,-1094730640);a=' . $names[10] . '(a,b,c,d,x[i+13],4,681279174);d=' . $names[10] . '(d,a,b,c,x[i+0],11,-358537222);c=' . $names[10] . '(c,d,a,b,x[i+3],16,-722521979);b=' . $names[10] . '(b,c,d,a,x[i+6],23,76029189);a=' . $names[10] . '(a,b,c,d,x[i+9],4,-640364487);d=' . $names[10] . '(d,a,b,c,x[i+12],11,-421815835);c=' . $names[10] . '(c,d,a,b,x[i+15],16,530742520);b=' . $names[10] . '(b,c,d,a,x[i+2],23,-995338651);a=' . $names[11] . '(a,b,c,d,x[i+0],6,-198630844);d=' . $names[11] . '(d,a,b,c,x[i+7],10,1126891415);c=' . $names[11] . '(c,d,a,b,x[i+14],15,-1416354905);b=' . $names[11] . '(b,c,d,a,x[i+5],21,-57434055);a=' . $names[11] . '(a,b,c,d,x[i+12],6,1700485571);d=' . $names[11] . '(d,a,b,c,x[i+3],10,-1894986606);c=' . $names[11] . '(c,d,a,b,x[i+10],15,-1051523);b=' . $names[11] . '(b,c,d,a,x[i+1],21,-2054922799);a=' . $names[11] . '(a,b,c,d,x[i+8],6,1873313359);d=' . $names[11] . '(d,a,b,c,x[i+15],10,-30611744);c=' . $names[11] . '(c,d,a,b,x[i+6],15,-1560198380);b=' . $names[11] . '(b,c,d,a,x[i+13],21,1309151649);a=' . $names[11] . '(a,b,c,d,x[i+4],6,-145523070);d=' . $names[11] . '(d,a,b,c,x[i+11],10,-1120210379);c=' . $names[11] . '(c,d,a,b,x[i+2],15,718787259);b=' . $names[11] . '(b,c,d,a,x[i+9],21,-343485551);a=' . $names[13] . '(a,olda);b=' . $names[13] . '(b,oldb);c=' . $names[13] . '(c,oldc);d=' . $names[13] . '(d,oldd);}return Array(a,b,c,d);}' . $s;
- $bits [] = $p . 'function ' . $names[12] . '(q,a,b,x,s,t){return ' . $names[13] . '(' . $names[16] . '(' . $names[13] . '(' . $names[13] . '(a,q),' . $names[13] . '(x,t)),s),b);}function ' . $names[8] . '(a,b,c,d,x,s,t){return ' . $names[12] . '((b&c)|((~b)&d),a,b,x,s,t);}' . $s;
- $bits [] = $p . 'function ' . $names[9] . '(a,b,c,d,x,s,t){return ' . $names[12] . '((b&d)|(c&(~d)),a,b,x,s,t);}' . $s;
- $bits [] = $p . 'function ' . $names[10] . '(a,b,c,d,x,s,t){return ' . $names[12] . '(b ^ c ^ d,a,b,x,s,t);}' . $s;
- $bits [] = $p . 'function ' . $names[11] . '(a,b,c,d,x,s,t){return ' . $names[12] . '(c ^(b|(~d)),a,b,x,s,t);}' . $s;
- $bits [] = $p . 'function ' . $names[13] . '(x,y){var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF);}' . $s;
- $bits [] = $p . 'function ' . $names[16] . '(num,cnt){return(num<<cnt)|(num>>>(32-cnt));}' . $s;
- $bits [] = $p . 'function ' . $names[7] . '(str){var bin=Array();var mask=(1<<8)-1;for(var i=0;i<str.length*8;i+=8)bin[i>>5]|=(str.charCodeAt(i/8)&mask)<<(i%32);return bin;}' . $s;
- $bits [] = $p . 'function ' . $names[5] . '(' . $names[15] . '){var ' . $names[14] . '="0123456789abcdef";var str="";for(var i=0;i<' . $names[15] . '.length*4;i++){str+=' . $names[14] . '.charAt((' . $names[15] . '[i>>2]>>((i%4)*8+4))&0xF)+' . $names[14] . '.charAt((' . $names[15] . '[i>>2]>>((i%4)*8))&0xF);}return str;}' . $s;
-
- return $bits;
-}
-
-/**
- * Takes: <<void>>
- * Returns: the hashcash special code, based on the session or ip
- */
-function hashcash_special_code(){
- if(HASHCASH_PER_USER) {
- $key = strip_tags(session_id());
-
- if(!$key){
- $key = $_SERVER['REMOTE_ADDR'];
- }
-
- return md5($key . ABSPATH . $_SERVER['HTTP_USER_AGENT'] . date("F j, Y, g a"));
- } else {
- if(get_bloginfo('version') < 1.5){
- return md5(ABSPATH . get_bloginfo('version') . HASHCASH_PER_USER_RAND);
- } else {
- return md5(ABSPATH . get_bloginfo('version') . get_option('wp_hashcash_rand'));
- }
- }
-}
-
-/**
- * Takes: <<void>>
- * Returns: the hashcash special field value
- */
-function hashcash_field_value(){
- global $posts;
- return $posts[0]->ID * strlen(ABSPATH);
-}
-
-/**
- * Takes: String name of function
- * Returns: Javascript to compute field value
- */
-function hashcash_field_value_js($val_name){
- $js = 'function ' . $val_name . '(){';
-
- $type = rand(0, 5);
- switch($type){
- /* Addition of n times of field value / n, + modulus */
- case 0:
- $eax = hashcash_random_string(rand(8,10));
- $val = hashcash_field_value();
- $inc = rand(1, $val - 1);
- $n = floor($val / $inc);
- $r = $val % $inc;
-
- $js .= "var $eax = $inc; ";
- for($i = 0; $i < $n - 1; $i++){
- $js .= "$eax += $inc; ";
- }
-
- $js .= "$eax += $r; ";
- $js .= "return $eax; ";
-
- break;
-
- /* Conversion from binary */
- case 1:
- $eax = hashcash_random_string(rand(8,10));
- $ebx = hashcash_random_string(rand(8,10));
- $ecx = hashcash_random_string(rand(8,10));
- $val = hashcash_field_value();
- $binval = strrev(base_convert($val, 10, 2));
-
- $js .= "var $eax = \"$binval\"; ";
- $js .= "var $ebx = 0; ";
- $js .= "var $ecx = 0; ";
- $js .= "while($ecx < $eax.length){ ";
- $js .= "if($eax.charAt($ecx) == \"1\") { ";
- $js .= "$ebx += Math.pow(2, $ecx); ";
- $js .= "} ";
- $js .= "$ecx++; ";
- $js .= "} ";
- $js .= "return $ebx; ";
-
- break;
-
- /* Multiplication of square roots */
- case 2:
- $val = hashcash_field_value();
- $sqrt = floor(sqrt($val));
- $r = $val - ($sqrt * $sqrt);
- $js .= "return $sqrt * $sqrt + $r; ";
- break;
-
- /* Closest sum up to n */
- case 3:
- $val = hashcash_field_value();
- $n = floor((sqrt(8*$val+1)-1)/2);
- $sum = $n * ($n + 1) / 2;
- $r = $val - $sum;
- $eax = hashcash_random_string(rand(8,10));
-
- $js .= "var $eax = $r; ";
- for($i = 0; $i <= $n; $i++){
- $js .= "$eax += $i; ";
- }
- $js .= "return $eax; ";
- break;
-
- /* Closest sum up to n #2 */
- case 4:
- $val = hashcash_field_value();
- $n = floor((sqrt(8*$val+1)-1)/2);
- $sum = $n * ($n + 1) / 2;
- $r = $val - $sum;
-
- $js .= "return $r ";
- for($i = 0; $i <= $n; $i++){
- $js .= "+ $i ";
- }
- $js .= ";";
- break;
-
- /* Closest sum up to n #3 */
- case 5:
- $val = hashcash_field_value();
- $n = floor((sqrt(8*$val+1)-1)/2);
- $sum = $n * ($n + 1) / 2;
- $r = $val - $sum;
- $eax = hashcash_random_string(rand(8,10));
-
- $js .= "var $eax = $r; var i; ";
- $js .= "for(i = 0; i <= $n; i++){ ";
- $js .= "$eax += i; ";
- $js .= "} ";
- $js .= "return $eax; ";
- break;
- }
-
- $js .= "} ";
- return $js;
-}
-
-/**
- * Takes: An array matching the form
- * Returns: The form code, with input elements disabled
- */
-function hashcash_disable_callback($matches){
- $text = $matches[0];
- return preg_replace('/<input([^>]*?id="(submit|author|email|url)")/si', '<input disabled="disabled"$1', $text);
-}
-
-/**
- * Takes: An array matching the form
- * Returns: The form code, with a protected by link
- */
-function hashcash_link_callback($matches){
- $text = $matches[0];
- $r = rand(0, 4);
- switch($r){
- case 0:
- return str_replace('</form>', '<p>Protected by <a href="http://elliottback.com/" title="Elliott Back\'s Antispam Protection">WP-Hashcash</a>.</p>' . "\n" . '</form>', $text);
- break;
- case 1:
- return str_replace('</form>', '<p><a href="http://elliottback.com/" title="Elliott Back">WP-Hashcash</a>: protecting you from spam.</p>' . "\n" . '</form>', $text);
- break;
- case 2:
- return str_replace('</form>', '<p>Powered by <a href="http://elliottback.com/" title="Elliott Back, Spam Protection">WP-Hashcash</a>.</p>' . "\n" . '</form>', $text);
- break;
- case 3:
- return str_replace('</form>', '<p>I\'m <a href="http://elliottback.com/" title="Elliott Back">WP-Hashcash</a>. I eat spam.</p>' . "\n" . '</form>', $text);
- break;
- case 4:
- return str_replace('</form>', '<p>What\'s a blog without spam? <a href="http://elliottback.com/" title="Elliott Back + Spam Protection">WP-Hashcash</a>.</p>' . "\n" . '</form>', $text);
- break;
- }
-}
-
-/**
- * Takes: An array matching the form
- * Returns: The form code, with a noscript attribution
- */
-function hashcash_script_callback($matches){
- $text = $matches[0];
- return str_replace('<form', '<noscript><p>WP-Hashcash by <a href="http://elliottback.com/" title="Elliott Back\'s Blog">Elliott Back</a> protects <strong>you</strong> from spam. Please enable javascript and reload this page to add your comment.</p></noscript>' . "\n" . '<form', $text);
-}
-
-/**
- * Takes: An array matching the form
- * Returns: The form code, with appropriate javascript action
- */
-function hashcash_add_action_callback($matches){
- global $hashcash_form_action;
- return str_replace('<form', '<form onsubmit="' . $hashcash_form_action . '(\'' . hashcash_special_code() . '\');" ', $matches[0]);
-}
-
-/**
- * Takes: A WordPress single page
- * Returns: The same page with a random hidden field and others added.
- * This is the workhorse of WP-Hashcash
- */
-function hashcash_add_hidden_tag($page) {
- global $posts, $single, $hashcash_form_action, $post;
-
- if ($single && $post->comment_status == 'open'){
- $field_id = hashcash_random_string(rand(6,18));
- $field_name = hashcash_random_string(rand(6,18));
- $hashcash_form_action = hashcash_random_string(rand(6,18));
- $md5_name = hashcash_random_string(rand(6,18));
- $val_name = hashcash_random_string(rand(6,18));
- $eElement = hashcash_random_string(rand(6,18));
- $in_str = hashcash_random_string(rand(6,18));
- $fn_enable_name = hashcash_random_string(rand(6,18));
-
- /**
- * 1) Hidden hashcode
- */
-
- // Write in hidden field
- $page = str_replace('<input type="hidden" name="comment_post_ID"', '<input type="hidden" id="' . $field_id . '" name="' . $field_name . '" value="' . rand(100, 99999999) . '" /> <input type="hidden" name="comment_post_ID"', $page);
-
- // The form action
- $page = preg_replace_callback('/<form[^>]*?' . HASHCASH_FORM_ACTION . '.*?<\/form>/si', 'hashcash_add_action_callback', $page);
-
- // The javascript
- $hashcash_bits = hashcash_get_md5_javascript($md5_name);
- $hashcash_bits [] = "function $hashcash_form_action($in_str){ "
- . "$eElement = document.getElementById(\"$field_id\"); "
- . "if(!$eElement){ return false; } else { $eElement" . ".name = $md5_name($in_str); $eElement" . ".value = $val_name(); return true; }}";
-
- $hashcash_bits [] = hashcash_field_value_js($val_name);
-
- /**
- * 2) Javascript enabled form fields
- */
-
- // Disable form fields
- $page = preg_replace_callback('/<form[^>]*?' . HASHCASH_FORM_ACTION . '.*?<\/form>/si', 'hashcash_disable_callback', $page);
-
- // Try to enable all form fields from javascript
- $fields = array('submit', 'author', 'email', 'url');
- $page = str_replace('<body', '<body onload="' . $fn_enable_name . '();"', $page);
-
- $script = 'function ' . $fn_enable_name . '(){';
- shuffle($fields);
- foreach($fields as $field){
- $field_temp = hashcash_random_string(rand(6,18));
- $script .= "$field_temp = document.getElementById('$field'); if(!$field_temp){} else { $field_temp.disabled = false; } ";
- }
-
- // Other things that happen onload()
- $script .= "document.getElementById('" . HASHCASH_FORM_ID . "').style.display = 'block';";
-
- // Terminator
- $script .= '}';
- $hashcash_bits [] = $script;
-
- /**
- * 3) Hide form for non-users of javascript
- */
-
- $page = preg_replace_callback('/<form[^>]*?' . HASHCASH_FORM_ACTION . '.*?<\/form>/si', 'hashcash_script_callback', $page);
- $page = str_replace('</head>', '<style type="text/css">#' . HASHCASH_FORM_ID . '{ display: none; }</style>' . "\n" . '</head>', $page);
-
- /**
- * 4) Write all the javascript bits to various lines of <head>
- */
-
- shuffle($hashcash_bits);
- $js = '<script type="text/javascript">' . "\n"
- . '<!--' . "\n"
- . implode(" ", $hashcash_bits) . "\n"
- . '-->' . "\n"
- . '</script>' . "\n";
- $page = str_replace('</head>', $js . '</head>', $page);
-
- /**
- * 5) Powered by WP-Hashcash
- */
-
- if(HASHCASH_LINK)
- $page = preg_replace_callback('/<form[^>]*?' . HASHCASH_FORM_ACTION . '.*?<\/form>/si', 'hashcash_link_callback', $page);
- }
-
- return $page;
-}
-
-/**
- * Takes: <<void>>
- * Returns: Buffered page output w/ hashcash inserted
- */
-function hashcash_call_stopgap() {
- ob_start('hashcash_add_hidden_tag');
-}
-
-add_action('wp_head', 'hashcash_call_stopgap');
-
-/**
- * Takes: The text of a comment
- * Returns: <<void>>, writes comment to log
- */
-function write_comment_log($comment){
-
- /* Information to write to log */
- $user = array();
- $user[] = date("F j, Y, g:i a");
- $user[] = $_SERVER['REMOTE_ADDR'];
- $user[] = $_SERVER['HTTP_USER_AGENT'];
- $user[] = $_SERVER['HTTP_REFERER'];
- $user[] = $_POST['author'];
- $user[] = $_POST['email'];
- $user[] = $_POST['url'];
- $user[] = preg_replace('/[\n\r]+/','<br />', $comment);
- $user[] = $_POST['comment_post_ID'];
-
- $lines = join($user, "\n");
-
- /* In 1.5, use options. */
- $path = ABSPATH . "wp-content/plugins/wp-hashcash.log";
- if(get_bloginfo('version') < 1.5){
- /* Open the file */
- $file = fopen($path, 'a+');
- if(!$file) die("File \"$path\" failed to open");
-
- /* Save the log */
- $status = fwrite($file, "\n" . $lines);
-
- /* Close the file */
- fclose($file);
- if(!status) die("Spam-log write failed...");
-
- /* Read the file */
- $new = file($path);
- } else {
- add_option('wp_hashcash_log', '', 'Log option for the wp-hashcash plugin', 'no');
- $current = get_option('wp_hashcash_log');
- $new = $current . "\n" . $lines;
- update_option('wp_hashcash_log', $new);
- }
-
- /* If we're here, the file exists. Check size, email every 64kb */
- if( strlen($new) > HASHCASH_LOG_SIZE ) {
- $header = "<html><head><style>tr { margin: 0px 0px 5px 20px; }</style></head><body><h2>Spam Report:</h2>";
- $footer = "</body></html>";
-
- // Process log
- $log = $header;
- $i = false;
-
- $temp = explode("\n", $new);
-
- $count = count($temp) / 9;
- $log .= "<p>There were $count spam...</p>";
-
- // Table
- $log .= "<table>";
- for ($j = 0; $j < count($temp) - 1; $j++) {
- if ($i)
- $log .= '<tr style="background-color: #eee">';
- else
- $log .= '<tr>';
-
- $log .= "<td>";
- $log .= $temp[$j]; $j++;
- $log .= "<blockquote>";
- $log .= "<strong>IP:</strong> $temp[$j]<br />"; $j++;
- $log .= "<strong>User-Agent:</strong> $temp[$j]<br />"; $j++;
- $log .= "<strong>Referer:</strong> <a href=\"$temp[$j]\">$temp[$j]</a><br />"; $j++;
- $log .= "<strong>Author:</strong> $temp[$j]<br />"; $j++;
- $log .= "<strong>Email:</strong> <a href=\"mailto:$temp[$j]\">$temp[$j]</a><br />"; $j++;
- $log .= "<strong>URL:</strong> <a href=\"$temp[$j]\">$temp[$j]</a><br />"; $j++;
- $log .= "<br />";
- $log .= $temp[$j]; $j++;
- $log .= "<br /><br />";
- $log .= "on post <a href=\"" . get_settings('siteurl') . "/index.php?p=" . $temp[$j] . "\">" . $temp[$j] . "</a>";
- $log .= "</blockquote>";
- $log .="</td>";
- $log .= "</tr>";
- $i = !$i;
- }
- $log .= "</table>";
-
- // Footer
- $log .= $footer;
-
- // Send email
- $headers = "Content-type: text/html; charset=" . get_settings('blog_charset') . "\r\n";
- mail(get_settings('admin_email'), '[' . get_settings('blogname') . '] Spam Report', $log, $headers);
-
- // Clear file
- if(get_bloginfo('version') < 1.5){
- $file = fopen($path, 'w');
- if(!file){
- die("Unable to truncate old log file");
- } else{
- fclose($file);
- }
- } else {
- update_option('wp_hashcash_log', '');
- }
- }
-}
-
-/**
- * Takes: The text of a comment
- * Returns: The comment iff it matches the hidden md5'ed tag
- */
-function hashcash_check_hidden_tag($comment) {
- // Our special codes, fixed to check the previous hour
- $special = array();
-
- if(HASHCASH_PER_USER){
- $special[] = md5($_SERVER['REMOTE_ADDR'] . ABSPATH . $_SERVER['HTTP_USER_AGENT'] . date("F j, Y, g a"));
- $special[] = md5($_SERVER['REMOTE_ADDR'] . ABSPATH . $_SERVER['HTTP_USER_AGENT'] . date("F j, Y, g a", time()-(60*60)));
- $special[] = md5(strip_tags(session_id()) . ABSPATH . $_SERVER['HTTP_USER_AGENT'] . date("F j, Y, g a"));
- $special[] = md5(strip_tags(session_id()) . ABSPATH . $_SERVER['HTTP_USER_AGENT'] . date("F j, Y, g a", time()-(60*60)));
- } else {
- if(get_bloginfo('version') < 1.5){
- $special[] = md5(ABSPATH . get_bloginfo('version') . HASHCASH_PER_USER_RAND);
- } else {
- $special[] = md5(ABSPATH . get_bloginfo('version') . get_option('wp_hashcash_rand'));
- }
- }
-
- foreach($special as $val){
- if($_POST[md5($val)] == ($_POST['comment_post_ID'] * strlen(ABSPATH))){
- return $comment;
- }
- }
-
- // If here, the comment has failed the check
- if( HASHCASH_DEBUG )
- write_comment_log($comment);
-
- // Be more user friendly if we detect spam, and it sends a referer
- if(strlen(trim($_SERVER['HTTP_REFERER'])) > 0 && preg_match('|' . get_bloginfo('url') . '|i', $_SERVER['HTTP_REFERER']))
- echo '
-<!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" lang="en">
- <head profile="http://gmpg.org/xfn/11">
- <title>WP-Hashcash Check Failed</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <style type="text/css">
- body {
- font-family: Arial, Verdana, Helvetica;
- color: #3F3F3F;
- }
-
- h1 {
- margin: 0px;
- color: #6A8E1C;
- font-size: 1.8em;
- }
-
- a:link {
- color: #78A515;
- font-weight: bold;
- text-decoration: none;
- }
-
- a:visited { color: #999; }
-
- a:hover, a:active {
- background: #78A515;
- color: #fff;
- text-decoration: none;
- }
- </style>
- </head>
-
- <body>
- <div style="margin: 0 auto; margin-top:50px; padding: 20px; text-align: left; width: 400px; border: 1px solid #78A515;">
- <h1>WP-Hashcash Check Failed</h1>
-
- <p>Your client has failed to compute the special javascript hashcode required to comment on this blog.
- If you believe this to be in error, please contact the blog administrator, and check for javascript,
- validation, or php errors. It is also possible that you are trying to spam this blog.</p>
-
- <p>If you are using Google Web Accelerator, a proxy, or some other caching system, WP-Hashcash may not let you comment.
- There are known issues with caching that are fundamentally insoluble, because the page being written to you must be generated freshly.
- Turn off your caching software and reload the page. If you are using a proxy, commenting should work, but it is untested.</p>';
-
-/* Possible sources of error */
-
-if(!session_id()){
- echo '<p style="border: 2px solid red; color:red; padding:4px;">Unable to generate you a Session ID, falling back on your remote address,
-which appears to be ' . $_SERVER['REMOTE_ADDR'] . '. If this is not your remote address, this is the cause of the error.</p>';
-}
-
-if(!session_id() && strlen($_SERVER['REMOTE_ADDR']) < 1){
- echo '<p style="border: 2px solid red; color:red; padding:4px;">Your remote address is null.</p>';
-}
-
-if(!in_array($_POST['comment_post_ID'] * strlen(ABSPATH), $_POST)){
- echo '<p style="border: 2px solid red; color:red; padding:4px;">The value you submitted (' . $_POST[md5($val)] . ')
- is incorrect. Check the javascript to assure that the value part of the (hash, value) pair is being correctly
- generated.</p>';
-}
-
-$hashash = false;
-foreach($special as $spec){
- if(array_key_exists($spec, $_POST))
- $hashash = true;
-}
-
-if($hashash) {
- echo '<p style="border: 2px solid red; color:red; padding:4px;">The hash does not exist.
- Check the javascript to assure that the md5 hash part of the (hash, value) pair is
- being correctly generated.</p>';
-}
-
-if(WP_CACHE && HASHCASH_PER_USER){
- echo '<p style="border: 2px solid red; color:red; padding:4px;">WP-Cache is detected, but for
- some reason, HASHCASH_PER_USER is set to true.</p>';
-}
-
-echo' <p>This comment has been logged, and will not be displayed on the blog.</p>
- </div>
- </body>
-</html>';
-
- die();
-}
-
-add_filter('newblog_id', 'hashcash_check_hidden_tag');
-
-?>
diff --git a/wp-inst/wp-newblog.php b/wp-inst/wp-newblog.php
deleted file mode 100644
index d7b41fe..0000000
--- a/wp-inst/wp-newblog.php
+++ /dev/null
@@ -1,256 +0,0 @@
-<?php
-require('wp-config.php');
-
-do_action( "newblogheader", "" );
-include( "wp-newblog.inc.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
-
-function displayInitialForm( $weblog_id = '', $weblog_title = '', $admin_email = '', $admin_login = '', $form = '', $errormsg = '' ) {
- global $current_site;
- 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="setupform" id="setupform" 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>';
- }
- ?><th valign="top">Username:</th><td><?php
- if( strlen( $errormsg[ 'weblog_id' ] ) > 3 ) {
- ?><p><strong>Warning! <?php echo $errormsg[ 'weblog_id' ] ?></strong></p><?php
- }
- print '<input name="weblog_id" type="text" id="weblog_id" value="'.$weblog_id.'" maxlength="50" style="width:40%; text-align: right; font-size: 30px;" /><span style="font-size: 30px">.' . $current_site->domain . '</span><br />(<strong>Your address will be username.' . $current_site->domain . '.</strong> Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)</td> </tr>';
- if( $errormsg[ 'weblog_title' ] != '' ) {
- print '<tr class="error">';
- } else {
- print '<tr>';
- }
- ?><th valign="top">Blog Title:</th><td><?php
- if( strlen( $errormsg[ 'weblog_title' ] ) > 3 ) {
- ?><p><strong>Warning! <?php echo $errormsg[ 'weblog_title' ] ?></strong></p><?php
- }
- print '<input name="weblog_title" type="text" id="weblog_title" value="'.wp_specialchars( $weblog_title, 1 ).'" /></td>
- </tr>';
- if( $errormsg[ 'admin_email' ] != '' ) {
- print '<tr class="error">';
- } else {
- print '<tr>';
- }
- ?><th valign="top">Email&nbsp;Address:</th><td><?php
- if( strlen( $errormsg[ 'admin_email' ] ) > 3 ) {
- ?><p><strong>Warning! <?php echo $errormsg[ 'admin_email' ] ?></strong></p><?php
- }
- print '
- <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 id="submit" 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);
-
- return $result;
-}
-
-function get_invited_details( $u ) {
- global $wpdb;
- $email = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$u}_to_email' AND user_id = '0'" );
- $name = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$u}_to_name' AND user_id = '0'" );
- $invitee_id = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$u}_invited_by' AND user_id = '0'" );
- if( $invitee_id ) {
- $invitee_user_login = $wpdb->get_row( "SELECT user_login, user_email FROM {$wpdb->users} WHERE ID = '$invitee_id'" );
- } else {
- $invitee_user_login = false;
- }
- $user_login = '';
- if( $name != false ) {
- $user_login = strtolower( $name );
- if( $wpdb->get_var( "SELECT user_login FROM {$wpdb->users} WHERE user_login = '{$user_login}'" ) != false ) {
- $count = 1;
- while( $wpdb->get_var( "SELECT user_login FROM {$wpdb->users} WHERE user_login = '{$user_login}{$count}'" ) != false ) {
- $count ++;
- }
- $user_login = $user_login . $count;
- }
- $weblog_title = $name."'s Blog";
- } else {
- $weblog_title = '';
- }
- return array( "email" => $email, "name" => $name, "user_login" => $user_login, "weblog_title" => $weblog_title, "invitee_id" => $invitee_id, "invitee_user_login" => $invitee_user_login );
-}
-
-switch( $_POST[ 'stage' ] )
-{
- case "1":
- $illegal_names = get_site_option( "illegal_names" );
- if( $illegal_names == false ) {
- $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" );
- add_site_option( "illegal_names", $illegal_names );
- }
-
- $newBlogID = sanitize_title($_POST['weblog_id']);
- preg_match( "/[a-zA-Z0-9]+/", $newBlogID, $maybe );
- if( $newBlogID != $maybe[0] ) {
- $errormsg[ 'weblog_id' ] = "Only letters and numbers allowed";
- }
- if( in_array( $newBlogID, $illegal_names ) == true ) {
- $errormsg[ 'weblog_id' ] = "That name is not allowed";
- }
- if( strlen( $newBlogID ) < 4 ) {
- $errormsg[ 'weblog_id' ] = "Username must be at least 4 characters";
- }
- $weblog_title = stripslashes( $_POST[ 'weblog_title' ] );
- $admin_email = $_POST[ 'admin_email' ];
-
- if( is_email( $admin_email ) == false )
- $errormsg[ 'admin_email' ] = "Please enter a correct email address";
-
- if( empty( $newBlogID ) )
- $errormsg[ 'weblog_id' ] = "Please enter a username";
-
- if( empty( $weblog_title ) )
- $errormsg[ 'weblog_title' ] = "Please enter a blog title";
-
- $newBlogID = apply_filters( "newblog_id", $newBlogID );
-
- 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 ) {
- $admin_id = $wpdb->get_var( "SELECT ID FROM ".$wpdb->users." WHERE user_pass = '".md5( $_POST[ 'admin_pw' ] )."' AND user_login = 'admin'" );
- 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."/";
- }
- $source = 'regpage';
- if( $_POST[ 'u' ] ) {
- $source = apply_filters( "get_wpmu_reg_source", $source );
- }
- $err = createBlog( $newBlogID.".".$domain, $scriptBaseName, $newBlogID, $weblog_title, $admin_email, $source );
- if( $err == 'ok' ) {
- if( $_POST[ 'u' ] ) {
- $details = get_invited_details( $_POST[ 'u' ] );
- }
- displaySecondForm();
- $email = get_site_option( "admin_email" );
- $msg = "A new blog has been created on " . $current_site->domain . $current_site->path . "\n";
- $msg .= "Address: http://" . $newBlogID . "." . $domain . $scriptBaseName . "\n";
- $msg .= "Title: $weblog_title\n";
- $msg .= "Email: $admin_email\n";
- $msg .= 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n";
- if( is_object( $details[ 'invitee_user_login' ] ) ) {
- $logindetails = $details[ 'invitee_user_login' ];
- $msg .= "User invited by {$logindetails->user_login} ({$logindetails->user_email})\n";
- }
- $msg .= "Backend: http://" . $newBlogID . "." . $domain . $scriptBaseName . "wp-login.php (You can login with your admin u/p)\n";
- $subject = "New Blog on: http://" . $current_site->domain . $current_site->path;
- mail( $email, $subject, $msg, "From: WordPress <" . $email . ">" );
- } else {
- if( $err == 'error: username used' ) {
- $errormsg[ 'weblog_id' ] = "Sorry, that blog already exists!";
- } elseif( $err == 'error: email domain not allowed' ) {
- $errormsg[ 'admin_email' ] = "Sorry, that email address is not allowed!";
- } elseif( $err == 'error: email used' ) {
- $errormsg[ 'admin_email' ] = "Sorry, that email address is already used!";
- } elseif( $err == 'error: username must not contain _' ) {
- $errormsg[ 'weblog_id' ] = "Sorry, usernames may not contain the character '_'!";
- } 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:
- if( $_GET[ 'u' ] ) {
- $details = get_invited_details( $_GET[ 'u' ] );
- }
- displayInitialForm( $details[ 'user_login' ], $details[ 'weblog_title' ], $details[ 'email' ] );
- break;
-}
-
-?>
-</div>
-<?php get_footer(); ?>
diff --git a/wp-inst/wp-settings.php b/wp-inst/wp-settings.php
index ea85ae9..8a12855 100644
--- a/wp-inst/wp-settings.php
+++ b/wp-inst/wp-settings.php
@@ -75,113 +75,14 @@ if ( defined('WP_CACHE') )
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';
-$wpdb->sitecategories = $table_prefix . 'sitecategories';
+$wpdb->blogs = 'wp_blogs';
+$wpdb->users = 'wp_users';
+$wpdb->usermeta = 'wp_usermeta';
+$wpdb->site = 'wp_site';
+$wpdb->sitemeta = 'wp_sitemeta';
+$wpdb->sitecategories = 'wp_sitecategories';
-
-// find out what tables to use from $wpblog
-$wpdb->hide_errors();
-
-$domain = addslashes($_SERVER['HTTP_HOST']);
-if( substr( $domain, 0, 4 ) == 'www.' )
- $domain = substr( $domain, 4 );
-$domain = preg_replace('/:.*$/', '', $domain); // Strip ports
-
-function is_installed() {
- global $wpdb, $domain, $base;
-
- if( defined( "WP_INSTALLING" ) == false ) {
- $check = $wpdb->get_results( "SELECT * FROM $wpdb->site" );
- if( $check == false ) {
- $msg = '<strong>Database Tables Missing.</strong><br /> The table <em>' . DB_NAME . '::' . $wpdb->site . '</em> is missing. Delete the .htaccess file and run the installer again!<br />';
- } else {
- $msg = '<strong>Could Not Find Blog!</strong><br />';
- $msg .= "Searched for <em>" . $domain . $base . "</em> in " . DB_NAME . "::" . $wpdb->blogs . " table. Is that right?<br />";
- }
- $msg .= "Please check that your database contains the following tables:<ul>
- <li> $wpdb->blogs </li>
- <li> $wpdb->users </li>
- <li> $wpdb->usermeta </li>
- <li> $wpdb->site </li>
- <li> $wpdb->sitemeta </li>
- <li> $wpdb->sitecategories </li>
- </ul>";
- $msg .= "If you suspect a problem please report it to <a href='http://mu.wordpress.org/forums/'>support forums</a>!";
- die( "<h1>Fatal Error</h1> " . $msg );
- }
-}
-if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
- $current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain = '$domain' AND path = '$base'");
-} else {
- if( $base == '/' ) {
- $wpblog = substr( $_SERVER[ 'REQUEST_URI' ], 1 );
- } else {
- $wpblog = str_replace( $base, '', $_SERVER[ 'REQUEST_URI' ] );
- }
- if( strpos( $wpblog, '/' ) )
- $wpblog = substr( $wpblog, 0, strpos( $wpblog, '/' ) );
- if( $wpblog == '' || file_exists( ABSPATH . $wpblog ) || is_dir( ABSPATH . $wpblog ) ) {
- $searchdomain = $domain;
- } else {
- $searchdomain = $wpblog . "." . $domain;
- }
- $current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain = '{$searchdomain}' AND path = '$base'");
-}
-if( $current_blog == false ) {
- is_installed();
-}
-$blog_id = $current_blog->blog_id;
-$public = $current_blog->public;
-$site_id = $current_blog->site_id;
-if( $site_id == 0 )
- $site_id = 1;
-
-$current_site = $wpdb->get_row("SELECT * FROM $wpdb->site WHERE id='$site_id'");
-if( $current_site == false ) {
- is_installed();
-}
-$current_site->site_name = $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = '$site_id' AND meta_key = 'site_name'" );
-if( $current_site->site_name == false ) {
- $current_site->site_name = ucfirst( $current_site->domain );
- include( ABSPATH . "wp-admin/wpmu-upgrade.inc.php" );
-}
-
-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 {
- $check = $wpdb->get_results( "SELECT * FROM $wpdb->site" );
- if( $check == false ) {
- $msg = ': DB Tables Missing';
- } else {
- $msg = '';
- }
- die( "No Blog by that name on this system." . $msg );
- }
-}
-
-if( '0' == $current_blog->public ) {
- // This just means the blog shouldn't show up in google, etc. Only to registered members
-}
-
-$wpdb->show_errors();
-
-$table_prefix = $table_prefix . $blog_id . '_';
+require_once ( ABSPATH . 'wpmu-settings.php' );
// Table names
$wpdb->siteid = $site_id;
@@ -191,9 +92,11 @@ $wpdb->categories = $table_prefix . 'categories';
$wpdb->post2cat = $table_prefix . 'post2cat';
$wpdb->comments = $table_prefix . 'comments';
$wpdb->links = $table_prefix . 'links';
+$wpdb->link2cat = $table_prefix . 'link2cat';
$wpdb->linkcategories = $table_prefix . 'linkcategories';
$wpdb->options = $table_prefix . 'options';
$wpdb->postmeta = $table_prefix . 'postmeta';
+$wpdb->signups = $table_prefix . 'signups';
$wpdb->prefix = $table_prefix;
if ( defined('CUSTOM_USER_TABLE') )
@@ -247,18 +150,25 @@ require (ABSPATH . WPINC . '/functions-formatting.php');
require (ABSPATH . WPINC . '/functions-post.php');
require (ABSPATH . WPINC . '/capabilities.php');
require (ABSPATH . WPINC . '/classes.php');
+require (ABSPATH . WPINC . '/query.php');
+require (ABSPATH . WPINC . '/theme.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 . '/comment.php');
+require (ABSPATH . WPINC . '/comment-template.php');
+require (ABSPATH . WPINC . '/rewrite.php');
require (ABSPATH . WPINC . '/feed-functions.php');
-require (ABSPATH . WPINC . '/links.php');
+require (ABSPATH . WPINC . '/template-functions-bookmarks.php');
require (ABSPATH . WPINC . '/kses.php');
+require (ABSPATH . WPINC . '/cron.php');
require (ABSPATH . WPINC . '/version.php');
+require (ABSPATH . WPINC . '/deprecated.php');
require_once( ABSPATH . WPINC . '/wpmu-functions.php' );
+require_once( ABSPATH . WPINC . '/registration-functions.php');
if( defined( "WP_INSTALLING" ) == false ) {
$current_site->site_name = get_site_option('site_name');
@@ -290,15 +200,6 @@ if( $is_archived == 'yes' ) {
die( "This blog has been archived or suspended temporarily. Please check back later." );
}
-if( $current_blog->archived == '1' ) {
- die( 'This blog has been archived or suspended.' );
-}
-
-if( $current_blog->spam == '1' ) {
- die( 'This blog has been archived or suspended.' );
-}
-
-
if (!strstr($_SERVER['PHP_SELF'], 'install.php') && !strstr($_SERVER['PHP_SELF'], 'wp-admin/import')) :
// Used to guarantee unique hash cookies
$cookiehash = ''; // Remove in 1.4
@@ -306,9 +207,9 @@ if (!strstr($_SERVER['PHP_SELF'], 'install.php') && !strstr($_SERVER['PHP_SELF']
endif;
if ( !defined('USER_COOKIE') )
- define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH);
+ define('USER_COOKIE', 'wordpressuser');
if ( !defined('PASS_COOKIE') )
- define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH);
+ define('PASS_COOKIE', 'wordpresspass');
if ( !defined('COOKIEPATH') )
define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' ) );
if ( !defined('SITECOOKIEPATH') )
@@ -318,14 +219,6 @@ if ( !defined('COOKIE_DOMAIN') )
require (ABSPATH . WPINC . '/vars.php');
-/*
-// Check for hacks file if the option is enabled
-if (get_settings('hack_file')) {
- if (file_exists(ABSPATH . '/my-hacks.php'))
- require(ABSPATH . '/my-hacks.php');
-}
-*/
-
if ( get_settings('active_plugins') ) {
$current_plugins = get_settings('active_plugins');
if ( is_array($current_plugins) ) {
@@ -368,6 +261,8 @@ load_default_textdomain();
// Pull in locale data after loading text domain.
require_once(ABSPATH . WPINC . '/locale.php');
+$wp_locale = new WP_Locale();
+
// Load functions for active theme.
if ( file_exists(TEMPLATEPATH . "/functions.php") )
include(TEMPLATEPATH . "/functions.php");
@@ -381,4 +276,4 @@ register_shutdown_function('shutdown_action_hook');
// Everything is loaded and initialized.
do_action('init');
-?>
+?> \ No newline at end of file
diff --git a/wp-inst/wp-signup.php b/wp-inst/wp-signup.php
new file mode 100644
index 0000000..fa18474
--- /dev/null
+++ b/wp-inst/wp-signup.php
@@ -0,0 +1,180 @@
+<?php
+require ('wp-config.php');
+require_once( ABSPATH . WPINC . '/registration-functions.php');
+
+do_action("signup_header");
+
+get_header();
+?>
+<div id="content" class="widecolumn">
+<style type="text/css">
+form { margin-top: 2em; }
+#submit, #blog_title, #user_email {
+ width: 90%;
+ font-size: 24px;
+}
+#language {
+ margin-top: .5em;
+}
+.error {
+ background-color: #f66;
+}
+</style>
+<?php
+function show_signup_form($blog_id = '', $blog_title = '', $user_email = '', $errors = '') {
+ global $current_user, $current_site, $wpdb;
+
+ if ( ! is_wp_error($errors) )
+ $errors = new WP_Error();
+
+ echo '<h2>' . __('Get your own WordPress MU blog in seconds') . '</h2>';
+
+ if ( $errors->get_error_code() ) {
+ print "<p>There was a problem, please correct the form below and try again.</p>";
+ }
+?>
+
+<form name="setupform" id="setupform" method="post" action="">
+<input type="hidden" name="stage" value="1">
+<table border="0" width="100%" cellpadding="9">
+<?php
+ // Blog name/Username
+ if ( $errors->get_error_message('blog_id') || $errors->get_error_message('user_name') ) {
+ print '<tr class="error">';
+ } else {
+ print '<tr>';
+ }
+ if ( !is_user_logged_in() )
+ echo '<th valign="top">' . __('Username:') . '</th><td>';
+ else
+ echo '<th valign="top">' . __('Blog Domain:') . '</th><td>';
+
+ if ( $errmsg = $errors->get_error_message('user_name') ) {
+?><p><strong><?php echo $errmsg ?></strong></p><?php
+ } else if ( $errmsg = $errors->get_error_message('blog_id') ) {
+?><p><strong><?php echo $errmsg ?></strong></p><?php
+ }
+ if ( constant( 'VHOST' ) == 'yes' )
+ echo '<input name="blog_id" type="text" id="blog_id" value="'.$blog_id.'" maxlength="50" style="width:40%; text-align: right; font-size: 30px;" /><span style="font-size: 30px">' . $current_site->domain . '</span><br />';
+ else
+ echo '<span style="font-size: 30px">' . $current_site->domain . '/</span><input name="blog_id" type="text" id="blog_id" value="'.$blog_id.'" maxlength="50" style="width:40%; font-size: 30px;" /><br />';
+
+ if ( !is_user_logged_in() ) print 'At least 4 letters and numbers only, please. It cannot be changed so choose carefully!)</td> </tr>';
+
+ // Blog Title
+ if ( $errors->get_error_message('blog_title')) {
+ print '<tr class="error">';
+ } else {
+ print '<tr>';
+ }
+?><th valign="top" width="120">Blog Title:</th><td><?php
+
+ if ( $errmsg = $errors->get_error_message('blog_title') ) {
+?><p><strong><?php echo $errmsg ?></strong></p><?php
+ }
+ print '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" /></td>
+ </tr>';
+
+ // User Email
+ // Don't show email field if user is logged in.
+ if ( !is_user_logged_in() ) {
+ if ( $errors->get_error_message('user_email') ) {
+ print '<tr class="error">';
+ } else {
+ print '<tr>';
+ }
+?><th valign="top">Email&nbsp;Address:</th><td><?php
+
+ if ( $errmsg = $errors->get_error_message('user_email') ) {
+?><p><strong><?php echo $errmsg ?></strong></p><?php
+ }
+ print '
+ <input name="user_email" type="text" id="user_email" value="'.wp_specialchars($user_email, 1).'" maxlength="200" /><br /> (We&#8217;ll send your password to this address, so double-check it.)</td>
+ </tr>';
+ }
+
+ if ( $errmsg = $errors->get_error_message('generic') )
+ print '<tr class="error"> <th colspan="2">'.$errmsg.'</th> </tr>';
+?>
+<tr>
+<th scope="row" valign="top">&nbsp;</th>
+<td><input id="submit" type="submit" name="Submit" class="submit" value="Sign Up &raquo;" /></td>
+</tr>
+<?php
+ do_action('signup_form');
+ print '
+ </table>
+ </form>';
+}
+
+function show_signup_confirm_form($domain, $path, $blog_title, $user_name, $user_email, $meta) {
+?>
+<h2><?php printf(__('%s Is Yours'), $domain) ?></h2>
+<p><?php _e('But, before you can start using your blog, <strong>you must activate it</strong>.') ?></p>
+<p><?php printf(__('Check your inbox at <strong>%1$s</strong> and click the link given. '), $user_email) ?></p>
+<p><?php _e('If you do not activate your blog within two days, you will have to sign up again.'); ?></p>
+<?php
+ do_action('signup_finished');
+}
+
+function show_create_confirm_form($domain, $path, $blog_title, $user_name, $user_email, $meta) {
+?>
+<h2><?php printf(__('%s Is Yours'), $domain) ?></h2>
+<p><?php printf(__('%1$s is your new blog. <a href="%2$s">Login</a> as "%3$s" using your existing password.'), $domain, "http://${domain}${path}wp-login.php", $user_name) ?></p>
+<?php
+ do_action('signup_finished');
+}
+
+function validate_signup_form() {
+ global $current_user;
+ if ( is_user_logged_in() )
+ $result = wpmu_validate_signup($_POST['blog_id'], $_POST['blog_title'], $current_user, $current_user->user_email);
+ else
+ $result = wpmu_validate_signup($_POST['blog_id'], $_POST['blog_title'], $_POST['blog_id'], $_POST['user_email']);
+ extract($result);
+
+ if ( empty($errors) )
+ $errors = new WP_Error();
+
+ if ( $errors->get_error_code() ) {
+ show_signup_form($blog_id, $blog_title, $user_email, $errors);
+ return;
+ }
+ $errors = new WP_Error();
+
+ if (empty ($blog_id)) {
+ $errors->add('blog_id', __("Sorry, your blog domain may only contain the characters a-z or 0-9!"));
+ show_signup_form($blog_id, $blog_title, $user_email, $errors);
+ return;
+ }
+
+ $public = (int) $_POST['blog_public'];
+ $meta = array ();
+
+ if ( is_user_logged_in() ) {
+ wpmu_create_blog($domain, $path, $blog_title, $current_user->id, $meta);
+ show_create_confirm_form($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
+ } else {
+ wpmu_signup($domain, $path, $blog_title, $blog_id, $user_email, $meta);
+ show_signup_confirm_form($domain, $path, $blog_title, $blog_id, $user_email, $meta);
+ }
+}
+
+switch ($_POST['stage']) {
+ case "1" :
+ validate_signup_form();
+ break;
+ default :
+ $user_login = '';
+ $blog_title = '';
+ $email = '';
+ if ($_GET['new'])
+ $user_login = stripslashes($_GET['new']);
+
+ show_signup_form($user_login, $blog_title, $email);
+ break;
+}
+?>
+</div>
+
+<?php get_footer(); ?> \ No newline at end of file
diff --git a/wp-inst/wpmu-settings.php b/wp-inst/wpmu-settings.php
new file mode 100644
index 0000000..5d82676
--- /dev/null
+++ b/wp-inst/wpmu-settings.php
@@ -0,0 +1,106 @@
+<?php
+
+if( defined( 'ABSPATH' ) == false )
+ die();
+
+$wpmuBaseTablePrefix = $table_prefix;
+
+$domain = addslashes( $_SERVER['HTTP_HOST'] );
+if( substr( $domain, 0, 4 ) == 'www.' )
+ $domain = substr( $domain, 4 );
+$domain = preg_replace('/:.*$/', '', $domain); // Strip ports
+
+$path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] );
+$path = str_replace ( '/wp-admin/', '/', $path );
+$path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path );
+
+$wpdb->hide_errors();
+
+if( constant( 'VHOST' ) == 'yes' )
+ $current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain = '$domain'");
+else
+ $current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain = '$domain' AND path = '$path'");
+
+if( $current_blog == false )
+ is_installed();
+
+$blog_id = $current_blog->blog_id;
+$public = $current_blog->public;
+$site_id = $current_blog->site_id;
+
+if( $site_id == 0 )
+ $site_id = 1;
+
+$current_site = $wpdb->get_row("SELECT * FROM $wpdb->site WHERE id='$site_id'");
+
+if( $current_site == false )
+ is_installed();
+
+$current_site->site_name = $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = '$site_id' AND meta_key = 'site_name'" );
+
+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 {
+ $check = $wpdb->get_results( "SELECT * FROM $wpdb->site" );
+ if( $check == false ) {
+ $msg = ': DB Tables Missing';
+ } else {
+ $msg = '';
+ }
+ die( "No Blog by that name on this system." . $msg );
+ }
+}
+
+$wpdb->show_errors();
+
+if( '0' == $current_blog->public ) {
+ // This just means the blog shouldn't show up in google, etc. Only to registered members
+}
+
+if( $current_blog->archived == '1' ) {
+ die( 'This blog has been archived or suspended.' );
+}
+
+if( $current_blog->spam == '1' ) {
+ die( 'This blog has been archived or suspended.' );
+}
+
+function is_installed() {
+ global $wpdb, $domain, $path;
+ $base = stripslashes( $base );
+ if( defined( "WP_INSTALLING" ) == false ) {
+ $check = $wpdb->get_results( "SELECT * FROM $wpdb->site" );
+ if( $check == false ) {
+ $msg = '<strong>Database Tables Missing.</strong><br /> The table <em>' . DB_NAME . '::' . $wpdb->site . '</em> is missing. Delete the .htaccess file and run the installer again!<br />';
+ } else {
+ $msg = '<strong>Could Not Find Blog!</strong><br />';
+ $msg .= "Searched for <em>" . $domain . $path . "</em> in " . DB_NAME . "::" . $wpdb->blogs . " table. Is that right?<br />";
+ }
+ $msg .= "Please check that your database contains the following tables:<ul>
+ <li> $wpdb->blogs </li>
+ <li> $wpdb->users </li>
+ <li> $wpdb->usermeta </li>
+ <li> $wpdb->site </li>
+ <li> $wpdb->sitemeta </li>
+ <li> $wpdb->sitecategories </li>
+ </ul>";
+ $msg .= "If you suspect a problem please report it to <a href='http://mu.wordpress.org/forums/'>support forums</a>!";
+ die( "<h1>Fatal Error</h1> " . $msg );
+ }
+}
+
+$table_prefix = $table_prefix . $blog_id . '_';
+
+?> \ No newline at end of file
diff --git a/wp-inst/wpmu-settings.php.dist b/wp-inst/wpmu-settings.php.dist
deleted file mode 100644
index 1e2e37e..0000000
--- a/wp-inst/wpmu-settings.php.dist
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-if( defined( 'ABSPATH' ) == false )
- die();
-
-$base="BASE";
-
-if( isset( $_REQUEST[ 'wpblog' ] ) ) $wpblog = addslashes( $_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';
-}
-
-$wpmuBaseTablePrefix = $table_prefix;
-$server = DB_HOST;
-$loginsql = DB_USER;
-$passsql = DB_PASSWORD;
-
-require_once( ABSPATH.'wp-settings.php' );
-
-?>