summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-includes
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-12 11:27:54 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-12 11:27:54 +0000
commit4f3bce79bfb5851cef9e7bc655c91bb3093cc401 (patch)
tree10a0991fddeb0e075d7fa46e2b40e5dbc64d1e88 /wp-inst/wp-includes
downloadwordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.tar.gz
wordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.tar.xz
wordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.zip
Initial Import
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-includes')
-rw-r--r--wp-inst/wp-includes/capabilities.php263
-rw-r--r--wp-inst/wp-includes/class-IXR.php815
-rw-r--r--wp-inst/wp-includes/class-pop3.php680
-rw-r--r--wp-inst/wp-includes/class-smarty.php3867
-rw-r--r--wp-inst/wp-includes/class-snoopy.php901
-rw-r--r--wp-inst/wp-includes/classes.php1526
-rw-r--r--wp-inst/wp-includes/comment-functions.php678
-rwxr-xr-xwp-inst/wp-includes/create_smarty_template.php144
-rw-r--r--wp-inst/wp-includes/default-filters.php88
-rw-r--r--wp-inst/wp-includes/feed-functions.php158
-rw-r--r--wp-inst/wp-includes/functions-compat.php92
-rw-r--r--wp-inst/wp-includes/functions-formatting.php996
-rw-r--r--wp-inst/wp-includes/functions-post.php714
-rw-r--r--wp-inst/wp-includes/functions.php2000
-rw-r--r--wp-inst/wp-includes/gettext.php358
-rw-r--r--wp-inst/wp-includes/kses.php563
-rw-r--r--wp-inst/wp-includes/links.php568
-rw-r--r--wp-inst/wp-includes/locale.php70
-rw-r--r--wp-inst/wp-includes/pluggable-functions.php282
-rw-r--r--wp-inst/wp-includes/registration-functions.php32
-rw-r--r--wp-inst/wp-includes/rss-functions.php850
-rw-r--r--wp-inst/wp-includes/streams.php159
-rw-r--r--wp-inst/wp-includes/template-functions-author.php211
-rw-r--r--wp-inst/wp-includes/template-functions-category.php402
-rw-r--r--wp-inst/wp-includes/template-functions-general.php644
-rw-r--r--wp-inst/wp-includes/template-functions-links.php492
-rw-r--r--wp-inst/wp-includes/template-functions-post.php414
-rw-r--r--wp-inst/wp-includes/template-loader.php59
-rw-r--r--wp-inst/wp-includes/vars.php113
-rw-r--r--wp-inst/wp-includes/version.php7
-rw-r--r--wp-inst/wp-includes/wp-db.php362
-rw-r--r--wp-inst/wp-includes/wp-l10n.php103
-rw-r--r--wp-inst/wp-includes/wpmu-functions.php807
33 files changed, 19418 insertions, 0 deletions
diff --git a/wp-inst/wp-includes/capabilities.php b/wp-inst/wp-includes/capabilities.php
new file mode 100644
index 0000000..af5fb58
--- /dev/null
+++ b/wp-inst/wp-includes/capabilities.php
@@ -0,0 +1,263 @@
+<?php
+
+class WP_Roles {
+ var $roles;
+
+ var $role_objects = array();
+ var $role_names = array();
+ var $role_key;
+
+ function WP_Roles() {
+ global $table_prefix;
+ $this->role_key = $table_prefix . 'user_roles';
+
+ $this->roles = get_option($this->role_key);
+
+ if ( empty($this->roles) )
+ return;
+
+ foreach ($this->roles as $role => $data) {
+ $this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']);
+ $this->role_names[$role] = $this->roles[$role]['name'];
+ }
+ }
+
+ function add_role($role, $capabilities, $display_name) {
+ $this->roles[$role] = array('name' => $display_name,
+ 'capabilities' => $capabilities);
+ update_option($this->role_key, $this->roles);
+ $this->role_objects[$role] = new WP_Role($role, $capabilities);
+ $this->role_names[$role] = $display_name;
+ }
+
+ function remove_role($role) {
+ if ( ! isset($this->role_objects[$role]) )
+ return;
+
+ unset($this->role_objects[$role]);
+ unset($this->role_names[$role]);
+ unset($this->roles[$role]);
+
+ update_option($this->role_key, $this->roles);
+ }
+
+ function add_cap($role, $cap, $grant) {
+ $this->roles[$role]['capabilities'][$cap] = $grant;
+ update_option($this->role_key, $this->roles);
+ }
+
+ function remove_cap($role, $cap) {
+ unset($this->roles[$role]['capabilities'][$cap]);
+ update_option($this->role_key, $this->roles);
+ }
+
+ function &get_role($role) {
+ if ( isset($this->role_objects[$role]) )
+ return $this->role_objects[$role];
+ else
+ return null;
+ }
+
+ function get_names() {
+ return $this->role_names;
+ }
+
+ function is_role($caps)
+ {
+ return empty($this->role_names[$cap]);
+ }
+}
+
+class WP_Role {
+ var $name;
+ var $capabilities;
+
+ function WP_Role($role, $capabilities) {
+ $this->name = $role;
+ $this->capabilities = $capabilities;
+ }
+
+ function add_cap($cap, $grant) {
+ global $wp_roles;
+
+ $this->capabilities[$cap] = $grant;
+ $wp_roles->add_cap($this->name, $cap);
+ }
+
+ function remove_cap($cap) {
+ global $wp_roles;
+
+ unset($this->capabilities[$cap]);
+ $wp_roles->remove_cap($this->name, $cap);
+ }
+
+ function has_cap($cap) {
+ if ( !empty($this->capabilities[$cap]) )
+ return $this->capabilities[$cap];
+ else
+ return false;
+ }
+
+}
+
+class WP_User {
+ var $data;
+ var $id;
+ var $caps;
+ var $cap_key;
+ var $roles;
+ var $allcaps;
+
+ function WP_User($id) {
+ global $wp_roles, $table_prefix;
+ $this->id = $id;
+ $this->data = get_userdata($id);
+ $this->cap_key = $table_prefix . 'capabilities';
+ $this->caps = &$this->data->{$this->cap_key};
+ $this->get_role_caps();
+ }
+
+ function get_role_caps() {
+ global $wp_roles;
+ //Filter out caps that are not role names and assign to $this->roles
+ if(is_array($this->caps))
+ $this->roles = array_filter($this->caps, array(&$wp_roles, 'is_role'));
+
+ //Build $allcaps from role caps, overlay user's $caps
+ $this->allcaps = array();
+ foreach($this->roles as $role => $value) {
+ $role = $wp_roles->get_role($role);
+ $this->allcaps = array_merge($this->allcaps, $role->capabilities);
+ }
+ $this->allcaps = array_merge($this->allcaps, $this->caps);
+ }
+
+ function add_role($role) {
+ $this->caps[$role] = true;
+ update_usermeta($this->id, $this->cap_key, $this->caps);
+ $this->get_role_caps();
+ $this->update_user_level_from_caps();
+ }
+
+ function remove_role($role) {
+ if(!empty($this->roles[$role]) && (count($this->roles) > 1))
+ unset($this->caps[$cap]);
+ update_usermeta($this->id, $this->cap_key, $this->caps);
+ $this->get_role_caps();
+ }
+
+ function set_role($role) {
+ foreach($this->roles as $oldrole => $value)
+ unset($this->caps[$oldrole]);
+ $this->caps[$role] = true;
+ $this->roles = array($role => true);
+ update_usermeta($this->id, $this->cap_key, $this->caps);
+ $this->get_role_caps();
+ $this->update_user_level_from_caps();
+ }
+
+ function level_reduction($max, $item) {
+ if(preg_match('/^level_(10|[0-9])$/i', $item, $matches)) {
+ $level = intval($matches[1]);
+ return max($max, $level);
+ } else {
+ return $max;
+ }
+ }
+
+ function update_user_level_from_caps() {
+ global $table_prefix;
+ $this->data->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0);
+ update_usermeta($this->id, $table_prefix.'user_level', $this->data->user_level);
+ }
+
+ function add_cap($cap, $grant = true) {
+ $this->caps[$cap] = $grant;
+ update_usermeta($this->id, $this->cap_key, $this->caps);
+ }
+
+ function remove_cap($cap) {
+ if(!empty($this->roles[$role])) return;
+ unset($this->caps[$cap]);
+ update_usermeta($this->id, $this->cap_key, $this->caps);
+ }
+
+ //has_cap(capability_or_role_name) or
+ //has_cap('edit_post', post_id)
+ function has_cap($cap) {
+ global $wp_roles;
+
+ if ( is_numeric($cap) )
+ $cap = $this->translate_level_to_cap($cap);
+
+ $args = array_slice(func_get_args(), 1);
+ $args = array_merge(array($cap, $this->id), $args);
+ $caps = call_user_func_array('map_meta_cap', $args);
+ // Must have ALL requested caps
+ foreach ($caps as $cap) {
+ //echo "Checking cap $cap<br/>";
+ if(empty($this->allcaps[$cap]) || !$this->allcaps[$cap])
+ return false;
+ }
+
+ return true;
+ }
+
+ function translate_level_to_cap($level) {
+ return 'level_' . $level;
+ }
+
+}
+
+// Map meta capabilities to primitive capabilities.
+function map_meta_cap($cap, $user_id) {
+ $args = array_slice(func_get_args(), 2);
+ $caps = array();
+
+ switch ($cap) {
+ // edit_post breaks down to edit_posts, edit_published_posts, or
+ // edit_others_posts
+ case 'edit_post':
+ $author_data = get_userdata($user_id);
+ //echo "post ID: {$args[0]}<br/>";
+ $post = get_post($args[0]);
+ $post_author_data = get_userdata($post->post_author);
+ //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
+ // If the user is the author...
+ if ($user_id == $post_author_data->ID) {
+ // If the post is published...
+ if ($post->post_status == 'publish')
+ $caps[] = 'edit_published_posts';
+ else
+ // If the post is draft...
+ $caps[] = 'edit_posts';
+ } else {
+ // The user is trying to edit someone else's post.
+ $caps[] = 'edit_others_posts';
+ // The post is published, extra cap required.
+ if ($post->post_status == 'publish')
+ $caps[] = 'edit_published_posts';
+ }
+ break;
+ default:
+ // If no meta caps match, return the original cap.
+ $caps[] = $cap;
+ }
+
+ return $caps;
+}
+
+// Capability checking wrapper around the global $current_user object.
+function current_user_can($capability) {
+ global $current_user;
+
+ $args = array_slice(func_get_args(), 1);
+ $args = array_merge(array($capability), $args);
+
+ if ( empty($current_user) )
+ return false;
+
+ return call_user_func_array(array(&$current_user, 'has_cap'), $args);
+}
+
+?>
diff --git a/wp-inst/wp-includes/class-IXR.php b/wp-inst/wp-includes/class-IXR.php
new file mode 100644
index 0000000..01c3079
--- /dev/null
+++ b/wp-inst/wp-includes/class-IXR.php
@@ -0,0 +1,815 @@
+<?php
+/*
+ IXR - The Inutio XML-RPC Library - (c) Incutio Ltd 2002-2005
+ Version 1.7 (beta) - Simon Willison, 23rd May 2005
+ Site: http://scripts.incutio.com/xmlrpc/
+ Manual: http://scripts.incutio.com/xmlrpc/manual.php
+ Made available under the BSD License: http://www.opensource.org/licenses/bsd-license.php
+*/
+
+class IXR_Value {
+ var $data;
+ var $type;
+ function IXR_Value ($data, $type = false) {
+ $this->data = $data;
+ if (!$type) {
+ $type = $this->calculateType();
+ }
+ $this->type = $type;
+ if ($type == 'struct') {
+ /* Turn all the values in the array in to new IXR_Value objects */
+ foreach ($this->data as $key => $value) {
+ $this->data[$key] = new IXR_Value($value);
+ }
+ }
+ if ($type == 'array') {
+ for ($i = 0, $j = count($this->data); $i < $j; $i++) {
+ $this->data[$i] = new IXR_Value($this->data[$i]);
+ }
+ }
+ }
+ function calculateType() {
+ if ($this->data === true || $this->data === false) {
+ return 'boolean';
+ }
+ if (is_integer($this->data)) {
+ return 'int';
+ }
+ if (is_double($this->data)) {
+ return 'double';
+ }
+ // Deal with IXR object types base64 and date
+ if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
+ return 'date';
+ }
+ if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
+ return 'base64';
+ }
+ // If it is a normal PHP object convert it in to a struct
+ if (is_object($this->data)) {
+
+ $this->data = get_object_vars($this->data);
+ return 'struct';
+ }
+ if (!is_array($this->data)) {
+ return 'string';
+ }
+ /* We have an array - is it an array or a struct ? */
+ if ($this->isStruct($this->data)) {
+ return 'struct';
+ } else {
+ return 'array';
+ }
+ }
+ function getXml() {
+ /* Return XML for this value */
+ switch ($this->type) {
+ case 'boolean':
+ return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
+ break;
+ case 'int':
+ return '<int>'.$this->data.'</int>';
+ break;
+ case 'double':
+ return '<double>'.$this->data.'</double>';
+ break;
+ case 'string':
+ return '<string>'.htmlspecialchars($this->data).'</string>';
+ break;
+ case 'array':
+ $return = '<array><data>'."\n";
+ foreach ($this->data as $item) {
+ $return .= ' <value>'.$item->getXml()."</value>\n";
+ }
+ $return .= '</data></array>';
+ return $return;
+ break;
+ case 'struct':
+ $return = '<struct>'."\n";
+ foreach ($this->data as $name => $value) {
+ $name = htmlspecialchars($name);
+ $return .= " <member><name>$name</name><value>";
+ $return .= $value->getXml()."</value></member>\n";
+ }
+ $return .= '</struct>';
+ return $return;
+ break;
+ case 'date':
+ case 'base64':
+ return $this->data->getXml();
+ break;
+ }
+ return false;
+ }
+ function isStruct($array) {
+ /* Nasty function to check if an array is a struct or not */
+ $expected = 0;
+ foreach ($array as $key => $value) {
+ if ((string)$key != (string)$expected) {
+ return true;
+ }
+ $expected++;
+ }
+ return false;
+ }
+}
+
+
+class IXR_Message {
+ var $message;
+ var $messageType; // methodCall / methodResponse / fault
+ var $faultCode;
+ var $faultString;
+ var $methodName;
+ var $params;
+ // Current variable stacks
+ var $_arraystructs = array(); // The stack used to keep track of the current array/struct
+ var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
+ var $_currentStructName = array(); // A stack as well
+ var $_param;
+ var $_value;
+ var $_currentTag;
+ var $_currentTagContents;
+ // The XML parser
+ var $_parser;
+ function IXR_Message ($message) {
+ $this->message = $message;
+ }
+ function parse() {
+ // first remove the XML declaration
+ $this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message);
+ if (trim($this->message) == '') {
+ return false;
+ }
+ $this->_parser = xml_parser_create();
+ // Set XML parser to take the case of tags in to account
+ xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
+ // Set XML parser callback functions
+ xml_set_object($this->_parser, $this);
+ xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
+ xml_set_character_data_handler($this->_parser, 'cdata');
+ if (!xml_parse($this->_parser, $this->message)) {
+ /* die(sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($this->_parser)),
+ xml_get_current_line_number($this->_parser))); */
+ return false;
+ }
+ xml_parser_free($this->_parser);
+ // Grab the error messages, if any
+ if ($this->messageType == 'fault') {
+ $this->faultCode = $this->params[0]['faultCode'];
+ $this->faultString = $this->params[0]['faultString'];
+ }
+ return true;
+ }
+ function tag_open($parser, $tag, $attr) {
+ $this->_currentTagContents = '';
+ $this->currentTag = $tag;
+ switch($tag) {
+ case 'methodCall':
+ case 'methodResponse':
+ case 'fault':
+ $this->messageType = $tag;
+ break;
+ /* Deal with stacks of arrays and structs */
+ case 'data': // data is to all intents and puposes more interesting than array
+ $this->_arraystructstypes[] = 'array';
+ $this->_arraystructs[] = array();
+ break;
+ case 'struct':
+ $this->_arraystructstypes[] = 'struct';
+ $this->_arraystructs[] = array();
+ break;
+ }
+ }
+ function cdata($parser, $cdata) {
+ $this->_currentTagContents .= $cdata;
+ }
+ function tag_close($parser, $tag) {
+ $valueFlag = false;
+ switch($tag) {
+ case 'int':
+ case 'i4':
+ $value = (int) trim($this->_currentTagContents);
+ $valueFlag = true;
+ break;
+ case 'double':
+ $value = (double) trim($this->_currentTagContents);
+ $valueFlag = true;
+ break;
+ case 'string':
+ $value = $this->_currentTagContents;
+ $valueFlag = true;
+ break;
+ case 'dateTime.iso8601':
+ $value = new IXR_Date(trim($this->_currentTagContents));
+ // $value = $iso->getTimestamp();
+ $valueFlag = true;
+ break;
+ case 'value':
+ // "If no type is indicated, the type is string."
+ if (trim($this->_currentTagContents) != '') {
+ $value = (string)$this->_currentTagContents;
+ $valueFlag = true;
+ }
+ break;
+ case 'boolean':
+ $value = (boolean) trim($this->_currentTagContents);
+ $valueFlag = true;
+ break;
+ case 'base64':
+ $value = base64_decode( trim( $this->_currentTagContents ) );
+ $valueFlag = true;
+ break;
+ /* Deal with stacks of arrays and structs */
+ case 'data':
+ case 'struct':
+ $value = array_pop($this->_arraystructs);
+ array_pop($this->_arraystructstypes);
+ $valueFlag = true;
+ break;
+ case 'member':
+ array_pop($this->_currentStructName);
+ break;
+ case 'name':
+ $this->_currentStructName[] = trim($this->_currentTagContents);
+ break;
+ case 'methodName':
+ $this->methodName = trim($this->_currentTagContents);
+ break;
+ }
+ if ($valueFlag) {
+ if (count($this->_arraystructs) > 0) {
+ // Add value to struct or array
+ if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
+ // Add to struct
+ $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
+ } else {
+ // Add to array
+ $this->_arraystructs[count($this->_arraystructs)-1][] = $value;
+ }
+ } else {
+ // Just add as a paramater
+ $this->params[] = $value;
+ }
+ }
+ $this->_currentTagContents = '';
+ }
+}
+
+
+class IXR_Server {
+ var $data;
+ var $callbacks = array();
+ var $message;
+ var $capabilities;
+ function IXR_Server($callbacks = false, $data = false) {
+ $this->setCapabilities();
+ if ($callbacks) {
+ $this->callbacks = $callbacks;
+ }
+ $this->setCallbacks();
+ $this->serve($data);
+ }
+ function serve($data = false) {
+ if (!$data) {
+ global $HTTP_RAW_POST_DATA;
+ if (!$HTTP_RAW_POST_DATA) {
+ die('XML-RPC server accepts POST requests only.');
+ }
+ $data = $HTTP_RAW_POST_DATA;
+ }
+ $this->message = new IXR_Message($data);
+ if (!$this->message->parse()) {
+ $this->error(-32700, 'parse error. not well formed');
+ }
+ if ($this->message->messageType != 'methodCall') {
+ $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
+ }
+ $result = $this->call($this->message->methodName, $this->message->params);
+ // Is the result an error?
+ if (is_a($result, 'IXR_Error')) {
+ $this->error($result);
+ }
+ // Encode the result
+ $r = new IXR_Value($result);
+ $resultxml = $r->getXml();
+ // Create the XML
+ $xml = <<<EOD
+<methodResponse>
+ <params>
+ <param>
+ <value>
+ $resultxml
+ </value>
+ </param>
+ </params>
+</methodResponse>
+
+EOD;
+ // Send it
+ $this->output($xml);
+ }
+ function call($methodname, $args) {
+ if (!$this->hasMethod($methodname)) {
+ return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
+ }
+ $method = $this->callbacks[$methodname];
+ // Perform the callback and send the response
+ if (count($args) == 1) {
+ // If only one paramater just send that instead of the whole array
+ $args = $args[0];
+ }
+ // Are we dealing with a function or a method?
+ if (substr($method, 0, 5) == 'this:') {
+ // It's a class method - check it exists
+ $method = substr($method, 5);
+ if (!method_exists($this, $method)) {
+ return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
+ }
+ // Call the method
+ $result = $this->$method($args);
+ } else {
+ // It's a function - does it exist?
+ if (is_array($method)) {
+ if (!method_exists($method[0], $method[1])) {
+ return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
+ }
+ } else if (!function_exists($method)) {
+ return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
+ }
+ // Call the function
+ $result = call_user_func($method, $args);
+ }
+ return $result;
+ }
+
+ function error($error, $message = false) {
+ // Accepts either an error object or an error code and message
+ if ($message && !is_object($error)) {
+ $error = new IXR_Error($error, $message);
+ }
+ $this->output($error->getXml());
+ }
+ function output($xml) {
+ $xml = '<?xml version="1.0"?>'."\n".$xml;
+ $length = strlen($xml);
+ header('Connection: close');
+ header('Content-Length: '.$length);
+ header('Content-Type: text/xml');
+ header('Date: '.date('r'));
+ echo $xml;
+ exit;
+ }
+ function hasMethod($method) {
+ return in_array($method, array_keys($this->callbacks));
+ }
+ function setCapabilities() {
+ // Initialises capabilities array
+ $this->capabilities = array(
+ 'xmlrpc' => array(
+ 'specUrl' => 'http://www.xmlrpc.com/spec',
+ 'specVersion' => 1
+ ),
+ 'faults_interop' => array(
+ 'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
+ 'specVersion' => 20010516
+ ),
+ 'system.multicall' => array(
+ 'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
+ 'specVersion' => 1
+ ),
+ );
+ }
+ function getCapabilities($args) {
+ return $this->capabilities;
+ }
+ function setCallbacks() {
+ $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
+ $this->callbacks['system.listMethods'] = 'this:listMethods';
+ $this->callbacks['system.multicall'] = 'this:multiCall';
+ }
+ function listMethods($args) {
+ // Returns a list of methods - uses array_reverse to ensure user defined
+ // methods are listed before server defined methods
+ return array_reverse(array_keys($this->callbacks));
+ }
+ function multiCall($methodcalls) {
+ // See http://www.xmlrpc.com/discuss/msgReader$1208
+ $return = array();
+ foreach ($methodcalls as $call) {
+ $method = $call['methodName'];
+ $params = $call['params'];
+ if ($method == 'system.multicall') {
+ $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
+ } else {
+ $result = $this->call($method, $params);
+ }
+ if (is_a($result, 'IXR_Error')) {
+ $return[] = array(
+ 'faultCode' => $result->code,
+ 'faultString' => $result->message
+ );
+ } else {
+ $return[] = array($result);
+ }
+ }
+ return $return;
+ }
+}
+
+class IXR_Request {
+ var $method;
+ var $args;
+ var $xml;
+ function IXR_Request($method, $args) {
+ $this->method = $method;
+ $this->args = $args;
+ $this->xml = <<<EOD
+<?xml version="1.0"?>
+<methodCall>
+<methodName>{$this->method}</methodName>
+<params>
+
+EOD;
+ foreach ($this->args as $arg) {
+ $this->xml .= '<param><value>';
+ $v = new IXR_Value($arg);
+ $this->xml .= $v->getXml();
+ $this->xml .= "</value></param>\n";
+ }
+ $this->xml .= '</params></methodCall>';
+ }
+ function getLength() {
+ return strlen($this->xml);
+ }
+ function getXml() {
+ return $this->xml;
+ }
+}
+
+
+class IXR_Client {
+ var $server;
+ var $port;
+ var $path;
+ var $useragent;
+ var $response;
+ var $message = false;
+ var $debug = false;
+ var $timeout;
+ // Storage place for an error message
+ var $error = false;
+ function IXR_Client($server, $path = false, $port = 80, $timeout = false) {
+ if (!$path) {
+ // Assume we have been given a URL instead
+ $bits = parse_url($server);
+ $this->server = $bits['host'];
+ $this->port = isset($bits['port']) ? $bits['port'] : 80;
+ $this->path = isset($bits['path']) ? $bits['path'] : '/';
+ // Make absolutely sure we have a path
+ if (!$this->path) {
+ $this->path = '/';
+ }
+ } else {
+ $this->server = $server;
+ $this->path = $path;
+ $this->port = $port;
+ }
+ $this->useragent = 'Incutio XML-RPC';
+ $this->timeout = $timeout;
+ }
+ function query() {
+ $args = func_get_args();
+ $method = array_shift($args);
+ $request = new IXR_Request($method, $args);
+ $length = $request->getLength();
+ $xml = $request->getXml();
+ $r = "\r\n";
+ $request = "POST {$this->path} HTTP/1.0$r";
+ $request .= "Host: {$this->server}$r";
+ $request .= "Content-Type: text/xml$r";
+ $request .= "User-Agent: {$this->useragent}$r";
+ $request .= "Content-length: {$length}$r$r";
+ $request .= $xml;
+ // Now send the request
+ if ($this->debug) {
+ echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n";
+ }
+ if ($this->timeout) {
+ $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
+ } else {
+ $fp = @fsockopen($this->server, $this->port, $errno, $errstr);
+ }
+ if (!$fp) {
+ $this->error = new IXR_Error(-32300, "transport error - could not open socket: $errno $errstr");
+ return false;
+ }
+ fputs($fp, $request);
+ $contents = '';
+ $gotFirstLine = false;
+ $gettingHeaders = true;
+ while (!feof($fp)) {
+ $line = fgets($fp, 4096);
+ if (!$gotFirstLine) {
+ // Check line for '200'
+ if (strstr($line, '200') === false) {
+ $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
+ return false;
+ }
+ $gotFirstLine = true;
+ }
+ if (trim($line) == '') {
+ $gettingHeaders = false;
+ }
+ if (!$gettingHeaders) {
+ $contents .= trim($line)."\n";
+ }
+ }
+ if ($this->debug) {
+ echo '<pre>'.htmlspecialchars($contents)."\n</pre>\n\n";
+ }
+ // Now parse what we've got back
+ $this->message = new IXR_Message($contents);
+ if (!$this->message->parse()) {
+ // XML error
+ $this->error = new IXR_Error(-32700, 'parse error. not well formed');
+ return false;
+ }
+ // Is the message a fault?
+ if ($this->message->messageType == 'fault') {
+ $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
+ return false;
+ }
+ // Message must be OK
+ return true;
+ }
+ function getResponse() {
+ // methodResponses can only have one param - return that
+ return $this->message->params[0];
+ }
+ function isError() {
+ return (is_object($this->error));
+ }
+ function getErrorCode() {
+ return $this->error->code;
+ }
+ function getErrorMessage() {
+ return $this->error->message;
+ }
+}
+
+
+class IXR_Error {
+ var $code;
+ var $message;
+ function IXR_Error($code, $message) {
+ $this->code = $code;
+ $this->message = $message;
+ }
+ function getXml() {
+ $xml = <<<EOD
+<methodResponse>
+ <fault>
+ <value>
+ <struct>
+ <member>
+ <name>faultCode</name>
+ <value><int>{$this->code}</int></value>
+ </member>
+ <member>
+ <name>faultString</name>
+ <value><string>{$this->message}</string></value>
+ </member>
+ </struct>
+ </value>
+ </fault>
+</methodResponse>
+
+EOD;
+ return $xml;
+ }
+}
+
+
+class IXR_Date {
+ var $year;
+ var $month;
+ var $day;
+ var $hour;
+ var $minute;
+ var $second;
+ function IXR_Date($time) {
+ // $time can be a PHP timestamp or an ISO one
+ if (is_numeric($time)) {
+ $this->parseTimestamp($time);
+ } else {
+ $this->parseIso($time);
+ }
+ }
+ function parseTimestamp($timestamp) {
+ $this->year = date('Y', $timestamp);
+ $this->month = date('m', $timestamp);
+ $this->day = date('d', $timestamp);
+ $this->hour = date('H', $timestamp);
+ $this->minute = date('i', $timestamp);
+ $this->second = date('s', $timestamp);
+ }
+ function parseIso($iso) {
+ $this->year = substr($iso, 0, 4);
+ $this->month = substr($iso, 4, 2);
+ $this->day = substr($iso, 6, 2);
+ $this->hour = substr($iso, 9, 2);
+ $this->minute = substr($iso, 12, 2);
+ $this->second = substr($iso, 15, 2);
+ $this->timezone = substr($iso, 17);
+ }
+ function getIso() {
+ return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second;
+ }
+ function getXml() {
+ return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
+ }
+ function getTimestamp() {
+ return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
+ }
+}
+
+
+class IXR_Base64 {
+ var $data;
+ function IXR_Base64($data) {
+ $this->data = $data;
+ }
+ function getXml() {
+ return '<base64>'.base64_encode($this->data).'</base64>';
+ }
+}
+
+
+class IXR_IntrospectionServer extends IXR_Server {
+ var $signatures;
+ var $help;
+ function IXR_IntrospectionServer() {
+ $this->setCallbacks();
+ $this->setCapabilities();
+ $this->capabilities['introspection'] = array(
+ 'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
+ 'specVersion' => 1
+ );
+ $this->addCallback(
+ 'system.methodSignature',
+ 'this:methodSignature',
+ array('array', 'string'),
+ 'Returns an array describing the return type and required parameters of a method'
+ );
+ $this->addCallback(
+ 'system.getCapabilities',
+ 'this:getCapabilities',
+ array('struct'),
+ 'Returns a struct describing the XML-RPC specifications supported by this server'
+ );
+ $this->addCallback(
+ 'system.listMethods',
+ 'this:listMethods',
+ array('array'),
+ 'Returns an array of available methods on this server'
+ );
+ $this->addCallback(
+ 'system.methodHelp',
+ 'this:methodHelp',
+ array('string', 'string'),
+ 'Returns a documentation string for the specified method'
+ );
+ }
+ function addCallback($method, $callback, $args, $help) {
+ $this->callbacks[$method] = $callback;
+ $this->signatures[$method] = $args;
+ $this->help[$method] = $help;
+ }
+ function call($methodname, $args) {
+ // Make sure it's in an array
+ if ($args && !is_array($args)) {
+ $args = array($args);
+ }
+ // Over-rides default call method, adds signature check
+ if (!$this->hasMethod($methodname)) {
+ return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
+ }
+ $method = $this->callbacks[$methodname];
+ $signature = $this->signatures[$methodname];
+ $returnType = array_shift($signature);
+ // Check the number of arguments
+ if (count($args) != count($signature)) {
+ return new IXR_Error(-32602, 'server error. wrong number of method parameters');
+ }
+ // Check the argument types
+ $ok = true;
+ $argsbackup = $args;
+ for ($i = 0, $j = count($args); $i < $j; $i++) {
+ $arg = array_shift($args);
+ $type = array_shift($signature);
+ switch ($type) {
+ case 'int':
+ case 'i4':
+ if (is_array($arg) || !is_int($arg)) {
+ $ok = false;
+ }
+ break;
+ case 'base64':
+ case 'string':
+ if (!is_string($arg)) {
+ $ok = false;
+ }
+ break;
+ case 'boolean':
+ if ($arg !== false && $arg !== true) {
+ $ok = false;
+ }
+ break;
+ case 'float':
+ case 'double':
+ if (!is_float($arg)) {
+ $ok = false;
+ }
+ break;
+ case 'date':
+ case 'dateTime.iso8601':
+ if (!is_a($arg, 'IXR_Date')) {
+ $ok = false;
+ }
+ break;
+ }
+ if (!$ok) {
+ return new IXR_Error(-32602, 'server error. invalid method parameters');
+ }
+ }
+ // It passed the test - run the "real" method call
+ return parent::call($methodname, $argsbackup);
+ }
+ function methodSignature($method) {
+ if (!$this->hasMethod($method)) {
+ return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
+ }
+ // We should be returning an array of types
+ $types = $this->signatures[$method];
+ $return = array();
+ foreach ($types as $type) {
+ switch ($type) {
+ case 'string':
+ $return[] = 'string';
+ break;
+ case 'int':
+ case 'i4':
+ $return[] = 42;
+ break;
+ case 'double':
+ $return[] = 3.1415;
+ break;
+ case 'dateTime.iso8601':
+ $return[] = new IXR_Date(time());
+ break;
+ case 'boolean':
+ $return[] = true;
+ break;
+ case 'base64':
+ $return[] = new IXR_Base64('base64');
+ break;
+ case 'array':
+ $return[] = array('array');
+ break;
+ case 'struct':
+ $return[] = array('struct' => 'struct');
+ break;
+ }
+ }
+ return $return;
+ }
+ function methodHelp($method) {
+ return $this->help[$method];
+ }
+}
+
+
+class IXR_ClientMulticall extends IXR_Client {
+ var $calls = array();
+ function IXR_ClientMulticall($server, $path = false, $port = 80) {
+ parent::IXR_Client($server, $path, $port);
+ $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
+ }
+ function addCall() {
+ $args = func_get_args();
+ $methodName = array_shift($args);
+ $struct = array(
+ 'methodName' => $methodName,
+ 'params' => $args
+ );
+ $this->calls[] = $struct;
+ }
+ function query() {
+ // Prepare multicall, then call the parent::query() method
+ return parent::query('system.multicall', $this->calls);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/class-pop3.php b/wp-inst/wp-includes/class-pop3.php
new file mode 100644
index 0000000..468ca8b
--- /dev/null
+++ b/wp-inst/wp-includes/class-pop3.php
@@ -0,0 +1,680 @@
+<?php
+
+ /**
+ * mail_fetch/setup.php
+ *
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ *
+ * Copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
+ * Modified by Philippe Mingo 2001 mingo@rotedic.com
+ * An RFC 1939 compliant wrapper class for the POP3 protocol.
+ *
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * pop3 class
+ *
+ * $Id: class-pop3.php 2066 2005-01-07 01:29:49Z saxmatt $
+ */
+
+class POP3 {
+ var $ERROR = ''; // Error string.
+
+ var $TIMEOUT = 60; // Default timeout before giving up on a
+ // network operation.
+
+ var $COUNT = -1; // Mailbox msg count
+
+ var $BUFFER = 512; // Socket buffer for socket fgets() calls.
+ // Per RFC 1939 the returned line a POP3
+ // server can send is 512 bytes.
+
+ var $FP = ''; // The connection to the server's
+ // file descriptor
+
+ var $MAILSERVER = ''; // Set this to hard code the server name
+
+ var $DEBUG = FALSE; // set to true to echo pop3
+ // commands and responses to error_log
+ // this WILL log passwords!
+
+ var $BANNER = ''; // Holds the banner returned by the
+ // pop server - used for apop()
+
+ var $RFC1939 = TRUE; // Set by noop(). See rfc1939.txt
+ //
+
+ var $ALLOWAPOP = FALSE; // Allow or disallow apop()
+ // This must be set to true
+ // manually
+
+ function POP3 ( $server = '', $timeout = '' ) {
+ settype($this->BUFFER,"integer");
+ if( !empty($server) ) {
+ // Do not allow programs to alter MAILSERVER
+ // if it is already specified. They can get around
+ // this if they -really- want to, so don't count on it.
+ if(empty($this->MAILSERVER))
+ $this->MAILSERVER = $server;
+ }
+ if(!empty($timeout)) {
+ settype($timeout,"integer");
+ $this->TIMEOUT = $timeout;
+ set_time_limit($timeout);
+ }
+ return true;
+ }
+
+ function update_timer () {
+ set_time_limit($this->TIMEOUT);
+ return true;
+ }
+
+ function connect ($server, $port = 110) {
+ // Opens a socket to the specified server. Unless overridden,
+ // port defaults to 110. Returns true on success, false on fail
+
+ // If MAILSERVER is set, override $server with it's value
+
+ if(!empty($this->MAILSERVER))
+ $server = $this->MAILSERVER;
+
+ if(empty($server)){
+ $this->ERROR = _("POP3 connect:") . ' ' . _("No server specified");
+ unset($this->FP);
+ return false;
+ }
+
+ $fp = fsockopen("$server", $port, $errno, $errstr);
+
+ if(!$fp) {
+ $this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$errno] [$errstr]";
+ unset($this->FP);
+ return false;
+ }
+
+ socket_set_blocking($fp,-1);
+ $this->update_timer();
+ $reply = fgets($fp,$this->BUFFER);
+ $reply = $this->strip_clf($reply);
+ if($this->DEBUG)
+ error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
+ if(!$this->is_ok($reply)) {
+ $this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$reply]";
+ unset($this->FP);
+ return false;
+ }
+ $this->FP = $fp;
+ $this->BANNER = $this->parse_banner($reply);
+ $this->RFC1939 = $this->noop();
+ if($this->RFC1939) {
+ $this->ERROR = _("POP3: premature NOOP OK, NOT an RFC 1939 Compliant server");
+ $this->quit();
+ return false;
+ } else
+ return true;
+ }
+
+ function noop () {
+
+ if(!isset($this->FP)) {
+ $this->ERROR = _("POP3 noop:") . ' ' . _("No connection to server");
+ return false;
+ } else {
+ $cmd = "NOOP";
+ $reply = $this->send_cmd( $cmd );
+ return( $this->is_ok( $reply ) );
+ }
+ }
+
+ function user ($user = "") {
+ // Sends the USER command, returns true or false
+
+ if( empty($user) ) {
+ $this->ERROR = _("POP3 user:") . ' ' . _("no login ID submitted");
+ return false;
+ } elseif(!isset($this->FP)) {
+ $this->ERROR = _("POP3 user:") . ' ' . _("connection not established");
+ return false;
+ } else {
+ $reply = $this->send_cmd("USER $user");
+ if(!$this->is_ok($reply)) {
+ $this->ERROR = _("POP3 user:") . ' ' . _("Error ") . "[$reply]";
+ return false;
+ } else
+ return true;
+ }
+ }
+
+ function pass ($pass = "") {
+ // Sends the PASS command, returns # of msgs in mailbox,
+ // returns false (undef) on Auth failure
+
+ if(empty($pass)) {
+ $this->ERROR = _("POP3 pass:") . ' ' . _("No password submitted");
+ return false;
+ } elseif(!isset($this->FP)) {
+ $this->ERROR = _("POP3 pass:") . ' ' . _("connection not established");
+ return false;
+ } else {
+ $reply = $this->send_cmd("PASS $pass");
+ if(!$this->is_ok($reply)) {
+ $this->ERROR = _("POP3 pass:") . ' ' . _("authentication failed ") . "[$reply]";
+ $this->quit();
+ return false;
+ } else {
+ // Auth successful.
+ $count = $this->last("count");
+ $this->COUNT = $count;
+ $this->RFC1939 = $this->noop();
+ if(!$this->RFC1939) {
+ $this->ERROR = _("POP3 pass:") . ' ' . _("NOOP failed. Server not RFC 1939 compliant");
+ $this->quit();
+ return false;
+ } else
+ return $count;
+ }
+ }
+ }
+
+ function apop ($login,$pass) {
+ // Attempts an APOP login. If this fails, it'll
+ // try a standard login. YOUR SERVER MUST SUPPORT
+ // THE USE OF THE APOP COMMAND!
+ // (apop is optional per rfc1939)
+
+ if(!isset($this->FP)) {
+ $this->ERROR = _("POP3 apop:") . ' ' . _("No connection to server");
+ return false;
+ } elseif(!$this->ALLOWAPOP) {
+ $retVal = $this->login($login,$pass);
+ return $retVal;
+ } elseif(empty($login)) {
+ $this->ERROR = _("POP3 apop:") . ' ' . _("No login ID submitted");
+ return false;
+ } elseif(empty($pass)) {
+ $this->ERROR = _("POP3 apop:") . ' ' . _("No password submitted");
+ return false;
+ } else {
+ $banner = $this->BANNER;
+ if( (!$banner) or (empty($banner)) ) {
+ $this->ERROR = _("POP3 apop:") . ' ' . _("No server banner") . ' - ' . _("abort");
+ $retVal = $this->login($login,$pass);
+ return $retVal;
+ } else {
+ $AuthString = $banner;
+ $AuthString .= $pass;
+ $APOPString = md5($AuthString);
+ $cmd = "APOP $login $APOPString";
+ $reply = $this->send_cmd($cmd);
+ if(!$this->is_ok($reply)) {
+ $this->ERROR = _("POP3 apop:") . ' ' . _("apop authentication failed") . ' - ' . _("abort");
+ $retVal = $this->login($login,$pass);
+ return $retVal;
+ } else {
+ // Auth successful.
+ $count = $this->last("count");
+ $this->COUNT = $count;
+ $this->RFC1939 = $this->noop();
+ if(!$this->RFC1939) {
+ $this->ERROR = _("POP3 apop:") . ' ' . _("NOOP failed. Server not RFC 1939 compliant");
+ $this->quit();
+ return false;
+ } else
+ return $count;
+ }
+ }
+ }
+ }
+
+ function login ($login = "", $pass = "") {
+ // Sends both user and pass. Returns # of msgs in mailbox or
+ // false on failure (or -1, if the error occurs while getting
+ // the number of messages.)
+
+ if( !isset($this->FP) ) {
+ $this->ERROR = _("POP3 login:") . ' ' . _("No connection to server");
+ return false;
+ } else {
+ $fp = $this->FP;
+ if( !$this->user( $login ) ) {
+ // Preserve the error generated by user()
+ return false;
+ } else {
+ $count = $this->pass($pass);
+ if( (!$count) || ($count == -1) ) {
+ // Preserve the error generated by last() and pass()
+ return false;
+ } else
+ return $count;
+ }
+ }
+ }
+
+ function top ($msgNum, $numLines = "0") {
+ // Gets the header and first $numLines of the msg body
+ // returns data in an array with each returned line being
+ // an array element. If $numLines is empty, returns
+ // only the header information, and none of the body.
+
+ if(!isset($this->FP)) {
+ $this->ERROR = _("POP3 top:") . ' ' . _("No connection to server");
+ return false;
+ }
+ $this->update_timer();
+
+ $fp = $this->FP;
+ $buffer = $this->BUFFER;
+ $cmd = "TOP $msgNum $numLines";
+ fwrite($fp, "TOP $msgNum $numLines\r\n");
+ $reply = fgets($fp, $buffer);
+ $reply = $this->strip_clf($reply);
+ if($this->DEBUG) {
+ @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
+ }
+ if(!$this->is_ok($reply))
+ {
+ $this->ERROR = _("POP3 top:") . ' ' . _("Error ") . "[$reply]";
+ return false;
+ }
+
+ $count = 0;
+ $MsgArray = array();
+
+ $line = fgets($fp,$buffer);
+ while ( !ereg("^\.\r\n",$line))
+ {
+ $MsgArray[$count] = $line;
+ $count++;
+ $line = fgets($fp,$buffer);
+ if(empty($line)) { break; }
+ }
+
+ return $MsgArray;
+ }
+
+ function pop_list ($msgNum = "") {
+ // If called with an argument, returns that msgs' size in octets
+ // No argument returns an associative array of undeleted
+ // msg numbers and their sizes in octets
+
+ if(!isset($this->FP))
+ {
+ $this->ERROR = _("POP3 pop_list:") . ' ' . _("No connection to server");
+ return false;
+ }
+ $fp = $this->FP;
+ $Total = $this->COUNT;
+ if( (!$Total) or ($Total == -1) )
+ {
+ return false;
+ }
+ if($Total == 0)
+ {
+ return array("0","0");
+ // return -1; // mailbox empty
+ }
+
+ $this->update_timer();
+
+ if(!empty($msgNum))
+ {
+ $cmd = "LIST $msgNum";
+ fwrite($fp,"$cmd\r\n");
+ $reply = fgets($fp,$this->BUFFER);
+ $reply = $this->strip_clf($reply);
+ if($this->DEBUG) {
+ @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
+ }
+ if(!$this->is_ok($reply))
+ {
+ $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]";
+ return false;
+ }
+ list($junk,$num,$size) = explode(" ",$reply);
+ return $size;
+ }
+ $cmd = "LIST";
+ $reply = $this->send_cmd($cmd);
+ if(!$this->is_ok($reply))
+ {
+ $reply = $this->strip_clf($reply);
+ $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]";
+ return false;
+ }
+ $MsgArray = array();
+ $MsgArray[0] = $Total;
+ for($msgC=1;$msgC <= $Total; $msgC++)
+ {
+ if($msgC > $Total) { break; }
+ $line = fgets($fp,$this->BUFFER);
+ $line = $this->strip_clf($line);
+ if(ereg("^\.",$line))
+ {
+ $this->ERROR = _("POP3 pop_list:") . ' ' . _("Premature end of list");
+ return false;
+ }
+ list($thisMsg,$msgSize) = explode(" ",$line);
+ settype($thisMsg,"integer");
+ if($thisMsg != $msgC)
+ {
+ $MsgArray[$msgC] = "deleted";
+ }
+ else
+ {
+ $MsgArray[$msgC] = $msgSize;
+ }
+ }
+ return $MsgArray;
+ }
+
+ function get ($msgNum) {
+ // Retrieve the specified msg number. Returns an array
+ // where each line of the msg is an array element.
+
+ if(!isset($this->FP))
+ {
+ $this->ERROR = _("POP3 get:") . ' ' . _("No connection to server");
+ return false;
+ }
+
+ $this->update_timer();
+
+ $fp = $this->FP;
+ $buffer = $this->BUFFER;
+ $cmd = "RETR $msgNum";
+ $reply = $this->send_cmd($cmd);
+
+ if(!$this->is_ok($reply))
+ {
+ $this->ERROR = _("POP3 get:") . ' ' . _("Error ") . "[$reply]";
+ return false;
+ }
+
+ $count = 0;
+ $MsgArray = array();
+
+ $line = fgets($fp,$buffer);
+ while ( !ereg("^\.\r\n",$line))
+ {
+ $MsgArray[$count] = $line;
+ $count++;
+ $line = fgets($fp,$buffer);
+ if(empty($line)) { break; }
+ }
+ return $MsgArray;
+ }
+
+ function last ( $type = "count" ) {
+ // Returns the highest msg number in the mailbox.
+ // returns -1 on error, 0+ on success, if type != count
+ // results in a popstat() call (2 element array returned)
+
+ $last = -1;
+ if(!isset($this->FP))
+ {
+ $this->ERROR = _("POP3 last:") . ' ' . _("No connection to server");
+ return $last;
+ }
+
+ $reply = $this->send_cmd("STAT");
+ if(!$this->is_ok($reply))
+ {
+ $this->ERROR = _("POP3 last:") . ' ' . _("Error ") . "[$reply]";
+ return $last;
+ }
+
+ $Vars = explode(" ",$reply);
+ $count = $Vars[1];
+ $size = $Vars[2];
+ settype($count,"integer");
+ settype($size,"integer");
+ if($type != "count")
+ {
+ return array($count,$size);
+ }
+ return $count;
+ }
+
+ function reset () {
+ // Resets the status of the remote server. This includes
+ // resetting the status of ALL msgs to not be deleted.
+ // This method automatically closes the connection to the server.
+
+ if(!isset($this->FP))
+ {
+ $this->ERROR = _("POP3 reset:") . ' ' . _("No connection to server");
+ return false;
+ }
+ $reply = $this->send_cmd("RSET");
+ if(!$this->is_ok($reply))
+ {
+ // The POP3 RSET command -never- gives a -ERR
+ // response - if it ever does, something truely
+ // wild is going on.
+
+ $this->ERROR = _("POP3 reset:") . ' ' . _("Error ") . "[$reply]";
+ @error_log("POP3 reset: ERROR [$reply]",0);
+ }
+ $this->quit();
+ return true;
+ }
+
+ function send_cmd ( $cmd = "" )
+ {
+ // Sends a user defined command string to the
+ // POP server and returns the results. Useful for
+ // non-compliant or custom POP servers.
+ // Do NOT includ the \r\n as part of your command
+ // string - it will be appended automatically.
+
+ // The return value is a standard fgets() call, which
+ // will read up to $this->BUFFER bytes of data, until it
+ // encounters a new line, or EOF, whichever happens first.
+
+ // This method works best if $cmd responds with only
+ // one line of data.
+
+ if(!isset($this->FP))
+ {
+ $this->ERROR = _("POP3 send_cmd:") . ' ' . _("No connection to server");
+ return false;
+ }
+
+ if(empty($cmd))
+ {
+ $this->ERROR = _("POP3 send_cmd:") . ' ' . _("Empty command string");
+ return "";
+ }
+
+ $fp = $this->FP;
+ $buffer = $this->BUFFER;
+ $this->update_timer();
+ fwrite($fp,"$cmd\r\n");
+ $reply = fgets($fp,$buffer);
+ $reply = $this->strip_clf($reply);
+ if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
+ return $reply;
+ }
+
+ function quit() {
+ // Closes the connection to the POP3 server, deleting
+ // any msgs marked as deleted.
+
+ if(!isset($this->FP))
+ {
+ $this->ERROR = _("POP3 quit:") . ' ' . _("connection does not exist");
+ return false;
+ }
+ $fp = $this->FP;
+ $cmd = "QUIT";
+ fwrite($fp,"$cmd\r\n");
+ $reply = fgets($fp,$this->BUFFER);
+ $reply = $this->strip_clf($reply);
+ if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
+ fclose($fp);
+ unset($this->FP);
+ return true;
+ }
+
+ function popstat () {
+ // Returns an array of 2 elements. The number of undeleted
+ // msgs in the mailbox, and the size of the mbox in octets.
+
+ $PopArray = $this->last("array");
+
+ if($PopArray == -1) { return false; }
+
+ if( (!$PopArray) or (empty($PopArray)) )
+ {
+ return false;
+ }
+ return $PopArray;
+ }
+
+ function uidl ($msgNum = "")
+ {
+ // Returns the UIDL of the msg specified. If called with
+ // no arguments, returns an associative array where each
+ // undeleted msg num is a key, and the msg's uidl is the element
+ // Array element 0 will contain the total number of msgs
+
+ if(!isset($this->FP)) {
+ $this->ERROR = _("POP3 uidl:") . ' ' . _("No connection to server");
+ return false;
+ }
+
+ $fp = $this->FP;
+ $buffer = $this->BUFFER;
+
+ if(!empty($msgNum)) {
+ $cmd = "UIDL $msgNum";
+ $reply = $this->send_cmd($cmd);
+ if(!$this->is_ok($reply))
+ {
+ $this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]";
+ return false;
+ }
+ list ($ok,$num,$myUidl) = explode(" ",$reply);
+ return $myUidl;
+ } else {
+ $this->update_timer();
+
+ $UIDLArray = array();
+ $Total = $this->COUNT;
+ $UIDLArray[0] = $Total;
+
+ if ($Total < 1)
+ {
+ return $UIDLArray;
+ }
+ $cmd = "UIDL";
+ fwrite($fp, "UIDL\r\n");
+ $reply = fgets($fp, $buffer);
+ $reply = $this->strip_clf($reply);
+ if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
+ if(!$this->is_ok($reply))
+ {
+ $this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]";
+ return false;
+ }
+
+ $line = "";
+ $count = 1;
+ $line = fgets($fp,$buffer);
+ while ( !ereg("^\.\r\n",$line)) {
+ if(ereg("^\.\r\n",$line)) {
+ break;
+ }
+ list ($msg,$msgUidl) = explode(" ",$line);
+ $msgUidl = $this->strip_clf($msgUidl);
+ if($count == $msg) {
+ $UIDLArray[$msg] = $msgUidl;
+ }
+ else
+ {
+ $UIDLArray[$count] = 'deleted';
+ }
+ $count++;
+ $line = fgets($fp,$buffer);
+ }
+ }
+ return $UIDLArray;
+ }
+
+ function delete ($msgNum = "") {
+ // Flags a specified msg as deleted. The msg will not
+ // be deleted until a quit() method is called.
+
+ if(!isset($this->FP))
+ {
+ $this->ERROR = _("POP3 delete:") . ' ' . _("No connection to server");
+ return false;
+ }
+ if(empty($msgNum))
+ {
+ $this->ERROR = _("POP3 delete:") . ' ' . _("No msg number submitted");
+ return false;
+ }
+ $reply = $this->send_cmd("DELE $msgNum");
+ if(!$this->is_ok($reply))
+ {
+ $this->ERROR = _("POP3 delete:") . ' ' . _("Command failed ") . "[$reply]";
+ return false;
+ }
+ return true;
+ }
+
+ // *********************************************************
+
+ // The following methods are internal to the class.
+
+ function is_ok ($cmd = "") {
+ // Return true or false on +OK or -ERR
+
+ if( empty($cmd) )
+ return false;
+ else
+ return( ereg ("^\+OK", $cmd ) );
+ }
+
+ function strip_clf ($text = "") {
+ // Strips \r\n from server responses
+
+ if(empty($text))
+ return $text;
+ else {
+ $stripped = str_replace("\r",'',$text);
+ $stripped = str_replace("\n",'',$stripped);
+ return $stripped;
+ }
+ }
+
+ function parse_banner ( $server_text ) {
+ $outside = true;
+ $banner = "";
+ $length = strlen($server_text);
+ for($count =0; $count < $length; $count++)
+ {
+ $digit = substr($server_text, $count, 1);
+ if ( false !== $digit ) {
+ if( (!$outside) && ($digit != '<') && ($digit != '>') )
+ {
+ $banner .= $digit;
+ }
+ if ($digit == '<')
+ {
+ $outside = false;
+ }
+ if($digit == '>')
+ {
+ $outside = true;
+ }
+ }
+ }
+ $banner = $this->strip_clf($banner); // Just in case
+ return "<$banner>";
+ }
+
+} // End class
+
+?>
diff --git a/wp-inst/wp-includes/class-smarty.php b/wp-inst/wp-includes/class-smarty.php
new file mode 100644
index 0000000..16aafd7
--- /dev/null
+++ b/wp-inst/wp-includes/class-smarty.php
@@ -0,0 +1,3867 @@
+<?php
+
+if( isset( $wpsmarty ) == false || is_object( $wpsmarty ) == false )
+{
+ if( defined( ABSPATH ) == false )
+ define( "ABSPATH", "../" );
+
+ require_once( ABSPATH . "Smarty.class.php" );
+ $wpsmarty = new Smarty;
+}
+
+/* get_the_category( $id = false ) */
+function smarty_get_the_category( $params, &$smarty )
+{
+ $id = false;
+
+ extract( $params );
+ return get_the_category( $id );
+}
+$wpsmarty->register_function( "get_the_category", "smarty_get_the_category" );
+
+/* get_category_link( $category_id ) */
+function smarty_get_category_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_category_link( $category_id );
+}
+$wpsmarty->register_function( "get_category_link", "smarty_get_category_link" );
+
+/* get_the_category_list( $separator = '', $parents='' ) */
+function smarty_get_the_category_list( $params, &$smarty )
+{
+ $separator = '';
+ $parents='';
+
+ extract( $params );
+ return get_the_category_list( $separator, $parents );
+}
+$wpsmarty->register_function( "get_the_category_list", "smarty_get_the_category_list" );
+
+/* the_category( $separator = '', $parents='' ) */
+function smarty_the_category( $params, &$smarty )
+{
+ $separator = '';
+ $parents='';
+
+ extract( $params );
+ return the_category( $separator, $parents );
+}
+$wpsmarty->register_function( "the_category", "smarty_the_category" );
+
+/* get_the_category_by_ID( $cat_ID ) */
+function smarty_get_the_category_by_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_category_by_ID( $cat_ID );
+}
+$wpsmarty->register_function( "get_the_category_by_ID", "smarty_get_the_category_by_ID" );
+
+/* get_category_parents( $id, $link = FALSE, $separat ) */
+function smarty_get_category_parents( $params, &$smarty )
+{
+ $link = FALSE;
+
+ extract( $params );
+ return get_category_parents( $id, $link, $separat );
+}
+$wpsmarty->register_function( "get_category_parents", "smarty_get_category_parents" );
+
+/* get_category_children( $id, $before = '/', $after = '' ) */
+function smarty_get_category_children( $params, &$smarty )
+{
+ $before = '/';
+ $after = '';
+
+ extract( $params );
+ return get_category_children( $id, $before, $after );
+}
+$wpsmarty->register_function( "get_category_children", "smarty_get_category_children" );
+
+/* the_category_ID( $echo = true ) */
+function smarty_the_category_ID( $params, &$smarty )
+{
+ $echo = true;
+
+ extract( $params );
+ return the_category_ID( $echo );
+}
+$wpsmarty->register_function( "the_category_ID", "smarty_the_category_ID" );
+
+/* the_category_head( $before='', $after='' ) */
+function smarty_the_category_head( $params, &$smarty )
+{
+ $before='';
+ $after='';
+
+ extract( $params );
+ return the_category_head( $before, $after );
+}
+$wpsmarty->register_function( "the_category_head", "smarty_the_category_head" );
+
+/* category_description( $category = 0 ) */
+function smarty_category_description( $params, &$smarty )
+{
+ $category = 0;
+
+ extract( $params );
+ return category_description( $category );
+}
+$wpsmarty->register_function( "category_description", "smarty_category_description" );
+
+/* dropdown_cats( $optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc',
+ $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE,
+ $selected=0, $hide=0 ) */
+function smarty_dropdown_cats( $params, &$smarty )
+{
+ $optionall = 1;
+ $all = 'All';
+ $sort_column = 'ID';
+ $sort_order = 'asc';
+ $optiondates = 0;
+ $optioncount = 0;
+ $hide_empty = 1;
+ $optionnone=FALSE;
+ $selected=0;
+ $hide=0;
+
+ extract( $params );
+ return dropdown_cats( $optionall, $all, $sort_column, $sort_order, $optiondates, $optioncount, $hide_empty, $optionnone, $selected, $hide );
+}
+$wpsmarty->register_function( "dropdown_cats", "smarty_dropdown_cats" );
+
+/* wp_list_cats( $args = '' ) */
+function smarty_wp_list_cats( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_list_cats( $args );
+}
+$wpsmarty->register_function( "wp_list_cats", "smarty_wp_list_cats" );
+
+/* list_cats( $optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE ) */
+function smarty_list_cats( $params, &$smarty )
+{
+ $optionall = 1;
+ $all = 'All';
+ $sort_column = 'ID';
+ $sort_order = 'asc';
+ $file = '';
+ $list = true;
+ $optiondates = 0;
+ $optioncount = 0;
+ $hide_empty = 1;
+ $use_desc_for_title = 1;
+ $children=FALSE;
+ $child_of=0;
+ $categories=0;
+ $recurse=0;
+ $feed = '';
+ $feed_image = '';
+ $exclude = '';
+ $hierarchical=FALSE;
+
+ extract( $params );
+ return list_cats( $optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $children, $child_of, $categories, $recurse, $feed, $feed_image, $exclude, $hierarchical );
+}
+$wpsmarty->register_function( "list_cats", "smarty_list_cats" );
+
+/* in_category( $category ) */
+function smarty_in_category( $params, &$smarty )
+{
+
+ extract( $params );
+ return in_category( $category );
+}
+$wpsmarty->register_function( "in_category", "smarty_in_category" );
+
+/* get_header( ) */
+function smarty_get_header( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_header( );
+}
+$wpsmarty->register_function( "get_header", "smarty_get_header" );
+
+/* get_footer( ) */
+function smarty_get_footer( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_footer( );
+}
+$wpsmarty->register_function( "get_footer", "smarty_get_footer" );
+
+/* get_sidebar( ) */
+function smarty_get_sidebar( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_sidebar( );
+}
+$wpsmarty->register_function( "get_sidebar", "smarty_get_sidebar" );
+
+/* wp_loginout( ) */
+function smarty_wp_loginout( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_loginout( );
+}
+$wpsmarty->register_function( "wp_loginout", "smarty_wp_loginout" );
+
+/* wp_register( $before = '<li>', $after = '</li>' ) */
+function smarty_wp_register( $params, &$smarty )
+{
+ $before = '<li>';
+ $after = '</li>';
+
+ extract( $params );
+ return wp_register( $before, $after );
+}
+$wpsmarty->register_function( "wp_register", "smarty_wp_register" );
+
+/* wp_meta( ) */
+function smarty_wp_meta( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_meta( );
+}
+$wpsmarty->register_function( "wp_meta", "smarty_wp_meta" );
+
+/* bloginfo( $show='' ) */
+function smarty_bloginfo( $params, &$smarty )
+{
+ $show='';
+
+ extract( $params );
+ return bloginfo( $show );
+}
+$wpsmarty->register_function( "bloginfo", "smarty_bloginfo" );
+
+/* get_bloginfo( $show='' ) */
+function smarty_get_bloginfo( $params, &$smarty )
+{
+ $show='';
+
+ extract( $params );
+ return get_bloginfo( $show );
+}
+$wpsmarty->register_function( "get_bloginfo", "smarty_get_bloginfo" );
+
+/* wp_title( $sep = '&raquo;', $display = true ) */
+function smarty_wp_title( $params, &$smarty )
+{
+ $sep = '&raquo;';
+ $display = true;
+
+ extract( $params );
+ return wp_title( $sep, $display );
+}
+$wpsmarty->register_function( "wp_title", "smarty_wp_title" );
+
+/* single_post_title( $prefix = '', $display = true ) */
+function smarty_single_post_title( $params, &$smarty )
+{
+ $prefix = '';
+ $display = true;
+
+ extract( $params );
+ return single_post_title( $prefix, $display );
+}
+$wpsmarty->register_function( "single_post_title", "smarty_single_post_title" );
+
+/* single_cat_title( $prefix = '', $display = true ) */
+function smarty_single_cat_title( $params, &$smarty )
+{
+ $prefix = '';
+ $display = true;
+
+ extract( $params );
+ return single_cat_title( $prefix, $display );
+}
+$wpsmarty->register_function( "single_cat_title", "smarty_single_cat_title" );
+
+/* single_month_title( $prefix = '', $display = true ) */
+function smarty_single_month_title( $params, &$smarty )
+{
+ $prefix = '';
+ $display = true;
+
+ extract( $params );
+ return single_month_title( $prefix, $display );
+}
+$wpsmarty->register_function( "single_month_title", "smarty_single_month_title" );
+
+/* get_archives_link( $url, $text, $format = 'html', $before = '', $after = '' ) */
+function smarty_get_archives_link( $params, &$smarty )
+{
+ $format = 'html';
+ $before = '';
+ $after = '';
+
+ extract( $params );
+ return get_archives_link( $url, $text, $format, $before, $after );
+}
+$wpsmarty->register_function( "get_archives_link", "smarty_get_archives_link" );
+
+/* wp_get_archives( $args = '' ) */
+function smarty_wp_get_archives( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_get_archives( $args );
+}
+$wpsmarty->register_function( "wp_get_archives", "smarty_wp_get_archives" );
+
+/* get_archives( $type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false ) */
+function smarty_get_archives( $params, &$smarty )
+{
+ $type='';
+ $limit='';
+ $format='html';
+ $before = '';
+ $after = '';
+ $show_post_count = false;
+
+ extract( $params );
+ return get_archives( $type, $limit, $format, $before, $after, $show_post_count );
+}
+$wpsmarty->register_function( "get_archives", "smarty_get_archives" );
+
+/* calendar_week_mod( $num ) */
+function smarty_calendar_week_mod( $params, &$smarty )
+{
+
+ extract( $params );
+ return calendar_week_mod( $num );
+}
+$wpsmarty->register_function( "calendar_week_mod", "smarty_calendar_week_mod" );
+
+/* get_calendar( $daylength = 1 ) */
+function smarty_get_calendar( $params, &$smarty )
+{
+ $daylength = 1;
+
+ extract( $params );
+ return get_calendar( $daylength );
+}
+$wpsmarty->register_function( "get_calendar", "smarty_get_calendar" );
+
+/* allowed_tags( ) */
+function smarty_allowed_tags( $params, &$smarty )
+{
+
+ extract( $params );
+ return allowed_tags( );
+}
+$wpsmarty->register_function( "allowed_tags", "smarty_allowed_tags" );
+
+/* the_date_xml( ) */
+function smarty_the_date_xml( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_date_xml( );
+}
+$wpsmarty->register_function( "the_date_xml", "smarty_the_date_xml" );
+
+/* the_date( $d='', $before='', $after='', $echo = true ) */
+function smarty_the_date( $params, &$smarty )
+{
+ $d='';
+ $before='';
+ $after='';
+ $echo = true;
+
+ extract( $params );
+ return the_date( $d, $before, $after, $echo );
+}
+$wpsmarty->register_function( "the_date", "smarty_the_date" );
+
+/* the_time( $d = '' ) */
+function smarty_the_time( $params, &$smarty )
+{
+ $d = '';
+
+ extract( $params );
+ return the_time( $d );
+}
+$wpsmarty->register_function( "the_time", "smarty_the_time" );
+
+/* get_the_time( $d = '' ) */
+function smarty_get_the_time( $params, &$smarty )
+{
+ $d = '';
+
+ extract( $params );
+ return get_the_time( $d );
+}
+$wpsmarty->register_function( "get_the_time", "smarty_get_the_time" );
+
+/* get_post_time( $d = 'U', $gmt = false ) */
+function smarty_get_post_time( $params, &$smarty )
+{
+ $d = 'U';
+ $gmt = false;
+
+ extract( $params );
+ return get_post_time( $d, $gmt );
+}
+$wpsmarty->register_function( "get_post_time", "smarty_get_post_time" );
+
+/* the_weekday( ) */
+function smarty_the_weekday( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_weekday( );
+}
+$wpsmarty->register_function( "the_weekday", "smarty_the_weekday" );
+
+/* the_weekday_date( $before='',$after='' ) */
+function smarty_the_weekday_date( $params, &$smarty )
+{
+ $before='';
+ $after='';
+
+ extract( $params );
+ return the_weekday_date( $before, $after );
+}
+$wpsmarty->register_function( "the_weekday_date", "smarty_the_weekday_date" );
+
+/* the_permalink( ) */
+function smarty_the_permalink( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_permalink( );
+}
+$wpsmarty->register_function( "the_permalink", "smarty_the_permalink" );
+
+/* permalink_link( ) */
+function smarty_permalink_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return permalink_link( );
+}
+$wpsmarty->register_function( "permalink_link", "smarty_permalink_link" );
+
+/* permalink_anchor( $mode = 'id' ) */
+function smarty_permalink_anchor( $params, &$smarty )
+{
+ $mode = 'id';
+
+ extract( $params );
+ return permalink_anchor( $mode );
+}
+$wpsmarty->register_function( "permalink_anchor", "smarty_permalink_anchor" );
+
+/* get_permalink( $id = 0 ) */
+function smarty_get_permalink( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return get_permalink( $id );
+}
+$wpsmarty->register_function( "get_permalink", "smarty_get_permalink" );
+
+/* get_page_link( $id = false ) */
+function smarty_get_page_link( $params, &$smarty )
+{
+ $id = false;
+
+ extract( $params );
+ return get_page_link( $id );
+}
+$wpsmarty->register_function( "get_page_link", "smarty_get_page_link" );
+
+/* get_year_link( $year ) */
+function smarty_get_year_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_year_link( $year );
+}
+$wpsmarty->register_function( "get_year_link", "smarty_get_year_link" );
+
+/* get_month_link( $year, $month ) */
+function smarty_get_month_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_month_link( $year, $month );
+}
+$wpsmarty->register_function( "get_month_link", "smarty_get_month_link" );
+
+/* get_day_link( $year, $month, $day ) */
+function smarty_get_day_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_day_link( $year, $month, $day );
+}
+$wpsmarty->register_function( "get_day_link", "smarty_get_day_link" );
+
+/* get_feed_link( $feed='rss2' ) */
+function smarty_get_feed_link( $params, &$smarty )
+{
+ $feed='rss2';
+
+ extract( $params );
+ return get_feed_link( $feed );
+}
+$wpsmarty->register_function( "get_feed_link", "smarty_get_feed_link" );
+
+/* edit_post_link( $link = 'Edit This', $before = '', $after = '' ) */
+function smarty_edit_post_link( $params, &$smarty )
+{
+ $link = 'Edit This';
+ $before = '';
+ $after = '';
+
+ extract( $params );
+ return edit_post_link( $link, $before, $after );
+}
+$wpsmarty->register_function( "edit_post_link", "smarty_edit_post_link" );
+
+/* edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) */
+function smarty_edit_comment_link( $params, &$smarty )
+{
+ $link = 'Edit This';
+ $before = '';
+ $after = '';
+
+ extract( $params );
+ return edit_comment_link( $link, $before, $after );
+}
+$wpsmarty->register_function( "edit_comment_link", "smarty_edit_comment_link" );
+
+/* get_previous_post( $in_same_cat = false, $excluded_categories = '' ) */
+function smarty_get_previous_post( $params, &$smarty )
+{
+ $in_same_cat = false;
+ $excluded_categories = '';
+
+ extract( $params );
+ return get_previous_post( $in_same_cat, $excluded_categories );
+}
+$wpsmarty->register_function( "get_previous_post", "smarty_get_previous_post" );
+
+/* get_next_post( $in_same_cat = false, $excluded_categories = '' ) */
+function smarty_get_next_post( $params, &$smarty )
+{
+ $in_same_cat = false;
+ $excluded_categories = '';
+
+ extract( $params );
+ return get_next_post( $in_same_cat, $excluded_categories );
+}
+$wpsmarty->register_function( "get_next_post", "smarty_get_next_post" );
+
+/* previous_post_link( $format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '' ) */
+function smarty_previous_post_link( $params, &$smarty )
+{
+ $format='&laquo; %link';
+ $link='%title';
+ $in_same_cat = false;
+ $excluded_categories = '';
+
+ extract( $params );
+ return previous_post_link( $format, $link, $in_same_cat, $excluded_categories );
+}
+$wpsmarty->register_function( "previous_post_link", "smarty_previous_post_link" );
+
+/* next_post_link( $format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '' ) */
+function smarty_next_post_link( $params, &$smarty )
+{
+ $format='%link &raquo;';
+ $link='%title';
+ $in_same_cat = false;
+ $excluded_categories = '';
+
+ extract( $params );
+ return next_post_link( $format, $link, $in_same_cat, $excluded_categories );
+}
+$wpsmarty->register_function( "next_post_link", "smarty_next_post_link" );
+
+/* previous_post( $format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='' ) */
+function smarty_previous_post( $params, &$smarty )
+{
+ $format='%';
+ $previous='previous post: ';
+ $title='yes';
+ $in_same_cat='no';
+ $limitprev=1;
+ $excluded_categories='';
+
+ extract( $params );
+ return previous_post( $format, $previous, $title, $in_same_cat, $limitprev, $excluded_categories );
+}
+$wpsmarty->register_function( "previous_post", "smarty_previous_post" );
+
+/* next_post( $format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='' ) */
+function smarty_next_post( $params, &$smarty )
+{
+ $format='%';
+ $next='next post: ';
+ $title='yes';
+ $in_same_cat='no';
+ $limitnext=1;
+ $excluded_categories='';
+
+ extract( $params );
+ return next_post( $format, $next, $title, $in_same_cat, $limitnext, $excluded_categories );
+}
+$wpsmarty->register_function( "next_post", "smarty_next_post" );
+
+/* get_pagenum_link( $pagenum = 1 ) */
+function smarty_get_pagenum_link( $params, &$smarty )
+{
+ $pagenum = 1;
+
+ extract( $params );
+ return get_pagenum_link( $pagenum );
+}
+$wpsmarty->register_function( "get_pagenum_link", "smarty_get_pagenum_link" );
+
+/* next_posts( $max_page = 0 ) */
+function smarty_next_posts( $params, &$smarty )
+{
+ $max_page = 0;
+
+ extract( $params );
+ return next_posts( $max_page );
+}
+$wpsmarty->register_function( "next_posts", "smarty_next_posts" );
+
+/* next_posts_link( $label='Next Page &raquo;', $max_page=0 ) */
+function smarty_next_posts_link( $params, &$smarty )
+{
+ $label='Next Page &raquo;';
+ $max_page=0;
+
+ extract( $params );
+ return next_posts_link( $label, $max_page );
+}
+$wpsmarty->register_function( "next_posts_link", "smarty_next_posts_link" );
+
+/* previous_posts( ) */
+function smarty_previous_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return previous_posts( );
+}
+$wpsmarty->register_function( "previous_posts", "smarty_previous_posts" );
+
+/* previous_posts_link( $label='&laquo; Previous Page' ) */
+function smarty_previous_posts_link( $params, &$smarty )
+{
+ $label='&laquo; Previous Page';
+
+ extract( $params );
+ return previous_posts_link( $label );
+}
+$wpsmarty->register_function( "previous_posts_link", "smarty_previous_posts_link" );
+
+/* posts_nav_link( $sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;' ) */
+function smarty_posts_nav_link( $params, &$smarty )
+{
+ $sep=' &#8212; ';
+ $prelabel='&laquo; Previous Page';
+ $nxtlabel='Next Page &raquo;';
+
+ extract( $params );
+ return posts_nav_link( $sep, $prelabel, $nxtlabel );
+}
+$wpsmarty->register_function( "posts_nav_link", "smarty_posts_nav_link" );
+
+/* get_the_password_form( ) */
+function smarty_get_the_password_form( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_password_form( );
+}
+$wpsmarty->register_function( "get_the_password_form", "smarty_get_the_password_form" );
+
+/* the_ID( ) */
+function smarty_the_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_ID( );
+}
+$wpsmarty->register_function( "the_ID", "smarty_the_ID" );
+
+/* the_title( $before = '', $after = '', $echo = true ) */
+function smarty_the_title( $params, &$smarty )
+{
+ $before = '';
+ $after = '';
+ $echo = true;
+
+ extract( $params );
+ return the_title( $before, $after, $echo );
+}
+$wpsmarty->register_function( "the_title", "smarty_the_title" );
+
+/* get_the_title( $id = 0 ) */
+function smarty_get_the_title( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return get_the_title( $id );
+}
+$wpsmarty->register_function( "get_the_title", "smarty_get_the_title" );
+
+/* get_the_guid( $id = 0 ) */
+function smarty_get_the_guid( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return get_the_guid( $id );
+}
+$wpsmarty->register_function( "get_the_guid", "smarty_get_the_guid" );
+
+/* the_guid( $id = 0 ) */
+function smarty_the_guid( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return the_guid( $id );
+}
+$wpsmarty->register_function( "the_guid", "smarty_the_guid" );
+
+/* the_content( $more_link_text = '(more...)', $stripteaser = 0, $more_file = '' ) */
+function smarty_the_content( $params, &$smarty )
+{
+ $more_link_text = '(more...)';
+ $stripteaser = 0;
+ $more_file = '';
+
+ extract( $params );
+ return the_content( $more_link_text, $stripteaser, $more_file );
+}
+$wpsmarty->register_function( "the_content", "smarty_the_content" );
+
+/* get_the_content( $more_link_text = '(more...)', $stripteaser = 0, $more_file = '' ) */
+function smarty_get_the_content( $params, &$smarty )
+{
+ $more_link_text = '(more...)';
+ $stripteaser = 0;
+ $more_file = '';
+
+ extract( $params );
+ return get_the_content( $more_link_text, $stripteaser, $more_file );
+}
+$wpsmarty->register_function( "get_the_content", "smarty_get_the_content" );
+
+/* the_excerpt( ) */
+function smarty_the_excerpt( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_excerpt( );
+}
+$wpsmarty->register_function( "the_excerpt", "smarty_the_excerpt" );
+
+/* get_the_excerpt( $fakeit = true ) */
+function smarty_get_the_excerpt( $params, &$smarty )
+{
+ $fakeit = true;
+
+ extract( $params );
+ return get_the_excerpt( $fakeit );
+}
+$wpsmarty->register_function( "get_the_excerpt", "smarty_get_the_excerpt" );
+
+/* wp_link_pages( $args = '' ) */
+function smarty_wp_link_pages( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_link_pages( $args );
+}
+$wpsmarty->register_function( "wp_link_pages", "smarty_wp_link_pages" );
+
+/* link_pages( $before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='' ) */
+function smarty_link_pages( $params, &$smarty )
+{
+ $before='<br />';
+ $after='<br />';
+ $next_or_number='number';
+ $nextpagelink='next page';
+ $previouspagelink='previous page';
+ $pagelink='%';
+ $more_file='';
+
+ extract( $params );
+ return link_pages( $before, $after, $next_or_number, $nextpagelink, $previouspagelink, $pagelink, $more_file );
+}
+$wpsmarty->register_function( "link_pages", "smarty_link_pages" );
+
+/* get_post_custom( $post_id = 0 ) */
+function smarty_get_post_custom( $params, &$smarty )
+{
+ $post_id = 0;
+
+ extract( $params );
+ return get_post_custom( $post_id );
+}
+$wpsmarty->register_function( "get_post_custom", "smarty_get_post_custom" );
+
+/* get_post_custom_keys( ) */
+function smarty_get_post_custom_keys( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_post_custom_keys( );
+}
+$wpsmarty->register_function( "get_post_custom_keys", "smarty_get_post_custom_keys" );
+
+/* get_post_custom_values( $key='' ) */
+function smarty_get_post_custom_values( $params, &$smarty )
+{
+ $key='';
+
+ extract( $params );
+ return get_post_custom_values( $key );
+}
+$wpsmarty->register_function( "get_post_custom_values", "smarty_get_post_custom_values" );
+
+/* post_custom( $key = '' ) */
+function smarty_post_custom( $params, &$smarty )
+{
+ $key = '';
+
+ extract( $params );
+ return post_custom( $key );
+}
+$wpsmarty->register_function( "post_custom", "smarty_post_custom" );
+
+/* the_meta( ) */
+function smarty_the_meta( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_meta( );
+}
+$wpsmarty->register_function( "the_meta", "smarty_the_meta" );
+
+/* &get_page_children( $page_id, $pages ) */
+function &smarty_get_page_children( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_page_children( $page_id, $pages );
+}
+$wpsmarty->register_function( "get_page_children", "smarty_get_page_children" );
+
+/* &get_pages( $args = '' ) */
+function &smarty_get_pages( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return get_pages( $args );
+}
+$wpsmarty->register_function( "get_pages", "smarty_get_pages" );
+
+/* wp_list_pages( $args = '' ) */
+function smarty_wp_list_pages( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_list_pages( $args );
+}
+$wpsmarty->register_function( "wp_list_pages", "smarty_wp_list_pages" );
+
+/* _page_level_out( $parent, $page_tree, $args, $depth = 0, $echo = true ) */
+function smarty__page_level_out( $params, &$smarty )
+{
+ $depth = 0;
+ $echo = true;
+
+ extract( $params );
+ return _page_level_out( $parent, $page_tree, $args, $depth, $echo );
+}
+$wpsmarty->register_function( "_page_level_out", "smarty__page_level_out" );
+
+/* get_the_author( $idmode = '' ) */
+function smarty_get_the_author( $params, &$smarty )
+{
+ $idmode = '';
+
+ extract( $params );
+ return get_the_author( $idmode );
+}
+$wpsmarty->register_function( "get_the_author", "smarty_get_the_author" );
+
+/* the_author( $idmode = '', $echo = true ) */
+function smarty_the_author( $params, &$smarty )
+{
+ $idmode = '';
+ $echo = true;
+
+ extract( $params );
+ return the_author( $idmode, $echo );
+}
+$wpsmarty->register_function( "the_author", "smarty_the_author" );
+
+/* get_the_author_description( ) */
+function smarty_get_the_author_description( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_description( );
+}
+$wpsmarty->register_function( "get_the_author_description", "smarty_get_the_author_description" );
+
+/* the_author_description( ) */
+function smarty_the_author_description( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_description( );
+}
+$wpsmarty->register_function( "the_author_description", "smarty_the_author_description" );
+
+/* get_the_author_login( ) */
+function smarty_get_the_author_login( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_login( );
+}
+$wpsmarty->register_function( "get_the_author_login", "smarty_get_the_author_login" );
+
+/* the_author_login( ) */
+function smarty_the_author_login( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_login( );
+}
+$wpsmarty->register_function( "the_author_login", "smarty_the_author_login" );
+
+/* get_the_author_firstname( ) */
+function smarty_get_the_author_firstname( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_firstname( );
+}
+$wpsmarty->register_function( "get_the_author_firstname", "smarty_get_the_author_firstname" );
+
+/* the_author_firstname( ) */
+function smarty_the_author_firstname( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_firstname( );
+}
+$wpsmarty->register_function( "the_author_firstname", "smarty_the_author_firstname" );
+
+/* get_the_author_lastname( ) */
+function smarty_get_the_author_lastname( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_lastname( );
+}
+$wpsmarty->register_function( "get_the_author_lastname", "smarty_get_the_author_lastname" );
+
+/* the_author_lastname( ) */
+function smarty_the_author_lastname( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_lastname( );
+}
+$wpsmarty->register_function( "the_author_lastname", "smarty_the_author_lastname" );
+
+/* get_the_author_nickname( ) */
+function smarty_get_the_author_nickname( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_nickname( );
+}
+$wpsmarty->register_function( "get_the_author_nickname", "smarty_get_the_author_nickname" );
+
+/* the_author_nickname( ) */
+function smarty_the_author_nickname( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_nickname( );
+}
+$wpsmarty->register_function( "the_author_nickname", "smarty_the_author_nickname" );
+
+/* get_the_author_ID( ) */
+function smarty_get_the_author_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_ID( );
+}
+$wpsmarty->register_function( "get_the_author_ID", "smarty_get_the_author_ID" );
+
+/* the_author_ID( ) */
+function smarty_the_author_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_ID( );
+}
+$wpsmarty->register_function( "the_author_ID", "smarty_the_author_ID" );
+
+/* get_the_author_email( ) */
+function smarty_get_the_author_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_email( );
+}
+$wpsmarty->register_function( "get_the_author_email", "smarty_get_the_author_email" );
+
+/* the_author_email( ) */
+function smarty_the_author_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_email( );
+}
+$wpsmarty->register_function( "the_author_email", "smarty_the_author_email" );
+
+/* get_the_author_url( ) */
+function smarty_get_the_author_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_url( );
+}
+$wpsmarty->register_function( "get_the_author_url", "smarty_get_the_author_url" );
+
+/* the_author_url( ) */
+function smarty_the_author_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_url( );
+}
+$wpsmarty->register_function( "the_author_url", "smarty_the_author_url" );
+
+/* get_the_author_icq( ) */
+function smarty_get_the_author_icq( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_icq( );
+}
+$wpsmarty->register_function( "get_the_author_icq", "smarty_get_the_author_icq" );
+
+/* the_author_icq( ) */
+function smarty_the_author_icq( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_icq( );
+}
+$wpsmarty->register_function( "the_author_icq", "smarty_the_author_icq" );
+
+/* get_the_author_aim( ) */
+function smarty_get_the_author_aim( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_aim( );
+}
+$wpsmarty->register_function( "get_the_author_aim", "smarty_get_the_author_aim" );
+
+/* the_author_aim( ) */
+function smarty_the_author_aim( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_aim( );
+}
+$wpsmarty->register_function( "the_author_aim", "smarty_the_author_aim" );
+
+/* get_the_author_yim( ) */
+function smarty_get_the_author_yim( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_yim( );
+}
+$wpsmarty->register_function( "get_the_author_yim", "smarty_get_the_author_yim" );
+
+/* the_author_yim( ) */
+function smarty_the_author_yim( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_yim( );
+}
+$wpsmarty->register_function( "the_author_yim", "smarty_the_author_yim" );
+
+/* get_the_author_msn( ) */
+function smarty_get_the_author_msn( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_msn( );
+}
+$wpsmarty->register_function( "get_the_author_msn", "smarty_get_the_author_msn" );
+
+/* the_author_msn( ) */
+function smarty_the_author_msn( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_msn( );
+}
+$wpsmarty->register_function( "the_author_msn", "smarty_the_author_msn" );
+
+/* get_the_author_posts( ) */
+function smarty_get_the_author_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_the_author_posts( );
+}
+$wpsmarty->register_function( "get_the_author_posts", "smarty_get_the_author_posts" );
+
+/* the_author_posts( ) */
+function smarty_the_author_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_author_posts( );
+}
+$wpsmarty->register_function( "the_author_posts", "smarty_the_author_posts" );
+
+/* the_author_posts_link( $idmode='' ) */
+function smarty_the_author_posts_link( $params, &$smarty )
+{
+ $idmode='';
+
+ extract( $params );
+ return the_author_posts_link( $idmode );
+}
+$wpsmarty->register_function( "the_author_posts_link", "smarty_the_author_posts_link" );
+
+/* get_author_link( $echo = false, $author_id, $author_nicename ) */
+function smarty_get_author_link( $params, &$smarty )
+{
+ $echo = false;
+
+ extract( $params );
+ return get_author_link( $echo, $author_id, $author_nicename );
+}
+$wpsmarty->register_function( "get_author_link", "smarty_get_author_link" );
+
+/* wp_list_authors( $args = '' ) */
+function smarty_wp_list_authors( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_list_authors( $args );
+}
+$wpsmarty->register_function( "wp_list_authors", "smarty_wp_list_authors" );
+
+/* list_authors( $optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '' ) */
+function smarty_list_authors( $params, &$smarty )
+{
+ $optioncount = false;
+ $exclude_admin = true;
+ $show_fullname = false;
+ $hide_empty = true;
+ $feed = '';
+ $feed_image = '';
+
+ extract( $params );
+ return list_authors( $optioncount, $exclude_admin, $show_fullname, $hide_empty, $feed, $feed_image );
+}
+$wpsmarty->register_function( "list_authors", "smarty_list_authors" );
+
+/* get_linksbyname( $cat_name = "noname", $before = '', $after = '<br />',
+ $between = " ", $show_images = true, $orderby = 'id',
+ $show_description = true, $show_rating = false,
+ $limit = -1, $show_updated = 0 ) */
+function smarty_get_linksbyname( $params, &$smarty )
+{
+ $cat_name = "noname";
+ $before = '';
+ $after = '<br />';
+ $between = " ";
+ $show_images = true;
+ $orderby = 'id';
+ $show_description = true;
+ $show_rating = false;
+ $limit = -1;
+ $show_updated = 0;
+
+ extract( $params );
+ return get_linksbyname( $cat_name, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated );
+}
+$wpsmarty->register_function( "get_linksbyname", "smarty_get_linksbyname" );
+
+/* bool_from_yn( $yn ) */
+function smarty_bool_from_yn( $params, &$smarty )
+{
+
+ extract( $params );
+ return bool_from_yn( $yn );
+}
+$wpsmarty->register_function( "bool_from_yn", "smarty_bool_from_yn" );
+
+/* wp_get_linksbyname( $category, $args = '' ) */
+function smarty_wp_get_linksbyname( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_get_linksbyname( $category, $args );
+}
+$wpsmarty->register_function( "wp_get_linksbyname", "smarty_wp_get_linksbyname" );
+
+/* wp_get_links( $args = '' ) */
+function smarty_wp_get_links( $params, &$smarty )
+{
+ $args = '';
+
+ extract( $params );
+ return wp_get_links( $args );
+}
+$wpsmarty->register_function( "wp_get_links", "smarty_wp_get_links" );
+
+/* get_links( $category = -1, $before = '', $after = '<br />',
+ $between = ' ', $show_images = true, $orderby = 'name',
+ $show_description = true, $show_rating = false,
+ $limit = -1, $show_updated = 1, $echo = true ) */
+function smarty_get_links( $params, &$smarty )
+{
+ $category = -1;
+ $before = '';
+ $after = '<br />';
+ $between = ' ';
+ $show_images = true;
+ $orderby = 'name';
+ $show_description = true;
+ $show_rating = false;
+ $limit = -1;
+ $show_updated = 1;
+ $echo = true;
+
+ extract( $params );
+ return get_links( $category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo );
+}
+$wpsmarty->register_function( "get_links", "smarty_get_links" );
+
+/* get_linkobjectsbyname( $cat_name = "noname" , $orderby = 'name', $limit = -1 ) */
+function smarty_get_linkobjectsbyname( $params, &$smarty )
+{
+ $cat_name = "noname";
+ $orderby = 'name';
+ $limit = -1;
+
+ extract( $params );
+ return get_linkobjectsbyname( $cat_name, $orderby, $limit );
+}
+$wpsmarty->register_function( "get_linkobjectsbyname", "smarty_get_linkobjectsbyname" );
+
+/* get_linkobjects( $category = -1, $orderby = 'name', $limit = -1 ) */
+function smarty_get_linkobjects( $params, &$smarty )
+{
+ $category = -1;
+ $orderby = 'name';
+ $limit = -1;
+
+ extract( $params );
+ return get_linkobjects( $category, $orderby, $limit );
+}
+$wpsmarty->register_function( "get_linkobjects", "smarty_get_linkobjects" );
+
+/* get_linkrating( $link ) */
+function smarty_get_linkrating( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_linkrating( $link );
+}
+$wpsmarty->register_function( "get_linkrating", "smarty_get_linkrating" );
+
+/* get_linksbyname_withrating( $cat_name = "noname", $before = '',
+ $after = '<br />', $between = " ",
+ $show_images = true, $orderby = 'id',
+ $show_description = true, $limit = -1, $show_updated = 0 ) */
+function smarty_get_linksbyname_withrating( $params, &$smarty )
+{
+ $cat_name = "noname";
+ $before = '';
+ $after = '<br />';
+ $between = " ";
+ $show_images = true;
+ $orderby = 'id';
+ $show_description = true;
+ $limit = -1;
+ $show_updated = 0;
+
+ extract( $params );
+ return get_linksbyname_withrating( $cat_name, $before, $after, $between, $show_images, $orderby, $show_description, $limit, $show_updated );
+}
+$wpsmarty->register_function( "get_linksbyname_withrating", "smarty_get_linksbyname_withrating" );
+
+/* get_links_withrating( $category = -1, $before = '', $after = '<br />',
+ $between = " ", $show_images = true,
+ $orderby = 'id', $show_description = true,
+ $limit = -1, $show_updated = 0 ) */
+function smarty_get_links_withrating( $params, &$smarty )
+{
+ $category = -1;
+ $before = '';
+ $after = '<br />';
+ $between = " ";
+ $show_images = true;
+ $orderby = 'id';
+ $show_description = true;
+ $limit = -1;
+ $show_updated = 0;
+
+ extract( $params );
+ return get_links_withrating( $category, $before, $after, $between, $show_images, $orderby, $show_description, $limit, $show_updated );
+}
+$wpsmarty->register_function( "get_links_withrating", "smarty_get_links_withrating" );
+
+/* get_linkcatname( $id = 0 ) */
+function smarty_get_linkcatname( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return get_linkcatname( $id );
+}
+$wpsmarty->register_function( "get_linkcatname", "smarty_get_linkcatname" );
+
+/* get_autotoggle( $id = 0 ) */
+function smarty_get_autotoggle( $params, &$smarty )
+{
+ $id = 0;
+
+ extract( $params );
+ return get_autotoggle( $id );
+}
+$wpsmarty->register_function( "get_autotoggle", "smarty_get_autotoggle" );
+
+/* links_popup_script( $text = 'Links', $width=400, $height=400,
+ $file='links.all.php', $count = true ) */
+function smarty_links_popup_script( $params, &$smarty )
+{
+ $text = 'Links';
+ $width=400;
+ $height=400;
+ $file='links.all.php';
+ $count = true;
+
+ extract( $params );
+ return links_popup_script( $text, $width, $height, $file, $count );
+}
+$wpsmarty->register_function( "links_popup_script", "smarty_links_popup_script" );
+
+/* get_links_list( $order = 'name', $hide_if_empty = 'obsolete' ) */
+function smarty_get_links_list( $params, &$smarty )
+{
+ $order = 'name';
+ $hide_if_empty = 'obsolete';
+
+ extract( $params );
+ return get_links_list( $order, $hide_if_empty );
+}
+$wpsmarty->register_function( "get_links_list", "smarty_get_links_list" );
+
+/* get_profile( $field, $user = false ) */
+function smarty_get_profile( $params, &$smarty )
+{
+ $user = false;
+
+ extract( $params );
+ return get_profile( $field, $user );
+}
+$wpsmarty->register_function( "get_profile", "smarty_get_profile" );
+
+/* mysql2date( $dateformatstring, $mysqlstring, $translate = true ) */
+function smarty_mysql2date( $params, &$smarty )
+{
+ $translate = true;
+
+ extract( $params );
+ return mysql2date( $dateformatstring, $mysqlstring, $translate );
+}
+$wpsmarty->register_function( "mysql2date", "smarty_mysql2date" );
+
+/* current_time( $type, $gmt = 0 ) */
+function smarty_current_time( $params, &$smarty )
+{
+ $gmt = 0;
+
+ extract( $params );
+ return current_time( $type, $gmt );
+}
+$wpsmarty->register_function( "current_time", "smarty_current_time" );
+
+/* date_i18n( $dateformatstring, $unixtimestamp ) */
+function smarty_date_i18n( $params, &$smarty )
+{
+
+ extract( $params );
+ return date_i18n( $dateformatstring, $unixtimestamp );
+}
+$wpsmarty->register_function( "date_i18n", "smarty_date_i18n" );
+
+/* get_weekstartend( $mysqlstring, $start_of_week ) */
+function smarty_get_weekstartend( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_weekstartend( $mysqlstring, $start_of_week );
+}
+$wpsmarty->register_function( "get_weekstartend", "smarty_get_weekstartend" );
+
+/* get_lastpostdate( $timezone = 'server' ) */
+function smarty_get_lastpostdate( $params, &$smarty )
+{
+ $timezone = 'server';
+
+ extract( $params );
+ return get_lastpostdate( $timezone );
+}
+$wpsmarty->register_function( "get_lastpostdate", "smarty_get_lastpostdate" );
+
+/* get_lastpostmodified( $timezone = 'server' ) */
+function smarty_get_lastpostmodified( $params, &$smarty )
+{
+ $timezone = 'server';
+
+ extract( $params );
+ return get_lastpostmodified( $timezone );
+}
+$wpsmarty->register_function( "get_lastpostmodified", "smarty_get_lastpostmodified" );
+
+/* user_pass_ok( $user_login,$user_pass ) */
+function smarty_user_pass_ok( $params, &$smarty )
+{
+
+ extract( $params );
+ return user_pass_ok( $user_login, $user_pass );
+}
+$wpsmarty->register_function( "user_pass_ok", "smarty_user_pass_ok" );
+
+/* get_usernumposts( $userid ) */
+function smarty_get_usernumposts( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_usernumposts( $userid );
+}
+$wpsmarty->register_function( "get_usernumposts", "smarty_get_usernumposts" );
+
+/* url_to_postid( $url ) */
+function smarty_url_to_postid( $params, &$smarty )
+{
+
+ extract( $params );
+ return url_to_postid( $url );
+}
+$wpsmarty->register_function( "url_to_postid", "smarty_url_to_postid" );
+
+/* get_settings( $setting ) */
+function smarty_get_settings( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_settings( $setting );
+}
+$wpsmarty->register_function( "get_settings", "smarty_get_settings" );
+
+/* get_option( $option ) */
+function smarty_get_option( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_option( $option );
+}
+$wpsmarty->register_function( "get_option", "smarty_get_option" );
+
+/* form_option( $option ) */
+function smarty_form_option( $params, &$smarty )
+{
+
+ extract( $params );
+ return form_option( $option );
+}
+$wpsmarty->register_function( "form_option", "smarty_form_option" );
+
+/* get_alloptions( ) */
+function smarty_get_alloptions( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_alloptions( );
+}
+$wpsmarty->register_function( "get_alloptions", "smarty_get_alloptions" );
+
+/* update_option( $option_name, $newvalue ) */
+function smarty_update_option( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_option( $option_name, $newvalue );
+}
+$wpsmarty->register_function( "update_option", "smarty_update_option" );
+
+/* add_option( $name, $value = '', $description = '', $autoload = 'yes' ) */
+function smarty_add_option( $params, &$smarty )
+{
+ $value = '';
+ $description = '';
+ $autoload = 'yes';
+
+ extract( $params );
+ return add_option( $name, $value, $description, $autoload );
+}
+$wpsmarty->register_function( "add_option", "smarty_add_option" );
+
+/* delete_option( $name ) */
+function smarty_delete_option( $params, &$smarty )
+{
+
+ extract( $params );
+ return delete_option( $name );
+}
+$wpsmarty->register_function( "delete_option", "smarty_delete_option" );
+
+/* add_post_meta( $post_id, $key, $value, $unique = false ) */
+function smarty_add_post_meta( $params, &$smarty )
+{
+ $unique = false;
+
+ extract( $params );
+ return add_post_meta( $post_id, $key, $value, $unique );
+}
+$wpsmarty->register_function( "add_post_meta", "smarty_add_post_meta" );
+
+/* delete_post_meta( $post_id, $key, $value = '' ) */
+function smarty_delete_post_meta( $params, &$smarty )
+{
+ $value = '';
+
+ extract( $params );
+ return delete_post_meta( $post_id, $key, $value );
+}
+$wpsmarty->register_function( "delete_post_meta", "smarty_delete_post_meta" );
+
+/* get_post_meta( $post_id, $key, $single = false ) */
+function smarty_get_post_meta( $params, &$smarty )
+{
+ $single = false;
+
+ extract( $params );
+ return get_post_meta( $post_id, $key, $single );
+}
+$wpsmarty->register_function( "get_post_meta", "smarty_get_post_meta" );
+
+/* update_post_meta( $post_id, $key, $value, $prev_value = '' ) */
+function smarty_update_post_meta( $params, &$smarty )
+{
+ $prev_value = '';
+
+ extract( $params );
+ return update_post_meta( $post_id, $key, $value, $prev_value );
+}
+$wpsmarty->register_function( "update_post_meta", "smarty_update_post_meta" );
+
+/* get_postdata( $postid ) */
+function smarty_get_postdata( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_postdata( $postid );
+}
+$wpsmarty->register_function( "get_postdata", "smarty_get_postdata" );
+
+/* &get_post( &$post, $output = OBJECT ) */
+function &smarty_get_post( $params, &$smarty )
+{
+ $output = OBJECT;
+
+ extract( $params );
+ return get_post( &$post, $output );
+}
+$wpsmarty->register_function( "get_post", "smarty_get_post" );
+
+/* &get_page( &$page, $output = OBJECT ) */
+function &smarty_get_page( $params, &$smarty )
+{
+ $output = OBJECT;
+
+ extract( $params );
+ return get_page( &$page, $output );
+}
+$wpsmarty->register_function( "get_page", "smarty_get_page" );
+
+/* &get_category( &$category, $output = OBJECT ) */
+function &smarty_get_category( $params, &$smarty )
+{
+ $output = OBJECT;
+
+ extract( $params );
+ return get_category( &$category, $output );
+}
+$wpsmarty->register_function( "get_category", "smarty_get_category" );
+
+/* &get_comment( &$comment, $output = OBJECT ) */
+function &smarty_get_comment( $params, &$smarty )
+{
+ $output = OBJECT;
+
+ extract( $params );
+ return get_comment( &$comment, $output );
+}
+$wpsmarty->register_function( "get_comment", "smarty_get_comment" );
+
+/* get_catname( $cat_ID ) */
+function smarty_get_catname( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_catname( $cat_ID );
+}
+$wpsmarty->register_function( "get_catname", "smarty_get_catname" );
+
+/* gzip_compression( ) */
+function smarty_gzip_compression( $params, &$smarty )
+{
+
+ extract( $params );
+ return gzip_compression( );
+}
+$wpsmarty->register_function( "gzip_compression", "smarty_gzip_compression" );
+
+/* timer_stop( $display = 0, $precision = 3 ) */
+function smarty_timer_stop( $params, &$smarty )
+{
+ $display = 0;
+ $precision = 3;
+
+ extract( $params );
+ return timer_stop( $display, $precision );
+}
+$wpsmarty->register_function( "timer_stop", "smarty_timer_stop" );
+
+/* weblog_ping( $server = '', $path = '' ) */
+function smarty_weblog_ping( $params, &$smarty )
+{
+ $server = '';
+ $path = '';
+
+ extract( $params );
+ return weblog_ping( $server, $path );
+}
+$wpsmarty->register_function( "weblog_ping", "smarty_weblog_ping" );
+
+/* generic_ping( $post_id = 0 ) */
+function smarty_generic_ping( $params, &$smarty )
+{
+ $post_id = 0;
+
+ extract( $params );
+ return generic_ping( $post_id );
+}
+$wpsmarty->register_function( "generic_ping", "smarty_generic_ping" );
+
+/* trackback( $trackback_url, $title, $excerpt, $ID ) */
+function smarty_trackback( $params, &$smarty )
+{
+
+ extract( $params );
+ return trackback( $trackback_url, $title, $excerpt, $ID );
+}
+$wpsmarty->register_function( "trackback", "smarty_trackback" );
+
+/* make_url_footnote( $content ) */
+function smarty_make_url_footnote( $params, &$smarty )
+{
+
+ extract( $params );
+ return make_url_footnote( $content );
+}
+$wpsmarty->register_function( "make_url_footnote", "smarty_make_url_footnote" );
+
+/* xmlrpc_getposttitle( $content ) */
+function smarty_xmlrpc_getposttitle( $params, &$smarty )
+{
+
+ extract( $params );
+ return xmlrpc_getposttitle( $content );
+}
+$wpsmarty->register_function( "xmlrpc_getposttitle", "smarty_xmlrpc_getposttitle" );
+
+/* xmlrpc_getpostcategory( $content ) */
+function smarty_xmlrpc_getpostcategory( $params, &$smarty )
+{
+
+ extract( $params );
+ return xmlrpc_getpostcategory( $content );
+}
+$wpsmarty->register_function( "xmlrpc_getpostcategory", "smarty_xmlrpc_getpostcategory" );
+
+/* xmlrpc_removepostdata( $content ) */
+function smarty_xmlrpc_removepostdata( $params, &$smarty )
+{
+
+ extract( $params );
+ return xmlrpc_removepostdata( $content );
+}
+$wpsmarty->register_function( "xmlrpc_removepostdata", "smarty_xmlrpc_removepostdata" );
+
+/* debug_fopen( $filename, $mode ) */
+function smarty_debug_fopen( $params, &$smarty )
+{
+
+ extract( $params );
+ return debug_fopen( $filename, $mode );
+}
+$wpsmarty->register_function( "debug_fopen", "smarty_debug_fopen" );
+
+/* debug_fwrite( $fp, $string ) */
+function smarty_debug_fwrite( $params, &$smarty )
+{
+
+ extract( $params );
+ return debug_fwrite( $fp, $string );
+}
+$wpsmarty->register_function( "debug_fwrite", "smarty_debug_fwrite" );
+
+/* debug_fclose( $fp ) */
+function smarty_debug_fclose( $params, &$smarty )
+{
+
+ extract( $params );
+ return debug_fclose( $fp );
+}
+$wpsmarty->register_function( "debug_fclose", "smarty_debug_fclose" );
+
+/* do_enclose( $content, $post_ID ) */
+function smarty_do_enclose( $params, &$smarty )
+{
+
+ extract( $params );
+ return do_enclose( $content, $post_ID );
+}
+$wpsmarty->register_function( "do_enclose", "smarty_do_enclose" );
+
+/* wp_get_http_headers( $url ) */
+function smarty_wp_get_http_headers( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_get_http_headers( $url );
+}
+$wpsmarty->register_function( "wp_get_http_headers", "smarty_wp_get_http_headers" );
+
+/* start_wp( ) */
+function smarty_start_wp( $params, &$smarty )
+{
+
+ extract( $params );
+ return start_wp( );
+}
+$wpsmarty->register_function( "start_wp", "smarty_start_wp" );
+
+/* setup_postdata( $post ) */
+function smarty_setup_postdata( $params, &$smarty )
+{
+
+ extract( $params );
+ return setup_postdata( $post );
+}
+$wpsmarty->register_function( "setup_postdata", "smarty_setup_postdata" );
+
+/* is_new_day( ) */
+function smarty_is_new_day( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_new_day( );
+}
+$wpsmarty->register_function( "is_new_day", "smarty_is_new_day" );
+
+/* merge_filters( $tag ) */
+function smarty_merge_filters( $params, &$smarty )
+{
+
+ extract( $params );
+ return merge_filters( $tag );
+}
+$wpsmarty->register_function( "merge_filters", "smarty_merge_filters" );
+
+/* apply_filters( $tag, $string ) */
+function smarty_apply_filters( $params, &$smarty )
+{
+
+ extract( $params );
+ return apply_filters( $tag, $string );
+}
+$wpsmarty->register_function( "apply_filters", "smarty_apply_filters" );
+
+/* add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) */
+function smarty_add_filter( $params, &$smarty )
+{
+ $priority = 10;
+ $accepted_args = 1;
+
+ extract( $params );
+ return add_filter( $tag, $function_to_add, $priority, $accepted_args );
+}
+$wpsmarty->register_function( "add_filter", "smarty_add_filter" );
+
+/* remove_filter( $tag, $function_to_remove, $priority = 10, $accepted_args = 1 ) */
+function smarty_remove_filter( $params, &$smarty )
+{
+ $priority = 10;
+ $accepted_args = 1;
+
+ extract( $params );
+ return remove_filter( $tag, $function_to_remove, $priority, $accepted_args );
+}
+$wpsmarty->register_function( "remove_filter", "smarty_remove_filter" );
+
+/* do_action( $tag, $arg = '' ) */
+function smarty_do_action( $params, &$smarty )
+{
+ $arg = '';
+
+ extract( $params );
+ return do_action( $tag, $arg );
+}
+$wpsmarty->register_function( "do_action", "smarty_do_action" );
+
+/* add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) */
+function smarty_add_action( $params, &$smarty )
+{
+ $priority = 10;
+ $accepted_args = 1;
+
+ extract( $params );
+ return add_action( $tag, $function_to_add, $priority, $accepted_args );
+}
+$wpsmarty->register_function( "add_action", "smarty_add_action" );
+
+/* remove_action( $tag, $function_to_remove, $priority = 10, $accepted_args = 1 ) */
+function smarty_remove_action( $params, &$smarty )
+{
+ $priority = 10;
+ $accepted_args = 1;
+
+ extract( $params );
+ return remove_action( $tag, $function_to_remove, $priority, $accepted_args );
+}
+$wpsmarty->register_function( "remove_action", "smarty_remove_action" );
+
+/* get_page_uri( $page_id ) */
+function smarty_get_page_uri( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_page_uri( $page_id );
+}
+$wpsmarty->register_function( "get_page_uri", "smarty_get_page_uri" );
+
+/* get_posts( $args ) */
+function smarty_get_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_posts( $args );
+}
+$wpsmarty->register_function( "get_posts", "smarty_get_posts" );
+
+/* &query_posts( $query ) */
+function &smarty_query_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return query_posts( $query );
+}
+$wpsmarty->register_function( "query_posts", "smarty_query_posts" );
+
+/* update_post_cache( &$posts ) */
+function smarty_update_post_cache( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_post_cache( &$posts );
+}
+$wpsmarty->register_function( "update_post_cache", "smarty_update_post_cache" );
+
+/* update_page_cache( &$pages ) */
+function smarty_update_page_cache( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_page_cache( &$pages );
+}
+$wpsmarty->register_function( "update_page_cache", "smarty_update_page_cache" );
+
+/* update_post_category_cache( $post_ids ) */
+function smarty_update_post_category_cache( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_post_category_cache( $post_ids );
+}
+$wpsmarty->register_function( "update_post_category_cache", "smarty_update_post_category_cache" );
+
+/* update_post_caches( &$posts ) */
+function smarty_update_post_caches( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_post_caches( &$posts );
+}
+$wpsmarty->register_function( "update_post_caches", "smarty_update_post_caches" );
+
+/* update_category_cache( ) */
+function smarty_update_category_cache( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_category_cache( );
+}
+$wpsmarty->register_function( "update_category_cache", "smarty_update_category_cache" );
+
+/* wp_head( ) */
+function smarty_wp_head( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_head( );
+}
+$wpsmarty->register_function( "wp_head", "smarty_wp_head" );
+
+/* wp_footer( ) */
+function smarty_wp_footer( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_footer( );
+}
+$wpsmarty->register_function( "wp_footer", "smarty_wp_footer" );
+
+/* is_single ( $post = '' ) */
+function smarty_is_single ( $params, &$smarty )
+{
+ $post = '';
+
+ extract( $params );
+ return is_single ( $post );
+}
+$wpsmarty->register_function( "is_single ", "smarty_is_single " );
+
+/* is_page ( $page = '' ) */
+function smarty_is_page ( $params, &$smarty )
+{
+ $page = '';
+
+ extract( $params );
+ return is_page ( $page );
+}
+$wpsmarty->register_function( "is_page ", "smarty_is_page " );
+
+/* is_archive ( ) */
+function smarty_is_archive ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_archive ( );
+}
+$wpsmarty->register_function( "is_archive ", "smarty_is_archive " );
+
+/* is_date ( ) */
+function smarty_is_date ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_date ( );
+}
+$wpsmarty->register_function( "is_date ", "smarty_is_date " );
+
+/* is_year ( ) */
+function smarty_is_year ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_year ( );
+}
+$wpsmarty->register_function( "is_year ", "smarty_is_year " );
+
+/* is_month ( ) */
+function smarty_is_month ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_month ( );
+}
+$wpsmarty->register_function( "is_month ", "smarty_is_month " );
+
+/* is_day ( ) */
+function smarty_is_day ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_day ( );
+}
+$wpsmarty->register_function( "is_day ", "smarty_is_day " );
+
+/* is_time ( ) */
+function smarty_is_time ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_time ( );
+}
+$wpsmarty->register_function( "is_time ", "smarty_is_time " );
+
+/* is_author ( $author = '' ) */
+function smarty_is_author ( $params, &$smarty )
+{
+ $author = '';
+
+ extract( $params );
+ return is_author ( $author );
+}
+$wpsmarty->register_function( "is_author ", "smarty_is_author " );
+
+/* is_category ( $category = '' ) */
+function smarty_is_category ( $params, &$smarty )
+{
+ $category = '';
+
+ extract( $params );
+ return is_category ( $category );
+}
+$wpsmarty->register_function( "is_category ", "smarty_is_category " );
+
+/* is_search ( ) */
+function smarty_is_search ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_search ( );
+}
+$wpsmarty->register_function( "is_search ", "smarty_is_search " );
+
+/* is_feed ( ) */
+function smarty_is_feed ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_feed ( );
+}
+$wpsmarty->register_function( "is_feed ", "smarty_is_feed " );
+
+/* is_trackback ( ) */
+function smarty_is_trackback ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_trackback ( );
+}
+$wpsmarty->register_function( "is_trackback ", "smarty_is_trackback " );
+
+/* is_admin ( ) */
+function smarty_is_admin ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_admin ( );
+}
+$wpsmarty->register_function( "is_admin ", "smarty_is_admin " );
+
+/* is_home ( ) */
+function smarty_is_home ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_home ( );
+}
+$wpsmarty->register_function( "is_home ", "smarty_is_home " );
+
+/* is_404 ( ) */
+function smarty_is_404 ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_404 ( );
+}
+$wpsmarty->register_function( "is_404 ", "smarty_is_404 " );
+
+/* is_comments_popup ( ) */
+function smarty_is_comments_popup ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_comments_popup ( );
+}
+$wpsmarty->register_function( "is_comments_popup ", "smarty_is_comments_popup " );
+
+/* is_paged ( ) */
+function smarty_is_paged ( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_paged ( );
+}
+$wpsmarty->register_function( "is_paged ", "smarty_is_paged " );
+
+/* get_query_var( $var ) */
+function smarty_get_query_var( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_query_var( $var );
+}
+$wpsmarty->register_function( "get_query_var", "smarty_get_query_var" );
+
+/* have_posts( ) */
+function smarty_have_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return have_posts( );
+}
+$wpsmarty->register_function( "have_posts", "smarty_have_posts" );
+
+/* rewind_posts( ) */
+function smarty_rewind_posts( $params, &$smarty )
+{
+
+ extract( $params );
+ return rewind_posts( );
+}
+$wpsmarty->register_function( "rewind_posts", "smarty_rewind_posts" );
+
+/* the_post( ) */
+function smarty_the_post( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_post( );
+}
+$wpsmarty->register_function( "the_post", "smarty_the_post" );
+
+/* get_theme_root( ) */
+function smarty_get_theme_root( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_theme_root( );
+}
+$wpsmarty->register_function( "get_theme_root", "smarty_get_theme_root" );
+
+/* get_theme_root_uri( ) */
+function smarty_get_theme_root_uri( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_theme_root_uri( );
+}
+$wpsmarty->register_function( "get_theme_root_uri", "smarty_get_theme_root_uri" );
+
+/* get_stylesheet( ) */
+function smarty_get_stylesheet( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_stylesheet( );
+}
+$wpsmarty->register_function( "get_stylesheet", "smarty_get_stylesheet" );
+
+/* get_stylesheet_directory( ) */
+function smarty_get_stylesheet_directory( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_stylesheet_directory( );
+}
+$wpsmarty->register_function( "get_stylesheet_directory", "smarty_get_stylesheet_directory" );
+
+/* get_stylesheet_directory_uri( ) */
+function smarty_get_stylesheet_directory_uri( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_stylesheet_directory_uri( );
+}
+$wpsmarty->register_function( "get_stylesheet_directory_uri", "smarty_get_stylesheet_directory_uri" );
+
+/* get_stylesheet_uri( ) */
+function smarty_get_stylesheet_uri( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_stylesheet_uri( );
+}
+$wpsmarty->register_function( "get_stylesheet_uri", "smarty_get_stylesheet_uri" );
+
+/* get_template( ) */
+function smarty_get_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_template( );
+}
+$wpsmarty->register_function( "get_template", "smarty_get_template" );
+
+/* get_template_directory( ) */
+function smarty_get_template_directory( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_template_directory( );
+}
+$wpsmarty->register_function( "get_template_directory", "smarty_get_template_directory" );
+
+/* get_template_directory_uri( ) */
+function smarty_get_template_directory_uri( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_template_directory_uri( );
+}
+$wpsmarty->register_function( "get_template_directory_uri", "smarty_get_template_directory_uri" );
+
+/* get_theme_data( $theme_file ) */
+function smarty_get_theme_data( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_theme_data( $theme_file );
+}
+$wpsmarty->register_function( "get_theme_data", "smarty_get_theme_data" );
+
+/* get_themes( ) */
+function smarty_get_themes( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_themes( );
+}
+$wpsmarty->register_function( "get_themes", "smarty_get_themes" );
+
+/* get_theme( $theme ) */
+function smarty_get_theme( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_theme( $theme );
+}
+$wpsmarty->register_function( "get_theme", "smarty_get_theme" );
+
+/* get_current_theme( ) */
+function smarty_get_current_theme( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_current_theme( );
+}
+$wpsmarty->register_function( "get_current_theme", "smarty_get_current_theme" );
+
+/* get_query_template( $type ) */
+function smarty_get_query_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_query_template( $type );
+}
+$wpsmarty->register_function( "get_query_template", "smarty_get_query_template" );
+
+/* get_404_template( ) */
+function smarty_get_404_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_404_template( );
+}
+$wpsmarty->register_function( "get_404_template", "smarty_get_404_template" );
+
+/* get_archive_template( ) */
+function smarty_get_archive_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_archive_template( );
+}
+$wpsmarty->register_function( "get_archive_template", "smarty_get_archive_template" );
+
+/* get_author_template( ) */
+function smarty_get_author_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_author_template( );
+}
+$wpsmarty->register_function( "get_author_template", "smarty_get_author_template" );
+
+/* get_category_template( ) */
+function smarty_get_category_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_category_template( );
+}
+$wpsmarty->register_function( "get_category_template", "smarty_get_category_template" );
+
+/* get_date_template( ) */
+function smarty_get_date_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_date_template( );
+}
+$wpsmarty->register_function( "get_date_template", "smarty_get_date_template" );
+
+/* get_home_template( ) */
+function smarty_get_home_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_home_template( );
+}
+$wpsmarty->register_function( "get_home_template", "smarty_get_home_template" );
+
+/* get_page_template( ) */
+function smarty_get_page_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_page_template( );
+}
+$wpsmarty->register_function( "get_page_template", "smarty_get_page_template" );
+
+/* get_paged_template( ) */
+function smarty_get_paged_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_paged_template( );
+}
+$wpsmarty->register_function( "get_paged_template", "smarty_get_paged_template" );
+
+/* get_search_template( ) */
+function smarty_get_search_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_search_template( );
+}
+$wpsmarty->register_function( "get_search_template", "smarty_get_search_template" );
+
+/* get_single_template( ) */
+function smarty_get_single_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_single_template( );
+}
+$wpsmarty->register_function( "get_single_template", "smarty_get_single_template" );
+
+/* get_comments_popup_template( ) */
+function smarty_get_comments_popup_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comments_popup_template( );
+}
+$wpsmarty->register_function( "get_comments_popup_template", "smarty_get_comments_popup_template" );
+
+/* htmlentities2( $myHTML ) */
+function smarty_htmlentities2( $params, &$smarty )
+{
+
+ extract( $params );
+ return htmlentities2( $myHTML );
+}
+$wpsmarty->register_function( "htmlentities2", "smarty_htmlentities2" );
+
+/* is_plugin_page( ) */
+function smarty_is_plugin_page( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_plugin_page( );
+}
+$wpsmarty->register_function( "is_plugin_page", "smarty_is_plugin_page" );
+
+/* add_query_arg( ) */
+function smarty_add_query_arg( $params, &$smarty )
+{
+
+ extract( $params );
+ return add_query_arg( );
+}
+$wpsmarty->register_function( "add_query_arg", "smarty_add_query_arg" );
+
+/* remove_query_arg( $key, $query ) */
+function smarty_remove_query_arg( $params, &$smarty )
+{
+
+ extract( $params );
+ return remove_query_arg( $key, $query );
+}
+$wpsmarty->register_function( "remove_query_arg", "smarty_remove_query_arg" );
+
+/* load_template( $file ) */
+function smarty_load_template( $params, &$smarty )
+{
+
+ extract( $params );
+ return load_template( $file );
+}
+$wpsmarty->register_function( "load_template", "smarty_load_template" );
+
+/* add_magic_quotes( $array ) */
+function smarty_add_magic_quotes( $params, &$smarty )
+{
+
+ extract( $params );
+ return add_magic_quotes( $array );
+}
+$wpsmarty->register_function( "add_magic_quotes", "smarty_add_magic_quotes" );
+
+/* wp_remote_fopen( $uri ) */
+function smarty_wp_remote_fopen( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_remote_fopen( $uri );
+}
+$wpsmarty->register_function( "wp_remote_fopen", "smarty_wp_remote_fopen" );
+
+/* wp( $query_vars = '' ) */
+function smarty_wp( $params, &$smarty )
+{
+ $query_vars = '';
+
+ extract( $params );
+ return wp( $query_vars );
+}
+$wpsmarty->register_function( "wp", "smarty_wp" );
+
+/* status_header( $header ) */
+function smarty_status_header( $params, &$smarty )
+{
+
+ extract( $params );
+ return status_header( $header );
+}
+$wpsmarty->register_function( "status_header", "smarty_status_header" );
+
+/* nocache_headers( ) */
+function smarty_nocache_headers( $params, &$smarty )
+{
+
+ extract( $params );
+ return nocache_headers( );
+}
+$wpsmarty->register_function( "nocache_headers", "smarty_nocache_headers" );
+
+/* get_usermeta( $user_id, $meta_key = '' ) */
+function smarty_get_usermeta( $params, &$smarty )
+{
+ $meta_key = '';
+
+ extract( $params );
+ return get_usermeta( $user_id, $meta_key );
+}
+$wpsmarty->register_function( "get_usermeta", "smarty_get_usermeta" );
+
+/* update_usermeta( $user_id, $meta_key, $meta_value ) */
+function smarty_update_usermeta( $params, &$smarty )
+{
+
+ extract( $params );
+ return update_usermeta( $user_id, $meta_key, $meta_value );
+}
+$wpsmarty->register_function( "update_usermeta", "smarty_update_usermeta" );
+
+/* register_activation_hook( $file, $function ) */
+function smarty_register_activation_hook( $params, &$smarty )
+{
+
+ extract( $params );
+ return register_activation_hook( $file, $function );
+}
+$wpsmarty->register_function( "register_activation_hook", "smarty_register_activation_hook" );
+
+/* register_deactivation_hook( $file, $function ) */
+function smarty_register_deactivation_hook( $params, &$smarty )
+{
+
+ extract( $params );
+ return register_deactivation_hook( $file, $function );
+}
+$wpsmarty->register_function( "register_deactivation_hook", "smarty_register_deactivation_hook" );
+
+/* plugin_basename( $file ) */
+function smarty_plugin_basename( $params, &$smarty )
+{
+
+ extract( $params );
+ return plugin_basename( $file );
+}
+$wpsmarty->register_function( "plugin_basename", "smarty_plugin_basename" );
+
+/* get_locale( ) */
+function smarty_get_locale( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_locale( );
+}
+$wpsmarty->register_function( "get_locale", "smarty_get_locale" );
+
+/* __( $text, $domain = 'default' ) */
+function smarty___( $params, &$smarty )
+{
+ $domain = 'default';
+
+ extract( $params );
+ return __( $text, $domain );
+}
+$wpsmarty->register_function( "__", "smarty___" );
+
+/* _e( $text, $domain = 'default' ) */
+function smarty__e( $params, &$smarty )
+{
+ $domain = 'default';
+
+ extract( $params );
+ return _e( $text, $domain );
+}
+$wpsmarty->register_function( "_e", "smarty__e" );
+
+/* __ngettext( $single, $plural, $number, $domain = 'default' ) */
+function smarty___ngettext( $params, &$smarty )
+{
+ $domain = 'default';
+
+ extract( $params );
+ return __ngettext( $single, $plural, $number, $domain );
+}
+$wpsmarty->register_function( "__ngettext", "smarty___ngettext" );
+
+/* load_textdomain( $domain, $mofile ) */
+function smarty_load_textdomain( $params, &$smarty )
+{
+
+ extract( $params );
+ return load_textdomain( $domain, $mofile );
+}
+$wpsmarty->register_function( "load_textdomain", "smarty_load_textdomain" );
+
+/* load_default_textdomain( ) */
+function smarty_load_default_textdomain( $params, &$smarty )
+{
+
+ extract( $params );
+ return load_default_textdomain( );
+}
+$wpsmarty->register_function( "load_default_textdomain", "smarty_load_default_textdomain" );
+
+/* load_plugin_textdomain( $domain ) */
+function smarty_load_plugin_textdomain( $params, &$smarty )
+{
+
+ extract( $params );
+ return load_plugin_textdomain( $domain );
+}
+$wpsmarty->register_function( "load_plugin_textdomain", "smarty_load_plugin_textdomain" );
+
+/* load_theme_textdomain( $domain ) */
+function smarty_load_theme_textdomain( $params, &$smarty )
+{
+
+ extract( $params );
+ return load_theme_textdomain( $domain );
+}
+$wpsmarty->register_function( "load_theme_textdomain", "smarty_load_theme_textdomain" );
+
+/* wptexturize( $text ) */
+function smarty_wptexturize( $params, &$smarty )
+{
+
+ extract( $params );
+ return wptexturize( $text );
+}
+$wpsmarty->register_function( "wptexturize", "smarty_wptexturize" );
+
+/* clean_pre( $text ) */
+function smarty_clean_pre( $params, &$smarty )
+{
+
+ extract( $params );
+ return clean_pre( $text );
+}
+$wpsmarty->register_function( "clean_pre", "smarty_clean_pre" );
+
+/* wpautop( $pee, $br = 1 ) */
+function smarty_wpautop( $params, &$smarty )
+{
+ $br = 1;
+
+ extract( $params );
+ return wpautop( $pee, $br );
+}
+$wpsmarty->register_function( "wpautop", "smarty_wpautop" );
+
+/* seems_utf8( $Str ) */
+function smarty_seems_utf8( $params, &$smarty )
+{
+
+ extract( $params );
+ return seems_utf8( $Str );
+}
+$wpsmarty->register_function( "seems_utf8", "smarty_seems_utf8" );
+
+/* wp_specialchars( $text, $quotes = 0 ) */
+function smarty_wp_specialchars( $params, &$smarty )
+{
+ $quotes = 0;
+
+ extract( $params );
+ return wp_specialchars( $text, $quotes );
+}
+$wpsmarty->register_function( "wp_specialchars", "smarty_wp_specialchars" );
+
+/* utf8_uri_encode( $utf8_string ) */
+function smarty_utf8_uri_encode( $params, &$smarty )
+{
+
+ extract( $params );
+ return utf8_uri_encode( $utf8_string );
+}
+$wpsmarty->register_function( "utf8_uri_encode", "smarty_utf8_uri_encode" );
+
+/* remove_accents( $string ) */
+function smarty_remove_accents( $params, &$smarty )
+{
+
+ extract( $params );
+ return remove_accents( $string );
+}
+$wpsmarty->register_function( "remove_accents", "smarty_remove_accents" );
+
+/* sanitize_user( $username ) */
+function smarty_sanitize_user( $params, &$smarty )
+{
+
+ extract( $params );
+ return sanitize_user( $username );
+}
+$wpsmarty->register_function( "sanitize_user", "smarty_sanitize_user" );
+
+/* sanitize_title( $title, $fallback_title = '' ) */
+function smarty_sanitize_title( $params, &$smarty )
+{
+ $fallback_title = '';
+
+ extract( $params );
+ return sanitize_title( $title, $fallback_title );
+}
+$wpsmarty->register_function( "sanitize_title", "smarty_sanitize_title" );
+
+/* sanitize_title_with_dashes( $title ) */
+function smarty_sanitize_title_with_dashes( $params, &$smarty )
+{
+
+ extract( $params );
+ return sanitize_title_with_dashes( $title );
+}
+$wpsmarty->register_function( "sanitize_title_with_dashes", "smarty_sanitize_title_with_dashes" );
+
+/* convert_chars( $content, $flag = 'obsolete' ) */
+function smarty_convert_chars( $params, &$smarty )
+{
+ $flag = 'obsolete';
+
+ extract( $params );
+ return convert_chars( $content, $flag );
+}
+$wpsmarty->register_function( "convert_chars", "smarty_convert_chars" );
+
+/* funky_javascript_fix( $text ) */
+function smarty_funky_javascript_fix( $params, &$smarty )
+{
+
+ extract( $params );
+ return funky_javascript_fix( $text );
+}
+$wpsmarty->register_function( "funky_javascript_fix", "smarty_funky_javascript_fix" );
+
+/* balanceTags( $text, $is_comment = 0 ) */
+function smarty_balanceTags( $params, &$smarty )
+{
+ $is_comment = 0;
+
+ extract( $params );
+ return balanceTags( $text, $is_comment );
+}
+$wpsmarty->register_function( "balanceTags", "smarty_balanceTags" );
+
+/* format_to_edit( $content ) */
+function smarty_format_to_edit( $params, &$smarty )
+{
+
+ extract( $params );
+ return format_to_edit( $content );
+}
+$wpsmarty->register_function( "format_to_edit", "smarty_format_to_edit" );
+
+/* format_to_post( $content ) */
+function smarty_format_to_post( $params, &$smarty )
+{
+
+ extract( $params );
+ return format_to_post( $content );
+}
+$wpsmarty->register_function( "format_to_post", "smarty_format_to_post" );
+
+/* zeroise( $number,$threshold ) */
+function smarty_zeroise( $params, &$smarty )
+{
+
+ extract( $params );
+ return zeroise( $number, $threshold );
+}
+$wpsmarty->register_function( "zeroise", "smarty_zeroise" );
+
+/* backslashit( $string ) */
+function smarty_backslashit( $params, &$smarty )
+{
+
+ extract( $params );
+ return backslashit( $string );
+}
+$wpsmarty->register_function( "backslashit", "smarty_backslashit" );
+
+/* trailingslashit( $string ) */
+function smarty_trailingslashit( $params, &$smarty )
+{
+
+ extract( $params );
+ return trailingslashit( $string );
+}
+$wpsmarty->register_function( "trailingslashit", "smarty_trailingslashit" );
+
+/* addslashes_gpc( $gpc ) */
+function smarty_addslashes_gpc( $params, &$smarty )
+{
+
+ extract( $params );
+ return addslashes_gpc( $gpc );
+}
+$wpsmarty->register_function( "addslashes_gpc", "smarty_addslashes_gpc" );
+
+/* stripslashes_deep( ) */
+function smarty_stripslashes_deep( $params, &$smarty )
+{
+
+ extract( $params );
+ return stripslashes_deep( );
+}
+$wpsmarty->register_function( "stripslashes_deep", "smarty_stripslashes_deep" );
+
+/* antispambot( $emailaddy, $mailto=0 ) */
+function smarty_antispambot( $params, &$smarty )
+{
+ $mailto=0;
+
+ extract( $params );
+ return antispambot( $emailaddy, $mailto );
+}
+$wpsmarty->register_function( "antispambot", "smarty_antispambot" );
+
+/* make_clickable( $ret ) */
+function smarty_make_clickable( $params, &$smarty )
+{
+
+ extract( $params );
+ return make_clickable( $ret );
+}
+$wpsmarty->register_function( "make_clickable", "smarty_make_clickable" );
+
+/* wp_rel_nofollow( $text ) */
+function smarty_wp_rel_nofollow( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_rel_nofollow( $text );
+}
+$wpsmarty->register_function( "wp_rel_nofollow", "smarty_wp_rel_nofollow" );
+
+/* convert_smilies( $text ) */
+function smarty_convert_smilies( $params, &$smarty )
+{
+
+ extract( $params );
+ return convert_smilies( $text );
+}
+$wpsmarty->register_function( "convert_smilies", "smarty_convert_smilies" );
+
+/* is_email( $user_email ) */
+function smarty_is_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return is_email( $user_email );
+}
+$wpsmarty->register_function( "is_email", "smarty_is_email" );
+
+/* wp_iso_descrambler( $string ) */
+function smarty_wp_iso_descrambler( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_iso_descrambler( $string );
+}
+$wpsmarty->register_function( "wp_iso_descrambler", "smarty_wp_iso_descrambler" );
+
+/* get_gmt_from_date( $string ) */
+function smarty_get_gmt_from_date( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_gmt_from_date( $string );
+}
+$wpsmarty->register_function( "get_gmt_from_date", "smarty_get_gmt_from_date" );
+
+/* get_date_from_gmt( $string ) */
+function smarty_get_date_from_gmt( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_date_from_gmt( $string );
+}
+$wpsmarty->register_function( "get_date_from_gmt", "smarty_get_date_from_gmt" );
+
+/* iso8601_timezone_to_offset( $timezone ) */
+function smarty_iso8601_timezone_to_offset( $params, &$smarty )
+{
+
+ extract( $params );
+ return iso8601_timezone_to_offset( $timezone );
+}
+$wpsmarty->register_function( "iso8601_timezone_to_offset", "smarty_iso8601_timezone_to_offset" );
+
+/* iso8601_to_datetime( $date_string, $timezone = USER ) */
+function smarty_iso8601_to_datetime( $params, &$smarty )
+{
+ $timezone = USER;
+
+ extract( $params );
+ return iso8601_to_datetime( $date_string, $timezone );
+}
+$wpsmarty->register_function( "iso8601_to_datetime", "smarty_iso8601_to_datetime" );
+
+/* popuplinks( $text ) */
+function smarty_popuplinks( $params, &$smarty )
+{
+
+ extract( $params );
+ return popuplinks( $text );
+}
+$wpsmarty->register_function( "popuplinks", "smarty_popuplinks" );
+
+/* sanitize_email( $email ) */
+function smarty_sanitize_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return sanitize_email( $email );
+}
+$wpsmarty->register_function( "sanitize_email", "smarty_sanitize_email" );
+
+/* human_time_diff( $from, $to = '' ) */
+function smarty_human_time_diff( $params, &$smarty )
+{
+ $to = '';
+
+ extract( $params );
+ return human_time_diff( $from, $to );
+}
+$wpsmarty->register_function( "human_time_diff", "smarty_human_time_diff" );
+
+/* wp_trim_excerpt( $text ) */
+function smarty_wp_trim_excerpt( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_trim_excerpt( $text );
+}
+$wpsmarty->register_function( "wp_trim_excerpt", "smarty_wp_trim_excerpt" );
+
+/* ent2ncr( $text ) */
+function smarty_ent2ncr( $params, &$smarty )
+{
+
+ extract( $params );
+ return ent2ncr( $text );
+}
+$wpsmarty->register_function( "ent2ncr", "smarty_ent2ncr" );
+
+/* wp_insert_post( $postarr = array() ) */
+function smarty_wp_insert_post( $params, &$smarty )
+{
+ $postarr = array();
+
+ extract( $params );
+ return wp_insert_post( $postarr );
+}
+$wpsmarty->register_function( "wp_insert_post", "smarty_wp_insert_post" );
+
+/* wp_get_single_post( $postid = 0, $mode = OBJECT ) */
+function smarty_wp_get_single_post( $params, &$smarty )
+{
+ $postid = 0;
+ $mode = OBJECT;
+
+ extract( $params );
+ return wp_get_single_post( $postid, $mode );
+}
+$wpsmarty->register_function( "wp_get_single_post", "smarty_wp_get_single_post" );
+
+/* wp_get_recent_posts( $num = 10 ) */
+function smarty_wp_get_recent_posts( $params, &$smarty )
+{
+ $num = 10;
+
+ extract( $params );
+ return wp_get_recent_posts( $num );
+}
+$wpsmarty->register_function( "wp_get_recent_posts", "smarty_wp_get_recent_posts" );
+
+/* wp_update_post( $postarr = array() ) */
+function smarty_wp_update_post( $params, &$smarty )
+{
+ $postarr = array();
+
+ extract( $params );
+ return wp_update_post( $postarr );
+}
+$wpsmarty->register_function( "wp_update_post", "smarty_wp_update_post" );
+
+/* wp_get_post_cats( $blogid = '1', $post_ID = 0 ) */
+function smarty_wp_get_post_cats( $params, &$smarty )
+{
+ $blogid = '1';
+ $post_ID = 0;
+
+ extract( $params );
+ return wp_get_post_cats( $blogid, $post_ID );
+}
+$wpsmarty->register_function( "wp_get_post_cats", "smarty_wp_get_post_cats" );
+
+/* wp_set_post_cats( $blogid = '1', $post_ID = 0, $post_categories = array() ) */
+function smarty_wp_set_post_cats( $params, &$smarty )
+{
+ $blogid = '1';
+ $post_ID = 0;
+ $post_categories = array();
+
+ extract( $params );
+ return wp_set_post_cats( $blogid, $post_ID, $post_categories );
+}
+$wpsmarty->register_function( "wp_set_post_cats", "smarty_wp_set_post_cats" );
+
+/* wp_delete_post( $postid = 0 ) */
+function smarty_wp_delete_post( $params, &$smarty )
+{
+ $postid = 0;
+
+ extract( $params );
+ return wp_delete_post( $postid );
+}
+$wpsmarty->register_function( "wp_delete_post", "smarty_wp_delete_post" );
+
+/* post_permalink( $post_id = 0, $mode = '' ) */
+function smarty_post_permalink( $params, &$smarty )
+{
+ $post_id = 0;
+ $mode = '';
+
+ extract( $params );
+ return post_permalink( $post_id, $mode );
+}
+$wpsmarty->register_function( "post_permalink", "smarty_post_permalink" );
+
+/* get_cat_name( $cat_id ) */
+function smarty_get_cat_name( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_cat_name( $cat_id );
+}
+$wpsmarty->register_function( "get_cat_name", "smarty_get_cat_name" );
+
+/* get_cat_ID( $cat_name='General' ) */
+function smarty_get_cat_ID( $params, &$smarty )
+{
+ $cat_name='General';
+
+ extract( $params );
+ return get_cat_ID( $cat_name );
+}
+$wpsmarty->register_function( "get_cat_ID", "smarty_get_cat_ID" );
+
+/* get_author_name( $auth_id ) */
+function smarty_get_author_name( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_author_name( $auth_id );
+}
+$wpsmarty->register_function( "get_author_name", "smarty_get_author_name" );
+
+/* get_extended( $post ) */
+function smarty_get_extended( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_extended( $post );
+}
+$wpsmarty->register_function( "get_extended", "smarty_get_extended" );
+
+/* trackback_url_list( $tb_list, $post_id ) */
+function smarty_trackback_url_list( $params, &$smarty )
+{
+
+ extract( $params );
+ return trackback_url_list( $tb_list, $post_id );
+}
+$wpsmarty->register_function( "trackback_url_list", "smarty_trackback_url_list" );
+
+/* user_can_create_post( $user_id, $blog_id = 1, $category_id = 'None' ) */
+function smarty_user_can_create_post( $params, &$smarty )
+{
+ $blog_id = 1;
+ $category_id = 'None';
+
+ extract( $params );
+ return user_can_create_post( $user_id, $blog_id, $category_id );
+}
+$wpsmarty->register_function( "user_can_create_post", "smarty_user_can_create_post" );
+
+/* user_can_create_draft( $user_id, $blog_id = 1, $category_id = 'None' ) */
+function smarty_user_can_create_draft( $params, &$smarty )
+{
+ $blog_id = 1;
+ $category_id = 'None';
+
+ extract( $params );
+ return user_can_create_draft( $user_id, $blog_id, $category_id );
+}
+$wpsmarty->register_function( "user_can_create_draft", "smarty_user_can_create_draft" );
+
+/* user_can_edit_post( $user_id, $post_id, $blog_id = 1 ) */
+function smarty_user_can_edit_post( $params, &$smarty )
+{
+ $blog_id = 1;
+
+ extract( $params );
+ return user_can_edit_post( $user_id, $post_id, $blog_id );
+}
+$wpsmarty->register_function( "user_can_edit_post", "smarty_user_can_edit_post" );
+
+/* user_can_delete_post( $user_id, $post_id, $blog_id = 1 ) */
+function smarty_user_can_delete_post( $params, &$smarty )
+{
+ $blog_id = 1;
+
+ extract( $params );
+ return user_can_delete_post( $user_id, $post_id, $blog_id );
+}
+$wpsmarty->register_function( "user_can_delete_post", "smarty_user_can_delete_post" );
+
+/* user_can_set_post_date( $user_id, $blog_id = 1, $category_id = 'None' ) */
+function smarty_user_can_set_post_date( $params, &$smarty )
+{
+ $blog_id = 1;
+ $category_id = 'None';
+
+ extract( $params );
+ return user_can_set_post_date( $user_id, $blog_id, $category_id );
+}
+$wpsmarty->register_function( "user_can_set_post_date", "smarty_user_can_set_post_date" );
+
+/* user_can_edit_post_date( $user_id, $post_id, $blog_id = 1 ) */
+function smarty_user_can_edit_post_date( $params, &$smarty )
+{
+ $blog_id = 1;
+
+ extract( $params );
+ return user_can_edit_post_date( $user_id, $post_id, $blog_id );
+}
+$wpsmarty->register_function( "user_can_edit_post_date", "smarty_user_can_edit_post_date" );
+
+/* user_can_edit_post_comments( $user_id, $post_id, $blog_id = 1 ) */
+function smarty_user_can_edit_post_comments( $params, &$smarty )
+{
+ $blog_id = 1;
+
+ extract( $params );
+ return user_can_edit_post_comments( $user_id, $post_id, $blog_id );
+}
+$wpsmarty->register_function( "user_can_edit_post_comments", "smarty_user_can_edit_post_comments" );
+
+/* user_can_delete_post_comments( $user_id, $post_id, $blog_id = 1 ) */
+function smarty_user_can_delete_post_comments( $params, &$smarty )
+{
+ $blog_id = 1;
+
+ extract( $params );
+ return user_can_delete_post_comments( $user_id, $post_id, $blog_id );
+}
+$wpsmarty->register_function( "user_can_delete_post_comments", "smarty_user_can_delete_post_comments" );
+
+/* user_can_edit_user( $user_id, $other_user ) */
+function smarty_user_can_edit_user( $params, &$smarty )
+{
+
+ extract( $params );
+ return user_can_edit_user( $user_id, $other_user );
+}
+$wpsmarty->register_function( "user_can_edit_user", "smarty_user_can_edit_user" );
+
+/* wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent ) */
+function smarty_wp_blacklist_check( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent );
+}
+$wpsmarty->register_function( "wp_blacklist_check", "smarty_wp_blacklist_check" );
+
+/* wp_proxy_check( $ipnum ) */
+function smarty_wp_proxy_check( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_proxy_check( $ipnum );
+}
+$wpsmarty->register_function( "wp_proxy_check", "smarty_wp_proxy_check" );
+
+/* wp_new_comment( $commentdata, $spam = false ) */
+function smarty_wp_new_comment( $params, &$smarty )
+{
+ $spam = false;
+
+ extract( $params );
+ return wp_new_comment( $commentdata, $spam );
+}
+$wpsmarty->register_function( "wp_new_comment", "smarty_wp_new_comment" );
+
+/* wp_update_comment( $commentarr ) */
+function smarty_wp_update_comment( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_update_comment( $commentarr );
+}
+$wpsmarty->register_function( "wp_update_comment", "smarty_wp_update_comment" );
+
+/* do_trackbacks( $post_id ) */
+function smarty_do_trackbacks( $params, &$smarty )
+{
+
+ extract( $params );
+ return do_trackbacks( $post_id );
+}
+$wpsmarty->register_function( "do_trackbacks", "smarty_do_trackbacks" );
+
+/* get_pung( $post_id ) */
+function smarty_get_pung( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_pung( $post_id );
+}
+$wpsmarty->register_function( "get_pung", "smarty_get_pung" );
+
+/* get_enclosed( $post_id ) */
+function smarty_get_enclosed( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_enclosed( $post_id );
+}
+$wpsmarty->register_function( "get_enclosed", "smarty_get_enclosed" );
+
+/* get_to_ping( $post_id ) */
+function smarty_get_to_ping( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_to_ping( $post_id );
+}
+$wpsmarty->register_function( "get_to_ping", "smarty_get_to_ping" );
+
+/* add_ping( $post_id, $uri ) */
+function smarty_add_ping( $params, &$smarty )
+{
+
+ extract( $params );
+ return add_ping( $post_id, $uri );
+}
+$wpsmarty->register_function( "add_ping", "smarty_add_ping" );
+
+/* generate_page_rewrite_rules( ) */
+function smarty_generate_page_rewrite_rules( $params, &$smarty )
+{
+
+ extract( $params );
+ return generate_page_rewrite_rules( );
+}
+$wpsmarty->register_function( "generate_page_rewrite_rules", "smarty_generate_page_rewrite_rules" );
+
+/* get_bloginfo_rss( $show = '' ) */
+function smarty_get_bloginfo_rss( $params, &$smarty )
+{
+ $show = '';
+
+ extract( $params );
+ return get_bloginfo_rss( $show );
+}
+$wpsmarty->register_function( "get_bloginfo_rss", "smarty_get_bloginfo_rss" );
+
+/* bloginfo_rss( $show = '' ) */
+function smarty_bloginfo_rss( $params, &$smarty )
+{
+ $show = '';
+
+ extract( $params );
+ return bloginfo_rss( $show );
+}
+$wpsmarty->register_function( "bloginfo_rss", "smarty_bloginfo_rss" );
+
+/* the_title_rss( ) */
+function smarty_the_title_rss( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_title_rss( );
+}
+$wpsmarty->register_function( "the_title_rss", "smarty_the_title_rss" );
+
+/* the_content_rss( $more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0 ) */
+function smarty_the_content_rss( $params, &$smarty )
+{
+ $more_link_text='(more...)';
+ $stripteaser=0;
+ $more_file='';
+ $cut = 0;
+ $encode_html = 0;
+
+ extract( $params );
+ return the_content_rss( $more_link_text, $stripteaser, $more_file, $cut, $encode_html );
+}
+$wpsmarty->register_function( "the_content_rss", "smarty_the_content_rss" );
+
+/* the_excerpt_rss( ) */
+function smarty_the_excerpt_rss( $params, &$smarty )
+{
+
+ extract( $params );
+ return the_excerpt_rss( );
+}
+$wpsmarty->register_function( "the_excerpt_rss", "smarty_the_excerpt_rss" );
+
+/* permalink_single_rss( $file = '' ) */
+function smarty_permalink_single_rss( $params, &$smarty )
+{
+ $file = '';
+
+ extract( $params );
+ return permalink_single_rss( $file );
+}
+$wpsmarty->register_function( "permalink_single_rss", "smarty_permalink_single_rss" );
+
+/* comment_link( ) */
+function smarty_comment_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_link( );
+}
+$wpsmarty->register_function( "comment_link", "smarty_comment_link" );
+
+/* comment_author_rss( ) */
+function smarty_comment_author_rss( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author_rss( );
+}
+$wpsmarty->register_function( "comment_author_rss", "smarty_comment_author_rss" );
+
+/* comment_text_rss( ) */
+function smarty_comment_text_rss( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_text_rss( );
+}
+$wpsmarty->register_function( "comment_text_rss", "smarty_comment_text_rss" );
+
+/* comments_rss_link( $link_text = 'Comments RSS', $commentsrssfilename = '' ) */
+function smarty_comments_rss_link( $params, &$smarty )
+{
+ $link_text = 'Comments RSS';
+ $commentsrssfilename = '';
+
+ extract( $params );
+ return comments_rss_link( $link_text, $commentsrssfilename );
+}
+$wpsmarty->register_function( "comments_rss_link", "smarty_comments_rss_link" );
+
+/* comments_rss( $commentsrssfilename = '' ) */
+function smarty_comments_rss( $params, &$smarty )
+{
+ $commentsrssfilename = '';
+
+ extract( $params );
+ return comments_rss( $commentsrssfilename );
+}
+$wpsmarty->register_function( "comments_rss", "smarty_comments_rss" );
+
+/* get_author_rss_link( $echo = false, $author_id, $author_nicename ) */
+function smarty_get_author_rss_link( $params, &$smarty )
+{
+ $echo = false;
+
+ extract( $params );
+ return get_author_rss_link( $echo, $author_id, $author_nicename );
+}
+$wpsmarty->register_function( "get_author_rss_link", "smarty_get_author_rss_link" );
+
+/* get_category_rss_link( $echo = false, $cat_ID, $category_nicename ) */
+function smarty_get_category_rss_link( $params, &$smarty )
+{
+ $echo = false;
+
+ extract( $params );
+ return get_category_rss_link( $echo, $cat_ID, $category_nicename );
+}
+$wpsmarty->register_function( "get_category_rss_link", "smarty_get_category_rss_link" );
+
+/* the_category_rss( $type = 'rss' ) */
+function smarty_the_category_rss( $params, &$smarty )
+{
+ $type = 'rss';
+
+ extract( $params );
+ return the_category_rss( $type );
+}
+$wpsmarty->register_function( "the_category_rss", "smarty_the_category_rss" );
+
+/* rss_enclosure( ) */
+function smarty_rss_enclosure( $params, &$smarty )
+{
+
+ extract( $params );
+ return rss_enclosure( );
+}
+$wpsmarty->register_function( "rss_enclosure", "smarty_rss_enclosure" );
+
+/* comments_template( $file = '/comments.php' ) */
+function smarty_comments_template( $params, &$smarty )
+{
+ $file = '/comments.php';
+
+ extract( $params );
+ return comments_template( $file );
+}
+$wpsmarty->register_function( "comments_template", "smarty_comments_template" );
+
+/* clean_url( $url ) */
+function smarty_clean_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return clean_url( $url );
+}
+$wpsmarty->register_function( "clean_url", "smarty_clean_url" );
+
+/* get_comments_number( $comment_id ) */
+function smarty_get_comments_number( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comments_number( $comment_id );
+}
+$wpsmarty->register_function( "get_comments_number", "smarty_get_comments_number" );
+
+/* comments_number( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $number = '' ) */
+function smarty_comments_number( $params, &$smarty )
+{
+ $zero = 'No Comments';
+ $one = '1 Comment';
+ $more = '% Comments';
+ $number = '';
+
+ extract( $params );
+ return comments_number( $zero, $one, $more, $number );
+}
+$wpsmarty->register_function( "comments_number", "smarty_comments_number" );
+
+/* get_comments_link( ) */
+function smarty_get_comments_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comments_link( );
+}
+$wpsmarty->register_function( "get_comments_link", "smarty_get_comments_link" );
+
+/* get_comment_link( ) */
+function smarty_get_comment_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_link( );
+}
+$wpsmarty->register_function( "get_comment_link", "smarty_get_comment_link" );
+
+/* comments_link( $file = '', $echo = true ) */
+function smarty_comments_link( $params, &$smarty )
+{
+ $file = '';
+ $echo = true;
+
+ extract( $params );
+ return comments_link( $file, $echo );
+}
+$wpsmarty->register_function( "comments_link", "smarty_comments_link" );
+
+/* comments_popup_script( $width=400, $height=400, $file='' ) */
+function smarty_comments_popup_script( $params, &$smarty )
+{
+ $width=400;
+ $height=400;
+ $file='';
+
+ extract( $params );
+ return comments_popup_script( $width, $height, $file );
+}
+$wpsmarty->register_function( "comments_popup_script", "smarty_comments_popup_script" );
+
+/* comments_popup_link( $zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off' ) */
+function smarty_comments_popup_link( $params, &$smarty )
+{
+ $zero='No Comments';
+ $one='1 Comment';
+ $more='% Comments';
+ $CSSclass='';
+ $none='Comments Off';
+
+ extract( $params );
+ return comments_popup_link( $zero, $one, $more, $CSSclass, $none );
+}
+$wpsmarty->register_function( "comments_popup_link", "smarty_comments_popup_link" );
+
+/* get_comment_ID( ) */
+function smarty_get_comment_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_ID( );
+}
+$wpsmarty->register_function( "get_comment_ID", "smarty_get_comment_ID" );
+
+/* comment_ID( ) */
+function smarty_comment_ID( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_ID( );
+}
+$wpsmarty->register_function( "comment_ID", "smarty_comment_ID" );
+
+/* get_comment_author( ) */
+function smarty_get_comment_author( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_author( );
+}
+$wpsmarty->register_function( "get_comment_author", "smarty_get_comment_author" );
+
+/* comment_author( ) */
+function smarty_comment_author( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author( );
+}
+$wpsmarty->register_function( "comment_author", "smarty_comment_author" );
+
+/* get_comment_author_email( ) */
+function smarty_get_comment_author_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_author_email( );
+}
+$wpsmarty->register_function( "get_comment_author_email", "smarty_get_comment_author_email" );
+
+/* comment_author_email( ) */
+function smarty_comment_author_email( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author_email( );
+}
+$wpsmarty->register_function( "comment_author_email", "smarty_comment_author_email" );
+
+/* get_comment_author_link( ) */
+function smarty_get_comment_author_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_author_link( );
+}
+$wpsmarty->register_function( "get_comment_author_link", "smarty_get_comment_author_link" );
+
+/* comment_author_link( ) */
+function smarty_comment_author_link( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author_link( );
+}
+$wpsmarty->register_function( "comment_author_link", "smarty_comment_author_link" );
+
+/* get_comment_type( ) */
+function smarty_get_comment_type( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_type( );
+}
+$wpsmarty->register_function( "get_comment_type", "smarty_get_comment_type" );
+
+/* comment_type( $commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback' ) */
+function smarty_comment_type( $params, &$smarty )
+{
+ $commenttxt = 'Comment';
+ $trackbacktxt = 'Trackback';
+ $pingbacktxt = 'Pingback';
+
+ extract( $params );
+ return comment_type( $commenttxt, $trackbacktxt, $pingbacktxt );
+}
+$wpsmarty->register_function( "comment_type", "smarty_comment_type" );
+
+/* get_comment_author_url( ) */
+function smarty_get_comment_author_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_author_url( );
+}
+$wpsmarty->register_function( "get_comment_author_url", "smarty_get_comment_author_url" );
+
+/* comment_author_url( ) */
+function smarty_comment_author_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author_url( );
+}
+$wpsmarty->register_function( "comment_author_url", "smarty_comment_author_url" );
+
+/* comment_author_email_link( $linktext='', $before='', $after='' ) */
+function smarty_comment_author_email_link( $params, &$smarty )
+{
+ $linktext='';
+ $before='';
+ $after='';
+
+ extract( $params );
+ return comment_author_email_link( $linktext, $before, $after );
+}
+$wpsmarty->register_function( "comment_author_email_link", "smarty_comment_author_email_link" );
+
+/* get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) */
+function smarty_get_comment_author_url_link( $params, &$smarty )
+{
+ $linktext = '';
+ $before = '';
+ $after = '';
+
+ extract( $params );
+ return get_comment_author_url_link( $linktext, $before, $after );
+}
+$wpsmarty->register_function( "get_comment_author_url_link", "smarty_get_comment_author_url_link" );
+
+/* comment_author_url_link( $linktext = '', $before = '', $after = '' ) */
+function smarty_comment_author_url_link( $params, &$smarty )
+{
+ $linktext = '';
+ $before = '';
+ $after = '';
+
+ extract( $params );
+ return comment_author_url_link( $linktext, $before, $after );
+}
+$wpsmarty->register_function( "comment_author_url_link", "smarty_comment_author_url_link" );
+
+/* get_comment_author_IP( ) */
+function smarty_get_comment_author_IP( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_author_IP( );
+}
+$wpsmarty->register_function( "get_comment_author_IP", "smarty_get_comment_author_IP" );
+
+/* comment_author_IP( ) */
+function smarty_comment_author_IP( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_author_IP( );
+}
+$wpsmarty->register_function( "comment_author_IP", "smarty_comment_author_IP" );
+
+/* get_comment_text( ) */
+function smarty_get_comment_text( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_text( );
+}
+$wpsmarty->register_function( "get_comment_text", "smarty_get_comment_text" );
+
+/* comment_text( ) */
+function smarty_comment_text( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_text( );
+}
+$wpsmarty->register_function( "comment_text", "smarty_comment_text" );
+
+/* get_comment_excerpt( ) */
+function smarty_get_comment_excerpt( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_comment_excerpt( );
+}
+$wpsmarty->register_function( "get_comment_excerpt", "smarty_get_comment_excerpt" );
+
+/* comment_excerpt( ) */
+function smarty_comment_excerpt( $params, &$smarty )
+{
+
+ extract( $params );
+ return comment_excerpt( );
+}
+$wpsmarty->register_function( "comment_excerpt", "smarty_comment_excerpt" );
+
+/* get_comment_date( $d = '' ) */
+function smarty_get_comment_date( $params, &$smarty )
+{
+ $d = '';
+
+ extract( $params );
+ return get_comment_date( $d );
+}
+$wpsmarty->register_function( "get_comment_date", "smarty_get_comment_date" );
+
+/* comment_date( $d = '' ) */
+function smarty_comment_date( $params, &$smarty )
+{
+ $d = '';
+
+ extract( $params );
+ return comment_date( $d );
+}
+$wpsmarty->register_function( "comment_date", "smarty_comment_date" );
+
+/* get_comment_time( $d = '', $gmt = false ) */
+function smarty_get_comment_time( $params, &$smarty )
+{
+ $d = '';
+ $gmt = false;
+
+ extract( $params );
+ return get_comment_time( $d, $gmt );
+}
+$wpsmarty->register_function( "get_comment_time", "smarty_get_comment_time" );
+
+/* comment_time( $d = '' ) */
+function smarty_comment_time( $params, &$smarty )
+{
+ $d = '';
+
+ extract( $params );
+ return comment_time( $d );
+}
+$wpsmarty->register_function( "comment_time", "smarty_comment_time" );
+
+/* get_trackback_url( ) */
+function smarty_get_trackback_url( $params, &$smarty )
+{
+
+ extract( $params );
+ return get_trackback_url( );
+}
+$wpsmarty->register_function( "get_trackback_url", "smarty_get_trackback_url" );
+
+/* trackback_url( $display = true ) */
+function smarty_trackback_url( $params, &$smarty )
+{
+ $display = true;
+
+ extract( $params );
+ return trackback_url( $display );
+}
+$wpsmarty->register_function( "trackback_url", "smarty_trackback_url" );
+
+/* trackback_rdf( $timezone = 0 ) */
+function smarty_trackback_rdf( $params, &$smarty )
+{
+ $timezone = 0;
+
+ extract( $params );
+ return trackback_rdf( $timezone );
+}
+$wpsmarty->register_function( "trackback_rdf", "smarty_trackback_rdf" );
+
+/* comments_open( ) */
+function smarty_comments_open( $params, &$smarty )
+{
+
+ extract( $params );
+ return comments_open( );
+}
+$wpsmarty->register_function( "comments_open", "smarty_comments_open" );
+
+/* pings_open( ) */
+function smarty_pings_open( $params, &$smarty )
+{
+
+ extract( $params );
+ return pings_open( );
+}
+$wpsmarty->register_function( "pings_open", "smarty_pings_open" );
+
+/* get_lastcommentmodified( $timezone = 'server' ) */
+function smarty_get_lastcommentmodified( $params, &$smarty )
+{
+ $timezone = 'server';
+
+ extract( $params );
+ return get_lastcommentmodified( $timezone );
+}
+$wpsmarty->register_function( "get_lastcommentmodified", "smarty_get_lastcommentmodified" );
+
+/* get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) */
+function smarty_get_commentdata( $params, &$smarty )
+{
+ $no_cache = 0;
+ $include_unapproved = false;
+
+ extract( $params );
+ return get_commentdata( $comment_ID, $no_cache, $include_unapproved );
+}
+$wpsmarty->register_function( "get_commentdata", "smarty_get_commentdata" );
+
+/* pingback( $content, $post_ID ) */
+function smarty_pingback( $params, &$smarty )
+{
+
+ extract( $params );
+ return pingback( $content, $post_ID );
+}
+$wpsmarty->register_function( "pingback", "smarty_pingback" );
+
+/* discover_pingback_server_uri( $url, $timeout_bytes = 2048 ) */
+function smarty_discover_pingback_server_uri( $params, &$smarty )
+{
+ $timeout_bytes = 2048;
+
+ extract( $params );
+ return discover_pingback_server_uri( $url, $timeout_bytes );
+}
+$wpsmarty->register_function( "discover_pingback_server_uri", "smarty_discover_pingback_server_uri" );
+
+/* wp_set_comment_status( $comment_id, $comment_status ) */
+function smarty_wp_set_comment_status( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_set_comment_status( $comment_id, $comment_status );
+}
+$wpsmarty->register_function( "wp_set_comment_status", "smarty_wp_set_comment_status" );
+
+/* wp_get_comment_status( $comment_id ) */
+function smarty_wp_get_comment_status( $params, &$smarty )
+{
+
+ extract( $params );
+ return wp_get_comment_status( $comment_id );
+}
+$wpsmarty->register_function( "wp_get_comment_status", "smarty_wp_get_comment_status" );
+
+/* check_comment( $author, $email, $url, $comment, $user_ip, $user_agent, $comment_type ) */
+function smarty_check_comment( $params, &$smarty )
+{
+
+ extract( $params );
+ return check_comment( $author, $email, $url, $comment, $user_ip, $user_agent, $comment_type );
+}
+$wpsmarty->register_function( "check_comment", "smarty_check_comment" );
+
+
+$wpsmarty->template_dir = ABSPATH."/wp-content/blogs/".$wpblog."/templates";
+$wpsmarty->compile_dir = ABSPATH."/wp-content/blogs/".$wpblog."/templates_c";
+$wpsmarty->cache_dir = ABSPATH."/wp-content/blogs/".$wpblog."/smartycache";
+$wpsmarty->plugins_dir = ABSPATH."/wp-content/smarty-plugins";
+$wpsmarty->cache_lifetime = -1;
+$wpsmarty->caching = true;
+$wpsmarty->security = 1;
+$wpsmarty->secure_dir = array( ABSPATH."/wp-content/blogs/".$wpblog."/templates", "wp-content/smarty-templates" );
+if( isset( $_GET[ "clear" ] ) )
+ $wpsmarty->clear_all_cache();
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/class-snoopy.php b/wp-inst/wp-includes/class-snoopy.php
new file mode 100644
index 0000000..9a9ac16
--- /dev/null
+++ b/wp-inst/wp-includes/class-snoopy.php
@@ -0,0 +1,901 @@
+<?php
+
+/*************************************************
+
+Snoopy - the PHP net client
+Author: Monte Ohrt <monte@ispi.net>
+Copyright (c): 1999-2000 ispi, all rights reserved
+Version: 1.0
+
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+You may contact the author of Snoopy by e-mail at:
+monte@ispi.net
+
+Or, write to:
+Monte Ohrt
+CTO, ispi
+237 S. 70th suite 220
+Lincoln, NE 68510
+
+The latest version of Snoopy can be obtained from:
+http://snoopy.sourceforge.net
+
+*************************************************/
+
+if ( !in_array('Snoopy', get_declared_classes() ) ) :
+class Snoopy
+{
+ /**** Public variables ****/
+
+ /* user definable vars */
+
+ var $host = "www.php.net"; // host name we are connecting to
+ var $port = 80; // port we are connecting to
+ var $proxy_host = ""; // proxy host to use
+ var $proxy_port = ""; // proxy port to use
+ var $agent = "Snoopy v1.0"; // agent we masquerade as
+ var $referer = ""; // referer info to pass
+ var $cookies = array(); // array of cookies to pass
+ // $cookies["username"]="joe";
+ var $rawheaders = array(); // array of raw headers to send
+ // $rawheaders["Content-type"]="text/html";
+
+ var $maxredirs = 5; // http redirection depth maximum. 0 = disallow
+ var $lastredirectaddr = ""; // contains address of last redirected address
+ var $offsiteok = true; // allows redirection off-site
+ var $maxframes = 0; // frame content depth maximum. 0 = disallow
+ var $expandlinks = true; // expand links to fully qualified URLs.
+ // this only applies to fetchlinks()
+ // or submitlinks()
+ var $passcookies = true; // pass set cookies back through redirects
+ // NOTE: this currently does not respect
+ // dates, domains or paths.
+
+ var $user = ""; // user for http authentication
+ var $pass = ""; // password for http authentication
+
+ // http accept types
+ var $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
+
+ var $results = ""; // where the content is put
+
+ var $error = ""; // error messages sent here
+ var $response_code = ""; // response code returned from server
+ var $headers = array(); // headers returned from server sent here
+ var $maxlength = 500000; // max return data length (body)
+ var $read_timeout = 0; // timeout on read operations, in seconds
+ // supported only since PHP 4 Beta 4
+ // set to 0 to disallow timeouts
+ var $timed_out = false; // if a read operation timed out
+ var $status = 0; // http request status
+
+ var $curl_path = "/usr/bin/curl";
+ // Snoopy will use cURL for fetching
+ // SSL content if a full system path to
+ // the cURL binary is supplied here.
+ // set to false if you do not have
+ // cURL installed. See http://curl.haxx.se
+ // for details on installing cURL.
+ // Snoopy does *not* use the cURL
+ // library functions built into php,
+ // as these functions are not stable
+ // as of this Snoopy release.
+
+ // send Accept-encoding: gzip?
+ var $use_gzip = true;
+
+ /**** Private variables ****/
+
+ var $_maxlinelen = 4096; // max line length (headers)
+
+ var $_httpmethod = "GET"; // default http request method
+ var $_httpversion = "HTTP/1.0"; // default http request version
+ var $_submit_method = "POST"; // default submit method
+ var $_submit_type = "application/x-www-form-urlencoded"; // default submit type
+ var $_mime_boundary = ""; // MIME boundary for multipart/form-data submit type
+ var $_redirectaddr = false; // will be set if page fetched is a redirect
+ var $_redirectdepth = 0; // increments on an http redirect
+ var $_frameurls = array(); // frame src urls
+ var $_framedepth = 0; // increments on frame depth
+
+ var $_isproxy = false; // set if using a proxy server
+ var $_fp_timeout = 30; // timeout for socket connection
+
+/*======================================================================*\
+ Function: fetch
+ Purpose: fetch the contents of a web page
+ (and possibly other protocols in the
+ future like ftp, nntp, gopher, etc.)
+ Input: $URI the location of the page to fetch
+ Output: $this->results the output text from the fetch
+\*======================================================================*/
+
+ function fetch($URI)
+ {
+
+ //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
+ $URI_PARTS = parse_url($URI);
+ if (!empty($URI_PARTS["user"]))
+ $this->user = $URI_PARTS["user"];
+ if (!empty($URI_PARTS["pass"]))
+ $this->pass = $URI_PARTS["pass"];
+
+ switch($URI_PARTS["scheme"])
+ {
+ case "http":
+ $this->host = $URI_PARTS["host"];
+ if(!empty($URI_PARTS["port"]))
+ $this->port = $URI_PARTS["port"];
+ if($this->_connect($fp))
+ {
+ if($this->_isproxy)
+ {
+ // using proxy, send entire URI
+ $this->_httprequest($URI,$fp,$URI,$this->_httpmethod);
+ }
+ else
+ {
+ $path = $URI_PARTS["path"].(isset($URI_PARTS["query"]) ? "?".$URI_PARTS["query"] : "");
+ // no proxy, send only the path
+ $this->_httprequest($path, $fp, $URI, $this->_httpmethod);
+ }
+
+ $this->_disconnect($fp);
+
+ if($this->_redirectaddr)
+ {
+ /* url was redirected, check if we've hit the max depth */
+ if($this->maxredirs > $this->_redirectdepth)
+ {
+ // only follow redirect if it's on this site, or offsiteok is true
+ if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
+ {
+ /* follow the redirect */
+ $this->_redirectdepth++;
+ $this->lastredirectaddr=$this->_redirectaddr;
+ $this->fetch($this->_redirectaddr);
+ }
+ }
+ }
+
+ if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
+ {
+ $frameurls = $this->_frameurls;
+ $this->_frameurls = array();
+
+ while(list(,$frameurl) = each($frameurls))
+ {
+ if($this->_framedepth < $this->maxframes)
+ {
+ $this->fetch($frameurl);
+ $this->_framedepth++;
+ }
+ else
+ break;
+ }
+ }
+ }
+ else
+ {
+ return false;
+ }
+ return true;
+ break;
+ case "https":
+ if(!$this->curl_path || (!is_executable($this->curl_path))) {
+ $this->error = "Bad curl ($this->curl_path), can't fetch HTTPS \n";
+ return false;
+ }
+ $this->host = $URI_PARTS["host"];
+ if(!empty($URI_PARTS["port"]))
+ $this->port = $URI_PARTS["port"];
+ if($this->_isproxy)
+ {
+ // using proxy, send entire URI
+ $this->_httpsrequest($URI,$URI,$this->_httpmethod);
+ }
+ else
+ {
+ $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
+ // no proxy, send only the path
+ $this->_httpsrequest($path, $URI, $this->_httpmethod);
+ }
+
+ if($this->_redirectaddr)
+ {
+ /* url was redirected, check if we've hit the max depth */
+ if($this->maxredirs > $this->_redirectdepth)
+ {
+ // only follow redirect if it's on this site, or offsiteok is true
+ if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
+ {
+ /* follow the redirect */
+ $this->_redirectdepth++;
+ $this->lastredirectaddr=$this->_redirectaddr;
+ $this->fetch($this->_redirectaddr);
+ }
+ }
+ }
+
+ if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
+ {
+ $frameurls = $this->_frameurls;
+ $this->_frameurls = array();
+
+ while(list(,$frameurl) = each($frameurls))
+ {
+ if($this->_framedepth < $this->maxframes)
+ {
+ $this->fetch($frameurl);
+ $this->_framedepth++;
+ }
+ else
+ break;
+ }
+ }
+ return true;
+ break;
+ default:
+ // not a valid protocol
+ $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
+ return false;
+ break;
+ }
+ return true;
+ }
+
+
+
+/*======================================================================*\
+ Private functions
+\*======================================================================*/
+
+
+/*======================================================================*\
+ Function: _striplinks
+ Purpose: strip the hyperlinks from an html document
+ Input: $document document to strip.
+ Output: $match an array of the links
+\*======================================================================*/
+
+ function _striplinks($document)
+ {
+ preg_match_all("'<\s*a\s+.*href\s*=\s* # find <a href=
+ ([\"\'])? # find single or double quote
+ (?(1) (.*?)\\1 | ([^\s\>]+)) # if quote found, match up to next matching
+ # quote, otherwise match up to next space
+ 'isx",$document,$links);
+
+
+ // catenate the non-empty matches from the conditional subpattern
+
+ while(list($key,$val) = each($links[2]))
+ {
+ if(!empty($val))
+ $match[] = $val;
+ }
+
+ while(list($key,$val) = each($links[3]))
+ {
+ if(!empty($val))
+ $match[] = $val;
+ }
+
+ // return the links
+ return $match;
+ }
+
+/*======================================================================*\
+ Function: _stripform
+ Purpose: strip the form elements from an html document
+ Input: $document document to strip.
+ Output: $match an array of the links
+\*======================================================================*/
+
+ function _stripform($document)
+ {
+ preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements);
+
+ // catenate the matches
+ $match = implode("\r\n",$elements[0]);
+
+ // return the links
+ return $match;
+ }
+
+
+
+/*======================================================================*\
+ Function: _striptext
+ Purpose: strip the text from an html document
+ Input: $document document to strip.
+ Output: $text the resulting text
+\*======================================================================*/
+
+ function _striptext($document)
+ {
+
+ // I didn't use preg eval (//e) since that is only available in PHP 4.0.
+ // so, list your entities one by one here. I included some of the
+ // more common ones.
+
+ $search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript
+ "'<[\/\!]*?[^<>]*?>'si", // strip out html tags
+ "'([\r\n])[\s]+'", // strip out white space
+ "'&(quote|#34);'i", // replace html entities
+ "'&(amp|#38);'i",
+ "'&(lt|#60);'i",
+ "'&(gt|#62);'i",
+ "'&(nbsp|#160);'i",
+ "'&(iexcl|#161);'i",
+ "'&(cent|#162);'i",
+ "'&(pound|#163);'i",
+ "'&(copy|#169);'i"
+ );
+ $replace = array( "",
+ "",
+ "\\1",
+ "\"",
+ "&",
+ "<",
+ ">",
+ " ",
+ chr(161),
+ chr(162),
+ chr(163),
+ chr(169));
+
+ $text = preg_replace($search,$replace,$document);
+
+ return $text;
+ }
+
+/*======================================================================*\
+ Function: _expandlinks
+ Purpose: expand each link into a fully qualified URL
+ Input: $links the links to qualify
+ $URI the full URI to get the base from
+ Output: $expandedLinks the expanded links
+\*======================================================================*/
+
+ function _expandlinks($links,$URI)
+ {
+
+ preg_match("/^[^\?]+/",$URI,$match);
+
+ $match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]);
+
+ $search = array( "|^http://".preg_quote($this->host)."|i",
+ "|^(?!http://)(\/)?(?!mailto:)|i",
+ "|/\./|",
+ "|/[^\/]+/\.\./|"
+ );
+
+ $replace = array( "",
+ $match."/",
+ "/",
+ "/"
+ );
+
+ $expandedLinks = preg_replace($search,$replace,$links);
+
+ return $expandedLinks;
+ }
+
+/*======================================================================*\
+ Function: _httprequest
+ Purpose: go get the http data from the server
+ Input: $url the url to fetch
+ $fp the current open file pointer
+ $URI the full URI
+ $body body contents to send if any (POST)
+ Output:
+\*======================================================================*/
+
+ function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
+ {
+ if($this->passcookies && $this->_redirectaddr)
+ $this->setcookies();
+
+ $URI_PARTS = parse_url($URI);
+ if(empty($url))
+ $url = "/";
+ $headers = $http_method." ".$url." ".$this->_httpversion."\r\n";
+ if(!empty($this->agent))
+ $headers .= "User-Agent: ".$this->agent."\r\n";
+ if(!empty($this->host) && !isset($this->rawheaders['Host']))
+ $headers .= "Host: ".$this->host."\r\n";
+ if(!empty($this->accept))
+ $headers .= "Accept: ".$this->accept."\r\n";
+
+ if($this->use_gzip) {
+ // make sure PHP was built with --with-zlib
+ // and we can handle gzipp'ed data
+ if ( function_exists(gzinflate) ) {
+ $headers .= "Accept-encoding: gzip\r\n";
+ }
+ else {
+ trigger_error(
+ "use_gzip is on, but PHP was built without zlib support.".
+ " Requesting file(s) without gzip encoding.",
+ E_USER_NOTICE);
+ }
+ }
+
+ if(!empty($this->referer))
+ $headers .= "Referer: ".$this->referer."\r\n";
+ if(!empty($this->cookies))
+ {
+ if(!is_array($this->cookies))
+ $this->cookies = (array)$this->cookies;
+
+ reset($this->cookies);
+ if ( count($this->cookies) > 0 ) {
+ $cookie_headers .= 'Cookie: ';
+ foreach ( $this->cookies as $cookieKey => $cookieVal ) {
+ $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; ";
+ }
+ $headers .= substr($cookie_headers,0,-2) . "\r\n";
+ }
+ }
+ if(!empty($this->rawheaders))
+ {
+ if(!is_array($this->rawheaders))
+ $this->rawheaders = (array)$this->rawheaders;
+ while(list($headerKey,$headerVal) = each($this->rawheaders))
+ $headers .= $headerKey.": ".$headerVal."\r\n";
+ }
+ if(!empty($content_type)) {
+ $headers .= "Content-type: $content_type";
+ if ($content_type == "multipart/form-data")
+ $headers .= "; boundary=".$this->_mime_boundary;
+ $headers .= "\r\n";
+ }
+ if(!empty($body))
+ $headers .= "Content-length: ".strlen($body)."\r\n";
+ if(!empty($this->user) || !empty($this->pass))
+ $headers .= "Authorization: BASIC ".base64_encode($this->user.":".$this->pass)."\r\n";
+
+ $headers .= "\r\n";
+
+ // set the read timeout if needed
+ if ($this->read_timeout > 0)
+ socket_set_timeout($fp, $this->read_timeout);
+ $this->timed_out = false;
+
+ fwrite($fp,$headers.$body,strlen($headers.$body));
+
+ $this->_redirectaddr = false;
+ unset($this->headers);
+
+ // content was returned gzip encoded?
+ $is_gzipped = false;
+
+ while($currentHeader = fgets($fp,$this->_maxlinelen))
+ {
+ if ($this->read_timeout > 0 && $this->_check_timeout($fp))
+ {
+ $this->status=-100;
+ return false;
+ }
+
+ // if($currentHeader == "\r\n")
+ if(preg_match("/^\r?\n$/", $currentHeader) )
+ break;
+
+ // if a header begins with Location: or URI:, set the redirect
+ if(preg_match("/^(Location:|URI:)/i",$currentHeader))
+ {
+ // get URL portion of the redirect
+ preg_match("/^(Location:|URI:)\s+(.*)/",chop($currentHeader),$matches);
+ // look for :// in the Location header to see if hostname is included
+ if(!preg_match("|\:\/\/|",$matches[2]))
+ {
+ // no host in the path, so prepend
+ $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
+ // eliminate double slash
+ if(!preg_match("|^/|",$matches[2]))
+ $this->_redirectaddr .= "/".$matches[2];
+ else
+ $this->_redirectaddr .= $matches[2];
+ }
+ else
+ $this->_redirectaddr = $matches[2];
+ }
+
+ if(preg_match("|^HTTP/|",$currentHeader))
+ {
+ if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status))
+ {
+ $this->status= $status[1];
+ }
+ $this->response_code = $currentHeader;
+ }
+
+ if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) {
+ $is_gzipped = true;
+ }
+
+ $this->headers[] = $currentHeader;
+ }
+
+ # $results = fread($fp, $this->maxlength);
+ $results = "";
+ while ( $data = fread($fp, $this->maxlength) ) {
+ $results .= $data;
+ if (
+ strlen($results) > $this->maxlength ) {
+ break;
+ }
+ }
+
+ // gunzip
+ if ( $is_gzipped ) {
+ // per http://www.php.net/manual/en/function.gzencode.php
+ $results = substr($results, 10);
+ $results = gzinflate($results);
+ }
+
+ if ($this->read_timeout > 0 && $this->_check_timeout($fp))
+ {
+ $this->status=-100;
+ return false;
+ }
+
+ // check if there is a a redirect meta tag
+
+ if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
+ {
+ $this->_redirectaddr = $this->_expandlinks($match[1],$URI);
+ }
+
+ // have we hit our frame depth and is there frame src to fetch?
+ if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
+ {
+ $this->results[] = $results;
+ for($x=0; $x<count($match[1]); $x++)
+ $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
+ }
+ // have we already fetched framed content?
+ elseif(is_array($this->results))
+ $this->results[] = $results;
+ // no framed content
+ else
+ $this->results = $results;
+
+ return true;
+ }
+
+/*======================================================================*\
+ Function: _httpsrequest
+ Purpose: go get the https data from the server using curl
+ Input: $url the url to fetch
+ $URI the full URI
+ $body body contents to send if any (POST)
+ Output:
+\*======================================================================*/
+
+ function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
+ {
+ if($this->passcookies && $this->_redirectaddr)
+ $this->setcookies();
+
+ $headers = array();
+
+ $URI_PARTS = parse_url($URI);
+ if(empty($url))
+ $url = "/";
+ // GET ... header not needed for curl
+ //$headers[] = $http_method." ".$url." ".$this->_httpversion;
+ if(!empty($this->agent))
+ $headers[] = "User-Agent: ".$this->agent;
+ if(!empty($this->host))
+ $headers[] = "Host: ".$this->host;
+ if(!empty($this->accept))
+ $headers[] = "Accept: ".$this->accept;
+ if(!empty($this->referer))
+ $headers[] = "Referer: ".$this->referer;
+ if(!empty($this->cookies))
+ {
+ if(!is_array($this->cookies))
+ $this->cookies = (array)$this->cookies;
+
+ reset($this->cookies);
+ if ( count($this->cookies) > 0 ) {
+ $cookie_str = 'Cookie: ';
+ foreach ( $this->cookies as $cookieKey => $cookieVal ) {
+ $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; ";
+ }
+ $headers[] = substr($cookie_str,0,-2);
+ }
+ }
+ if(!empty($this->rawheaders))
+ {
+ if(!is_array($this->rawheaders))
+ $this->rawheaders = (array)$this->rawheaders;
+ while(list($headerKey,$headerVal) = each($this->rawheaders))
+ $headers[] = $headerKey.": ".$headerVal;
+ }
+ if(!empty($content_type)) {
+ if ($content_type == "multipart/form-data")
+ $headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
+ else
+ $headers[] = "Content-type: $content_type";
+ }
+ if(!empty($body))
+ $headers[] = "Content-length: ".strlen($body);
+ if(!empty($this->user) || !empty($this->pass))
+ $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
+
+ for($curr_header = 0; $curr_header < count($headers); $curr_header++)
+ $cmdline_params .= " -H \"".$headers[$curr_header]."\"";
+
+ if(!empty($body))
+ $cmdline_params .= " -d \"$body\"";
+
+ if($this->read_timeout > 0)
+ $cmdline_params .= " -m ".$this->read_timeout;
+
+ $headerfile = uniqid(time());
+
+ # accept self-signed certs
+ $cmdline_params .= " -k";
+ exec($this->curl_path." -D \"/tmp/$headerfile\"".$cmdline_params." ".$URI,$results,$return);
+
+ if($return)
+ {
+ $this->error = "Error: cURL could not retrieve the document, error $return.";
+ return false;
+ }
+
+
+ $results = implode("\r\n",$results);
+
+ $result_headers = file("/tmp/$headerfile");
+
+ $this->_redirectaddr = false;
+ unset($this->headers);
+
+ for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
+ {
+
+ // if a header begins with Location: or URI:, set the redirect
+ if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader]))
+ {
+ // get URL portion of the redirect
+ preg_match("/^(Location: |URI:)(.*)/",chop($result_headers[$currentHeader]),$matches);
+ // look for :// in the Location header to see if hostname is included
+ if(!preg_match("|\:\/\/|",$matches[2]))
+ {
+ // no host in the path, so prepend
+ $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
+ // eliminate double slash
+ if(!preg_match("|^/|",$matches[2]))
+ $this->_redirectaddr .= "/".$matches[2];
+ else
+ $this->_redirectaddr .= $matches[2];
+ }
+ else
+ $this->_redirectaddr = $matches[2];
+ }
+
+ if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
+ {
+ $this->response_code = $result_headers[$currentHeader];
+ if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$this->response_code, $match))
+ {
+ $this->status= $match[1];
+ }
+ }
+ $this->headers[] = $result_headers[$currentHeader];
+ }
+
+ // check if there is a a redirect meta tag
+
+ if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
+ {
+ $this->_redirectaddr = $this->_expandlinks($match[1],$URI);
+ }
+
+ // have we hit our frame depth and is there frame src to fetch?
+ if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
+ {
+ $this->results[] = $results;
+ for($x=0; $x<count($match[1]); $x++)
+ $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
+ }
+ // have we already fetched framed content?
+ elseif(is_array($this->results))
+ $this->results[] = $results;
+ // no framed content
+ else
+ $this->results = $results;
+
+ unlink("/tmp/$headerfile");
+
+ return true;
+ }
+
+/*======================================================================*\
+ Function: setcookies()
+ Purpose: set cookies for a redirection
+\*======================================================================*/
+
+ function setcookies()
+ {
+ for($x=0; $x<count($this->headers); $x++)
+ {
+ if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match))
+ $this->cookies[$match[1]] = $match[2];
+ }
+ }
+
+
+/*======================================================================*\
+ Function: _check_timeout
+ Purpose: checks whether timeout has occurred
+ Input: $fp file pointer
+\*======================================================================*/
+
+ function _check_timeout($fp)
+ {
+ if ($this->read_timeout > 0) {
+ $fp_status = socket_get_status($fp);
+ if ($fp_status["timed_out"]) {
+ $this->timed_out = true;
+ return true;
+ }
+ }
+ return false;
+ }
+
+/*======================================================================*\
+ Function: _connect
+ Purpose: make a socket connection
+ Input: $fp file pointer
+\*======================================================================*/
+
+ function _connect(&$fp)
+ {
+ if(!empty($this->proxy_host) && !empty($this->proxy_port))
+ {
+ $this->_isproxy = true;
+ $host = $this->proxy_host;
+ $port = $this->proxy_port;
+ }
+ else
+ {
+ $host = $this->host;
+ $port = $this->port;
+ }
+
+ $this->status = 0;
+
+ if($fp = fsockopen(
+ $host,
+ $port,
+ $errno,
+ $errstr,
+ $this->_fp_timeout
+ ))
+ {
+ // socket connection succeeded
+
+ return true;
+ }
+ else
+ {
+ // socket connection failed
+ $this->status = $errno;
+ switch($errno)
+ {
+ case -3:
+ $this->error="socket creation failed (-3)";
+ case -4:
+ $this->error="dns lookup failure (-4)";
+ case -5:
+ $this->error="connection refused or timed out (-5)";
+ default:
+ $this->error="connection failed (".$errno.")";
+ }
+ return false;
+ }
+ }
+/*======================================================================*\
+ Function: _disconnect
+ Purpose: disconnect a socket connection
+ Input: $fp file pointer
+\*======================================================================*/
+
+ function _disconnect($fp)
+ {
+ return(fclose($fp));
+ }
+
+
+/*======================================================================*\
+ Function: _prepare_post_body
+ Purpose: Prepare post body according to encoding type
+ Input: $formvars - form variables
+ $formfiles - form upload files
+ Output: post body
+\*======================================================================*/
+
+ function _prepare_post_body($formvars, $formfiles)
+ {
+ settype($formvars, "array");
+ settype($formfiles, "array");
+
+ if (count($formvars) == 0 && count($formfiles) == 0)
+ return;
+
+ switch ($this->_submit_type) {
+ case "application/x-www-form-urlencoded":
+ reset($formvars);
+ while(list($key,$val) = each($formvars)) {
+ if (is_array($val) || is_object($val)) {
+ while (list($cur_key, $cur_val) = each($val)) {
+ $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
+ }
+ } else
+ $postdata .= urlencode($key)."=".urlencode($val)."&";
+ }
+ break;
+
+ case "multipart/form-data":
+ $this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
+
+ reset($formvars);
+ while(list($key,$val) = each($formvars)) {
+ if (is_array($val) || is_object($val)) {
+ while (list($cur_key, $cur_val) = each($val)) {
+ $postdata .= "--".$this->_mime_boundary."\r\n";
+ $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
+ $postdata .= "$cur_val\r\n";
+ }
+ } else {
+ $postdata .= "--".$this->_mime_boundary."\r\n";
+ $postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n";
+ $postdata .= "$val\r\n";
+ }
+ }
+
+ reset($formfiles);
+ while (list($field_name, $file_names) = each($formfiles)) {
+ settype($file_names, "array");
+ while (list(, $file_name) = each($file_names)) {
+ if (!is_readable($file_name)) continue;
+
+ $fp = fopen($file_name, "r");
+ $file_content = fread($fp, filesize($file_name));
+ fclose($fp);
+ $base_name = basename($file_name);
+
+ $postdata .= "--".$this->_mime_boundary."\r\n";
+ $postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n";
+ $postdata .= "$file_content\r\n";
+ }
+ }
+ $postdata .= "--".$this->_mime_boundary."--\r\n";
+ break;
+ }
+
+ return $postdata;
+ }
+}
+endif;
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/classes.php b/wp-inst/wp-includes/classes.php
new file mode 100644
index 0000000..ca4c082
--- /dev/null
+++ b/wp-inst/wp-includes/classes.php
@@ -0,0 +1,1526 @@
+<?php
+
+class WP_Query {
+ var $query;
+ var $query_vars;
+ var $queried_object;
+ var $queried_object_id;
+
+ var $posts;
+ var $post_count = 0;
+ var $current_post = -1;
+ var $post;
+
+ var $is_single = false;
+ var $is_page = false;
+ var $is_archive = false;
+ var $is_date = false;
+ var $is_year = false;
+ var $is_month = false;
+ var $is_day = false;
+ var $is_time = false;
+ var $is_author = false;
+ var $is_category = false;
+ var $is_search = false;
+ var $is_feed = false;
+ var $is_trackback = false;
+ var $is_home = false;
+ var $is_404 = false;
+ var $is_comments_popup = false;
+ var $is_admin = false;
+
+ function init () {
+ $this->is_single = false;
+ $this->is_page = false;
+ $this->is_archive = false;
+ $this->is_date = false;
+ $this->is_year = false;
+ $this->is_month = false;
+ $this->is_day = false;
+ $this->is_time = false;
+ $this->is_author = false;
+ $this->is_category = false;
+ $this->is_search = false;
+ $this->is_feed = false;
+ $this->is_trackback = false;
+ $this->is_home = false;
+ $this->is_404 = false;
+ $this->is_paged = false;
+ $this->is_admin = false;
+
+ unset($this->posts);
+ unset($this->query);
+ unset($this->query_vars);
+ unset($this->queried_object);
+ unset($this->queried_object_id);
+ $this->post_count = 0;
+ $this->current_post = -1;
+ }
+
+ // Reparse the query vars.
+ function parse_query_vars() {
+ $this->parse_query('');
+ }
+
+ // Parse a query string and set query type booleans.
+ function parse_query ($query) {
+ if ( !empty($query) || !isset($this->query) ) {
+ $this->init();
+ parse_str($query, $qv);
+ $this->query = $query;
+ $this->query_vars = $qv;
+ }
+
+ $qv['m'] = (int) $qv['m'];
+ $qv['p'] = (int) $qv['p'];
+
+ if ('' != $qv['name']) {
+ $this->is_single = true;
+ } elseif ( $qv['p'] ) {
+ $this->is_single = true;
+ } elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
+ // If year, month, day, hour, minute, and second are set, a single
+ // post is being queried.
+ $this->is_single = true;
+ } elseif ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) {
+ $this->is_page = true;
+ $this->is_single = false;
+ } elseif (!empty($qv['s'])) {
+ $this->is_search = true;
+ } else {
+ // Look for archive queries. Dates, categories, authors.
+
+ if ( (int) $qv['second']) {
+ $this->is_time = true;
+ $this->is_date = true;
+ }
+
+ if ( (int) $qv['minute']) {
+ $this->is_time = true;
+ $this->is_date = true;
+ }
+
+ if ( (int) $qv['hour']) {
+ $this->is_time = true;
+ $this->is_date = true;
+ }
+
+ if ( (int) $qv['day']) {
+ if (! $this->is_date) {
+ $this->is_day = true;
+ $this->is_date = true;
+ }
+ }
+
+ if ( (int) $qv['monthnum']) {
+ if (! $this->is_date) {
+ $this->is_month = true;
+ $this->is_date = true;
+ }
+ }
+
+ if ( (int) $qv['year']) {
+ if (! $this->is_date) {
+ $this->is_year = true;
+ $this->is_date = true;
+ }
+ }
+
+ if ( (int) $qv['m']) {
+ $this->is_date = true;
+ if (strlen($qv['m']) > 9) {
+ $this->is_time = true;
+ } else if (strlen($qv['m']) > 7) {
+ $this->is_day = true;
+ } else if (strlen($qv['m']) > 5) {
+ $this->is_month = true;
+ } else {
+ $this->is_year = true;
+ }
+ }
+
+ if ('' != $qv['w']) {
+ $this->is_date = true;
+ }
+
+ if (empty($qv['cat']) || ($qv['cat'] == '0')) {
+ $this->is_category = false;
+ } else {
+ if (stristr($qv['cat'],'-')) {
+ $this->is_category = false;
+ } else {
+ $this->is_category = true;
+ }
+ }
+
+ if ('' != $qv['category_name']) {
+ $this->is_category = true;
+ }
+
+ if ((empty($qv['author'])) || ($qv['author'] == '0')) {
+ $this->is_author = false;
+ } else {
+ $this->is_author = true;
+ }
+
+ if ('' != $qv['author_name']) {
+ $this->is_author = true;
+ }
+
+ if ( ($this->is_date || $this->is_author || $this->is_category)) {
+ $this->is_archive = true;
+ }
+ }
+
+ if ('' != $qv['feed']) {
+ $this->is_feed = true;
+ }
+
+ if ('' != $qv['tb']) {
+ $this->is_trackback = true;
+ }
+
+ if ('404' == $qv['error']) {
+ $this->is_404 = true;
+ }
+
+ if ('' != $qv['paged']) {
+ $this->is_paged = true;
+ }
+
+ if ('' != $qv['comments_popup']) {
+ $this->is_comments_popup = true;
+ }
+
+ if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) {
+ $this->is_admin = true;
+ }
+
+ if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) {
+ $this->is_home = true;
+ }
+
+ if ( !empty($query) ) {
+ do_action('parse_query', array(&$this));
+ }
+ }
+
+ function get($query_var) {
+ if (isset($this->query_vars[$query_var])) {
+ return $this->query_vars[$query_var];
+ }
+
+ return '';
+ }
+
+ function set($query_var, $value) {
+ $this->query_vars[$query_var] = $value;
+ }
+
+ function &get_posts() {
+ global $wpdb, $pagenow, $request, $user_ID;
+
+ // Shorthand.
+ $q = $this->query_vars;
+
+ // First let's clear some variables
+ $whichcat = '';
+ $whichauthor = '';
+ $result = '';
+ $where = '';
+ $limits = '';
+ $distinct = '';
+ $join = '';
+
+ if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 )
+ $q['posts_per_page'] = get_settings('posts_per_page');
+ if ( !isset($q['what_to_show']) )
+ $q['what_to_show'] = get_settings('what_to_show');
+ if ( isset($q['showposts']) && $q['showposts'] ) {
+ $q['showposts'] = (int) $q['showposts'];
+ $q['posts_per_page'] = $q['showposts'];
+ }
+ if ( (isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search) )
+ $q['posts_per_page'] = $q['posts_per_archive_page'];
+ if ( !isset($q['nopaging']) ) {
+ if ($q['posts_per_page'] == -1) {
+ $q['nopaging'] = true;
+ } else {
+ $q['nopaging'] = false;
+ }
+ }
+ if ( $this->is_feed ) {
+ $q['posts_per_page'] = get_settings('posts_per_rss');
+ $q['what_to_show'] = 'posts';
+ }
+
+ if (isset($q['page'])) {
+ $q['page'] = trim($q['page'], '/');
+ $q['page'] = (int) $q['page'];
+ }
+
+ $add_hours = intval(get_settings('gmt_offset'));
+ $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
+ $wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
+
+ // If a month is specified in the querystring, load that month
+ if ( (int) $q['m'] ) {
+ $q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']);
+ $where .= ' AND YEAR(post_date)=' . substr($q['m'], 0, 4);
+ if (strlen($q['m'])>5)
+ $where .= ' AND MONTH(post_date)=' . substr($q['m'], 4, 2);
+ if (strlen($q['m'])>7)
+ $where .= ' AND DAYOFMONTH(post_date)=' . substr($q['m'], 6, 2);
+ if (strlen($q['m'])>9)
+ $where .= ' AND HOUR(post_date)=' . substr($q['m'], 8, 2);
+ if (strlen($q['m'])>11)
+ $where .= ' AND MINUTE(post_date)=' . substr($q['m'], 10, 2);
+ if (strlen($q['m'])>13)
+ $where .= ' AND SECOND(post_date)=' . substr($q['m'], 12, 2);
+ }
+
+ if ( (int) $q['hour'] ) {
+ $q['hour'] = '' . intval($q['hour']);
+ $where .= " AND HOUR(post_date)='" . $q['hour'] . "'";
+ }
+
+ if ( (int) $q['minute'] ) {
+ $q['minute'] = '' . intval($q['minute']);
+ $where .= " AND MINUTE(post_date)='" . $q['minute'] . "'";
+ }
+
+ if ( (int) $q['second'] ) {
+ $q['second'] = '' . intval($q['second']);
+ $where .= " AND SECOND(post_date)='" . $q['second'] . "'";
+ }
+
+ if ( (int) $q['year'] ) {
+ $q['year'] = '' . intval($q['year']);
+ $where .= " AND YEAR(post_date)='" . $q['year'] . "'";
+ }
+
+ if ( (int) $q['monthnum'] ) {
+ $q['monthnum'] = '' . intval($q['monthnum']);
+ $where .= " AND MONTH(post_date)='" . $q['monthnum'] . "'";
+ }
+
+ if ( (int) $q['day'] ) {
+ $q['day'] = '' . intval($q['day']);
+ $where .= " AND DAYOFMONTH(post_date)='" . $q['day'] . "'";
+ }
+
+ if ('' != $q['name']) {
+ $q['name'] = sanitize_title($q['name']);
+ $where .= " AND post_name = '" . $q['name'] . "'";
+ } else if ('' != $q['pagename']) {
+ $q['pagename'] = sanitize_title(basename(str_replace('%2F', '/', urlencode($q['pagename']))));
+ $q['name'] = $q['pagename'];
+ $where .= " AND post_name = '" . $q['pagename'] . "'";
+ }
+
+
+ if ( (int) $q['w'] ) {
+ $q['w'] = ''.intval($q['w']);
+ $where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'";
+ }
+
+ if ( intval($q['comments_popup']) )
+ $q['p'] = intval($q['comments_popup']);
+
+ // If a post number is specified, load that post
+ if (($q['p'] != '') && intval($q['p']) != 0) {
+ $q['p'] = (int) $q['p'];
+ $where = ' AND ID = ' . $q['p'];
+ }
+
+ if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) {
+ $q['page_id'] = intval($q['page_id']);
+ $q['p'] = $q['page_id'];
+ $where = ' AND ID = '.$q['page_id'];
+ }
+
+ // If a search pattern is specified, load the posts that match
+ if (!empty($q['s'])) {
+ $q['s'] = addslashes_gpc($q['s']);
+ $search = ' AND (';
+ $q['s'] = preg_replace('/, +/', ' ', $q['s']);
+ $q['s'] = str_replace(',', ' ', $q['s']);
+ $q['s'] = str_replace('"', ' ', $q['s']);
+ $q['s'] = trim($q['s']);
+ if ($q['exact']) {
+ $n = '';
+ } else {
+ $n = '%';
+ }
+ if (!$q['sentence']) {
+ $s_array = explode(' ',$q['s']);
+ $q['search_terms'] = $s_array;
+ $search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))';
+ for ( $i = 1; $i < count($s_array); $i = $i + 1) {
+ $search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))';
+ }
+ $search .= ' OR (post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\')';
+ $search .= ')';
+ } else {
+ $search = ' AND ((post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\'))';
+ }
+ }
+
+ // Category stuff
+
+ if ((empty($q['cat'])) || ($q['cat'] == '0') ||
+ // Bypass cat checks if fetching specific posts
+ ( $this->is_single || $this->is_page )) {
+ $whichcat='';
+ } else {
+ $q['cat'] = ''.urldecode($q['cat']).'';
+ $q['cat'] = addslashes_gpc($q['cat']);
+ if (stristr($q['cat'],'-')) {
+ // Note: if we have a negative, we ignore all the positives. It must
+ // always mean 'everything /except/ this one'. We should be able to do
+ // multiple negatives but we don't :-(
+ $eq = '!=';
+ $andor = 'AND';
+ $q['cat'] = explode('-',$q['cat']);
+ $q['cat'] = intval($q['cat'][1]);
+ } else {
+ $eq = '=';
+ $andor = 'OR';
+ }
+ $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
+ $cat_array = preg_split('/[,\s]+/', $q['cat']);
+ $whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]);
+ $whichcat .= get_category_children($cat_array[0], ' '.$andor.' category_id '.$eq.' ');
+ for ($i = 1; $i < (count($cat_array)); $i = $i + 1) {
+ $whichcat .= ' '.$andor.' category_id '.$eq.' '.intval($cat_array[$i]);
+ $whichcat .= get_category_children($cat_array[$i], ' '.$andor.' category_id '.$eq.' ');
+ }
+ $whichcat .= ')';
+ if ($eq == '!=') {
+ $q['cat'] = '-'.$q['cat']; // Put back the knowledge that we are excluding a category.
+ }
+ }
+
+ // Category stuff for nice URIs
+
+ if ('' != $q['category_name']) {
+ if (stristr($q['category_name'],'/')) {
+ $q['category_name'] = explode('/',$q['category_name']);
+ if ($q['category_name'][count($q['category_name'])-1]) {
+ $q['category_name'] = $q['category_name'][count($q['category_name'])-1]; // no trailing slash
+ } else {
+ $q['category_name'] = $q['category_name'][count($q['category_name'])-2]; // there was a trailling slash
+ }
+ }
+ $q['category_name'] = sanitize_title($q['category_name']);
+ $tables = ", $wpdb->post2cat, $wpdb->categories";
+ $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
+ $whichcat = " AND (category_nicename = '" . $q['category_name'] . "'";
+ $q['cat'] = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '" . $q['category_name'] . "'");
+ $whichcat .= get_category_children($q['cat'], " OR category_id = ");
+ $whichcat .= ")";
+ }
+
+ // Author/user stuff
+
+ if ((empty($q['author'])) || ($q['author'] == '0')) {
+ $whichauthor='';
+ } else {
+ $q['author'] = ''.urldecode($q['author']).'';
+ $q['author'] = addslashes_gpc($q['author']);
+ if (stristr($q['author'], '-')) {
+ $eq = '!=';
+ $andor = 'AND';
+ $q['author'] = explode('-', $q['author']);
+ $q['author'] = ''.intval($q['author'][1]);
+ } else {
+ $eq = '=';
+ $andor = 'OR';
+ }
+ $author_array = preg_split('/[,\s]+/', $q['author']);
+ $whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);
+ for ($i = 1; $i < (count($author_array)); $i = $i + 1) {
+ $whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]);
+ }
+ $whichauthor .= ')';
+ }
+
+ // Author stuff for nice URIs
+
+ if ('' != $q['author_name']) {
+ if (stristr($q['author_name'],'/')) {
+ $q['author_name'] = explode('/',$q['author_name']);
+ if ($q['author_name'][count($q['author_name'])-1]) {
+ $q['author_name'] = $q['author_name'][count($q['author_name'])-1];#no trailing slash
+ } else {
+ $q['author_name'] = $q['author_name'][count($q['author_name'])-2];#there was a trailling slash
+ }
+ }
+ $q['author_name'] = sanitize_title($q['author_name']);
+ $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'");
+ $whichauthor .= ' AND (post_author = '.intval($q['author']).')';
+ }
+
+ $where .= $search.$whichcat.$whichauthor;
+
+ if ((empty($q['order'])) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC'))) {
+ $q['order']='DESC';
+ }
+
+ // Order by
+ if (empty($q['orderby'])) {
+ $q['orderby']='date '.$q['order'];
+ } else {
+ // Used to filter values
+ $allowed_keys = array('author','date','category','title');
+ $q['orderby'] = urldecode($q['orderby']);
+ $q['orderby'] = addslashes_gpc($q['orderby']);
+ $orderby_array = explode(' ',$q['orderby']);
+ if (!in_array($orderby_array[0],$allowed_keys)) {
+ $orderby_array[0] = 'date';
+ }
+ $q['orderby'] = $orderby_array[0].' '.$q['order'];
+ if (count($orderby_array)>1) {
+ for ($i = 1; $i < (count($orderby_array)); $i = $i + 1) {
+ // Only allow certain values for safety
+ if (in_array($orderby_array[$i],$allowed_keys)) {
+ $q['orderby'] .= ',post_'.$orderby_array[$i].' '.$q['order'];
+ }
+ }
+ }
+ }
+
+ $now = gmdate('Y-m-d H:i:59');
+
+ if ($pagenow != 'post.php' && $pagenow != 'edit.php') {
+ $where .= " AND post_date_gmt <= '$now'";
+ $distinct = 'DISTINCT';
+ }
+
+ if ($this->is_page) {
+ $where .= ' AND (post_status = "static")';
+ } elseif ($this->is_single) {
+ $where .= ' AND (post_status != "static")';
+ } else {
+ $where .= ' AND (post_status = "publish"';
+
+ if (isset($user_ID) && ('' != intval($user_ID)))
+ $where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')";
+ else
+ $where .= ')';
+ }
+
+ // Apply filters on where and join prior to paging so that any
+ // manipulations to them are reflected in the paging by day queries.
+ $where = apply_filters('posts_where', $where);
+ $join = apply_filters('posts_join', $join);
+
+ // Paging
+ if (empty($q['nopaging']) && ! $this->is_single) {
+ $page = $q['paged'];
+ if (empty($page)) {
+ $page = 1;
+ }
+
+ if (($q['what_to_show'] == 'posts')) {
+ $pgstrt = '';
+ $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
+ $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
+ } elseif ($q['what_to_show'] == 'days') {
+ $startrow = $q['posts_per_page'] * (intval($page)-1);
+ $start_date = $wpdb->get_var("SELECT max(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $startrow,1");
+ $endrow = $startrow + $q['posts_per_page'] - 1;
+ $end_date = $wpdb->get_var("SELECT min(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $endrow,1");
+
+ if ($page > 1) {
+ $where .= " AND post_date >= '$end_date' AND post_date <= '$start_date'";
+ } else {
+ $where .= " AND post_date >= '$end_date'";
+ }
+ }
+ }
+
+ // Apply post-paging filters on where and join. Only plugins that
+ // manipulate paging queries should use these hooks.
+ $where = apply_filters('posts_where_paged', $where);
+ $where .= " GROUP BY $wpdb->posts.ID";
+ $join = apply_filters('posts_join_paged', $join);
+ $orderby = "post_" . $q['orderby'];
+ $orderby = apply_filters('posts_orderby', $orderby);
+ $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1".$where." ORDER BY " . $orderby . " $limits";
+
+ $this->posts = $wpdb->get_results($request);
+
+ // Check post status to determine if post should be displayed.
+ if ($this->is_single) {
+ if ('publish' != $this->posts[0]->post_status) {
+ if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) {
+ // User must be logged in to view unpublished posts.
+ $this->posts = array();
+ } else {
+ if ('draft' == $this->posts[0]->post_status) {
+ // User must have edit permissions on the draft to preview.
+ if (! user_can_edit_post($user_ID, $this->posts[0]->ID))
+ $this->posts = array();
+ } elseif ('private' == $this->posts[0]->post_status) {
+ if ($this->posts[0]->post_author != $user_ID)
+ $this->posts = array();
+ }
+ }
+ }
+ }
+
+ $this->posts = apply_filters('the_posts', $this->posts);
+ $this->post_count = count($this->posts);
+ if ($this->post_count > 0) {
+ $this->post = $this->posts[0];
+ }
+
+ update_post_caches($this->posts);
+
+ // Save any changes made to the query vars.
+ $this->query_vars = $q;
+ return $this->posts;
+ }
+
+ function next_post() {
+
+ $this->current_post++;
+
+ $this->post = $this->posts[$this->current_post];
+ return $this->post;
+ }
+
+ function the_post() {
+ global $post;
+ $post = $this->next_post();
+ setup_postdata($post);
+ }
+
+ function have_posts() {
+ if ($this->current_post + 1 < $this->post_count) {
+ return true;
+ }
+
+ return false;
+ }
+
+ function rewind_posts() {
+ $this->current_post = -1;
+ if ($this->post_count > 0) {
+ $this->post = $this->posts[0];
+ }
+ }
+
+ function &query($query) {
+ $this->parse_query($query);
+ return $this->get_posts();
+ }
+
+ function get_queried_object() {
+ if (isset($this->queried_object)) {
+ return $this->queried_object;
+ }
+
+ $this->queried_object = NULL;
+ $this->queried_object_id = 0;
+
+ if ($this->is_category) {
+ $cat = $this->get('cat');
+ $category = &get_category($cat);
+ $this->queried_object = &$category;
+ $this->queried_object_id = $cat;
+ } else if ($this->is_single) {
+ $this->queried_object = $this->post;
+ $this->queried_object_id = $this->post->ID;
+ } else if ($this->is_page) {
+ $this->queried_object = $this->post;
+ $this->queried_object_id = $this->post->ID;
+ } else if ($this->is_author) {
+ global $cache_userdata;
+ if (isset($cache_userdata[$this->get('author')])) {
+ $this->queried_object = $cache_userdata[$this->get('author')];
+ $this->queried_object_id = $this->get('author');
+ }
+ }
+
+ return $this->queried_object;
+ }
+
+ function get_queried_object_id() {
+ $this->get_queried_object();
+
+ if (isset($this->queried_object_id)) {
+ return $this->queried_object_id;
+ }
+
+ return 0;
+ }
+
+ function WP_Query ($query = '') {
+ if (! empty($query)) {
+ $this->query($query);
+ }
+ }
+}
+
+class retrospam_mgr {
+ var $spam_words;
+ var $comments_list;
+ var $found_comments;
+
+ function retrospam_mgr() {
+ global $wpdb;
+
+ $list = explode("\n", get_settings('moderation_keys') );
+ $list = array_unique( $list );
+ $this->spam_words = $list;
+
+ $this->comment_list = $wpdb->get_results("SELECT comment_ID AS ID, comment_content AS text, comment_approved AS approved, comment_author_url AS url, comment_author_ip AS ip, comment_author_email AS email FROM $wpdb->comments ORDER BY comment_ID ASC");
+ } // End of class constructor
+
+ function move_spam( $id_list ) {
+ global $wpdb;
+ $cnt = 0;
+ $id_list = explode( ',', $id_list );
+
+ foreach ( $id_list as $comment ) {
+ if ( $wpdb->query("update $wpdb->comments set comment_approved = '0' where comment_ID = '$comment'") ) {
+ $cnt++;
+ }
+ }
+ echo "<div class='updated'><p>$cnt comment";
+ if ($cnt != 1 ) echo "s";
+ echo " moved to the moderation queue.</p></div>\n";
+ } // End function move_spam
+
+ function find_spam() {
+ $in_queue = 0;
+
+ foreach( $this->comment_list as $comment ) {
+ if( $comment->approved == 1 ) {
+ foreach( $this->spam_words as $word ) {
+ if ( empty( $word ) )
+ continue;
+ $fulltext = strtolower($comment->email.' '.$comment->url.' '.$comment->ip.' '.$comment->text);
+ if( strpos( $fulltext, strtolower(trim($word)) ) != FALSE ) {
+ $this->found_comments[] = $comment->ID;
+ break;
+ }
+ }
+ } else {
+ $in_queue++;
+ }
+ }
+ return array( 'found' => $this->found_comments, 'in_queue' => $in_queue );
+ } // End function find_spam
+
+ function display_edit_form( $counters ) {
+ $numfound = count($counters[found]);
+ $numqueue = $counters[in_queue];
+
+ $body = '<p>' . sprintf(__('Suspected spam comments: <strong>%s</strong>'), $numfound) . '</p>';
+
+ if ( count($counters[found]) > 0 ) {
+ $id_list = implode( ',', $counters[found] );
+ $body .= '<p><a href="options-discussion.php?action=retrospam&amp;move=true&amp;ids='.$id_list.'">'. __('Move suspect comments to moderation queue &raquo;') . '</a></p>';
+
+ }
+ $head = '<div class="wrap"><h2>' . __('Check Comments Results:') . '</h2>';
+
+ $foot .= '<p><a href="options-discussion.php">' . __('&laquo; Return to Discussion Options page.') . '</a></p></div>';
+
+ return $head . $body . $foot;
+ } // End function display_edit_form
+
+}
+
+class WP_Rewrite {
+ var $permalink_structure;
+ var $category_base;
+ var $category_structure;
+ var $author_base = 'author';
+ var $author_structure;
+ var $date_structure;
+ var $page_structure;
+ var $search_base = 'search';
+ var $search_structure;
+ var $comments_base = 'comments';
+ var $feed_base = 'feed';
+ var $comments_feed_structure;
+ var $feed_structure;
+ var $front;
+ var $root = '';
+ var $index = 'index.php';
+ var $matches = '';
+ var $rules;
+ var $use_verbose_rules = false;
+ var $rewritecode =
+ array(
+ '%year%',
+ '%monthnum%',
+ '%day%',
+ '%hour%',
+ '%minute%',
+ '%second%',
+ '%postname%',
+ '%post_id%',
+ '%category%',
+ '%author%',
+ '%pagename%',
+ '%search%'
+ );
+
+ var $rewritereplace =
+ array(
+ '([0-9]{4})',
+ '([0-9]{1,2})',
+ '([0-9]{1,2})',
+ '([0-9]{1,2})',
+ '([0-9]{1,2})',
+ '([0-9]{1,2})',
+ '([^/]+)',
+ '([0-9]+)',
+ '(.+?)',
+ '([^/]+)',
+ '([^/]+)',
+ '(.+)'
+ );
+
+ var $queryreplace =
+ array (
+ 'year=',
+ 'monthnum=',
+ 'day=',
+ 'hour=',
+ 'minute=',
+ 'second=',
+ 'name=',
+ 'p=',
+ 'category_name=',
+ 'author_name=',
+ 'pagename=',
+ 's='
+ );
+
+ var $feeds = array ('feed', 'rdf', 'rss', 'rss2', 'atom');
+
+ function using_permalinks() {
+ if (empty($this->permalink_structure))
+ return false;
+ else
+ return true;
+ }
+
+ function using_index_permalinks() {
+ if (empty($this->permalink_structure)) {
+ return false;
+ }
+
+ // If the index is not in the permalink, we're using mod_rewrite.
+ if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ function using_mod_rewrite_permalinks() {
+ if ( $this->using_permalinks() && ! $this->using_index_permalinks())
+ return true;
+ else
+ return false;
+ }
+
+ function preg_index($number) {
+ $match_prefix = '$';
+ $match_suffix = '';
+
+ if (! empty($this->matches)) {
+ $match_prefix = '$' . $this->matches . '[';
+ $match_suffix = ']';
+ }
+
+ return "$match_prefix$number$match_suffix";
+ }
+
+ function page_rewrite_rules() {
+ $uris = get_settings('page_uris');
+
+ $rewrite_rules = array();
+ $page_structure = $this->get_page_permastruct();
+ if( is_array( $uris ) )
+ {
+ foreach ($uris as $uri => $pagename) {
+ $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
+ $rewrite_rules += $this->generate_rewrite_rules($page_structure);
+ }
+ }
+
+ return $rewrite_rules;
+ }
+
+ function get_date_permastruct() {
+ if (isset($this->date_structure)) {
+ return $this->date_structure;
+ }
+
+ if (empty($this->permalink_structure)) {
+ $this->date_structure = '';
+ return false;
+ }
+
+ // The date permalink must have year, month, and day separated by slashes.
+ $endians = array('%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%');
+
+ $this->date_structure = '';
+ $date_endian = '';
+
+ foreach ($endians as $endian) {
+ if (false !== strpos($this->permalink_structure, $endian)) {
+ $date_endian= $endian;
+ break;
+ }
+ }
+
+ if ( empty($date_endian) )
+ $date_endian = '%year%/%monthnum%/%day%';
+
+ // Do not allow the date tags and %post_id% to overlap in the permalink
+ // structure. If they do, move the date tags to $front/date/.
+ $front = $this->front;
+ preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
+ $tok_index = 1;
+ foreach ($tokens[0] as $token) {
+ if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
+ $front = $front . 'date/';
+ break;
+ }
+ }
+
+ $this->date_structure = $front . $date_endian;
+
+ return $this->date_structure;
+ }
+
+ function get_year_permastruct() {
+ $structure = $this->get_date_permastruct($permalink_structure);
+
+ if (empty($structure)) {
+ return false;
+ }
+
+ $structure = str_replace('%monthnum%', '', $structure);
+ $structure = str_replace('%day%', '', $structure);
+
+ $structure = preg_replace('#/+#', '/', $structure);
+
+ return $structure;
+ }
+
+ function get_month_permastruct() {
+ $structure = $this->get_date_permastruct($permalink_structure);
+
+ if (empty($structure)) {
+ return false;
+ }
+
+ $structure = str_replace('%day%', '', $structure);
+
+ $structure = preg_replace('#/+#', '/', $structure);
+
+ return $structure;
+ }
+
+ function get_day_permastruct() {
+ return $this->get_date_permastruct($permalink_structure);
+ }
+
+ function get_category_permastruct() {
+ if (isset($this->category_structure)) {
+ return $this->category_structure;
+ }
+
+ if (empty($this->permalink_structure)) {
+ $this->category_structure = '';
+ return false;
+ }
+
+ if (empty($this->category_base))
+ $this->category_structure = $this->front . 'category/';
+ else
+ $this->category_structure = $this->category_base . '/';
+
+ $this->category_structure .= '%category%';
+
+ return $this->category_structure;
+ }
+
+ function get_author_permastruct() {
+ if (isset($this->author_structure)) {
+ return $this->author_structure;
+ }
+
+ if (empty($this->permalink_structure)) {
+ $this->author_structure = '';
+ return false;
+ }
+
+ $this->author_structure = $this->front . $this->author_base . '/%author%';
+
+ return $this->author_structure;
+ }
+
+ function get_search_permastruct() {
+ if (isset($this->search_structure)) {
+ return $this->search_structure;
+ }
+
+ if (empty($this->permalink_structure)) {
+ $this->search_structure = '';
+ return false;
+ }
+
+ $this->search_structure = $this->root . $this->search_base . '/%search%';
+
+ return $this->search_structure;
+ }
+
+ function get_page_permastruct() {
+ if (isset($this->page_structure)) {
+ return $this->page_structure;
+ }
+
+ if (empty($this->permalink_structure)) {
+ $this->page_structure = '';
+ return false;
+ }
+
+ $this->page_structure = $this->root . '%pagename%';
+
+ return $this->page_structure;
+ }
+
+ function get_feed_permastruct() {
+ if (isset($this->feed_structure)) {
+ return $this->feed_structure;
+ }
+
+ if (empty($this->permalink_structure)) {
+ $this->feed_structure = '';
+ return false;
+ }
+
+ $this->feed_structure = $this->root . $this->feed_base . '/%feed%';
+
+ return $this->feed_structure;
+ }
+
+ function get_comment_feed_permastruct() {
+ if (isset($this->comment_feed_structure)) {
+ return $this->comment_feed_structure;
+ }
+
+ if (empty($this->permalink_structure)) {
+ $this->comment_feed_structure = '';
+ return false;
+ }
+
+ $this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%';
+
+ return $this->comment_feed_structure;
+ }
+
+ function add_rewrite_tag($tag, $pattern, $query) {
+ // If the tag already exists, replace the existing pattern and query for
+ // that tag, otherwise add the new tag, pattern, and query to the end of
+ // the arrays.
+ $position = array_search($tag, $this->rewritecode);
+ if (FALSE !== $position && NULL !== $position) {
+ $this->rewritereplace[$position] = $pattern;
+ $this->queryreplace[$position] = $query;
+ } else {
+ $this->rewritecode[] = $tag;
+ $this->rewritereplace[] = $pattern;
+ $this->queryreplace[] = $query;
+ }
+ }
+
+ function generate_rewrite_rules($permalink_structure, $page = true, $feed = true, $forcomments = false, $walk_dirs = true) {
+ $feedregex2 = '';
+ foreach ($this->feeds as $feed_name) {
+ $feedregex2 .= $feed_name . '|';
+ }
+ $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$';
+ $feedregex = $this->feed_base . '/' . $feedregex2;
+
+ $trackbackregex = 'trackback/?$';
+ $pageregex = 'page/?([0-9]{1,})/?$';
+
+ $front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
+ preg_match_all('/%.+?%/', $permalink_structure, $tokens);
+
+ $num_tokens = count($tokens[0]);
+
+ $index = $this->index;
+ $feedindex = $index;
+ $trackbackindex = $index;
+ for ($i = 0; $i < $num_tokens; ++$i) {
+ if (0 < $i) {
+ $queries[$i] = $queries[$i - 1] . '&';
+ }
+
+ $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1);
+ $queries[$i] .= $query_token;
+ }
+
+ $structure = $permalink_structure;
+ if ($front != '/') {
+ $structure = str_replace($front, '', $structure);
+ }
+ $structure = trim($structure, '/');
+ if ($walk_dirs) {
+ $dirs = explode('/', $structure);
+ } else {
+ $dirs[] = $structure;
+ }
+ $num_dirs = count($dirs);
+
+ $front = preg_replace('|^/+|', '', $front);
+
+ $post_rewrite = array();
+ $struct = $front;
+ for ($j = 0; $j < $num_dirs; ++$j) {
+ $struct .= $dirs[$j] . '/';
+ $struct = ltrim($struct, '/');
+ $match = str_replace($this->rewritecode, $this->rewritereplace, $struct);
+ $num_toks = preg_match_all('/%.+?%/', $struct, $toks);
+ $query = $queries[$num_toks - 1];
+
+ $pagematch = $match . $pageregex;
+ $pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1);
+
+ $feedmatch = $match . $feedregex;
+ $feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
+
+ $feedmatch2 = $match . $feedregex2;
+ $feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
+
+ if ($forcomments) {
+ $feedquery .= '&withcomments=1';
+ $feedquery2 .= '&withcomments=1';
+ }
+
+ $rewrite = array();
+ if ($feed)
+ $rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
+ if ($page)
+ $rewrite = $rewrite + array($pagematch => $pagequery);
+
+ if ($num_toks) {
+ $post = 0;
+ if (strstr($struct, '%postname%') || strstr($struct, '%post_id%')
+ || strstr($struct, '%pagename%')
+ || (strstr($struct, '%year%') && strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) {
+ $post = 1;
+ $trackbackmatch = $match . $trackbackregex;
+ $trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
+ $match = rtrim($match, '/');
+ $match = $match . '(/[0-9]+)?/?$';
+ $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
+ } else {
+ $match .= '?$';
+ $query = $index . '?' . $query;
+ }
+
+ $rewrite = $rewrite + array($match => $query);
+
+ if ($post) {
+ $rewrite = array($trackbackmatch => $trackbackquery) + $rewrite;
+ }
+ }
+
+ $post_rewrite = $rewrite + $post_rewrite;
+ }
+
+ return $post_rewrite;
+ }
+
+ function generate_rewrite_rule($permalink_structure, $walk_dirs = false) {
+ return $this->generate_rewrite_rules($permalink_structure, false, false, false, $walk_dirs);
+ }
+
+ /* rewrite_rules
+ * Construct rewrite matches and queries from permalink structure.
+ * Returns an associate array of matches and queries.
+ */
+ function rewrite_rules() {
+ $rewrite = array();
+
+ if (empty($this->permalink_structure)) {
+ return $rewrite;
+ }
+
+ // Post
+ $post_rewrite = $this->generate_rewrite_rules($this->permalink_structure);
+ $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
+
+ // Date
+ $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct());
+ $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
+
+ // Root
+ $root_rewrite = $this->generate_rewrite_rules($this->root . '/');
+ $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
+
+ // Comments
+ $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, true, true, true);
+ $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
+
+ // Search
+ $search_structure = $this->get_search_permastruct();
+ $search_rewrite = $this->generate_rewrite_rules($search_structure);
+ $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
+
+ // Categories
+ $category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct());
+ $category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite);
+
+ // Authors
+ $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct());
+ $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
+
+ // Pages
+ $page_rewrite = $this->page_rewrite_rules();
+ $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
+
+ // Put them together.
+ $this->rules = $page_rewrite + $root_rewrite + $comments_rewrite + $search_rewrite + $category_rewrite + $author_rewrite + $date_rewrite + $post_rewrite;
+
+ do_action('generate_rewrite_rules', array(&$this));
+ $this->rules = apply_filters('rewrite_rules_array', $this->rules);
+ return $this->rules;
+ }
+
+ function wp_rewrite_rules() {
+ $this->matches = 'matches';
+ return $this->rewrite_rules();
+ }
+
+ function mod_rewrite_rules() {
+ if ( ! $this->using_permalinks()) {
+ return '';
+ }
+
+ $site_root = parse_url(get_settings('siteurl'));
+ $site_root = trailingslashit($site_root['path']);
+
+ $home_root = parse_url(get_settings('home'));
+ $home_root = trailingslashit($home_root['path']);
+
+ $rules = "<IfModule mod_rewrite.c>\n";
+ $rules .= "RewriteEngine On\n";
+ $rules .= "RewriteBase $home_root\n";
+
+ if ($this->use_verbose_rules) {
+ $this->matches = '';
+ $rewrite = $this->rewrite_rules();
+ $num_rules = count($rewrite);
+ $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
+ "RewriteCond %{REQUEST_FILENAME} -d\n" .
+ "RewriteRule ^.*$ - [S=$num_rules]\n";
+
+ foreach ($rewrite as $match => $query) {
+ // Apache 1.3 does not support the reluctant (non-greedy) modifier.
+ $match = str_replace('.+?', '.+', $match);
+
+ // If the match is unanchored and greedy, prepend rewrite conditions
+ // to avoid infinite redirects and eclipsing of real files.
+ if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
+ //nada.
+ }
+
+ if (strstr($query, $this->index)) {
+ $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
+ } else {
+ $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
+ }
+ }
+ } else {
+ $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
+ "RewriteCond %{REQUEST_FILENAME} !-d\n" .
+ "RewriteRule . {$home_root}{$this->index}\n";
+ }
+
+ $rules .= "</IfModule>\n";
+
+ $rules = apply_filters('mod_rewrite_rules', $rules);
+ $rules = apply_filters('rewrite_rules', $rules); // Deprecated
+
+ return $rules;
+ }
+
+ function init() {
+ $this->permalink_structure = get_settings('permalink_structure');
+ $this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));
+ $this->root = '';
+ if ($this->using_index_permalinks()) {
+ $this->root = $this->index . '/';
+ }
+ $this->category_base = get_settings('category_base');
+ unset($this->category_structure);
+ unset($this->author_structure);
+ unset($this->date_structure);
+ unset($this->page_structure);
+ unset($this->search_structure);
+ unset($this->feed_structure);
+ unset($this->comment_feed_structure);
+ }
+
+ function set_permalink_structure($permalink_structure) {
+ if ($permalink_structure != $this->permalink_structure) {
+ update_option('permalink_structure', $permalink_structure);
+ $this->init();
+ }
+ }
+
+ function set_category_base($category_base) {
+ if ($category_base != $this->category_base) {
+ update_option('category_base', $category_base);
+ $this->init();
+ }
+ }
+
+ function WP_Rewrite() {
+ $this->init();
+ }
+}
+
+class WP {
+ var $public_query_vars = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence', 'debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup');
+
+ var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging');
+
+ var $query_vars;
+ var $query_string;
+ var $did_permalink = false;
+
+ function parse_request($extra_query_vars = '') {
+ global $wp_rewrite;
+
+ $this->query_vars = array();
+
+ if (! empty($extra_query_vars))
+ parse_str($extra_query_vars, $extra_query_vars);
+
+ // Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
+ if ((isset($_GET['error']) && $_GET['error'] == '404') ||
+ ((! empty($_SERVER['PATH_INFO'])) &&
+ ('/' != $_SERVER['PATH_INFO']) &&
+ (false === strpos($_SERVER['PATH_INFO'], '.php'))
+ ) ||
+ (empty($_SERVER['QUERY_STRING']) &&
+ (false === strpos($_SERVER['REQUEST_URI'], '.php')) &&
+ ('/' != $_SERVER['REQUEST_URI']))
+ ) {
+
+ $this->did_permalink = true;
+
+ // If we match a rewrite rule, this will be cleared.
+ $error = '404';
+
+ // Fetch the rewrite rules.
+ $rewrite = $wp_rewrite->wp_rewrite_rules();
+
+ if (! empty($rewrite)) {
+ $pathinfo = $_SERVER['PATH_INFO'];
+ $req_uri = $_SERVER['REQUEST_URI'];
+ $home_path = parse_url(get_settings('home'));
+ $home_path = $home_path['path'];
+
+ // Trim path info from the end and the leading home path from the
+ // front. For path info requests, this leaves us with the requesting
+ // filename, if any. For 404 requests, this leaves us with the
+ // requested permalink.
+ $req_uri = str_replace($pathinfo, '', $req_uri);
+ $req_uri = str_replace($home_path, '', $req_uri);
+ $req_uri = trim($req_uri, '/');
+ $pathinfo = trim($pathinfo, '/');
+
+ // The requested permalink is in $pathinfo for path info requests and
+ // $req_uri for other requests.
+ if (! empty($pathinfo)) {
+ $request = $pathinfo;
+ } else {
+ $request = $req_uri;
+ }
+
+ // Look for matches.
+ $request_match = $request;
+ foreach ($rewrite as $match => $query) {
+ // If the requesting file is the anchor of the match, prepend it
+ // to the path info.
+ if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0)) {
+ $request_match = $req_uri . '/' . $request;
+ }
+
+ if (preg_match("!^$match!", $request_match, $matches)) {
+ // Got a match.
+ // Trim the query of everything up to the '?'.
+ $query = preg_replace("!^.+\?!", '', $query);
+
+ // Substitute the substring matches into the query.
+ eval("\$query = \"$query\";");
+
+ // Parse the query.
+ parse_str($query, $query_vars);
+
+ // If we're processing a 404 request, clear the error var
+ // since we found something.
+ if (isset($_GET['error'])) {
+ unset($_GET['error']);
+ }
+
+ if (isset($error)) {
+ unset($error);
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ $this->public_query_vars = apply_filters('query_vars', $this->public_query_vars);
+
+ for ($i=0; $i<count($this->public_query_vars); $i += 1) {
+ $wpvar = $this->public_query_vars[$i];
+ if (isset($extra_query_vars[$wpvar]))
+ $this->query_vars[$wpvar] = $extra_query_vars[$wpvar];
+ elseif (isset($GLOBALS[$wpvar]))
+ $this->query_vars[$wpvar] = $GLOBALS[$wpvar];
+ elseif (!empty($_POST[$wpvar]))
+ $this->query_vars[$wpvar] = $_POST[$wpvar];
+ elseif (!empty($_GET[$wpvar]))
+ $this->query_vars[$wpvar] = $_GET[$wpvar];
+ elseif (!empty($query_vars[$wpvar]))
+ $this->query_vars[$wpvar] = $query_vars[$wpvar];
+ else
+ $this->query_vars[$wpvar] = '';
+ }
+ }
+
+ function send_headers() {
+ @header('X-Pingback: '. get_bloginfo('pingback_url'));
+ if ( !empty($this->query_vars['error']) && '404' == $this->query_vars['error'] ) {
+ status_header( 404 );
+ } else if ( empty($this->query_vars['feed']) ) {
+ @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
+ } else {
+ // We're showing a feed, so WP is indeed the only thing that last changed
+ if ( $this->query_vars['withcomments'] )
+ $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
+ else
+ $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
+ $wp_etag = '"' . md5($wp_last_modified) . '"';
+ @header("Last-Modified: $wp_last_modified");
+ @header("ETag: $wp_etag");
+
+ // Support for Conditional GET
+ if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
+ else $client_etag = false;
+
+ $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']);
+ // If string is empty, return 0. If not, attempt to parse into a timestamp
+ $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
+
+ // Make a timestamp for our most recent modification...
+ $wp_modified_timestamp = strtotime($wp_last_modified);
+
+ if ( ($client_last_modified && $client_etag) ?
+ (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) :
+ (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) {
+ status_header( 304 );
+ exit;
+ }
+ }
+ }
+
+ function build_query_string() {
+ $this->query_string = '';
+
+ foreach ($this->public_query_vars as $wpvar) {
+ if (isset($this->query_vars[$wpvar]) && '' != $this->query_vars[$wpvar]) {
+ $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
+ $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]);
+ }
+ }
+
+ foreach ($this->private_query_vars as $wpvar) {
+ if (isset($GLOBALS[$wpvar]) && '' != $GLOBALS[$wpvar]) {
+ $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
+ $this->query_string .= $wpvar . '=' . rawurlencode($GLOBALS[$wpvar]);
+ }
+ }
+
+ $this->query_string = apply_filters('query_string', $this->query_string);
+ }
+
+ function register_globals() {
+ global $wp_query;
+ // Extract updated query vars back into global namespace.
+ foreach ($wp_query->query_vars as $key => $value) {
+ $GLOBALS[$key] = $value;
+ }
+
+ $GLOBALS['query_string'] = & $this->query_string;
+ $GLOBALS['posts'] = & $wp_query->posts;
+ $GLOBALS['post'] = & $wp_query->post;
+
+ if ( is_single() || is_page() ) {
+ $GLOBALS['more'] = 1;
+ $GLOBALS['single'] = 1;
+ }
+ }
+
+ function prime_caches() {
+ update_category_cache();
+ get_currentuserinfo();
+ }
+
+ function query_posts() {
+ $this->build_query_string();
+ query_posts($this->query_string);
+ }
+
+ function handle_404() {
+ global $wp_query;
+ // Issue a 404 if a permalink request doesn't match any posts. Don't
+ // issue a 404 if one was already issued, if the request was a search,
+ // or if the request was a regular query string request rather than a
+ // permalink request.
+ if ( (0 == count($wp_query->posts)) && !is_404() && !is_search()
+ && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) &&
+ (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
+ $wp_query->is_404 = true;
+ status_header( 404 );
+ } else {
+ status_header( 200 );
+ }
+ }
+
+ function main($query_args = '') {
+ $this->parse_request($query_args);
+ $this->send_headers();
+ $this->prime_caches();
+ $this->query_posts();
+ $this->handle_404();
+ $this->register_globals();
+ }
+
+ function WP() {
+ // Empty.
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/comment-functions.php b/wp-inst/wp-includes/comment-functions.php
new file mode 100644
index 0000000..e1b426e
--- /dev/null
+++ b/wp-inst/wp-includes/comment-functions.php
@@ -0,0 +1,678 @@
+<?php
+
+// Template functions
+
+function comments_template( $file = '/comments.php' ) {
+ global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
+
+ if ( is_single() || is_page() || $withcomments ) :
+ $req = get_settings('require_name_email');
+ $comment_author = isset($_COOKIE['comment_author_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_'.COOKIEHASH])) : '';
+ $comment_author_email = isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_email_'.COOKIEHASH])) : '';
+ $comment_author_url = isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_url_'.COOKIEHASH])) : '';
+ if ( empty($comment_author) ) {
+ $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date");
+ } else {
+ $author_db = $wpdb->escape($comment_author);
+ $email_db = $wpdb->escape($comment_author_email);
+ $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date");
+ }
+
+ get_currentuserinfo();
+
+ define('COMMENTS_TEMPLATE', true);
+ $include = apply_filters('comments_template', TEMPLATEPATH . $file );
+ if ( file_exists( $include ) )
+ require( $include );
+ else
+ require( ABSPATH . 'wp-content/themes/default/comments.php');
+
+ endif;
+}
+
+function clean_url( $url ) {
+ if ('' == $url) return $url;
+ $url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $url);
+ $url = str_replace(';//', '://', $url);
+ $url = (!strstr($url, '://')) ? 'http://'.$url : $url;
+ $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
+ return $url;
+}
+
+function get_comments_number( $comment_id ) {
+ global $wpdb, $comment_count_cache;
+ $comment_id = (int) $comment_id;
+ if (!isset($comment_count_cache[$comment_id]))
+ $comment_count_cache[$comment_id] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_id' AND comment_approved = '1'");
+
+ return apply_filters('get_comments_number', $comment_count_cache[$comment_id]);
+}
+
+function comments_number( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $number = '' ) {
+ global $id, $comment;
+ $number = get_comments_number( $id );
+ if ($number == 0) {
+ $blah = $zero;
+ } elseif ($number == 1) {
+ $blah = $one;
+ } elseif ($number > 1) {
+ $blah = str_replace('%', $number, $more);
+ }
+ echo apply_filters('comments_number', $blah);
+}
+
+function get_comments_link() {
+ return get_permalink() . '#comments';
+}
+
+function get_comment_link() {
+ global $comment;
+ return get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID;
+}
+
+function comments_link( $file = '', $echo = true ) {
+ echo get_comments_link();
+}
+
+function comments_popup_script($width=400, $height=400, $file='') {
+ global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;
+
+ if (empty ($file)) {
+ $wpcommentspopupfile = ''; // Use the index.
+ } else {
+ $wpcommentspopupfile = $file;
+ }
+
+ $wpcommentsjavascript = 1;
+ $javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n";
+ echo $javascript;
+}
+
+function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
+ global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb;
+ global $comment_count_cache;
+
+ if (! is_single() && ! is_page()) {
+ if ( !isset($comment_count_cache[$id]) )
+ $comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");
+
+ $number = $comment_count_cache[$id];
+
+ if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) {
+ echo $none;
+ return;
+ } else {
+ if (!empty($post->post_password)) { // if there's a password
+ if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
+ echo('Enter your password to view comments');
+ return;
+ }
+ }
+ echo '<a href="';
+ if ($wpcommentsjavascript) {
+ if ( empty($wpcommentspopupfile) )
+ $home = get_settings('home');
+ else
+ $home = get_settings('siteurl');
+ echo $home . '/' . $wpcommentspopupfile.'?comments_popup='.$id;
+ echo '" onclick="wpopen(this.href); return false"';
+ } else { // if comments_popup_script() is not in the template, display simple comment link
+ if ( 0 == $number )
+ echo get_permalink() . '#respond';
+ else
+ comments_link();
+ echo '"';
+ }
+ if (!empty($CSSclass)) {
+ echo ' class="'.$CSSclass.'"';
+ }
+ echo '>';
+ comments_number($zero, $one, $more, $number);
+ echo '</a>';
+ }
+ }
+}
+
+function get_comment_ID() {
+ global $comment;
+ return apply_filters('get_comment_ID', $comment->comment_ID);
+}
+
+function comment_ID() {
+ echo get_comment_ID();
+}
+
+function get_comment_author() {
+ global $comment;
+ if ( empty($comment->comment_author) )
+ $author = 'Anonymous';
+ else
+ $author = $comment->comment_author;
+ return apply_filters('get_comment_author', $author);
+}
+
+function comment_author() {
+ $author = apply_filters('comment_author', get_comment_author() );
+ echo $author;
+}
+
+function get_comment_author_email() {
+ global $comment;
+ return apply_filters('get_comment_author_email', $comment->comment_author_email);
+}
+
+function comment_author_email() {
+ echo apply_filters('author_email', get_comment_author_email() );
+}
+
+function get_comment_author_link() {
+ global $comment;
+ $url = get_comment_author_url();
+ $author = get_comment_author();
+
+ if ( empty( $url ) )
+ $return = $author;
+ else
+ $return = "<a href='$url' rel='external nofollow'>$author</a>";
+ return apply_filters('get_comment_author_link', $return);
+}
+
+function comment_author_link() {
+ echo get_comment_author_link();
+}
+
+function get_comment_type() {
+ global $comment;
+
+ if ( '' == $comment->comment_type )
+ $comment->comment_type = 'comment';
+
+ return apply_filters('get_comment_type', $comment->comment_type);
+}
+
+function comment_type($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') {
+ $type = get_comment_type();
+ switch( $type ) {
+ case 'trackback' :
+ echo $trackbacktxt;
+ break;
+ case 'pingback' :
+ echo $pingbacktxt;
+ break;
+ default :
+ echo $commenttxt;
+ }
+}
+
+function get_comment_author_url() {
+ global $comment;
+ return apply_filters('get_comment_author_url', $comment->comment_author_url);
+}
+
+function comment_author_url() {
+ echo apply_filters('comment_url', get_comment_author_url());
+}
+
+function comment_author_email_link($linktext='', $before='', $after='') {
+ global $comment;
+ $email = apply_filters('comment_email', $comment->comment_author_email);
+ if ((!empty($email)) && ($email != '@')) {
+ $display = ($linktext != '') ? $linktext : $email;
+ echo $before;
+ echo "<a href='mailto:$email'>$display</a>";
+ echo $after;
+ }
+}
+
+function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
+ global $comment;
+ $url = get_comment_author_url();
+ $display = ($linktext != '') ? $linktext : $url;
+ $return = "$before<a href='$url' rel='external'>$display</a>$after";
+ return apply_filters('get_comment_author_url_link', $return);
+}
+
+function comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
+ echo get_comment_author_url_link( $linktext, $before, $after );
+}
+
+function get_comment_author_IP() {
+ global $comment;
+ return apply_filters('get_comment_author_IP', $comment->comment_author_IP);
+}
+
+function comment_author_IP() {
+ echo get_comment_author_IP();
+}
+
+function get_comment_text() {
+ global $comment;
+ return apply_filters('get_comment_text', $comment->comment_content);
+}
+
+function comment_text() {
+ echo apply_filters('comment_text', get_comment_text() );
+}
+
+function get_comment_excerpt() {
+ global $comment;
+ $comment_text = strip_tags($comment->comment_content);
+ $blah = explode(' ', $comment_text);
+ if (count($blah) > 20) {
+ $k = 20;
+ $use_dotdotdot = 1;
+ } else {
+ $k = count($blah);
+ $use_dotdotdot = 0;
+ }
+ $excerpt = '';
+ for ($i=0; $i<$k; $i++) {
+ $excerpt .= $blah[$i] . ' ';
+ }
+ $excerpt .= ($use_dotdotdot) ? '...' : '';
+ return apply_filters('get_comment_excerpt', $excerpt);
+}
+
+function comment_excerpt() {
+ echo apply_filters('comment_excerpt', get_comment_excerpt() );
+}
+
+function get_comment_date( $d = '' ) {
+ global $comment;
+ if ( '' == $d )
+ $date = mysql2date( get_settings('date_format'), $comment->comment_date);
+ else
+ $date = mysql2date($d, $comment->comment_date);
+ return apply_filters('get_comment_date', $date);
+}
+
+function comment_date( $d = '' ) {
+ echo get_comment_date( $d );
+}
+
+function get_comment_time( $d = '', $gmt = false ) {
+ global $comment;
+ $comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date;
+ if ( '' == $d )
+ $date = mysql2date(get_settings('time_format'), $comment_date);
+ else
+ $date = mysql2date($d, $comment_date);
+ return apply_filters('get_comment_time', $date);
+}
+
+function comment_time( $d = '' ) {
+ echo get_comment_time($d);
+}
+
+function get_trackback_url() {
+ global $id;
+ $tb_url = get_settings('siteurl') . '/wp-trackback.php?p=' . $id;
+
+ if ( '' != get_settings('permalink_structure') )
+ $tb_url = trailingslashit(get_permalink()) . 'trackback/';
+
+ return $tb_url;
+}
+function trackback_url( $display = true ) {
+ if ( $display)
+ echo get_trackback_url();
+ else
+ return get_trackback_url();
+}
+
+function trackback_rdf($timezone = 0) {
+ global $id;
+ if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) {
+ echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
+ <rdf:Description rdf:about="';
+ the_permalink();
+ echo '"'."\n";
+ echo ' dc:identifier="';
+ the_permalink();
+ echo '"'."\n";
+ echo ' dc:title="'.str_replace('--', '&#x2d;&#x2d;', wptexturize(strip_tags(get_the_title()))).'"'."\n";
+ echo ' trackback:ping="'.trackback_url(0).'"'." />\n";
+ echo '</rdf:RDF>';
+ }
+}
+
+function comments_open() {
+ global $post;
+ if ( 'open' == $post->comment_status )
+ return true;
+ else
+ return false;
+}
+
+function pings_open() {
+ global $post;
+ if ( 'open' == $post->ping_status )
+ return true;
+ else
+ return false;
+}
+
+// Non-template functions
+
+function get_lastcommentmodified($timezone = 'server') {
+ global $tablecomments, $cache_lastcommentmodified, $pagenow, $wpdb;
+ $add_seconds_blog = get_settings('gmt_offset') * 3600;
+ $add_seconds_server = date('Z');
+ $now = current_time('mysql', 1);
+ if ( !isset($cache_lastcommentmodified[$timezone]) ) {
+ switch(strtolower($timezone)) {
+ case 'gmt':
+ $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $tablecomments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
+ break;
+ case 'blog':
+ $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $tablecomments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
+ break;
+ case 'server':
+ $lastcommentmodified = $wpdb->get_var("SELECT DATE_ADD(comment_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $tablecomments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
+ break;
+ }
+ $cache_lastcommentmodified[$timezone] = $lastcommentmodified;
+ } else {
+ $lastcommentmodified = $cache_lastcommentmodified[$timezone];
+ }
+ return $lastcommentmodified;
+}
+
+function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { // less flexible, but saves DB queries
+ global $postc, $id, $commentdata, $wpdb;
+ if ($no_cache) {
+ $query = "SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_ID'";
+ if (false == $include_unapproved) {
+ $query .= " AND comment_approved = '1'";
+ }
+ $myrow = $wpdb->get_row($query, ARRAY_A);
+ } else {
+ $myrow['comment_ID'] = $postc->comment_ID;
+ $myrow['comment_post_ID'] = $postc->comment_post_ID;
+ $myrow['comment_author'] = $postc->comment_author;
+ $myrow['comment_author_email'] = $postc->comment_author_email;
+ $myrow['comment_author_url'] = $postc->comment_author_url;
+ $myrow['comment_author_IP'] = $postc->comment_author_IP;
+ $myrow['comment_date'] = $postc->comment_date;
+ $myrow['comment_content'] = $postc->comment_content;
+ $myrow['comment_karma'] = $postc->comment_karma;
+ $myrow['comment_approved'] = $postc->comment_approved;
+ $myrow['comment_type'] = $postc->comment_type;
+ }
+ return $myrow;
+}
+
+function pingback($content, $post_ID) {
+ global $wp_version, $wpdb;
+ include_once (ABSPATH . WPINC . '/class-IXR.php');
+
+ // original code by Mort (http://mort.mine.nu:8080)
+ $log = debug_fopen(ABSPATH . '/pingback.log', 'a');
+ $post_links = array();
+ debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n");
+
+ $pung = get_pung($post_ID);
+
+ // Variables
+ $ltrs = '\w';
+ $gunk = '/#~:.?+=&%@!\-';
+ $punc = '.:?\-';
+ $any = $ltrs . $gunk . $punc;
+
+ // Step 1
+ // Parsing the post, external links (if any) are stored in the $post_links array
+ // This regexp comes straight from phpfreaks.com
+ // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php
+ preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
+
+ // Debug
+ debug_fwrite($log, 'Post contents:');
+ debug_fwrite($log, $content."\n");
+
+ // Step 2.
+ // Walking thru the links array
+ // first we get rid of links pointing to sites, not to specific files
+ // Example:
+ // http://dummy-weblog.org
+ // http://dummy-weblog.org/
+ // http://dummy-weblog.org/post.php
+ // We don't wanna ping first and second types, even if they have a valid <link/>
+
+ foreach($post_links_temp[0] as $link_test) :
+ if ( !in_array($link_test, $pung) ) : // If we haven't pung it already
+ $test = parse_url($link_test);
+ if (isset($test['query']))
+ $post_links[] = $link_test;
+ elseif(($test['path'] != '/') && ($test['path'] != ''))
+ $post_links[] = $link_test;
+ endif;
+ endforeach;
+
+ foreach ($post_links as $pagelinkedto){
+ debug_fwrite($log, "Processing -- $pagelinkedto\n");
+ $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
+
+ if ($pingback_server_url) {
+ set_time_limit( 60 );
+ // Now, the RPC call
+ debug_fwrite($log, "Page Linked To: $pagelinkedto \n");
+ debug_fwrite($log, 'Page Linked From: ');
+ $pagelinkedfrom = get_permalink($post_ID);
+ debug_fwrite($log, $pagelinkedfrom."\n");
+
+ // using a timeout of 3 seconds should be enough to cover slow servers
+ $client = new IXR_Client($pingback_server_url);
+ $client->timeout = 3;
+ $client->useragent .= ' -- WordPress/' . $wp_version;
+
+ // when set to true, this outputs debug messages by itself
+ $client->debug = false;
+
+ if ( $client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto) ) )
+ add_ping( $post_ID, $pagelinkedto );
+ else
+ debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n");
+ }
+ }
+
+ debug_fwrite($log, "\nEND: ".time()."\n****************************\n");
+ debug_fclose($log);
+}
+
+function discover_pingback_server_uri($url, $timeout_bytes = 2048) {
+ global $wp_version;
+
+ $byte_count = 0;
+ $contents = '';
+ $headers = '';
+ $pingback_str_dquote = 'rel="pingback"';
+ $pingback_str_squote = 'rel=\'pingback\'';
+ $x_pingback_str = 'x-pingback: ';
+ $pingback_href_original_pos = 27;
+
+ extract(parse_url($url));
+
+ if (!isset($host)) {
+ // Not an URL. This should never happen.
+ return false;
+ }
+
+ $path = (!isset($path)) ? '/' : $path;
+ $path .= (isset($query)) ? '?'.$query : '';
+ $port = (isset($port)) ? $port : 80;
+
+ // Try to connect to the server at $host
+ $fp = @fsockopen($host, $port, $errno, $errstr, 2);
+ if (!$fp) {
+ // Couldn't open a connection to $host;
+ return false;
+ }
+
+ // Send the GET request
+ $request = "GET $path HTTP/1.1\r\nHost: $host\r\nUser-Agent: WordPress/$wp_version PHP/" . phpversion() . "\r\n\r\n";
+ ob_end_flush();
+ fputs($fp, $request);
+
+ // Let's check for an X-Pingback header first
+ while (!feof($fp)) {
+ $line = fgets($fp, 512);
+ if (trim($line) == '') {
+ break;
+ }
+ $headers .= trim($line)."\n";
+ $x_pingback_header_offset = strpos(strtolower($headers), $x_pingback_str);
+ if ($x_pingback_header_offset) {
+ // We got it!
+ preg_match('#x-pingback: (.+)#is', $headers, $matches);
+ $pingback_server_url = trim($matches[1]);
+ return $pingback_server_url;
+ }
+ if(strpos(strtolower($headers), 'content-type: ')) {
+ preg_match('#content-type: (.+)#is', $headers, $matches);
+ $content_type = trim($matches[1]);
+ }
+ }
+
+ if (preg_match('#(image|audio|video|model)/#is', $content_type)) {
+ // Not an (x)html, sgml, or xml page, no use going further
+ return false;
+ }
+
+ while (!feof($fp)) {
+ $line = fgets($fp, 1024);
+ $contents .= trim($line);
+ $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
+ $pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
+ if ($pingback_link_offset_dquote || $pingback_link_offset_squote) {
+ $quote = ($pingback_link_offset_dquote) ? '"' : '\'';
+ $pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
+ $pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset);
+ $pingback_href_start = $pingback_href_pos+6;
+ $pingback_href_end = @strpos($contents, $quote, $pingback_href_start);
+ $pingback_server_url_len = $pingback_href_end - $pingback_href_start;
+ $pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len);
+ // We may find rel="pingback" but an incomplete pingback URI
+ if ($pingback_server_url_len > 0) {
+ // We got it!
+ return $pingback_server_url;
+ }
+ }
+ $byte_count += strlen($line);
+ if ($byte_count > $timeout_bytes) {
+ // It's no use going further, there probably isn't any pingback
+ // server to find in this file. (Prevents loading large files.)
+ return false;
+ }
+ }
+
+ // We didn't find anything.
+ return false;
+}
+
+
+function wp_set_comment_status($comment_id, $comment_status) {
+ global $wpdb;
+
+ switch($comment_status) {
+ case 'hold':
+ $query = "UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
+ case 'approve':
+ $query = "UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
+ case 'spam':
+ $query = "UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
+ case 'delete':
+ $query = "DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
+ default:
+ return false;
+ }
+
+ if ($wpdb->query($query)) {
+ do_action('wp_set_comment_status', $comment_id, $comment_status);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+
+function wp_get_comment_status($comment_id) {
+ global $wpdb;
+
+ $result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
+ if ($result == NULL) {
+ return 'deleted';
+ } else if ($result == '1') {
+ return 'approved';
+ } else if ($result == '0') {
+ return 'unapproved';
+ } else if ($result == 'spam') {
+ return 'spam';
+ } else {
+ return false;
+ }
+}
+
+function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
+ global $wpdb;
+
+ if (1 == get_settings('comment_moderation')) return false; // If moderation is set to manual
+
+ if ( (count(explode('http:', $comment)) - 1) >= get_settings('comment_max_links') )
+ return false; // Check # of external links
+
+ $mod_keys = trim( get_settings('moderation_keys') );
+ if ( !empty($mod_keys) ) {
+ $words = explode("\n", $mod_keys );
+
+ foreach ($words as $word) {
+ $word = trim($word);
+
+ // Skip empty lines
+ if (empty($word)) { continue; }
+
+ // Do some escaping magic so that '#' chars in the
+ // spam words don't break things:
+ $word = preg_quote($word, '#');
+
+ $pattern = "#$word#i";
+ if ( preg_match($pattern, $author) ) return false;
+ if ( preg_match($pattern, $email) ) return false;
+ if ( preg_match($pattern, $url) ) return false;
+ if ( preg_match($pattern, $comment) ) return false;
+ if ( preg_match($pattern, $user_ip) ) return false;
+ if ( preg_match($pattern, $user_agent) ) return false;
+ }
+ }
+
+ // Comment whitelisting:
+ if ( 1 == get_settings('comment_whitelist')) {
+ if ( 'trackback' == $comment_type || 'pingback' == $comment_type ) { // check if domain is in blogroll
+ $uri = parse_url($url);
+ $domain = $uri['host'];
+ $uri = parse_url( get_option('home') );
+ $home_domain = $uri['host'];
+ if ( $wpdb->get_var("SELECT link_id FROM $wpdb->links WHERE link_url LIKE ('%$domain%') LIMIT 1") || $domain == $home_domain )
+ return true;
+ else
+ return false;
+ } elseif( $author != '' && $email != '' ) {
+ $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1");
+ if ( 1 == $ok_to_comment && false === strpos( $email, get_settings('moderation_keys')) )
+ return true;
+ else
+ return false;
+ } else {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+?>
diff --git a/wp-inst/wp-includes/create_smarty_template.php b/wp-inst/wp-includes/create_smarty_template.php
new file mode 100755
index 0000000..7556a68
--- /dev/null
+++ b/wp-inst/wp-includes/create_smarty_template.php
@@ -0,0 +1,144 @@
+#!/usr/bin/php -q
+<?php
+
+/* $Id: create_smarty_template.php,v 1.7 2005/03/12 20:17:52 donncha Exp $ */
+
+
+if (is_dir( "." ))
+{
+ if ($dh = opendir( "." ))
+ {
+ while (($file = readdir($dh)) !== false )
+ {
+ if( strpos( $file, "template-functions" ) !== false )
+ {
+ $files[] = $file;
+ }
+ }
+ closedir($dh);
+ }
+}
+$files[] = 'links.php';
+$files[] = 'functions.php';
+$files[] = 'wp-l10n.php';
+$files[] = 'functions-formatting.php';
+$files[] = 'functions-post.php';
+$files[] = 'functions-user.php';
+$files[] = 'feed-functions.php';
+$files[] = 'comment-functions.php';
+
+
+$buffer2 = '';
+reset( $files );
+while( list( $k, $file ) = each( $files ) )
+{
+ if( is_file( $file ) )
+ {
+ $fp = fopen( $file, "r" );
+ while (!feof ($fp))
+ {
+ $buffer = fgets($fp, 4096);
+ if( strpos( $buffer, "unction " ) == '1' )
+ {
+ if( strpos( $buffer, '{' ) === false )
+ {
+ // multi-line function call
+ $buffer2 .= $buffer;
+ while(!feof( $fp ) && strpos( $buffer, '{' ) === false )
+ {
+ $buffer = fgets($fp, 4096);
+ $buffer2 .= $buffer;
+ }
+ $line[] = $buffer2;
+ $buffer2 = '';
+ }
+ else
+ {
+ $line[] = $buffer;
+ $buffer2 = '';
+ }
+ }
+
+ }
+ fclose ($fp);
+ }
+}
+print '<'.'?'.'php'."\n".'
+if( isset( $wpsmarty ) == false || is_object( $wpsmarty ) == false )
+{
+ if( defined( ABSPATH ) == false )
+ define( "ABSPATH", "../" );
+
+ require_once( ABSPATH . "Smarty.class.php" );
+ $wpsmarty = new Smarty;
+}
+
+';
+
+reset( $line );
+while( list( $key, $val ) = each( $line ) )
+{
+ $function = substr( $val, 9, strpos( $val, "(" ) - 9 );
+ $bracket1 = strpos( $val, "(" ) + 1;
+ $origargs = substr( $val, $bracket1, strpos( $val, ') {' ) - $bracket1 );
+ $argslist = split( ",", $origargs );
+ $args = '';
+ $defineargs = '';
+ reset( $argslist );
+ while( list( $key, $val ) = each( $argslist ) )
+ {
+ if( strpos( $val, "=" ) )
+ {
+ $defineargs .= " ".trim( $val ).";\n";
+ $args .= trim( substr( $val, 0, strpos( $val, "=" ) ) ).", ";
+ }
+ else
+ {
+ $args .= $val.", ";
+ }
+ }
+ $args = substr( $args, 0, -2 );
+ print "/* $function( $origargs ) */\n";
+ if( $function[0] == '&' )
+ {
+ print "function &smarty_".substr( $function, 1 )."( \$params, &\$smarty )\n";
+ }
+ else
+ {
+ print "function smarty_".$function."( \$params, &\$smarty )\n";
+ }
+ print "{\n";
+ print "$defineargs\n";
+ print " extract( \$params );\n";
+ if( $function[0] == '&' )
+ {
+ print " return ".substr( $function, 1 )."( $args );\n";
+ }
+ else
+ {
+ print " return $function( $args );\n";
+ }
+ print "}\n";
+ if( $function[0] == '&' )
+ {
+ print '$wpsmarty->register_function( "'.substr( $function, 1 ).'", "smarty_'.substr( $function, 1 ).'" );'."\n\n";
+ }
+ else
+ {
+ print '$wpsmarty->register_function( "'.$function.'", "smarty_'.$function.'" );'."\n\n";
+ }
+}
+print '
+$wpsmarty->template_dir = ABSPATH."/wp-content/blogs/".$wpblog."/templates";
+$wpsmarty->compile_dir = ABSPATH."/wp-content/blogs/".$wpblog."/templates_c";
+$wpsmarty->cache_dir = ABSPATH."/wp-content/blogs/".$wpblog."/smartycache";
+$wpsmarty->plugins_dir = ABSPATH."/wp-content/smarty-plugins";
+$wpsmarty->cache_lifetime = -1;
+$wpsmarty->caching = true;
+$wpsmarty->security = 1;
+$wpsmarty->secure_dir = array( ABSPATH."/wp-content/blogs/".$wpblog."/templates", "wp-content/smarty-templates" );
+if( isset( $_GET[ "clear" ] ) )
+ $wpsmarty->clear_all_cache();
+';
+print "?".">";
+?>
diff --git a/wp-inst/wp-includes/default-filters.php b/wp-inst/wp-includes/default-filters.php
new file mode 100644
index 0000000..5b988a9
--- /dev/null
+++ b/wp-inst/wp-includes/default-filters.php
@@ -0,0 +1,88 @@
+<?php
+
+// Some default filters
+add_filter('bloginfo','wp_specialchars');
+add_filter('category_description', 'wptexturize');
+add_filter('list_cats', 'wptexturize');
+add_filter('comment_author', 'wptexturize');
+add_filter('comment_text', 'wptexturize');
+add_filter('single_post_title', 'wptexturize');
+add_filter('the_title', 'wptexturize');
+add_filter('the_content', 'wptexturize');
+add_filter('the_excerpt', 'wptexturize');
+add_filter('bloginfo', 'wptexturize');
+
+// Comments, trackbacks, pingbacks
+add_filter('pre_comment_author_name', 'strip_tags');
+add_filter('pre_comment_author_name', 'trim');
+add_filter('pre_comment_author_name', 'wp_specialchars', 30);
+
+add_filter('pre_comment_author_email', 'trim');
+add_filter('pre_comment_author_email', 'sanitize_email');
+
+add_filter('pre_comment_author_url', 'strip_tags');
+add_filter('pre_comment_author_url', 'trim');
+add_filter('pre_comment_author_url', 'clean_url');
+
+add_filter('pre_comment_content', 'stripslashes', 1);
+add_filter('pre_comment_content', 'wp_filter_kses');
+add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
+add_filter('pre_comment_content', 'balanceTags', 30);
+add_filter('pre_comment_content', 'addslashes', 50);
+
+add_filter('pre_comment_author_name', 'wp_filter_kses');
+add_filter('pre_comment_author_email', 'wp_filter_kses');
+add_filter('pre_comment_author_url', 'wp_filter_kses');
+
+// Default filters for these functions
+add_filter('comment_author', 'wptexturize');
+add_filter('comment_author', 'convert_chars');
+add_filter('comment_author', 'wp_specialchars');
+
+add_filter('comment_email', 'antispambot');
+
+add_filter('comment_url', 'clean_url');
+
+add_filter('comment_text', 'convert_chars');
+add_filter('comment_text', 'make_clickable');
+add_filter('comment_text', 'wpautop', 30);
+add_filter('comment_text', 'convert_smilies', 20);
+
+add_filter('comment_excerpt', 'convert_chars');
+
+// Places to balance tags on input
+add_filter('content_save_pre', 'balanceTags', 50);
+add_filter('excerpt_save_pre', 'balanceTags', 50);
+add_filter('comment_save_pre', 'balanceTags', 50);
+
+// Misc. title, content, and excerpt filters
+add_filter('the_title', 'convert_chars');
+add_filter('the_title', 'trim');
+
+add_filter('the_content', 'convert_smilies');
+add_filter('the_content', 'convert_chars');
+add_filter('the_content', 'wpautop');
+
+add_filter('the_excerpt', 'convert_smilies');
+add_filter('the_excerpt', 'convert_chars');
+add_filter('the_excerpt', 'wpautop');
+add_filter('get_the_excerpt', 'wp_trim_excerpt');
+
+add_filter('sanitize_title', 'sanitize_title_with_dashes');
+
+// RSS filters
+add_filter('the_title_rss', 'strip_tags');
+add_filter('the_title_rss', 'ent2ncr', 8);
+add_filter('the_content_rss', 'ent2ncr', 8);
+add_filter('the_excerpt_rss', 'convert_chars');
+add_filter('the_excerpt_rss', 'ent2ncr', 8);
+add_filter('comment_author_rss', 'ent2ncr', 8);
+add_filter('comment_text_rss', 'htmlspecialchars');
+add_filter('comment_text_rss', 'ent2ncr', 8);
+add_filter('bloginfo_rss', 'ent2ncr', 8);
+add_filter('the_author', 'ent2ncr', 8);
+
+// Actions
+add_action('publish_post', 'generic_ping');
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/feed-functions.php b/wp-inst/wp-includes/feed-functions.php
new file mode 100644
index 0000000..a9df4e7
--- /dev/null
+++ b/wp-inst/wp-includes/feed-functions.php
@@ -0,0 +1,158 @@
+<?php
+
+function get_bloginfo_rss($show = '') {
+ $info = strip_tags(get_bloginfo($show));
+ return convert_chars($info);
+}
+
+function bloginfo_rss($show = '') {
+ echo get_bloginfo_rss($show);
+}
+
+function the_title_rss() {
+ $title = get_the_title();
+ $title = apply_filters('the_title', $title);
+ $title = apply_filters('the_title_rss', $title);
+ echo $title;
+}
+
+function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
+ $content = get_the_content($more_link_text, $stripteaser, $more_file);
+ $content = apply_filters('the_content', $content);
+ if ($cut && !$encode_html) {
+ $encode_html = 2;
+ }
+ if ($encode_html == 1) {
+ $content = wp_specialchars($content);
+ $cut = 0;
+ } elseif ($encode_html == 0) {
+ $content = make_url_footnote($content);
+ } elseif ($encode_html == 2) {
+ $content = strip_tags($content);
+ }
+ if ($cut) {
+ $blah = explode(' ', $content);
+ if (count($blah) > $cut) {
+ $k = $cut;
+ $use_dotdotdot = 1;
+ } else {
+ $k = count($blah);
+ $use_dotdotdot = 0;
+ }
+ for ($i=0; $i<$k; $i++) {
+ $excerpt .= $blah[$i].' ';
+ }
+ $excerpt .= ($use_dotdotdot) ? '...' : '';
+ $content = $excerpt;
+ }
+ $content = str_replace(']]>', ']]&gt;', $content);
+ echo $content;
+}
+
+function the_excerpt_rss() {
+ $output = get_the_excerpt(true);
+ echo apply_filters('the_excerpt_rss', $output);
+}
+
+function permalink_single_rss($file = '') {
+ echo get_permalink();
+}
+
+function comment_link() {
+ echo get_comment_link();
+}
+
+function comment_author_rss() {
+ $author = apply_filters('comment_author_rss', get_comment_author() );
+ echo $author;
+}
+
+function comment_text_rss() {
+ $comment_text = get_comment_text();
+ $comment_text = apply_filters('comment_text_rss', $comment_text);
+ echo $comment_text;
+}
+
+function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = '') {
+ $url = comments_rss($commentsrssfilename);
+ echo "<a href='$url'>$link_text</a>";
+}
+
+function comments_rss($commentsrssfilename = '') {
+ global $id;
+
+ if ('' != get_settings('permalink_structure'))
+ $url = trailingslashit( get_permalink() ) . 'feed/';
+ else
+ $url = get_settings('home') . "/$commentsrssfilename?feed=rss2&amp;p=$id";
+
+ return apply_filters('post_comments_feed_link', $url);
+}
+
+function get_author_rss_link($echo = false, $author_id, $author_nicename) {
+ $auth_ID = $author_id;
+ $permalink_structure = get_settings('permalink_structure');
+
+ if ('' == $permalink_structure) {
+ $link = get_settings('home') . '?feed=rss2&amp;author=' . $author_id;
+ } else {
+ $link = get_author_link(0, $author_id, $author_nicename);
+ $link = $link . "feed/";
+ }
+
+ $link = apply_filters('author_feed_link', $link);
+
+ if ($echo) echo $link;
+ return $link;
+}
+
+function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
+ $permalink_structure = get_settings('permalink_structure');
+
+ if ('' == $permalink_structure) {
+ $link = get_settings('home') . '?feed=rss2&amp;cat=' . $cat_ID;
+ } else {
+ $link = get_category_link($cat_ID);
+ $link = $link . "feed/";
+ }
+
+ $link = apply_filters('category_feed_link', $link);
+
+ if ($echo) echo $link;
+ return $link;
+}
+
+function the_category_rss($type = 'rss') {
+ $categories = get_the_category();
+ $the_list = '';
+ foreach ($categories as $category) {
+ $category->cat_name = convert_chars($category->cat_name);
+ if ('rdf' == $type) {
+ $the_list .= "\n\t<dc:subject>$category->cat_name</dc:subject>";
+ } else {
+ $the_list .= "\n\t<category>$category->cat_name</category>";
+ }
+ }
+ echo apply_filters('the_category_rss', $the_list, $type);
+}
+
+function rss_enclosure() {
+ global $id, $post;
+ if (!empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password)) return;
+
+ $custom_fields = get_post_custom();
+ if( is_array( $custom_fields ) ) {
+ while( list( $key, $val ) = each( $custom_fields ) ) {
+ if( $key == 'enclosure' ) {
+ if (is_array($val)) {
+ foreach($val as $enc) {
+ $enclosure = split( "\n", $enc );
+ print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
+ }
+ }
+ }
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/functions-compat.php b/wp-inst/wp-includes/functions-compat.php
new file mode 100644
index 0000000..5063ece
--- /dev/null
+++ b/wp-inst/wp-includes/functions-compat.php
@@ -0,0 +1,92 @@
+<?php
+
+/* Functions missing from older PHP versions */
+
+
+/* Added in PHP 4.2.0 */
+
+if (!function_exists('floatval')) {
+ function floatval($string) {
+ return ((float) $string);
+ }
+}
+
+if (!function_exists('is_a')) {
+ function is_a($object, $class) {
+ // by Aidan Lister <aidan@php.net>
+ if (get_class($object) == strtolower($class)) {
+ return true;
+ } else {
+ return is_subclass_of($object, $class);
+ }
+ }
+}
+
+if (!function_exists('ob_clean')) {
+ function ob_clean() {
+ // by Aidan Lister <aidan@php.net>
+ if (@ob_end_clean()) {
+ return ob_start();
+ }
+ return false;
+ }
+}
+
+
+/* Added in PHP 4.3.0 */
+
+function printr($var, $do_not_echo = false) {
+ // from php.net/print_r user contributed notes
+ ob_start();
+ print_r($var);
+ $code = htmlentities(ob_get_contents());
+ ob_clean();
+ if (!$do_not_echo) {
+ echo "<pre>$code</pre>";
+ }
+ return $code;
+}
+
+if (!defined('CASE_LOWER')) {
+ define('CASE_LOWER', 0);
+}
+
+if (!defined('CASE_UPPER')) {
+ define('CASE_UPPER', 1);
+}
+
+
+/**
+ * Replace array_change_key_case()
+ *
+ * @category PHP
+ * @package PHP_Compat
+ * @link http://php.net/function.array_change_key_case
+ * @author Stephan Schmidt <schst@php.net>
+ * @author Aidan Lister <aidan@php.net>
+ * @version $Revision: 2247 $
+ * @since PHP 4.2.0
+ * @require PHP 4.0.0 (user_error)
+ */
+if (!function_exists('array_change_key_case')) {
+ function array_change_key_case($input, $case = CASE_LOWER)
+ {
+ if (!is_array($input)) {
+ user_error('array_change_key_case(): The argument should be an array',
+ E_USER_WARNING);
+ return false;
+ }
+
+ $output = array ();
+ $keys = array_keys($input);
+ $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper';
+
+ foreach ($keys as $key) {
+ $output[$casefunc($key)] = $input[$key];
+ }
+
+ return $output;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/functions-formatting.php b/wp-inst/wp-includes/functions-formatting.php
new file mode 100644
index 0000000..3ad94f5
--- /dev/null
+++ b/wp-inst/wp-includes/functions-formatting.php
@@ -0,0 +1,996 @@
+<?php
+
+function wptexturize($text) {
+ $output = '';
+ // Capture tags and everything inside them
+ $textarr = preg_split("/(<.*>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
+ $stop = count($textarr); $next = true; // loop stuff
+ for ($i = 0; $i < $stop; $i++) {
+ $curl = $textarr[$i];
+
+ if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag
+ $curl = str_replace('---', '&#8212;', $curl);
+ $curl = str_replace(' -- ', ' &#8212; ', $curl);
+ $curl = str_replace('--', '&#8211;', $curl);
+ $curl = str_replace('xn&#8211;', 'xn--', $curl);
+ $curl = str_replace('...', '&#8230;', $curl);
+ $curl = str_replace('``', '&#8220;', $curl);
+
+ // This is a hack, look at this more later. It works pretty well though.
+ $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause");
+ $cockneyreplace = array("&#8217;tain&#8217;t","&#8217;twere","&#8217;twas","&#8217;tis","&#8217;twill","&#8217;til","&#8217;bout","&#8217;nuff","&#8217;round","&#8217;cause");
+ $curl = str_replace($cockney, $cockneyreplace, $curl);
+
+ $curl = preg_replace("/'s/", '&#8217;s', $curl);
+ $curl = preg_replace("/'(\d\d(?:&#8217;|')?s)/", "&#8217;$1", $curl);
+ $curl = preg_replace('/(\s|\A|")\'/', '$1&#8216;', $curl);
+ $curl = preg_replace('/(\d+)"/', '$1&#8243;', $curl);
+ $curl = preg_replace("/(\d+)'/", '$1&#8242;', $curl);
+ $curl = preg_replace("/(\S)'([^'\s])/", "$1&#8217;$2", $curl);
+ $curl = preg_replace('/(\s|\A)"(?!\s)/', '$1&#8220;$2', $curl);
+ $curl = preg_replace('/"(\s|\S|\Z)/', '&#8221;$1', $curl);
+ $curl = preg_replace("/'([\s.]|\Z)/", '&#8217;$1', $curl);
+ $curl = preg_replace("/ \(tm\)/i", ' &#8482;', $curl);
+ $curl = str_replace("''", '&#8221;', $curl);
+
+ $curl = preg_replace('/(\d+)x(\d+)/', "$1&#215;$2", $curl);
+
+ } elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) {
+ // strstr is fast
+ $next = false;
+ } else {
+ $next = true;
+ }
+ $curl = preg_replace('/&([^#])(?![a-z12]{1,8};)/', '&#038;$1', $curl);
+ $output .= $curl;
+ }
+ return $output;
+}
+
+function clean_pre($text) {
+ $text = str_replace('<br />', '', $text);
+ $text = str_replace('<p>', "\n", $text);
+ $text = str_replace('</p>', '', $text);
+ return $text;
+}
+
+function wpautop($pee, $br = 1) {
+ $pee = $pee . "\n"; // just to make things a little easier, pad the end
+ $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
+ // Space things out a little
+ $pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee);
+ $pee = preg_replace('!(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)!', "$1\n", $pee);
+ $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
+ $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
+ $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "\t<p>$1</p>\n", $pee); // make paragraphs, including one at the end
+ $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
+ $pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
+ $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
+ $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
+ $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
+ $pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "$1", $pee);
+ $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee);
+ if ($br) $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
+ $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*<br />!', "$1", $pee);
+ $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)!', '$1', $pee);
+ $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . clean_pre('$2') . '</pre>' ", $pee);
+
+ return $pee;
+}
+
+
+function seems_utf8($Str) { # by bmorel at ssi dot fr
+ for ($i=0; $i<strlen($Str); $i++) {
+ if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb
+ elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb
+ elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb
+ elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb
+ elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb
+ elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b
+ else return false; # Does not match any model
+ for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
+ if ((++$i == strlen($Str)) || ((ord($Str[$i]) & 0xC0) != 0x80))
+ return false;
+ }
+ }
+ return true;
+}
+
+function wp_specialchars( $text, $quotes = 0 ) {
+ // Like htmlspecialchars except don't double-encode HTML entities
+ $text = preg_replace('/&([^#])(?![a-z12]{1,8};)/', '&#038;$1', $text);-
+ $text = str_replace('<', '&lt;', $text);
+ $text = str_replace('>', '&gt;', $text);
+ if ( $quotes ) {
+ $text = str_replace('"', '&quot;', $text);
+ $text = str_replace("'", '&#039;', $text);
+ }
+ return $text;
+}
+
+function utf8_uri_encode( $utf8_string ) {
+ $unicode = '';
+ $values = array();
+ $num_octets = 1;
+
+ for ($i = 0; $i < strlen( $utf8_string ); $i++ ) {
+
+ $value = ord( $utf8_string[ $i ] );
+
+ if ( $value < 128 ) {
+ $unicode .= chr($value);
+ } else {
+ if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
+
+ $values[] = $value;
+
+ if ( count( $values ) == $num_octets ) {
+ if ($num_octets == 3) {
+ $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
+ } else {
+ $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
+ }
+
+ $values = array();
+ $num_octets = 1;
+ }
+ }
+ }
+
+ return $unicode;
+}
+
+function remove_accents($string) {
+ if (seems_utf8($string)) {
+ $chars = array(
+ // Decompositions for Latin-1 Supplement
+ chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
+ chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
+ chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
+ chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
+ chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
+ chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
+ chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
+ chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
+ chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
+ chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
+ chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
+ chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
+ chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
+ chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
+ chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
+ chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
+ chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
+ chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
+ chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
+ chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
+ chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
+ chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
+ chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
+ chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
+ chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
+ chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
+ chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
+ chr(195).chr(191) => 'y',
+ // Decompositions for Latin Extended-A
+ chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
+ chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
+ chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
+ chr(196).chr(134) => 'C', chr(196).chr(134) => 'c',
+ chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
+ chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
+ chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
+ chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
+ chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
+ chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
+ chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
+ chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
+ chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
+ chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
+ chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
+ chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
+ chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
+ chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
+ chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
+ chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
+ chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
+ chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
+ chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
+ chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
+ chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
+ chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
+ chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
+ chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
+ chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
+ chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
+ chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
+ chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
+ chr(197).chr(128) => 'l', chr(196).chr(129) => 'L',
+ chr(197).chr(130) => 'l', chr(196).chr(131) => 'N',
+ chr(197).chr(132) => 'n', chr(196).chr(133) => 'N',
+ chr(197).chr(134) => 'n', chr(196).chr(135) => 'N',
+ chr(197).chr(136) => 'n', chr(196).chr(137) => 'N',
+ chr(197).chr(138) => 'n', chr(196).chr(139) => 'N',
+ chr(197).chr(140) => 'O', chr(196).chr(141) => 'o',
+ chr(197).chr(142) => 'O', chr(196).chr(143) => 'o',
+ chr(197).chr(144) => 'O', chr(196).chr(145) => 'o',
+ chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
+ chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
+ chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
+ chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
+ chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
+ chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
+ chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
+ chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
+ chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
+ chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
+ chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
+ chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
+ chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
+ chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
+ chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
+ chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
+ chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
+ chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
+ chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
+ chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
+ chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
+ chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
+ chr(197).chr(190) => 'z', chr(197).chr(191) => 's',
+ // Euro Sign
+ chr(226).chr(130).chr(172) => 'E');
+
+ $string = strtr($string, $chars);
+ } else {
+ // Assume ISO-8859-1 if not UTF-8
+ $chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158)
+ .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194)
+ .chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202)
+ .chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210)
+ .chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218)
+ .chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227)
+ .chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235)
+ .chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243)
+ .chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251)
+ .chr(252).chr(253).chr(255);
+
+ $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy";
+
+ $string = strtr($string, $chars['in'], $chars['out']);
+ $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254));
+ $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');
+ $string = str_replace($double_chars['in'], $double_chars['out'], $string);
+ }
+
+ return $string;
+}
+
+function sanitize_user( $username ) {
+ return preg_replace('|a-z0-9 _.-|i', '', $username);
+}
+
+function sanitize_title($title, $fallback_title = '') {
+ $title = strip_tags($title);
+ $title = apply_filters('sanitize_title', $title);
+
+ if (empty($title)) {
+ $title = $fallback_title;
+ }
+
+ return $title;
+}
+
+function sanitize_title_with_dashes($title) {
+ $title = strip_tags($title);
+ // Preserve escaped octets.
+ $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
+ // Remove percent signs that are not part of an octet.
+ $title = str_replace('%', '', $title);
+ // Restore octets.
+ $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
+
+ $title = remove_accents($title);
+ if (seems_utf8($title)) {
+ if (function_exists('mb_strtolower')) {
+ $title = mb_strtolower($title, 'UTF-8');
+ }
+ $title = utf8_uri_encode($title);
+ }
+
+ $title = strtolower($title);
+ $title = preg_replace('/&.+?;/', '', $title); // kill entities
+ $title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
+ $title = preg_replace('/\s+/', '-', $title);
+ $title = preg_replace('|-+|', '-', $title);
+ $title = trim($title, '-');
+
+ return $title;
+}
+
+function convert_chars($content, $flag = 'obsolete') {
+ // Translation of invalid Unicode references range to valid range
+ $wp_htmltranswinuni = array(
+ '&#128;' => '&#8364;', // the Euro sign
+ '&#129;' => '',
+ '&#130;' => '&#8218;', // these are Windows CP1252 specific characters
+ '&#131;' => '&#402;', // they would look weird on non-Windows browsers
+ '&#132;' => '&#8222;',
+ '&#133;' => '&#8230;',
+ '&#134;' => '&#8224;',
+ '&#135;' => '&#8225;',
+ '&#136;' => '&#710;',
+ '&#137;' => '&#8240;',
+ '&#138;' => '&#352;',
+ '&#139;' => '&#8249;',
+ '&#140;' => '&#338;',
+ '&#141;' => '',
+ '&#142;' => '&#382;',
+ '&#143;' => '',
+ '&#144;' => '',
+ '&#145;' => '&#8216;',
+ '&#146;' => '&#8217;',
+ '&#147;' => '&#8220;',
+ '&#148;' => '&#8221;',
+ '&#149;' => '&#8226;',
+ '&#150;' => '&#8211;',
+ '&#151;' => '&#8212;',
+ '&#152;' => '&#732;',
+ '&#153;' => '&#8482;',
+ '&#154;' => '&#353;',
+ '&#155;' => '&#8250;',
+ '&#156;' => '&#339;',
+ '&#157;' => '',
+ '&#158;' => '',
+ '&#159;' => '&#376;'
+ );
+
+ // Remove metadata tags
+ $content = preg_replace('/<title>(.+?)<\/title>/','',$content);
+ $content = preg_replace('/<category>(.+?)<\/category>/','',$content);
+
+ // Converts lone & characters into &#38; (a.k.a. &amp;)
+ $content = preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $content);
+
+ // Fix Word pasting
+ $content = strtr($content, $wp_htmltranswinuni);
+
+ // Just a little XHTML help
+ $content = str_replace('<br>', '<br />', $content);
+ $content = str_replace('<hr>', '<hr />', $content);
+
+ return $content;
+}
+
+function funky_javascript_fix($text) {
+ // Fixes for browsers' javascript bugs
+ global $is_macIE, $is_winIE;
+
+ if ( $is_winIE || $is_macIE )
+ $text = preg_replace("/\%u([0-9A-F]{4,4})/e", "'&#'.base_convert('\\1',16,10).';'", $text);
+
+ return $text;
+}
+
+/*
+ balanceTags
+
+ Balances Tags of string using a modified stack.
+
+ @param text Text to be balanced
+ @return Returns balanced text
+ @author Leonard Lin (leonard@acm.org)
+ @version v1.1
+ @date November 4, 2001
+ @license GPL v2.0
+ @notes
+ @changelog
+ --- Modified by Scott Reilly (coffee2code) 02 Aug 2004
+ 1.2 ***TODO*** Make better - change loop condition to $text
+ 1.1 Fixed handling of append/stack pop order of end text
+ Added Cleaning Hooks
+ 1.0 First Version
+*/
+function balanceTags($text, $is_comment = 0) {
+
+ if (get_settings('use_balanceTags') == 0) {
+ return $text;
+ }
+
+ $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
+
+ # WP bug fix for comments - in case you REALLY meant to type '< !--'
+ $text = str_replace('< !--', '< !--', $text);
+ # WP bug fix for LOVE <3 (and other situations with '<' before a number)
+ $text = preg_replace('#<([0-9]{1})#', '&lt;$1', $text);
+
+ while (preg_match("/<(\/?\w*)\s*([^>]*)>/",$text,$regex)) {
+ $newtext .= $tagqueue;
+
+ $i = strpos($text,$regex[0]);
+ $l = strlen($regex[0]);
+
+ // clear the shifter
+ $tagqueue = '';
+ // Pop or Push
+ if ($regex[1][0] == "/") { // End Tag
+ $tag = strtolower(substr($regex[1],1));
+ // if too many closing tags
+ if($stacksize <= 0) {
+ $tag = '';
+ //or close to be safe $tag = '/' . $tag;
+ }
+ // if stacktop value = tag close value then pop
+ else if ($tagstack[$stacksize - 1] == $tag) { // found closing tag
+ $tag = '</' . $tag . '>'; // Close Tag
+ // Pop
+ array_pop ($tagstack);
+ $stacksize--;
+ } else { // closing tag not at top, search for it
+ for ($j=$stacksize-1;$j>=0;$j--) {
+ if ($tagstack[$j] == $tag) {
+ // add tag to tagqueue
+ for ($k=$stacksize-1;$k>=$j;$k--){
+ $tagqueue .= '</' . array_pop ($tagstack) . '>';
+ $stacksize--;
+ }
+ break;
+ }
+ }
+ $tag = '';
+ }
+ } else { // Begin Tag
+ $tag = strtolower($regex[1]);
+
+ // Tag Cleaning
+
+ // If self-closing or '', don't do anything.
+ if((substr($regex[2],-1) == '/') || ($tag == '')) {
+ }
+ // ElseIf it's a known single-entity tag but it doesn't close itself, do so
+ elseif ($tag == 'br' || $tag == 'img' || $tag == 'hr' || $tag == 'input') {
+ $regex[2] .= '/';
+ } else { // Push the tag onto the stack
+ // If the top of the stack is the same as the tag we want to push, close previous tag
+ if (($stacksize > 0) && ($tag != 'div') && ($tagstack[$stacksize - 1] == $tag)) {
+ $tagqueue = '</' . array_pop ($tagstack) . '>';
+ $stacksize--;
+ }
+ $stacksize = array_push ($tagstack, $tag);
+ }
+
+ // Attributes
+ $attributes = $regex[2];
+ if($attributes) {
+ $attributes = ' '.$attributes;
+ }
+ $tag = '<'.$tag.$attributes.'>';
+ //If already queuing a close tag, then put this tag on, too
+ if ($tagqueue) {
+ $tagqueue .= $tag;
+ $tag = '';
+ }
+ }
+ $newtext .= substr($text,0,$i) . $tag;
+ $text = substr($text,$i+$l);
+ }
+
+ // Clear Tag Queue
+ $newtext .= $tagqueue;
+
+ // Add Remaining text
+ $newtext .= $text;
+
+ // Empty Stack
+ while($x = array_pop($tagstack)) {
+ $newtext .= '</' . $x . '>'; // Add remaining tags to close
+ }
+
+ // WP fix for the bug with HTML comments
+ $newtext = str_replace("< !--","<!--",$newtext);
+ $newtext = str_replace("< !--","< !--",$newtext);
+
+ return $newtext;
+}
+
+
+function format_to_edit($content) {
+ $content = apply_filters('format_to_edit', $content);
+ $content = htmlspecialchars($content);
+ return $content;
+}
+
+function format_to_post($content) {
+ global $wpdb;
+ $content = apply_filters('format_to_post', $content);
+ return $content;
+}
+
+function zeroise($number,$threshold) { // function to add leading zeros when necessary
+ return sprintf('%0'.$threshold.'s', $number);
+ }
+
+
+function backslashit($string) {
+ $string = preg_replace('/([a-z])/i', '\\\\\1', $string);
+ return $string;
+}
+
+function trailingslashit($string) {
+ if ( '/' != substr($string, -1)) {
+ $string .= '/';
+ }
+ return $string;
+}
+
+function addslashes_gpc($gpc) {
+ global $wpdb;
+
+ if (get_magic_quotes_gpc()) {
+ $gpc = stripslashes($gpc);
+ }
+
+ return $wpdb->escape($gpc);
+}
+
+
+function stripslashes_deep($value)
+{
+ $value = is_array($value) ?
+ array_map('stripslashes_deep', $value) :
+ stripslashes($value);
+
+ return $value;
+}
+
+function antispambot($emailaddy, $mailto=0) {
+ $emailNOSPAMaddy = '';
+ srand ((float) microtime() * 1000000);
+ for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {
+ $j = floor(rand(0, 1+$mailto));
+ if ($j==0) {
+ $emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';';
+ } elseif ($j==1) {
+ $emailNOSPAMaddy .= substr($emailaddy,$i,1);
+ } elseif ($j==2) {
+ $emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2);
+ }
+ }
+ $emailNOSPAMaddy = str_replace('@','&#64;',$emailNOSPAMaddy);
+ return $emailNOSPAMaddy;
+}
+
+function make_clickable($ret) {
+ $ret = ' ' . $ret . ' ';
+ $ret = preg_replace("#([\s>])(https?)://([^\s<>{}()]+[^\s.,<>{}()])#i", "$1<a href='$2://$3' rel='nofollow'>$2://$3</a>", $ret);
+ $ret = preg_replace("#(\s)www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^ <>{}()\n\r]*[^., <>{}()\n\r]?)?)#i", "$1<a href='http://www.$2.$3$4' rel='nofollow'>www.$2.$3$4</a>", $ret);
+ $ret = preg_replace("#(\s)([a-z0-9\-_.]+)@([^,< \n\r]+)#i", "$1<a href=\"mailto:$2@$3\">$2@$3</a>", $ret);
+ $ret = trim($ret);
+ return $ret;
+}
+
+function wp_rel_nofollow( $text ) {
+ $text = preg_replace('|<a (.+?)>|i', '<a $1 rel="nofollow">', $text);
+ return $text;
+}
+
+function convert_smilies($text) {
+ global $wp_smiliessearch, $wp_smiliesreplace;
+ $output = '';
+ if (get_settings('use_smilies')) {
+ // HTML loop taken from texturize function, could possible be consolidated
+ $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between
+ $stop = count($textarr);// loop stuff
+ for ($i = 0; $i < $stop; $i++) {
+ $content = $textarr[$i];
+ if ((strlen($content) > 0) && ('<' != $content{0})) { // If it's not a tag
+ $content = str_replace($wp_smiliessearch, $wp_smiliesreplace, $content);
+ }
+ $output .= $content;
+ }
+ } else {
+ // return default text.
+ $output = $text;
+ }
+ return $output;
+}
+
+
+function is_email($user_email) {
+ $chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i";
+ if(strstr($user_email, '@') && strstr($user_email, '.')) {
+ if (preg_match($chars, $user_email)) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+}
+
+// used by wp-mail to handle charsets in email subjects
+function wp_iso_descrambler($string) {
+ /* this may only work with iso-8859-1, I'm afraid */
+ if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
+ return $string;
+ } else {
+ $subject = str_replace('_', ' ', $matches[2]);
+ $subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject);
+ return $subject;
+ }
+}
+
+
+// give it a date, it will give you the same date as GMT
+function get_gmt_from_date($string) {
+ // note: this only substracts $time_difference from the given date
+ preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
+ $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
+ $string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_settings('gmt_offset') * 3600);
+ return $string_gmt;
+}
+
+// give it a GMT date, it will give you the same date with $time_difference added
+function get_date_from_gmt($string) {
+ // note: this only adds $time_difference to the given date
+ preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
+ $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
+ $string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_settings('gmt_offset')*3600);
+ return $string_localtime;
+}
+
+// computes an offset in seconds from an iso8601 timezone
+function iso8601_timezone_to_offset($timezone) {
+ // $timezone is either 'Z' or '[+|-]hhmm'
+ if ($timezone == 'Z') {
+ $offset = 0;
+ } else {
+ $sign = (substr($timezone, 0, 1) == '+') ? 1 : -1;
+ $hours = intval(substr($timezone, 1, 2));
+ $minutes = intval(substr($timezone, 3, 4)) / 60;
+ $offset = $sign * 3600 * ($hours + $minutes);
+ }
+ return $offset;
+}
+
+// converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]
+function iso8601_to_datetime($date_string, $timezone = USER) {
+ if ($timezone == GMT) {
+ preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);
+ if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
+ $offset = iso8601_timezone_to_offset($date_bits[7]);
+ } else { // we don't have a timezone, so we assume user local timezone (not server's!)
+ $offset = 3600 * get_settings('gmt_offset');
+ }
+ $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);
+ $timestamp -= $offset;
+ return gmdate('Y-m-d H:i:s', $timestamp);
+ } elseif ($timezone == USER) {
+ return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string);
+ }
+}
+
+function popuplinks($text) {
+ // Comment text in popup windows should be filtered through this.
+ // Right now it's a moderately dumb function, ideally it would detect whether
+ // a target or rel attribute was already there and adjust its actions accordingly.
+ $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
+ return $text;
+}
+
+function sanitize_email($email) {
+ return preg_replace('/[^a-z0-9+_.@-]/i', '', $email);
+}
+
+function human_time_diff( $from, $to = '' ) {
+ if ( empty($to) )
+ $to = time();
+ $diff = (int) abs($to - $from);
+ if ($diff <= 3600) {
+ $mins = round($diff / 60);
+ if ($mins <= 1)
+ $since = __('1 min');
+ else
+ $since = sprintf( __('%s mins'), $mins);
+ } else if (($diff <= 86400) && ($diff > 3600)) {
+ $hours = round($diff / 3600);
+ if ($hours <= 1)
+ $since = __('1 hour');
+ else
+ $since = sprintf( __('%s hours'), $hours );
+ } elseif ($diff >= 86400) {
+ $days = round($diff / 86400);
+ if ($days <= 1)
+ $since = __('1 day');
+ else
+ $since = sprintf( __('%s days'), $days );
+ }
+ return $since;
+}
+
+function wp_trim_excerpt($text) { // Fakes an excerpt if needed
+ global $post;
+ if ( '' == $text ) {
+ $text = $post->post_content;
+ $text = apply_filters('the_content', $text);
+ $text = str_replace(']]>', ']]&gt;', $text);
+ $text = strip_tags($text);
+ $excerpt_length = 55;
+ $words = explode(' ', $text, $excerpt_length + 1);
+ if (count($words) > $excerpt_length) {
+ array_pop($words);
+ array_push($words, '[...]');
+ $text = implode(' ', $words);
+ }
+ }
+ return $text;
+}
+
+function ent2ncr($text) {
+ $to_ncr = array(
+ '&quot;' => '&#34;',
+ '&amp;' => '&#38;',
+ '&frasl;' => '&#47;',
+ '&lt;' => '&#60;',
+ '&gt;' => '&#62;',
+ '|' => '&#124;',
+ '&nbsp;' => '&#160;',
+ '&iexcl;' => '&#161;',
+ '&cent;' => '&#162;',
+ '&pound;' => '&#163;',
+ '&curren;' => '&#164;',
+ '&yen;' => '&#165;',
+ '&brvbar;' => '&#166;',
+ '&brkbar;' => '&#166;',
+ '&sect;' => '&#167;',
+ '&uml;' => '&#168;',
+ '&die;' => '&#168;',
+ '&copy;' => '&#169;',
+ '&ordf;' => '&#170;',
+ '&laquo;' => '&#171;',
+ '&not;' => '&#172;',
+ '&shy;' => '&#173;',
+ '&reg;' => '&#174;',
+ '&macr;' => '&#175;',
+ '&hibar;' => '&#175;',
+ '&deg;' => '&#176;',
+ '&plusmn;' => '&#177;',
+ '&sup2;' => '&#178;',
+ '&sup3;' => '&#179;',
+ '&acute;' => '&#180;',
+ '&micro;' => '&#181;',
+ '&para;' => '&#182;',
+ '&middot;' => '&#183;',
+ '&cedil;' => '&#184;',
+ '&sup1;' => '&#185;',
+ '&ordm;' => '&#186;',
+ '&raquo;' => '&#187;',
+ '&frac14;' => '&#188;',
+ '&frac12;' => '&#189;',
+ '&frac34;' => '&#190;',
+ '&iquest;' => '&#191;',
+ '&Agrave;' => '&#192;',
+ '&Aacute;' => '&#193;',
+ '&Acirc;' => '&#194;',
+ '&Atilde;' => '&#195;',
+ '&Auml;' => '&#196;',
+ '&Aring;' => '&#197;',
+ '&AElig;' => '&#198;',
+ '&Ccedil;' => '&#199;',
+ '&Egrave;' => '&#200;',
+ '&Eacute;' => '&#201;',
+ '&Ecirc;' => '&#202;',
+ '&Euml;' => '&#203;',
+ '&Igrave;' => '&#204;',
+ '&Iacute;' => '&#205;',
+ '&Icirc;' => '&#206;',
+ '&Iuml;' => '&#207;',
+ '&ETH;' => '&#208;',
+ '&Ntilde;' => '&#209;',
+ '&Ograve;' => '&#210;',
+ '&Oacute;' => '&#211;',
+ '&Ocirc;' => '&#212;',
+ '&Otilde;' => '&#213;',
+ '&Ouml;' => '&#214;',
+ '&times;' => '&#215;',
+ '&Oslash;' => '&#216;',
+ '&Ugrave;' => '&#217;',
+ '&Uacute;' => '&#218;',
+ '&Ucirc;' => '&#219;',
+ '&Uuml;' => '&#220;',
+ '&Yacute;' => '&#221;',
+ '&THORN;' => '&#222;',
+ '&szlig;' => '&#223;',
+ '&agrave;' => '&#224;',
+ '&aacute;' => '&#225;',
+ '&acirc;' => '&#226;',
+ '&atilde;' => '&#227;',
+ '&auml;' => '&#228;',
+ '&aring;' => '&#229;',
+ '&aelig;' => '&#230;',
+ '&ccedil;' => '&#231;',
+ '&egrave;' => '&#232;',
+ '&eacute;' => '&#233;',
+ '&ecirc;' => '&#234;',
+ '&euml;' => '&#235;',
+ '&igrave;' => '&#236;',
+ '&iacute;' => '&#237;',
+ '&icirc;' => '&#238;',
+ '&iuml;' => '&#239;',
+ '&eth;' => '&#240;',
+ '&ntilde;' => '&#241;',
+ '&ograve;' => '&#242;',
+ '&oacute;' => '&#243;',
+ '&ocirc;' => '&#244;',
+ '&otilde;' => '&#245;',
+ '&ouml;' => '&#246;',
+ '&divide;' => '&#247;',
+ '&oslash;' => '&#248;',
+ '&ugrave;' => '&#249;',
+ '&uacute;' => '&#250;',
+ '&ucirc;' => '&#251;',
+ '&uuml;' => '&#252;',
+ '&yacute;' => '&#253;',
+ '&thorn;' => '&#254;',
+ '&yuml;' => '&#255;',
+ '&OElig;' => '&#338;',
+ '&oelig;' => '&#339;',
+ '&Scaron;' => '&#352;',
+ '&scaron;' => '&#353;',
+ '&Yuml;' => '&#376;',
+ '&fnof;' => '&#402;',
+ '&circ;' => '&#710;',
+ '&tilde;' => '&#732;',
+ '&Alpha;' => '&#913;',
+ '&Beta;' => '&#914;',
+ '&Gamma;' => '&#915;',
+ '&Delta;' => '&#916;',
+ '&Epsilon;' => '&#917;',
+ '&Zeta;' => '&#918;',
+ '&Eta;' => '&#919;',
+ '&Theta;' => '&#920;',
+ '&Iota;' => '&#921;',
+ '&Kappa;' => '&#922;',
+ '&Lambda;' => '&#923;',
+ '&Mu;' => '&#924;',
+ '&Nu;' => '&#925;',
+ '&Xi;' => '&#926;',
+ '&Omicron;' => '&#927;',
+ '&Pi;' => '&#928;',
+ '&Rho;' => '&#929;',
+ '&Sigma;' => '&#931;',
+ '&Tau;' => '&#932;',
+ '&Upsilon;' => '&#933;',
+ '&Phi;' => '&#934;',
+ '&Chi;' => '&#935;',
+ '&Psi;' => '&#936;',
+ '&Omega;' => '&#937;',
+ '&alpha;' => '&#945;',
+ '&beta;' => '&#946;',
+ '&gamma;' => '&#947;',
+ '&delta;' => '&#948;',
+ '&epsilon;' => '&#949;',
+ '&zeta;' => '&#950;',
+ '&eta;' => '&#951;',
+ '&theta;' => '&#952;',
+ '&iota;' => '&#953;',
+ '&kappa;' => '&#954;',
+ '&lambda;' => '&#955;',
+ '&mu;' => '&#956;',
+ '&nu;' => '&#957;',
+ '&xi;' => '&#958;',
+ '&omicron;' => '&#959;',
+ '&pi;' => '&#960;',
+ '&rho;' => '&#961;',
+ '&sigmaf;' => '&#962;',
+ '&sigma;' => '&#963;',
+ '&tau;' => '&#964;',
+ '&upsilon;' => '&#965;',
+ '&phi;' => '&#966;',
+ '&chi;' => '&#967;',
+ '&psi;' => '&#968;',
+ '&omega;' => '&#969;',
+ '&thetasym;' => '&#977;',
+ '&upsih;' => '&#978;',
+ '&piv;' => '&#982;',
+ '&ensp;' => '&#8194;',
+ '&emsp;' => '&#8195;',
+ '&thinsp;' => '&#8201;',
+ '&zwnj;' => '&#8204;',
+ '&zwj;' => '&#8205;',
+ '&lrm;' => '&#8206;',
+ '&rlm;' => '&#8207;',
+ '&ndash;' => '&#8211;',
+ '&mdash;' => '&#8212;',
+ '&lsquo;' => '&#8216;',
+ '&rsquo;' => '&#8217;',
+ '&sbquo;' => '&#8218;',
+ '&ldquo;' => '&#8220;',
+ '&rdquo;' => '&#8221;',
+ '&bdquo;' => '&#8222;',
+ '&dagger;' => '&#8224;',
+ '&Dagger;' => '&#8225;',
+ '&bull;' => '&#8226;',
+ '&hellip;' => '&#8230;',
+ '&permil;' => '&#8240;',
+ '&prime;' => '&#8242;',
+ '&Prime;' => '&#8243;',
+ '&lsaquo;' => '&#8249;',
+ '&rsaquo;' => '&#8250;',
+ '&oline;' => '&#8254;',
+ '&frasl;' => '&#8260;',
+ '&euro;' => '&#8364;',
+ '&image;' => '&#8465;',
+ '&weierp;' => '&#8472;',
+ '&real;' => '&#8476;',
+ '&trade;' => '&#8482;',
+ '&alefsym;' => '&#8501;',
+ '&crarr;' => '&#8629;',
+ '&lArr;' => '&#8656;',
+ '&uArr;' => '&#8657;',
+ '&rArr;' => '&#8658;',
+ '&dArr;' => '&#8659;',
+ '&hArr;' => '&#8660;',
+ '&forall;' => '&#8704;',
+ '&part;' => '&#8706;',
+ '&exist;' => '&#8707;',
+ '&empty;' => '&#8709;',
+ '&nabla;' => '&#8711;',
+ '&isin;' => '&#8712;',
+ '&notin;' => '&#8713;',
+ '&ni;' => '&#8715;',
+ '&prod;' => '&#8719;',
+ '&sum;' => '&#8721;',
+ '&minus;' => '&#8722;',
+ '&lowast;' => '&#8727;',
+ '&radic;' => '&#8730;',
+ '&prop;' => '&#8733;',
+ '&infin;' => '&#8734;',
+ '&ang;' => '&#8736;',
+ '&and;' => '&#8743;',
+ '&or;' => '&#8744;',
+ '&cap;' => '&#8745;',
+ '&cup;' => '&#8746;',
+ '&int;' => '&#8747;',
+ '&there4;' => '&#8756;',
+ '&sim;' => '&#8764;',
+ '&cong;' => '&#8773;',
+ '&asymp;' => '&#8776;',
+ '&ne;' => '&#8800;',
+ '&equiv;' => '&#8801;',
+ '&le;' => '&#8804;',
+ '&ge;' => '&#8805;',
+ '&sub;' => '&#8834;',
+ '&sup;' => '&#8835;',
+ '&nsub;' => '&#8836;',
+ '&sube;' => '&#8838;',
+ '&supe;' => '&#8839;',
+ '&oplus;' => '&#8853;',
+ '&otimes;' => '&#8855;',
+ '&perp;' => '&#8869;',
+ '&sdot;' => '&#8901;',
+ '&lceil;' => '&#8968;',
+ '&rceil;' => '&#8969;',
+ '&lfloor;' => '&#8970;',
+ '&rfloor;' => '&#8971;',
+ '&lang;' => '&#9001;',
+ '&rang;' => '&#9002;',
+ '&larr;' => '&#8592;',
+ '&uarr;' => '&#8593;',
+ '&rarr;' => '&#8594;',
+ '&darr;' => '&#8595;',
+ '&harr;' => '&#8596;',
+ '&loz;' => '&#9674;',
+ '&spades;' => '&#9824;',
+ '&clubs;' => '&#9827;',
+ '&hearts;' => '&#9829;',
+ '&diams;' => '&#9830;'
+ );
+
+ foreach ($to_ncr as $entity => $ncr) {
+ $text = str_replace($entity, $ncr, $text);
+ }
+ return $text;
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/functions-post.php b/wp-inst/wp-includes/functions-post.php
new file mode 100644
index 0000000..c078ffd
--- /dev/null
+++ b/wp-inst/wp-includes/functions-post.php
@@ -0,0 +1,714 @@
+<?php
+
+/**** DB Functions ****/
+
+/*
+ * generic function for inserting data into the posts table.
+ */
+function wp_insert_post($postarr = array()) {
+ global $wpdb, $allowedtags, $user_ID;
+
+ // export array as variables
+ extract($postarr);
+
+ // Are we updating or creating?
+ $update = false;
+ if ( !empty($ID) ) {
+ $update = true;
+ $post = & get_post($ID);
+ $previous_status = $post->post_status;
+ }
+
+ // Get the basics.
+ $post_content = apply_filters('content_save_pre', $post_content);
+ $post_excerpt = apply_filters('excerpt_save_pre', $post_excerpt);
+ $post_title = apply_filters('title_save_pre', $post_title);
+ $post_category = apply_filters('category_save_pre', $post_category);
+ $post_status = apply_filters('status_save_pre', $post_status);
+ $post_name = apply_filters('name_save_pre', $post_name);
+
+ // Make sure we set a valid category
+ if (0 == count($post_category) || !is_array($post_category)) {
+ $post_category = array(get_option('default_category'));
+ }
+ $post_cat = $post_category[0];
+
+ if ( empty($post_author) )
+ $post_author = $user_ID;
+
+ if ( empty($post_status) )
+ $post_status = 'draft';
+
+ // Get the post ID.
+ if ( $update ) {
+ $post_ID = $ID;
+ } else {
+ $id_result = $wpdb->get_row("SHOW TABLE STATUS LIKE '$wpdb->posts'");
+ $post_ID = $id_result->Auto_increment;
+ }
+
+ // Create a valid post name. Drafts are allowed to have an empty
+ // post name.
+ if ( empty($post_name) ) {
+ if ( 'draft' != $post_status )
+ $post_name = sanitize_title($post_title, $post_ID);
+ } else {
+ $post_name = sanitize_title($post_name, $post_ID);
+ }
+
+ if (empty($post_date))
+ $post_date = current_time('mysql');
+ if (empty($post_date_gmt))
+ $post_date_gmt = current_time('mysql', 1);
+
+ if (empty($comment_status))
+ $comment_status = get_settings('default_comment_status');
+ if (empty($ping_status))
+ $ping_status = get_settings('default_ping_status');
+ if ( empty($post_pingback) )
+ $post_pingback = get_option('default_pingback_flag');
+
+ if ( isset($to_ping) )
+ $to_ping = preg_replace('|\s+|', "\n", $to_ping);
+ else
+ $to_ping = '';
+
+ if ( isset($post_parent) )
+ $post_parent = (int) $post_parent;
+ else
+ $post_parent = 0;
+
+ if ( isset($menu_order) )
+ $menu_order = (int) $menu_order;
+ else
+ $menu_order = 0;
+
+ if ( !isset($post_password) )
+ $post_password = '';
+
+ if ('publish' == $post_status) {
+ $post_name_check = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'publish' AND ID != '$post_ID' LIMIT 1");
+ if ($post_name_check) {
+ $suffix = 2;
+ while ($post_name_check) {
+ $alt_post_name = $post_name . "-$suffix";
+ $post_name_check = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'publish' AND ID != '$post_ID' LIMIT 1");
+ $suffix++;
+ }
+ $post_name = $alt_post_name;
+ }
+ }
+
+ if ($update) {
+ $postquery =
+ "UPDATE $wpdb->posts SET
+ post_author = '$post_author',
+ post_date = '$post_date',
+ post_date_gmt = '$post_date_gmt',
+ post_content = '$post_content',
+ post_title = '$post_title',
+ post_excerpt = '$post_excerpt',
+ post_status = '$post_status',
+ comment_status = '$comment_status',
+ ping_status = '$ping_status',
+ post_password = '$post_password',
+ post_name = '$post_name',
+ to_ping = '$to_ping',
+ post_modified = '$post_date',
+ post_modified_gmt = '$post_date_gmt',
+ post_parent = '$post_parent',
+ menu_order = '$menu_order'
+ WHERE ID = $post_ID";
+ } else {
+ $postquery =
+ "INSERT INTO $wpdb->posts
+ (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt, post_parent, menu_order)
+ VALUES
+ ('$post_ID', '$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order')";
+ }
+
+ $result = $wpdb->query($postquery);
+ if ( $update )
+ $rval = $wpdb->rows_affected;
+ else
+ $rval = $wpdb->insert_id;
+
+ // Set GUID
+ if ( ! $update )
+ $wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'");
+
+ wp_set_post_cats('', $post_ID, $post_category);
+
+ if ( $update) {
+ if ($previous_status != 'publish' && $post_status == 'publish')
+ do_action('private_to_published', $post_ID);
+
+ do_action('edit_post', $post_ID);
+ }
+
+ if ($post_status == 'publish') {
+ do_action('publish_post', $post_ID);
+ if ($post_pingback)
+ pingback($post_content, $post_ID);
+ do_enclose( $post_content, $post_ID );
+ do_trackbacks($post_ID);
+ } else if ($post_status == 'static') {
+ generate_page_rewrite_rules();
+
+ if ( empty($page_template) )
+ $page_template = 'Default Template';
+
+ if ( ! update_post_meta($post_ID, '_wp_page_template', $page_template))
+ add_post_meta($post_ID, '_wp_page_template', $page_template, true);
+ }
+
+ return $rval;
+}
+
+function wp_get_single_post($postid = 0, $mode = OBJECT) {
+ global $wpdb;
+
+ $post = get_post($postid, $mode);
+
+ // Set categories
+ if($mode == OBJECT) {
+ $post->post_category = wp_get_post_cats('',$postid);
+ }
+ else {
+ $post['post_category'] = wp_get_post_cats('',$postid);
+ }
+
+ return $post;
+}
+
+function wp_get_recent_posts($num = 10) {
+ global $wpdb;
+
+ // Set the limit clause, if we got a limit
+ if ($num) {
+ $limit = "LIMIT $num";
+ }
+
+ $sql = "SELECT * FROM $wpdb->posts WHERE post_status IN ('publish', 'draft', 'private') ORDER BY post_date DESC $limit";
+ $result = $wpdb->get_results($sql,ARRAY_A);
+
+ return $result?$result:array();
+}
+
+function wp_update_post($postarr = array()) {
+ global $wpdb;
+
+ // First, get all of the original fields
+ $post = wp_get_single_post($postarr['ID'], ARRAY_A);
+
+ // Escape data pulled from DB.
+ $post = add_magic_quotes($post);
+
+ // Passed post category list overwrites existing category list if not empty.
+ if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
+ && 0 != count($postarr['post_category']) )
+ $post_cats = $postarr['post_category'];
+ else
+ $post_cats = $post['post_category'];
+
+ // Merge old and new fields with new fields overwriting old ones.
+ $postarr = array_merge($post, $postarr);
+ $postarr['post_category'] = $post_cats;
+
+ return wp_insert_post($postarr);
+}
+
+function wp_get_post_cats($blogid = '1', $post_ID = 0) {
+ global $wpdb;
+
+ $sql = "SELECT category_id
+ FROM $wpdb->post2cat
+ WHERE post_id = $post_ID
+ ORDER BY category_id";
+
+ $result = $wpdb->get_col($sql);
+
+ if ( !$result )
+ $result = array();
+
+ return array_unique($result);
+}
+
+function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
+ global $wpdb;
+ // If $post_categories isn't already an array, make it one:
+ if (!is_array($post_categories) || 0 == count($post_categories))
+ $post_categories = array(get_option('default_category'));
+
+ $post_categories = array_unique($post_categories);
+
+ // First the old categories
+ $old_categories = $wpdb->get_col("
+ SELECT category_id
+ FROM $wpdb->post2cat
+ WHERE post_id = $post_ID");
+
+ if (!$old_categories) {
+ $old_categories = array();
+ } else {
+ $old_categories = array_unique($old_categories);
+ }
+
+
+ $oldies = printr($old_categories,1);
+ $newbies = printr($post_categories,1);
+
+ // Delete any?
+ $delete_cats = array_diff($old_categories,$post_categories);
+
+ if ($delete_cats) {
+ foreach ($delete_cats as $del) {
+ $wpdb->query("
+ DELETE FROM $wpdb->post2cat
+ WHERE category_id = $del
+ AND post_id = $post_ID
+ ");
+ }
+ }
+
+ // Add any?
+ $add_cats = array_diff($post_categories, $old_categories);
+
+ if ($add_cats) {
+ foreach ($add_cats as $new_cat) {
+ $wpdb->query("
+ INSERT INTO $wpdb->post2cat (post_id, category_id)
+ VALUES ($post_ID, $new_cat)");
+ }
+ }
+} // wp_set_post_cats()
+
+function wp_delete_post($postid = 0) {
+ global $wpdb;
+ $postid = (int) $postid;
+
+ if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") )
+ return $post;
+
+ if ( 'static' == $post->post_status )
+ $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_status = 'static'");
+
+ $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid");
+
+ $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = $postid");
+
+ $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = $postid");
+
+ $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid");
+
+ if ( 'static' == $post->post_status )
+ generate_page_rewrite_rules();
+
+ do_action('delete_post', $postid);
+
+ return $post;
+}
+
+/**** /DB Functions ****/
+
+/**** Misc ****/
+
+// get permalink from post ID
+function post_permalink($post_id = 0, $mode = '') { // $mode legacy
+ return get_permalink($post_id);
+}
+
+// Get the name of a category from its ID
+function get_cat_name($cat_id) {
+ global $wpdb;
+
+ $cat_id -= 0; // force numeric
+ $name = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID=$cat_id");
+
+ return $name;
+}
+
+// Get the ID of a category from its name
+function get_cat_ID($cat_name='General') {
+ global $wpdb;
+
+ $cid = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
+
+ return $cid?$cid:1; // default to cat 1
+}
+
+// Get author's preferred display name
+function get_author_name( $auth_id ) {
+ $authordata = get_userdata( $auth_id );
+
+ return $authordata->display_name;
+}
+
+// get extended entry info (<!--more-->)
+function get_extended($post) {
+ list($main,$extended) = explode('<!--more-->', $post, 2);
+
+ // Strip leading and trailing whitespace
+ $main = preg_replace('/^[\s]*(.*)[\s]*$/','\\1',$main);
+ $extended = preg_replace('/^[\s]*(.*)[\s]*$/','\\1',$extended);
+
+ return array('main' => $main, 'extended' => $extended);
+}
+
+// do trackbacks for a list of urls
+// borrowed from edit.php
+// accepts a comma-separated list of trackback urls and a post id
+function trackback_url_list($tb_list, $post_id) {
+ if (!empty($tb_list)) {
+ // get post data
+ $postdata = wp_get_single_post($post_id, ARRAY_A);
+
+ // import postdata as variables
+ extract($postdata);
+
+ // form an excerpt
+ $excerpt = strip_tags($post_excerpt?$post_excerpt:$post_content);
+
+ if (strlen($excerpt) > 255) {
+ $excerpt = substr($excerpt,0,252) . '...';
+ }
+
+ $trackback_urls = explode(',', $tb_list);
+ foreach($trackback_urls as $tb_url) {
+ $tb_url = trim($tb_url);
+ trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
+ }
+ }
+}
+
+
+// query user capabilities
+// rather simplistic. shall evolve with future permission system overhaul
+// $blog_id and $category_id are there for future usage
+
+/* returns true if $user_id can create a new post */
+function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
+ $author_data = get_userdata($user_id);
+ return ($author_data->user_level > 1);
+}
+
+/* returns true if $user_id can create a new post */
+function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
+ $author_data = get_userdata($user_id);
+ return ($author_data->user_level >= 1);
+}
+
+/* returns true if $user_id can edit $post_id */
+function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
+ $author_data = get_userdata($user_id);
+ $post = get_post($post_id);
+ $post_author_data = get_userdata($post->post_author);
+
+ if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2))
+ || ($author_data->user_level > $post_author_data->user_level)
+ || ($author_data->user_level >= 10) ) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/* returns true if $user_id can delete $post_id */
+function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
+ // right now if one can edit, one can delete
+ return user_can_edit_post($user_id, $post_id, $blog_id);
+}
+
+/* returns true if $user_id can set new posts' dates on $blog_id */
+function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
+ $author_data = get_userdata($user_id);
+ return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
+}
+
+/* returns true if $user_id can edit $post_id's date */
+function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
+ $author_data = get_userdata($user_id);
+ return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
+}
+
+/* returns true if $user_id can edit $post_id's comments */
+function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
+ // right now if one can edit a post, one can edit comments made on it
+ return user_can_edit_post($user_id, $post_id, $blog_id);
+}
+
+/* returns true if $user_id can delete $post_id's comments */
+function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
+ // right now if one can edit comments, one can delete comments
+ return user_can_edit_post_comments($user_id, $post_id, $blog_id);
+}
+
+function user_can_edit_user($user_id, $other_user) {
+ $user = get_userdata($user_id);
+ $other = get_userdata($other_user);
+ if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID )
+ return true;
+ else
+ return false;
+}
+
+function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {
+ global $wpdb;
+
+ do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent);
+
+ if ( preg_match_all('/&#(\d+);/', $comment . $author . $url, $chars) ) {
+ foreach ($chars[1] as $char) {
+ // If it's an encoded char in the normal ASCII set, reject
+ if ($char < 128)
+ return true;
+ }
+ }
+
+ $mod_keys = trim( get_settings('blacklist_keys') );
+ if ('' == $mod_keys )
+ return false; // If moderation keys are empty
+ $words = explode("\n", $mod_keys );
+
+ foreach ($words as $word) {
+ $word = trim($word);
+
+ // Skip empty lines
+ if ( empty($word) ) { continue; }
+
+ // Do some escaping magic so that '#' chars in the
+ // spam words don't break things:
+ $word = preg_quote($word, '#');
+
+ $pattern = "#$word#i";
+ if ( preg_match($pattern, $author ) ) return true;
+ if ( preg_match($pattern, $email ) ) return true;
+ if ( preg_match($pattern, $url ) ) return true;
+ if ( preg_match($pattern, $comment ) ) return true;
+ if ( preg_match($pattern, $user_ip ) ) return true;
+ if ( preg_match($pattern, $user_agent) ) return true;
+ }
+
+ if ( isset($_SERVER['REMOTE_ADDR']) ) {
+ if ( wp_proxy_check($_SERVER['REMOTE_ADDR']) ) return true;
+ }
+
+ return false;
+}
+
+function wp_proxy_check($ipnum) {
+ if ( get_option('open_proxy_check') && isset($ipnum) ) {
+ $rev_ip = implode( '.', array_reverse( explode( '.', $ipnum ) ) );
+ $lookup = $rev_ip . '.opm.blitzed.org';
+ if ( $lookup != gethostbyname( $lookup ) )
+ return true;
+ }
+
+ return false;
+}
+
+function wp_new_comment( $commentdata, $spam = false ) {
+ global $wpdb;
+
+ $commentdata = apply_filters('preprocess_comment', $commentdata);
+ extract($commentdata);
+
+ $comment_post_ID = (int) $comment_post_ID;
+
+ $user_id = apply_filters('pre_user_id', $user_ID);
+ $author = apply_filters('pre_comment_author_name', $comment_author);
+ $email = apply_filters('pre_comment_author_email', $comment_author_email);
+ $url = apply_filters('pre_comment_author_url', $comment_author_url);
+ $comment = apply_filters('pre_comment_content', $comment_content);
+ $comment = apply_filters('post_comment_text', $comment); // Deprecated
+ $comment = apply_filters('comment_content_presave', $comment); // Deprecated
+
+ $user_ip = apply_filters('pre_comment_user_ip', $_SERVER['REMOTE_ADDR']);
+ $user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($user_ip) );
+ $user_agent = apply_filters('pre_comment_user_agent', $_SERVER['HTTP_USER_AGENT']);
+
+ $now = current_time('mysql');
+ $now_gmt = current_time('mysql', 1);
+
+ if ( $user_id ) {
+ $userdata = get_userdata($user_id);
+ $post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1");
+ }
+
+ // Simple duplicate check
+ $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$author' ";
+ if ( $email ) $dupe .= "OR comment_author_email = '$email' ";
+ $dupe .= ") AND comment_content = '$comment' LIMIT 1";
+ if ( $wpdb->get_var($dupe) )
+ die( __('Duplicate comment detected; it looks as though you\'ve already said that!') );
+
+ // Simple flood-protection
+ if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$user_ip' OR comment_author_email = '$email' ORDER BY comment_date DESC LIMIT 1") ) {
+ $time_lastcomment = mysql2date('U', $lasttime);
+ $time_newcomment = mysql2date('U', $now_gmt);
+ if ( ($time_newcomment - $time_lastcomment) < 15 ) {
+ do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
+ die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') );
+ }
+ }
+
+ if ( $userdata && ( $user_id == $post_author || $userdata->user_level >= 9 ) ) {
+ $approved = 1;
+ } else {
+ if ( check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) )
+ $approved = 1;
+ else
+ $approved = 0;
+ if ( wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) )
+ $approved = 'spam';
+ }
+
+ $approved = apply_filters('pre_comment_approved', $approved);
+
+ $result = $wpdb->query("INSERT INTO $wpdb->comments
+ (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, user_id)
+ VALUES
+ ('$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$now_gmt', '$comment', '$approved', '$user_agent', '$comment_type', '$user_id')
+ ");
+
+ $comment_id = $wpdb->insert_id;
+ do_action('comment_post', $comment_id, $approved);
+
+ if ( 'spam' !== $approved ) { // If it's spam save it silently for later crunching
+ if ( '0' == $approved )
+ wp_notify_moderator($comment_id);
+
+ if ( get_settings('comments_notify') && $approved )
+ wp_notify_postauthor($comment_id, $comment_type);
+ }
+
+ return $result;
+}
+
+function wp_update_comment($commentarr) {
+ global $wpdb;
+
+ // First, get all of the original fields
+ $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
+
+ // Escape data pulled from DB.
+ foreach ($comment as $key => $value)
+ $comment[$key] = $wpdb->escape($value);
+
+ // Merge old and new fields with new fields overwriting old ones.
+ $commentarr = array_merge($comment, $commentarr);
+
+ // Now extract the merged array.
+ extract($commentarr);
+
+ $comment_content = apply_filters('comment_save_pre', $comment_content);
+
+ $result = $wpdb->query(
+ "UPDATE $wpdb->comments SET
+ comment_content = '$comment_content',
+ comment_author = '$comment_author',
+ comment_author_email = '$comment_author_email',
+ comment_approved = '$comment_approved',
+ comment_author_url = '$comment_author_url',
+ comment_date = '$comment_date'
+ WHERE comment_ID = $comment_ID" );
+
+ $rval = $wpdb->rows_affected;
+
+ do_action('edit_comment', $comment_ID);
+
+ return $rval;
+}
+
+function do_trackbacks($post_id) {
+ global $wpdb;
+
+ $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $post_id");
+ $to_ping = get_to_ping($post_id);
+ $pinged = get_pung($post_id);
+ if ( empty($to_ping) )
+ return;
+ if (empty($post->post_excerpt))
+ $excerpt = apply_filters('the_content', $post->post_content);
+ else
+ $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
+ $excerpt = str_replace(']]>', ']]&gt;', $excerpt);
+ $excerpt = strip_tags($excerpt);
+ $excerpt = substr($excerpt, 0, 252) . '...';
+
+ $post_title = apply_filters('the_title', $post->post_title);
+ $post_title = strip_tags($post_title);
+
+ if ($to_ping) : foreach ($to_ping as $tb_ping) :
+ $tb_ping = trim($tb_ping);
+ if ( !in_array($tb_ping, $pinged) )
+ trackback($tb_ping, $post_title, $excerpt, $post_id);
+ endforeach; endif;
+}
+
+function get_pung($post_id) { // Get URIs already pung for a post
+ global $wpdb;
+ $pung = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_id");
+ $pung = trim($pung);
+ $pung = preg_split('/\s/', $pung);
+ return $pung;
+}
+
+function get_enclosed($post_id) { // Get enclosures already enclosed for a post
+ global $wpdb;
+ $custom_fields = get_post_custom( $post_id );
+ $pung = array();
+ if( is_array( $custom_fields ) ) {
+ while( list( $key, $val ) = each( $custom_fields ) ) {
+ if( $key == 'enclosure' ) {
+ if (is_array($val)) {
+ foreach($val as $enc) {
+ $enclosure = split( "\n", $enc );
+ $pung[] = trim( $enclosure[ 0 ] );
+ }
+ }
+ }
+ }
+ }
+ return $pung;
+}
+
+function get_to_ping($post_id) { // Get any URIs in the todo list
+ global $wpdb;
+ $to_ping = $wpdb->get_var("SELECT to_ping FROM $wpdb->posts WHERE ID = $post_id");
+ $to_ping = trim($to_ping);
+ $to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY);
+ return $to_ping;
+}
+
+function add_ping($post_id, $uri) { // Add a URI to those already pung
+ global $wpdb;
+ $pung = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_id");
+ $pung = trim($pung);
+ $pung = preg_split('/\s/', $pung);
+ $pung[] = $uri;
+ $new = implode("\n", $pung);
+ return $wpdb->query("UPDATE $wpdb->posts SET pinged = '$new' WHERE ID = $post_id");
+}
+
+function generate_page_rewrite_rules() {
+ global $wpdb;
+ $posts = $wpdb->get_results("SELECT ID, post_name FROM $wpdb->posts WHERE post_status = 'static' ORDER BY post_parent DESC");
+
+ $page_rewrite_rules = array();
+
+ if ($posts) {
+ foreach ($posts as $post) {
+ // URI => page name
+ $uri = get_page_uri($post->ID);
+
+ $page_rewrite_rules[$uri] = $post->post_name;
+ }
+
+ update_option('page_uris', $page_rewrite_rules);
+
+ save_mod_rewrite_rules();
+ }
+}
+
+?>
diff --git a/wp-inst/wp-includes/functions.php b/wp-inst/wp-includes/functions.php
new file mode 100644
index 0000000..af027d7
--- /dev/null
+++ b/wp-inst/wp-includes/functions.php
@@ -0,0 +1,2000 @@
+<?php
+
+require_once(dirname(__FILE__).'/functions-compat.php');
+
+if (!function_exists('_')) {
+ function _($string) {
+ return $string;
+ }
+}
+
+function get_profile($field, $user = false) {
+ global $wpdb;
+ if (!$user)
+ $user = $wpdb->escape($_COOKIE['wordpressuser_' . COOKIEHASH]);
+ return $wpdb->get_var("SELECT $field FROM $wpdb->users WHERE user_login = '$user'");
+}
+
+function mysql2date($dateformatstring, $mysqlstring, $translate = true) {
+ global $month, $weekday, $month_abbrev, $weekday_abbrev;
+ $m = $mysqlstring;
+ if (empty($m)) {
+ return false;
+ }
+ $i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4));
+ if (!empty($month) && !empty($weekday) && $translate) {
+ $datemonth = $month[date('m', $i)];
+ $datemonth_abbrev = $month_abbrev[$datemonth];
+ $dateweekday = $weekday[date('w', $i)];
+ $dateweekday_abbrev = $weekday_abbrev[$dateweekday];
+ $dateformatstring = ' '.$dateformatstring;
+ $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
+
+ $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
+ }
+ $j = @date($dateformatstring, $i);
+ if (!$j) {
+ // for debug purposes
+ // echo $i." ".$mysqlstring;
+ }
+ return $j;
+}
+
+function current_time($type, $gmt = 0) {
+ switch ($type) {
+ case 'mysql':
+ if ($gmt) $d = gmdate('Y-m-d H:i:s');
+ else $d = gmdate('Y-m-d H:i:s', (time() + (get_settings('gmt_offset') * 3600)));
+ return $d;
+ break;
+ case 'timestamp':
+ if ($gmt) $d = time();
+ else $d = time() + (get_settings('gmt_offset') * 3600);
+ return $d;
+ break;
+ }
+}
+
+function date_i18n($dateformatstring, $unixtimestamp) {
+ global $month, $weekday, $month_abbrev, $weekday_abbrev;
+ $i = $unixtimestamp;
+ if ((!empty($month)) && (!empty($weekday))) {
+ $datemonth = $month[date('m', $i)];
+ $datemonth_abbrev = $month_abbrev[$datemonth];
+ $dateweekday = $weekday[date('w', $i)];
+ $dateweekday_abbrev = $weekday_abbrev[$dateweekday];
+ $dateformatstring = ' '.$dateformatstring;
+ $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
+ $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
+ $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
+ }
+ $j = @date($dateformatstring, $i);
+ return $j;
+ }
+
+function get_weekstartend($mysqlstring, $start_of_week) {
+ $my = substr($mysqlstring,0,4);
+ $mm = substr($mysqlstring,8,2);
+ $md = substr($mysqlstring,5,2);
+ $day = mktime(0,0,0, $md, $mm, $my);
+ $weekday = date('w',$day);
+ $i = 86400;
+
+ if ($weekday < get_settings('start_of_week'))
+ $weekday = 7 - (get_settings('start_of_week') - $weekday);
+
+ while ($weekday > get_settings('start_of_week')) {
+ $weekday = date('w',$day);
+ if ($weekday < get_settings('start_of_week'))
+ $weekday = 7 - (get_settings('start_of_week') - $weekday);
+
+ $day = $day - 86400;
+ $i = 0;
+ }
+ $week['start'] = $day + 86400 - $i;
+ //$week['end'] = $day - $i + 691199;
+ $week['end'] = $week['start'] + 604799;
+ return $week;
+}
+
+function get_lastpostdate($timezone = 'server') {
+ global $cache_lastpostdate, $pagenow, $wpdb;
+ $add_seconds_blog = get_settings('gmt_offset') * 3600;
+ $add_seconds_server = date('Z');
+ $now = current_time('mysql', 1);
+ if ( !isset($cache_lastpostdate[$timezone]) ) {
+ switch(strtolower($timezone)) {
+ case 'gmt':
+ $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
+ break;
+ case 'blog':
+ $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
+ break;
+ case 'server':
+ $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
+ break;
+ }
+ $cache_lastpostdate[$timezone] = $lastpostdate;
+ } else {
+ $lastpostdate = $cache_lastpostdate[$timezone];
+ }
+ return $lastpostdate;
+}
+
+function get_lastpostmodified($timezone = 'server') {
+ global $cache_lastpostmodified, $pagenow, $wpdb;
+ $add_seconds_blog = get_settings('gmt_offset') * 3600;
+ $add_seconds_server = date('Z');
+ $now = current_time('mysql', 1);
+ if ( !isset($cache_lastpostmodified[$timezone]) ) {
+ switch(strtolower($timezone)) {
+ case 'gmt':
+ $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
+ break;
+ case 'blog':
+ $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
+ break;
+ case 'server':
+ $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
+ break;
+ }
+ $lastpostdate = get_lastpostdate($timezone);
+ if ($lastpostdate > $lastpostmodified) {
+ $lastpostmodified = $lastpostdate;
+ }
+ $cache_lastpostmodified[$timezone] = $lastpostmodified;
+ } else {
+ $lastpostmodified = $cache_lastpostmodified[$timezone];
+ }
+ return $lastpostmodified;
+}
+
+function user_pass_ok($user_login,$user_pass) {
+ global $cache_userdata;
+ if ( empty($cache_userdata[$user_login]) ) {
+ $userdata = get_userdatabylogin($user_login);
+ } else {
+ $userdata = $cache_userdata[$user_login];
+ }
+ return (md5($user_pass) == $userdata->user_pass);
+}
+
+
+function get_usernumposts($userid) {
+ global $wpdb;
+ return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_status = 'publish'");
+}
+
+
+// examine a url (supposedly from this blog) and try to
+// determine the post ID it represents.
+function url_to_postid($url) {
+ global $wp_rewrite;
+
+ // First, check to see if there is a 'p=N' or 'page_id=N' to match against
+ preg_match('#[?&](p|page_id)=(\d+)#', $url, $values);
+ $id = intval($values[2]);
+ if ($id) return $id;
+
+ // Check to see if we are using rewrite rules
+ $rewrite = $wp_rewrite->wp_rewrite_rules();
+
+ // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
+ if ( empty($rewrite) )
+ return 0;
+
+ // $url cleanup by Mark Jaquith
+ // This fixes things like #anchors, ?query=strings, missing 'www.',
+ // added 'www.', or added 'index.php/' that will mess up our WP_Query
+ // and return a false negative
+
+ // Get rid of the #anchor
+ $url_split = explode('#', $url);
+ $url = $url_split[0];
+
+ // Get rid of URI ?query=string
+ $url_split = explode('?', $url);
+ $url = $url_split[0];
+
+ // Add 'www.' if it is absent and should be there
+ if ( false !== strpos(get_settings('home'), '://www.') && false === strpos($url, '://www.') )
+ $url = str_replace('://', '://www.', $url);
+
+ // Strip 'www.' if it is present and shouldn't be
+ if ( false === strpos(get_settings('home'), '://www.') )
+ $url = str_replace('://www.', '://', $url);
+
+ // Strip 'index.php/' if we're not using path info permalinks
+ if ( false === strpos($rewrite, 'index.php/') )
+ $url = str_replace('index.php/', '', $url);
+
+ // Chop off http://domain.com
+ if ( false !== strpos($url, get_settings('home')) ) {
+ $url = str_replace(get_settings('home'), '', $url);
+ } else {
+ // Chop off /path/to/blog
+ $home_path = parse_url(get_settings('home'));
+ $home_path = $home_path['path'];
+ $url = str_replace($home_path, '', $url);
+ }
+
+ // Trim leading and lagging slashes
+ $url = trim($url, '/');
+
+ $request = $url;
+
+ // Done with cleanup
+
+ // Look for matches.
+ $request_match = $request;
+ foreach ($rewrite as $match => $query) {
+ // If the requesting file is the anchor of the match, prepend it
+ // to the path info.
+ if ((! empty($url)) && (strpos($match, $url) === 0)) {
+ $request_match = $url . '/' . $request;
+ }
+
+ if (preg_match("!^$match!", $request_match, $matches)) {
+ // Got a match.
+ // Trim the query of everything up to the '?'.
+ $query = preg_replace("!^.+\?!", '', $query);
+
+ // Substitute the substring matches into the query.
+ eval("\$query = \"$query\";");
+ $query = new WP_Query($query);
+ if ( $query->is_post || $query->is_page )
+ return $query->post->ID;
+ else
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
+
+/* Options functions */
+
+function get_settings($setting) {
+ global $wpdb, $cache_settings, $cache_nonexistantoptions;
+ if ( strstr($_SERVER['REQUEST_URI'], 'wp-admin/install.php') || defined('WP_INSTALLING') )
+ return false;
+
+ if ( empty($cache_settings) )
+ $cache_settings = get_alloptions();
+
+ if ( empty($cache_nonexistantoptions) )
+ $cache_nonexistantoptions = array();
+
+ if ('home' == $setting && '' == $cache_settings->home)
+ return apply_filters('option_' . $setting, $cache_settings->siteurl);
+
+ if ( isset($cache_settings->$setting) ) :
+ return apply_filters('option_' . $setting, $cache_settings->$setting);
+ else :
+ // for these cases when we're asking for an unknown option
+ if ( isset($cache_nonexistantoptions[$setting]) )
+ return false;
+
+ $option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
+
+ if (!$option) :
+ $cache_nonexistantoptions[$setting] = true;
+ return false;
+ endif;
+
+ @ $kellogs = unserialize($option);
+ if ($kellogs !== FALSE)
+ return apply_filters('option_' . $setting, $kellogs);
+ else return apply_filters('option_' . $setting, $option);
+ endif;
+}
+
+function get_option($option) {
+ return get_settings($option);
+}
+
+function form_option($option) {
+ echo htmlspecialchars( get_option($option), ENT_QUOTES );
+}
+
+function get_alloptions() {
+ global $wpdb, $wp_queries;
+ $wpdb->hide_errors();
+ if (!$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'")) {
+ $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
+ }
+ $wpdb->show_errors();
+
+ foreach ($options as $option) {
+ // "When trying to design a foolproof system,
+ // never underestimate the ingenuity of the fools :)" -- Dougal
+ if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ @ $value = unserialize($option->option_value);
+ if ($value === FALSE)
+ $value = $option->option_value;
+ $all_options->{$option->option_name} = apply_filters('pre_option_' . $option->option_name, $value);
+ }
+ return apply_filters('all_options', $all_options);
+}
+
+function update_option($option_name, $newvalue) {
+ global $wpdb, $cache_settings;
+ if ( is_array($newvalue) || is_object($newvalue) )
+ $newvalue = serialize($newvalue);
+
+ $newvalue = trim($newvalue); // I can't think of any situation we wouldn't want to trim
+
+ // If the new and old values are the same, no need to update.
+ if ($newvalue == get_option($option_name)) {
+ return true;
+ }
+
+ // If it's not there add it
+ if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$option_name'") )
+ add_option($option_name);
+
+ $newvalue = $wpdb->escape($newvalue);
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'");
+ $cache_settings = get_alloptions(); // Re cache settings
+ return true;
+}
+
+
+// thx Alex Stapleton, http://alex.vort-x.net/blog/
+function add_option($name, $value = '', $description = '', $autoload = 'yes') {
+ global $wpdb;
+ $original = $value;
+ if ( is_array($value) || is_object($value) )
+ $value = serialize($value);
+
+ if( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$name'") ) {
+ $name = $wpdb->escape($name);
+ $value = $wpdb->escape($value);
+ $description = $wpdb->escape($description);
+ $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, option_description, autoload) VALUES ('$name', '$value', '$description', '$autoload')");
+
+ if($wpdb->insert_id) {
+ global $cache_settings;
+ $cache_settings->{$name} = $original;
+ }
+ }
+ return;
+}
+
+function delete_option($name) {
+ global $wpdb;
+ // Get the ID, if no ID then return
+ $option_id = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = '$name'");
+ if (!$option_id) return false;
+ $wpdb->query("DELETE FROM $wpdb->options WHERE option_name = '$name'");
+ return true;
+}
+
+function add_post_meta($post_id, $key, $value, $unique = false) {
+ global $wpdb;
+
+ if ($unique) {
+ if( $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
+= '$key' AND post_id = '$post_id'") ) {
+ return false;
+ }
+ }
+
+ $wpdb->query("INSERT INTO $wpdb->postmeta
+ (post_id,meta_key,meta_value)
+ VALUES ('$post_id','$key','$value')
+ ");
+
+ return true;
+}
+
+function delete_post_meta($post_id, $key, $value = '') {
+ global $wpdb;
+
+ if (empty($value)) {
+ $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE
+post_id = '$post_id' AND meta_key = '$key'");
+ } else {
+ $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE
+post_id = '$post_id' AND meta_key = '$key' AND meta_value = '$value'");
+ }
+
+ if (!$meta_id) return false;
+
+ if (empty($value)) {
+ $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
+AND meta_key = '$key'");
+ } else {
+ $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
+AND meta_key = '$key' AND meta_value = '$value'");
+ }
+
+ return true;
+}
+
+function get_post_meta($post_id, $key, $single = false) {
+ global $wpdb, $post_meta_cache;
+
+ if (isset($post_meta_cache[$post_id][$key])) {
+ if ($single) {
+ return $post_meta_cache[$post_id][$key][0];
+ } else {
+ return $post_meta_cache[$post_id][$key];
+ }
+ }
+
+ $metalist = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = '$post_id' AND meta_key = '$key'", ARRAY_N);
+
+ $values = array();
+ if ($metalist) {
+ foreach ($metalist as $metarow) {
+ $values[] = $metarow[0];
+ }
+ }
+
+ if ($single) {
+ if (count($values)) {
+ return $values[0];
+ } else {
+ return '';
+ }
+ } else {
+ return $values;
+ }
+}
+
+function update_post_meta($post_id, $key, $value, $prev_value = '') {
+ global $wpdb, $post_meta_cache;
+
+ if(! $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
+= '$key' AND post_id = '$post_id'") ) {
+ return false;
+ }
+
+ if (empty($prev_value)) {
+ $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
+meta_key = '$key' AND post_id = '$post_id'");
+ } else {
+ $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
+meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'");
+ }
+
+ return true;
+}
+
+// Deprecated. Use get_post().
+function get_postdata($postid) {
+ $post = &get_post($postid);
+
+ $postdata = array (
+ 'ID' => $post->ID,
+ 'Author_ID' => $post->post_author,
+ 'Date' => $post->post_date,
+ 'Content' => $post->post_content,
+ 'Excerpt' => $post->post_excerpt,
+ 'Title' => $post->post_title,
+ 'Category' => $post->post_category,
+ 'post_status' => $post->post_status,
+ 'comment_status' => $post->comment_status,
+ 'ping_status' => $post->ping_status,
+ 'post_password' => $post->post_password,
+ 'to_ping' => $post->to_ping,
+ 'pinged' => $post->pinged,
+ 'post_name' => $post->post_name
+ );
+
+ return $postdata;
+}
+
+// Retrieves post data given a post ID or post object.
+// Handles post caching.
+function &get_post(&$post, $output = OBJECT) {
+ global $post_cache, $wpdb;
+
+ if ( empty($post) ) {
+ if ( isset($GLOBALS['post']) )
+ $_post = & $GLOBALS['post'];
+ else
+ $_post = null;
+ } elseif (is_object($post) ) {
+ if (! isset($post_cache[$post->ID]))
+ $post_cache[$post->ID] = &$post;
+ $_post = & $post_cache[$post->ID];
+ } else {
+ if (isset($post_cache[$post]))
+ $_post = & $post_cache[$post];
+ else {
+ $query = "SELECT * FROM $wpdb->posts WHERE ID = '$post'";
+ $post_cache[$post] = & $wpdb->get_row($query);
+ $_post = & $post_cache[$post];
+ }
+ }
+
+ if ( $output == OBJECT ) {
+ return $_post;
+ } elseif ( $output == ARRAY_A ) {
+ return get_object_vars($_post);
+ } elseif ( $output == ARRAY_N ) {
+ return array_values(get_object_vars($_post));
+ } else {
+ return $_post;
+ }
+}
+
+// Retrieves page data given a page ID or page object.
+// Handles page caching.
+function &get_page(&$page, $output = OBJECT) {
+ global $page_cache, $wpdb;
+
+ if ( empty($page) ) {
+ if ( isset($GLOBALS['page']) )
+ $_page = & $GLOBALS['page'];
+ else
+ $_page = null;
+ } elseif (is_object($page) ) {
+ if (! isset($page_cache[$page->ID]))
+ $page_cache[$page->ID] = &$page;
+ $_page = & $page_cache[$page->ID];
+ } else {
+ if ( isset($GLOBALS['page']) && ($page == $GLOBALS['page']->ID) )
+ $_page = & $GLOBALS['page'];
+ elseif (isset($page_cache[$page]))
+ $_page = & $page_cache[$page];
+ else {
+ $query = "SELECT * FROM $wpdb->posts WHERE ID= '$page'";
+ $page_cache[$page] = & $wpdb->get_row($query);
+ $_page = & $page_cache[$page];
+ }
+ }
+
+ if ( $output == OBJECT ) {
+ return $_page;
+ } elseif ( $output == ARRAY_A ) {
+ return get_object_vars($_page);
+ } elseif ( $output == ARRAY_N ) {
+ return array_values(get_object_vars($_page));
+ } else {
+ return $_page;
+ }
+}
+
+// Retrieves category data given a category ID or category object.
+// Handles category caching.
+function &get_category(&$category, $output = OBJECT) {
+ global $cache_categories, $wpdb;
+
+ if ( empty($category) )
+ return null;
+
+ if ( ! isset($cache_categories))
+ update_category_cache();
+
+ if (is_object($category)) {
+ if ( ! isset($cache_categories[$category->cat_ID]))
+ $cache_categories[$category->cat_ID] = &$category;
+ $_category = & $cache_categories[$category->cat_ID];
+ } else {
+ if ( !isset($cache_categories[$category]) ) {
+ $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category'");
+ $cache_categories[$category->cat_ID] = & $_category;
+ } else {
+ $_category = & $cache_categories[$category];
+ }
+ }
+
+ if ( $output == OBJECT ) {
+ return $_category;
+ } elseif ( $output == ARRAY_A ) {
+ return get_object_vars($_category);
+ } elseif ( $output == ARRAY_N ) {
+ return array_values(get_object_vars($_category));
+ } else {
+ return $_category;
+ }
+}
+
+// Retrieves comment data given a comment ID or comment object.
+// Handles comment caching.
+function &get_comment(&$comment, $output = OBJECT) {
+ global $comment_cache, $wpdb;
+
+ if ( empty($comment) )
+ return null;
+
+ if (is_object($comment)) {
+ if ( ! isset($comment_cache[$comment->comment_ID]))
+ $comment_cache[$comment->comment_ID] = &$comment;
+ $_comment = & $comment_cache[$comment->comment_ID];
+ } else {
+ if ( !isset($comment_cache[$comment]) ) {
+ $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment'");
+ $comment_cache[$comment->comment_ID] = & $_comment;
+ } else {
+ $_comment = & $comment_cache[$comment];
+ }
+ }
+
+ if ( $output == OBJECT ) {
+ return $_comment;
+ } elseif ( $output == ARRAY_A ) {
+ return get_object_vars($_comment);
+ } elseif ( $output == ARRAY_N ) {
+ return array_values(get_object_vars($_comment));
+ } else {
+ return $_comment;
+ }
+}
+
+function get_catname($cat_ID) {
+ $category = &get_category($cat_ID);
+ return $category->cat_name;
+}
+
+function gzip_compression() {
+ if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) return false;
+ if ( !get_settings('gzipcompression') ) return false;
+
+ if( extension_loaded('zlib') ) {
+ ob_start('ob_gzhandler');
+ }
+}
+
+
+// functions to count the page generation time (from phpBB2)
+// ( or just any time between timer_start() and timer_stop() )
+
+function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
+ global $timestart, $timeend;
+ $mtime = microtime();
+ $mtime = explode(' ',$mtime);
+ $mtime = $mtime[1] + $mtime[0];
+ $timeend = $mtime;
+ $timetotal = $timeend-$timestart;
+ if ($display)
+ echo number_format($timetotal,$precision);
+ return $timetotal;
+}
+
+function weblog_ping($server = '', $path = '') {
+ global $wp_version;
+ include_once (ABSPATH . WPINC . '/class-IXR.php');
+
+ // using a timeout of 3 seconds should be enough to cover slow servers
+ $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
+ $client->timeout = 3;
+ $client->useragent .= ' -- WordPress/'.$wp_version;
+
+ // when set to true, this outputs debug messages by itself
+ $client->debug = false;
+ $home = trailingslashit( get_option('home') );
+ if ( !$client->query('weblogUpdates.extendedPing', get_settings('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping
+ $client->query('weblogUpdates.ping', get_settings('blogname'), $home);
+}
+
+function generic_ping($post_id = 0) {
+ $services = get_settings('ping_sites');
+ $services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines
+ $services = trim($services);
+ if ('' != $services) {
+ $services = explode("\n", $services);
+ foreach ($services as $service) {
+ weblog_ping($service);
+ }
+ }
+
+ return $post_id;
+}
+
+// Send a Trackback
+function trackback($trackback_url, $title, $excerpt, $ID) {
+ global $wpdb, $wp_version;
+
+ if (empty($trackback_url))
+ return;
+
+ $title = urlencode($title);
+ $excerpt = urlencode($excerpt);
+ $blog_name = urlencode(get_settings('blogname'));
+ $tb_url = $trackback_url;
+ $url = urlencode(get_permalink($ID));
+ $query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
+ $trackback_url = parse_url($trackback_url);
+ $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'.$trackback_url['query'] : '') . " HTTP/1.0\r\n";
+ $http_request .= 'Host: '.$trackback_url['host']."\r\n";
+ $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n";
+ $http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
+ $http_request .= "User-Agent: WordPress/" . $wp_version;
+ $http_request .= "\r\n\r\n";
+ $http_request .= $query_string;
+ if ( '' == $trackback_url['port'] )
+ $trackback_url['port'] = 80;
+ $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
+ @fputs($fs, $http_request);
+/*
+ $debug_file = 'trackback.log';
+ $fp = fopen($debug_file, 'a');
+ fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n");
+ while(!@feof($fs)) {
+ fwrite($fp, @fgets($fs, 4096));
+ }
+ fwrite($fp, "\n\n");
+ fclose($fp);
+*/
+ @fclose($fs);
+
+ $wpdb->query("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'");
+ $wpdb->query("UPDATE $wpdb->posts SET to_ping = REPLACE(to_ping, '$tb_url', '') WHERE ID = '$ID'");
+ return $result;
+}
+
+function make_url_footnote($content) {
+ preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches);
+ $j = 0;
+ for ($i=0; $i<count($matches[0]); $i++) {
+ $links_summary = (!$j) ? "\n" : $links_summary;
+ $j++;
+ $link_match = $matches[0][$i];
+ $link_number = '['.($i+1).']';
+ $link_url = $matches[2][$i];
+ $link_text = $matches[4][$i];
+ $content = str_replace($link_match, $link_text.' '.$link_number, $content);
+ $link_url = (strtolower(substr($link_url,0,7)) != 'http://') ? get_settings('home') . $link_url : $link_url;
+ $links_summary .= "\n".$link_number.' '.$link_url;
+ }
+ $content = strip_tags($content);
+ $content .= $links_summary;
+ return $content;
+}
+
+
+function xmlrpc_getposttitle($content) {
+ global $post_default_title;
+ if (preg_match('/<title>(.+?)<\/title>/is', $content, $matchtitle)) {
+ $post_title = $matchtitle[0];
+ $post_title = preg_replace('/<title>/si', '', $post_title);
+ $post_title = preg_replace('/<\/title>/si', '', $post_title);
+ } else {
+ $post_title = $post_default_title;
+ }
+ return $post_title;
+}
+
+function xmlrpc_getpostcategory($content) {
+ global $post_default_category;
+ if (preg_match('/<category>(.+?)<\/category>/is', $content, $matchcat)) {
+ $post_category = trim($matchcat[1], ',');
+ $post_category = explode(',', $post_category);
+ } else {
+ $post_category = $post_default_category;
+ }
+ return $post_category;
+}
+
+function xmlrpc_removepostdata($content) {
+ $content = preg_replace('/<title>(.+?)<\/title>/si', '', $content);
+ $content = preg_replace('/<category>(.+?)<\/category>/si', '', $content);
+ $content = trim($content);
+ return $content;
+}
+
+function debug_fopen($filename, $mode) {
+ global $debug;
+ if ($debug == 1) {
+ $fp = fopen($filename, $mode);
+ return $fp;
+ } else {
+ return false;
+ }
+}
+
+function debug_fwrite($fp, $string) {
+ global $debug;
+ if ($debug == 1) {
+ fwrite($fp, $string);
+ }
+}
+
+function debug_fclose($fp) {
+ global $debug;
+ if ($debug == 1) {
+ fclose($fp);
+ }
+}
+
+function do_enclose( $content, $post_ID ) {
+ global $wp_version, $wpdb;
+ include_once (ABSPATH . WPINC . '/class-IXR.php');
+
+ $log = debug_fopen(ABSPATH . '/enclosures.log', 'a');
+ $post_links = array();
+ debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n");
+
+ $pung = get_enclosed( $post_ID );
+
+ $ltrs = '\w';
+ $gunk = '/#~:.?+=&%@!\-';
+ $punc = '.:?\-';
+ $any = $ltrs . $gunk . $punc;
+
+ preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
+
+ debug_fwrite($log, 'Post contents:');
+ debug_fwrite($log, $content."\n");
+
+ foreach($post_links_temp[0] as $link_test) :
+ if ( !in_array($link_test, $pung) ) : // If we haven't pung it already
+ $test = parse_url($link_test);
+ if (isset($test['query']))
+ $post_links[] = $link_test;
+ elseif(($test['path'] != '/') && ($test['path'] != ''))
+ $post_links[] = $link_test;
+ endif;
+ endforeach;
+
+ foreach ($post_links as $url) :
+ if ( $url != '' && !$wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE post_id = '$post_ID' AND meta_key = 'enclosure' AND meta_value LIKE ('$url%')") ) {
+ if ( $headers = wp_get_http_headers( $url) ) {
+ $len = (int) $headers['content-length'];
+ $type = $wpdb->escape( $headers['content-type'] );
+ $allowed_types = array( 'video', 'audio' );
+ if( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
+ $meta_value = "$url\n$len\n$type\n";
+ $wpdb->query( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` )
+ VALUES ( '$post_ID', 'enclosure' , '$meta_value')" );
+ }
+ }
+ }
+ endforeach;
+}
+
+function wp_get_http_headers( $url ) {
+ set_time_limit( 60 );
+ $parts = parse_url( $url );
+ $file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : '');
+ $host = $parts['host'];
+ if ( !isset( $parts['port'] ) )
+ $parts['port'] = 80;
+
+ $head = "HEAD $file HTTP/1.1\r\nHOST: $host\r\n\r\n";
+
+ $fp = @fsockopen($host, $parts['port'], $err_num, $err_msg, 3);
+ if ( !$fp )
+ return false;
+
+ $response = '';
+ fputs( $fp, $head );
+ while ( !feof( $fp ) && strpos( $response, "\r\n\r\n" ) == false )
+ $response .= fgets( $fp, 2048 );
+ fclose( $fp );
+ preg_match_all('/(.*?): (.*)\r/', $response, $matches);
+ $count = count($matches[1]);
+ for ( $i = 0; $i < $count; $i++) {
+ $key = strtolower($matches[1][$i]);
+ $headers["$key"] = $matches[2][$i];
+ }
+
+ preg_match('/.*([0-9]{3}).*/', $response, $return);
+ $headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404
+ return $headers;
+}
+
+// Deprecated. Use the new post loop.
+function start_wp() {
+ global $wp_query, $post;
+
+ // Since the old style loop is being used, advance the query iterator here.
+ $wp_query->next_post();
+
+ setup_postdata($post);
+}
+
+// Setup global post data.
+function setup_postdata($post) {
+ global $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages, $wp_query;
+ global $pagenow;
+
+ $id = $post->ID;
+
+ $authordata = get_userdata($post->post_author);
+
+ $day = mysql2date('d.m.y', $post->post_date);
+ $currentmonth = mysql2date('m', $post->post_date);
+ $numpages = 1;
+ $page = get_query_var('page');
+ if (!$page)
+ $page = 1;
+ if (is_single() || is_page())
+ $more = 1;
+ $content = $post->post_content;
+ if (preg_match('/<!--nextpage-->/', $content)) {
+ if ($page > 1)
+ $more = 1;
+ $multipage = 1;
+ $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
+ $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
+ $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
+ $pages = explode('<!--nextpage-->', $content);
+ $numpages = count($pages);
+ } else {
+ $pages[0] = $post->post_content;
+ $multipage = 0;
+ }
+ return true;
+}
+
+function is_new_day() {
+ global $day, $previousday;
+ if ($day != $previousday) {
+ return(1);
+ } else {
+ return(0);
+ }
+}
+
+// Filters: these are the core of WP's plugin architecture
+
+function merge_filters($tag) {
+ global $wp_filter;
+ if (isset($wp_filter['all'])) {
+ foreach ($wp_filter['all'] as $priority => $functions) {
+ if (isset($wp_filter[$tag][$priority]))
+ $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]);
+ else
+ $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], array());
+ $wp_filter[$tag][$priority] = array_unique($wp_filter[$tag][$priority]);
+ }
+ }
+
+ if ( isset($wp_filter[$tag]) )
+ ksort( $wp_filter[$tag] );
+}
+
+function apply_filters($tag, $string) {
+ global $wp_filter;
+
+ $args = array_slice(func_get_args(), 2);
+
+ merge_filters($tag);
+
+ if (!isset($wp_filter[$tag])) {
+ return $string;
+ }
+ foreach ($wp_filter[$tag] as $priority => $functions) {
+ if (!is_null($functions)) {
+ foreach($functions as $function) {
+
+ $all_args = array_merge(array($string), $args);
+ $function_name = $function['function'];
+ $accepted_args = $function['accepted_args'];
+
+ if($accepted_args == 1) {
+ $the_args = array($string);
+ } elseif ($accepted_args > 1) {
+ $the_args = array_slice($all_args, 0, $accepted_args);
+ } elseif($accepted_args == 0) {
+ $the_args = NULL;
+ } else {
+ $the_args = $all_args;
+ }
+
+ $string = call_user_func_array($function_name, $the_args);
+ }
+ }
+ }
+ return $string;
+}
+
+function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
+ global $wp_filter;
+
+ // check that we don't already have the same filter at the same priority
+ if (isset($wp_filter[$tag]["$priority"])) {
+ foreach($wp_filter[$tag]["$priority"] as $filter) {
+ // uncomment if we want to match function AND accepted_args
+ //if ($filter == array($function, $accepted_args)) {
+ if ($filter['function'] == $function_to_add) {
+ return true;
+ }
+ }
+ }
+
+ // So the format is wp_filter['tag']['array of priorities']['array of ['array (functions, accepted_args)]']
+ $wp_filter[$tag]["$priority"][] = array('function'=>$function_to_add, 'accepted_args'=>$accepted_args);
+ return true;
+}
+
+function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
+ global $wp_filter;
+
+ // rebuild the list of filters
+ if (isset($wp_filter[$tag]["$priority"])) {
+ foreach($wp_filter[$tag]["$priority"] as $filter) {
+ if ($filter['function'] != $function_to_remove) {
+ $new_function_list[] = $filter;
+ }
+ }
+ $wp_filter[$tag]["$priority"] = $new_function_list;
+ }
+ return true;
+}
+
+// The *_action functions are just aliases for the *_filter functions, they take special strings instead of generic content
+
+function do_action($tag, $arg = '') {
+ global $wp_filter;
+ $extra_args = array_slice(func_get_args(), 2);
+ if ( is_array($arg) )
+ $args = array_merge($arg, $extra_args);
+ else
+ $args = array_merge(array($arg), $extra_args);
+
+ merge_filters($tag);
+
+ if (!isset($wp_filter[$tag])) {
+ return;
+ }
+ foreach ($wp_filter[$tag] as $priority => $functions) {
+ if (!is_null($functions)) {
+ foreach($functions as $function) {
+
+ $function_name = $function['function'];
+ $accepted_args = $function['accepted_args'];
+
+ if($accepted_args == 1) {
+ if ( is_array($arg) )
+ $the_args = $arg;
+ else
+ $the_args = array($arg);
+ } elseif ($accepted_args > 1) {
+ $the_args = array_slice($args, 0, $accepted_args);
+ } elseif($accepted_args == 0) {
+ $the_args = NULL;
+ } else {
+ $the_args = $args;
+ }
+
+ $string = call_user_func_array($function_name, $the_args);
+ }
+ }
+ }
+}
+
+function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
+ add_filter($tag, $function_to_add, $priority, $accepted_args);
+}
+
+function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
+ remove_filter($tag, $function_to_remove, $priority, $accepted_args);
+}
+
+function get_page_uri($page_id) {
+ $page = get_page($page_id);
+ $uri = urldecode($page->post_name);
+
+ // A page cannot be it's own parent.
+ if ($page->post_parent == $page->ID) {
+ return $uri;
+ }
+
+ while ($page->post_parent != 0) {
+ $page = get_page($page->post_parent);
+ $uri = urldecode($page->post_name) . "/" . $uri;
+ }
+
+ return $uri;
+}
+
+function get_posts($args) {
+ global $wpdb;
+ parse_str($args, $r);
+ if (!isset($r['numberposts'])) $r['numberposts'] = 5;
+ if (!isset($r['offset'])) $r['offset'] = 0;
+ if (!isset($r['category'])) $r['category'] = '';
+ if (!isset($r['orderby'])) $r['orderby'] = 'post_date';
+ if (!isset($r['order'])) $r['order'] = 'DESC';
+
+ $now = current_time('mysql');
+
+ $posts = $wpdb->get_results(
+ "SELECT DISTINCT * FROM $wpdb->posts " .
+ ( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) .
+ " WHERE post_date <= '$now' AND (post_status = 'publish') ".
+ ( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) .
+ " GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
+
+ update_post_caches($posts);
+
+ return $posts;
+}
+
+function &query_posts($query) {
+ global $wp_query;
+ return $wp_query->query($query);
+}
+
+function update_post_cache(&$posts) {
+ global $post_cache;
+
+ if ( !$posts )
+ return;
+
+ for ($i = 0; $i < count($posts); $i++) {
+ $post_cache[$posts[$i]->ID] = &$posts[$i];
+ }
+}
+
+function update_page_cache(&$pages) {
+ global $page_cache;
+
+ if ( !$pages )
+ return;
+
+ for ($i = 0; $i < count($pages); $i++) {
+ $page_cache[$pages[$i]->ID] = &$pages[$i];
+ }
+}
+
+function update_post_category_cache($post_ids) {
+ global $wpdb, $category_cache, $cache_categories;
+
+ if (empty($post_ids))
+ return;
+
+ if (is_array($post_ids))
+ $post_ids = implode(',', $post_ids);
+
+ $dogs = $wpdb->get_results("SELECT DISTINCT
+ post_id, cat_ID FROM $wpdb->categories, $wpdb->post2cat
+ WHERE category_id = cat_ID AND post_id IN ($post_ids)");
+
+ if (! isset($cache_categories))
+ update_category_cache();
+
+ if ( !empty($dogs) ) {
+ foreach ($dogs as $catt) {
+ $category_cache[$catt->post_id][$catt->cat_ID] = &$cache_categories[$catt->cat_ID];
+ }
+ }
+}
+
+function update_post_caches(&$posts) {
+ global $post_cache, $category_cache, $comment_count_cache, $post_meta_cache;
+ global $wpdb;
+
+ // No point in doing all this work if we didn't match any posts.
+ if ( !$posts )
+ return;
+
+ // Get the categories for all the posts
+ for ($i = 0; $i < count($posts); $i++) {
+ $post_id_list[] = $posts[$i]->ID;
+ $post_cache[$posts[$i]->ID] = &$posts[$i];
+ }
+
+ $post_id_list = implode(',', $post_id_list);
+
+ update_post_category_cache($post_id_list);
+
+ // Do the same for comment numbers
+ $comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount
+ FROM $wpdb->posts
+ LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID AND comment_approved = '1')
+ WHERE ID IN ($post_id_list)
+ GROUP BY ID");
+
+ if ($comment_counts) {
+ foreach ($comment_counts as $comment_count)
+ $comment_count_cache["$comment_count->ID"] = $comment_count->ccount;
+ }
+
+ // Get post-meta info
+ if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
+ // Change from flat structure to hierarchical:
+ $post_meta_cache = array();
+ foreach ($meta_list as $metarow) {
+ $mpid = $metarow['post_id'];
+ $mkey = $metarow['meta_key'];
+ $mval = $metarow['meta_value'];
+
+ // Force subkeys to be array type:
+ if (!isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]))
+ $post_meta_cache[$mpid] = array();
+ if (!isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]))
+ $post_meta_cache[$mpid]["$mkey"] = array();
+
+ // Add a value to the current pid/key:
+ $post_meta_cache[$mpid][$mkey][] = $mval;
+ }
+ }
+}
+
+function update_category_cache() {
+ global $cache_categories, $wpdb;
+ if($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")):
+ foreach ($dogs as $catt)
+ $cache_categories[$catt->cat_ID] = $catt;
+ return true;
+ else:
+ return false;
+ endif;
+}
+
+function wp_head() {
+ do_action('wp_head');
+}
+
+function wp_footer() {
+ do_action('wp_footer');
+}
+
+function is_single ($post = '') {
+ global $wp_query;
+
+ if ( !$wp_query->is_single )
+ return false;
+
+ if ( empty( $post) )
+ return true;
+
+ $post_obj = $wp_query->get_queried_object();
+
+ if ( $post == $post_obj->ID )
+ return true;
+ elseif ( $post == $post_obj->post_title )
+ return true;
+ elseif ( $post == $post_obj->post_name )
+ return true;
+
+ return false;
+}
+
+function is_page ($page = '') {
+ global $wp_query;
+
+ if (! $wp_query->is_page) {
+ return false;
+ }
+
+ if (empty($page)) {
+ return true;
+ }
+
+ $page_obj = $wp_query->get_queried_object();
+
+ if ($page == $page_obj->ID) {
+ return true;
+ } else if ($page == $page_obj->post_title) {
+ return true;
+ } else if ($page == $page_obj->post_name) {
+ return true;
+ }
+
+ return false;
+}
+
+function is_archive () {
+ global $wp_query;
+
+ return $wp_query->is_archive;
+}
+
+function is_date () {
+ global $wp_query;
+
+ return $wp_query->is_date;
+}
+
+function is_year () {
+ global $wp_query;
+
+ return $wp_query->is_year;
+}
+
+function is_month () {
+ global $wp_query;
+
+ return $wp_query->is_month;
+}
+
+function is_day () {
+ global $wp_query;
+
+ return $wp_query->is_day;
+}
+
+function is_time () {
+ global $wp_query;
+
+ return $wp_query->is_time;
+}
+
+function is_author ($author = '') {
+ global $wp_query;
+
+ if (! $wp_query->is_author) {
+ return false;
+ }
+
+ if (empty($author)) {
+ return true;
+ }
+
+ $author_obj = $wp_query->get_queried_object();
+
+ if ($author == $author_obj->ID) {
+ return true;
+ } else if ($author == $author_obj->nickname) {
+ return true;
+ } else if ($author == $author_obj->user_nicename) {
+ return true;
+ }
+
+ return false;
+}
+
+function is_category ($category = '') {
+ global $wp_query;
+
+ if (! $wp_query->is_category) {
+ return false;
+ }
+
+ if (empty($category)) {
+ return true;
+ }
+
+ $cat_obj = $wp_query->get_queried_object();
+
+ if ($category == $cat_obj->cat_ID) {
+ return true;
+ } else if ($category == $cat_obj->cat_name) {
+ return true;
+ } else if ($category == $cat_obj->category_nicename) {
+ return true;
+ }
+
+ return false;
+}
+
+function is_search () {
+ global $wp_query;
+
+ return $wp_query->is_search;
+}
+
+function is_feed () {
+ global $wp_query;
+
+ return $wp_query->is_feed;
+}
+
+function is_trackback () {
+ global $wp_query;
+
+ return $wp_query->is_trackback;
+}
+
+function is_admin () {
+ global $wp_query;
+
+ return $wp_query->is_admin;
+}
+
+function is_home () {
+ global $wp_query;
+
+ return $wp_query->is_home;
+}
+
+function is_404 () {
+ global $wp_query;
+
+ return $wp_query->is_404;
+}
+
+function is_comments_popup () {
+ global $wp_query;
+
+ return $wp_query->is_comments_popup;
+}
+
+function is_paged () {
+ global $wp_query;
+
+ return $wp_query->is_paged;
+}
+
+function get_query_var($var) {
+ global $wp_query;
+
+ return $wp_query->get($var);
+}
+
+function have_posts() {
+ global $wp_query;
+
+ return $wp_query->have_posts();
+}
+
+function rewind_posts() {
+ global $wp_query;
+
+ return $wp_query->rewind_posts();
+}
+
+function the_post() {
+ global $wp_query;
+ $wp_query->the_post();
+}
+
+function get_theme_root() {
+ return apply_filters('theme_root', ABSPATH . "wp-content/themes");
+}
+
+function get_theme_root_uri() {
+ return apply_filters('theme_root_uri', get_settings('siteurl') . "/wp-content/themes", get_settings('siteurl'));
+}
+
+function get_stylesheet() {
+ return apply_filters('stylesheet', get_settings('stylesheet'));
+}
+
+function get_stylesheet_directory() {
+ $stylesheet = get_stylesheet();
+ $stylesheet_dir = get_theme_root() . "/$stylesheet";
+ return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet);
+}
+
+function get_stylesheet_directory_uri() {
+ $stylesheet = rawurlencode( get_stylesheet() );
+ $stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet";
+ return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet);
+}
+
+function get_stylesheet_uri() {
+ $stylesheet_dir_uri = get_stylesheet_directory_uri();
+ $stylesheet_uri = $stylesheet_dir_uri . "/style.css";
+ return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
+}
+
+function get_template() {
+ return apply_filters('template', get_settings('template'));
+}
+
+function get_template_directory() {
+ $template = get_template();
+ $template_dir = get_theme_root() . "/$template";
+ return apply_filters('template_directory', $template_dir, $template);
+}
+
+function get_template_directory_uri() {
+ $template = get_template();
+ $template_dir_uri = get_theme_root_uri() . "/$template";
+ return apply_filters('template_directory_uri', $template_dir_uri, $template);
+}
+
+function get_theme_data($theme_file) {
+ $theme_data = implode('', file($theme_file));
+ preg_match("|Theme Name:(.*)|i", $theme_data, $theme_name);
+ preg_match("|Theme URI:(.*)|i", $theme_data, $theme_uri);
+ preg_match("|Description:(.*)|i", $theme_data, $description);
+ preg_match("|Author:(.*)|i", $theme_data, $author_name);
+ preg_match("|Author URI:(.*)|i", $theme_data, $author_uri);
+ preg_match("|Template:(.*)|i", $theme_data, $template);
+ if ( preg_match("|Version:(.*)|i", $theme_data, $version) )
+ $version = $version[1];
+ else
+ $version ='';
+ if ( preg_match("|Status:(.*)|i", $theme_data, $status) )
+ $status = $status[1];
+ else
+ $status ='publish';
+
+ $description = wptexturize($description[1]);
+
+ $name = $theme_name[1];
+ $name = trim($name);
+ $theme = $name;
+ if ('' != $theme_uri[1] && '' != $name) {
+ $theme = '<a href="' . $theme_uri[1] . '" title="' . __('Visit theme homepage') . '">' . $theme . '</a>';
+ }
+
+ if ('' == $author_uri[1]) {
+ $author = $author_name[1];
+ } else {
+ $author = '<a href="' . $author_uri[1] . '" title="' . __('Visit author homepage') . '">' . $author_name[1] . '</a>';
+ }
+
+ return array('Name' => $name, 'Title' => $theme, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1], 'Status' => $status);
+}
+
+function get_themes() {
+ global $wp_themes;
+ global $wp_broken_themes;
+
+ if (isset($wp_themes)) {
+ return $wp_themes;
+ }
+
+ $themes = array();
+ $wp_broken_themes = array();
+ $theme_root = get_theme_root();
+ $theme_loc = str_replace(ABSPATH, '', $theme_root);
+
+ // Files in wp-content/themes directory
+ $themes_dir = @ dir($theme_root);
+ if ($themes_dir) {
+ while(($theme_dir = $themes_dir->read()) !== false) {
+ if (is_dir($theme_root . '/' . $theme_dir)) {
+ if ($theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS') {
+ continue;
+ }
+ $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
+ $found_stylesheet = false;
+ while(($theme_file = $stylish_dir->read()) !== false) {
+ if ( $theme_file == 'style.css' ) {
+ $theme_files[] = $theme_dir . '/' . $theme_file;
+ $found_stylesheet = true;
+ break;
+ }
+ }
+ if (!$found_stylesheet) {
+ $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
+ }
+ }
+ }
+ }
+
+ if (!$themes_dir || !$theme_files) {
+ return $themes;
+ }
+
+ sort($theme_files);
+
+ foreach($theme_files as $theme_file) {
+ $theme_data = get_theme_data("$theme_root/$theme_file");
+
+ $name = $theme_data['Name'];
+ $title = $theme_data['Title'];
+ $description = wptexturize($theme_data['Description']);
+ $version = $theme_data['Version'];
+ $author = $theme_data['Author'];
+ $template = $theme_data['Template'];
+ $stylesheet = dirname($theme_file);
+
+ if (empty($name)) {
+ $name = dirname($theme_file);
+ $title = $name;
+ }
+
+ if (empty($template)) {
+ if (file_exists(dirname("$theme_root/$theme_file/index.php"))) {
+ $template = dirname($theme_file);
+ } else {
+ continue;
+ }
+ }
+
+ $template = trim($template);
+
+ if (! file_exists("$theme_root/$template/index.php")) {
+ $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
+ continue;
+ }
+
+ $stylesheet_files = array();
+ $stylesheet_dir = @ dir("$theme_root/$stylesheet");
+ if ($stylesheet_dir) {
+ while(($file = $stylesheet_dir->read()) !== false) {
+ if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) )
+ $stylesheet_files[] = "$theme_loc/$stylesheet/$file";
+ }
+ }
+
+ $template_files = array();
+ $template_dir = @ dir("$theme_root/$template");
+ if ($template_dir) {
+ while(($file = $template_dir->read()) !== false) {
+ if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) )
+ $template_files[] = "$theme_loc/$template/$file";
+ }
+ }
+
+ $template_dir = dirname($template_files[0]);
+ $stylesheet_dir = dirname($stylesheet_files[0]);
+
+ if (empty($template_dir)) $template_dir = '/';
+ if (empty($stylesheet_dir)) $stylesheet_dir = '/';
+
+ // Check for theme name collision. This occurs if a theme is copied to
+ // a new theme directory and the theme header is not updated. Whichever
+ // theme is first keeps the name. Subsequent themes get a suffix applied.
+ // The Default and Classic themes always trump their pretenders.
+ if ( isset($themes[$name]) ) {
+ if ( ('WordPress Default' == $name || 'WordPress Classic' == $name) &&
+ ('default' == $stylesheet || 'classic' == $stylesheet) ) {
+ // If another theme has claimed to be one of our default themes, move
+ // them aside.
+ $suffix = $themes[$name]['Stylesheet'];
+ $new_name = "$name/$suffix";
+ $themes[$new_name] = $themes[$name];
+ $themes[$new_name]['Name'] = $new_name;
+ } else {
+ $name = "$name/$stylesheet";
+ }
+ }
+
+ $themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Stylesheet' => $stylesheet, 'Template Files' => $template_files, 'Stylesheet Files' => $stylesheet_files, 'Template Dir' => $template_dir, 'Stylesheet Dir' => $stylesheet_dir, 'Status' => $theme_data['Status']);
+ }
+
+ // Resolve theme dependencies.
+ $theme_names = array_keys($themes);
+
+ foreach ($theme_names as $theme_name) {
+ $themes[$theme_name]['Parent Theme'] = '';
+ if ($themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template']) {
+ foreach ($theme_names as $parent_theme_name) {
+ if (($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template'])) {
+ $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
+ break;
+ }
+ }
+ }
+ }
+
+ $wp_themes = $themes;
+
+ return $themes;
+}
+
+function get_theme($theme) {
+ $themes = get_themes();
+
+ if (array_key_exists($theme, $themes)) {
+ return $themes[$theme];
+ }
+
+ return NULL;
+}
+
+function get_current_theme() {
+ $themes = get_themes();
+ $theme_names = array_keys($themes);
+ $current_template = get_settings('template');
+ $current_stylesheet = get_settings('stylesheet');
+ $current_theme = 'WordPress Default';
+
+ if ($themes) {
+ foreach ($theme_names as $theme_name) {
+ if ($themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
+ $themes[$theme_name]['Template'] == $current_template) {
+ $current_theme = $themes[$theme_name]['Name'];
+ break;
+ }
+ }
+ }
+
+ return $current_theme;
+}
+
+function get_query_template($type) {
+ $template = '';
+ if ( file_exists(TEMPLATEPATH . "/{$type}.php") )
+ $template = TEMPLATEPATH . "/{$type}.php";
+
+ return apply_filters("{$type}_template", $template);
+}
+
+function get_404_template() {
+ return get_query_template('404');
+}
+
+function get_archive_template() {
+ return get_query_template('archive');
+}
+
+function get_author_template() {
+ return get_query_template('author');
+}
+
+function get_category_template() {
+ $template = '';
+ if ( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') )
+ $template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php';
+ else if ( file_exists(TEMPLATEPATH . "/category.php") )
+ $template = TEMPLATEPATH . "/category.php";
+
+ return apply_filters('category_template', $template);
+}
+
+function get_date_template() {
+ return get_query_template('date');
+}
+
+function get_home_template() {
+ $template = '';
+
+ if ( file_exists(TEMPLATEPATH . "/home.php") )
+ $template = TEMPLATEPATH . "/home.php";
+ else if ( file_exists(TEMPLATEPATH . "/index.php") )
+ $template = TEMPLATEPATH . "/index.php";
+
+ return apply_filters('home_template', $template);
+}
+
+function get_page_template() {
+ global $wp_query;
+
+ $id = $wp_query->post->ID;
+ $template = get_post_meta($id, '_wp_page_template', true);
+
+ if ( 'default' == $template )
+ $template = '';
+
+ if ( ! empty($template) && file_exists(TEMPLATEPATH . "/$template") )
+ $template = TEMPLATEPATH . "/$template";
+ else if ( file_exists(TEMPLATEPATH . "/page.php") )
+ $template = TEMPLATEPATH . "/page.php";
+ else
+ $template = '';
+
+ return apply_filters('page_template', $template);
+}
+
+function get_paged_template() {
+ return get_query_template('paged');
+}
+
+function get_search_template() {
+ return get_query_template('search');
+}
+
+function get_single_template() {
+ return get_query_template('single');
+}
+
+function get_comments_popup_template() {
+ if ( file_exists( TEMPLATEPATH . '/comments-popup.php') )
+ $template = TEMPLATEPATH . '/comments-popup.php';
+ else
+ $template = get_theme_root() . '/default/comments-popup.php';
+
+ return apply_filters('comments_popup_template', $template);
+}
+
+// Borrowed from the PHP Manual user notes. Convert entities, while
+// preserving already-encoded entities:
+function htmlentities2($myHTML) {
+ $translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES);
+ $translation_table[chr(38)] = '&';
+ return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" , strtr($myHTML, $translation_table));
+}
+
+
+function is_plugin_page() {
+ global $plugin_page;
+
+ if (isset($plugin_page)) {
+ return true;
+ }
+
+ return false;
+}
+
+/*
+add_query_arg: Returns a modified querystring by adding
+a single key & value or an associative array.
+Setting a key value to emptystring removes the key.
+Omitting oldquery_or_uri uses the $_SERVER value.
+
+Parameters:
+add_query_arg(newkey, newvalue, oldquery_or_uri) or
+add_query_arg(associative_array, oldquery_or_uri)
+*/
+function add_query_arg() {
+ $ret = '';
+ if(is_array(func_get_arg(0))) {
+ $uri = @func_get_arg(1);
+ }
+ else {
+ if (@func_num_args() < 3) {
+ $uri = $_SERVER['REQUEST_URI'];
+ } else {
+ $uri = @func_get_arg(2);
+ }
+ }
+
+ if (strstr($uri, '?')) {
+ $parts = explode('?', $uri, 2);
+ if (1 == count($parts)) {
+ $base = '?';
+ $query = $parts[0];
+ }
+ else {
+ $base = $parts[0] . '?';
+ $query = $parts[1];
+ }
+ }
+ else if (strstr($uri, '/')) {
+ $base = $uri . '?';
+ $query = '';
+ } else {
+ $base = '';
+ $query = $uri;
+ }
+
+ parse_str($query, $qs);
+ if (is_array(func_get_arg(0))) {
+ $kayvees = func_get_arg(0);
+ $qs = array_merge($qs, $kayvees);
+ }
+ else
+ {
+ $qs[func_get_arg(0)] = func_get_arg(1);
+ }
+
+ foreach($qs as $k => $v)
+ {
+ if($v != '')
+ {
+ if($ret != '') $ret .= '&';
+ $ret .= "$k=$v";
+ }
+ }
+ $ret = $base . $ret;
+ return trim($ret, '?');
+}
+
+function remove_query_arg($key, $query) {
+ return add_query_arg($key, '', $query);
+}
+
+function load_template($file) {
+ global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query,
+ $wp_rewrite, $wpdb;
+
+ extract($wp_query->query_vars);
+
+ require_once($file);
+}
+
+function add_magic_quotes($array) {
+ global $wpdb;
+
+ foreach ($array as $k => $v) {
+ if (is_array($v)) {
+ $array[$k] = add_magic_quotes($v);
+ } else {
+ $array[$k] = $wpdb->escape($v);
+ }
+ }
+ return $array;
+}
+
+function wp_remote_fopen( $uri ) {
+ if ( ini_get('allow_url_fopen') ) {
+ $fp = fopen( $uri, 'r' );
+ if ( !$fp )
+ return false;
+ $linea = '';
+ while( $remote_read = fread($fp, 4096) )
+ $linea .= $remote_read;
+ fclose($fp);
+ return $linea;
+ } else if ( function_exists('curl_init') ) {
+ $handle = curl_init();
+ curl_setopt ($handle, CURLOPT_URL, $uri);
+ curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1);
+ curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1);
+ $buffer = curl_exec($handle);
+ curl_close($handle);
+ return $buffer;
+ } else {
+ return false;
+ }
+}
+
+function wp($query_vars = '') {
+ global $wp;
+ $wp->main($query_vars);
+}
+
+function status_header( $header ) {
+ if ( 200 == $header ) {
+ $text = 'OK';
+ } elseif ( 301 == $header ) {
+ $text = 'Moved Permanently';
+ } elseif ( 302 == $header ) {
+ $text = 'Moved Temporarily';
+ } elseif ( 304 == $header ) {
+ $text = 'Not Modified';
+ } elseif ( 404 == $header ) {
+ $text = 'Not Found';
+ } elseif ( 410 == $header ) {
+ $text = 'Gone';
+ }
+ if ( preg_match('/cgi/',php_sapi_name()) ) {
+ @header("Status: $header $text");
+ } else {
+ if ( version_compare(phpversion(), '4.3.0', '>=') )
+ @header($text, TRUE, $header);
+ else
+ @header("HTTP/1.x $header $text");
+ }
+}
+
+function nocache_headers() {
+ @ header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
+ @ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+ @ header('Cache-Control: no-cache, must-revalidate, max-age=0');
+ @ header('Pragma: no-cache');
+}
+
+function get_usermeta( $user_id, $meta_key = '') {
+ global $wpdb;
+ $user_id = (int) $user_id;
+
+ if ( !empty($meta_key) ) {
+ $meta_key = preg_replace('|a-z0-9_|i', '', $meta_key);
+ $metas = $wpdb->get_results("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
+ } else {
+ $metas = $wpdb->get_results("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id'");
+ }
+
+ foreach ($metas as $index => $meta) {
+ @ $value = unserialize($meta->meta_key);
+ if ($value !== FALSE)
+ $metas[$index]->meta_key = $value;
+ }
+
+ if ( !empty($meta_key) )
+ return $metas[0];
+ else
+ return $metas;
+}
+
+function update_usermeta( $user_id, $meta_key, $meta_value ) {
+ global $wpdb;
+ if ( !is_numeric( $user_id ) )
+ return false;
+ $meta_key = preg_replace('|a-z0-9_|i', '', $meta_key);
+
+ if ( is_array($meta_value) || is_object($meta_value) )
+ $meta_value = serialize($meta_value);
+
+ $cur = $wpdb->get_row("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
+ if ( !$cur ) {
+ $wpdb->query("INSERT INTO $wpdb->usermeta ( user_id, meta_key, meta_value )
+ VALUES
+ ( '$user_id', '$meta_key', '$meta_value' )");
+ return true;
+ }
+ if ( $cur->meta_value != $meta_value )
+ $wpdb->query("UPDATE $wpdb->usermeta SET meta_value = '$meta_value' WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
+}
+
+function register_activation_hook($file, $function) {
+ $file = plugin_basename($file);
+
+ add_action('activate_' . $file, $function);
+}
+
+function register_deactivation_hook($file, $function) {
+ $file = plugin_basename($file);
+
+ add_action('deactivate_' . $file, $function);
+}
+
+function plugin_basename($file) {
+ return preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file);
+}
+
+?>
diff --git a/wp-inst/wp-includes/gettext.php b/wp-inst/wp-includes/gettext.php
new file mode 100644
index 0000000..45af0f6
--- /dev/null
+++ b/wp-inst/wp-includes/gettext.php
@@ -0,0 +1,358 @@
+<?php
+/*
+ Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
+ Copyright (c) 2005 Nico Kaiser <nico@siriux.net>
+
+ This file is part of PHP-gettext.
+
+ PHP-gettext is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ PHP-gettext is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with PHP-gettext; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+/**
+ * Provides a simple gettext replacement that works independently from
+ * the system's gettext abilities.
+ * It can read MO files and use them for translating strings.
+ * The files are passed to gettext_reader as a Stream (see streams.php)
+ *
+ * This version has the ability to cache all strings and translations to
+ * speed up the string lookup.
+ * While the cache is enabled by default, it can be switched off with the
+ * second parameter in the constructor (e.g. whenusing very large MO files
+ * that you don't want to keep in memory)
+ */
+class gettext_reader {
+ //public:
+ var $error = 0; // public variable that holds error code (0 if no error)
+
+ //private:
+ var $BYTEORDER = 0; // 0: low endian, 1: big endian
+ var $STREAM = NULL;
+ var $short_circuit = false;
+ var $enable_cache = false;
+ var $originals = NULL; // offset of original table
+ var $translations = NULL; // offset of translation table
+ var $pluralheader = NULL; // cache header field for plural forms
+ var $total = 0; // total string count
+ var $table_originals = NULL; // table for original strings (offsets)
+ var $table_translations = NULL; // table for translated strings (offsets)
+ var $cache_translations = NULL; // original -> translation mapping
+
+
+ /* Methods */
+
+
+ /**
+ * Reads a 32bit Integer from the Stream
+ *
+ * @access private
+ * @return Integer from the Stream
+ */
+ function readint() {
+ if ($this->BYTEORDER == 0) {
+ // low endian
+ return array_shift(unpack('V', $this->STREAM->read(4)));
+ } else {
+ // big endian
+ return array_shift(unpack('N', $this->STREAM->read(4)));
+ }
+ }
+
+ /**
+ * Reads an array of Integers from the Stream
+ *
+ * @param int count How many elements should be read
+ * @return Array of Integers
+ */
+ function readintarray($count) {
+ if ($this->BYTEORDER == 0) {
+ // low endian
+ return unpack('V'.$count, $this->STREAM->read(4 * $count));
+ } else {
+ // big endian
+ return unpack('N'.$count, $this->STREAM->read(4 * $count));
+ }
+ }
+
+ /**
+ * Constructor
+ *
+ * @param object Reader the StreamReader object
+ * @param boolean enable_cache Enable or disable caching of strings (default on)
+ */
+ function gettext_reader($Reader, $enable_cache = true) {
+ // If there isn't a StreamReader, turn on short circuit mode.
+ if (! $Reader) {
+ $this->short_circuit = true;
+ return;
+ }
+
+ // Caching can be turned off
+ $this->enable_cache = $enable_cache;
+
+ // $MAGIC1 = (int)0x950412de; //bug in PHP 5
+ $MAGIC1 = (int) - 1794895138;
+ // $MAGIC2 = (int)0xde120495; //bug
+ $MAGIC2 = (int) - 569244523;
+
+ $this->STREAM = $Reader;
+ $magic = $this->readint();
+ if ($magic == $MAGIC1) {
+ $this->BYTEORDER = 0;
+ } elseif ($magic == $MAGIC2) {
+ $this->BYTEORDER = 1;
+ } else {
+ $this->error = 1; // not MO file
+ return false;
+ }
+
+ // FIXME: Do we care about revision? We should.
+ $revision = $this->readint();
+
+ $this->total = $this->readint();
+ $this->originals = $this->readint();
+ $this->translations = $this->readint();
+ }
+
+ /**
+ * Loads the translation tables from the MO file into the cache
+ * If caching is enabled, also loads all strings into a cache
+ * to speed up translation lookups
+ *
+ * @access private
+ */
+ function load_tables() {
+ if (is_array($this->cache_translations) &&
+ is_array($this->table_originals) &&
+ is_array($this->table_translations))
+ return;
+
+ /* get original and translations tables */
+ $this->STREAM->seekto($this->originals);
+ $this->table_originals = $this->readintarray($this->total * 2);
+ $this->STREAM->seekto($this->translations);
+ $this->table_translations = $this->readintarray($this->total * 2);
+
+ if ($this->enable_cache) {
+ $this->cache_translations = array ();
+ /* read all strings in the cache */
+ for ($i = 0; $i < $this->total; $i++) {
+ $this->STREAM->seekto($this->table_originals[$i * 2 + 2]);
+ $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]);
+ $this->STREAM->seekto($this->table_translations[$i * 2 + 2]);
+ $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]);
+ $this->cache_translations[$original] = $translation;
+ }
+ }
+ }
+
+ /**
+ * Returns a string from the "originals" table
+ *
+ * @access private
+ * @param int num Offset number of original string
+ * @return string Requested string if found, otherwise ''
+ */
+ function get_original_string($num) {
+ $length = $this->table_originals[$num * 2 + 1];
+ $offset = $this->table_originals[$num * 2 + 2];
+ if (! $length)
+ return '';
+ $this->STREAM->seekto($offset);
+ $data = $this->STREAM->read($length);
+ return (string)$data;
+ }
+
+ /**
+ * Returns a string from the "translations" table
+ *
+ * @access private
+ * @param int num Offset number of original string
+ * @return string Requested string if found, otherwise ''
+ */
+ function get_translation_string($num) {
+ $length = $this->table_translations[$num * 2 + 1];
+ $offset = $this->table_translations[$num * 2 + 2];
+ if (! $length)
+ return '';
+ $this->STREAM->seekto($offset);
+ $data = $this->STREAM->read($length);
+ return (string)$data;
+ }
+
+ /**
+ * Binary search for string
+ *
+ * @access private
+ * @param string string
+ * @param int start (internally used in recursive function)
+ * @param int end (internally used in recursive function)
+ * @return int string number (offset in originals table)
+ */
+ function find_string($string, $start = -1, $end = -1) {
+ if (($start == -1) or ($end == -1)) {
+ // find_string is called with only one parameter, set start end end
+ $start = 0;
+ $end = $this->total;
+ }
+ if (abs($start - $end) <= 1) {
+ // We're done, now we either found the string, or it doesn't exist
+ $txt = $this->get_original_string($start);
+ if ($string == $txt)
+ return $start;
+ else
+ return -1;
+ } else if ($start > $end) {
+ // start > end -> turn around and start over
+ return $this->find_string($string, $end, $start);
+ } else {
+ // Divide table in two parts
+ $half = (int)(($start + $end) / 2);
+ $cmp = strcmp($string, $this->get_original_string($half));
+ if ($cmp == 0)
+ // string is exactly in the middle => return it
+ return $half;
+ else if ($cmp < 0)
+ // The string is in the upper half
+ return $this->find_string($string, $start, $half);
+ else
+ // The string is in the lower half
+ return $this->find_string($string, $half, $end);
+ }
+ }
+
+ /**
+ * Translates a string
+ *
+ * @access public
+ * @param string string to be translated
+ * @return string translated string (or original, if not found)
+ */
+ function translate($string) {
+ if ($this->short_circuit)
+ return $string;
+ $this->load_tables();
+
+ if ($this->enable_cache) {
+ // Caching enabled, get translated string from cache
+ if (array_key_exists($string, $this->cache_translations))
+ return $this->cache_translations[$string];
+ else
+ return $string;
+ } else {
+ // Caching not enabled, try to find string
+ $num = $this->find_string($string);
+ if ($num == -1)
+ return $string;
+ else
+ return $this->get_translation_string($num);
+ }
+ }
+
+ /**
+ * Get possible plural forms from MO header
+ *
+ * @access private
+ * @return string plural form header
+ */
+ function get_plural_forms() {
+ // lets assume message number 0 is header
+ // this is true, right?
+ $this->load_tables();
+
+ // cache header field for plural forms
+ if (! is_string($this->pluralheader)) {
+ if ($this->enable_cache) {
+ $header = $this->cache_translations[""];
+ } else {
+ $header = $this->get_translation_string(0);
+ }
+ if (eregi("plural-forms: (.*)\n", $header, $regs))
+ $expr = $regs[1];
+ else
+ $expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
+ $this->pluralheader = $expr;
+ }
+ return $this->pluralheader;
+ }
+
+ /**
+ * Detects which plural form to take
+ *
+ * @access private
+ * @param n count
+ * @return int array index of the right plural form
+ */
+ function select_string($n) {
+ $string = $this->get_plural_forms();
+ $string = str_replace('nplurals',"\$total",$string);
+ $string = str_replace("n",$n,$string);
+ $string = str_replace('plural',"\$plural",$string);
+
+ $total = 0;
+ $plural = 0;
+
+ eval("$string");
+ if ($plural >= $total) $plural = 0;
+ return $plural;
+ }
+
+ /**
+ * Plural version of gettext
+ *
+ * @access public
+ * @param string single
+ * @param string plural
+ * @param string number
+ * @return translated plural form
+ */
+ function ngettext($single, $plural, $number) {
+ if ($this->short_circuit) {
+ if ($number != 1)
+ return $plural;
+ else
+ return $single;
+ }
+
+ // find out the appropriate form
+ $select = $this->select_string($number);
+
+ // this should contains all strings separated by NULLs
+ $key = $single.chr(0).$plural;
+
+
+ if ($this->enable_cache) {
+ if (! array_key_exists($key, $this->cache_translations)) {
+ return ($number != 1) ? $plural : $single;
+ } else {
+ $result = $this->cache_translations[$key];
+ $list = explode(chr(0), $result);
+ return $list[$select];
+ }
+ } else {
+ $num = $this->find_string($key);
+ if ($num == -1) {
+ return ($number != 1) ? $plural : $single;
+ } else {
+ $result = $this->get_translation_string($num);
+ $list = explode(chr(0), $result);
+ return $list[$select];
+ }
+ }
+ }
+
+}
+
+?>
diff --git a/wp-inst/wp-includes/kses.php b/wp-inst/wp-includes/kses.php
new file mode 100644
index 0000000..93dbe3a
--- /dev/null
+++ b/wp-inst/wp-includes/kses.php
@@ -0,0 +1,563 @@
+<?php
+// Added wp_ prefix to avoid conflicts with existing kses users
+# kses 0.2.1 - HTML/XHTML filter that only allows some elements and attributes
+# Copyright (C) 2002, 2003 Ulf Harnhammar
+# *** CONTACT INFORMATION ***
+#
+# E-mail: metaur at users dot sourceforge dot net
+# Web page: http://sourceforge.net/projects/kses
+# Paper mail: (not at the moment)
+#
+# [kses strips evil scripts!]
+if (!defined('CUSTOM_TAGS'))
+ define('CUSTOM_TAGS', false);
+
+// You can override this in your my-hacks.php file
+if (!CUSTOM_TAGS) {
+$allowedtags = array(
+ 'a' => array(
+ 'href' => array(),
+ 'title' => array()
+ ),
+ 'abbr' => array('title' => array()),
+ 'acronym' => array('title' => array()),
+ 'b' => array(),
+ 'blockquote' => array('cite' => array()),
+// 'br' => array(),
+ 'code' => array(),
+// 'del' => array('datetime' => array()),
+// 'dd' => array(),
+// 'dl' => array(),
+// 'dt' => array(),
+ 'em' => array(),
+ 'i' => array(),
+// 'ins' => array('datetime' => array(), 'cite' => array()),
+// 'li' => array(),
+// 'ol' => array(),
+// 'p' => array(),
+// 'q' => array(),
+ 'strike' => array(),
+ 'strong' => array(),
+// 'sub' => array(),
+// 'sup' => array(),
+// 'u' => array(),
+// 'ul' => array(),
+ );
+}
+function wp_kses($string, $allowed_html, $allowed_protocols =
+ array('http', 'https', 'ftp', 'news', 'nntp', 'feed', 'gopher', 'mailto'))
+###############################################################################
+# This function makes sure that only the allowed HTML element names, attribute
+# names and attribute values plus only sane HTML entities will occur in
+# $string. You have to remove any slashes from PHP's magic quotes before you
+# call this function.
+###############################################################################
+{
+ $string = wp_kses_no_null($string);
+ $string = wp_kses_js_entities($string);
+ $string = wp_kses_normalize_entities($string);
+ $string = wp_kses_hook($string);
+ $allowed_html_fixed = wp_kses_array_lc($allowed_html);
+ return wp_kses_split($string, $allowed_html_fixed, $allowed_protocols);
+} # function wp_kses
+
+
+function wp_kses_hook($string)
+###############################################################################
+# You add any kses hooks here.
+###############################################################################
+{
+ return $string;
+} # function wp_kses_hook
+
+
+function wp_kses_version()
+###############################################################################
+# This function returns kses' version number.
+###############################################################################
+{
+ return '0.2.1';
+} # function wp_kses_version
+
+
+function wp_kses_split($string, $allowed_html, $allowed_protocols)
+###############################################################################
+# This function searches for HTML tags, no matter how malformed. It also
+# matches stray ">" characters.
+###############################################################################
+{
+ return preg_replace('%(<'. # EITHER: <
+ '[^>]*'. # things that aren't >
+ '(>|$)'. # > or end of string
+ '|>)%e', # OR: just a >
+ "wp_kses_split2('\\1', \$allowed_html, ".
+ '$allowed_protocols)',
+ $string);
+} # function wp_kses_split
+
+
+function wp_kses_split2($string, $allowed_html, $allowed_protocols)
+###############################################################################
+# This function does a lot of work. It rejects some very malformed things
+# like <:::>. It returns an empty string, if the element isn't allowed (look
+# ma, no strip_tags()!). Otherwise it splits the tag into an element and an
+# attribute list.
+###############################################################################
+{
+ $string = wp_kses_stripslashes($string);
+
+ if (substr($string, 0, 1) != '<')
+ return '&gt;';
+ # It matched a ">" character
+
+ if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches))
+ return '';
+ # It's seriously malformed
+
+ $slash = trim($matches[1]);
+ $elem = $matches[2];
+ $attrlist = $matches[3];
+
+ if (!is_array($allowed_html[strtolower($elem)]))
+ return '';
+ # They are using a not allowed HTML element
+
+ return wp_kses_attr("$slash$elem", $attrlist, $allowed_html,
+ $allowed_protocols);
+} # function wp_kses_split2
+
+
+function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols)
+###############################################################################
+# This function removes all attributes, if none are allowed for this element.
+# If some are allowed it calls wp_kses_hair() to split them further, and then it
+# builds up new HTML code from the data that kses_hair() returns. It also
+# removes "<" and ">" characters, if there are any left. One more thing it
+# does is to check if the tag has a closing XHTML slash, and if it does,
+# it puts one in the returned code as well.
+###############################################################################
+{
+# Is there a closing XHTML slash at the end of the attributes?
+
+ $xhtml_slash = '';
+ if (preg_match('%\s/\s*$%', $attr))
+ $xhtml_slash = ' /';
+
+# Are any attributes allowed at all for this element?
+
+ if (count($allowed_html[strtolower($element)]) == 0)
+ return "<$element$xhtml_slash>";
+
+# Split it
+
+ $attrarr = wp_kses_hair($attr, $allowed_protocols);
+
+# Go through $attrarr, and save the allowed attributes for this element
+# in $attr2
+
+ $attr2 = '';
+
+ foreach ($attrarr as $arreach)
+ {
+ $current = $allowed_html[strtolower($element)]
+ [strtolower($arreach['name'])];
+ if ($current == '')
+ continue; # the attribute is not allowed
+
+ if (!is_array($current))
+ $attr2 .= ' '.$arreach['whole'];
+ # there are no checks
+
+ else
+ {
+ # there are some checks
+ $ok = true;
+ foreach ($current as $currkey => $currval)
+ if (!wp_kses_check_attr_val($arreach['value'], $arreach['vless'],
+ $currkey, $currval))
+ { $ok = false; break; }
+
+ if ($ok)
+ $attr2 .= ' '.$arreach['whole']; # it passed them
+ } # if !is_array($current)
+ } # foreach
+
+# Remove any "<" or ">" characters
+
+ $attr2 = preg_replace('/[<>]/', '', $attr2);
+
+ return "<$element$attr2$xhtml_slash>";
+} # function wp_kses_attr
+
+
+function wp_kses_hair($attr, $allowed_protocols)
+###############################################################################
+# This function does a lot of work. It parses an attribute list into an array
+# with attribute data, and tries to do the right thing even if it gets weird
+# input. It will add quotes around attribute values that don't have any quotes
+# or apostrophes around them, to make it easier to produce HTML code that will
+# conform to W3C's HTML specification. It will also remove bad URL protocols
+# from attribute values.
+###############################################################################
+{
+ $attrarr = array();
+ $mode = 0;
+ $attrname = '';
+
+# Loop through the whole attribute list
+
+ while (strlen($attr) != 0)
+ {
+ $working = 0; # Was the last operation successful?
+
+ switch ($mode)
+ {
+ case 0: # attribute name, href for instance
+
+ if (preg_match('/^([-a-zA-Z]+)/', $attr, $match))
+ {
+ $attrname = $match[1];
+ $working = $mode = 1;
+ $attr = preg_replace('/^[-a-zA-Z]+/', '', $attr);
+ }
+
+ break;
+
+ case 1: # equals sign or valueless ("selected")
+
+ if (preg_match('/^\s*=\s*/', $attr)) # equals sign
+ {
+ $working = 1; $mode = 2;
+ $attr = preg_replace('/^\s*=\s*/', '', $attr);
+ break;
+ }
+
+ if (preg_match('/^\s+/', $attr)) # valueless
+ {
+ $working = 1; $mode = 0;
+ $attrarr[] = array
+ ('name' => $attrname,
+ 'value' => '',
+ 'whole' => $attrname,
+ 'vless' => 'y');
+ $attr = preg_replace('/^\s+/', '', $attr);
+ }
+
+ break;
+
+ case 2: # attribute value, a URL after href= for instance
+
+ if (preg_match('/^"([^"]*)"(\s+|$)/', $attr, $match))
+ # "value"
+ {
+ $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
+
+ $attrarr[] = array
+ ('name' => $attrname,
+ 'value' => $thisval,
+ 'whole' => "$attrname=\"$thisval\"",
+ 'vless' => 'n');
+ $working = 1; $mode = 0;
+ $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr);
+ break;
+ }
+
+ if (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match))
+ # 'value'
+ {
+ $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
+
+ $attrarr[] = array
+ ('name' => $attrname,
+ 'value' => $thisval,
+ 'whole' => "$attrname='$thisval'",
+ 'vless' => 'n');
+ $working = 1; $mode = 0;
+ $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr);
+ break;
+ }
+
+ if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match))
+ # value
+ {
+ $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
+
+ $attrarr[] = array
+ ('name' => $attrname,
+ 'value' => $thisval,
+ 'whole' => "$attrname=\"$thisval\"",
+ 'vless' => 'n');
+ # We add quotes to conform to W3C's HTML spec.
+ $working = 1; $mode = 0;
+ $attr = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr);
+ }
+
+ break;
+ } # switch
+
+ if ($working == 0) # not well formed, remove and try again
+ {
+ $attr = wp_kses_html_error($attr);
+ $mode = 0;
+ }
+ } # while
+
+ if ($mode == 1)
+ # special case, for when the attribute list ends with a valueless
+ # attribute like "selected"
+ $attrarr[] = array
+ ('name' => $attrname,
+ 'value' => '',
+ 'whole' => $attrname,
+ 'vless' => 'y');
+
+ return $attrarr;
+} # function wp_kses_hair
+
+
+function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue)
+###############################################################################
+# This function performs different checks for attribute values. The currently
+# implemented checks are "maxlen", "minlen", "maxval", "minval" and "valueless"
+# with even more checks to come soon.
+###############################################################################
+{
+ $ok = true;
+
+ switch (strtolower($checkname))
+ {
+ case 'maxlen':
+ # The maxlen check makes sure that the attribute value has a length not
+ # greater than the given value. This can be used to avoid Buffer Overflows
+ # in WWW clients and various Internet servers.
+
+ if (strlen($value) > $checkvalue)
+ $ok = false;
+ break;
+
+ case 'minlen':
+ # The minlen check makes sure that the attribute value has a length not
+ # smaller than the given value.
+
+ if (strlen($value) < $checkvalue)
+ $ok = false;
+ break;
+
+ case 'maxval':
+ # The maxval check does two things: it checks that the attribute value is
+ # an integer from 0 and up, without an excessive amount of zeroes or
+ # whitespace (to avoid Buffer Overflows). It also checks that the attribute
+ # value is not greater than the given value.
+ # This check can be used to avoid Denial of Service attacks.
+
+ if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value))
+ $ok = false;
+ if ($value > $checkvalue)
+ $ok = false;
+ break;
+
+ case 'minval':
+ # The minval check checks that the attribute value is a positive integer,
+ # and that it is not smaller than the given value.
+
+ if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value))
+ $ok = false;
+ if ($value < $checkvalue)
+ $ok = false;
+ break;
+
+ case 'valueless':
+ # The valueless check checks if the attribute has a value
+ # (like <a href="blah">) or not (<option selected>). If the given value
+ # is a "y" or a "Y", the attribute must not have a value.
+ # If the given value is an "n" or an "N", the attribute must have one.
+
+ if (strtolower($checkvalue) != $vless)
+ $ok = false;
+ break;
+ } # switch
+
+ return $ok;
+} # function wp_kses_check_attr_val
+
+
+function wp_kses_bad_protocol($string, $allowed_protocols)
+###############################################################################
+# This function removes all non-allowed protocols from the beginning of
+# $string. It ignores whitespace and the case of the letters, and it does
+# understand HTML entities. It does its work in a while loop, so it won't be
+# fooled by a string like "javascript:javascript:alert(57)".
+###############################################################################
+{
+ $string = wp_kses_no_null($string);
+ $string2 = $string.'a';
+
+ while ($string != $string2)
+ {
+ $string2 = $string;
+ $string = wp_kses_bad_protocol_once($string, $allowed_protocols);
+ } # while
+
+ return $string;
+} # function wp_kses_bad_protocol
+
+
+function wp_kses_no_null($string)
+###############################################################################
+# This function removes any NULL or chr(173) characters in $string.
+###############################################################################
+{
+ $string = preg_replace('/\0+/', '', $string);
+ $string = preg_replace('/(\\\\0)+/', '', $string);
+
+ return $string;
+} # function wp_kses_no_null
+
+
+function wp_kses_stripslashes($string)
+###############################################################################
+# This function changes the character sequence \" to just "
+# It leaves all other slashes alone. It's really weird, but the quoting from
+# preg_replace(//e) seems to require this.
+###############################################################################
+{
+ return preg_replace('%\\\\"%', '"', $string);
+} # function wp_kses_stripslashes
+
+
+function wp_kses_array_lc($inarray)
+###############################################################################
+# This function goes through an array, and changes the keys to all lower case.
+###############################################################################
+{
+ $outarray = array();
+
+ foreach ($inarray as $inkey => $inval)
+ {
+ $outkey = strtolower($inkey);
+ $outarray[$outkey] = array();
+
+ foreach ($inval as $inkey2 => $inval2)
+ {
+ $outkey2 = strtolower($inkey2);
+ $outarray[$outkey][$outkey2] = $inval2;
+ } # foreach $inval
+ } # foreach $inarray
+
+ return $outarray;
+} # function wp_kses_array_lc
+
+
+function wp_kses_js_entities($string)
+###############################################################################
+# This function removes the HTML JavaScript entities found in early versions of
+# Netscape 4.
+###############################################################################
+{
+ return preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string);
+} # function wp_kses_js_entities
+
+
+function wp_kses_html_error($string)
+###############################################################################
+# This function deals with parsing errors in wp_kses_hair(). The general plan is
+# to remove everything to and including some whitespace, but it deals with
+# quotes and apostrophes as well.
+###############################################################################
+{
+ return preg_replace('/^("[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*/', '', $string);
+} # function wp_kses_html_error
+
+
+function wp_kses_bad_protocol_once($string, $allowed_protocols)
+###############################################################################
+# This function searches for URL protocols at the beginning of $string, while
+# handling whitespace and HTML entities.
+###############################################################################
+{
+ return preg_replace('/^((&[^;]*;|[\sA-Za-z0-9])*)'.
+ '(:|&#58;|&#[Xx]3[Aa];)\s*/e',
+ 'wp_kses_bad_protocol_once2("\\1", $allowed_protocols)',
+ $string);
+} # function wp_kses_bad_protocol_once
+
+
+function wp_kses_bad_protocol_once2($string, $allowed_protocols)
+###############################################################################
+# This function processes URL protocols, checks to see if they're in the white-
+# list or not, and returns different data depending on the answer.
+###############################################################################
+{
+ $string2 = wp_kses_decode_entities($string);
+ $string2 = preg_replace('/\s/', '', $string2);
+ $string2 = wp_kses_no_null($string2);
+ $string2 = strtolower($string2);
+
+ $allowed = false;
+ foreach ($allowed_protocols as $one_protocol)
+ if (strtolower($one_protocol) == $string2)
+ {
+ $allowed = true;
+ break;
+ }
+
+ if ($allowed)
+ return "$string2:";
+ else
+ return '';
+} # function wp_kses_bad_protocol_once2
+
+
+function wp_kses_normalize_entities($string)
+###############################################################################
+# This function normalizes HTML entities. It will convert "AT&T" to the correct
+# "AT&amp;T", "&#00058;" to "&#58;", "&#XYZZY;" to "&amp;#XYZZY;" and so on.
+###############################################################################
+{
+# Disarm all entities by converting & to &amp;
+
+ $string = str_replace('&', '&amp;', $string);
+
+# Change back the allowed entities in our entity whitelist
+
+ $string = preg_replace('/&amp;([A-Za-z][A-Za-z0-9]{0,19});/',
+ '&\\1;', $string);
+ $string = preg_replace('/&amp;#0*([0-9]{1,5});/e',
+ 'wp_kses_normalize_entities2("\\1")', $string);
+ $string = preg_replace('/&amp;#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/',
+ '&#\\1\\2;', $string);
+
+ return $string;
+} # function wp_kses_normalize_entities
+
+
+function wp_kses_normalize_entities2($i)
+###############################################################################
+# This function helps wp_kses_normalize_entities() to only accept 16 bit values
+# and nothing more for &#number; entities.
+###############################################################################
+{
+ return (($i > 65535) ? "&amp;#$i;" : "&#$i;");
+} # function wp_kses_normalize_entities2
+
+
+function wp_kses_decode_entities($string)
+###############################################################################
+# This function decodes numeric HTML entities (&#65; and &#x41;). It doesn't
+# do anything with other entities like &auml;, but we don't need them in the
+# URL protocol whitelisting system anyway.
+###############################################################################
+{
+ $string = preg_replace('/&#([0-9]+);/e', 'chr("\\1")', $string);
+ $string = preg_replace('/&#[Xx]([0-9A-Fa-f]+);/e', 'chr(hexdec("\\1"))',
+ $string);
+
+ return $string;
+} # function wp_kses_decode_entities
+
+function wp_filter_kses( $string ) {
+ global $allowedtags;
+ return wp_kses($string, $allowedtags);
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/links.php b/wp-inst/wp-includes/links.php
new file mode 100644
index 0000000..52292ae
--- /dev/null
+++ b/wp-inst/wp-includes/links.php
@@ -0,0 +1,568 @@
+<?php
+
+/** function get_linksbyname()
+ ** Gets the links associated with category 'cat_name'.
+ ** Parameters:
+ ** cat_name (default 'noname') - The category name to use. If no
+ ** match is found uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and it's description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url', 'description' or 'rating'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined
+ ** show_rating (default false) - show rating stars/chars
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - whether to show last updated timestamp
+ */
+function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />',
+ $between = " ", $show_images = true, $orderby = 'id',
+ $show_description = true, $show_rating = false,
+ $limit = -1, $show_updated = 0) {
+ global $wpdb;
+ $cat_id = -1;
+ $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
+ if ($results) {
+ foreach ($results as $result) {
+ $cat_id = $result->cat_id;
+ }
+ }
+ get_links($cat_id, $before, $after, $between, $show_images, $orderby,
+ $show_description, $show_rating, $limit, $show_updated);
+}
+
+function bool_from_yn($yn) {
+ if ($yn == 'Y') return 1;
+ return 0;
+}
+
+/** function wp_get_linksbyname()
+ ** Gets the links associated with the named category.
+ ** Parameters:
+ ** category (no default) - The category to use.
+ **/
+function wp_get_linksbyname($category, $args = '') {
+ global $wpdb;
+
+ $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
+ . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
+ . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_name='$category'");
+
+ if (! $cat) {
+ return;
+ }
+
+ if (empty($args)) {
+ if ($cat->sort_desc == 'Y') {
+ $cat->sort_order = '_'.$cat->sort_order;
+ }
+ get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
+ $cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
+ bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
+ $cat->list_limit, bool_from_yn($cat->show_updated));
+ } else {
+ $args = add_query_arg('category', $cat->cat_id, $args);
+ wp_get_links($args);
+ }
+} // end wp_get_linksbyname
+
+/** function wp_get_links()
+ ** Gets the links associated with category n.
+ ** Parameters:
+ ** category (no default) - The category to use.
+ ** or:
+ ** a query string
+ **/
+function wp_get_links($args = '') {
+ global $wpdb;
+
+ if (!empty($args) && false === strpos($args, '=')) {
+ // If args is not a query string, it's a category id.
+ $category = $args;
+ $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
+ . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
+ . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$category");
+ if ($cat) {
+ if ($cat->sort_desc == 'Y') {
+ $cat->sort_order = '_'.$cat->sort_order;
+ }
+ get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
+ $cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
+ bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
+ $cat->list_limit, bool_from_yn($cat->show_updated));
+ }
+ } else {
+ parse_str($args);
+
+ if (! isset($category)) $category = -1;
+ if (! isset($before)) $before = '';
+ if (! isset($after)) $after = '<br />';
+ if (! isset($between)) $between = ' ';
+ if (! isset($show_images)) $show_images = true;
+ if (! isset($orderby)) $orderby = 'name';
+ if (! isset($show_description)) $show_description = true;
+ if (! isset($show_rating)) $show_rating = false;
+ if (! isset($limit)) $limit = -1;
+ if (! isset($show_updated)) $show_updated = 1;
+ if (! isset($echo)) $echo = true;
+
+ return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
+ }
+} // end wp_get_links
+
+/** function get_links()
+ ** Gets the links associated with category n.
+ ** Parameters:
+ ** category (default -1) - The category to use. If no category supplied
+ ** uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and it's description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url', 'description', or 'rating'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined .
+ ** show_rating (default false) - show rating stars/chars
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - whether to show last updated timestamp
+ */
+function get_links($category = -1, $before = '', $after = '<br />',
+ $between = ' ', $show_images = true, $orderby = 'name',
+ $show_description = true, $show_rating = false,
+ $limit = -1, $show_updated = 1, $echo = true) {
+
+ global $wpdb;
+
+ $direction = ' ASC';
+ $category_query = "";
+ if ($category != -1) {
+ $category_query = " AND link_category = $category ";
+ }
+ if (get_settings('links_recently_updated_time')) {
+ $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL ".get_settings('links_recently_updated_time')." MINUTE) >= NOW(), 1,0) as recently_updated ";
+ } else {
+ $recently_updated_test = '';
+ }
+ if ($show_updated) {
+ $get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
+ }
+
+ $orderby=strtolower($orderby);
+ if ($orderby == '')
+ $orderby = 'id';
+ if (substr($orderby,0,1) == '_') {
+ $direction = ' DESC';
+ $orderby = substr($orderby,1);
+ }
+
+ switch($orderby) {
+ case 'length':
+ $length = ",CHAR_LENGTH(link_name) AS length";
+ break;
+ case 'rand':
+ $orderby = 'rand()';
+ break;
+ default:
+ $orderby = " link_" . $orderby;
+ }
+
+ if (!isset($length)) {
+ $length = "";
+ }
+
+ $sql = "SELECT link_url, link_name, link_image, link_target,
+ link_description, link_rating, link_rel $length $recently_updated_test $get_updated
+ FROM $wpdb->links
+ WHERE link_visible = 'Y' " .
+ $category_query;
+ $sql .= ' ORDER BY ' . $orderby;
+ $sql .= $direction;
+ /* The next 2 lines implement LIMIT TO processing */
+ if ($limit != -1)
+ $sql .= " LIMIT $limit";
+ //echo $sql;
+ $results = $wpdb->get_results($sql);
+ if (!$results) {
+ return;
+ }
+
+ $output = "";
+
+ foreach ($results as $row) {
+ if (!isset($row->recently_updated)) $row->recently_updated = false;
+ $output .= ($before);
+
+ if ($show_updated && $row->recently_updated) {
+ $output .= get_settings('links_recently_updated_prepend');
+ }
+
+ $the_link = '#';
+
+ if ( !empty($row->link_url) )
+ $the_link = wp_specialchars($row->link_url);
+ $rel = $row->link_rel;
+
+ if ($rel != '') {
+ $rel = " rel='$rel'";
+ }
+
+ $desc = wp_specialchars($row->link_description, ENT_QUOTES);
+ $name = wp_specialchars($row->link_name, ENT_QUOTES);
+
+ $title = $desc;
+
+ if ($show_updated) {
+ if (substr($row->link_updated_f,0,2) != '00') {
+ $title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $row->link_updated_f + (get_settings('gmt_offset') * 3600)) .')';
+ }
+ }
+
+ if ('' != $title) {
+ $title = " title='$title'";
+ }
+
+ $alt = " alt='$name'";
+
+ $target = $row->link_target;
+ if ('' != $target) {
+ $target = " target='$target'";
+ }
+
+ $output.= "<a href='$the_link'";
+ $output.= $rel . $title . $target;
+ $output.= '>';
+
+ if (($row->link_image != null) && $show_images) {
+ if (strstr($row->link_image, 'http'))
+ $output.= "<img src='$row->link_image' $alt $title />";
+ else // If it's a relative path
+ $output.= "<img src='" . get_settings('siteurl') . "$row->link_image' $alt $title />";
+ } else {
+ $output.= $name;
+ }
+
+ $output.= '</a>';
+
+ if ($show_updated && $row->recently_updated) {
+ $output.= get_settings('links_recently_updated_append');
+ }
+
+ if ($show_description && ($desc != '')) {
+ $output.= $between.$desc;
+ }
+ $output.= "$after\n";
+ } // end while
+
+ if($echo) {
+ echo $output;
+ } else {
+ return $output;
+ }
+}
+
+
+/** function get_linkobjectsbyname()
+ ** Gets an array of link objects associated with category 'cat_name'.
+ ** Parameters:
+ ** cat_name (default 'noname') - The category name to use. If no
+ ** match is found uses all
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url', 'description', or 'rating'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ **
+ ** Use this like:
+ ** $links = get_linkobjectsbyname('fred');
+ ** foreach ($links as $link) {
+ ** echo '<li>'.$link->link_name.'</li>';
+ ** }
+ **/
+function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
+ global $wpdb;
+ $cat_id = -1;
+ $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
+ if ($results) {
+ foreach ($results as $result) {
+ $cat_id = $result->cat_id;
+ }
+ }
+ return get_linkobjects($cat_id, $orderby, $limit);
+}
+
+/** function get_linkobjects()
+ ** Gets an array of link objects associated with category n.
+ ** Parameters:
+ ** category (default -1) - The category to use. If no category supplied
+ ** uses all
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url', 'description', or 'rating'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ **
+ ** Use this like:
+ ** $links = get_linkobjects(1);
+ ** if ($links) {
+ ** foreach ($links as $link) {
+ ** echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
+ ** }
+ ** }
+ ** Fields are:
+ ** link_id
+ ** link_url
+ ** link_name
+ ** link_image
+ ** link_target
+ ** link_category
+ ** link_description
+ ** link_visible
+ ** link_owner
+ ** link_rating
+ ** link_updated
+ ** link_rel
+ ** link_notes
+ **/
+function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
+ global $wpdb;
+
+ $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";
+ if ($category != -1) {
+ $sql .= " AND link_category = $category ";
+ }
+ if ($orderby == '')
+ $orderby = 'id';
+ if (substr($orderby,0,1) == '_') {
+ $direction = ' DESC';
+ $orderby = substr($orderby,1);
+ }
+ if (strcasecmp('rand',$orderby) == 0) {
+ $orderby = 'rand()';
+ } else {
+ $orderby = " link_" . $orderby;
+ }
+ $sql .= ' ORDER BY ' . $orderby;
+ $sql .= $direction;
+ /* The next 2 lines implement LIMIT TO processing */
+ if ($limit != -1)
+ $sql .= " LIMIT $limit";
+
+ $results = $wpdb->get_results($sql);
+ if ($results) {
+ foreach ($results as $result) {
+ $result->link_url = $result->link_url;
+ $result->link_name = $result->link_name;
+ $result->link_description = $result->link_description;
+ $result->link_notes = $result->link_notes;
+ $newresults[] = $result;
+ }
+ }
+ return $newresults;
+}
+
+function get_linkrating($link) {
+ return apply_filters('link_rating', $link->link_rating);
+}
+
+
+/** function get_linksbyname_withrating()
+ ** Gets the links associated with category 'cat_name' and display rating stars/chars.
+ ** Parameters:
+ ** cat_name (default 'noname') - The category name to use. If no
+ ** match is found uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and it's description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url' or 'description'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - whether to show last updated timestamp
+ */
+function get_linksbyname_withrating($cat_name = "noname", $before = '',
+ $after = '<br />', $between = " ",
+ $show_images = true, $orderby = 'id',
+ $show_description = true, $limit = -1, $show_updated = 0) {
+
+ get_linksbyname($cat_name, $before, $after, $between, $show_images,
+ $orderby, $show_description, true, $limit, $show_updated);
+}
+
+/** function get_links_withrating()
+ ** Gets the links associated with category n and display rating stars/chars.
+ ** Parameters:
+ ** category (default -1) - The category to use. If no category supplied
+ ** uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and it's description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url' or 'description'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined .
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - whether to show last updated timestamp
+ */
+function get_links_withrating($category = -1, $before = '', $after = '<br />',
+ $between = " ", $show_images = true,
+ $orderby = 'id', $show_description = true,
+ $limit = -1, $show_updated = 0) {
+
+ get_links($category, $before, $after, $between, $show_images, $orderby,
+ $show_description, true, $limit, $show_updated);
+}
+
+/** function get_linkcatname()
+ ** Gets the name of category n.
+ ** Parameters: id (default 0) - The category to get. If no category supplied
+ ** uses 0
+ */
+function get_linkcatname($id = 0) {
+ global $wpdb;
+ $cat_name = '';
+ if ('' != $id) {
+ $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->linkcategories WHERE cat_id=$id");
+ }
+ return $cat_name;
+}
+
+/** function get_get_autotoggle()
+ ** Gets the auto_toggle setting of category n.
+ ** Parameters: id (default 0) - The category to get. If no category supplied
+ ** uses 0
+ */
+function get_autotoggle($id = 0) {
+ global $wpdb;
+ $auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $wpdb->linkcategories WHERE cat_id=$id");
+ if ('' == $auto_toggle)
+ $auto_toggle = 'N';
+ return $auto_toggle;
+}
+
+/** function links_popup_script()
+ ** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/
+ ** Show the link to the links popup and the number of links
+ ** Parameters:
+ ** text (default Links) - the text of the link
+ ** width (default 400) - the width of the popup window
+ ** height (default 400) - the height of the popup window
+ ** file (default linkspopup.php) - the page to open in the popup window
+ ** count (default true) - the number of links in the db
+ */
+function links_popup_script($text = 'Links', $width=400, $height=400,
+ $file='links.all.php', $count = true) {
+ if ($count == true) {
+ $counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links");
+ }
+
+ $javascript = "<a href=\"#\" " .
+ " onclick=\"javascript:window.open('$file?popup=1', '_blank', " .
+ "'width=$width,height=$height,scrollbars=yes,status=no'); " .
+ " return false\">";
+ $javascript .= $text;
+
+ if ($count == true) {
+ $javascript .= " ($counts)";
+ }
+
+ $javascript .="</a>\n\n";
+ echo $javascript;
+}
+
+
+/*
+ * function get_links_list()
+ *
+ * added by Dougal
+ *
+ * Output a list of all links, listed by category, using the
+ * settings in $wpdb->linkcategories and output it as a nested
+ * HTML unordered list.
+ *
+ * Parameters:
+ * order (default 'name') - Sort link categories by 'name' or 'id'
+ * hide_if_empty (default true) - Supress listing empty link categories
+ */
+function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
+ global $wpdb;
+
+ $order = strtolower($order);
+
+ // Handle link category sorting
+ if (substr($order,0,1) == '_') {
+ $direction = ' DESC';
+ $order = substr($order,1);
+ }
+
+ // if 'name' wasn't specified, assume 'id':
+ $cat_order = ('name' == $order) ? 'cat_name' : 'cat_id';
+
+ if (!isset($direction)) $direction = '';
+ // Fetch the link category data as an array of hashesa
+ $cats = $wpdb->get_results("
+ SELECT DISTINCT link_category, cat_name, show_images,
+ show_description, show_rating, show_updated, sort_order,
+ sort_desc, list_limit
+ FROM `$wpdb->links`
+ LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id)
+ WHERE link_visible = 'Y'
+ AND list_limit <> 0
+ ORDER BY $cat_order $direction ", ARRAY_A);
+
+ // Display each category
+ if ($cats) {
+ foreach ($cats as $cat) {
+ // Handle each category.
+ // First, fix the sort_order info
+ $orderby = $cat['sort_order'];
+ $orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby;
+
+ // Display the category name
+ echo ' <li id="linkcat-' . $cat['link_category'] . '"><h2>' . $cat['cat_name'] . "</h2>\n\t<ul>\n";
+ // Call get_links() with all the appropriate params
+ get_links($cat['link_category'],
+ '<li>',"</li>","\n",
+ bool_from_yn($cat['show_images']),
+ $orderby,
+ bool_from_yn($cat['show_description']),
+ bool_from_yn($cat['show_rating']),
+ $cat['list_limit'],
+ bool_from_yn($cat['show_updated']));
+
+ // Close the last category
+ echo "\n\t</ul>\n</li>\n";
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/locale.php b/wp-inst/wp-includes/locale.php
new file mode 100644
index 0000000..7af4dea
--- /dev/null
+++ b/wp-inst/wp-includes/locale.php
@@ -0,0 +1,70 @@
+<?php
+// Date and Time
+
+// The Weekdays
+$weekday[0] = __('Sunday');
+$weekday[1] = __('Monday');
+$weekday[2] = __('Tuesday');
+$weekday[3] = __('Wednesday');
+$weekday[4] = __('Thursday');
+$weekday[5] = __('Friday');
+$weekday[6] = __('Saturday');
+
+// The first letter of each day. The _%day%_initial suffix is a hack to make
+// sure the day initials are unique. They should be translated to a one
+// letter initial.
+$weekday_initial[__('Sunday')] = __('S_Sunday_initial');
+$weekday_initial[__('Monday')] = __('M_Monday_initial');
+$weekday_initial[__('Tuesday')] = __('T_Tuesday_initial');
+$weekday_initial[__('Wednesday')] = __('W_Wednesday_initial');
+$weekday_initial[__('Thursday')] = __('T_Thursday_initial');
+$weekday_initial[__('Friday')] = __('F_Friday_initial');
+$weekday_initial[__('Saturday')] = __('S_Saturday_initial');
+
+foreach ($weekday_initial as $weekday_ => $weekday_initial_) {
+ $weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
+}
+
+// Abbreviations for each day.
+$weekday_abbrev[__('Sunday')] = __('Sun');
+$weekday_abbrev[__('Monday')] = __('Mon');
+$weekday_abbrev[__('Tuesday')] = __('Tue');
+$weekday_abbrev[__('Wednesday')] = __('Wed');
+$weekday_abbrev[__('Thursday')] = __('Thu');
+$weekday_abbrev[__('Friday')] = __('Fri');
+$weekday_abbrev[__('Saturday')] = __('Sat');
+
+// The Months
+$month['01'] = __('January');
+$month['02'] = __('February');
+$month['03'] = __('March');
+$month['04'] = __('April');
+$month['05'] = __('May');
+$month['06'] = __('June');
+$month['07'] = __('July');
+$month['08'] = __('August');
+$month['09'] = __('September');
+$month['10'] = __('October');
+$month['11'] = __('November');
+$month['12'] = __('December');
+
+// Abbreviations for each month. Uses the same hack as above to get around the
+// 'May' duplication.
+$month_abbrev[__('January')] = __('Jan_January_abbreviation');
+$month_abbrev[__('February')] = __('Feb_February_abbreviation');
+$month_abbrev[__('March')] = __('Mar_March_abbreviation');
+$month_abbrev[__('April')] = __('Apr_April_abbreviation');
+$month_abbrev[__('May')] = __('May_May_abbreviation');
+$month_abbrev[__('June')] = __('Jun_June_abbreviation');
+$month_abbrev[__('July')] = __('Jul_July_abbreviation');
+$month_abbrev[__('August')] = __('Aug_August_abbreviation');
+$month_abbrev[__('September')] = __('Sep_September_abbreviation');
+$month_abbrev[__('October')] = __('Oct_October_abbreviation');
+$month_abbrev[__('November')] = __('Nov_November_abbreviation');
+$month_abbrev[__('December')] = __('Dec_December_abbreviation');
+
+foreach ($month_abbrev as $month_ => $month_abbrev_) {
+ $month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/pluggable-functions.php b/wp-inst/wp-includes/pluggable-functions.php
new file mode 100644
index 0000000..4d25ffd
--- /dev/null
+++ b/wp-inst/wp-includes/pluggable-functions.php
@@ -0,0 +1,282 @@
+<?php
+
+ /* These functions can be replaced via plugins. They are loaded after
+ plugins are loaded. */
+
+
+if ( !function_exists('get_currentuserinfo') ) :
+function get_currentuserinfo() {
+ global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
+
+ if ( !isset($_COOKIE['wordpressuser_' . COOKIEHASH]))
+ return false;
+
+ $user_login = $_COOKIE['wordpressuser_' . COOKIEHASH];
+ $userdata = get_userdatabylogin($user_login);
+ $user_level = $userdata->user_level;
+ $user_ID = $userdata->ID;
+ $user_email = $userdata->user_email;
+ $user_url = $userdata->user_url;
+ $user_pass_md5 = md5($userdata->user_pass);
+ $user_identity = $userdata->display_name;
+
+ if ( empty($current_user) )
+ $current_user = new WP_User($user_ID);
+}
+endif;
+
+if ( !function_exists('get_userdata') ) :
+function get_userdata( $user_id ) {
+ global $wpdb, $cache_userdata;
+ $user_id = (int) $user_id;
+ if ( $user_id == 0 )
+ return false;
+
+ if ( isset( $cache_userdata[$user_id] ) )
+ return $cache_userdata[$user_id];
+
+ if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$user_id'") )
+ return $cache_userdata[$user_id] = false;
+
+ $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'");
+
+ foreach ( $metavalues as $meta ) {
+ @ $value = unserialize($meta->meta_value);
+ if ($value === FALSE)
+ $value = $meta->meta_value;
+ $user->{$meta->meta_key} = $value;
+
+ // We need to set user_level from meta, not row
+ if ( $wpdb->prefix . 'user_level' == $meta->meta_key )
+ $user->user_level = $meta->meta_value;
+ }
+
+ $cache_userdata[$user_id] = $user;
+
+ $cache_userdata[$cache_userdata[$userid]->user_login] =& $cache_userdata[$user_id];
+
+ return $cache_userdata[$user_id];
+}
+endif;
+
+if ( !function_exists('get_userdatabylogin') ) :
+function get_userdatabylogin($user_login) {
+ global $cache_userdata, $wpdb;
+ $user_login = sanitize_user( $user_login );
+ if ( empty( $user_login ) )
+ return false;
+ if ( isset( $cache_userdata[$user_login] ) )
+ return $cache_userdata[$user_login];
+
+ $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$user_login'");
+
+ return get_userdata( $user_id );
+}
+endif;
+
+if ( !function_exists('wp_mail') ) :
+function wp_mail($to, $subject, $message, $headers = '') {
+ if( $headers == '' ) {
+ $headers = "MIME-Version: 1.0\n" .
+ "From: " . get_settings('admin_email') . "\n" .
+ "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n";
+ }
+
+ return @mail($to, $subject, $message, $headers);
+}
+endif;
+
+if ( !function_exists('wp_login') ) :
+function wp_login($username, $password, $already_md5 = false) {
+ global $wpdb, $error;
+
+ if ( !$username )
+ return false;
+
+ if ( !$password ) {
+ $error = __('<strong>Error</strong>: The password field is empty.');
+ return false;
+ }
+
+ $login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'");
+
+ if (!$login) {
+ $error = __('<strong>Error</strong>: Wrong username.');
+ return false;
+ } else {
+ // If the password is already_md5, it has been double hashed.
+ // Otherwise, it is plain text.
+ if ( ($already_md5 && $login->user_login == $username && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) {
+ return true;
+ } else {
+ $error = __('<strong>Error</strong>: Incorrect password.');
+ $pwd = '';
+ return false;
+ }
+ }
+}
+endif;
+
+if ( !function_exists('auth_redirect') ) :
+function auth_redirect() {
+ // Checks if a user is logged in, if not redirects them to the login page
+ if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) &&
+ !wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) ||
+ (empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) {
+ nocache_headers();
+
+ header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
+ exit();
+ }
+}
+endif;
+
+// Cookie safe redirect. Works around IIS Set-Cookie bug.
+// http://support.microsoft.com/kb/q176113/
+if ( !function_exists('wp_redirect') ) :
+function wp_redirect($location) {
+ global $is_IIS;
+
+ if ($is_IIS)
+ header("Refresh: 0;url=$location");
+ else
+ header("Location: $location");
+}
+endif;
+
+if ( !function_exists('wp_setcookie') ) :
+function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '') {
+ if ( !$already_md5 )
+ $password = md5( md5($password) ); // Double hash the password in the cookie.
+
+ if ( empty($home) )
+ $cookiepath = COOKIEPATH;
+ else
+ $cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' );
+
+ if ( empty($siteurl) ) {
+ $sitecookiepath = SITECOOKIEPATH;
+ $cookiehash = COOKIEHASH;
+ } else {
+ $sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' );
+ $cookiehash = md5($siteurl);
+ }
+
+ setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $cookiepath);
+ setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $cookiepath);
+
+ if ( $cookiepath != $sitecookiepath ) {
+ setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $sitecookiepath);
+ setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $sitecookiepath);
+ }
+}
+endif;
+
+if ( !function_exists('wp_clearcookie') ) :
+function wp_clearcookie() {
+ setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH);
+ setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH);
+ setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH);
+ setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH);
+}
+endif;
+
+if ( ! function_exists('wp_notify_postauthor') ) :
+function wp_notify_postauthor($comment_id, $comment_type='') {
+ global $wpdb;
+
+ $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
+ $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
+ $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1");
+
+ if ('' == $user->user_email) return false; // If there's no email to send the comment to
+
+ $comment_author_domain = gethostbyaddr($comment->comment_author_IP);
+
+ $blogname = get_settings('blogname');
+
+ if ( empty( $comment_type ) ) $comment_type = 'comment';
+
+ if ('comment' == $comment_type) {
+ $notify_message = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
+ $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+ $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
+ $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";
+ $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
+ $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+ $notify_message .= __('You can see all comments on this post here: ') . "\r\n";
+ $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
+ } elseif ('trackback' == $comment_type) {
+ $notify_message = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
+ $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+ $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";
+ $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+ $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
+ $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
+ } elseif ('pingback' == $comment_type) {
+ $notify_message = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
+ $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+ $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";
+ $notify_message .= __('Excerpt: ') . "\r\n" . sprintf( __('[...] %s [...]'), $comment->comment_content ) . "\r\n\r\n";
+ $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
+ $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
+ }
+ $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
+ $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n";
+
+ if ('' == $comment->comment_author_email || '' == $comment->comment_author) {
+ $from = "From: \"$blogname\" <wordpress@" . $_SERVER['SERVER_NAME'] . '>';
+ } else {
+ $from = 'From: "' . $comment->comment_author . "\" <$comment->comment_author_email>";
+ }
+
+ $message_headers = "MIME-Version: 1.0\n"
+ . "$from\n"
+ . "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n";
+
+ @wp_mail($user->user_email, $subject, $notify_message, $message_headers);
+
+ return true;
+}
+endif;
+
+/* wp_notify_moderator
+ notifies the moderator of the blog (usually the admin)
+ about a new comment that waits for approval
+ always returns true
+ */
+if ( !function_exists('wp_notify_moderator') ) :
+function wp_notify_moderator($comment_id) {
+ global $wpdb;
+
+ if( get_settings( "moderation_notify" ) == 0 )
+ return true;
+
+ $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
+ $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
+
+ $comment_author_domain = gethostbyaddr($comment->comment_author_IP);
+ $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
+
+ $notify_message = sprintf( __('A new comment on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n";
+ $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
+ $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+ $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
+ $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n";
+ $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
+ $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+ $notify_message .= sprintf( __('To approve this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=mailapprovecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n";
+ $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n";
+ $notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n";
+ $notify_message .= get_settings('siteurl') . "/wp-admin/moderation.php\r\n";
+
+ $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_settings('blogname'), $post->post_title );
+ $admin_email = get_settings("admin_email");
+
+ @wp_mail($admin_email, $subject, $notify_message);
+
+ return true;
+}
+endif;
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/registration-functions.php b/wp-inst/wp-includes/registration-functions.php
new file mode 100644
index 0000000..9299d01
--- /dev/null
+++ b/wp-inst/wp-includes/registration-functions.php
@@ -0,0 +1,32 @@
+<?php
+
+function username_exists( $username ) {
+ global $wpdb;
+ $username = sanitize_user( $username );
+ $query = "SELECT user_login FROM $wpdb->users WHERE user_login = '$username'";
+ $query = apply_filters('username_exists', $query);
+ return $wpdb->get_var( $query );
+}
+
+function create_user( $username, $password, $email, $user_level ) {
+ global $wpdb;
+ $username = $wpdb->escape( $username );
+ $email = $wpdb->escape( $email );
+ $password = md5( $password );
+ $user_nicename = sanitize_title( $username );
+ $now = gmdate('Y-m-d H:i:s');
+
+ $query = "INSERT INTO $wpdb->users
+ (user_login, user_pass, user_email, user_registered, user_nicename, display_name)
+ VALUES
+ ('$username', '$password', '$email', '$now', '$user_nicename', '$username')";
+ $query = apply_filters('create_user_query', $query);
+ $wpdb->query( $query );
+ $user_id = $wpdb->insert_id;
+
+ $user_level = (int) $user_level;
+ update_usermeta( $user_id, $wpdb->prefix . 'user_level', $user_level);
+ return $user_id;
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/rss-functions.php b/wp-inst/wp-includes/rss-functions.php
new file mode 100644
index 0000000..960c273
--- /dev/null
+++ b/wp-inst/wp-includes/rss-functions.php
@@ -0,0 +1,850 @@
+<?php
+/*
+ * Project: MagpieRSS: a simple RSS integration tool
+ * File: A compiled file for RSS syndication
+ * Author: Kellan Elliott-McCrea <kellan@protest.net>
+ * Version: 0.51
+ * License: GPL
+ */
+
+define('RSS', 'RSS');
+define('ATOM', 'Atom');
+define('MAGPIE_USER_AGENT', 'WordPress/' . $wp_version);
+
+class MagpieRSS {
+ var $parser;
+ var $current_item = array(); // item currently being parsed
+ var $items = array(); // collection of parsed items
+ var $channel = array(); // hash of channel fields
+ var $textinput = array();
+ var $image = array();
+ var $feed_type;
+ var $feed_version;
+
+ // parser variables
+ var $stack = array(); // parser stack
+ var $inchannel = false;
+ var $initem = false;
+ var $incontent = false; // if in Atom <content mode="xml"> field
+ var $intextinput = false;
+ var $inimage = false;
+ var $current_field = '';
+ var $current_namespace = false;
+
+ //var $ERROR = "";
+
+ var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
+
+ function MagpieRSS ($source) {
+
+ # if PHP xml isn't compiled in, die
+ #
+ if (!function_exists('xml_parser_create')) {
+ $this->error( "Failed to load PHP's XML Extension. " .
+ "http://www.php.net/manual/en/ref.xml.php",
+ E_USER_ERROR );
+ }
+
+ $parser = @xml_parser_create();
+
+ if (!is_resource($parser))
+ {
+ $this->error( "Failed to create an instance of PHP's XML parser. " .
+ "http://www.php.net/manual/en/ref.xml.php",
+ E_USER_ERROR );
+ }
+
+
+ $this->parser = $parser;
+
+ # pass in parser, and a reference to this object
+ # setup handlers
+ #
+ xml_set_object( $this->parser, $this );
+ xml_set_element_handler($this->parser,
+ 'feed_start_element', 'feed_end_element' );
+
+ xml_set_character_data_handler( $this->parser, 'feed_cdata' );
+
+ $status = xml_parse( $this->parser, $source );
+
+ if (! $status ) {
+ $errorcode = xml_get_error_code( $this->parser );
+ if ( $errorcode != XML_ERROR_NONE ) {
+ $xml_error = xml_error_string( $errorcode );
+ $error_line = xml_get_current_line_number($this->parser);
+ $error_col = xml_get_current_column_number($this->parser);
+ $errormsg = "$xml_error at line $error_line, column $error_col";
+
+ $this->error( $errormsg );
+ }
+ }
+
+ xml_parser_free( $this->parser );
+
+ $this->normalize();
+ }
+
+ function feed_start_element($p, $element, &$attrs) {
+ $el = $element = strtolower($element);
+ $attrs = array_change_key_case($attrs, CASE_LOWER);
+
+ // check for a namespace, and split if found
+ $ns = false;
+ if ( strpos( $element, ':' ) ) {
+ list($ns, $el) = split( ':', $element, 2);
+ }
+ if ( $ns and $ns != 'rdf' ) {
+ $this->current_namespace = $ns;
+ }
+
+ # if feed type isn't set, then this is first element of feed
+ # identify feed from root element
+ #
+ if (!isset($this->feed_type) ) {
+ if ( $el == 'rdf' ) {
+ $this->feed_type = RSS;
+ $this->feed_version = '1.0';
+ }
+ elseif ( $el == 'rss' ) {
+ $this->feed_type = RSS;
+ $this->feed_version = $attrs['version'];
+ }
+ elseif ( $el == 'feed' ) {
+ $this->feed_type = ATOM;
+ $this->feed_version = $attrs['version'];
+ $this->inchannel = true;
+ }
+ return;
+ }
+
+ if ( $el == 'channel' )
+ {
+ $this->inchannel = true;
+ }
+ elseif ($el == 'item' or $el == 'entry' )
+ {
+ $this->initem = true;
+ if ( isset($attrs['rdf:about']) ) {
+ $this->current_item['about'] = $attrs['rdf:about'];
+ }
+ }
+
+ // if we're in the default namespace of an RSS feed,
+ // record textinput or image fields
+ elseif (
+ $this->feed_type == RSS and
+ $this->current_namespace == '' and
+ $el == 'textinput' )
+ {
+ $this->intextinput = true;
+ }
+
+ elseif (
+ $this->feed_type == RSS and
+ $this->current_namespace == '' and
+ $el == 'image' )
+ {
+ $this->inimage = true;
+ }
+
+ # handle atom content constructs
+ elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
+ {
+ // avoid clashing w/ RSS mod_content
+ if ($el == 'content' ) {
+ $el = 'atom_content';
+ }
+
+ $this->incontent = $el;
+
+
+ }
+
+ // if inside an Atom content construct (e.g. content or summary) field treat tags as text
+ elseif ($this->feed_type == ATOM and $this->incontent )
+ {
+ // if tags are inlined, then flatten
+ $attrs_str = join(' ',
+ array_map('map_attrs',
+ array_keys($attrs),
+ array_values($attrs) ) );
+
+ $this->append_content( "<$element $attrs_str>" );
+
+ array_unshift( $this->stack, $el );
+ }
+
+ // Atom support many links per containging element.
+ // Magpie treats link elements of type rel='alternate'
+ // as being equivalent to RSS's simple link element.
+ //
+ elseif ($this->feed_type == ATOM and $el == 'link' )
+ {
+ if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
+ {
+ $link_el = 'link';
+ }
+ else {
+ $link_el = 'link_' . $attrs['rel'];
+ }
+
+ $this->append($link_el, $attrs['href']);
+ }
+ // set stack[0] to current element
+ else {
+ array_unshift($this->stack, $el);
+ }
+ }
+
+
+
+ function feed_cdata ($p, $text) {
+
+ if ($this->feed_type == ATOM and $this->incontent)
+ {
+ $this->append_content( $text );
+ }
+ else {
+ $current_el = join('_', array_reverse($this->stack));
+ $this->append($current_el, $text);
+ }
+ }
+
+ function feed_end_element ($p, $el) {
+ $el = strtolower($el);
+
+ if ( $el == 'item' or $el == 'entry' )
+ {
+ $this->items[] = $this->current_item;
+ $this->current_item = array();
+ $this->initem = false;
+ }
+ elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' )
+ {
+ $this->intextinput = false;
+ }
+ elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' )
+ {
+ $this->inimage = false;
+ }
+ elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
+ {
+ $this->incontent = false;
+ }
+ elseif ($el == 'channel' or $el == 'feed' )
+ {
+ $this->inchannel = false;
+ }
+ elseif ($this->feed_type == ATOM and $this->incontent ) {
+ // balance tags properly
+ // note: i don't think this is actually neccessary
+ if ( $this->stack[0] == $el )
+ {
+ $this->append_content("</$el>");
+ }
+ else {
+ $this->append_content("<$el />");
+ }
+
+ array_shift( $this->stack );
+ }
+ else {
+ array_shift( $this->stack );
+ }
+
+ $this->current_namespace = false;
+ }
+
+ function concat (&$str1, $str2="") {
+ if (!isset($str1) ) {
+ $str1="";
+ }
+ $str1 .= $str2;
+ }
+
+ function append_content($text) {
+ if ( $this->initem ) {
+ $this->concat( $this->current_item[ $this->incontent ], $text );
+ }
+ elseif ( $this->inchannel ) {
+ $this->concat( $this->channel[ $this->incontent ], $text );
+ }
+ }
+
+ // smart append - field and namespace aware
+ function append($el, $text) {
+ if (!$el) {
+ return;
+ }
+ if ( $this->current_namespace )
+ {
+ if ( $this->initem ) {
+ $this->concat(
+ $this->current_item[ $this->current_namespace ][ $el ], $text);
+ }
+ elseif ($this->inchannel) {
+ $this->concat(
+ $this->channel[ $this->current_namespace][ $el ], $text );
+ }
+ elseif ($this->intextinput) {
+ $this->concat(
+ $this->textinput[ $this->current_namespace][ $el ], $text );
+ }
+ elseif ($this->inimage) {
+ $this->concat(
+ $this->image[ $this->current_namespace ][ $el ], $text );
+ }
+ }
+ else {
+ if ( $this->initem ) {
+ $this->concat(
+ $this->current_item[ $el ], $text);
+ }
+ elseif ($this->intextinput) {
+ $this->concat(
+ $this->textinput[ $el ], $text );
+ }
+ elseif ($this->inimage) {
+ $this->concat(
+ $this->image[ $el ], $text );
+ }
+ elseif ($this->inchannel) {
+ $this->concat(
+ $this->channel[ $el ], $text );
+ }
+
+ }
+ }
+
+ function normalize () {
+ // if atom populate rss fields
+ if ( $this->is_atom() ) {
+ $this->channel['descripton'] = $this->channel['tagline'];
+ for ( $i = 0; $i < count($this->items); $i++) {
+ $item = $this->items[$i];
+ if ( isset($item['summary']) )
+ $item['description'] = $item['summary'];
+ if ( isset($item['atom_content']))
+ $item['content']['encoded'] = $item['atom_content'];
+
+ $this->items[$i] = $item;
+ }
+ }
+ elseif ( $this->is_rss() ) {
+ $this->channel['tagline'] = $this->channel['description'];
+ for ( $i = 0; $i < count($this->items); $i++) {
+ $item = $this->items[$i];
+ if ( isset($item['description']))
+ $item['summary'] = $item['description'];
+ if ( isset($item['content']['encoded'] ) )
+ $item['atom_content'] = $item['content']['encoded'];
+
+ $this->items[$i] = $item;
+ }
+ }
+ }
+
+ function is_rss () {
+ if ( $this->feed_type == RSS ) {
+ return $this->feed_version;
+ }
+ else {
+ return false;
+ }
+ }
+
+ function is_atom() {
+ if ( $this->feed_type == ATOM ) {
+ return $this->feed_version;
+ }
+ else {
+ return false;
+ }
+ }
+
+function map_attrs($k, $v) {
+ return "$k=\"$v\"";
+ }
+}
+require_once( dirname(__FILE__) . '/class-snoopy.php');
+
+function fetch_rss ($url) {
+ // initialize constants
+ init();
+
+ if ( !isset($url) ) {
+ error("fetch_rss called without a url");
+ return false;
+ }
+
+ // if cache is disabled
+ if ( !MAGPIE_CACHE_ON ) {
+ // fetch file, and parse it
+ $resp = _fetch_remote_file( $url );
+ if ( is_success( $resp->status ) ) {
+ return _response_to_rss( $resp );
+ }
+ else {
+ error("Failed to fetch $url and cache is off");
+ return false;
+ }
+ }
+ // else cache is ON
+ else {
+ // Flow
+ // 1. check cache
+ // 2. if there is a hit, make sure its fresh
+ // 3. if cached obj fails freshness check, fetch remote
+ // 4. if remote fails, return stale object, or error
+
+ $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
+
+ if (MAGPIE_DEBUG and $cache->ERROR) {
+ debug($cache->ERROR, E_USER_WARNING);
+ }
+
+
+ $cache_status = 0; // response of check_cache
+ $request_headers = array(); // HTTP headers to send with fetch
+ $rss = 0; // parsed RSS object
+ $errormsg = 0; // errors, if any
+
+ if (!$cache->ERROR) {
+ // return cache HIT, MISS, or STALE
+ $cache_status = $cache->check_cache( $url );
+ }
+
+ // if object cached, and cache is fresh, return cached obj
+ if ( $cache_status == 'HIT' ) {
+ $rss = $cache->get( $url );
+ if ( isset($rss) and $rss ) {
+ $rss->from_cache = 1;
+ if ( MAGPIE_DEBUG > 1) {
+ debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
+ }
+ return $rss;
+ }
+ }
+
+ // else attempt a conditional get
+
+ // setup headers
+ if ( $cache_status == 'STALE' ) {
+ $rss = $cache->get( $url );
+ if ( $rss->etag and $rss->last_modified ) {
+ $request_headers['If-None-Match'] = $rss->etag;
+ $request_headers['If-Last-Modified'] = $rss->last_modified;
+ }
+ }
+
+ $resp = _fetch_remote_file( $url, $request_headers );
+
+ if (isset($resp) and $resp) {
+ if ($resp->status == '304' ) {
+ // we have the most current copy
+ if ( MAGPIE_DEBUG > 1) {
+ debug("Got 304 for $url");
+ }
+ // reset cache on 304 (at minutillo insistent prodding)
+ $cache->set($url, $rss);
+ return $rss;
+ }
+ elseif ( is_success( $resp->status ) ) {
+ $rss = _response_to_rss( $resp );
+ if ( $rss ) {
+ if (MAGPIE_DEBUG > 1) {
+ debug("Fetch successful");
+ }
+ // add object to cache
+ $cache->set( $url, $rss );
+ return $rss;
+ }
+ }
+ else {
+ $errormsg = "Failed to fetch $url. ";
+ if ( $resp->error ) {
+ # compensate for Snoopy's annoying habbit to tacking
+ # on '\n'
+ $http_error = substr($resp->error, 0, -2);
+ $errormsg .= "(HTTP Error: $http_error)";
+ }
+ else {
+ $errormsg .= "(HTTP Response: " . $resp->response_code .')';
+ }
+ }
+ }
+ else {
+ $errormsg = "Unable to retrieve RSS file for unknown reasons.";
+ }
+
+ // else fetch failed
+
+ // attempt to return cached object
+ if ($rss) {
+ if ( MAGPIE_DEBUG ) {
+ debug("Returning STALE object for $url");
+ }
+ return $rss;
+ }
+
+ // else we totally failed
+ error( $errormsg );
+
+ return false;
+
+ } // end if ( !MAGPIE_CACHE_ON ) {
+} // end fetch_rss()
+
+function _fetch_remote_file ($url, $headers = "" ) {
+ // Snoopy is an HTTP client in PHP
+ $client = new Snoopy();
+ $client->agent = MAGPIE_USER_AGENT;
+ $client->read_timeout = MAGPIE_FETCH_TIME_OUT;
+ $client->use_gzip = MAGPIE_USE_GZIP;
+ if (is_array($headers) ) {
+ $client->rawheaders = $headers;
+ }
+
+ @$client->fetch($url);
+ return $client;
+
+}
+
+function _response_to_rss ($resp) {
+ $rss = new MagpieRSS( $resp->results );
+
+ // if RSS parsed successfully
+ if ( $rss and !$rss->ERROR) {
+
+ // find Etag, and Last-Modified
+ foreach($resp->headers as $h) {
+ // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
+ if (strpos($h, ": ")) {
+ list($field, $val) = explode(": ", $h, 2);
+ }
+ else {
+ $field = $h;
+ $val = "";
+ }
+
+ if ( $field == 'ETag' ) {
+ $rss->etag = $val;
+ }
+
+ if ( $field == 'Last-Modified' ) {
+ $rss->last_modified = $val;
+ }
+ }
+
+ return $rss;
+ } // else construct error message
+ else {
+ $errormsg = "Failed to parse RSS file.";
+
+ if ($rss) {
+ $errormsg .= " (" . $rss->ERROR . ")";
+ }
+ error($errormsg);
+
+ return false;
+ } // end if ($rss and !$rss->error)
+}
+
+/*=======================================================================*\
+ Function: init
+ Purpose: setup constants with default values
+ check for user overrides
+\*=======================================================================*/
+function init () {
+ if ( defined('MAGPIE_INITALIZED') ) {
+ return;
+ }
+ else {
+ define('MAGPIE_INITALIZED', 1);
+ }
+
+ if ( !defined('MAGPIE_CACHE_ON') ) {
+ define('MAGPIE_CACHE_ON', 1);
+ }
+
+ if ( !defined('MAGPIE_CACHE_DIR') ) {
+ define('MAGPIE_CACHE_DIR', './cache');
+ }
+
+ if ( !defined('MAGPIE_CACHE_AGE') ) {
+ define('MAGPIE_CACHE_AGE', 60*60); // one hour
+ }
+
+ if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) {
+ define('MAGPIE_CACHE_FRESH_ONLY', 0);
+ }
+
+ if ( !defined('MAGPIE_DEBUG') ) {
+ define('MAGPIE_DEBUG', 0);
+ }
+
+ if ( !defined('MAGPIE_USER_AGENT') ) {
+ $ua = 'WordPress/' . $wp_version;
+
+ if ( MAGPIE_CACHE_ON ) {
+ $ua = $ua . ')';
+ }
+ else {
+ $ua = $ua . '; No cache)';
+ }
+
+ define('MAGPIE_USER_AGENT', $ua);
+ }
+
+ if ( !defined('MAGPIE_FETCH_TIME_OUT') ) {
+ define('MAGPIE_FETCH_TIME_OUT', 2); // 2 second timeout
+ }
+
+ // use gzip encoding to fetch rss files if supported?
+ if ( !defined('MAGPIE_USE_GZIP') ) {
+ define('MAGPIE_USE_GZIP', true);
+ }
+}
+
+function is_info ($sc) {
+ return $sc >= 100 && $sc < 200;
+}
+
+function is_success ($sc) {
+ return $sc >= 200 && $sc < 300;
+}
+
+function is_redirect ($sc) {
+ return $sc >= 300 && $sc < 400;
+}
+
+function is_error ($sc) {
+ return $sc >= 400 && $sc < 600;
+}
+
+function is_client_error ($sc) {
+ return $sc >= 400 && $sc < 500;
+}
+
+function is_server_error ($sc) {
+ return $sc >= 500 && $sc < 600;
+}
+
+class RSSCache {
+ var $BASE_CACHE = 'wp-content/cache'; // where the cache files are stored
+ var $MAX_AGE = 43200; // when are files stale, default twelve hours
+ var $ERROR = ''; // accumulate error messages
+
+ function RSSCache ($base='', $age='') {
+ if ( $base ) {
+ $this->BASE_CACHE = $base;
+ }
+ if ( $age ) {
+ $this->MAX_AGE = $age;
+ }
+
+ }
+
+/*=======================================================================*\
+ Function: set
+ Purpose: add an item to the cache, keyed on url
+ Input: url from wich the rss file was fetched
+ Output: true on sucess
+\*=======================================================================*/
+ function set ($url, $rss) {
+ global $wpdb;
+ $cache_option = 'rss_' . $this->file_name( $url );
+ $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
+
+ if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$cache_option'") )
+ add_option($cache_option, '', '', 'no');
+ if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$cache_timestamp'") )
+ add_option($cache_timestamp, '', '', 'no');
+
+ update_option($cache_option, $rss);
+ update_option($cache_timestamp, time() );
+
+ return $cache_option;
+ }
+
+/*=======================================================================*\
+ Function: get
+ Purpose: fetch an item from the cache
+ Input: url from wich the rss file was fetched
+ Output: cached object on HIT, false on MISS
+\*=======================================================================*/
+ function get ($url) {
+ $this->ERROR = "";
+ $cache_option = 'rss_' . $this->file_name( $url );
+
+ if ( ! get_option( $cache_option ) ) {
+ $this->debug(
+ "Cache doesn't contain: $url (cache option: $cache_option)"
+ );
+ return 0;
+ }
+
+ $rss = get_option( $cache_option );
+
+ return $rss;
+ }
+
+/*=======================================================================*\
+ Function: check_cache
+ Purpose: check a url for membership in the cache
+ and whether the object is older then MAX_AGE (ie. STALE)
+ Input: url from wich the rss file was fetched
+ Output: cached object on HIT, false on MISS
+\*=======================================================================*/
+ function check_cache ( $url ) {
+ $this->ERROR = "";
+ $cache_option = $this->file_name( $url );
+ $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
+
+ if ( $mtime = get_option($cache_timestamp) ) {
+ // find how long ago the file was added to the cache
+ // and whether that is longer then MAX_AGE
+ $age = time() - $mtime;
+ if ( $this->MAX_AGE > $age ) {
+ // object exists and is current
+ return 'HIT';
+ }
+ else {
+ // object exists but is old
+ return 'STALE';
+ }
+ }
+ else {
+ // object does not exist
+ return 'MISS';
+ }
+ }
+
+/*=======================================================================*\
+ Function: serialize
+\*=======================================================================*/
+ function serialize ( $rss ) {
+ return serialize( $rss );
+ }
+
+/*=======================================================================*\
+ Function: unserialize
+\*=======================================================================*/
+ function unserialize ( $data ) {
+ return unserialize( $data );
+ }
+
+/*=======================================================================*\
+ Function: file_name
+ Purpose: map url to location in cache
+ Input: url from wich the rss file was fetched
+ Output: a file name
+\*=======================================================================*/
+ function file_name ($url) {
+ return md5( $url );
+ }
+
+/*=======================================================================*\
+ Function: error
+ Purpose: register error
+\*=======================================================================*/
+ function error ($errormsg, $lvl=E_USER_WARNING) {
+ // append PHP's error message if track_errors enabled
+ if ( isset($php_errormsg) ) {
+ $errormsg .= " ($php_errormsg)";
+ }
+ $this->ERROR = $errormsg;
+ if ( MAGPIE_DEBUG ) {
+ trigger_error( $errormsg, $lvl);
+ }
+ else {
+ error_log( $errormsg, 0);
+ }
+ }
+ function debug ($debugmsg, $lvl=E_USER_NOTICE) {
+ if ( MAGPIE_DEBUG ) {
+ $this->error("MagpieRSS [debug] $debugmsg", $lvl);
+ }
+ }
+}
+
+function parse_w3cdtf ( $date_str ) {
+
+ # regex to match wc3dtf
+ $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
+
+ if ( preg_match( $pat, $date_str, $match ) ) {
+ list( $year, $month, $day, $hours, $minutes, $seconds) =
+ array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
+
+ # calc epoch for current date assuming GMT
+ $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
+
+ $offset = 0;
+ if ( $match[10] == 'Z' ) {
+ # zulu time, aka GMT
+ }
+ else {
+ list( $tz_mod, $tz_hour, $tz_min ) =
+ array( $match[8], $match[9], $match[10]);
+
+ # zero out the variables
+ if ( ! $tz_hour ) { $tz_hour = 0; }
+ if ( ! $tz_min ) { $tz_min = 0; }
+
+ $offset_secs = (($tz_hour*60)+$tz_min)*60;
+
+ # is timezone ahead of GMT? then subtract offset
+ #
+ if ( $tz_mod == '+' ) {
+ $offset_secs = $offset_secs * -1;
+ }
+
+ $offset = $offset_secs;
+ }
+ $epoch = $epoch + $offset;
+ return $epoch;
+ }
+ else {
+ return -1;
+ }
+ }
+function wp_rss ($url, $num) {
+ //ini_set("display_errors", false); uncomment to suppress php errors thrown if the feed is not returned.
+ $num_items = $num;
+ $rss = fetch_rss($url);
+ if ( $rss ) {
+ echo "<ul>";
+ $rss->items = array_slice($rss->items, 0, $num_items);
+ foreach ($rss->items as $item ) {
+ echo "<li>\n";
+ echo "<a href='$item[link]' title='$item[description]'>";
+ echo htmlentities($item['title']);
+ echo "</a><br />\n";
+ echo "</li>\n";
+ }
+ echo "</ul>";
+ }
+ else {
+ echo "an error has occured the feed is probably down, try again later.";
+ }
+}
+
+function get_rss ($uri, $num = 5) { // Like get posts, but for RSS
+ $rss = fetch_rss($url);
+ if ( $rss ) {
+ $rss->items = array_slice($rss->items, 0, $num_items);
+ foreach ($rss->items as $item ) {
+ echo "<li>\n";
+ echo "<a href='$item[link]' title='$item[description]'>";
+ echo htmlentities($item['title']);
+ echo "</a><br />\n";
+ echo "</li>\n";
+ }
+ return $posts;
+ } else {
+ return false;
+ }
+}
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/streams.php b/wp-inst/wp-includes/streams.php
new file mode 100644
index 0000000..c69841e
--- /dev/null
+++ b/wp-inst/wp-includes/streams.php
@@ -0,0 +1,159 @@
+<?php
+/*
+ Copyright (c) 2003, 2005 Danilo Segan <danilo@kvota.net>.
+
+ This file is part of PHP-gettext.
+
+ PHP-gettext is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ PHP-gettext is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with PHP-gettext; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+
+// Simple class to wrap file streams, string streams, etc.
+// seek is essential, and it should be byte stream
+class StreamReader {
+ // should return a string [FIXME: perhaps return array of bytes?]
+ function read($bytes) {
+ return false;
+ }
+
+ // should return new position
+ function seekto($position) {
+ return false;
+ }
+
+ // returns current position
+ function currentpos() {
+ return false;
+ }
+
+ // returns length of entire stream (limit for seekto()s)
+ function length() {
+ return false;
+ }
+}
+
+class StringReader {
+ var $_pos;
+ var $_str;
+
+ function StringReader($str='') {
+ $this->_str = $str;
+ $this->_pos = 0;
+ }
+
+ function read($bytes) {
+ $data = substr($this->_str, $this->_pos, $bytes);
+ $this->_pos += $bytes;
+ if (strlen($this->_str)<$this->_pos)
+ $this->_pos = strlen($this->_str);
+
+ return $data;
+ }
+
+ function seekto($pos) {
+ $this->_pos = $pos;
+ if (strlen($this->_str)<$this->_pos)
+ $this->_pos = strlen($this->_str);
+ return $this->_pos;
+ }
+
+ function currentpos() {
+ return $this->_pos;
+ }
+
+ function length() {
+ return strlen($this->_str);
+ }
+
+}
+
+
+class FileReader {
+ var $_pos;
+ var $_fd;
+ var $_length;
+
+ function FileReader($filename) {
+ if (file_exists($filename)) {
+
+ $this->_length=filesize($filename);
+ $this->_pos = 0;
+ $this->_fd = fopen($filename,'rb');
+ if (!$this->_fd) {
+ $this->error = 3; // Cannot read file, probably permissions
+ return false;
+ }
+ } else {
+ $this->error = 2; // File doesn't exist
+ return false;
+ }
+ }
+
+ function read($bytes) {
+ if ($bytes) {
+ fseek($this->_fd, $this->_pos);
+ $data = fread($this->_fd, $bytes);
+ $this->_pos = ftell($this->_fd);
+
+ return $data;
+ } else return '';
+ }
+
+ function seekto($pos) {
+ fseek($this->_fd, $pos);
+ $this->_pos = ftell($this->_fd);
+ return $this->_pos;
+ }
+
+ function currentpos() {
+ return $this->_pos;
+ }
+
+ function length() {
+ return $this->_length;
+ }
+
+ function close() {
+ fclose($this->_fd);
+ }
+
+}
+
+// Preloads entire file in memory first, then creates a StringReader
+// over it (it assumes knowledge of StringReader internals)
+class CachedFileReader extends StringReader {
+ function CachedFileReader($filename) {
+ if (file_exists($filename)) {
+
+ $length=filesize($filename);
+ $fd = fopen($filename,'rb');
+
+ if (!$fd) {
+ $this->error = 3; // Cannot read file, probably permissions
+ return false;
+ }
+ $this->_str = fread($fd, $length);
+ fclose($fd);
+
+ } else {
+ $this->error = 2; // File doesn't exist
+ return false;
+ }
+ }
+}
+
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/template-functions-author.php b/wp-inst/wp-includes/template-functions-author.php
new file mode 100644
index 0000000..86aaa48
--- /dev/null
+++ b/wp-inst/wp-includes/template-functions-author.php
@@ -0,0 +1,211 @@
+<?php
+
+function get_the_author($idmode = '') {
+ global $authordata;
+ return $authordata->display_name;
+}
+
+function the_author($idmode = '', $echo = true) {
+ if ($echo) echo get_the_author($idmode);
+ return get_the_author($idmode);
+}
+
+function get_the_author_description() {
+ global $authordata;
+ return $authordata->user_description;
+}
+function the_author_description() {
+ echo get_the_author_description();
+}
+
+function get_the_author_login() {
+ global $id,$authordata; return $authordata->user_login;
+}
+function the_author_login() {
+ echo get_the_author_login();
+}
+
+function get_the_author_firstname() {
+ global $id,$authordata; return $authordata->first_name;
+}
+function the_author_firstname() {
+ echo get_the_author_firstname();
+}
+
+function get_the_author_lastname() {
+ global $id,$authordata; return $authordata->last_name;
+}
+function the_author_lastname() {
+ echo get_the_author_lastname();
+}
+
+function get_the_author_nickname() {
+ global $id,$authordata; return $authordata->nickname;
+}
+function the_author_nickname() {
+ echo get_the_author_nickname();
+}
+
+function get_the_author_ID() {
+ global $id,$authordata; return $authordata->ID;
+}
+function the_author_ID() {
+ echo get_the_author_id();
+}
+
+function get_the_author_email() {
+ global $authordata;
+ return $authordata->user_email;
+}
+
+function the_author_email() {
+ echo apply_filters('the_author_email', get_the_author_email() );
+}
+
+function get_the_author_url() {
+ global $id,$authordata; return $authordata->user_url;
+}
+function the_author_url() {
+ echo get_the_author_url();
+}
+
+function get_the_author_icq() {
+ global $id,$authordata; return $authordata->icq;
+}
+function the_author_icq() {
+ echo get_the_author_icq();
+}
+
+function get_the_author_aim() {
+ global $id,$authordata; return str_replace(' ', '+', $authordata->aim);
+}
+function the_author_aim() {
+ echo get_the_author_aim();
+}
+
+function get_the_author_yim() {
+ global $id,$authordata; return $authordata->yim;
+}
+function the_author_yim() {
+ echo get_the_author_yim();
+}
+
+function get_the_author_msn() {
+ global $id,$authordata; return $authordata->msn;
+}
+function the_author_msn() {
+ echo get_the_author_msn();
+}
+
+function get_the_author_posts() {
+ global $id,$post;
+ $posts=get_usernumposts($post->post_author);
+ return $posts;
+}
+function the_author_posts() {
+ echo get_the_author_posts();
+}
+
+/* the_author_posts_link() requires no get_, use get_author_link() */
+function the_author_posts_link($idmode='') {
+ global $id, $authordata;
+
+ echo '<a href="' . get_author_link(0, $authordata->ID, $authordata->user_nicename) . '" title="' . sprintf(__("Posts by %s"), wp_specialchars(the_author($idmode, false))) . '">' . the_author($idmode, false) . '</a>';
+}
+
+
+function get_author_link($echo = false, $author_id, $author_nicename) {
+ global $wpdb, $wp_rewrite, $post, $cache_userdata;
+ $auth_ID = $author_id;
+ $link = $wp_rewrite->get_author_permastruct();
+
+ if (empty($link)) {
+ $file = get_settings('home') . '/';
+ $link = $file . '?author=' . $auth_ID;
+ } else {
+ if ('' == $author_nicename) $author_nicename = $cache_userdata[$author_id]->user_nicename;
+ $link = str_replace('%author%', $author_nicename, $link);
+ $link = get_settings('home') . trailingslashit($link);
+ }
+
+ $link = apply_filters('author_link', $link, $author_id, $author_nicename);
+ if ($echo) echo $link;
+ return $link;
+}
+
+function wp_list_authors($args = '') {
+ parse_str($args, $r);
+ if (!isset($r['optioncount'])) $r['optioncount'] = false;
+ if (!isset($r['exclude_admin'])) $r['exclude_admin'] = true;
+ if (!isset($r['show_fullname'])) $r['show_fullname'] = false;
+ if (!isset($r['hide_empty'])) $r['hide_empty'] = true;
+ if (!isset($r['feed'])) $r['feed'] = '';
+ if (!isset($r['feed_image'])) $r['feed_image'] = '';
+
+ list_authors($r['optioncount'], $r['exclude_admin'], $r['show_fullname'], $r['hide_empty'], $r['feed'], $r['feed_image']);
+}
+
+function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
+ global $wpdb;
+
+ $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name";
+ $authors = $wpdb->get_results($query);
+
+ foreach($authors as $author) {
+ $author = get_userdata( $author->ID );
+ $posts = get_usernumposts($author->ID);
+ $name = $author->nickname;
+
+ if ($show_fullname && ($author->first_name != '' && $author->last_name != '')) {
+ $name = "$author->first_name $author->last_name";
+ }
+
+ if (! ($posts == 0 && $hide_empty)) echo "<li>";
+ if ($posts == 0) {
+ if ( !$hide_empty )
+ $link = $name;
+ } else {
+ $link = '<a href="' . get_author_link(0, $author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), wp_specialchars($author->display_name)) . '">' . $name . '</a>';
+
+ if ( (! empty($feed_image)) || (! empty($feed)) ) {
+
+ $link .= ' ';
+
+ if (empty($feed_image)) {
+ $link .= '(';
+ }
+
+ $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';
+
+ if (! empty($feed)) {
+ $title = ' title="' . $feed . '"';
+ $alt = ' alt="' . $feed . '"';
+ $name = $feed;
+ $link .= $title;
+ }
+
+ $link .= '>';
+
+ if (! empty($feed_image)) {
+ $link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />';
+ } else {
+ $link .= $name;
+ }
+
+ $link .= '</a>';
+
+ if (empty($feed_image)) {
+ $link .= ')';
+ }
+ }
+
+ if ($optioncount) {
+ $link .= ' ('. $posts . ')';
+ }
+ }
+
+ if (! ($posts == 0 && $hide_empty)) echo "$link</li>";
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/template-functions-category.php b/wp-inst/wp-includes/template-functions-category.php
new file mode 100644
index 0000000..d1d4fb8
--- /dev/null
+++ b/wp-inst/wp-includes/template-functions-category.php
@@ -0,0 +1,402 @@
+<?php
+
+function get_the_category($id = false) {
+ global $post, $category_cache;
+
+ if ( !$id )
+ $id = $post->ID;
+
+ if ( ! isset($category_cache[$id]) )
+ update_post_category_cache($id);
+
+ $categories = $category_cache[$id];
+
+ if (!empty($categories))
+ sort($categories);
+ else
+ $categories = array();
+
+ return $categories;
+}
+
+function get_category_link($category_id) {
+ global $wp_rewrite;
+ $catlink = $wp_rewrite->get_category_permastruct();
+
+ if ( empty($catlink) ) {
+ $file = get_settings('home') . '/' . get_settings('blogfilename');
+ $catlink = $file . '?cat=' . $category_id;
+ } else {
+ $category = &get_category($category_id);
+ $category_nicename = $category->category_nicename;
+
+ if ($parent = $category->category_parent)
+ $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/';
+
+ $catlink = str_replace('%category%', $category_nicename, $catlink);
+ $catlink = get_settings('home') . trailingslashit($catlink);
+ }
+ return apply_filters('category_link', $catlink, $category_id);
+}
+
+function get_the_category_list($separator = '', $parents='') {
+ $categories = get_the_category();
+ if (empty($categories)) {
+ return apply_filters('the_category', __('Uncategorized'), $separator, $parents);
+ }
+
+ $thelist = '';
+ if ('' == $separator) {
+ $thelist .= '<ul class="post-categories">';
+ foreach ($categories as $category) {
+ $category->cat_name = $category->cat_name;
+ $thelist .= "\n\t<li>";
+ switch(strtolower($parents)) {
+ case 'multiple':
+ if ($category->category_parent) {
+ $thelist .= get_category_parents($category->category_parent, TRUE);
+ }
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';
+ break;
+ case 'single':
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . ' rel="category tag">';
+ if ($category->category_parent) {
+ $thelist .= get_category_parents($category->category_parent, FALSE);
+ }
+ $thelist .= $category->cat_name.'</a></li>';
+ break;
+ case '':
+ default:
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';
+ }
+ }
+ $thelist .= '</ul>';
+ } else {
+ $i = 0;
+ foreach ($categories as $category) {
+ $category->cat_name = $category->cat_name;
+ if (0 < $i) $thelist .= $separator . ' ';
+ switch(strtolower($parents)) {
+ case 'multiple':
+ if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, TRUE);
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';
+ break;
+ case 'single':
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">';
+ if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, FALSE);
+ $thelist .= "$category->cat_name</a>";
+ break;
+ case '':
+ default:
+ $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';
+ }
+ ++$i;
+ }
+ }
+ return apply_filters('the_category', $thelist, $separator, $parents);
+}
+
+function the_category($separator = '', $parents='') {
+ echo get_the_category_list($separator, $parents);
+}
+
+function get_the_category_by_ID($cat_ID) {
+ $cat_ID = (int) $cat_ID;
+ $category = &get_category($cat_ID);
+ return $category->cat_name;
+}
+
+function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
+ $chain = '';
+ $parent = &get_category($id);
+ if ($nicename) {
+ $name = $parent->category_nicename;
+ } else {
+ $name = $parent->cat_name;
+ }
+ if ($parent->category_parent) $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename);
+ if ($link) {
+ $chain .= '<a href="' . get_category_link($parent->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator;
+ } else {
+ $chain .= $name.$separator;
+ }
+ return $chain;
+}
+
+function get_category_children($id, $before = '/', $after = '') {
+ global $cache_categories;
+
+ if ( ! isset($cache_categories))
+ update_category_cache();
+
+ $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy
+ $chain = '';
+ foreach ($c_cache as $category){
+ if ($category->category_parent == $id){
+ $chain .= $before.$category->cat_ID.$after;
+ $chain .= get_category_children($category->cat_ID, $before, $after);
+ }
+ }
+ return $chain;
+}
+
+// Deprecated.
+function the_category_ID($echo = true) {
+ // Grab the first cat in the list.
+ $categories = get_the_category();
+ $cat = $categories[0]->cat_ID;
+
+ if ($echo) echo $cat;
+
+ return $cat;
+}
+
+// Deprecated.
+function the_category_head($before='', $after='') {
+ global $currentcat, $previouscat;
+ // Grab the first cat in the list.
+ $categories = get_the_category();
+ $currentcat = $categories[0]->category_id;
+ if ($currentcat != $previouscat) {
+ echo $before;
+ echo get_the_category_by_ID($currentcat);
+ echo $after;
+ $previouscat = $currentcat;
+ }
+}
+
+function category_description($category = 0) {
+ global $cat;
+ if (!$category) $category = $cat;
+ $category = & get_category($category);
+ return apply_filters('category_description', $category->category_description, $category->cat_ID);
+}
+
+// out of the WordPress loop
+function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc',
+ $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE,
+ $selected=0, $hide=0) {
+ global $wpdb;
+ if (($file == 'blah') || ($file == '')) $file = get_settings('home') . '/';
+ if (!$selected) $selected=$cat;
+ $sort_column = 'cat_'.$sort_column;
+
+ $query = "
+ SELECT cat_ID, cat_name, category_nicename,category_parent,
+ COUNT($wpdb->post2cat.post_id) AS cat_count,
+ DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
+ FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id)
+ LEFT JOIN $wpdb->posts ON (ID = post_id)
+ WHERE cat_ID > 0
+ ";
+ if ($hide) {
+ $query .= " AND cat_ID != $hide";
+ $query .= get_category_children($hide, " AND cat_ID != ");
+ }
+ $query .=" GROUP BY cat_ID";
+ if (intval($hide_empty) == 1) $query .= " HAVING cat_count > 0";
+ $query .= " ORDER BY $sort_column $sort_order, post_date DESC";
+
+ $categories = $wpdb->get_results($query);
+ echo "<select name='cat' class='postform'>\n";
+ if (intval($optionall) == 1) {
+ $all = apply_filters('list_cats', $all);
+ echo "\t<option value='0'>$all</option>\n";
+ }
+ if (intval($optionnone) == 1) echo "\t<option value='-1'>".__('None')."</option>\n";
+ if ($categories) {
+ foreach ($categories as $category) {
+ $cat_name = apply_filters('list_cats', $category->cat_name, $category);
+ echo "\t<option value=\"".$category->cat_ID."\"";
+ if ($category->cat_ID == $selected)
+ echo ' selected="selected"';
+ echo '>';
+ echo $cat_name;
+ if (intval($optioncount) == 1) echo '&nbsp;&nbsp;('.$category->cat_count.')';
+ if (intval($optiondates) == 1) echo '&nbsp;&nbsp;'.$category->lastday.'/'.$category->lastmonth;
+ echo "</option>\n";
+ }
+ }
+ echo "</select>\n";
+}
+
+// out of the WordPress loop
+function wp_list_cats($args = '') {
+ parse_str($args, $r);
+ if (!isset($r['optionall'])) $r['optionall'] = 0;
+ if (!isset($r['all'])) $r['all'] = 'All';
+ if (!isset($r['sort_column'])) $r['sort_column'] = 'ID';
+ if (!isset($r['sort_order'])) $r['sort_order'] = 'asc';
+ if (!isset($r['file'])) $r['file'] = '';
+ if (!isset($r['list'])) $r['list'] = true;
+ if (!isset($r['optiondates'])) $r['optiondates'] = 0;
+ if (!isset($r['optioncount'])) $r['optioncount'] = 0;
+ if (!isset($r['hide_empty'])) $r['hide_empty'] = 1;
+ if (!isset($r['use_desc_for_title'])) $r['use_desc_for_title'] = 1;
+ if (!isset($r['children'])) $r['children'] = true;
+ if (!isset($r['child_of'])) $r['child_of'] = 0;
+ if (!isset($r['categories'])) $r['categories'] = 0;
+ if (!isset($r['recurse'])) $r['recurse'] = 0;
+ if (!isset($r['feed'])) $r['feed'] = '';
+ if (!isset($r['feed_image'])) $r['feed_image'] = '';
+ if (!isset($r['exclude'])) $r['exclude'] = '';
+ if (!isset($r['hierarchical'])) $r['hierarchical'] = true;
+
+ return list_cats($r['optionall'], $r['all'], $r['sort_column'], $r['sort_order'], $r['file'], $r['list'], $r['optiondates'], $r['optioncount'], $r['hide_empty'], $r['use_desc_for_title'], $r['children'], $r['child_of'], $r['categories'], $r['recurse'], $r['feed'], $r['feed_image'], $r['exclude'], $r['hierarchical']);
+}
+
+function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE) {
+ global $wpdb, $category_posts;
+ // Optiondates now works
+ if ('' == $file) {
+ $file = get_settings('home') . '/';
+ }
+
+ $exclusions = '';
+ if (!empty($exclude)) {
+ $excats = preg_split('/[\s,]+/',$exclude);
+ if (count($excats)) {
+ foreach ($excats as $excat) {
+ $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
+ }
+ }
+ }
+
+ if (intval($categories)==0){
+ $sort_column = 'cat_'.$sort_column;
+
+ $query = "
+ SELECT cat_ID, cat_name, category_nicename, category_description, category_parent
+ FROM $wpdb->categories
+ WHERE cat_ID > 0 $exclusions
+ ORDER BY $sort_column $sort_order";
+
+ $categories = $wpdb->get_results($query);
+ }
+ if (!count($category_posts)) {
+ $now = current_time('mysql', 1);
+ $cat_counts = $wpdb->get_results(" SELECT cat_ID,
+ COUNT($wpdb->post2cat.post_id) AS cat_count
+ FROM $wpdb->categories
+ INNER JOIN $wpdb->post2cat ON (cat_ID = category_id)
+ INNER JOIN $wpdb->posts ON (ID = post_id)
+ WHERE post_status = 'publish'
+ AND post_date_gmt < '$now' $exclusions
+ GROUP BY category_id");
+ if (! empty($cat_counts)) {
+ foreach ($cat_counts as $cat_count) {
+ if (1 != intval($hide_empty) || $cat_count > 0) {
+ $category_posts["$cat_count->cat_ID"] = $cat_count->cat_count;
+ }
+ }
+ }
+ }
+
+ if ( $optiondates ) {
+ $cat_dates = $wpdb->get_results(" SELECT category_id,
+ UNIX_TIMESTAMP( MAX(post_date) ) AS ts
+ FROM $wpdb->posts, $wpdb->post2cat
+ WHERE post_status = 'publish' AND post_id = ID $exclusions
+ GROUP BY category_id");
+ foreach ($cat_dates as $cat_date) {
+ $category_timestamp["$cat_date->category_id"] = $cat_date->ts;
+ }
+ }
+
+ $num_found=0;
+ $thelist = "";
+
+ foreach ($categories as $category) {
+ if ((intval($hide_empty) == 0 || isset($category_posts["$category->cat_ID"])) && (!$hierarchical || $category->category_parent == $child_of) ) {
+ $num_found++;
+ $link = '<a href="'.get_category_link($category->cat_ID).'" ';
+ if ($use_desc_for_title == 0 || empty($category->category_description)) {
+ $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"';
+ } else {
+ $link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category)) . '"';
+ }
+ $link .= '>';
+ $link .= apply_filters('list_cats', $category->cat_name, $category).'</a>';
+
+ if ( (! empty($feed_image)) || (! empty($feed)) ) {
+
+ $link .= ' ';
+
+ if (empty($feed_image)) {
+ $link .= '(';
+ }
+
+ $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
+
+ if ( !empty($feed) ) {
+ $title = ' title="' . $feed . '"';
+ $alt = ' alt="' . $feed . '"';
+ $name = $feed;
+ $link .= $title;
+ }
+
+ $link .= '>';
+
+ if (! empty($feed_image)) {
+ $link .= "<img src='$feed_image' $alt$title" . ' />';
+ } else {
+ $link .= $name;
+ }
+
+ $link .= '</a>';
+
+ if (empty($feed_image)) {
+ $link .= ')';
+ }
+ }
+
+ if (intval($optioncount) == 1) {
+ $link .= ' ('.intval($category_posts["$category->cat_ID"]).')';
+ }
+ if ( $optiondates ) {
+ if ( $optiondates == 1 ) $optiondates = 'Y-m-d';
+ $link .= ' ' . gmdate($optiondates, $category_timestamp["$category->cat_ID"]);
+ }
+ if ($list) {
+ $thelist .= "\t<li>$link\n";
+ } else {
+ $thelist .= "\t$link<br />\n";
+ }
+ if ($hierarchical && $children) $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categories, 1, $feed, $feed_image, $exclude, $hierarchical);
+ if ($list) $thelist .= "</li>\n";
+ }
+ }
+ if (!$num_found && !$child_of){
+ if ($list) {
+ $before = '<li>';
+ $after = '</li>';
+ }
+ echo $before . __("No categories") . $after . "\n";
+ return;
+ }
+ if ($list && $child_of && $num_found && $recurse) {
+ $pre = "\t\t<ul class='children'>";
+ $post = "\t\t</ul>\n";
+ } else {
+ $pre = $post = '';
+ }
+ $thelist = $pre . $thelist . $post;
+ if ($recurse) {
+ return $thelist;
+ }
+ echo apply_filters('list_cats', $thelist);
+}
+
+function in_category($category) { // Check if the current post is in the given category
+ global $post, $category_cache;
+ $cats = '';
+ foreach ($category_cache[$post->ID] as $cat) :
+ $cats[] = $cat->cat_ID;
+ endforeach;
+
+ if ( in_array($category, $cats) )
+ return true;
+ else
+ return false;
+}
+?>
diff --git a/wp-inst/wp-includes/template-functions-general.php b/wp-inst/wp-includes/template-functions-general.php
new file mode 100644
index 0000000..340dc57
--- /dev/null
+++ b/wp-inst/wp-includes/template-functions-general.php
@@ -0,0 +1,644 @@
+<?php
+
+/* Note: these tags go anywhere in the template */
+
+function get_header() {
+ if ( file_exists( TEMPLATEPATH . '/header.php') )
+ load_template( TEMPLATEPATH . '/header.php');
+ else
+ load_template( ABSPATH . 'wp-content/themes/default/header.php');
+}
+
+function get_footer() {
+ if ( file_exists( TEMPLATEPATH . '/footer.php') )
+ load_template( TEMPLATEPATH . '/footer.php');
+ else
+ load_template( ABSPATH . 'wp-content/themes/default/footer.php');
+}
+
+function get_sidebar() {
+ if ( file_exists( TEMPLATEPATH . '/sidebar.php') )
+ load_template( TEMPLATEPATH . '/sidebar.php');
+ else
+ load_template( ABSPATH . 'wp-content/themes/default/sidebar.php');
+}
+
+
+function wp_loginout() {
+ global $user_ID;
+ get_currentuserinfo();
+
+ if ('' == $user_ID) :
+ $link = '<a href="' . get_settings('siteurl') . '/wp-login.php">' . __('Login') . '</a>';
+ else :
+ $link = '<a href="' . get_settings('siteurl') . '/wp-login.php?action=logout">' . __('Logout') . '</a>';
+ endif;
+
+ echo apply_filters('loginout', $link);
+}
+
+function wp_register( $before = '<li>', $after = '</li>' ) {
+ global $user_ID;
+
+ get_currentuserinfo();
+
+ if ('' == $user_ID && get_settings('users_can_register') ) :
+ $link = $before . '<a href="' . get_settings('siteurl') . '/wp-register.php">' . __('Register') . '</a>' . $after;
+ elseif ('' == $user_ID && !get_settings('users_can_register') ) :
+ $link = '';
+ else :
+ $link = $before . '<a href="' . get_settings('siteurl') . '/wp-admin/">' . __('Site Admin') . '</a>' . $after;
+ endif;
+
+ echo apply_filters('register', $link);
+}
+
+function wp_meta() {
+ do_action('wp_meta');
+}
+
+function bloginfo($show='') {
+ $info = get_bloginfo($show);
+ $info = apply_filters('bloginfo', $info, $show);
+ echo convert_chars($info);
+}
+
+function get_bloginfo($show='') {
+
+ switch($show) {
+ case 'url' :
+ case 'home' :
+ case 'siteurl' :
+ $output = get_settings('home');
+ break;
+ case 'wpurl' :
+ $output = get_settings('siteurl');
+ break;
+ case 'description':
+ $output = get_settings('blogdescription');
+ break;
+ case 'rdf_url':
+ $output = get_feed_link('rdf');
+ break;
+ case 'rss_url':
+ $output = get_feed_link('rss');
+ break;
+ case 'rss2_url':
+ $output = get_feed_link('rss2');
+ break;
+ case 'atom_url':
+ $output = get_feed_link('atom');
+ break;
+ case 'comments_rss2_url':
+ $output = get_feed_link('comments_rss2');
+ break;
+ case 'pingback_url':
+ $output = get_settings('siteurl') .'/xmlrpc.php';
+ break;
+ case 'stylesheet_url':
+ $output = get_stylesheet_uri();
+ break;
+ case 'stylesheet_directory':
+ $output = get_stylesheet_directory_uri();
+ break;
+ case 'template_directory':
+ case 'template_url':
+ $output = get_template_directory_uri();
+ break;
+ case 'admin_email':
+ $output = get_settings('admin_email');
+ break;
+ case 'charset':
+ $output = get_settings('blog_charset');
+ if ('' == $output) $output = 'UTF-8';
+ break;
+ case 'html_type' :
+ $output = get_option('html_type');
+ break;
+ case 'version':
+ global $wp_version;
+ $output = $wp_version;
+ break;
+ case 'name':
+ default:
+ $output = get_settings('blogname');
+ break;
+ }
+ return $output;
+}
+
+function wp_title($sep = '&raquo;', $display = true) {
+ global $wpdb;
+ global $m, $year, $monthnum, $day, $category_name, $month, $posts;
+
+ $cat = get_query_var('cat');
+ $p = get_query_var('p');
+ $name = get_query_var('name');
+ $category_name = get_query_var('category_name');
+
+ // If there's a category
+ if(!empty($cat)) {
+ if (!stristr($cat,'-')) { // category excluded
+ $title = get_the_category_by_ID($cat);
+ }
+ }
+ if (!empty($category_name)) {
+ if (stristr($category_name,'/')) {
+ $category_name = explode('/',$category_name);
+ if ($category_name[count($category_name)-1]) {
+ $category_name = $category_name[count($category_name)-1]; // no trailing slash
+ } else {
+ $category_name = $category_name[count($category_name)-2]; // there was a trailling slash
+ }
+ }
+ $title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'");
+ }
+
+ // If there's a month
+ if(!empty($m)) {
+ $my_year = substr($m, 0, 4);
+ $my_month = $month[substr($m, 4, 2)];
+ $title = "$my_year $sep $my_month";
+
+ }
+ if (!empty($year)) {
+ $title = $year;
+ if (!empty($monthnum)) {
+ $title .= " $sep ".$month[zeroise($monthnum, 2)];
+ }
+ if (!empty($day)) {
+ $title .= " $sep ".zeroise($day, 2);
+ }
+ }
+
+ // If there's a post
+ if (is_single() || is_page()) {
+ $title = strip_tags($posts[0]->post_title);
+ $title = apply_filters('single_post_title', $title);
+ }
+
+ // Send it out
+ if ($display && isset($title)) {
+ echo " $sep $title";
+ } elseif (!$display && isset($title)) {
+ return " $sep $title";
+ }
+}
+
+function single_post_title($prefix = '', $display = true) {
+ global $wpdb;
+ $p = get_query_var('p');
+ $name = get_query_var('name');
+ if (intval($p) || '' != $name) {
+ if (!$p) {
+ $p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$name'");
+ }
+ $post = & get_post($p);
+ $title = $post->post_title;
+ $title = apply_filters('single_post_title', $title);
+ if ($display) {
+ echo $prefix.strip_tags($title);
+ } else {
+ return strip_tags($title);
+ }
+ }
+}
+
+function single_cat_title($prefix = '', $display = true ) {
+ $cat = intval( get_query_var('cat') );
+ if( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
+ $my_cat_name = get_the_category_by_ID($cat);
+ if( !empty($my_cat_name) ) {
+ if ($display)
+ echo $prefix.strip_tags($my_cat_name);
+ else
+ return strip_tags($my_cat_name);
+ }
+ }
+}
+
+function single_month_title($prefix = '', $display = true ) {
+ global $m, $monthnum, $month, $year;
+ if(!empty($monthnum) && !empty($year)) {
+ $my_year = $year;
+ $my_month = $month[str_pad($monthnum, 2, '0', STR_PAD_LEFT)];
+ } elseif(!empty($m)) {
+ $my_year = substr($m, 0, 4);
+ $my_month = $month[substr($m, 4, 2)];
+ }
+
+ if (!empty($my_month) && $display) {
+ echo $prefix . $my_month . $prefix . $my_year;
+ } else {
+ return $monthnum;
+ }
+}
+
+/* link navigation hack by Orien http://icecode.com/ */
+function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
+ $text = wptexturize($text);
+ $title_text = wp_specialchars($text, 1);
+
+ if ('link' == $format) {
+ return "\t<link rel='archives' title='$title_text' href='$url' />\n";
+ } elseif ('option' == $format) {
+ return "\t<option value='$url'>$before $text $after</option>\n";
+ } elseif ('html' == $format) {
+ return "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";
+ } else { // custom
+ return "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";
+ }
+}
+
+function wp_get_archives($args = '') {
+ parse_str($args, $r);
+ if (!isset($r['type'])) $r['type'] = '';
+ if (!isset($r['limit'])) $r['limit'] = '';
+ if (!isset($r['format'])) $r['format'] = 'html';
+ if (!isset($r['before'])) $r['before'] = '';
+ if (!isset($r['after'])) $r['after'] = '';
+ if (!isset($r['show_post_count'])) $r['show_post_count'] = false;
+ get_archives($r['type'], $r['limit'], $r['format'], $r['before'], $r['after'], $r['show_post_count']);
+}
+
+function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
+ global $month, $wpdb;
+
+ if ('' == $type) {
+ $type = 'monthly';
+ }
+
+ if ('' != $limit) {
+ $limit = (int) $limit;
+ $limit = ' LIMIT '.$limit;
+ }
+ // this is what will separate dates on weekly archive links
+ $archive_week_separator = '&#8211;';
+
+ // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
+ $archive_date_format_over_ride = 0;
+
+ // options for daily archive (only if you over-ride the general date format)
+ $archive_day_date_format = 'Y/m/d';
+
+ // options for weekly archive (only if you over-ride the general date format)
+ $archive_week_start_date_format = 'Y/m/d';
+ $archive_week_end_date_format = 'Y/m/d';
+
+ if (!$archive_date_format_over_ride) {
+ $archive_day_date_format = get_settings('date_format');
+ $archive_week_start_date_format = get_settings('date_format');
+ $archive_week_end_date_format = get_settings('date_format');
+ }
+
+ $add_hours = intval(get_settings('gmt_offset'));
+ $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
+
+ $now = current_time('mysql');
+
+ if ('monthly' == $type) {
+ $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
+ if ($arcresults) {
+ $afterafter = $after;
+ foreach ($arcresults as $arcresult) {
+ $url = get_month_link($arcresult->year, $arcresult->month);
+ if ($show_post_count) {
+ $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
+ $after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
+ } else {
+ $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
+ }
+ echo get_archives_link($url, $text, $format, $before, $after);
+ }
+ }
+ } elseif ('daily' == $type) {
+ $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
+ if ($arcresults) {
+ foreach ($arcresults as $arcresult) {
+ $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
+ $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
+ $text = mysql2date($archive_day_date_format, $date);
+ echo get_archives_link($url, $text, $format, $before, $after);
+ }
+ }
+ } elseif ('weekly' == $type) {
+ $start_of_week = get_settings('start_of_week');
+ $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
+ $arc_w_last = '';
+ if ($arcresults) {
+ foreach ($arcresults as $arcresult) {
+ if ($arcresult->week != $arc_w_last) {
+ $arc_year = $arcresult->yr;
+ $arc_w_last = $arcresult->week;
+ $arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week'));
+ $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
+ $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
+ $url = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('home'), '', '?',
+ '=', $arc_year, '&amp;',
+ '=', $arcresult->week);
+ $text = $arc_week_start . $archive_week_separator . $arc_week_end;
+ echo get_archives_link($url, $text, $format, $before, $after);
+ }
+ }
+ }
+ } elseif ('postbypost' == $type) {
+ $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
+ if ($arcresults) {
+ foreach ($arcresults as $arcresult) {
+ if ($arcresult->post_date != '0000-00-00 00:00:00') {
+ $url = get_permalink($arcresult);
+ $arc_title = $arcresult->post_title;
+ if ($arc_title) {
+ $text = strip_tags($arc_title);
+ } else {
+ $text = $arcresult->ID;
+ }
+ echo get_archives_link($url, $text, $format, $before, $after);
+ }
+ }
+ }
+ }
+}
+
+// Used in get_calendar
+function calendar_week_mod($num) {
+ $base = 7;
+ return ($num - $base*floor($num/$base));
+}
+
+function get_calendar($daylength = 1) {
+ global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;
+
+ // Quick check. If we have no posts at all, abort!
+ if (!$posts) {
+ $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
+ if (!$gotsome)
+ return;
+ }
+
+ if (isset($_GET['w'])) {
+ $w = ''.intval($_GET['w']);
+ }
+
+ // week_begins = 0 stands for sunday
+ $week_begins = intval(get_settings('start_of_week'));
+ $add_hours = intval(get_settings('gmt_offset'));
+ $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
+
+ // Let's figure out when we are
+ if (!empty($monthnum) && !empty($year)) {
+ $thismonth = ''.zeroise(intval($monthnum), 2);
+ $thisyear = ''.intval($year);
+ } elseif (!empty($w)) {
+ // We need to get the month from MySQL
+ $thisyear = ''.intval(substr($m, 0, 4));
+ $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
+ $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
+ } elseif (!empty($m)) {
+ $calendar = substr($m, 0, 6);
+ $thisyear = ''.intval(substr($m, 0, 4));
+ if (strlen($m) < 6) {
+ $thismonth = '01';
+ } else {
+ $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
+ }
+ } else {
+ $thisyear = gmdate('Y', current_time('timestamp') + get_settings('gmt_offset') * 3600);
+ $thismonth = gmdate('m', current_time('timestamp') + get_settings('gmt_offset') * 3600);
+ }
+
+ $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
+
+ // Get the next and previous month and year with at least one post
+ $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
+ FROM $wpdb->posts
+ WHERE post_date < '$thisyear-$thismonth-01'
+ AND post_status = 'publish'
+ ORDER BY post_date DESC
+ LIMIT 1");
+ $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
+ FROM $wpdb->posts
+ WHERE post_date > '$thisyear-$thismonth-01'
+ AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
+ AND post_status = 'publish'
+ ORDER BY post_date ASC
+ LIMIT 1");
+
+ echo '<table id="wp-calendar">
+ <caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>
+ <thead>
+ <tr>';
+
+ $day_abbrev = $weekday_initial;
+ if ($daylength > 1) {
+ $day_abbrev = $weekday_abbrev;
+ }
+
+ $myweek = array();
+
+ for ($wdcount=0; $wdcount<=6; $wdcount++) {
+ $myweek[]=$weekday[($wdcount+$week_begins)%7];
+ }
+
+ foreach ($myweek as $wd) {
+ echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $day_abbrev[$wd] . '</th>';
+ }
+
+ echo '
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr>';
+
+ if ($previous) {
+ echo "\n\t\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' .
+ get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($previous->month, 2)], date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $month_abbrev[$month[zeroise($previous->month, 2)]] . '</a></td>';
+ } else {
+ echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
+ }
+
+ echo "\n\t\t".'<td class="pad">&nbsp;</td>';
+
+ if ($next) {
+ echo "\n\t\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .
+ get_month_link($next->year, $next->month) . '" title="View posts for ' . $month[zeroise($next->month, 2)] . ' ' .
+ date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . $month_abbrev[$month[zeroise($next->month, 2)]] . ' &raquo;</a></td>';
+ } else {
+ echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
+ }
+
+ echo '
+ </tr>
+ </tfoot>
+
+ <tbody>
+ <tr>';
+
+ // Get days with posts
+ $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
+ FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
+ AND YEAR(post_date) = $thisyear
+ AND post_status = 'publish'
+ AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
+ if ($dayswithposts) {
+ foreach ($dayswithposts as $daywith) {
+ $daywithpost[] = $daywith[0];
+ }
+ } else {
+ $daywithpost = array();
+ }
+
+
+
+ if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') ||
+ strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') ||
+ strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari')) {
+ $ak_title_separator = "\n";
+ } else {
+ $ak_title_separator = ', ';
+ }
+
+ $ak_titles_for_day = array();
+ $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
+ ."FROM $wpdb->posts "
+ ."WHERE YEAR(post_date) = '$thisyear' "
+ ."AND MONTH(post_date) = '$thismonth' "
+ ."AND post_date < '".current_time('mysql')."' "
+ ."AND post_status = 'publish'"
+ );
+ if ($ak_post_titles) {
+ foreach ($ak_post_titles as $ak_post_title) {
+ if (empty($ak_titles_for_day['day_'.$ak_post_title->dom])) {
+ $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
+ }
+ if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one
+ $ak_titles_for_day["$ak_post_title->dom"] = str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
+ } else {
+ $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
+ }
+ }
+ }
+
+
+ // See how much we should pad in the beginning
+ $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
+ if (0 != $pad) echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>';
+
+ $daysinmonth = intval(date('t', $unixmonth));
+ for ($day = 1; $day <= $daysinmonth; ++$day) {
+ if (isset($newrow) && $newrow)
+ echo "\n\t</tr>\n\t<tr>\n\t\t";
+ $newrow = false;
+
+ if ($day == gmdate('j', (time() + (get_settings('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_settings('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_settings('gmt_offset') * 3600)))
+ echo '<td id="today">';
+ else
+ echo '<td>';
+
+ if (in_array($day, $daywithpost)) { // any posts today?
+ echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
+ } else {
+ echo $day;
+ }
+ echo '</td>';
+
+ if (6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins))
+ $newrow = true;
+ }
+
+ $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
+ if ($pad != 0 && $pad != 7)
+ echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
+
+ echo "\n\t</tr>\n\t</tbody>\n\t</table>";
+}
+
+function allowed_tags() {
+ global $allowedtags;
+ $allowed = '';
+ foreach($allowedtags as $tag => $attributes) {
+ $allowed .= '<'.$tag;
+ if (0 < count($attributes)) {
+ foreach ($attributes as $attribute => $limits) {
+ $allowed .= ' '.$attribute.'=""';
+ }
+ }
+ $allowed .= '> ';
+ }
+ return htmlentities($allowed);
+}
+
+/***** Date/Time tags *****/
+
+function the_date_xml() {
+ global $post;
+ echo mysql2date('Y-m-d', $post->post_date);
+ //echo ""+$post->post_date;
+}
+
+function the_date($d='', $before='', $after='', $echo = true) {
+ global $id, $post, $day, $previousday, $newday;
+ $the_date = '';
+ if ($day != $previousday) {
+ $the_date .= $before;
+ if ($d=='') {
+ $the_date .= mysql2date(get_settings('date_format'), $post->post_date);
+ } else {
+ $the_date .= mysql2date($d, $post->post_date);
+ }
+ $the_date .= $after;
+ $previousday = $day;
+ }
+ $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
+ if ($echo) {
+ echo $the_date;
+ } else {
+ return $the_date;
+ }
+}
+
+function the_time( $d = '' ) {
+ echo apply_filters('the_time', get_the_time( $d ), $d);
+}
+
+function get_the_time( $d = '' ) {
+ if ( '' == $d )
+ $the_time = get_post_time(get_settings('time_format'));
+ else
+ $the_time = get_post_time($d);
+ return apply_filters('get_the_time', $the_time, $d);
+}
+
+function get_post_time( $d = 'U', $gmt = false ) { // returns timestamp
+ global $post;
+ if ( $gmt )
+ $time = $post->post_date_gmt;
+ else
+ $time = $post->post_date;
+
+ $time = mysql2date($d, $time);
+ return apply_filters('get_the_time', $time, $d, $gmt);
+}
+
+function the_weekday() {
+ global $weekday, $id, $post;
+ $the_weekday = $weekday[mysql2date('w', $post->post_date)];
+ $the_weekday = apply_filters('the_weekday', $the_weekday);
+ echo $the_weekday;
+}
+
+function the_weekday_date($before='',$after='') {
+ global $weekday, $id, $post, $day, $previousweekday;
+ $the_weekday_date = '';
+ if ($day != $previousweekday) {
+ $the_weekday_date .= $before;
+ $the_weekday_date .= $weekday[mysql2date('w', $post->post_date)];
+ $the_weekday_date .= $after;
+ $previousweekday = $day;
+ }
+ $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after);
+ echo $the_weekday_date;
+}
+
+?>
diff --git a/wp-inst/wp-includes/template-functions-links.php b/wp-inst/wp-includes/template-functions-links.php
new file mode 100644
index 0000000..6e29a1f
--- /dev/null
+++ b/wp-inst/wp-includes/template-functions-links.php
@@ -0,0 +1,492 @@
+<?php
+
+function the_permalink() {
+ echo apply_filters('the_permalink', get_permalink());
+}
+
+function permalink_link() { // For backwards compatibility
+ echo apply_filters('the_permalink', get_permalink());
+}
+
+function permalink_anchor($mode = 'id') {
+ global $id, $post;
+ switch(strtolower($mode)) {
+ case 'title':
+ $title = sanitize_title($post->post_title) . '-' . $id;
+ echo '<a id="'.$title.'"></a>';
+ break;
+ case 'id':
+ default:
+ echo '<a id="post-'.$id.'"></a>';
+ break;
+ }
+}
+
+function get_permalink($id = 0) {
+ $rewritecode = array(
+ '%year%',
+ '%monthnum%',
+ '%day%',
+ '%hour%',
+ '%minute%',
+ '%second%',
+ '%postname%',
+ '%post_id%',
+ '%category%',
+ '%author%',
+ '%pagename%'
+ );
+
+ $post = & get_post($id);
+ if ($post->post_status == 'static') {
+ return get_page_link($post->ID);
+ }
+
+ $permalink = get_settings('permalink_structure');
+
+ if ('' != $permalink && 'draft' != $post->post_status) {
+ $unixtime = strtotime($post->post_date);
+
+ $category = '';
+ if (strstr($permalink, '%category%')) {
+ $cats = get_the_category($post->ID);
+ $category = $cats[0]->category_nicename;
+ if ($parent=$cats[0]->category_parent) $category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
+ }
+
+ $authordata = get_userdata($post->post_author);
+ $author = $authordata->user_nicename;
+ $rewritereplace =
+ array(
+ date('Y', $unixtime),
+ date('m', $unixtime),
+ date('d', $unixtime),
+ date('H', $unixtime),
+ date('i', $unixtime),
+ date('s', $unixtime),
+ $post->post_name,
+ $post->ID,
+ $category,
+ $author,
+ $post->post_name,
+ );
+ return apply_filters('post_link', get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post);
+ } else { // if they're not using the fancy permalink option
+ $permalink = get_settings('home') . '/?p=' . $post->ID;
+ return apply_filters('post_link', $permalink, $post);
+ }
+}
+
+function get_page_link($id = false) {
+ global $post, $wp_rewrite;
+
+ if (! $id) {
+ $id = $post->ID;
+ }
+
+ $pagestruct = $wp_rewrite->get_page_permastruct();
+
+ if ('' != $pagestruct) {
+ $link = get_page_uri($id);
+ $link = str_replace('%pagename%', $link, $pagestruct);
+ $link = get_settings('home') . "/$link/";
+ } else {
+ $link = get_settings('home') . "/?page_id=$id";
+ }
+
+ return apply_filters('page_link', $link, $id);
+}
+
+function get_year_link($year) {
+ global $wp_rewrite;
+ if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
+ $yearlink = $wp_rewrite->get_year_permastruct();
+ if (!empty($yearlink)) {
+ $yearlink = str_replace('%year%', $year, $yearlink);
+ return apply_filters('year_link', get_settings('home') . trailingslashit($yearlink), $year);
+ } else {
+ return apply_filters('year_link', get_settings('home') . '/?m=' . $year, $year);
+ }
+}
+
+function get_month_link($year, $month) {
+ global $wp_rewrite;
+ if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
+ if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
+ $monthlink = $wp_rewrite->get_month_permastruct();
+ if (!empty($monthlink)) {
+ $monthlink = str_replace('%year%', $year, $monthlink);
+ $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
+ return apply_filters('month_link', get_settings('home') . trailingslashit($monthlink), $year, $month);
+ } else {
+ return apply_filters('month_link', get_settings('home') . '/?m=' . $year . zeroise($month, 2), $year, $month);
+ }
+}
+
+function get_day_link($year, $month, $day) {
+ global $wp_rewrite;
+ if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
+ if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
+ if (!$day) $day = gmdate('j', time()+(get_settings('gmt_offset') * 3600));
+
+ $daylink = $wp_rewrite->get_day_permastruct();
+ if (!empty($daylink)) {
+ $daylink = str_replace('%year%', $year, $daylink);
+ $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
+ $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
+ return apply_filters('day_link', get_settings('home') . trailingslashit($daylink), $year, $month, $day);
+ } else {
+ return apply_filters('day_link', get_settings('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day);
+ }
+}
+
+function get_feed_link($feed='rss2') {
+ global $wp_rewrite;
+ $do_perma = 0;
+ $feed_url = get_settings('siteurl');
+ $comment_feed_url = $feed_url;
+
+ $permalink = $wp_rewrite->get_feed_permastruct();
+ if ('' != $permalink) {
+ if ( false !== strpos($feed, 'comments_') ) {
+ $feed = str_replace('comments_', '', $feed);
+ $permalink = $wp_rewrite->get_comment_feed_permastruct();
+ }
+
+ if ( 'rss2' == $feed )
+ $feed = '';
+
+ $permalink = str_replace('%feed%', $feed, $permalink);
+ $permalink = preg_replace('#/+#', '/', "/$permalink/");
+ $output = get_settings('home') . $permalink;
+ } else {
+ if ( false !== strpos($feed, 'comments_') )
+ $feed = str_replace('comments_', 'comments-', $feed);
+
+ $output = get_settings('home') . "/?feed={$feed}";
+ }
+
+ return apply_filters('feed_link', $output, $feed);
+}
+
+function edit_post_link($link = 'Edit This', $before = '', $after = '') {
+ global $user_ID, $post;
+
+ get_currentuserinfo();
+
+ if (!user_can_edit_post($user_ID, $post->ID)) {
+ return;
+ }
+
+ $location = get_settings('siteurl') . "/wp-admin/post.php?action=edit&amp;post=$post->ID";
+ echo "$before <a href=\"$location\">$link</a> $after";
+}
+
+function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
+ global $user_ID, $post, $comment;
+
+ get_currentuserinfo();
+
+ if (!user_can_edit_post_comments($user_ID, $post->ID)) {
+ return;
+ }
+
+ $location = get_settings('siteurl') . "/wp-admin/post.php?action=editcomment&amp;comment=$comment->comment_ID";
+ echo "$before <a href='$location'>$link</a> $after";
+}
+
+// Navigation links
+
+function get_previous_post($in_same_cat = false, $excluded_categories = '') {
+ global $post, $wpdb;
+
+ if(! is_single()) {
+ return null;
+ }
+
+ $current_post_date = $post->post_date;
+
+ $join = '';
+ if ($in_same_cat) {
+ $join = " INNER JOIN $wpdb->post2cat ON $wpdb->posts.ID= $wpdb->post2cat.post_id ";
+ $cat_array = get_the_category($post->ID);
+ $join .= ' AND (category_id = ' . intval($cat_array[0]->cat_ID);
+ for ($i = 1; $i < (count($cat_array)); $i++) {
+ $join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID);
+ }
+ $join .= ')';
+ }
+
+ $sql_exclude_cats = '';
+ if (!empty($excluded_categories)) {
+ $blah = explode('and', $excluded_categories);
+ foreach($blah as $category) {
+ $category = intval($category);
+ $sql_exclude_cats .= " AND post_category != $category";
+ }
+ }
+
+ return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT 1");
+}
+
+function get_next_post($in_same_cat = false, $excluded_categories = '') {
+ global $post, $wpdb;
+
+ if(! is_single()) {
+ return null;
+ }
+
+ $current_post_date = $post->post_date;
+
+ $join = '';
+ if ($in_same_cat) {
+ $join = " INNER JOIN $wpdb->post2cat ON $wpdb->posts.ID= $wpdb->post2cat.post_id ";
+ $cat_array = get_the_category($post->ID);
+ $join .= ' AND (category_id = ' . intval($cat_array[0]->cat_ID);
+ for ($i = 1; $i < (count($cat_array)); $i++) {
+ $join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID);
+ }
+ $join .= ')';
+ }
+
+ $sql_exclude_cats = '';
+ if (!empty($excluded_categories)) {
+ $blah = explode('and', $excluded_categories);
+ foreach($blah as $category) {
+ $category = intval($category);
+ $sql_exclude_cats .= " AND post_category != $category";
+ }
+ }
+
+ $now = current_time('mysql');
+
+ return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT 1");
+}
+
+function previous_post_link($format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
+ $post = get_previous_post($in_same_cat, $excluded_categories);
+
+ if(! $post) {
+ return;
+ }
+
+ $title = apply_filters('the_title', $post->post_title, $post);
+
+ $string = '<a href="'.get_permalink($post->ID).'">';
+
+ $link = str_replace('%title', $title, $link);
+
+ $link = $string . $link . '</a>';
+
+ $format = str_replace('%link', $link, $format);
+
+ echo $format;
+}
+
+function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '') {
+ $post = get_next_post($in_same_cat, $excluded_categories);
+
+ if(! $post) {
+ return;
+ }
+
+ $title = apply_filters('the_title', $post->post_title, $post);
+
+ $string = '<a href="'.get_permalink($post->ID).'">';
+
+ $link = str_replace('%title', $title, $link);
+
+ $link = $string . $link . '</a>';
+
+ $format = str_replace('%link', $link, $format);
+
+ echo $format;
+}
+
+// Deprecated. Use previous_post_link().
+function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
+
+ if ( empty($in_same_cat) || 'no' == $in_same_cat )
+ $in_same_cat = false;
+ else
+ $in_same_cat = true;
+
+ $post = get_previous_post($in_same_cat, $excluded_categories);
+
+ if(! $post) {
+ return;
+ }
+
+ $string = '<a href="'.get_permalink($post->ID).'">'.$previous;
+ if ($title == 'yes') {
+ $string .= apply_filters('the_title', $post->post_title, $post);
+ }
+ $string .= '</a>';
+ $format = str_replace('%', $string, $format);
+ echo $format;
+}
+
+// Deprecated. Use next_post_link().
+function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
+
+ if ( empty($in_same_cat) || 'no' == $in_same_cat )
+ $in_same_cat = false;
+ else
+ $in_same_cat = true;
+
+ $post = get_next_post($in_same_cat, $excluded_categories);
+
+ if(! $post) {
+ return;
+ }
+
+ $string = '<a href="'.get_permalink($post->ID).'">'.$next;
+ if ($title=='yes') {
+ $string .= apply_filters('the_title', $post->post_title, $nextpost);
+ }
+ $string .= '</a>';
+ $format = str_replace('%', $string, $format);
+ echo $format;
+}
+
+function get_pagenum_link($pagenum = 1) {
+ global $wp_rewrite;
+
+ $qstr = $_SERVER['REQUEST_URI'];
+
+ $page_querystring = "paged";
+ $page_modstring = "page/";
+ $page_modregex = "page/?";
+ $permalink = 0;
+
+ $home_root = parse_url(get_settings('home'));
+ $home_root = $home_root['path'];
+ $home_root = trailingslashit($home_root);
+ $qstr = preg_replace('|^'. $home_root . '|', '', $qstr);
+ $qstr = preg_replace('|^/+|', '', $qstr);
+
+ $index = $_SERVER['PHP_SELF'];
+ $index = preg_replace('|^'. $home_root . '|', '', $index);
+ $index = preg_replace('|^/+|', '', $index);
+
+ // if we already have a QUERY style page string
+ if( stristr( $qstr, $page_querystring ) ) {
+ $replacement = "$page_querystring=$pagenum";
+ $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr);
+ // if we already have a mod_rewrite style page string
+ } elseif ( preg_match( '|'.$page_modregex.'\d+|', $qstr ) ){
+ $permalink = 1;
+ $qstr = preg_replace('|'.$page_modregex.'\d+|',"$page_modstring$pagenum",$qstr);
+
+ // if we don't have a page string at all ...
+ // lets see what sort of URL we have...
+ } else {
+ // we need to know the way queries are being written
+ // if there's a querystring_start (a "?" usually), it's definitely not mod_rewritten
+ if ( stristr( $qstr, '?' ) ){
+ // so append the query string (using &, since we already have ?)
+ $qstr .= '&amp;' . $page_querystring . '=' . $pagenum;
+ // otherwise, it could be rewritten, OR just the default index ...
+ } elseif( '' != get_settings('permalink_structure') && ! is_admin()) {
+ $permalink = 1;
+ $index = $wp_rewrite->index;
+ // If it's not a path info permalink structure, trim the index.
+ if (! $wp_rewrite->using_index_permalinks()) {
+ $qstr = preg_replace("#/*" . $index . "/*#", '/', $qstr);
+ } else {
+ // If using path info style permalinks, make sure the index is in
+ // the URI.
+ if (strpos($qstr, $index) === false) {
+ $qstr = '/' . $index . $qstr;
+ }
+ }
+
+ $qstr = trailingslashit($qstr) . $page_modstring . $pagenum;
+ } else {
+ $qstr = $index . '?' . $page_querystring . '=' . $pagenum;
+ }
+ }
+
+ $qstr = preg_replace('|^/+|', '', $qstr);
+ if ($permalink) $qstr = trailingslashit($qstr);
+ return preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', trailingslashit( get_settings('home') ) . $qstr );
+}
+
+function next_posts($max_page = 0) { // original by cfactor at cooltux.org
+ global $paged, $pagenow;
+
+ if (! is_single()) {
+ if (!$paged) $paged = 1;
+ $nextpage = intval($paged) + 1;
+ if (!$max_page || $max_page >= $nextpage) {
+ echo get_pagenum_link($nextpage);
+ }
+ }
+}
+
+function next_posts_link($label='Next Page &raquo;', $max_page=0) {
+ global $paged, $result, $request, $posts_per_page, $wpdb, $max_num_pages;
+ if (!$max_page) {
+ if ( isset($max_num_pages) ) {
+ $max_page = $max_num_pages;
+ } else {
+ preg_match('#FROM (.*) GROUP BY#', $request, $matches);
+ $fromwhere = $matches[1];
+ $numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere");
+ $max_page = $max_num_pages = ceil($numposts / $posts_per_page);
+ }
+ }
+ if (!$paged)
+ $paged = 1;
+ $nextpage = intval($paged) + 1;
+ if ((! is_single()) && (empty($paged) || $nextpage <= $max_page)) {
+ echo '<a href="';
+ next_posts($max_page);
+ echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
+ }
+}
+
+
+function previous_posts() { // original by cfactor at cooltux.org
+ global $_SERVER, $paged, $pagenow;
+
+ if (! is_single()) {
+ $nextpage = intval($paged) - 1;
+ if ($nextpage < 1) $nextpage = 1;
+ echo get_pagenum_link($nextpage);
+ }
+}
+
+function previous_posts_link($label='&laquo; Previous Page') {
+ global $paged;
+ if ((! is_single()) && ($paged > 1) ) {
+ echo '<a href="';
+ previous_posts();
+ echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
+ }
+}
+
+function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;') {
+ global $request, $posts_per_page, $wpdb, $max_num_pages;
+ if (! is_single()) {
+
+ if (get_query_var('what_to_show') == 'posts') {
+ if ( ! isset($max_num_pages) ) {
+ preg_match('#FROM (.*) GROUP BY#', $request, $matches);
+ $fromwhere = $matches[1];
+ $numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere");
+ $max_num_pages = ceil($numposts / $posts_per_page);
+ }
+ } else {
+ $max_num_pages = 999999;
+ }
+
+ if ($max_num_pages > 1) {
+ previous_posts_link($prelabel);
+ echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $sep);
+ next_posts_link($nxtlabel, $max_page);
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/template-functions-post.php b/wp-inst/wp-includes/template-functions-post.php
new file mode 100644
index 0000000..88cc3ac
--- /dev/null
+++ b/wp-inst/wp-includes/template-functions-post.php
@@ -0,0 +1,414 @@
+<?php
+
+function get_the_password_form() {
+ $output = '<form action="' . get_settings('siteurl') . '/wp-pass.php" method="post">
+ <p>' . __("This post is password protected. To view it please enter your password below:") . '</p>
+ <p><label>' . __("Password:") . ' <input name="post_password" type="password" size="20" /></label> <input type="submit" name="Submit" value="Submit" /></p>
+ </form>
+ ';
+ return $output;
+}
+
+function the_ID() {
+ global $id;
+ echo $id;
+}
+
+function the_title($before = '', $after = '', $echo = true) {
+ $title = get_the_title();
+ if ( strlen($title) > 0 ) {
+ $title = apply_filters('the_title', $before . $title . $after, $before, $after);
+ if ($echo)
+ echo $title;
+ else
+ return $title;
+ }
+}
+
+function get_the_title($id = 0) {
+ $post = &get_post($id);
+
+ $title = $post->post_title;
+ if (!empty($post->post_password))
+ $title = sprintf(__('Protected: %s'), $title);
+
+ return $title;
+}
+
+function get_the_guid( $id = 0 ) {
+ $post = &get_post($id);
+
+ return apply_filters('get_the_guid', $post->guid);
+}
+
+function the_guid( $id = 0 ) {
+ echo get_the_guid($id);
+}
+
+
+function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
+ $content = get_the_content($more_link_text, $stripteaser, $more_file);
+ $content = apply_filters('the_content', $content);
+ $content = str_replace(']]>', ']]&gt;', $content);
+ echo $content;
+}
+
+function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
+ global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages;
+ global $preview;
+ global $pagenow;
+ $output = '';
+
+ if (!empty($post->post_password)) { // if there's a password
+ if (stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) { // and it doesn't match the cookie
+ $output = get_the_password_form();
+ return $output;
+ }
+ }
+
+ if ($more_file != '') {
+ $file = $more_file;
+ } else {
+ $file = $pagenow; //$_SERVER['PHP_SELF'];
+ }
+ $content = $pages[$page-1];
+ $content = explode('<!--more-->', $content, 2);
+ if ((preg_match('/<!--noteaser-->/', $post->post_content) && ((!$multipage) || ($page==1))))
+ $stripteaser = 1;
+ $teaser = $content[0];
+ if (($more) && ($stripteaser))
+ $teaser = '';
+ $output .= $teaser;
+ if (count($content)>1) {
+ if ($more) {
+ $output .= '<a id="more-'.$id.'"></a>'.$content[1];
+ } else {
+ $output .= ' <a href="'. get_permalink() . "#more-$id\">$more_link_text</a>";
+ }
+ }
+ if ($preview) { // preview fix for javascript bug with foreign languages
+ $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output);
+ }
+ return $output;
+}
+
+function the_excerpt() {
+ echo apply_filters('the_excerpt', get_the_excerpt());
+}
+
+function get_the_excerpt($fakeit = true) {
+ global $id, $post;
+ $output = '';
+ $output = $post->post_excerpt;
+ if (!empty($post->post_password)) { // if there's a password
+ if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
+ $output = __('There is no excerpt because this is a protected post.');
+ return $output;
+ }
+ }
+
+ return apply_filters('get_the_excerpt', $output);
+}
+
+function wp_link_pages($args = '') {
+ parse_str($args, $r);
+ if (!isset($r['before'])) $r['before'] = '<p>' . __('Pages:');
+ if (!isset($r['after'])) $r['after'] = '</p>';
+ if (!isset($r['next_or_number'])) $r['next_or_number'] = 'number';
+ if (!isset($r['nextpagelink'])) $r['nextpagelink'] = 'Next page';
+ if (!isset($r['previouspagelink'])) $r['previouspagelink'] = 'Previous page';
+ if (!isset($r['pagelink'])) $r['pagelink'] = '%';
+ if (!isset($r['more_file'])) $r['more_file'] = '';
+ link_pages($r['before'], $r['after'], $r['next_or_number'], $r['nextpagelink'], $r['previouspagelink'], $r['pagelink'], $r['more_file']);
+}
+
+function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') {
+ global $id, $page, $numpages, $multipage, $more;
+ global $pagenow;
+ if ($more_file != '') {
+ $file = $more_file;
+ } else {
+ $file = $pagenow;
+ }
+ if (($multipage)) {
+ if ($next_or_number=='number') {
+ echo $before;
+ for ($i = 1; $i < ($numpages+1); $i = $i + 1) {
+ $j=str_replace('%',"$i",$pagelink);
+ echo ' ';
+ if (($i != $page) || ((!$more) && ($page==1))) {
+ if ('' == get_settings('permalink_structure')) {
+ echo '<a href="' . get_permalink() . '&amp;page=' . $i . '">';
+ } else {
+ echo '<a href="' . trailingslashit( get_permalink() ) . $i . '/">';
+ }
+ }
+ echo $j;
+ if (($i != $page) || ((!$more) && ($page==1)))
+ echo '</a>';
+ }
+ echo $after;
+ } else {
+ if ($more) {
+ echo $before;
+ $i=$page-1;
+ if ($i && $more) {
+ if ('' == get_settings('permalink_structure')) {
+ echo '<a href="' . get_permalink() . '&amp;page=' . $i . '">'.$previouspagelink.'</a>';
+ } else {
+ echo '<a href="' . get_permalink() . $i . '/">'.$previouspagelink.'</a>';
+ }
+ }
+ $i=$page+1;
+ if ($i<=$numpages && $more) {
+ if ('' == get_settings('permalink_structure')) {
+ echo '<a href="'.get_permalink() . '&amp;page=' . $i . '">'.$nextpagelink.'</a>';
+ } else {
+ echo '<a href="'.get_permalink().$i.'/">'.$nextpagelink.'</a>';
+ }
+ }
+ echo $after;
+ }
+ }
+ }
+}
+
+/*
+ * Post-meta: Custom per-post fields.
+ */
+
+function get_post_custom( $post_id = 0 ) {
+ global $id, $post_meta_cache, $wpdb;
+ if ( $post_id )
+ $id = $post_id;
+ if ( isset($post_meta_cache[$id]) ) {
+ return $post_meta_cache[$id];
+ } else {
+ if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = '$id' ORDER BY post_id, meta_key", ARRAY_A) ) {
+
+ // Change from flat structure to hierarchical:
+ $post_meta_cache = array();
+ foreach ($meta_list as $metarow) {
+ $mpid = $metarow['post_id'];
+ $mkey = $metarow['meta_key'];
+ $mval = $metarow['meta_value'];
+
+ // Force subkeys to be array type:
+ if (!isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]))
+ $post_meta_cache[$mpid] = array();
+ if (!isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]))
+ $post_meta_cache[$mpid]["$mkey"] = array();
+
+ // Add a value to the current pid/key:
+ $post_meta_cache[$mpid][$mkey][] = $mval;
+ }
+ return $post_meta_cache[$mpid];
+ }
+ }
+}
+
+function get_post_custom_keys() {
+ global $id, $post_meta_cache;
+
+ if (!is_array($post_meta_cache[$id]))
+ return;
+ if ($keys = array_keys($post_meta_cache[$id]))
+ return $keys;
+}
+
+function get_post_custom_values($key='') {
+ global $id, $post_meta_cache;
+
+ return $post_meta_cache[$id][$key];
+}
+
+function post_custom( $key = '' ) {
+ global $id, $post_meta_cache;
+
+ if ( 1 == count($post_meta_cache[$id][$key]) ) return $post_meta_cache[$id][$key][0];
+ else return $post_meta_cache[$id][$key];
+}
+
+// this will probably change at some point...
+function the_meta() {
+ global $id, $post_meta_cache;
+
+ if ($keys = get_post_custom_keys()) {
+ echo "<ul class='post-meta'>\n";
+ foreach ($keys as $key) {
+ $values = array_map('trim',$post_meta_cache[$id][$key]);
+ $value = implode($values,', ');
+
+ echo "<li><span class='post-meta-key'>$key:</span> $value</li>\n";
+ }
+ echo "</ul>\n";
+ }
+}
+
+
+//
+// Pages
+//
+
+function &get_page_children($page_id, $pages) {
+ global $page_cache;
+
+ if ( empty($pages) )
+ $pages = &$page_cache;
+
+ $page_list = array();
+ foreach ($pages as $page) {
+ if ($page->post_parent == $page_id) {
+ $page_list[] = $page;
+ if ( $children = get_page_children($page->ID, $pages)) {
+ $page_list = array_merge($page_list, $children);
+ }
+ }
+ }
+
+ return $page_list;
+}
+
+function &get_pages($args = '') {
+ global $wpdb;
+
+ parse_str($args, $r);
+
+ if (!isset($r['child_of'])) $r['child_of'] = 0;
+ if (!isset($r['sort_column'])) $r['sort_column'] = 'post_title';
+ if (!isset($r['sort_order'])) $r['sort_order'] = 'ASC';
+
+ $exclusions = '';
+ if (!empty($r['exclude'])) {
+ $expages = preg_split('/[\s,]+/',$r['exclude']);
+ if (count($expages)) {
+ foreach ($expages as $expage) {
+ $exclusions .= ' AND ID <> ' . intval($expage) . ' ';
+ }
+ }
+ }
+
+ $pages = $wpdb->get_results("SELECT * " .
+ "FROM $wpdb->posts " .
+ "WHERE post_status = 'static' " .
+ "$exclusions " .
+ "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);
+
+ if ( empty($pages) )
+ return array();
+
+ // Update cache.
+ update_page_cache($pages);
+
+ if ($r['child_of'])
+ $pages = & get_page_children($r['child_of'], $pages);
+
+ return $pages;
+}
+
+function wp_list_pages($args = '') {
+ parse_str($args, $r);
+ if ( !isset($r['depth']) ) $r['depth'] = 0;
+ if ( !isset($r['show_date']) ) $r['show_date'] = '';
+ if ( !isset($r['child_of']) ) $r['child_of'] = 0;
+ if ( !isset($r['title_li']) ) $r['title_li'] = __('Pages');
+ if ( !isset($r['echo']) ) $r['echo'] = 1;
+
+ $output = '';
+
+ // Query pages.
+ $pages = & get_pages($args);
+ if ( $pages ) :
+
+ if ( $r['title_li'] )
+ $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
+ // Now loop over all pages that were selected
+ $page_tree = Array();
+ foreach($pages as $page) {
+ // set the title for the current page
+ $page_tree[$page->ID]['title'] = $page->post_title;
+ $page_tree[$page->ID]['name'] = $page->post_name;
+
+ // set the selected date for the current page
+ // depending on the query arguments this is either
+ // the createtion date or the modification date
+ // as a unix timestamp. It will also always be in the
+ // ts field.
+ if (! empty($r['show_date'])) {
+ if ('modified' == $r['show_date'])
+ $page_tree[$page->ID]['ts'] = $page->post_modified;
+ else
+ $page_tree[$page->ID]['ts'] = $page->post_date;
+ }
+
+ // The tricky bit!!
+ // Using the parent ID of the current page as the
+ // array index we set the curent page as a child of that page.
+ // We can now start looping over the $page_tree array
+ // with any ID which will output the page links from that ID downwards.
+ if ( $page->post_parent != $page->ID)
+ $page_tree[$page->post_parent]['children'][] = $page->ID;
+ }
+ // Output of the pages starting with child_of as the root ID.
+ // child_of defaults to 0 if not supplied in the query.
+ $output .= _page_level_out($r['child_of'],$page_tree, $r, 0, false);
+ if ( $r['title_li'] )
+ $output .= '</ul></li>';
+ endif;
+
+ $output = apply_filters('wp_list_pages', $output);
+
+ if ( $r['echo'] )
+ echo $output;
+ else
+ return $output;
+}
+
+function _page_level_out($parent, $page_tree, $args, $depth = 0, $echo = true) {
+ global $wp_query;
+
+ $queried_obj = $wp_query->get_queried_object();
+
+ $output = '';
+
+ if($depth)
+ $indent = str_repeat("\t", $depth);
+ //$indent = join('', array_fill(0,$depth,"\t"));
+
+ foreach($page_tree[$parent]['children'] as $page_id) {
+ $cur_page = $page_tree[$page_id];
+ $title = $cur_page['title'];
+
+ $css_class = 'page_item';
+ if( $page_id == $queried_obj->ID) {
+ $css_class .= ' current_page_item';
+ }
+
+ $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>';
+
+ if(isset($cur_page['ts'])) {
+ $format = get_settings('date_format');
+ if(isset($args['date_format']))
+ $format = $args['date_format'];
+ $output .= " " . mysql2date($format, $cur_page['ts']);
+ }
+ $output .= "\n";
+
+ if(isset($cur_page['children']) && is_array($cur_page['children'])) {
+ $new_depth = $depth + 1;
+
+ if(!$args['depth'] || $depth < ($args['depth']-1)) {
+ $output .= "$indent<ul>\n";
+ $output .= _page_level_out($page_id, $page_tree, $args, $new_depth, false);
+ $output .= "$indent</ul>\n";
+ }
+ }
+ $output .= "$indent</li>\n";
+ }
+ if ( $echo )
+ echo $output;
+ else
+ return $output;
+}
+
+?>
diff --git a/wp-inst/wp-includes/template-loader.php b/wp-inst/wp-includes/template-loader.php
new file mode 100644
index 0000000..07bda7c
--- /dev/null
+++ b/wp-inst/wp-includes/template-loader.php
@@ -0,0 +1,59 @@
+<?php
+
+if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
+ do_action('template_redirect');
+ if ( is_feed() ) {
+ include(ABSPATH . '/wp-feed.php');
+ exit;
+ } else if ( is_trackback() ) {
+ include(ABSPATH . '/wp-trackback.php');
+ exit;
+ } else if ( is_404() && get_404_template() ) {
+ include(get_404_template());
+ exit;
+ } else if ( is_search() && get_search_template() ) {
+ include(get_search_template());
+ exit;
+ } else if ( is_home() && get_home_template() ) {
+ include(get_home_template());
+ exit;
+ } else if ( is_single() && get_single_template() ) {
+ include(get_single_template());
+ exit;
+ } else if ( is_page() && get_page_template() ) {
+ include(get_page_template());
+ exit;
+ } else if ( is_category() && get_category_template()) {
+ include(get_category_template());
+ exit;
+ } else if ( is_author() && get_author_template() ) {
+ include(get_author_template());
+ exit;
+ } else if ( is_date() && get_date_template() ) {
+ include(get_date_template());
+ exit;
+ } else if ( is_archive() && get_archive_template() ) {
+ include(get_archive_template());
+ exit;
+ } else if ( is_comments_popup() && get_comments_popup_template() ) {
+ include(get_comments_popup_template());
+ exit;
+ } else if ( is_paged() && get_paged_template() ) {
+ include(get_paged_template());
+ exit;
+ } else if ( file_exists(TEMPLATEPATH . "/index.php") ) {
+ include(TEMPLATEPATH . "/index.php");
+ exit;
+ }
+} else {
+ // Process feeds and trackbacks even if not using themes.
+ if ( is_feed() ) {
+ include(ABSPATH . '/wp-feed.php');
+ exit;
+ } else if ( is_trackback() ) {
+ include(ABSPATH . '/wp-trackback.php');
+ exit;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/vars.php b/wp-inst/wp-includes/vars.php
new file mode 100644
index 0000000..494f285
--- /dev/null
+++ b/wp-inst/wp-includes/vars.php
@@ -0,0 +1,113 @@
+<?php
+
+// On which page are we ?
+$PHP_SELF = $_SERVER['PHP_SELF'];
+if (preg_match('#([^/]+.php)#', $PHP_SELF, $self_matches)) {
+ $pagenow = $self_matches[1];
+} else if (strstr($PHP_SELF, '?')) {
+ $pagenow = explode('/', $PHP_SELF);
+ $pagenow = trim($pagenow[(sizeof($pagenow)-1)]);
+ $pagenow = explode('?', $pagenow);
+ $pagenow = $pagenow[0];
+} else {
+ $pagenow = 'index.php';
+}
+
+// Simple browser detection
+$is_lynx = 0; $is_gecko = 0; $is_winIE = 0; $is_macIE = 0; $is_opera = 0; $is_NS4 = 0;
+if (!isset($HTTP_USER_AGENT)) {
+ $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
+}
+if (preg_match('/Lynx/', $HTTP_USER_AGENT)) {
+ $is_lynx = 1;
+} elseif (preg_match('/Gecko/', $HTTP_USER_AGENT)) {
+ $is_gecko = 1;
+} elseif ((preg_match('/MSIE/', $HTTP_USER_AGENT)) && (preg_match('/Win/', $HTTP_USER_AGENT))) {
+ $is_winIE = 1;
+} elseif ((preg_match('/MSIE/', $HTTP_USER_AGENT)) && (preg_match('/Mac/', $HTTP_USER_AGENT))) {
+ $is_macIE = 1;
+} elseif (preg_match('/Opera/', $HTTP_USER_AGENT)) {
+ $is_opera = 1;
+} elseif ((preg_match('/Nav/', $HTTP_USER_AGENT) ) || (preg_match('/Mozilla\/4\./', $HTTP_USER_AGENT))) {
+ $is_NS4 = 1;
+}
+$is_IE = (($is_macIE) || ($is_winIE));
+
+// Server detection
+$is_apache = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? 1 : 0;
+$is_IIS = strstr($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') ? 1 : 0;
+
+// if the config file does not provide the smilies array, let's define it here
+if (!isset($wpsmiliestrans)) {
+ $wpsmiliestrans = array(
+ ' :)' => 'icon_smile.gif',
+ ' :D' => 'icon_biggrin.gif',
+ ' :-D' => 'icon_biggrin.gif',
+ ':grin:' => 'icon_biggrin.gif',
+ ' :)' => 'icon_smile.gif',
+ ' :-)' => 'icon_smile.gif',
+ ':smile:' => 'icon_smile.gif',
+ ' :(' => 'icon_sad.gif',
+ ' :-(' => 'icon_sad.gif',
+ ':sad:' => 'icon_sad.gif',
+ ' :o' => 'icon_surprised.gif',
+ ' :-o' => 'icon_surprised.gif',
+ ':eek:' => 'icon_surprised.gif',
+ ' 8O' => 'icon_eek.gif',
+ ' 8-O' => 'icon_eek.gif',
+ ':shock:' => 'icon_eek.gif',
+ ' :?' => 'icon_confused.gif',
+ ' :-?' => 'icon_confused.gif',
+ ' :???:' => 'icon_confused.gif',
+ ' 8)' => 'icon_cool.gif',
+ ' 8-)' => 'icon_cool.gif',
+ ':cool:' => 'icon_cool.gif',
+ ':lol:' => 'icon_lol.gif',
+ ' :x' => 'icon_mad.gif',
+ ' :-x' => 'icon_mad.gif',
+ ':mad:' => 'icon_mad.gif',
+ ' :P' => 'icon_razz.gif',
+ ' :-P' => 'icon_razz.gif',
+ ':razz:' => 'icon_razz.gif',
+ ':oops:' => 'icon_redface.gif',
+ ':cry:' => 'icon_cry.gif',
+ ':evil:' => 'icon_evil.gif',
+ ':twisted:' => 'icon_twisted.gif',
+ ':roll:' => 'icon_rolleyes.gif',
+ ':wink:' => 'icon_wink.gif',
+ ' ;)' => 'icon_wink.gif',
+ ' ;-)' => 'icon_wink.gif',
+ ':!:' => 'icon_exclaim.gif',
+ ':?:' => 'icon_question.gif',
+ ':idea:' => 'icon_idea.gif',
+ ':arrow:' => 'icon_arrow.gif',
+ ' :|' => 'icon_neutral.gif',
+ ' :-|' => 'icon_neutral.gif',
+ ':neutral:' => 'icon_neutral.gif',
+ ':mrgreen:' => 'icon_mrgreen.gif',
+ );
+}
+
+// sorts the smilies' array
+if (!function_exists('smiliescmp')) {
+function smiliescmp ($a, $b) {
+ if (strlen($a) == strlen($b)) {
+ return strcmp($a, $b);
+ }
+ return (strlen($a) > strlen($b)) ? -1 : 1;
+ }
+}
+uksort($wpsmiliestrans, 'smiliescmp');
+
+// generates smilies' search & replace arrays
+foreach($wpsmiliestrans as $smiley => $img) {
+ $wp_smiliessearch[] = $smiley;
+ $smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES);
+ $wp_smiliesreplace[] = " <img src='" . get_settings('siteurl') . "/wp-images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
+}
+
+// Path for cookies
+define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' ) );
+define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('siteurl') . '/' ) );
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/version.php b/wp-inst/wp-includes/version.php
new file mode 100644
index 0000000..53c9f16
--- /dev/null
+++ b/wp-inst/wp-includes/version.php
@@ -0,0 +1,7 @@
+<?php
+
+// This just holds the version number, in a separate file so we can bump it without cluttering the SVN
+
+$wp_version = '1.6-ALPHA-do-not-use';
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/wp-db.php b/wp-inst/wp-includes/wp-db.php
new file mode 100644
index 0000000..73d4be7
--- /dev/null
+++ b/wp-inst/wp-includes/wp-db.php
@@ -0,0 +1,362 @@
+<?php
+// WordPress DB Class
+
+// ORIGINAL CODE FROM:
+// Justin Vincent (justin@visunet.ie)
+// http://php.justinvincent.com
+
+define('EZSQL_VERSION', 'WP1.25');
+define('OBJECT', 'OBJECT', true);
+define('ARRAY_A', 'ARRAY_A', false);
+define('ARRAY_N', 'ARRAY_N', false);
+
+if (!defined('SAVEQUERIES'))
+ define('SAVEQUERIES', false);
+
+class wpdb {
+
+ var $show_errors = true;
+ var $num_queries = 0;
+ var $last_query;
+ var $col_info;
+ var $queries;
+
+ // Our tables
+ var $posts;
+ var $users;
+ var $categories;
+ var $post2cat;
+ var $comments;
+ var $links;
+ var $linkcategories;
+ var $options;
+ var $optiontypes;
+ var $optionvalues;
+ var $optiongroups;
+ var $optiongroup_options;
+ var $postmeta;
+
+ // ==================================================================
+ // DB Constructor - connects to the server and selects a database
+
+ function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
+ $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
+ if (!$this->dbh) {
+ $this->bail("
+<h1>Error establishing a database connection</h1>
+<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>$dbhost</code>. This could mean your host's database server is down.</p>
+<ul>
+ <li>Are you sure you have the correct username and password?</li>
+ <li>Are you sure that you have typed the correct hostname?</li>
+ <li>Are you sure that the database server is running?</li>
+</ul>
+<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>
+");
+ }
+
+ $this->select($dbname);
+ }
+
+ // ==================================================================
+ // Select a DB (if another one needs to be selected)
+
+ function select($db) {
+ if (!@mysql_select_db($db, $this->dbh)) {
+ $this->bail("
+<h1>Can&#8217;t select database</h1>
+<p>We were able to connect to the database server (which means your username and password is okay) but not able to select the <code>$db</code> database.</p>
+<ul>
+<li>Are you sure it exists?</li>
+<li>On some systems the name of your database is prefixed with your username, so it would be like username_wordpress. Could that be the problem?</li>
+</ul>
+<p>If you don't know how to setup a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>");
+ }
+ }
+
+ // ====================================================================
+ // Format a string correctly for safe insert under all PHP conditions
+
+ function escape($string) {
+ if( !$this->dbh || version_compare( phpversion(), '4.3.0' ) == '-1' )
+ return mysql_escape_string( $string );
+ else
+ return mysql_real_escape_string( $string, $this->dbh );
+ }
+
+ // ==================================================================
+ // Print SQL/DB error.
+
+ function print_error($str = '') {
+ global $EZSQL_ERROR;
+ if (!$str) $str = mysql_error();
+ $EZSQL_ERROR[] =
+ array ('query' => $this->last_query, 'error_str' => $str);
+
+ // Is error output turned on or not..
+ if ( $this->show_errors ) {
+ // If there is an error then take note of it
+ print "<div id='error'>
+ <p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
+ <code>$this->last_query</code></p>
+ </div>";
+ } else {
+ return false;
+ }
+ }
+
+ // ==================================================================
+ // Turn error handling on or off..
+
+ function show_errors() {
+ $this->show_errors = true;
+ }
+
+ function hide_errors() {
+ $this->show_errors = false;
+ }
+
+ // ==================================================================
+ // Kill cached query results
+
+ function flush() {
+ $this->last_result = null;
+ $this->col_info = null;
+ $this->last_query = null;
+ }
+
+ // ==================================================================
+ // Basic Query - see docs for more detail
+
+ function query($query) {
+ // initialise return
+ $return_val = 0;
+ $this->flush();
+
+ // Log how the function was called
+ $this->func_call = "\$db->query(\"$query\")";
+
+ // Keep track of the last query for debug..
+ $this->last_query = $query;
+
+ // Perform the query via std mysql_query function..
+ if (SAVEQUERIES)
+ $this->timer_start();
+
+ $this->result = @mysql_query($query, $this->dbh);
+ ++$this->num_queries;
+
+ if (SAVEQUERIES)
+ $this->queries[] = array( $query, $this->timer_stop() );
+
+ // If there is an error then take note of it..
+ if ( mysql_error() ) {
+ $this->print_error();
+ return false;
+ }
+
+ if ( preg_match("/^\\s*(insert|delete|update|replace) /i",$query) ) {
+ $this->rows_affected = mysql_affected_rows();
+ // Take note of the insert_id
+ if ( preg_match("/^\\s*(insert|replace) /i",$query) ) {
+ $this->insert_id = mysql_insert_id($this->dbh);
+ }
+ // Return number of rows affected
+ $return_val = $this->rows_affected;
+ } else {
+ $i = 0;
+ while ($i < @mysql_num_fields($this->result)) {
+ $this->col_info[$i] = @mysql_fetch_field($this->result);
+ $i++;
+ }
+ $num_rows = 0;
+ while ( $row = @mysql_fetch_object($this->result) ) {
+ $this->last_result[$num_rows] = $row;
+ $num_rows++;
+ }
+
+ @mysql_free_result($this->result);
+
+ // Log number of rows the query returned
+ $this->num_rows = $num_rows;
+
+ // Return number of rows selected
+ $return_val = $this->num_rows;
+ }
+
+ return $return_val;
+ }
+
+ // ==================================================================
+ // Get one variable from the DB - see docs for more detail
+
+ function get_var($query=null, $x = 0, $y = 0) {
+ $this->func_call = "\$db->get_var(\"$query\",$x,$y)";
+ if ( $query )
+ $this->query($query);
+
+ // Extract var out of cached results based x,y vals
+ if ( $this->last_result[$y] ) {
+ $values = array_values(get_object_vars($this->last_result[$y]));
+ }
+
+ // If there is a value return it else return null
+ return (isset($values[$x]) && $values[$x]!=='') ? $values[$x] : null;
+ }
+
+ // ==================================================================
+ // Get one row from the DB - see docs for more detail
+
+ function get_row($query = null, $output = OBJECT, $y = 0) {
+ $this->func_call = "\$db->get_row(\"$query\",$output,$y)";
+ if ( $query )
+ $this->query($query);
+
+ if ( $output == OBJECT ) {
+ return $this->last_result[$y] ? $this->last_result[$y] : null;
+ } elseif ( $output == ARRAY_A ) {
+ return $this->last_result[$y] ? get_object_vars($this->last_result[$y]) : null;
+ } elseif ( $output == ARRAY_N ) {
+ return $this->last_result[$y] ? array_values(get_object_vars($this->last_result[$y])) : null;
+ } else {
+ $this->print_error(" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N");
+ }
+ }
+
+ // ==================================================================
+ // Function to get 1 column from the cached result set based in X index
+ // se docs for usage and info
+
+ function get_col($query = null , $x = 0) {
+ if ( $query )
+ $this->query($query);
+
+ // Extract the column values
+ for ( $i=0; $i < count($this->last_result); $i++ ) {
+ $new_array[$i] = $this->get_var(null, $x, $i);
+ }
+ return $new_array;
+ }
+
+ // ==================================================================
+ // Return the the query as a result set - see docs for more details
+
+ function get_results($query = null, $output = OBJECT) {
+ $this->func_call = "\$db->get_results(\"$query\", $output)";
+
+ if ( $query )
+ $this->query($query);
+
+ // Send back array of objects. Each row is an object
+ if ( $output == OBJECT ) {
+ return $this->last_result;
+ } elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
+ if ( $this->last_result ) {
+ $i = 0;
+ foreach( $this->last_result as $row ) {
+ $new_array[$i] = (array) $row;
+ if ( $output == ARRAY_N ) {
+ $new_array[$i] = array_values($new_array[$i]);
+ }
+ $i++;
+ }
+ return $new_array;
+ } else {
+ return null;
+ }
+ }
+ }
+
+
+ // ==================================================================
+ // Function to get column meta data info pertaining to the last query
+ // see docs for more info and usage
+
+ function get_col_info($info_type = 'name', $col_offset = -1) {
+ if ( $this->col_info ) {
+ if ( $col_offset == -1 ) {
+ $i = 0;
+ foreach($this->col_info as $col ) {
+ $new_array[$i] = $col->{$info_type};
+ $i++;
+ }
+ return $new_array;
+ } else {
+ return $this->col_info[$col_offset]->{$info_type};
+ }
+ }
+ }
+
+ function timer_start() {
+ $mtime = microtime();
+ $mtime = explode(' ', $mtime);
+ $this->time_start = $mtime[1] + $mtime[0];
+ return true;
+ }
+
+ function timer_stop($precision = 3) {
+ $mtime = microtime();
+ $mtime = explode(' ', $mtime);
+ $time_end = $mtime[1] + $mtime[0];
+ $time_total = $time_end - $this->time_start;
+ return $time_total;
+ }
+
+ function bail($message) { // Just wraps errors in a nice header and footer
+ if ( !$this->show_errors )
+ return false;
+ header( 'Content-Type: text/html; charset=utf-8');
+ echo <<<HEAD
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>WordPress &rsaquo; Error</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <style media="screen" type="text/css">
+ <!--
+ html {
+ background: #eee;
+ }
+ body {
+ background: #fff;
+ color: #000;
+ font-family: Georgia, "Times New Roman", Times, serif;
+ margin-left: 25%;
+ margin-right: 25%;
+ padding: .2em 2em;
+ }
+
+ h1 {
+ color: #006;
+ font-size: 18px;
+ font-weight: lighter;
+ }
+
+ h2 {
+ font-size: 16px;
+ }
+
+ p, li, dt {
+ line-height: 140%;
+ padding-bottom: 2px;
+ }
+
+ ul, ol {
+ padding: 5px 5px 5px 20px;
+ }
+ #logo {
+ margin-bottom: 2em;
+ }
+ -->
+ </style>
+ </head>
+ <body>
+ <h1 id="logo"><img alt="WordPress" src="http://static.wordpress.org/logo.png" /></h1>
+HEAD;
+ echo $message;
+ echo "</body></html>";
+ die();
+ }
+}
+
+$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/wp-l10n.php b/wp-inst/wp-includes/wp-l10n.php
new file mode 100644
index 0000000..c051fda
--- /dev/null
+++ b/wp-inst/wp-includes/wp-l10n.php
@@ -0,0 +1,103 @@
+<?php
+
+if ( defined('WPLANG') && '' != constant('WPLANG') ) {
+ include_once(ABSPATH . 'wp-includes/streams.php');
+ include_once(ABSPATH . 'wp-includes/gettext.php');
+}
+
+function get_locale() {
+ global $locale;
+
+ if (isset($locale))
+ return $locale;
+
+ // WPLANG is defined in wp-config.
+ if (defined('WPLANG')) {
+ $locale = WPLANG;
+ }
+
+ if (empty($locale)) {
+ $locale = 'en_US';
+ }
+
+ $locale = apply_filters('locale', $locale);
+
+ return $locale;
+}
+
+// Return a translated string.
+function __($text, $domain = 'default') {
+ global $l10n;
+
+ if (isset($l10n[$domain])) {
+ return $l10n[$domain]->translate($text);
+ } else {
+ return $text;
+ }
+}
+
+// Echo a translated string.
+function _e($text, $domain = 'default') {
+ global $l10n;
+
+ if (isset($l10n[$domain])) {
+ echo $l10n[$domain]->translate($text);
+ } else {
+ echo $text;
+ }
+}
+
+// Return the plural form.
+function __ngettext($single, $plural, $number, $domain = 'default') {
+ global $l10n;
+
+ if (isset($l10n[$domain])) {
+ return $l10n[$domain]->ngettext($single, $plural, $number);
+ } else {
+ if ($number != 1)
+ return $plural;
+ else
+ return $single;
+ }
+}
+
+function load_textdomain($domain, $mofile) {
+ global $l10n;
+
+ if (isset($l10n[$domain])) {
+ return;
+ }
+
+ if ( is_readable($mofile)) {
+ $input = new CachedFileReader($mofile);
+ } else {
+ return;
+ }
+
+ $l10n[$domain] = new gettext_reader($input);
+}
+
+function load_default_textdomain() {
+ global $l10n;
+
+ $locale = get_locale();
+ $mofile = ABSPATH . "wp-includes/languages/$locale.mo";
+
+ load_textdomain('default', $mofile);
+}
+
+function load_plugin_textdomain($domain) {
+ $locale = get_locale();
+
+ $mofile = ABSPATH . "wp-content/plugins/$domain-$locale.mo";
+ load_textdomain($domain, $mofile);
+}
+
+function load_theme_textdomain($domain) {
+ $locale = get_locale();
+
+ $mofile = get_template_directory() . "/$locale.mo";
+ load_textdomain($domain, $mofile);
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/wpmu-functions.php b/wp-inst/wp-includes/wpmu-functions.php
new file mode 100644
index 0000000..c18fa89
--- /dev/null
+++ b/wp-inst/wp-includes/wpmu-functions.php
@@ -0,0 +1,807 @@
+<?PHP
+/*
+ Helper functions for WPMU
+ 4th March 2005
+
+ There are 2 types of helper functions; those that use hooks (do_action, apply_filters hooks) and those that support WPMU the Administration plugin.
+
+ Where possible - existing hooks have been used, but occasionally - extra hooks have been implemented in the WP Core.
+*/
+
+/**
+ * Retrieves a list of client blogs
+ *
+ * @return array
+ */
+function wpmu_getBlogs(){
+ $blogs = array();
+
+ $link = opendir(ABSPATH . 'wp-content/blogs.dir/');
+ while(false !== ($dir = readdir($link))){
+ if(is_dir(ABSPATH . 'wp-content/blogs.dir/' . $dir)) {
+ switch($dir){
+ case '.':
+ case '..':
+ case 'DEFAULT':
+ break;
+ case 'main':
+ array_unshift($blogs, $dir);
+ break;
+
+ default:
+ $blogs[] = $dir;
+ break;
+ }
+ }
+ }
+
+ closedir($link);
+
+ return $blogs;
+}
+
+
+// Cache clearing
+/**
+ * Clears the smarty cache when post/comments occur
+ *
+ */
+function wpmu_clear_cache() {
+ // for future use.
+}
+add_action('comment_post', 'wpmu_clear_cache');
+add_action('delete_post', 'wpmu_clear_cache');
+add_action('delete_comment', 'wpmu_clear_cache');
+add_action('private_to_published', 'wpmu_clear_cache');
+add_action('publish_phone', 'wpmu_clear_cache');
+add_action('publish_post', 'wpmu_clear_cache');
+add_action('trackback_post', 'wpmu_clear_cache');
+add_action('wp_set_comment_status', 'wpmu_clear_cache');
+
+function wpmu_update_blogs_date() {
+ global $wpdb;
+
+ $query = "UPDATE ".$wpdb->blogs."
+ SET last_updated = NOW()
+ WHERE blog_id = '".$wpdb->blogid."'";
+ $wpdb->query( $query );
+}
+add_action('comment_post', 'wpmu_update_blogs_date');
+add_action('delete_post', 'wpmu_update_blogs_date');
+add_action('delete_comment', 'wpmu_update_blogs_date');
+add_action('private_to_published', 'wpmu_update_blogs_date');
+add_action('publish_phone', 'wpmu_update_blogs_date');
+add_action('publish_post', 'wpmu_update_blogs_date');
+add_action('trackback_post', 'wpmu_update_blogs_date');
+add_action('wp_set_comment_status', 'wpmu_update_blogs_date');
+
+
+/**
+ * Cleans the passed path.
+ * Removes the wpmu & the blog name from the path
+ * This should only be used for display filters
+ *
+ * @param unknown $path
+ * @return unknown
+ */
+function wpmu_tidypath($path) {
+ global $wpblog;
+
+ $path = str_replace('/wpmu/','/',$path);
+ $path = str_replace("/{$wpblog}/",'/',$path);
+
+ return $path;
+}
+add_filter('wpmu_display_get_page_string','wpmu_tidypath',10);
+add_filter('wpmu_display_get_permalink','wpmu_tidypath',10);
+
+/**
+ * Wrapper for querying the databse
+ *
+ * @param string $query
+ * @return object
+ */
+function wpmu_adminDatabaseQuery($query) {
+ /* @var $wpdb wpdb */
+ global $wpdb;
+
+ $result = $wpdb->get_row($query);
+
+ return $result;
+}
+
+/**
+ * Set an option in the Master Blog 'main' options table
+ *
+ * @param string $optionName
+ * @param mixed $optionValue
+ */
+function wpmu_adminOptionSet($optionName, $optionValue) {
+ wpmu_blogOption_set('main',$optionName, $optionValue);
+}
+
+/**
+ * Retrieve a setting from the Master Blog Tables
+ *
+ * @param string $optionName
+ * @param mixed $default
+ * @return mixed
+ */
+function wpmu_adminOption_get($optionName, $default=null) {
+ return wpmu_blogOption_get('main',$optionName, $default);
+}
+
+/**
+ * Retrives a setting from a specific client blog
+ *
+ * @param string $blogName
+ * @param string $optionName
+ * @param mixed $default
+ * @return mixed
+ */
+function wpmu_blogOption_get($blogName, $optionName, $default=null) {
+ global $wpdb;
+
+ // check if options table exists
+ if( defined('WP_INSTALLING') )
+ return null;
+
+ $query = wpmu_adminDatabaseQuery("SELECT * FROM ".$wpdb->options." WHERE option_name = '{$optionName}'");
+ if (!isset($query) || is_null($query)) {
+ $result = $default;
+ } else {
+ $result = $query->option_value;
+ if (!(unserialize($result)===false)) {
+ $result = unserialize($result);
+ }
+ }
+
+ return $result;
+}
+
+
+/**
+ * Sets an option for a specific client blog
+ *
+ * @param string $blogName
+ * @param string $optionName
+ * @param mixed $optionValue
+ */
+function wpmu_blogOption_set($blogName, $optionName, $optionValue) {
+
+ global $wpdb;
+
+ $isExisting = wpmu_blogOption_get($blogName,$optionName,null);
+
+ if (is_array($optionValue) || is_object($optionValue)) {
+ $optionValue = serialize($optionValue);
+ }
+
+ if (is_null($isExisting)) {
+ wpmu_adminDatabaseQuery("INSERT INTO ".$wpdb->options." (option_name, option_value) values ('{$optionName}', '{$optionValue}')");
+ } else {
+ wpmu_adminDatabaseQuery("UPDATE ".$wpdb->options." set option_value = '{$optionValue}' where option_name = '{$optionName}'");
+ }
+}
+
+/*
+ Determines if the available space defined by the admin has been exceeded by the user
+*/
+/**
+ * Returns how much space is available (also shows a picture) for the current client blog, retrieving the value from the master blog 'main' option table
+ *
+ * @param string $action
+ * @return string
+ */
+function wpmu_checkAvailableSpace($action) {
+ // Using the action.
+ // Set the action to 'not-writable' to block the upload
+ global $wpblog, $blog_id;
+
+ // Default space allowed is 10 MB
+ $spaceAllowed = wpmu_adminOption_get("wpmu_space_allocated", 10485760 );
+
+ $dirName = ABSPATH."wp-content/blogs.dir/".$blog_id."/files/";
+
+ $dir = dir($dirName);
+ $size = 0;
+
+ while($file = $dir->read()) {
+ if ($file != '.' && $file != '..') {
+ if (is_dir($file)) {
+ $size += dirsize($dirName . '/' . $file);
+ } else {
+ $size += filesize($dirName . '/' . $file);
+ }
+ }
+ }
+ $dir->close();
+
+ ?>
+ <table align="center" width="20%" cellpadding="0" cellspacing="0">
+ <tr>
+ <td>Space Available (<?php print $spaceAllowed-$size ?><i>bytes)</i></td>
+ </tr>
+ <tr>
+ <td bgcolor="<?php echo ((($size/$spaceAllowed)*100)<70)?"Green":"Red"; ?>">&nbsp;</td><td bgcolor="Black" width="<?php echo (($size/$spaceAllowed)*100); ?>%"></td>
+ </tr>
+ </table>
+ <?
+
+ if (($spaceAllowed-$size)>0) {
+ return $action;
+ } else {
+ // No space left
+ return 'not-writable';
+ }
+}
+add_filter('fileupload_init','wpmu_checkAvailableSpace');
+
+
+/**
+ * Retrieves a list of all plugins - and flags those that have been enabled
+ *
+ * @param array $args ByRef Array of plugins
+ */
+function wpmu_allBlogPlugins_get($args) {
+
+ $allPlugins = get_plugins();
+
+ $enabledPlugins = wpmu_adminOption_get('wpmu_global_blog_plugins',array());
+ $enabledPlugins = unserialize($enabledPlugins);
+ if (!is_array($enabledPlugins)) {
+ $enabledPlugins = array();
+ }
+
+ foreach ($enabledPlugins as $thisPlugin) {
+ if (isset($allPlugins[$thisPlugin])) {
+ $allPlugins[$thisPlugin]['enabled']='1';
+ }
+ }
+
+ $args[] = array(
+ 'caption'=>'Plugins Enabled',
+ 'name'=>'wpmu_global_blog_plugins',
+ 'value'=>$allPlugins,
+ 'type'=>'checkbox'
+ );
+}
+add_action('wpmu_options_admin_get','wpmu_allBlogPlugins_get');
+
+/**
+ * Sets global plugins for all blogs
+ *
+ * @param array $args The plugins to configure
+ */
+function wpmu_allBlogPlugins_set($args) {
+
+ // obtain the list of Admin Plugins to work with
+ $activePlugins = $args['wpmu_global_blog_plugins'];
+
+ // Process the array - turn it into something that is similar to the active_plugins array
+ // and work out if the plugin has an installation phase
+ $adminPlugins = array();
+ $pluginsThatNeedInstalling = array();
+ foreach ($activePlugins as $filename => $value) {
+ $adminPlugins[] = $filename;
+ // Check if the plugin has an install stage - by looking for AutoInstall in the plugin header
+ if (wpmu_checkPluginForInstallStages($filename)) {
+ $pluginsThatNeedInstalling[$filename]=true;
+ } else {
+ //
+ }
+ }
+
+ // Store the setting first in the main blog settings for wpmu
+ wpmu_adminOptionSet('wpmu_global_blog_plugins',serialize($adminPlugins));
+
+ // Now rotate through the client blogs and apply the setting
+ $allBlogs = wpmu_getBlogs();
+ foreach ($allBlogs as $thisBlog) {
+ // Exclude the 'main' blog
+ if ($allBlogs!='main') {
+ $currentClientPlugings = wpmu_blogOption_get($thisBlog,'active_plugins',array());
+
+ if (!(unserialize($currentClientPlugings)===false)) {
+ $currentClientPlugings = unserialize($currentClientPlugings);
+ }
+
+ // Deal with the case when we don't get back a serialized array
+ if (!is_array($currentClientPlugings)) {
+ $currentClientPlugings = array();
+ }
+
+ // Work through the currently setup plugins for this blog
+ foreach ($adminPlugins as $thisAdminPlugin) {
+ // If the client blog doesn't already has the plugin
+ if (!in_array($thisAdminPlugin, $currentClientPlugings)) {
+ $currentClientPlugings[] = $thisAdminPlugin;
+ if (isset($pluginsThatNeedInstalling[$thisAdminPlugin])) {
+ $clientPluginsThatNeedInstalling[] = $thisAdminPlugin;
+ } else {
+ //
+ }
+ } else {
+ //
+ }
+ }
+
+ // Store the new plugins for this blog
+ wpmu_blogOption_set($thisBlog,'active_plugins',serialize($currentClientPlugings));
+ if (count($clientPluginsThatNeedInstalling)>0) {
+ wpmu_blogOption_set($thisBlog,'wpmu_plugins_pending',serialize($clientPluginsThatNeedInstalling));
+ }
+ }
+ }
+}
+add_action('wpmu_options_admin_set','wpmu_allBlogPlugins_set');
+
+/**
+ * Determines if a plugin contains auto-install instructions
+ *
+ * @param string $plugin_file
+ * @return string|false Returns the install instructions or false
+ */
+function wpmu_checkPluginForInstallStages($plugin_file) {
+
+ if (file_exists(ABSPATH.'wp-content/plugins/'.$plugin_file)) {
+ $plugin_file = ABSPATH.'wp-content/plugins/'.$plugin_file;
+ } else {
+ die("{$plugin_file}");
+ }
+
+ $plugin_data = implode('', file($plugin_file));
+ preg_match("|AutoInstall:(.*)|i", $plugin_data, $pluginAutoInstall);
+
+ if (is_array($pluginAutoInstall)) {
+ $pluginAutoInstall = $pluginAutoInstall[0];
+ } else {
+ $pluginAutoInstall = "";
+ }
+
+ if (isset($pluginAutoInstall) && !is_null($pluginAutoInstall)) {
+ $pluginAutoInstall = str_replace('AutoInstall:','',$pluginAutoInstall);
+ $pluginAutoInstall = str_replace('<code>','',$pluginAutoInstall);
+ $pluginAutoInstall = str_replace('</code>','',$pluginAutoInstall);
+ return $pluginAutoInstall;
+ }
+ return false;
+}
+
+/**
+ * Evaluates an expression
+ *
+ * @param unknown $string
+ * @return unknown
+ */
+function wpmu_eval($string) {
+
+ $result = eval($string);
+
+ if ($result===false || is_null($result)) {
+ return false;
+ }
+ return true;
+}
+
+/**
+ * Auto installs plugins
+ *
+ */
+function wpmu_autoInstallPlugins($pendingPlugins) {
+ global $wpblog;
+
+ foreach ($pendingPlugins as $key => $filename) {
+ $installOptions = wpmu_checkPluginForInstallStages($filename);
+ if ($installOptions) {
+ // Include the file
+ require_once(ABSPATH.'wp-content/plugins/'.$filename);
+ $result = wpmu_eval($installOptions);
+ } else {
+ $result = true;
+ }
+ if ($result==true) {
+ // Everything worked ok
+ unset($pendingPlugins[$key]);
+ } else {
+ // There was a problem - should be logged
+ }
+ }
+ wpmu_blogOption_set($wpblog,'wpmu_plugins_pending',serialize($pendingPlugins));
+}
+
+/*
+ Determine if there are any plugins that need installing or configuring
+ This will enable not just the auto install/configure of plugins - but updates (to plugins or plugin data) as well
+*/
+$pendingPlugins = wpmu_blogOption_get($wpblog,'wpmu_plugins_pending', null);
+
+if (is_null($pendingPlugins)) {
+ // If null is returned - then this is a brand new blog
+ $adminPlugins = wpmu_adminOption_get('wpmu_global_blog_plugins',null);
+ if (!is_null($adminPlugins)) {
+ // We've something to do
+ wpmu_autoInstallPlugins($adminPlugins);
+ }
+} else {
+ if (count($pendingPlugins)>0) {
+ wpmu_autoInstallPlugins($pendingPlugins);
+ }
+}
+
+function createBlog( $hostname, $domain, $path, $blogname, $weblog_title, $admin_email, $username='' ) {
+ global $wpdb, $table_prefix, $wp_queries, $wpmuBaseTablePrefix;
+
+ $blogname = addslashes( $blogname );
+ $weblog_title = addslashes( $weblog_title );
+ $admin_email = addslashes( $admin_email );
+ $username = addslashes( $username );
+
+ // Check if the username has been used already. We should return an error message.
+ if( $username == '' ) {
+ $query = "SELECT ID
+ FROM ".$wpdb->users."
+ WHERE user_login = '".$blogname."'";
+ $ID = $wpdb->get_var( $query );
+ if( $ID != false ) {
+ return "error: blogname used by user";
+ }
+ } else {
+ $query = "SELECT ID
+ FROM ".$wpdb->users."
+ WHERE user_login = '".$username."'";
+ $ID = $wpdb->get_var( $query );
+ if( $ID != false ) {
+ return "error: username used";
+ }
+ }
+
+ // Need to backup wpdb table names, and create a new wp_blogs entry for new blog.
+ // Need to get blog_id from wp_blogs, and create new table names.
+ // Must restore table names at the end of function.
+
+ $wpdb->hide_errors();
+ $query = "SELECT id
+ FROM ".$wpdb->site."
+ WHERE domain = '".$domain."'
+ AND path = '".$path."'";
+ $site_id = $wpdb->get_var( $query );
+
+ if( $site_id == false ) {
+ $query = "INSERT INTO `wp_site` ( `id` , `domain` , `path` )
+ VALUES ( NULL, '".$domain."', '".$path."')";
+ $wpdb->query( $query );
+ $site_id = $wpdb->insert_id;
+ }
+
+ $query = "SELECT blog_id
+ FROM ".$wpdb->blogs."
+ WHERE site_id = '".$site_id."'
+ AND blogname = '".$blogname."'";
+ $blog_id = $wpdb->get_var( $query );
+ if( $blog_id != false ) {
+ return "error: blogname used";
+ }
+ $query = "INSERT INTO ".$wpdb->blogs." ( blog_id, site_id, blogname, registered )
+ VALUES ( NULL, '".$site_id."', '".$blogname."', NOW( ))";
+ if( $wpdb->query( $query ) == false ) {
+ return "error: problem creating blog entry";
+ }
+ $blog_id = $wpdb->insert_id;
+
+ // backup
+ $tmp[ 'siteid' ] = $wpdb->siteid;
+ $tmp[ 'blogid' ] = $wpdb->blogid;
+ $tmp[ 'posts' ] = $wpdb->posts;
+ $tmp[ 'categories' ] = $wpdb->categories;
+ $tmp[ 'post2cat' ] = $wpdb->post2cat;
+ $tmp[ 'comments' ] = $wpdb->comments;
+ $tmp[ 'links' ] = $wpdb->links;
+ $tmp[ 'linkcategories' ] = $wpdb->linkcategories;
+ $tmp[ 'option' ] = $wpdb->option;
+ $tmp[ 'postmeta' ] = $wpdb->postmeta;
+ $tmptable_prefix = $table_prefix;
+
+ // fix the new prefix.
+ $table_prefix = $wpmuBaseTablePrefix . $blog_id . "_";
+ $wpdb->siteid = $site_id;
+ $wpdb->blogid = $blog_id;
+ $wpdb->posts = $table_prefix . 'posts';
+ $wpdb->categories = $table_prefix . 'categories';
+ $wpdb->post2cat = $table_prefix . 'post2cat';
+ $wpdb->comments = $table_prefix . 'comments';
+ $wpdb->links = $table_prefix . 'links';
+ $wpdb->linkcategories = $table_prefix . 'linkcategories';
+ $wpdb->options = $table_prefix . 'options';
+ $wpdb->postmeta = $table_prefix . 'postmeta';
+
+ @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id, 0777 );
+ @mkdir( ABSPATH . "wp-content/blogs.dir/".$blog_id."/files", 0777 );
+
+ require_once( ABSPATH . 'wp-admin/upgrade-functions.php');
+ $wpdb->hide_errors();
+ $installed = $wpdb->get_results("SELECT * FROM $wpdb->posts");
+ if ($installed) die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
+ flush();
+
+ if( $path == '/' ) {
+ $slash = '';
+ } else {
+ $slash = $path;
+ }
+ if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ if( $blogname == 'main' ) {
+ $url = "http://".$hostname.$path.$slash;
+ } else {
+ $url = "http://".$blogname.".".$domain.$path.$slash;
+ }
+ } else {
+ if( $blogname == 'main' ) {
+ $url = "http://".$hostname.$path.$slash;
+ } else {
+ $url = "http://".$hostname.$path.$blogname.$slash;
+ }
+ }
+
+ // Set everything up
+ make_db_current_silent();
+ populate_options();
+
+ // fix url.
+ update_option('siteurl', $url);
+
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '".$weblog_title."' WHERE option_name = 'blogname'");
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '".$admin_email."' WHERE option_name = 'admin_email'");
+
+ // Now drop in some default links
+ $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".addslashes(__('Blogroll'))."')");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blog.carthik.net/index.php', 'Carthik', 1, 'http://blog.carthik.net/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php');");
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/');");
+
+ // Default category
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename) VALUES ('0', '".addslashes(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."')");
+
+ // Set up admin user
+ $random_password = substr(md5(uniqid(microtime())), 0, 6);
+ if( $username != '' ) {
+ $adminname = $username;
+ } else {
+ $adminname = $blogname;
+ }
+ $wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_registered, user_level, display_name) VALUES ( NULL, '".$adminname."', MD5('$random_password'), '".$admin_email."', NOW(), '10', 'Administrator' )");
+ $userID = $wpdb->insert_id;
+ $metavalues = array( "user_nickname" => addslashes(__('Administrator')), $table_prefix . "user_level" => 10, "source_domain" => $domain );
+ reset( $metavalues );
+ while( list( $key, $val ) = each ( $metavalues ) )
+ {
+ $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
+ VALUES ( NULL, '".$userID."', '".$key."' , '".$val."')";
+ $wpdb->query( $query );
+ }
+
+ // First post
+ $now = date('Y-m-d H:i:s');
+ $now_gmt = gmdate('Y-m-d H:i:s');
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('Welcome to WordPress MU. This is your first post. Edit or delete it, then start blogging!'))."', '".addslashes(__('Hello world!'))."', '0', '".addslashes(__('hello-world'))."', '$now', '$now_gmt')");
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status) VALUES ('".$userID."', '$now', '$now_gmt', '".addslashes(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '".addslashes(__('About'))."', '0', '".addslashes(__('about'))."', '$now', '$now_gmt', 'static')");
+
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (2, 2, 1)" );
+
+ // Default comment
+ $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".addslashes(__('Mr WordPress'))."', '', 'http://wordpress.org', '127.0.0.1', '$now', '$now_gmt', '".addslashes(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')");
+
+ $message_headers = 'From: ' . stripslashes($weblog_title) . ' <wordpress@' . $_SERVER[ 'SERVER_NAME' ] . '>';
+ $message = __("Dear User,\n\nYour new WordPressMU blog has been successfully set up at:\n".$url."\n\nYou can log in to the administrator account with the following information:\n Username: ".$adminname."\n Password: ".$random_password."\nLogin Here: ".$url."wp-login.php\n\nWe hope you enjoy your new weblog.\n Thanks!\n\n--The WordPressMU Team\nhttp://mu.wordpress.org/\n");
+ @mail($admin_email, __('New WordPress MU Blog').": ".stripslashes( $weblog_title ), $message, $message_headers);
+
+ upgrade_all();
+ // remove all perms except for the login user.
+ $query = "DELETE FROM ".$wpdb->usermeta."
+ WHERE user_id != '".$userID."'
+ AND meta_key = '".$table_prefix."user_level'";
+ $wpdb->query( $query );
+
+ // insert admin user into user table.
+ $adminusers = get_admin_users_for_domain();
+ if( is_array( $adminusers ) ) {
+ reset( $adminusers );
+ while( list( $key, $val ) = each( $adminusers ) ) {
+ $query = "INSERT INTO ".$wpdb->usermeta." ( `umeta_id` , `user_id` , `meta_key` , `meta_value` )
+ VALUES ( NULL, '".$val[ 'ID' ]."', '".$table_prefix."user_level' , '10')";
+ $wpdb->query( $query );
+ }
+ } else {
+ die( "Problem getting admin users!" );
+ }
+
+ // restore wpdb variables
+ reset( $tmp );
+ while( list( $key, $val ) = each( $tmp ) )
+ {
+ $wpdb->$key = $val;
+ }
+ $table_prefix = $tmptable_prefix;
+
+ $wpdb->show_errors();
+
+ return "ok";
+}
+
+function get_blogaddress_by_id( $blog_id ) {
+ global $hostname, $domain, $base, $wpdb;
+
+ // not current blog
+ $query = "SELECT *
+ FROM ".$wpdb->blogs."
+ WHERE blog_id = '".$blog_id."'";
+ $bloginfo = $wpdb->get_results( $query, ARRAY_A );
+ if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ return "http://".$bloginfo[ 'blogname' ].".".$domain.$base;
+ } else {
+ return "http://".$hostname.$base.$bloginfo[ 'blogname' ];
+ }
+}
+
+function get_blogaddress_by_name( $blogname ) {
+ global $domain, $base, $wpdb;
+
+ if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) {
+ if( $blogname == 'main' )
+ $blogname = 'www';
+ return "http://".$blogname.".".$domain.$base;
+ } else {
+ return "http://".$hostname.$base.$blogname;
+ }
+}
+
+function get_sitestats() {
+ global $wpdb, $basedomain, $base;
+
+ $query = "SELECT count(*) as c
+ FROM ".$wpdb->blogs."
+ WHERE site_id = '".$wpdb->siteid."'";
+ $blogs = $wpdb->get_var( $query );
+ $stats[ 'blogs' ] = $blogs;
+
+ $query = "SELECT count(*) as c
+ FROM ".$wpdb->users;
+ $users = $wpdb->get_var( $query );
+ $stats[ 'users' ] = $users;
+
+ return $stats;
+
+}
+function get_admin_users_for_domain( $sitedomain = '', $path = '' ) {
+ global $domain, $base, $basedomain, $wpdb, $wpmuBaseTablePrefix;
+ if( $sitedomain == '' ) {
+ $sitedomain = $basedomain;
+ $site_id = $wpdb->siteid;
+ } else {
+ $query = "SELECT id
+ FROM ".$wpdb->site."
+ WHERE domain = '".$domain."'
+ AND path = '".$base."'";
+ $site_id = $wpdb->get_var( $query );
+ }
+ if( $site_id != false ) {
+ $query = "SELECT ID, user_login, user_pass
+ FROM ".$wpdb->users.", ".$wpdb->sitemeta."
+ WHERE meta_key = 'admin_user_id'
+ AND ".$wpdb->users.".ID = ".$wpdb->sitemeta.".meta_value
+ AND site_id = '".$site_id."'";
+ $details = $wpdb->get_results( $query, ARRAY_A );
+ } else {
+ $details = false;
+ }
+
+ return $details;
+}
+
+function get_site_settings( $option ) {
+ global $wpdb;
+
+ $query = "SELECT meta_value
+ FROM $wpdb->sitemeta
+ WHERE meta_key = '$option'
+ AND site_id = '".$wpdb->siteid."'";
+ $option = $wpdb->get_var( $query );
+ @ $kellogs = unserialize($option);
+ if ($kellogs !== FALSE)
+ $option = $kellogs;
+
+ return $option;
+}
+
+function add_site_settings( $key, $value ) {
+ global $wpdb;
+ if( $value != get_site_settings( $key ) ) {
+ if ( is_array($value) || is_object($value) )
+ $value = serialize($value);
+ $query = "SELECT meta_value
+ FROM ".$wpdb->sitemeta."
+ WHERE meta_key = '$key'
+ AND site_id = '".$wpdb->siteid."'";
+ if( $wpdb->get_var( $query ) == false ) {
+ $query = "INSERT INTO wp_sitemeta ( meta_id , site_id , meta_key , meta_value )
+ VALUES ( NULL, '".$wpdb->siteid."', '".$key."', '".$wpdb->escape( $value )."')";
+ $wpdb->query( $query );
+ }
+ }
+}
+
+function update_site_settings( $key, $value ) {
+ global $wpdb;
+ if( $value != get_site_settings( $key ) ) {
+ if ( is_array($value) || is_object($value) )
+ $value = serialize($value);
+
+ $value = trim($value); // I can't think of any situation we wouldn't want to trim
+ $query = "SELECT meta_value
+ FROM ".$wpdb->sitemeta."
+ WHERE meta_key = '$key'
+ AND site_id = '".$wpdb->siteid."'";
+ if( $wpdb->get_var( $query ) == false ) {
+ add_site_settings( $key, $value );
+ } else {
+ $query = "UPDATE ".$wpdb->sitemeta."
+ SET meta_value = '".$wpdb->escape( $value )."'
+ WHERE meta_key = '".$key."'";
+ $wpdb->query( $query );
+ }
+ }
+}
+
+function switch_to_blogid( $blog_id ) {
+ global $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $cache_settings;
+
+ // FIXME
+
+ // backup
+ $tmpoldblogdetails[ 'blogid' ] = $wpdb->blogid;
+ $tmpoldblogdetails[ 'posts' ] = $wpdb->posts;
+ $tmpoldblogdetails[ 'categories' ] = $wpdb->categories;
+ $tmpoldblogdetails[ 'post2cat' ] = $wpdb->post2cat;
+ $tmpoldblogdetails[ 'comments' ] = $wpdb->comments;
+ $tmpoldblogdetails[ 'links' ] = $wpdb->links;
+ $tmpoldblogdetails[ 'linkcategories' ] = $wpdb->linkcategories;
+ $tmpoldblogdetails[ 'option' ] = $wpdb->option;
+ $tmpoldblogdetails[ 'postmeta' ] = $wpdb->postmeta;
+ $tmpoldblogdetails[ 'prefix' ] = $wpdb->prefix;
+
+ // fix the new prefix.
+ $table_prefix = $wpmuBaseTablePrefix . $blog_id . "_";
+ $wpdb->blogid = $blog_id;
+ $wpdb->posts = $table_prefix . 'posts';
+ $wpdb->categories = $table_prefix . 'categories';
+ $wpdb->post2cat = $table_prefix . 'post2cat';
+ $wpdb->comments = $table_prefix . 'comments';
+ $wpdb->links = $table_prefix . 'links';
+ $wpdb->linkcategories = $table_prefix . 'linkcategories';
+ $wpdb->options = $table_prefix . 'options';
+ $wpdb->postmeta = $table_prefix . 'postmeta';
+
+ unset( $cache_settings );
+}
+
+function restore_current_blogid() {
+ global $tmpoldblogdetails, $wpdb;
+ // backup
+ $wpdb->blogid = $tmpoldblogdetails[ 'blogid' ];
+ $wpdb->posts = $tmpoldblogdetails[ 'posts' ];
+ $wpdb->categories = $tmpoldblogdetails[ 'categories' ];
+ $wpdb->post2cat = $tmpoldblogdetails[ 'post2cat' ];
+ $wpdb->comments = $tmpoldblogdetails[ 'comments' ];
+ $wpdb->links = $tmpoldblogdetails[ 'links' ];
+ $wpdb->linkcategories = $tmpoldblogdetails[ 'linkcategories' ];
+ $wpdb->option = $tmpoldblogdetails[ 'option' ];
+ $wpdb->postmeta = $tmpoldblogdetails[ 'postmeta' ];
+ $wpdb->prefix = $tmpoldblogdetails[ 'prefix' ];
+}
+?>