Compare commits

..

1 Commits
1.5.2 ... 1.5

Author SHA1 Message Date
ryan
9e03957cca Tagging WordPress 1.5 Stryhorn
git-svn-id: http://svn.automattic.com/wordpress/tags/1.5@2541 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2005-04-18 21:22:37 +00:00
95 changed files with 2123 additions and 3191 deletions

View File

@@ -1,10 +1,10 @@
<div id="footer"><p><a href="http://wordpress.org/"><img src="../wp-images/wp-small.png" alt="WordPress" /></a><br />
<?php bloginfo('version'); ?> <br />
<a href="http://codex.wordpress.org/"><?php _e('Documentation'); ?></a> &#8212; <a href="http://wordpress.org/support/"><?php _e('Support Forums'); ?></a> <br />
<?php bloginfo('version'); ?> &#8212; <a href="http://wordpress.org/support/"><?php _e('Support Forums'); ?></a><br />
<?php printf(__('%s seconds'), number_format(timer_stop(), 2)); ?>
</p>
<p><a href="http://spreadfirefox.com/community/?q=affiliates&amp;id=2490&amp;t=1" title="<?php _e('WordPress recommends the open-source Firefox browser') ?>"><img src="http://static.wordpress.org/get-firefox.png" alt="Get Firefox" /></a></p>
</div>
<?php do_action('admin_footer', ''); ?>

View File

@@ -409,9 +409,10 @@ function update_meta($mid, $mkey, $mvalue) {
return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");
}
function touch_time($edit = 1, $for_post = 1) {
global $month, $postdata, $commentdata;
if ( $for_post && ('draft' == $postdata->post_status) ) {
function touch_time($edit = 1) {
global $month, $postdata;
// echo $postdata['Date'];
if ('draft' == $postdata->post_status) {
$checked = 'checked="checked" ';
$edit = false;
} else {
@@ -421,7 +422,7 @@ function touch_time($edit = 1, $for_post = 1) {
echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" '.$checked.'/> <label for="timestamp">' . __('Edit timestamp') . '</label></legend>';
$time_adj = time() + (get_settings('gmt_offset') * 3600);
$post_date = ($for_post) ? $postdata->post_date : $commentdata['comment_date'];
$post_date = $postdata->post_date;
$jj = ($edit) ? mysql2date('d', $post_date) : gmdate('d', $time_adj);
$mm = ($edit) ? mysql2date('m', $post_date) : gmdate('m', $time_adj);
$aa = ($edit) ? mysql2date('Y', $post_date) : gmdate('Y', $time_adj);
@@ -448,29 +449,16 @@ function touch_time($edit = 1, $for_post = 1) {
<input type="text" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" /> @
<input type="text" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" /> :
<input type="text" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" />
<input type="hidden" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
<?php _e('Existing timestamp'); ?>:
<?php
// We might need to readjust to display proper existing timestamp
if ( $for_post && ('draft' == $postdata->post_status) ) {
$jj = mysql2date('d', $post_date);
$mm = mysql2date('m', $post_date);
$aa = mysql2date('Y', $post_date);
$hh = mysql2date('H', $post_date);
$mn = mysql2date('i', $post_date);
$ss = mysql2date('s', $post_date);
}
echo "{$month[$mm]} $jj, $aa @ $hh:$mn"; ?>
</fieldset>
<input type="hidden" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" /> <?php _e('Existing timestamp'); ?>: <?php echo "{$month[$mm]} $jj, $aa @ $hh:$mn"; ?></fieldset>
<?php
}
function check_admin_referer() {
$adminurl = strtolower( get_settings('siteurl') ) . '/wp-admin';
$referer = strtolower( $_SERVER['HTTP_REFERER'] );
if ( !strstr($referer, $adminurl) )
die(__('Sorry, you need to <a href="http://codex.wordpress.org/Enable_Sending_Referrers">enable sending referrers</a> for this feature to work.'));
do_action('check_admin_referer');
$adminurl = strtolower(get_settings('siteurl')).'/wp-admin';
$referer = strtolower($_SERVER['HTTP_REFERER']);
if ( !strstr($referer, $adminurl) ) {
die('Sorry, you need to enable sending referrers, for this feature to work.');
}
}
// insert_with_markers: Owen Winkler
@@ -626,18 +614,16 @@ function get_page_templates() {
$templates = $themes[$theme]['Template Files'];
$page_templates = array();
if( is_array( $templates ) ) {
foreach ($templates as $template) {
$template_data = implode('', file(ABSPATH . $template));
preg_match("|Template Name:(.*)|i", $template_data, $name);
preg_match("|Description:(.*)|i", $template_data, $description);
foreach ($templates as $template) {
$template_data = implode('', file(ABSPATH . $template));
preg_match("|Template Name:(.*)|i", $template_data, $name);
preg_match("|Description:(.*)|i", $template_data, $description);
$name = $name[1];
$description = $description[1];
$name = $name[1];
$description = $description[1];
if (! empty($name)) {
$page_templates[trim($name)] = basename($template);
}
if (! empty($name)) {
$page_templates[trim($name)] = basename($template);
}
}
@@ -758,7 +744,6 @@ function get_admin_page_title() {
function get_admin_page_parent() {
global $parent_file;
global $menu;
global $submenu;
global $pagenow;
global $plugin_page;
@@ -767,15 +752,6 @@ function get_admin_page_parent() {
return $parent_file;
}
if ($pagenow == 'admin.php' && isset($plugin_page)) {
foreach ($menu as $parent_menu) {
if ($parent_menu[2] == $plugin_page) {
$parent_file = $plugin_page;
return $plugin_page;
}
}
}
foreach (array_keys($submenu) as $parent) {
foreach ($submenu[$parent] as $submenu_array) {
if ($submenu_array[2] == $pagenow) {
@@ -793,10 +769,10 @@ function get_admin_page_parent() {
}
function plugin_basename($file) {
return preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file);
return preg_replace('#^.*wp-content/plugins/#', '', $file);
}
function add_menu_page($page_title, $menu_title, $access_level, $file, $function = '') {
function add_menu_page($page_title, $menu_title, $access_level, $file) {
global $menu, $admin_page_hooks;
$file = plugin_basename($file);
@@ -804,12 +780,6 @@ function add_menu_page($page_title, $menu_title, $access_level, $file, $function
$menu[] = array($menu_title, $access_level, $file, $page_title);
$admin_page_hooks[$file] = sanitize_title($menu_title);
$hookname = get_plugin_page_hookname($file, '');
if ( !empty($function) && !empty($hookname) )
add_action($hookname, $function);
return $hookname;
}
function add_submenu_page($parent, $page_title, $menu_title, $access_level, $file, $function = '') {
@@ -976,13 +946,13 @@ function get_plugin_data($plugin_file) {
$name = trim($name);
$plugin = $name;
if ('' != $plugin_uri[1] && '' != $name) {
$plugin = '<a href="' . $plugin_uri[1] . '" title="' . __('Visit plugin homepage') . '">' . $plugin . '</a>';
$plugin = __("<a href='{$plugin_uri[1]}' title='Visit plugin homepage'>{$plugin}</a>");
}
if ('' == $author_uri[1]) {
$author = $author_name[1];
} else {
$author = '<a href="' . $author_uri[1] . '" title="' . __('Visit author homepage') . '">' . $author_name[1] . '</a>';
$author = __("<a href='{$author_uri[1]}' title='Visit author homepage'>{$author_name[1]}</a>");
}
return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1]);
@@ -1044,18 +1014,10 @@ function get_plugins() {
function get_plugin_page_hookname($plugin_page, $parent_page) {
global $admin_page_hooks;
$parent = get_admin_page_parent();
if ( empty($parent_page) || 'admin.php' == $parent_page ) {
if ( isset($admin_page_hooks[$plugin_page]) )
$page_type = 'toplevel';
else if ( isset($admin_page_hooks[$parent]) )
$page_type = $admin_page_hooks[$parent];
} else if ( isset($admin_page_hooks[$parent_page]) ) {
if ( isset($admin_page_hooks[$parent_page]) )
$page_type = $admin_page_hooks[$parent_page];
} else {
else
$page_type = 'admin';
}
$plugin_name = preg_replace('!\.php!', '', $plugin_page);
@@ -1064,22 +1026,13 @@ function get_plugin_page_hookname($plugin_page, $parent_page) {
function get_plugin_page_hook($plugin_page, $parent_page) {
global $wp_filter;
$hook = get_plugin_page_hookname($plugin_page, $parent_page);
if ( isset($wp_filter[$hook]) )
return $hook;
else
return '';
}
function pimp_firefox() {
if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'Firefox' ) )
return;
$getit = __('WordPress recommends the open-source Firefox browser');
echo '
<p id="firefoxlink" style="text-align: center;"><a href="http://spreadfirefox.com/community/?q=affiliates&amp;id=2490&amp;t=1" title="' . $getit . '"><img src="../wp-images/get-firefox.png" alt="Get Firefox" /></a></p>
';
}
add_action('admin_footer', 'pimp_firefox');
?>
?>

View File

@@ -6,7 +6,7 @@ if (!isset($_GET["page"])) require_once('admin.php'); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
<link rel="stylesheet" href="<?php echo get_settings('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo get_settings('siteurl') ?>/wp-admin/wp-admin.css" type="text/css" />
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
<script type="text/javascript">

View File

@@ -1,18 +1,17 @@
<?php
if ( defined('ABSPATH') )
require_once( ABSPATH . 'wp-config.php');
else
require_once('../wp-config.php');
require_once('../wp-config.php');
require_once(ABSPATH . 'wp-admin/admin-functions.php');
auth_redirect();
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
header('Expires: Mon, 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');
update_category_cache();
$dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories");
foreach ($dogs as $catt) {
$cache_categories[$catt->cat_ID] = $catt;
}
get_currentuserinfo();

View File

@@ -34,7 +34,6 @@ case 'addcat':
$cat = intval($_POST['cat']);
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')");
do_action('add_category', $wpdb->insert_id);
header('Location: categories.php?message=1#addcat');
break;
@@ -58,7 +57,6 @@ case 'delete':
$wpdb->query("UPDATE $wpdb->categories SET category_parent = '$cat_parent' WHERE category_parent = '$cat_ID'");
// TODO: Only set categories to general if they're not in another category already
$wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'");
do_action('delete_category', $cat_ID);
header('Location: categories.php?message=2');
@@ -156,7 +154,9 @@ cat_rows();
<?php if ( $user_level > 3 ) : ?>
<div class="wrap">
<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete posts from that category, it will just set them back to the default category <strong>%s</strong>.'), get_catname(1)) ?>
<p><?php printf(__('<strong>Note:</strong><br />
Deleting a category does not delete posts from that category, it will just
set them back to the default category <strong>%s</strong>.'), get_catname(1)) ?>
</p>
</div>
@@ -183,4 +183,4 @@ break;
}
include('admin-footer.php');
?>
?>

View File

@@ -20,7 +20,7 @@ if (0 == $post_ID) {
$form_extra = "<input type='hidden' name='post_ID' value='$post_ID' />";
}
$form_pingback = '<input type="hidden" name="post_pingback" value="' . get_option('default_pingback_flag') . '" id="post_pingback" />';
$form_pingback = '<input type="hidden" name="post_pingback" value="1" id="post_pingback" />';
$form_prevstatus = '<input type="hidden" name="prev_status" value="'.$post_status.'" />';
@@ -115,7 +115,7 @@ edCanvas = document.getElementById('content');
<?php
if ('publish' != $post_status || 0 == $post_ID) {
?>
<?php if ( user_can_create_post($user_ID) ) : ?>
<?php if ( 1 < $user_level || (1 == $user_level && 2 == get_option('new_users_can_blog')) ) : ?>
<input name="publish" type="submit" id="publish" tabindex="10" value="<?php _e('Publish') ?>" />
<?php endif; ?>
<?php
@@ -135,7 +135,7 @@ if ('publish' != $post_status || 0 == $post_ID) {
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr>
<th scope="row" valign="top"><?php _e('Post Status') ?>:</th>
<td><?php if ( user_can_create_post($user_ID) ) : ?>
<td><?php if ( 1 < $user_level || (1 == $user_level && 2 == get_option('new_users_can_blog')) ) : ?>
<label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post_status, 'publish'); ?> /> <?php _e('Published') ?></label><br />
<?php endif; ?>
<label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post_status, 'draft'); ?> /> <?php _e('Draft') ?></label><br />
@@ -157,7 +157,7 @@ if ('publish' != $post_status || 0 == $post_ID) {
<select name="post_author_override" id="post_author_override">
<?php
foreach ($users as $o) :
if ( $post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
if ( $post_author == $o->ID ) $selected = 'selected="selected"';
else $selected = '';
echo "<option value='$o->ID' $selected>$o->user_login ($o->user_firstname $o->user_lastname)</option>";
endforeach;
@@ -172,13 +172,11 @@ if ('publish' != $post_status || 0 == $post_ID) {
<td><?php touch_time(($action == 'edit')); ?></td>
</tr>
<?php endif; ?>
<?php if ('edit' == $action) : ?>
<tr>
<th scope="row"><?php _e('Delete'); ?>:</th>
<td>
<td><?php if ('edit' == $action) : ?>
<input name="deletepost" class="button" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this post') ?>" <?php echo "onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), addslashes($edited_post_title) ) . "')\""; ?> />
</td>
<?php endif; ?>
<?php endif; ?></td>
</tr>
</table>

View File

@@ -54,7 +54,7 @@ edCanvas = document.getElementById('content');
//-->
</script>
<p class="submit"><input type="submit" name="editcomment" id="editcomment" value="<?php echo $submitbutton_text ?>" style="font-weight: bold;" tabindex="6" />
<p class="submit"><input type="submit" name="submit" value="<?php echo $submitbutton_text ?>" style="font-weight: bold;" tabindex="6" />
<input name="referredby" type="hidden" id="referredby" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" />
</p>
@@ -74,7 +74,7 @@ edCanvas = document.getElementById('content');
<?php if ($user_level > 4) : ?>
<tr>
<th scope="row"><?php _e('Edit time'); ?>:</th>
<td><?php touch_time(('editcomment' == $action), 0); ?></td>
<td><?php touch_time(($action == 'edit')); ?></td>
</tr>
<?php endif; ?>

View File

@@ -50,7 +50,7 @@ edCanvas = document.getElementById('content');
//-->
</script>
<input type="hidden" name="post_pingback" value="<?php echo get_option('default_pingback_flag') ?>" id="post_pingback" />
<input type="hidden" name="post_pingback" value="1" id="post_pingback" />
<p><label for="trackback"> <?php printf(__('<a href="%s" title="Help on trackbacks"><strong>TrackBack</strong> a <abbr title="Universal Resource Identifier">URI</abbr></a>:</label> (Separate multiple <abbr title="Universal Resource Identifier">URI</abbr>s with spaces.)<br />'), 'http://wordpress.org/docs/reference/post/#trackback') ?>
<input type="text" name="trackback_url" style="width: 360px" id="trackback" tabindex="7" /></p>
@@ -58,7 +58,7 @@ edCanvas = document.getElementById('content');
<p class="submit"><input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="<?php _e('Save as Draft') ?>" />
<input name="saveasprivate" type="submit" id="saveasprivate" tabindex="10" value="<?php _e('Save as Private') ?>" />
<?php if ( user_can_create_post($user_ID) ) : ?>
<?php if ( 1 < $user_level || (1 == $user_level && 2 == get_option('new_users_can_blog')) ) : ?>
<input name="publish" type="submit" id="publish" tabindex="6" style="font-weight: bold;" value="<?php _e('Publish') ?>" />
<?php endif; ?>

View File

@@ -12,8 +12,8 @@ if (0 == $post_ID) {
$sendto = $_SERVER['HTTP_REFERER'];
if ( 0 != $post_ID && $sendto == get_permalink($post_ID) )
$sendto = 'redo';
if ( $sendto == get_permalink($post) )
$sendto = 'redo';
$sendto = wp_specialchars( $sendto );
?>
@@ -85,17 +85,12 @@ edCanvas = document.getElementById('content');
</script>
<p class="submit">
<?php if ( $post_ID ) : ?>
<input name="save" type="submit" id="save" tabindex="5" value=" <?php _e('Save and Continue Editing'); ?> "/>
<input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php $post_ID ? _e('Edit Page') : _e('Create New Page') ?> &raquo;" />
<?php else : ?>
<input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php _e('Create New Page') ?> &raquo;" />
<?php endif; ?>
<input name="referredby" type="hidden" id="referredby" value="<?php echo $sendto; ?>" />
<input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php $post_ID ? _e('Edit Page') :_e('Create New Page') ?> &raquo;" />
<input name="referredby" type="hidden" id="referredby" value="<?php echo $sendto; ?>" />
</p>
<fieldset id="pageoptions">
<legend><?php _e('Page Options') ?></legend>
<legend><?php _e('Page Options') ?></legend>
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<?php if ( 0 != count( get_page_templates() ) ) { ?>
<tr valign="top">

View File

@@ -66,21 +66,12 @@ if ($drafts || $other_drafts) {
<div class="wrap">
<h2>
<?php
$what_to_show = 'posts';
$posts_per_page = 15;
$posts_per_archive_page = -1;
include(ABSPATH.'wp-blog-header.php');
if ( is_month() ) {
single_month_title(' ');
} elseif ( is_search() ) {
if ( $_GET['m'] ) {
echo $month[substr( $_GET['m'], 4, 2 )] . ' ' . substr( $_GET['m'], 0, 4 );
} elseif ( isset( $_GET['s'] ) ) {
printf(__('Search for &#8220;%s&#8221;'), wp_specialchars($_GET['s']) );
} else {
if ( ! is_paged() || get_query_var('paged') == 1 )
_e('Last 15 Posts');
else
_e('Previous Posts');
_e('Last 15 Posts');
}
?>
</h2>
@@ -88,7 +79,7 @@ if ( is_month() ) {
<form name="searchform" action="" method="get" style="float: left; width: 16em; margin-right: 3em;">
<fieldset>
<legend><?php _e('Search Posts&hellip;') ?></legend>
<input type="text" name="s" value="<?php if (isset($s)) echo wp_specialchars($s, 1); ?>" size="17" />
<input type="text" name="s" value="<?php if (isset($s)) echo $s; ?>" size="17" />
<input type="submit" name="submit" value="<?php _e('Search') ?>" />
</fieldset>
</form>
@@ -149,6 +140,15 @@ $posts_columns['control_delete'] = '';
</tr>
<?php
$what_to_show = 'posts';
if ( empty($_GET['m']) || 0 == $_GET['m'] && empty($_GET['s']) ) {
$showposts = 15;
} else {
$nopaging = true;
}
include(ABSPATH.'wp-blog-header.php');
if ($posts) {
$bgcolor = '';
foreach ($posts as $post) { start_wp();
@@ -208,13 +208,13 @@ foreach($posts_columns as $column_name=>$column_display_name) {
case 'control_edit':
?>
<td><?php if ( user_can_edit_post($user_ID,$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<td><?php if ( user_can_edit_user($user_ID,$authordata->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<?php
break;
case 'control_delete':
?>
<td><?php if ( user_can_edit_post($user_ID,$post->ID) ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "')\">" . __('Delete') . "</a>"; } ?></td>
<td><?php if ( user_can_edit_user($user_ID,$authordata->ID) ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "')\">" . __('Delete') . "</a>"; } ?></td>
<?php
break;
@@ -238,12 +238,6 @@ foreach($posts_columns as $column_name=>$column_display_name) {
} // end if ($posts)
?>
</table>
<div class="navigation">
<div class="alignleft"><?php next_posts_link(__('&laquo; Previous Entries')) ?></div>
<div class="alignright"><?php previous_posts_link(__('Next Entries &raquo;')) ?></div>
</div>
<?php
if ( 1 == count($posts) ) {

View File

@@ -4,7 +4,6 @@ require_once('../wp-config.php');
require('upgrade-functions.php');
$step = $_GET['step'];
if (!$step) $step = 0;
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

View File

@@ -15,9 +15,8 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
}
}
require_once('../wp-config.php');
require('upgrade-functions.php');
header( 'Content-Type: text/html; charset=utf-8' );
require_once('../wp-config.php');
require('upgrade-functions.php');
switch ($action) {
case "step1":
@@ -86,7 +85,7 @@ case "step1":
user_ip,
user_domain,
user_browser,
user_registered,
dateYMDhour,
user_level,
user_idmode
) VALUES (

View File

@@ -1,5 +1,4 @@
<?php
if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. You must install WordPress before you import any entries.");
require_once('../wp-config.php');
require('upgrade-functions.php');
@@ -20,63 +19,47 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
}
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>WordPress &rsaquo; Import from GreyMatter</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style media="screen" type="text/css">
body {
font-family: Georgia, "Times New Roman", Times, serif;
margin-left: 20%;
margin-right: 20%;
}
#logo {
margin: 0;
padding: 0;
background-image: url(http://wordpress.org/images/logo.png);
background-repeat: no-repeat;
height: 60px;
border-bottom: 4px solid #333;
}
#logo a {
display: block;
text-decoration: none;
text-indent: -100em;
height: 60px;
}
p {
line-height: 140%;
}
#authors li {
padding:3px;
border: 1px solid #ccc;
width: 40%;
margin-bottom:2px;
}
</style>
</head><body>
<h1 id="logo"><a href="http://wordpress.org">WordPress</a></h1>
<?php
switch ($action) {
case "step1":
function gm2autobr($string) { // transforms GM's |*| into wp's <br />\n
function gm2autobr($string) { // transforms GM's |*| into b2's <br />\n
$string = str_replace("|*|","<br />\n",$string);
return($string);
}
if (!@chdir($archivespath))
if (!chdir($archivespath))
die("Wrong path, $archivespath\ndoesn't exist\non the server");
if (!@chdir($gmpath))
if (!chdir($gmpath))
die("Wrong path, $gmpath\ndoesn't exist\non the server");
?>
<html>
<head>
<title>GM 2 b2 - converting...</title>
<link rel="stylesheet" href="wp-admin/b2.css" type="text/css">
<style type="text/css">
<!--
<?php
if (!preg_match("/Nav/",$HTTP_USER_AGENT)) {
?>
textarea,input,select {
background-color: #f0f0f0;
border-width: 1px;
border-color: #cccccc;
border-style: solid;
padding: 2px;
margin: 1px;
}
<?php
}
?>
-->
</style>
</head>
<body style="margin: 20px;">
<p><font face="times new roman" style="font-size: 39px;">gm 2 <img src="../wp-images/wpminilogo.png" width="50" height="50" border="0" alt="WP" align="top" /></font></p>
<p>The importer is running...</p>
<ul>
<li>importing users... <ul><?php
@@ -84,6 +67,9 @@ case "step1":
chdir($gmpath);
$userbase = file("gm-authors.cgi");
$connexion = mysql_connect($server,$loginsql,$passsql) or die ("Oops, MySQL connection error ! Couldn't connect to $server with the username $loginsql");
$bdd = mysql_select_db(DB_NAME,$connexion) or die ("Oops, can't find any database named DB_NAME here !");
foreach($userbase as $user) {
$userdata=explode("|", $user);
@@ -107,8 +93,8 @@ case "step1":
continue;
}
$query = "INSERT INTO $wpdb->users (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,user_registered,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','1','nickname')";
$result = $wpdb->query($query);
$query = "INSERT INTO $wpdb->users (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','1','nickname')";
$result = mysql_query($query);
if ($result==false) {
die ("<strong>ERROR</strong>: couldn't register an user!");
}
@@ -154,8 +140,8 @@ case "step1":
$post_author=trim(addslashes($postinfo[1]));
// we'll check the author is registered, or if it's a deleted author
$sql = "SELECT * FROM $wpdb->users WHERE user_login = '$post_author'";
$result = $wpdb->query($sql);
if (! $result) { // if deleted from GM, we register the author as a level 0 user in wp
$result = mysql_query($sql);
if (!mysql_num_rows($result)) { // if deleted from GM, we register the author as a level 0 user in b2
$user_ip="127.0.0.1";
$user_domain="localhost";
$user_browser="server";
@@ -166,16 +152,18 @@ case "step1":
$user_email=addslashes("user@deleted.com");
$user_url=addslashes("");
$user_joindate=addslashes($user_joindate);
$query = "INSERT INTO $wpdb->users (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,user_registered,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','0','nickname')";
$result = $wpdb->query($query);
$query = "INSERT INTO $wpdb->users (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','0','nickname')";
$result = mysql_query($query);
if ($result==false) {
die ("<strong>ERROR</strong>: couldn't register an user!");
}
echo ": registered deleted user <i>$user_login</i> at level 0 ";
}
$sql = "SELECT ID FROM $wpdb->users WHERE user_login = '$post_author'";
$post_author_ID = $wpdb->get_var($sql);
$sql = "SELECT * FROM $wpdb->users WHERE user_login = '$post_author'";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$post_author_ID=$myrow[0];
$post_title=gm2autobr($postinfo[2]);
$post_title=addslashes($post_title);
@@ -200,13 +188,15 @@ case "step1":
$post_karma=$postinfo[12];
$query = "INSERT INTO $wpdb->posts (post_author,post_date,post_content,post_title) VALUES ('$post_author_ID','$post_date','$post_content','$post_title')";
$result = $wpdb->query($query);
$result = mysql_query($query) or die(mysql_error());
if (!$result)
die ("Error in posting...");
$query = "SELECT ID FROM $wpdb->posts ORDER BY ID DESC LIMIT 1";
$post_ID = $wpdb->get_var($query);
$sql2 = "SELECT * FROM $wpdb->posts ORDER BY ID DESC LIMIT 1";
$result2 = mysql_query($sql2);
$myrow2 = mysql_fetch_array($result2);
$post_ID=$myrow2[0];
// Grab a default category.
$post_category = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories LIMIT 1");
@@ -247,7 +237,7 @@ case "step1":
$comment_content=addslashes($commentinfo[12]);
$sql3 = "INSERT INTO $wpdb->comments (comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_author_IP,comment_date,comment_content) VALUES ('$comment_post_ID','$comment_author','$comment_author_email','$comment_author_url','$comment_author_IP','$comment_date','$comment_content')";
$result3 = $wpdb->query($sql3);
$result3 = mysql_query($sql3);
if (!$result3)
die ("There is an error with the database, it can't store your comment..");
}
@@ -263,19 +253,48 @@ case "step1":
?>
</ul><b>Done</b></li></ul>
<p>&nbsp;</p>
<p>Completed GM 2 WordPress import !</p>
<p>Completed GM 2 b2 import !</p>
<p>Now you can go and <a href="wp-login.php">log in</a>, have fun !</p>
<?php
break;
default:
?>
default:
?><html>
<head>
<title>GM 2 b2 importer utility</title>
<link rel="stylesheet" href="wp-admin/b2.css" type="text/css">
<style type="text/css">
<!--
<?php
if (!preg_match("/Nav/",$HTTP_USER_AGENT)) {
?>
textarea,input,select {
background-color: #f0f0f0;
border-width: 1px;
border-color: #cccccc;
border-style: solid;
padding: 2px;
margin: 1px;
}
<?php
}
?>
-->
</style>
</head>
<body style="margin: 20px;">
<p><font face="times new roman" style="font-size: 39px;">gm 2 <img src="../wp-images/wpminilogo.png" width="50" height="50" border="0" alt="WP" align="top" /></font></p>
<p>This is a basic GreyMatter to WordPress import script.</p>
<p>What it does:</p>
<ul>
<li>parses gm-authors.cgi to import authors: everyone is imported at level 1</li>
<li>parses the entries cgi files to import posts, comments, and karma on posts (although karma is not used on WordPress); if authors are found not to be in gm-authors.cgi, imports them at level 0</li>
<li>parses the entries cgi files to import posts, comments, and karma on posts (although karma is not used on WordPress yet)<br />if authors are found not to be in gm-authors.cgi, imports them at level 0</li>
</ul>
<p>What it does not:</p>
<ul>
@@ -283,14 +302,15 @@ default:
<li>import gm-templates. you'll start with the basic template wp.php</li>
<li>doesn't keep entries on top</li>
</ul>
<p>&nbsp;</p>
<h3>First step: Install WordPress</h3>
<h3>First step: install WordPress</h3>
<p>Install the WordPress blog as explained in the <a href="../readme.html" target="_blank">ReadMe</a>, then immediately come back here.</p>
<form name="stepOne" method="get">
<input type="hidden" name="action" value="step1" />
<h3>Second step: Provide GreyMatter details</h3>
<table cellpadding="0">
<h3>Second step: GreyMatter details:</h3>
<p><table cellpadding="0">
<tr>
<td>Path to GM files:</td>
<td><input type="text" style="width:300px" name="gmpath" value="/home/my/site/cgi-bin/greymatter/" /></td>
@@ -299,17 +319,15 @@ default:
<td>Path to GM entries:</td>
<td><input type="text" style="width:300px" name="archivespath" value="/home/my/site/cgi-bin/greymatter/archives/" /></td>
</tr>
</table>
<p>This importer will search for files 00000001.cgi to 000-whatever.cgi, so you need to enter the number of the last GM post here. (If you don't know that number, just log into your FTP and look it up in the entries' folder)</p>
<table>
<tr>
<td colspan="2"><br />This importer will search for files 00000001.cgi to 000-whatever.cgi,<br />so you need to enter the number of the last GM post here.<br />(if you don't know that number, just log into your FTP and look it out<br />in the entries' folder)</td>
</tr>
<tr>
<td>Last entry's number:</td>
<td><input type="text" name="lastentry" value="00000001" /></td>
</tr>
</table>
</p>
<p>When you're ready, click OK to start importing: <input type="submit" name="submit" value="OK" class="search" /></p>
</form>
@@ -317,6 +335,7 @@ default:
</html>
<?php
break;
}
?>

View File

@@ -17,7 +17,6 @@ require('../wp-config.php');
$step = $_GET['step'];
if (!$step) $step = 0;
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

View File

@@ -8,7 +8,6 @@ require('../wp-config.php');
require ('upgrade-functions.php');
$step = $_GET['step'];
if (!$step) $step = 0;
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -69,7 +68,7 @@ set_magic_quotes_runtime(0);
$importdata = file(MTEXPORT); // Read the file into an array
$importdata = implode('', $importdata); // squish it
$importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata);
$importdata = preg_replace("/\n--------\n/", "--MT-ENTRY--\n", $importdata);
$importdata = preg_replace("/--------\nAUTHOR/", "--MT-ENTRY--\nAUTHOR", $importdata);
$authors = array();
$temp = array();
$posts = explode("--MT-ENTRY--", $importdata);
@@ -180,7 +179,7 @@ set_magic_quotes_runtime(0);
$importdata = file(MTEXPORT); // Read the file into an array
$importdata = implode('', $importdata); // squish it
$importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata);
$importdata = preg_replace("/\n--------\n/", "--MT-ENTRY--", $importdata);
$importdata = preg_replace("/--------\nAUTHOR/", "--MT-ENTRY--\nAUTHOR", $importdata);
$authors = array();
$temp = array();
$posts = explode("--MT-ENTRY--", $importdata);

View File

@@ -22,7 +22,6 @@ require('../wp-config.php');
$step = $_GET['step'];
if (!$step) $step = 0;
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

View File

@@ -13,7 +13,6 @@ require('upgrade-functions.php');
$step = $_GET['step'];
if (!$step) $step = 0;
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

View File

@@ -39,7 +39,7 @@ if ( $scheduled = $wpdb->get_results("SELECT ID, post_title, post_date_gmt FROM
foreach ($scheduled as $post) {
if ($post->post_title == '')
$post->post_title = sprintf(__('Post #%s'), $post->ID);
echo "<li>" . sprintf(__('%1$s in %2$s'), "<a href='post.php?action=edit&amp;post=$post->ID' title='" . __('Edit this post') . "'>$post->post_title</a>", human_time_diff( current_time('timestamp', 1), strtotime($post->post_date_gmt. ' GMT') )) . "</li>";
echo "<li><a href='post.php?action=edit&amp;post=$post->ID' title='" . __('Edit this post') . "'>$post->post_title</a> in " . human_time_diff( current_time('timestamp', 1), strtotime($post->post_date_gmt) ) . "</li>";
}
?>
</ul>
@@ -54,7 +54,7 @@ if ( $comments = $wpdb->get_results("SELECT comment_author, comment_author_url,
<ul>
<?php
foreach ($comments as $comment) {
echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');
echo '<li>' . sprintf('%s on %s', get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');
edit_comment_link(__("Edit"), ' <small>(', ')</small>');
echo '</li>';
}
@@ -81,7 +81,7 @@ if (0 < $numcomms) $numcomms = number_format($numcomms);
$numcats = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories");
if (0 < $numcats) $numcats = number_format($numcats);
?>
<p><?php printf(__('There are currently %1$s <a href="%2$s" title="Posts">posts</a> and %3$s <a href="%4$s" title="Comments">comments</a>, contained within %5$s <a href="%6$s" title="categories">categories</a>.'), $numposts, 'edit.php', $numcomms, 'edit-comments.php', $numcats, 'categories.php'); ?></p>
<p>There are currently <?php echo $numposts ?> <a href="edit.php" title="posts">posts</a> and <?php echo $numcomms ?> <a href="edit-comments.php" title="Comments">comments</a>, contained within <?php echo $numcats ?> <a href="categories.php" title="categories">categories</a>.</p>
</div>
<?php

View File

@@ -1,5 +1,5 @@
<?php
define('WP_INSTALLING', true);
$_wp_installing = 1;
if (!file_exists('../wp-config.php'))
die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.");
@@ -12,12 +12,11 @@ if (isset($_GET['step']))
$step = $_GET['step'];
else
$step = 0;
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php _e('WordPress &rsaquo; Installation'); ?></title>
<title>WordPress &rsaquo; Installation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style media="screen" type="text/css">
<!--
@@ -78,58 +77,46 @@ header( 'Content-Type: text/html; charset=utf-8' );
// Let's check to make sure WP isn't already installed.
$wpdb->hide_errors();
$installed = $wpdb->get_results("SELECT * FROM $wpdb->users");
if ($installed) die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
if ($installed) die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p></body></html>'));
$wpdb->show_errors();
switch($step) {
case 0:
?>
<p><?php printf(__('Welcome to WordPress installation. We&#8217;re now going to go through a few steps to get you up and running with the latest in personal publishing platforms. You may want to peruse the <a href="%s">ReadMe documentation</a> at your leisure.'), '../readme.html'); ?></p>
<h2 class="step"><a href="install.php?step=1"><?php _e('First Step &raquo;'); ?></a></h2>
<p>Welcome to WordPress installation. We&#8217;re now going to go through a few steps to get you up and running with the latest in personal publishing platforms. You may want to peruse the <a href="../readme.html">ReadMe documentation</a> at your leisure.</p>
<h2 class="step"><a href="install.php?step=1">First Step &raquo;</a></h2>
<?php
break;
case 1:
?>
<h1><?php _e('First Step'); ?></h1>
<p><?php _e("Before we begin we need a little bit of information. Don't worry, you can always change these later."); ?></p>
<h1>First Step</h1>
<p>Before we begin we need a little bit of information. Don't worry, you can always change these later. </p>
<form id="setup" method="post" action="install.php?step=2">
<table width="100%">
<tr>
<th width="33%"><?php _e('Weblog title:'); ?></th>
<th width="33%">Weblog title:</th>
<td><input name="weblog_title" type="text" id="weblog_title" size="25" /></td>
</tr>
<tr>
<th><?php _e('Your e-mail:'); ?></th>
<th>Your e-mail:</th>
<td><input name="admin_email" type="text" id="admin_email" size="25" /></td>
</tr>
</table>
<p><em><?php _e('Double-check that email address before continuing.'); ?></em></p>
<p><em>Double-check that email address before continuing.</em></p>
<h2 class="step">
<input type="submit" name="Submit" value="<?php _e('Continue to Second Step &raquo;'); ?>" />
<input type="submit" name="Submit" value="Continue to Second Step &raquo;" />
</h2>
</form>
<?php
break;
case 2:
// Fill in the data we gathered
$weblog_title = $_POST['weblog_title'];
$admin_email = $_POST['admin_email'];
// check e-mail address
if (empty($admin_email)) {
die (__("<strong>ERROR</strong>: please type your e-mail address"));
} else if (!is_email($admin_email)) {
die (__("<strong>ERROR</strong>: the e-mail address isn't correct"));
}
?>
<h1><?php _e('Second Step'); ?></h1>
<p><?php _e('Now we&#8217;re going to create the database tables and fill them with some default data.'); ?></p>
<h1>Second Step</h1>
<p>Now we&#8217;re going to create the database tables and fill them with some default data.</p>
<?php
@@ -139,11 +126,15 @@ flush();
make_db_current_silent();
populate_options();
// Fill in the data we gathered
$weblog_title = addslashes(stripslashes(stripslashes($_POST['weblog_title'])));
$admin_email = addslashes(stripslashes(stripslashes($_POST['admin_email'])));
$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->linkcategories (cat_id, cat_name) VALUES (1, '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/');");
@@ -154,61 +145,65 @@ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link
$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'))."')");
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name) VALUES ('0', 'Uncategorized')");
// First post
$now = date('Y-m-d H:i:s');
$now_gmt = gmdate('Y-m-d H:i:s');
$wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_name, post_modified, post_modified_gmt) VALUES ('1', '$now', '$now_gmt', '".addslashes(__('Welcome to WordPress. 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_modified, post_modified_gmt) VALUES ('1', '$now', '$now_gmt', 'Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!', 'Hello world!', '0', '$now', '$now_gmt')");
$wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
// Default comment
$wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_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.'))."')");
$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', 'Mr WordPress', '', 'http://wordpress.org', '127.0.0.1', '$now', '$now_gmt', 'Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.')");
// Set up admin user
$random_password = substr(md5(uniqid(microtime())), 0, 6);
$wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_nickname, user_email, user_level, user_idmode, user_registered) VALUES ( '1', 'admin', MD5('$random_password'), '".addslashes(__('Administrator'))."', '$admin_email', '10', 'nickname', NOW() )");
$wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_nickname, user_email, user_level, user_idmode, user_registered) VALUES ( '1', 'admin', MD5('$random_password'), 'Administrator', '$admin_email', '10', 'nickname', NOW() )");
$message_headers = 'From: ' . stripslashes($_POST['weblog_title']) . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
$message = sprintf(__("Your new WordPress blog has been successfully set up at:
$from = 'From: '.$_POST['weblog_title'].' <wordpress@'.$_SERVER['SERVER_NAME'].'>';
$message_headers = "$from";
$message = "Your new WordPress blog has been successfully set up at:
%1\$s
$guessurl
You can log in to the administrator account with the following information:
Username: admin
Password: %2\$s
Password: $random_password
We hope you enjoy your new weblog. Thanks!
--The WordPress Team
http://wordpress.org/
"), $guessurl, $random_password);
";
@mail($admin_email, __('New WordPress Blog'), $message, $message_headers);
@mail($admin_email, 'New WordPress Blog', $message, $message_headers);
upgrade_all();
?>
<p><em><?php _e('Finished!'); ?></em></p>
<p><em>Finished!</em></p>
<p><?php printf(__('Now you can <a href="%1$s">log in</a> with the <strong>username</strong> "<code>admin</code>" and <strong>password</strong> "<code>%2$s</code>".'), '../wp-login.php', $random_password); ?></p>
<p><?php _e('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you. If you lose it, you will have to delete the tables from the database yourself, and re-install WordPress. So to review:'); ?>
<p>Now you can <a href="../wp-login.php">log in</a> with the <strong>login</strong>
"<code>admin</code>" and <strong>password</strong> "<code><?php echo $random_password; ?></code>".</p>
<p><strong><em>Note that password</em></strong> carefully! It is a <em>random</em>
password that was generated just for you. If you lose it, you
will have to delete the tables from the database yourself, and re-install WordPress. So to review:
</p>
<dl>
<dt><?php _e('Username'); ?></dt>
<dt>Login</dt>
<dd><code>admin</code></dd>
<dt><?php _e('Password'); ?></dt>
<dt>Password</dt>
<dd><code><?php echo $random_password; ?></code></dd>
<dt><?php _e('Login address'); ?></dt>
<dt>Login address</dt>
<dd><a href="../wp-login.php">wp-login.php</a></dd>
</dl>
<p><?php _e('Were you expecting more steps? Sorry to disappoint. All done! :)'); ?></p>
<p>Were you expecting more steps? Sorry to disappoint. All done! :)</p>
<?php
break;
}
?>
<p id="footer"><?php _e('<a href="http://wordpress.org/">WordPress</a>, personal publishing platform.'); ?></p>
<p id="footer"><a href="http://wordpress.org/">WordPress</a>, personal publishing platform.</p>
</body>
</html>

View File

@@ -116,10 +116,10 @@ require('admin-header.php');
<tr>
<th scope="row"> <?php _e('friendship') ?> </th>
<td>
<label for="contact">
<input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
<label for="acquaintance">
<input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php _e('acquaintance') ?></label>
<label for="contact">
<input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
<label id="friend">
<input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
<label for="friendship">
@@ -160,7 +160,7 @@ require('admin-header.php');
</td>
</tr>
<tr>
<th scope="row"> <?php _e('family'); ?> </th>
<th scope="row"> family </th>
<td>
<label for="child">
<input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> />

View File

@@ -108,7 +108,7 @@ switch ($action) {
?>
<div class="wrap">
<h2><?php printf(__('Edit &#8220%s&#8221; Category'), wp_specialchars($row->cat_name)); ?></h2>
<h2>Edit &#8220;<?php echo wp_specialchars($row->cat_name)?>&#8221; Category </h2>
<form name="editcat" method="post">
<input type="hidden" name="action" value="editedcat" />
@@ -305,50 +305,24 @@ $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle, show_images
$i = 1;
foreach ($results as $row) {
if ($row->list_limit == -1) {
$row->list_limit = __('none');
$row->list_limit = 'none';
}
$style = ($i % 2) ? ' class="alternate"' : '';
/*
Manually internationalize every sort order option.
*/
switch ($row->sort_order) {
case 'name':
$row->sort_order = __('name');
break;
case 'id':
$row->sort_order = __('id');
break;
case 'url':
$row->sort_order = __('url');
break;
case 'rating':
$row->sort_order = __('rating');
break;
case 'updated':
$row->sort_order = __('updated');
break;
case 'rand':
$row->sort_order = __('rand');
break;
case 'length':
$row->sort_order = __('length');
break;
}
?>
<tr valign="middle" align="center" <?php echo $style ?> style="border-bottom: 1px dotted #9C9A9C;">
<td><?php echo wp_specialchars($row->cat_name)?></td>
<td ><?php echo $row->cat_id?></td>
<td><?php echo $row->auto_toggle == 'Y' ? __('Yes') : __('No') ?></td>
<td><?php echo $row->show_images == 'Y' ? __('Yes') : __('No') ?></td>
<td><?php echo $row->show_description == 'Y' ? __('Yes') : __('No') ?></td>
<td><?php echo $row->show_rating == 'Y' ? __('Yes') : __('No') ?></td>
<td><?php echo $row->show_updated == 'Y' ? __('Yes') : __('No') ?></td>
<td><?php echo $row->sort_order ?></td>
<td><?php echo $row->sort_desc == 'Y' ? __('Yes') : __('No') ?></td>
<td><?php echo $row->auto_toggle?></td>
<td><?php echo $row->show_images?></td>
<td><?php echo $row->show_description?></td>
<td><?php echo $row->show_rating?></td>
<td><?php echo $row->show_updated?></td>
<td><?php echo $row->sort_order?></td>
<td><?php echo $row->sort_desc?></td>
<td nowrap="nowrap"><?php echo htmlentities($row->text_before_link)?>&nbsp;</td>
<td nowrap="nowrap"><?php echo htmlentities($row->text_after_link)?>&nbsp;</td>
<td nowrap="nowrap"><?php echo htmlentities($row->text_after_all)?></td>
<td><?php echo $row->list_limit ?></td>
<td><?php echo $row->list_limit?></td>
<td><a href="link-categories.php?cat_id=<?php echo $row->cat_id?>&amp;action=Edit" class="edit"><?php _e('Edit') ?></a></td>
<td><a href="link-categories.php?cat_id=<?php echo $row->cat_id?>&amp;action=Delete" onclick="return confirm('<?php _e("You are about to delete this category.\\n \'Cancel\' to stop, \'OK\' to delete.") ?>');" class="delete"><?php _e('Delete') ?></a></td>
</tr>
@@ -443,11 +417,13 @@ foreach ($results as $row) {
</div>
<div class="wrap">
<h3><?php _e('Note:') ?></h3>
<?php printf(__('<p>Deleting a link category does not delete links from that category.<br />It will just set them back to the default category <b>%s</b>.'), get_linkcatname(1)) ?></p>
<?php printf(__('<p>Deleting a link category does not delete links from that category.<br />
It will just set them back to the default category <b>%s</b>.'), get_linkcatname(1)) ?>
</p>
</div>
<?php
break;
} // end default
} // end case
?>
<?php include('admin-footer.php'); ?>
<?php include('admin-footer.php'); ?>

View File

@@ -28,8 +28,14 @@ switch ($step) {
<form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
<ol>
<li><?php _e('Go to <a href="http://www.blogrolling.com">Blogrolling.com</a> and sign in. Once you&#8217;ve done that, click on <strong>Get Code</strong>, and then look for the <strong><abbr title="Outline Processor Markup Language">OPML</abbr> code</strong>') ?>.</li>
<li><?php _e('Or go to <a href="http://blo.gs">Blo.gs</a> and sign in. Once you&#8217;ve done that in the \'Welcome Back\' box on the right, click on <strong>share</strong>, and then look for the <strong><abbr title="Outline Processor Markup Language">OPML</abbr> link</strong> (favorites.opml).') ?></li>
<li><?php _e('Go to <a href="http://www.blogrolling.com">Blogrolling.com</a>
and sign in. Once you&#8217;ve done that, click on <strong>Get Code</strong>, and then
look for the <strong><abbr title="Outline Processor Markup Language">OPML</abbr>
code</strong>') ?>.</li>
<li><?php _e('Or go to <a href="http://blo.gs">Blo.gs</a> and sign in. Once you&#8217;ve done
that in the \'Welcome Back\' box on the right, click on <strong>share</strong>, and then
look for the <strong><abbr title="Outline Processor Markup Language">OPML</abbr>
link</strong> (favorites.opml).') ?></li>
<li><?php _e('Select that text and copy it or copy the link/shortcut into the box below.') ?><br />
<input type="hidden" name="step" value="1" />
<?php _e('Your OPML URL:') ?> <input type="text" name="opml_url" size="65" />

View File

@@ -66,7 +66,6 @@ $links_show_order = $_COOKIE['links_show_order_' . COOKIEHASH];
if ('' != $_POST['assign']) $action = 'assign';
if ('' != $_POST['visibility']) $action = 'visibility';
if ('' != $_POST['move']) $action = 'move';
if ('' != $_POST['linkcheck']) $linkcheck = $_POST[linkcheck];
switch ($action) {
case 'assign':
@@ -243,7 +242,7 @@ switch ($action) {
WHERE link_id=$link_id");
} // end if save
setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
wp_redirect($this_file);
header('Location: ' . $this_file);
break;
} // end Save
@@ -267,7 +266,7 @@ switch ($action) {
}
$links_show_cat_id = $cat_id;
setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
wp_redirect($this_file);
header('Location: '.$this_file);
break;
} // end Delete
@@ -347,10 +346,10 @@ switch ($action) {
<tr>
<th scope="row"> <?php _e('friendship') ?> </th>
<td>
<label for="contact">
<input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
<label for="acquaintance">
<input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php _e('acquaintance') ?></label>
<label for="contact">
<input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
<label id="friend">
<input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
<label for="friendship">
@@ -391,7 +390,7 @@ switch ($action) {
</td>
</tr>
<tr>
<th scope="row"> <?php _e('family') ?> </th>
<th scope="row"> family </th>
<td>
<label for="child">
<input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> />
@@ -675,10 +674,11 @@ function checkAll(form)
$visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
++$i;
$style = ($i % 2) ? ' class="alternate"' : '';
?>
<tr valign="middle" <?php echo $style; ?>>
<td><strong><?php echo $link->link_name; ?></strong><br />
<?php
echo <<<LINKS
<tr valign="middle" $style>
<td><strong>$link->link_name</strong><br />
LINKS;
echo sprintf(__('Description: %s'), $link->link_description) . "</td>";
echo "<td><a href=\"$link->link_url\" title=\"" . sprintf(__('Visit %s'), $link->link_name) . "\">$short_url</a></td>";
echo <<<LINKS
@@ -752,4 +752,4 @@ LINKS;
} // end case
?>
<?php include('admin-footer.php'); ?>
<?php include('admin-footer.php'); ?>

View File

@@ -35,19 +35,16 @@ foreach ($submenu["$parent_file"] as $item) :
continue;
}
if ( isset($submenu_file) ) {
if ( $submenu_file == $item[2] ) $class = ' class="current"';
else $class = '';
} else if ( (isset($plugin_page) && $plugin_page == $item[2]) || (!isset($plugin_page) && $self == $item[2]) ) $class = ' class="current"';
if ( (isset($plugin_page) && $plugin_page == $item[2]) || (!isset($plugin_page) && substr($self, -10) == substr($item[2], -10)) ) $class = ' class="current"';
else if (isset($submenu_file) && $submenu_file == substr($item[2], -10)) $class = ' class="current"';
else $class = '';
$menu_hook = get_plugin_page_hook($item[2], $parent_file);
if (file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") || ! empty($menu_hook)) {
if ( 'admin.php' == $pagenow )
echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
if (file_exists(ABSPATH . "wp-content/plugins/{$item[2]}")) {
$page_hook = get_plugin_page_hook($item[2], $parent_file);
if ( $page_hook )
echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$parent_file}?page={$item[2]}'$class>{$item[0]}</a></li>";
else
echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$parent_file}?page={$item[2]}'$class>{$item[0]}</a></li>";
echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
} else {
echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
}

View File

@@ -98,7 +98,7 @@ endforeach;
<fieldset class="options">
<legend><?php _e('Update Services') ?></legend>
<p><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="http://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service URIs with line breaks.') ?></p>
<p><?php printf(__('When you publish a new post WordPress can notify site update services. For more about this see <a href="%s">Update Services</a> on the Codex. Separate multiple service URIs with line breaks.'), 'http://codex.wordpress.org/Update_Services') ?></p>
<textarea name="ping_sites" id="ping_sites" style="width: 98%;" rows="3" cols="50"><?php form_option('ping_sites'); ?></textarea>
</fieldset>

View File

@@ -53,6 +53,8 @@ case 'update':
if ($user_level >= $option->option_admin_level) {
$old_val = $option->option_value;
$new_val = trim($_POST[$option->option_name]);
if ( !$new_val && $old_val != 0 )
$new_val = '';
if( in_array($option->option_name, $nonbools) && ( $new_val == '0' || $new_val == '') )
$new_val = 'closed';
if ($new_val !== $old_val) {
@@ -68,8 +70,6 @@ case 'update':
if ($any_changed) {
// If siteurl or home changed, reset cookies.
if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
// If home changed, write rewrite rules to new location.
save_mod_rewrite_rules();
// Get currently logged in user and password.
get_currentuserinfo();
// Clear cookies for old paths.
@@ -84,14 +84,14 @@ case 'update':
$referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']);
$goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']);
$goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
wp_redirect($goback);
header('Location: ' . $goback);
break;
default:
include('admin-header.php'); ?>
<div class="wrap">
<h2><?php _e('All options'); ?></h2>
<h2>All options</h2>
<form name="form" action="options.php" method="post">
<input type="hidden" name="action" value="update" />
<table width="98%">
@@ -103,7 +103,7 @@ foreach ($options as $option) :
echo "
<tr>
<th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
<td><input type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . $value . "' /></td>
<td><input type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . htmlspecialchars($value, ENT_QUOTES) . "' /></td>
<td>$option->option_description</td>
</tr>";
endforeach;

View File

@@ -67,7 +67,7 @@ default:
if (!$error) {
$f = fopen($real_file, 'r');
$content = fread($f, filesize($real_file));
$content = htmlspecialchars($content);
$content = wp_specialchars($content);
}
?>

View File

@@ -29,16 +29,6 @@ require_once('admin-header.php');
// If any plugins don't exist, axe 'em
$check_plugins = get_settings('active_plugins');
// Sanity check. If the active plugin list is not an array, make it an
// empty array.
if ( !is_array($check_plugins) ) {
$check_plugins = array();
update_option('active_plugins', $check_plugins);
}
// If a plugin file does not exist, remove it from the list of active
// plugins.
foreach ($check_plugins as $check_plugin) {
if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) {
$current = get_settings('active_plugins');
@@ -82,24 +72,22 @@ if (empty($plugins)) {
<?php
$style = '';
foreach($plugins as $plugin_file => $plugin_data) {
$style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
$style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
$action = "<a href='plugins.php?action=deactivate&amp;plugin=$plugin_file' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
$plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>";
$style .= $style == 'alternate' ? ' active' : 'active';
} else {
$action = "<a href='plugins.php?action=activate&amp;plugin=$plugin_file' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
}
$plugin_data['Description'] = wp_kses($plugin_data['Description'], array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()) ); ;
if ($style != '') $style = 'class="' . $style . '"';
echo "
<tr $style>
<td class=\"name\">{$plugin_data['Title']}</td>
<td class=\"vers\">{$plugin_data['Version']}</td>
<td class=\"auth\">{$plugin_data['Author']}</td>
<td class=\"desc\">{$plugin_data['Description']}</td>
<td class=\"togl\">$action</td>
<td>{$plugin_data['Title']}</td>
<td>{$plugin_data['Version']}</td>
<td>{$plugin_data['Author']}</td>
<td>{$plugin_data['Description']}</td>
<td>$action</td>
</tr>";
}
?>
@@ -108,10 +96,6 @@ if (empty($plugins)) {
<?php
}
?>
<h2><?php _e('Get More Plugins'); ?></h2>
<p><?php _e('You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>. To install a plugin you generally just need to upload the plugin file into your <code>wp-content/plugins</code> directory. Once a plugin is uploaded, you may activate it here.'); ?></p>
</div>
<?php

View File

@@ -22,16 +22,11 @@ if (isset($_POST['deletepost'])) {
$action = "delete";
}
// Fix submenu highlighting for pages.
if (false !== strpos($_SERVER['HTTP_REFERER'], 'edit-pages.php')) $submenu_file = 'page-new.php';
$editing = true;
switch($action) {
case 'post':
if ( !user_can_create_draft($user_ID) )
die( __('You are not allowed to create posts or drafts on this blog.') );
die('You are not allowed to create posts or drafts on this blog.');
$post_pingback = (int) $_POST['post_pingback'];
$content = apply_filters('content_save_pre', $_POST['content']);
@@ -63,25 +58,14 @@ case 'post':
if ( empty($post_status) )
$post_status = 'draft';
// Double-check
if ( 'publish' == $post_status && (!user_can_create_post($user_ID)) )
if ( 'publish' == $post_status && (!user_can_create_post($user_ID)) && 2 != get_option('new_users_can_blog') )
$post_status = 'draft';
$comment_status = $_POST['comment_status'];
if ( empty($comment_status) ) {
if ( !isset($_POST['advanced_view']) )
$comment_status = get_option('default_comment_status');
else
$comment_status = 'closed';
}
if ( empty($comment_status) && !isset($_POST['advanced_view']) )
$comment_status = get_option('default_comment_status');
$ping_status = $_POST['ping_status'];
if ( empty($ping_status) ) {
if ( !isset($_POST['advanced_view']) )
$ping_status = get_option('default_ping_status');
else
$ping_status = 'closed';
}
if ( empty($ping_status) && !isset($_POST['advanced_view']) )
$ping_status = get_option('default_ping_status');
$post_password = $_POST['post_password'];
$trackback = $_POST['trackback_url'];
@@ -118,8 +102,7 @@ case 'post':
$post_ID = $id_result->Auto_increment;
if ( empty($post_name) ) {
if ( 'draft' != $post_status )
$post_name = sanitize_title($post_title, $post_ID);
$post_name = sanitize_title($post_title, $post_ID);
} else {
$post_name = sanitize_title($post_name, $post_ID);
}
@@ -193,11 +176,11 @@ case 'post':
do_action('save_post', $post_ID);
if ('publish' == $post_status) {
do_action('publish_post', $post_ID);
if ($post_pingback)
register_shutdown_function('pingback', $content, $post_ID);
register_shutdown_function('do_enclose', $content, $post_ID );
register_shutdown_function('do_trackbacks', $post_ID);
pingback($content, $post_ID);
do_enclose( $content, $post_ID );
do_trackbacks($post_ID);
do_action('publish_post', $post_ID);
}
if ($post_status == 'static') {
@@ -218,9 +201,9 @@ case 'edit':
$post = $post_ID = $p = (int) $_GET['post'];
if ( !user_can_edit_post($user_ID, $post_ID) )
die ( __('You are not allowed to edit this post.') );
die ('You are not allowed to edit this post.');
$postdata = &get_post($post_ID);
$postdata = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$post_ID'");
$content = $postdata->post_content;
$content = format_to_edit($content);
$content = apply_filters('content_edit_pre', $content);
@@ -241,7 +224,7 @@ case 'edit':
$menu_order = $postdata->menu_order;
if( 'private' == $postdata->post_status && $postdata->post_author != $user_ID )
die ( __('You are not allowed to view other users\' private posts.') );
die ('You are not allowed to view other users\' private posts.');
if ($post_status == 'static') {
$page_template = get_post_meta($post_ID, '_wp_page_template', true);
@@ -250,11 +233,11 @@ case 'edit':
include('edit-form-advanced.php');
}
$post = &$postdata;
$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$post_ID'");
?>
<div id='preview' class='wrap'>
<h2><?php _e('Post Preview (updated when post is saved)'); ?></h2>
<h3 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__("Permanent Link: %s"), get_the_title()); ?>"><?php the_title(); ?></a></h3>
<h3 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__("Permanent Link: %s"), the_title()); ?>"><?php the_title(); ?></a></h3>
<div class="meta"><?php _e("Filed under:"); ?> <?php the_category(','); ?> &#8212; <?php the_author() ?> @ <?php the_time() ?></div>
<div class="storycontent">
@@ -272,10 +255,10 @@ case 'editpost':
if (!isset($blog_ID)) {
$blog_ID = 1;
}
$post_ID = (int) $_POST['post_ID'];
$post_ID = $_POST['post_ID'];
if (!user_can_edit_post($user_ID, $post_ID, $blog_ID))
die( __('You are not allowed to edit this post.') );
die('You are not allowed to edit this post.');
$post_categories = $_POST['post_category'];
if (!$post_categories) $post_categories[] = 1;
@@ -304,10 +287,13 @@ case 'editpost':
//if (!$_POST['ping_status']) $ping_status = get_settings('default_ping_status');
$post_password = $_POST['post_password'];
$post_name = $_POST['post_name'];
if (empty($post_name)) {
$post_name = $post_title;
}
$post_parent = 0;
if (isset($_POST['parent_id'])) {
$post_parent = (int) $_POST['parent_id'];
$post_parent = $_POST['parent_id'];
}
$trackback = $_POST['trackback_url'];
@@ -316,12 +302,11 @@ case 'editpost':
if (isset($_POST['publish'])) $post_status = 'publish';
// Double-check
if ( 'publish' == $post_status && (!user_can_create_post($user_ID)) )
if ( 'publish' == $post_status && (!user_can_create_post($user_ID)) && 2 != get_option('new_users_can_blog') )
$post_status = 'draft';
if ( empty($post_name) ) {
if ( 'draft' != $post_status )
$post_name = sanitize_title($post_title, $post_ID);
if (empty($post_name)) {
$post_name = sanitize_title($post_title, $post_ID);
} else {
$post_name = sanitize_title($post_name, $post_ID);
}
@@ -429,14 +414,12 @@ case 'editpost':
if ($prev_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);
register_shutdown_function('do_trackbacks', $post_ID);
register_shutdown_function('do_enclose', $content, $post_ID );
do_trackbacks($post_ID);
do_enclose( $content, $post_ID );
if ( get_option('default_pingback_flag') )
register_shutdown_function('pingback', $content, $post_ID);
pingback($content, $post_ID);
}
if ($post_status == 'static') {
@@ -447,6 +430,7 @@ case 'editpost':
}
}
do_action('edit_post', $post_ID);
exit();
break;
@@ -456,11 +440,11 @@ case 'delete':
$post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
if (!user_can_delete_post($user_ID, $post_id)) {
die( __('You are not allowed to delete this post.') );
die('You are not allowed to delete this post.');
}
if (! wp_delete_post($post_id))
die( __('Error in deleting...') );
die(__('Error in deleting...'));
$sendback = $_SERVER['HTTP_REFERER'];
if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post.php';
@@ -477,11 +461,11 @@ case 'editcomment':
get_currentuserinfo();
$comment = (int) $_GET['comment'];
$comment = $_GET['comment'];
$commentdata = get_commentdata($comment, 1, true) or die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)'));
if (!user_can_edit_post_comments($user_ID, $commentdata['comment_post_ID'])) {
die( __('You are not allowed to edit comments on this post.') );
die('You are not allowed to edit comments on this post.');
}
$content = $commentdata['comment_content'];
@@ -498,12 +482,12 @@ case 'confirmdeletecomment':
require_once('./admin-header.php');
$comment = (int) $_GET['comment'];
$p = (int) $_GET['p'];
$comment = $_GET['comment'];
$p = $_GET['p'];
$commentdata = get_commentdata($comment, 1, true) or die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if (!user_can_delete_post_comments($user_ID, $commentdata['comment_post_ID'])) {
die( __('You are not allowed to delete comments on this post.') );
die('You are not allowed to delete comments on this post.');
}
echo "<div class=\"wrap\">\n";
@@ -533,19 +517,19 @@ case 'deletecomment':
check_admin_referer();
$comment = (int) $_GET['comment'];
$p = (int) $_GET['p'];
$comment = $_GET['comment'];
$p = $_GET['p'];
if (isset($_GET['noredir'])) {
$noredir = true;
} else {
$noredir = false;
}
$postdata = get_post($p) or die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
$postdata = get_postdata($p) or die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
$commentdata = get_commentdata($comment, 1, true) or die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'post.php'));
if (!user_can_delete_post_comments($user_ID, $commentdata['comment_post_ID'])) {
die( __('You are not allowed to edit comments on this post.') );
die('You are not allowed to edit comments on this post.');
}
wp_set_comment_status($comment, "delete");
@@ -565,8 +549,8 @@ case 'unapprovecomment':
check_admin_referer();
$comment = (int) $_GET['comment'];
$p = (int) $_GET['p'];
$comment = $_GET['comment'];
$p = $_GET['p'];
if (isset($_GET['noredir'])) {
$noredir = true;
} else {
@@ -576,7 +560,7 @@ case 'unapprovecomment':
$commentdata = get_commentdata($comment) or die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if (!user_can_edit_post_comments($user_ID, $commentdata['comment_post_ID'])) {
die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
die('You are not allowed to edit comments on this post, so you cannot disapprove this comment.');
}
wp_set_comment_status($comment, "hold");
@@ -596,7 +580,7 @@ case 'mailapprovecomment':
$commentdata = get_commentdata($comment, 1, true) or die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if (!user_can_edit_post_comments($user_ID, $commentdata['comment_post_ID'])) {
die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
die('You are not allowed to edit comments on this post, so you cannot approve this comment.');
}
if ('1' != $commentdata['comment_approved']) {
@@ -611,8 +595,8 @@ case 'mailapprovecomment':
case 'approvecomment':
$comment = (int) $_GET['comment'];
$p = (int) $_GET['p'];
$comment = $_GET['comment'];
$p = $_GET['p'];
if (isset($_GET['noredir'])) {
$noredir = true;
} else {
@@ -621,7 +605,7 @@ case 'approvecomment':
$commentdata = get_commentdata($comment) or die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if (!user_can_edit_post_comments($user_ID, $commentdata['comment_post_ID'])) {
die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
die('You are not allowed to edit comments on this post, so you cannot approve this comment.');
}
wp_set_comment_status($comment, "approve");
@@ -640,15 +624,15 @@ case 'approvecomment':
case 'editedcomment':
$comment_ID = (int) $_POST['comment_ID'];
$comment_post_ID = (int) $_POST['comment_post_ID'];
$comment_ID = $_POST['comment_ID'];
$comment_post_ID = $_POST['comment_post_ID'];
$newcomment_author = $_POST['newcomment_author'];
$newcomment_author_email = $_POST['newcomment_author_email'];
$newcomment_author_url = $_POST['newcomment_author_url'];
$comment_status = $_POST['comment_status'];
if (!user_can_edit_post_comments($user_ID, $comment_post_ID)) {
die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.') );
die('You are not allowed to edit comments on this post, so you cannot edit this comment.');
}
if (user_can_edit_post_date($user_ID, $post_ID) && (!empty($_POST['edit_date']))) {
@@ -692,7 +676,7 @@ default:
require_once ('./admin-header.php');
?>
<?php if ( isset($_GET['posted']) ) : ?>
<div class="updated"><p><?php printf(__('Post saved. <a href="%s">View site &raquo;</a>'), get_bloginfo('home')); ?></p></div>
<div class="updated"><p>Post saved. <a href="<?php bloginfo('home'); ?>">View site &raquo;</a></p></div>
<?php endif; ?>
<?php
if (user_can_create_draft($user_ID)) {

View File

@@ -30,7 +30,7 @@ case 'update':
/* checking the nickname has been typed */
if (empty($_POST["newuser_nickname"])) {
die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)"));
die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your login)"));
return false;
}
@@ -51,20 +51,16 @@ case 'update':
return false;
}
$pass1 = $_POST["pass1"];
$pass2 = $_POST["pass2"];
do_action('check_passwords', array($user_login, &$pass1, &$pass2));
if ( '' == $pass1 ) {
if ( '' != $pass2 )
if ($_POST["pass1"] == "") {
if ($_POST["pass2"] != "")
die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
$updatepassword = "";
} else {
if ('' == $pass2)
if ($_POST["pass2"] == "")
die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
if ( $pass1 != $pass2 )
if ($_POST["pass1"] != $_POST["pass2"])
die (__("<strong>ERROR</strong>: you typed two different passwords. Go back to correct that."));
$newuser_pass = $pass1;
$newuser_pass = $_POST["pass1"];
$updatepassword = "user_pass=MD5('$newuser_pass'), ";
wp_clearcookie();
wp_setcookie($user_login, $newuser_pass);
@@ -73,7 +69,7 @@ case 'update':
$newuser_firstname = wp_specialchars($_POST['newuser_firstname']);
$newuser_lastname = wp_specialchars($_POST['newuser_lastname']);
$newuser_nickname = $_POST['newuser_nickname'];
$newuser_nicename = sanitize_title($newuser_nickname);
$newuser_nicename = sanitize_title($newuser_nickname);
$newuser_icq = wp_specialchars($_POST['newuser_icq']);
$newuser_aim = wp_specialchars($_POST['newuser_aim']);
$newuser_msn = wp_specialchars($_POST['newuser_msn']);
@@ -86,7 +82,7 @@ case 'update':
$result = $wpdb->query("UPDATE $wpdb->users SET user_firstname='$newuser_firstname', $updatepassword user_lastname='$newuser_lastname', user_nickname='$newuser_nickname', user_icq='$newuser_icq', user_email='$newuser_email', user_url='$newuser_url', user_aim='$newuser_aim', user_msn='$newuser_msn', user_yim='$newuser_yim', user_idmode='$newuser_idmode', user_description = '$user_description', user_nicename = '$newuser_nicename' WHERE ID = $user_ID");
wp_redirect('profile.php?updated=true');
header('Location: profile.php?updated=true');
break;
case 'IErightclick':
@@ -144,7 +140,7 @@ if (isset($updated)) { ?>
<table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform">
<tr>
<th width="33%" scope="row"><?php _e('Username:') ?></th>
<th width="33%" scope="row"><?php _e('Login:') ?></th>
<td width="67%"><?php echo $profiledata->user_login; ?></td>
</tr>
<tr>
@@ -229,17 +225,12 @@ if (isset($updated)) { ?>
<th scope="row"><?php _e('Profile:') ?></th>
<td><textarea name="user_description" rows="5" id="textarea2" style="width: 99%; "><?php echo $profiledata->user_description ?></textarea></td>
</tr>
<?php
$show_password_fields = apply_filters('show_password_fields', true);
if ( $show_password_fields ) :
?>
<tr>
<th scope="row"><?php _e('New <strong>Password</strong> (Leave blank to stay the same.)') ?></th>
<td><input type="password" name="pass1" size="16" value="" />
<br />
<input type="password" name="pass2" size="16" value="" /></td>
</tr>
<?php endif; ?>
</table>
<p class="submit">
<input type="submit" value="<?php _e('Update Profile &raquo;') ?>" name="submit" />

View File

@@ -25,17 +25,18 @@ function zeroise(number, threshold) {
}
var now = new Date();
var datetime = now.getUTCFullYear() + '-' +
zeroise(now.getUTCMonth() + 1, 2) + '-' +
zeroise(now.getUTCDate(), 2) + 'T' +
zeroise(now.getUTCHours(), 2) + ':' +
zeroise(now.getUTCMinutes(), 2) + ':' +
zeroise(now.getUTCSeconds() ,2) +
'+00:00';
var datetime = now.getFullYear() + '-' +
zeroise(now.getMonth() + 1, 2) + '-' +
zeroise(now.getDate(), 2) + 'T' +
zeroise(now.getHours(), 2) + ':' +
zeroise(now.getMinutes(), 2) + ':' +
zeroise(now.getSeconds() ,2) +
// FIXME: we could try handling timezones like +05:30 and the like
zeroise((now.getTimezoneOffset()/60), 2) + ':' + '00';
edButtons[edButtons.length] =
new edButton('ed_strong'
,'b'
,'str'
,'<strong>'
,'</strong>'
,'b'
@@ -43,7 +44,7 @@ new edButton('ed_strong'
edButtons[edButtons.length] =
new edButton('ed_em'
,'i'
,'em'
,'<em>'
,'</em>'
,'i'
@@ -60,8 +61,8 @@ new edButton('ed_link'
edButtons[edButtons.length] =
new edButton('ed_block'
,'b-quote'
,'\n\n<blockquote>'
,'</blockquote>\n\n'
,'<blockquote>'
,'</blockquote>'
,'q'
);
@@ -131,7 +132,7 @@ new edButton('ed_more'
,'t'
,-1
);
/*
edButtons[edButtons.length] =
new edButton('ed_next'
,'page'
@@ -140,7 +141,7 @@ new edButton('ed_next'
,'p'
,-1
);
*/
function edLink() {
this.display = '';
this.URL = '';
@@ -250,8 +251,8 @@ function edSpell(myField) {
if (word == '') {
word = prompt('Enter a word to look up:', '');
}
if (word !== null && /^\w[\w ]*$/.test(word)) {
window.open('http://www.answers.com/' + escape(word));
if (word != '') {
window.open('http://dictionary.reference.com/search?q=' + escape(word));
}
}
@@ -260,7 +261,7 @@ function edToolbar() {
for (i = 0; i < edButtons.length; i++) {
edShowButton(edButtons[i], i);
}
document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="Dictionary lookup" value="lookup" />');
document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="Dictionary lookup" value="Dict." />');
document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="Close all open tags" value="Close Tags" />');
// edShowLinks(); // disabled by default
document.write('</div>');

View File

@@ -1,8 +1,8 @@
<?php
define('WP_INSTALLING', true);
$_wp_installing = 1;
if (file_exists('../wp-config.php'))
die("The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.");
die("The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first.");
if (!file_exists('../wp-config-sample.php'))
die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
@@ -12,7 +12,6 @@ if (!is_writable('../')) die("Sorry, I can't write to the directory. You'll have
$step = 0;
if(isset($_GET['step'])) $step = $_GET['step'];
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

View File

@@ -1,7 +1,8 @@
<?php
$mode = 'sidebar';
require_once('admin.php');
$standalone = 1;
require_once('admin-header.php');
get_currentuserinfo();
@@ -17,7 +18,7 @@ if ('b' == $_GET['a']) {
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=UTF-8" />
<link rel="stylesheet" href="wp-admin.css" type="text/css" />
</head>
<body>
<body
<p>Posted !</p>
<p><a href="sidebar.php">Click here</a> to post again.</p>
</body>

View File

@@ -135,9 +135,9 @@ endif;
?>
</div>
<div class="wrap">
<h2><?php _e('Other Files') ?></h2>
<h2>Other Files</h2>
<p><?php _e('To edit a file, type its name here. You can edit any file <a href="http://codex.wordpress.org/Changing_File_Permissions" title="Read more about making files writable">writable by the server</a>, e.g. CHMOD 666.') ?></p>
<p><?php _e('To edit a file, type its name here. You can edit any file <a href="http://wiki.wordpress.org/index.php/MakeWritable" title="Read more about making files writable">writable by the server</a>, e.g. CHMOD 666.') ?></p>
<form name="file" action="templates.php" method="get">
<input type="text" name="file" />
<input type="submit" name="submit" value="<?php _e('Edit file &raquo;') ?>" />

View File

@@ -24,13 +24,7 @@ $themes = get_themes();
if (empty($theme)) {
$theme = get_current_theme();
} else {
$theme = stripslashes($theme);
}
if ( ! isset($themes[$theme]) )
die(__('The requested theme does not exist.'));
}
$allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);
@@ -76,7 +70,7 @@ default:
if (!is_file($real_file))
$error = 1;
if (!$error && filesize($real_file) > 0) {
if (!$error) {
$f = fopen($real_file, 'r');
$content = fread($f, filesize($real_file));
$content = htmlspecialchars($content);
@@ -95,8 +89,7 @@ default:
$theme_name = $a_theme['Name'];
if ($theme_name == $theme) $selected = " selected='selected'";
else $selected = '';
$theme_name = wp_specialchars($theme_name, true);
echo "\n\t<option value=\"$theme_name\" $selected>$theme_name</option>";
echo "\n\t<option value='$theme_name' $selected>$theme_name</option>";
}
?>
</select>

View File

@@ -53,7 +53,9 @@ $current_stylesheet = $themes[$current_theme]['Stylesheet'];
<?php } ?>
</div>
<h2><?php _e('Themes Available'); ?></h2>
<h2><?php _e('Other Themes'); ?></h2>
<p><?php _e('Themes are usually downloaded separately from WordPress. To install a theme you generally just need to put the theme file or files into your <code>wp-content/themes</code> directory. Once a theme is installed, you may select it here.'); ?></p>
<?php if ( 1 < count($themes) ) { ?>
<table width="100%" cellpadding="3" cellspacing="3">
<tr>
@@ -63,7 +65,7 @@ $current_stylesheet = $themes[$current_theme]['Stylesheet'];
<th></th>
</tr>
<?php
$style = '';
$theme = '';
$theme_names = array_keys($themes);
natcasesort($theme_names);
@@ -84,20 +86,17 @@ $current_stylesheet = $themes[$current_theme]['Stylesheet'];
$current = false;
}
$style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
if ($current) $style .= $style == 'alternate' ? ' active' : 'active';
if ($style != '') $style = 'class="' . $style . '"';
$theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
echo "
<tr $style>";
<tr $theme>";
if ( $current )
echo "<td><strong>$title $version</strong></td>";
else
echo "<td>$title $version</td>";
echo "
<td class=\"auth\">$author</td>
<td class=\"desc\">$description</td>
<td class=\"togl\">$action</td>
<td align='center'>$author</td>
<td>$description</td>
<td align='center'>$action</td>
</tr>";
}
?>
@@ -144,9 +143,6 @@ if (count($broken_themes)) {
}
?>
<h2><?php _e('Get More Themes'); ?></h2>
<p><?php _e('You can find additional themes for your site in the <a href="http://wordpress.org/extend/themes/">WordPress theme directory</a>. To install a theme you generally just need to upload the theme folder into your <code>wp-content/themes</code> directory. Once a theme is uploaded, you may activate it here.'); ?></p>
</div>
<?php

View File

@@ -23,22 +23,22 @@ $http_request .= "\r\n";
$http_request .= $query_string;
$response = '';
if( false !== ( $fs = fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) {
fwrite($fs, $http_request);
while ( !feof($fs) )
$response .= fgets($fs, 1160); // One TCP-IP packet
fclose($fs);
$response = explode("\r\n\r\n", $response, 2);
$body = trim( $response[1] );
$body = str_replace(array("\r\n", "\r"), "\n", $body);
$returns = explode("\n", $body);
foreach ($returns as $return) :
$time = addslashes( substr($return, 0, 19) );
$uri = addslashes( preg_replace('/(.*?) | (.*?)/', '$2', $return) );
$wpdb->query("UPDATE $wpdb->links SET link_updated = '$time' WHERE link_url = '$uri'");
endforeach;
}
$fs = fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5);
fwrite($fs, $http_request);
while ( !feof($fs) )
$response .= fgets($fs, 1160); // One TCP-IP packet
fclose($fs);
$response = explode("\r\n\r\n", $response, 2);
$body = trim( $response[1] );
$body = str_replace(array("\r\n", "\r"), "\n", $body);
$returns = explode("\n", $body);
foreach ($returns as $return) :
$time = addslashes( substr($return, 0, 19) );
$uri = addslashes( preg_replace('/(.*?) | (.*?)/', '$2', $return) );
$wpdb->query("UPDATE $wpdb->links SET link_updated = '$time' WHERE link_url = '$uri'");
endforeach;
?>

View File

@@ -131,7 +131,7 @@ function upgrade_110() {
$wpdb->query("UPDATE $wpdb->posts SET post_modified = post_date");
$wpdb->query("UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'");
$wpdb->query("UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
$wpdb->query("UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
$wpdb->query("UPDATE $wpdb->users SET user_registered = DATE_ADD(dateYMDhour, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
}
}
@@ -180,14 +180,10 @@ function upgrade_130() {
$wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'");
}
$active_plugins = __get_option('active_plugins');
// If plugins are not stored in an array, they're stored in the old
// newline separated format. Convert to new format.
if ( !is_array( $active_plugins ) ) {
$active_plugins = explode("\n", trim($active_plugins));
update_option('active_plugins', $active_plugins);
}
if ( !is_array( get_settings('active_plugins') ) ) {
$plugins = explode("\n", trim(get_settings('active_plugins')) );
update_option('active_plugins', $plugins);
}
// Obsolete tables
$wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optionvalues');
@@ -295,19 +291,6 @@ function get_alloptions_110() {
return $all_options;
}
// Version of get_option that is private to install/upgrade.
function __get_option($setting) {
global $wpdb;
$option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
@ $kellogs = unserialize($option);
if ($kellogs !== FALSE)
return $kellogs;
else
return $option;
}
function deslash($content) {
// Note: \\\ inside a regex denotes a single backslash.
@@ -578,13 +561,13 @@ function make_site_theme_from_oldschool($theme_name, $template) {
$lines = explode("\n", implode('', file("$site_dir/$newfile")));
if ($lines) {
$f = fopen("$site_dir/$newfile", 'w');
foreach ($lines as $line) {
if (preg_match('/require.*wp-blog-header/', $line))
$line = '//' . $line;
// Update stylesheet references.
$line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
$line = str_replace("<?php echo get_settings('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
// Update comments template inclusion.
$line = str_replace("<?php include(ABSPATH . 'wp-comments.php'); ?>", "<?php comments_template(); ?>", $line);
@@ -596,7 +579,7 @@ function make_site_theme_from_oldschool($theme_name, $template) {
}
// Add a theme header.
$header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the upgrade.\nVersion: 1.0\nAuthor: Moi\n*/\n";
$header = "/*\nTheme Name: $theme_name\nTheme URI: " . get_option('siteurl') . "\nDescription: A theme automatically created by the upgrade.\nVersion: 1.0\nAuthor: Moi\n*/\n";
$stylelines = file_get_contents("$site_dir/style.css");
if ($stylelines) {
@@ -635,7 +618,7 @@ function make_site_theme_from_default($theme_name, $template) {
foreach ($stylelines as $line) {
if (strstr($line, "Theme Name:")) $line = "Theme Name: $theme_name";
elseif (strstr($line, "Theme URI:")) $line = "Theme URI: " . __get_option('siteurl');
elseif (strstr($line, "Theme URI:")) $line = "Theme URI: " . get_option('siteurl');
elseif (strstr($line, "Description:")) $line = "Description: Your theme";
elseif (strstr($line, "Version:")) $line = "Version: 1";
elseif (strstr($line, "Author:")) $line = "Author: You";
@@ -665,7 +648,7 @@ function make_site_theme_from_default($theme_name, $template) {
// Create a site theme from the default theme.
function make_site_theme() {
// Name the theme after the blog.
$theme_name = __get_option('blogname');
$theme_name = get_option('blogname');
$template = sanitize_title($theme_name);
$site_dir = ABSPATH . "wp-content/themes/$template";
@@ -696,7 +679,7 @@ function make_site_theme() {
}
// Make the new site theme active.
$current_template = __get_option('template');
$current_template = get_option('template');
if ($current_template == 'default') {
update_option('template', $template);
update_option('stylesheet', $template);

View File

@@ -152,9 +152,9 @@ function populate_options() {
global $wpdb;
$guessurl = preg_replace('|/wp-admin/.*|i', '', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
add_option('siteurl', $guessurl, __('WordPress web address'));
add_option('blogname', __('My Weblog'), __('Blog title'));
add_option('blogdescription', __('Just another WordPress weblog'), __('Short tagline'));
add_option('siteurl', $guessurl, 'WordPress web address');
add_option('blogname', 'My Weblog', 'Blog title');
add_option('blogdescription', 'Just another WordPress weblog', 'Short tagline');
add_option('new_users_can_blog', 0);
add_option('users_can_register', 0);
add_option('admin_email', 'you@example.com');
@@ -183,9 +183,9 @@ function populate_options() {
add_option('default_post_edit_rows', 9);
add_option('posts_per_page', 10);
add_option('what_to_show', 'posts');
add_option('date_format', __('F j, Y'));
add_option('time_format', __('g:i a'));
add_option('links_updated_date_format', __('F j, Y g:i a'));
add_option('date_format', 'F j, Y');
add_option('time_format', 'g:i a');
add_option('links_updated_date_format', 'F j, Y g:i a');
add_option('links_recently_updated_prepend', '<em>');
add_option('links_recently_updated_append', '</em>');
add_option('links_recently_updated_time', 120);
@@ -203,7 +203,7 @@ function populate_options() {
add_option('advanced_edit', 0);
add_option('comment_max_links', 2);
// 1.5
add_option('default_email_category', 1, __('Posts by email go to this category'));
add_option('default_email_category', 1, 'Posts by email go to this category');
add_option('recently_edited');
add_option('use_linksupdate', 0);
add_option('template', 'default');
@@ -215,8 +215,6 @@ function populate_options() {
add_option('open_proxy_check', 1);
add_option('rss_language', 'en');
add_option('html_type', 'text/html');
// 1.5.1
add_option('use_trackback', 0);
// Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url');
@@ -231,4 +229,4 @@ function populate_options() {
endforeach;
}
?>
?>

View File

@@ -1,5 +1,5 @@
<?php
define('WP_INSTALLING', true);
$_wp_installing = 1;
if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. Double check that you updated wp-config-sample.php with the proper database connection information and renamed it to wp-config.php.");
require('../wp-config.php');
timer_start();
@@ -67,8 +67,8 @@ switch($step) {
case 0:
?>
<p><?php _e('This file upgrades you from any previous version of WordPress to the latest. It may take a while though, so be patient.'); ?></p>
<h2 class="step"><a href="upgrade.php?step=1"><?php _e('Upgrade WordPress &raquo;'); ?></a></h2>
<p>This file upgrades you from any previous version of WordPress to the latest. It may take a while though, so be patient.</p>
<h2 class="step"><a href="upgrade.php?step=1">Upgrade WordPress &raquo;</a></h2>
<?php
break;
@@ -76,14 +76,14 @@ switch($step) {
make_db_current_silent();
upgrade_all();
?>
<h2><?php _e('Step 1'); ?></h2>
<p><?php printf(__("There's actually only one step. So if you see this, you're done. <a href='%s'>Have fun</a>!"), '../'); ?></p>
<h2>Step 1</h2>
<p>There's actually only one step. So if you see this, you're done. <a href="../">Have fun</a>! </p>
<!--
<pre>
<?php printf(__('%s queries'), $wpdb->num_queries); ?>
<?php echo $wpdb->num_queries; ?> queries
<?php printf(__('%s seconds'), timer_stop(0)); ?>
<?php timer_stop(1); ?> seconds
</pre>
-->

View File

@@ -213,7 +213,7 @@ $piece_of_code = htmlspecialchars( $piece_of_code );
<p><code><?php echo $piece_of_code; ?></code>
</p>
<p><strong><?php _e('Image Details') ?></strong>: <br />
<?php _e('Name:'); ?>
Name:
<?php echo $img1_name; ?>
<br />
<?php _e('Size:') ?>

View File

@@ -30,28 +30,24 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to
/* checking the nickname has been typed */
if (empty($_POST["new_nickname"])) {
die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)"));
die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your login)"));
return false;
}
$new_user_login = wp_specialchars($_POST['new_user_login']);
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
do_action('check_passwords', array($new_user_login, &$pass1, &$pass2));
if ( '' == $pass1 ) {
if ( '' != $pass2 )
if ($_POST['pass1'] == '') {
if ($_POST['pass2'] != '')
die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
$updatepassword = '';
} else {
if ( '' == $pass2)
if ($_POST['pass2'] == "")
die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
if ( $pass1 != $pass2 )
if ($_POST['pass1'] != $_POST['pass2'])
die (__("<strong>ERROR</strong>: you typed two different passwords. Go back to correct that."));
$new_pass = $pass1;
$new_pass = $_POST["pass1"];
$updatepassword = "user_pass=MD5('$new_pass'), ";
}
$new_user_login = wp_specialchars($_POST['new_user_login']);
$new_firstname = wp_specialchars($_POST['new_firstname']);
$new_lastname = wp_specialchars($_POST['new_lastname']);
$new_nickname = $_POST['new_nickname'];
@@ -99,7 +95,7 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to
<form name="edituser" id="edituser" action="user-edit.php" method="post">
<table width="99%" border="0" cellspacing="2" cellpadding="3">
<tr>
<th width="33%" scope="row"><?php _e('Username:') ?></th>
<th width="33%" scope="row"><?php _e('Login:') ?></th>
<td width="73%"><input type="text" name="new_user_login" id="new_user_login" value="<?php echo $edituser->user_login; ?>" /></td>
</tr>
<tr>
@@ -184,17 +180,12 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to
</select>
</td>
</tr>
<?php
$show_password_fields = apply_filters('show_password_fields', true);
if ( $show_password_fields ) :
?>
<tr>
<th scope="row"><?php _e('New <strong>Password</strong> (Leave blank to stay the same.)') ?></th>
<td><input type="password" name="pass1" size="16" value="" />
<br />
<input type="password" name="pass2" size="16" value="" /></td>
</tr>
<?php endif; ?>
</table>
<p class="submit">
<input type="hidden" name="action" value="update" />
@@ -209,4 +200,4 @@ break;
}
include('admin-footer.php');
?>
?>

View File

@@ -24,33 +24,35 @@ switch ($action) {
case 'adduser':
check_admin_referer();
$user_login = wp_specialchars(trim($_POST['user_login']));
$user_login = wp_specialchars($_POST['user_login']);
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
$user_email = wp_specialchars(trim($_POST['email']));
$user_firstname = wp_specialchars(trim($_POST['firstname']));
$user_lastname = wp_specialchars(trim($_POST['lastname']));
$user_uri = wp_specialchars(trim($_POST['uri']));
$user_email = wp_specialchars($_POST['email']);
$user_firstname = wp_specialchars($_POST['firstname']);
$user_lastname = wp_specialchars($_POST['lastname']);
$user_uri = wp_specialchars($_POST['uri']);
/* checking that username has been typed */
if ($user_login == '')
die (__('<strong>ERROR</strong>: Please enter a username.'));
/* checking login has been typed */
if ($user_login == '') {
die (__('<strong>ERROR</strong>: Please enter a login.'));
}
/* checking the password has been typed twice */
do_action('check_passwords', array($user_login, &$pass1, &$pass2));
if ($pass1 == '' || $pass2 == '')
if ($pass1 == '' || $pass2 == '') {
die (__('<strong>ERROR</strong>: Please enter your password twice.'));
}
/* checking the password has been typed twice the same */
if ($pass1 != $pass2)
if ($pass1 != $pass2) {
die (__('<strong>ERROR</strong>: Please type the same password in the two password fields.'));
}
$user_nickname = $user_login;
/* checking that the username isn't already used by another user */
/* checking the login isn't already used by another user */
$loginthere = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '$user_login'");
if ($loginthere)
die (__('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
if ($loginthere) {
die (__('<strong>ERROR</strong>: This login is already registered, please choose another one.'));
}
/* checking e-mail address */
if (empty($_POST["email"])) {
@@ -72,22 +74,21 @@ case 'adduser':
(user_login, user_pass, user_nickname, user_email, user_ip, user_domain, user_browser, user_registered, user_level, user_idmode, user_firstname, user_lastname, user_nicename, user_url)
VALUES
('$user_login', MD5('$pass1'), '$user_nickname', '$user_email', '$user_ip', '$user_domain', '$user_browser', '$now', '$new_users_can_blog', 'nickname', '$user_firstname', '$user_lastname', '$user_nicename', '$user_uri')");
do_action('user_register', $wpdb->insert_id);
if ($result == false)
if ($result == false) {
die (__('<strong>ERROR</strong>: Couldn&#8217;t register you!'));
}
$stars = '';
for ($i = 0; $i < strlen($pass1); $i = $i + 1)
for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
$stars .= '*';
}
$user_login = stripslashes($user_login);
$message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
$user_login = stripslashes($user_login);
$message = 'New user registration on your blog ' . get_settings('blogname') . ":\r\n\r\n";
$message .= "Login: $user_login\r\n\r\nE-mail: $user_email";
@wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
@wp_mail(get_settings('admin_email'), '[' . get_settings('blogname') . '] New User Registration', $message);
header('Location: users.php');
break;
@@ -98,7 +99,7 @@ case 'promote':
header('Location: users.php');
}
$id = (int) $_GET['id'];
$id = $_GET['id'];
$prom = $_GET['prom'];
$user_data = get_userdata($id);
@@ -110,11 +111,12 @@ case 'promote':
if ('up' == $prom) {
$new_level = $usertopromote_level + 1;
$wpdb->query("UPDATE $wpdb->users SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level");
$sql="UPDATE $wpdb->users SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level";
} elseif ('down' == $prom) {
$new_level = $usertopromote_level - 1;
$wpdb->query("UPDATE $wpdb->users SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level");
$sql="UPDATE $wpdb->users SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level";
}
$result = $wpdb->query($sql);
header('Location: users.php');
@@ -306,17 +308,12 @@ echo "\n<tr $style>
<th scope="row"><?php _e('Website') ?></th>
<td><input name="uri" type="text" id="uri" /></td>
</tr>
<?php
$show_password_fields = apply_filters('show_password_fields', true);
if ( $show_password_fields ) :
?>
<tr>
<th scope="row"><?php _e('Password (twice)') ?> </th>
<td><input name="pass1" type="password" id="pass1" />
<br />
<input name="pass2" type="password" id="pass2" /></td>
</tr>
<?php endif; ?>
</table>
<p class="submit">
<input name="adduser" type="submit" id="adduser" value="<?php _e('Add User') ?> &raquo;" />

View File

@@ -141,14 +141,6 @@ textarea, input, select {
padding: 3px;
}
.alignleft {
float: left
}
.alignright {
float: right;
}
.alternate {
background: #eee;
}
@@ -181,13 +173,6 @@ textarea, input, select {
display: none;
}
.navigation {
display: block;
text-align: center;
margin-top: 10px;
margin-bottom: 30px;
}
.post-categories {
display: inline;
margin: 0;
@@ -296,13 +281,13 @@ textarea, input, select {
#adminmenu2 {
background: #a3a3a3;
border-bottom: none;
height: 21px;
margin: 0;
padding: 3px 2em 0;
padding: 0 2em;
}
#adminmenu2 .current {
background: #f2f2f2;
border-top: 1px solid #9a9a9a;
border-right: 2px solid #4f4f4f;
color: #000;
}
@@ -311,7 +296,7 @@ textarea, input, select {
border: none;
color: #fff;
font-size: 12px;
padding: .3em .4em .33em;
padding: 3px 5px 4px;
}
#adminmenu2 a:hover {
@@ -556,11 +541,3 @@ textarea, input, select {
margin: 0 0 .3em .6em;
padding: 0 0 0 .6em;
}
/* emeyer additions */
.active td {background: #BEB;}
.active .name {background: #9C9;}
.alternate.active td {background: #ADA;}
.alternate.active .name {background: #8B8;}

View File

@@ -20,8 +20,8 @@ $more = 1;
<title><?php bloginfo_rss('name') ?></title>
<link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />
<tagline><?php bloginfo_rss("description") ?></tagline>
<modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></modified>
<copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog'), 0); ?></copyright>
<modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></modified>
<copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></copyright>
<generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
@@ -32,12 +32,18 @@ $more = 1;
<title type="text/html" mode="escaped"><![CDATA[<?php the_title_rss() ?>]]></title>
<link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />
<id><?php the_guid(); ?></id>
<modified><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></modified>
<issued><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></issued>
<?php the_category_rss('rdf') ?>
<summary type="text/plain" mode="escaped"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
<?php if ( !get_settings('rss_use_excerpt') ) : ?>
<modified><?php the_time('Y-m-d\TH:i:s\Z'); ?></modified>
<issued> <?php the_time('Y-m-d\TH:i:s\Z'); ?></issued>
<?php the_category_rss('rdf') ?>
<summary type="<?php bloginfo('html_type'); ?>" mode="escaped"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
<?php if (!get_settings('rss_use_excerpt')) : ?>
<?php if ( strlen( $post->post_content ) ) : ?>
<content type="<?php bloginfo('html_type'); ?>" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
<?php else : ?>
<content type="<?php bloginfo('html_type'); ?>" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></content>
<?php endif; ?>
<?php else : ?>
<content type="<?php bloginfo('html_type'); ?>" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_excerpt_rss() ?>]]></content>
<?php endif; ?>
<?php rss_enclosure(); ?>
</entry>

View File

@@ -17,7 +17,7 @@ $query_vars = array();
if ((isset($_GET['error']) && $_GET['error'] == '404') ||
((! empty($_SERVER['PATH_INFO'])) &&
('/' != $_SERVER['PATH_INFO']) &&
(false === strpos($_SERVER['PATH_INFO'], '.php'))
(false === strpos($_SERVER['PATH_INFO'], 'index.php'))
)) {
// If we match a rewrite rule, this will be cleared.
@@ -85,7 +85,7 @@ if ((isset($_GET['error']) && $_GET['error'] == '404') ||
}
}
$wpvarstoreset = 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');
$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','preview','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');
$wpvarstoreset = apply_filters('query_vars', $wpvarstoreset);
@@ -128,28 +128,24 @@ if ( !empty($error) && '404' == $error ) {
@header('X-Pingback: ' . get_bloginfo('pingback_url'));
// Support for Conditional GET
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) $client_last_modified = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
else $client_last_modified = false;
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)) ) {
(($client_last_modified == $wp_last_modified) && ($client_etag == $wp_etag)) :
(($client_last_modified == $wp_last_modified) || ($client_etag == $wp_etag)) ) {
if ( preg_match('/cgi/',php_sapi_name()) ) {
header('Status: 304 Not Modified');
echo "\r\n\r\n";
exit;
header('Status: 304 Not Modified');
echo "\r\n\r\n";
exit;
} else {
if ( version_compare(phpversion(), '4.3.0', '>=') )
header('Not Modified', TRUE, 304);
else
header('HTTP/1.x 304 Not Modified');
if ( version_compare(phpversion(), '4.3.0', '>=') ) {
header('Not Modified', TRUE, 304);
} else {
header('HTTP/1.x 304 Not Modified');
}
exit;
}
}
@@ -171,15 +167,14 @@ foreach (array_merge($wpvarstoreset, $more_wpvars) as $wpvar) {
$query_string = apply_filters('query_string', $query_string);
update_category_cache();
get_currentuserinfo();
// Call query posts to do the work.
$posts = & query_posts($query_string);
$posts = query_posts($query_string);
// Extract updated query vars back into global namespace.
extract($wp_query->query_vars);
if ( is_single() || is_page() ) {
if (1 == count($posts)) {
$more = 1;
$single = 1;
}
@@ -188,8 +183,8 @@ if ( is_single() || is_page() ) {
// 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($posts)) && !is_404() && !is_search()
&& ( isset($rewrite) || (!empty($_SERVER['QUERY_STRING']) &&
(false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
&& !empty($_SERVER['QUERY_STRING']) &&
(false === strpos($_SERVER['REQUEST_URI'], '?')) ) {
$wp_query->is_404 = true;
if ( preg_match('/cgi/', php_sapi_name()) )
@header('Status: 404 Not Found');
@@ -260,4 +255,4 @@ if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
}
endif;
?>
?>

View File

@@ -3,23 +3,20 @@ require( dirname(__FILE__) . '/wp-config.php' );
$comment_post_ID = (int) $_POST['comment_post_ID'];
$status = $wpdb->get_row("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = '$comment_post_ID'");
$post_status = $wpdb->get_var("SELECT comment_status FROM $wpdb->posts WHERE ID = '$comment_post_ID'");
if ( empty($status->comment_status) ) {
if ( empty($post_status) ) {
do_action('comment_id_not_found', $comment_post_ID);
exit;
} elseif ( 'closed' == $status->comment_status ) {
} elseif ( 'closed' == $post_status ) {
do_action('comment_closed', $comment_post_ID);
die( __('Sorry, comments are closed for this item.') );
} elseif ( 'draft' == $status->post_status ) {
do_action('comment_on_draft', $comment_post_ID);
exit;
}
$comment_author = trim($_POST['author']);
$comment_author_email = trim($_POST['email']);
$comment_author_url = trim($_POST['url']);
$comment_content = trim($_POST['comment']);
$comment_author = $_POST['author'];
$comment_author_email = $_POST['email'];
$comment_author_url = $_POST['url'];
$comment_content = $_POST['comment'];
// If the user is logged in
get_currentuserinfo();
@@ -34,12 +31,8 @@ endif;
$comment_type = '';
if ( get_settings('require_name_email') && !$user_ID ) {
if ( 6 > strlen($comment_author_email) || '' == $comment_author )
die( __('Error: please fill the required fields (name, email).') );
elseif ( !is_email($comment_author_email))
die( __('Error: please enter a valid email address.') );
}
if ( get_settings('require_name_email') && ('' == $comment_author_email || '' == $comment_author) )
die( __('Error: please fill the required fields (name, email).') );
if ( '' == $comment_content )
die( __('Error: please type a comment.') );
@@ -52,12 +45,13 @@ setcookie('comment_author_' . COOKIEHASH, stripslashes($comment_author), time()
setcookie('comment_author_email_' . COOKIEHASH, stripslashes($comment_author_email), time() + 30000000, COOKIEPATH);
setcookie('comment_author_url_' . COOKIEHASH, stripslashes($comment_author_url), time() + 30000000, COOKIEPATH);
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
header('Expires: Mon, 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');
$location = (empty($_POST['redirect_to'])) ? $_SERVER["HTTP_REFERER"] : $_POST['redirect_to'];
$location = get_permalink($comment_post_ID);
header("Location: $location");
wp_redirect($location);
?>

View File

@@ -30,17 +30,17 @@ if (have_posts()) :
<?php
if (is_single() || is_page()) {
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
comment_author_url, comment_date, comment_content, comment_post_ID,
$wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id'
AND $wpdb->comments.comment_approved = '1' AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'static')
AND $wpdb->comments.comment_approved = '1' AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'page')
AND post_date < '".date("Y-m-d H:i:59")."'
ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') );
ORDER BY comment_date LIMIT " . get_settings('posts_per_rss') );
} else { // if no post id passed in, we'll just ue the last 10 comments.
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
comment_author_url, comment_date, comment_content, comment_post_ID,
$wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'static')
LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish'
AND $wpdb->comments.comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s")."'
ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') );
}
@@ -49,14 +49,9 @@ if (have_posts()) :
foreach ($comments as $comment) {
?>
<item>
<title><?php if ( (! is_single()) || (! is_page()) ) {
$title = get_the_title($comment->comment_post_ID);
$title = apply_filters('the_title', $title);
$title = apply_filters('the_title_rss', $title);
echo "Comment on $title";
} ?> by: <?php comment_author_rss() ?></title>
<title>by: <?php comment_author_rss() ?></title>
<link><?php comment_link() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>
<pubDate><?php comment_time('r'); ?></pubDate>
<guid><?php comment_link() ?></guid>
<?php
if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {

View File

@@ -1,21 +1,21 @@
<?php
// ** MySQL settings ** //
define('DB_NAME', 'wordpress'); // The name of the database
define('DB_USER', 'username'); // Your MySQL username
define('DB_PASSWORD', 'password'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
// Change the prefix if you want to have multiple blogs in a single database.
$table_prefix = 'wp_'; // example: 'wp_' or 'b2' or 'mylogin_'
// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-includes/languages.
// For example, install de.mo to wp-includes/languages and set WPLANG to 'de'
// to enable German language support.
define ('WPLANG', '');
/* Stop editing */
define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
<?php
// ** MySQL settings ** //
define('DB_NAME', 'wordpress'); // The name of the database
define('DB_USER', 'username'); // Your MySQL username
define('DB_PASSWORD', 'password'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
// Change the prefix if you want to have multiple blogs in a single database.
$table_prefix = 'wp_'; // example: 'wp_' or 'b2' or 'mylogin_'
// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-includes/languages.
// For example, install de.mo to wp-includes/languages and set WPLANG to 'de'
// to enable German language support.
define ('WPLANG', '');
/* Stop editing */
define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
?>

View File

@@ -45,7 +45,6 @@ if (isset($wp_version)) {
# Add Markdown filter with priority 6 (same as Textile).
add_filter('the_content', 'Markdown', 6);
add_filter('the_excerpt', 'Markdown', 6);
add_filter('the_excerpt_rss', 'Markdown', 6);
add_filter('comment_text', 'Markdown', 6);
}

View File

@@ -70,7 +70,7 @@ POSSIBILITY OF SUCH DAMAGE.
$text = preg_split("/\n/",$text);
foreach($text as $line){
$line = rtrim($line);
$line = trim($line);
$lineout[] = $line;
}

View File

@@ -7,6 +7,6 @@
</div>
<?php wp_footer(); ?>
<?php do_action('wp_footer'); ?>
</body>
</html>

View File

@@ -6,8 +6,8 @@ get_header();
<?php the_date('','<h2>','</h2>'); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<div class="post">
<h3 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> &#8212; <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
<div class="storycontent">
@@ -18,6 +18,10 @@ get_header();
<?php wp_link_pages(); ?>
<?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
</div>
<!--
<?php trackback_rdf(); ?>
-->
</div>

View File

@@ -30,8 +30,8 @@
<div class="navigation">
<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
<div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries') ?></div>
<div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','') ?></div>
</div>
<?php while (have_posts()) : the_post(); ?>
@@ -44,14 +44,17 @@
</div>
<p class="postmetadata">Posted in <?php the_category(', ') ?> <strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
<!--
<?php trackback_rdf(); ?>
-->
</div>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
<div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries') ?></div>
<div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','') ?></div>
</div>
<?php else : ?>

View File

@@ -6,7 +6,7 @@ foreach ($posts as $post) { start_wp();
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo get_settings('blogname'); ?> - Comments on <?php the_title(); ?></title>
<title><?php echo get_settings('blogname'); ?> - <?php echo sprintf(__("Comments on %s"), the_title('','',false)); ?></title>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
<style type="text/css" media="screen">
@@ -19,12 +19,12 @@ foreach ($posts as $post) { start_wp();
<h1 id="header"><a href="" title="<?php echo get_settings('blogname'); ?>"><?php echo get_settings('blogname'); ?></a></h1>
<h2 id="comments">Comments</h2>
<h2 id="comments"><?php _e("Comments"); ?></h2>
<p><a href="<?php echo get_settings('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.</a></p>
<p><a href="<?php echo get_settings('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><?php _e("<abbr title=\"Really Simple Syndication\">RSS</abbr> feed for comments on this post."); ?></a></p>
<?php if ('open' == $post->ping_status) { ?>
<p>The <acronym title="Uniform Resource Identifier">URI</acronym> to TrackBack this entry is: <em><?php trackback_url() ?></em></p>
<p><?php _e("The <acronym title=\"Uniform Resource Identifier\">URI</acronym> to TrackBack this entry is:"); ?> <em><?php trackback_url() ?></em></p>
<?php } ?>
<?php
@@ -43,55 +43,55 @@ if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH
<?php foreach ($comments as $comment) { ?>
<li id="comment-<?php comment_ID() ?>">
<?php comment_text() ?>
<p><cite><?php comment_type('Comment', 'Trackback', 'Pingback'); ?> by <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
<p><cite><?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?> <?php _e("by"); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
</li>
<?php } // end for each comment ?>
</ol>
<?php } else { // this is displayed if there are no comments so far ?>
<p>No comments yet.</p>
<p><?php _e("No comments yet."); ?></p>
<?php } ?>
<?php if ('open' == $commentstatus->comment_status) { ?>
<h2>Leave a comment</h2>
<p>Line and paragraph breaks automatic, e-mail address never displayed, <acronym title="Hypertext Markup Language">HTML</acronym> allowed: <code><?php echo allowed_tags(); ?></code></p>
<h2><?php _e("Leave a comment"); ?></h2>
<p><?php _e("Line and paragraph breaks automatic, e-mail address never displayed, <acronym title=\"Hypertext Markup Language\">HTML</acronym> allowed:"); ?> <code><?php echo allowed_tags(); ?></code></p>
<form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<p>
<input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" />
<label for="author">Name</label>
<label for="author"><?php _e("Name"); ?></label>
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
<input type="hidden" name="redirect_to" value="<?php echo wp_specialchars($_SERVER["REQUEST_URI"]); ?>" />
</p>
<p>
<input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="28" tabindex="2" />
<label for="email">E-mail</label>
<label for="email"><?php _e("E-mail"); ?></label>
</p>
<p>
<input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" />
<label for="url"><acronym title="Uniform Resource Identifier">URI</acronym></label>
<label for="url"><?php _e("<acronym title=\"Uniform Resource Identifier\">URI</acronym>"); ?></label>
</p>
<p>
<label for="comment">Your Comment</label>
<label for="comment"><?php _e("Your Comment"); ?></label>
<br />
<textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
</p>
<p>
<input name="submit" type="submit" tabindex="5" value="Say It!" />
<input name="submit" type="submit" tabindex="5" value="<?php _e("Say It!"); ?>" />
</p>
<?php do_action('comment_form', $post->ID); ?>
</form>
<?php } else { // comments are closed ?>
<p>Sorry, the comment form is closed at this time.</p>
<p><?php _e("Sorry, the comment form is closed at this time."); ?></p>
<?php }
} // end password check
?>
<div><strong><a href="javascript:window.close()">Close this window.</a></strong></div>
<div><strong><a href="javascript:window.close()"><?php _e("Close this window."); ?></a></strong></div>
<?php // if you delete this the sky will fall on your head
}
@@ -99,7 +99,7 @@ if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH
<!-- // this is just the end of the motor - don't touch that line either :) -->
<?php //} ?>
<p class="credit"><?php timer_stop(1); ?> <cite>Powered by <a href="http://wordpress.org" title="Powered by WordPress, state-of-the-art semantic personal publishing platform"><strong>Wordpress</strong></a></cite></p>
<p class="credit"><?php timer_stop(1); ?> <?php echo sprintf(__("<cite>Powered by <a href=\"http://wordpress.org\" title=\"%s\"><strong>Wordpress</strong></a></cite>"),__("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?></p>
<?php // Seen at http://www.mijnkopthee.nl/log2/archive/2003/05/28/esc(18) ?>
<script type="text/javascript">
<!--

View File

@@ -6,7 +6,7 @@
if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
?>
<p class="nocomments">This post is password protected. Enter the password to view comments.<p>
<p class="nocomments"><?php _e("This post is password protected. Enter the password to view comments."); ?><p>
<?php
return;
@@ -50,7 +50,7 @@
<?php else : // this is displayed if there are no comments so far ?>
<?php if ('open' == $post->comment_status) : ?>
<?php if ('open' == $post-> comment_status) : ?>
<!-- If comments are open, but there are no comments. -->
<?php else : // comments are closed ?>
@@ -61,7 +61,7 @@
<?php endif; ?>
<?php if ('open' == $post->comment_status) : ?>
<?php if ('open' == $post-> comment_status) : ?>
<h3 id="respond">Leave a Reply</h3>
@@ -73,15 +73,15 @@
<?php if ( $user_ID ) : ?>
<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Logout &raquo;</a></p>
<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>">Logout &raquo;</a></p>
<?php else : ?>
<p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
<label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
<label for="author"><small>Name <?php if ($req) _e('(required)'); ?></small></label></p>
<p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
<label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>
<label for="email"><small>Mail (will not be published) <?php if ($req) _e('(required)'); ?></small></label></p>
<p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>
@@ -101,4 +101,4 @@
<?php endif; // If registration required and not logged in ?>
<?php endif; // if you delete this the sky will fall on your head ?>
<?php endif; // if you delete this the sky will fall on your head ?>

View File

@@ -14,7 +14,7 @@
<!-- Gorgeous design by Michael Heilemann - http://binarybonsai.com/kubrick/ -->
<?php /* "Just what do you think you're doing Dave?" */ ?>
<?php wp_footer(); ?>
<?php do_action('wp_footer'); ?>
</body>
</html>

View File

@@ -2,50 +2,54 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<style type="text/css" media="screen">
/* To accomodate differing install paths of WordPress, images are referred only here,
and not in the wp-layout.css file. If you prefer to use only CSS for colors and what
not, then go right ahead and delete the following lines, and the image files. */
<style type="text/css" media="screen">
/* BEGIN IMAGE CSS */
/* To accomodate differing install paths of WordPress, images are referred only here,
and not in the wp-layout.css file. If you prefer to use only CSS for colors and what
not, then go right ahead and delete the following lines, and the image files. */
body { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgcolor.jpg"); } <?php /* Checks to see whether it needs a sidebar or not */ if ((! $withcomments) && (! is_single()) && (! is_page())) { ?>
#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg.jpg") repeat-y top; border: none; } <?php } else { // No sidebar ?>
#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; } <?php } ?>
#header { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickheader.jpg") no-repeat bottom center; }
#footer { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickfooter.jpg") no-repeat bottom; border: none;}
/* Because the template is slightly different, size-wise, with images, this needs to be set here
If you don't want to use the template's images, you can also delete the following two lines. */
#header { margin: 0 !important; margin: 0 0 0 1px; padding: 1px; height: 198px; width: 758px; }
#headerimg { margin: 7px 9px 0; height: 192px; width: 740px; }
/* END IMAGE CSS */
body { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgcolor.jpg"); }
<?php /* Checks to see whether it needs a sidebar or not */ if ((! $withcomments) && (! is_single())) { ?>
#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg.jpg") repeat-y top; border: none; }
<?php } else { // No sidebar ?>
#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; }
<?php } ?>
#header { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickheader.jpg") no-repeat bottom center; }
#footer { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickfooter.jpg") no-repeat bottom; border: none;}
/* Because the template is slightly different, size-wise, with images, this needs to be set here
If you don't want to use the template's images, you can also delete the following two lines. */
/* To ease the insertion of a personal header image, I have done it in such a way,
that you simply drop in an image called 'personalheader.jpg' into your /images/
directory. Dimensions should be at least 760px x 200px. Anything above that will
get cropped off of the image. */
#header { margin: 0 !important; margin: 0 0 0 1px; padding: 1px; height: 198px; width: 758px; }
#headerimg { margin: 7px 9px 0; height: 192px; width: 740px; }
/*
#headerimg { background: url('<?php bloginfo('stylesheet_directory'); ?>/images/personalheader.jpg') no-repeat top;}
*/
/* To ease the insertion of a personal header image, I have done it in such a way,
that you simply drop in an image called 'personalheader.jpg' into your /images/
directory. Dimensions should be at least 760px x 200px. Anything above that will
get cropped off of the image. */
/*
#headerimg { background: url('<?php bloginfo('stylesheet_directory'); ?>/images/personalheader.jpg') no-repeat top;}
*/
</style>
</style>
<?php wp_get_archives('type=monthly&format=link'); ?>
<?php wp_get_archives('type=monthly&format=link'); ?>
<?php wp_head(); ?>
<?php wp_head(); ?>
</head>
<body>

View File

@@ -6,28 +6,32 @@
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="post">
<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
<div class="entry">
<?php the_content('Read the rest of this entry &raquo;'); ?>
</div>
<p class="postmetadata">Posted in <?php the_category(', ') ?> <strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
<p class="postmetadata">Posted in <?php the_category(', ') ?> <strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
<!--
<?php trackback_rdf(); ?>
-->
</div>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
<div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries') ?></div>
<div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','') ?></div>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<p class="center"><?php _e("Sorry, but you are looking for something that isn't here."); ?></p>
<?php include (TEMPLATEPATH . "/searchform.php"); ?>
<?php endif; ?>
@@ -36,4 +40,4 @@
<?php get_sidebar(); ?>
<?php get_footer(); ?>
<?php get_footer(); ?>

View File

@@ -3,8 +3,8 @@
<div id="content" class="narrowcolumn">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="post">
<h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
<div class="entrytext">
<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>

View File

@@ -7,8 +7,8 @@
<h2 class="pagetitle">Search Results</h2>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
<div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries') ?></div>
<div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','') ?></div>
</div>
@@ -22,14 +22,18 @@
<?php the_excerpt() ?>
</div>
<p class="postmetadata">Posted in <?php the_category(', ') ?> <strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
<p class="postmetadata">Posted in <?php the_category(', ') ?> <strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
<!--
<?php trackback_rdf(); ?>
-->
</div>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
<div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries') ?></div>
<div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','') ?></div>
</div>
<?php else : ?>

View File

@@ -6,14 +6,13 @@
</li>
<!-- Author information is disabled per default. Uncomment and fill in your details if you want to use it.
<li><h2>Author</h2>
<li><h2><?php _e('Author'); ?></h2>
<p>A little something about you, the author. Nothing lengthy, just an overview.</p>
</li>
-->
<li>
<?php /* If this is a 404 page */ if (is_404()) { ?>
<?php /* If this is a category archive */ } elseif (is_category()) { ?>
<?php /* If this is a category archive */ if (is_category()) { ?>
<p>You are currently browsing the archives for the <?php single_cat_title(''); ?> category.</p>
<?php /* If this is a yearly archive */ } elseif (is_day()) { ?>
@@ -38,30 +37,30 @@
<?php } ?>
</li>
<?php wp_list_pages('title_li=<h2>Pages</h2>' ); ?>
<?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>' ); ?>
<li><h2>Archives</h2>
<li><h2><?php _e('Archives'); ?></h2>
<ul>
<?php wp_get_archives('type=monthly'); ?>
</ul>
</li>
<li><h2>Categories</h2>
<li><h2><?php _e('Categories'); ?></h2>
<ul>
<?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
<?php list_cats(0, '', 'name', 'asc', '', 1, 0, 1, 1, 1, 1, 0,'','','','','') ?>
</ul>
</li>
<?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>
<?php get_links_list(); ?>
<li><h2>Meta</h2>
<li><h2><?php _e('Meta'); ?></h2>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<li><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a></li>
<li><a href="http://validator.w3.org/check/referer" title="<?php _e('This page validates as XHTML 1.0 Transitional'); ?>"><?php _e('Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr>'); ?></a></li>
<li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>
<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>
<li><a href="http://wordpress.org/" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.'); ?>">WordPress</a></li>
<?php wp_meta(); ?>
</ul>
</li>

View File

@@ -5,12 +5,12 @@
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="navigation">
<div class="alignleft"><?php previous_post_link('&laquo; %link') ?></div>
<div class="alignright"><?php next_post_link('%link &raquo;') ?></div>
<div class="alignleft"><?php previous_post('&laquo; %','','yes') ?></div>
<div class="alignright"><?php next_post(' % &raquo;','','yes') ?></div>
</div>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="post">
<h2 id="post-<?php the_ID(); ?>"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="entrytext">
<?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
@@ -30,11 +30,11 @@
<?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
// Both Comments and Pings are open ?>
You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(true); ?>" rel="trackback">trackback</a> from your own site.
You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(display); ?>">trackback</a> from your own site.
<?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
// Only Pings are Open ?>
Responses are currently closed, but you can <a href="<?php trackback_url(true); ?> " rel="trackback">trackback</a> from your own site.
Responses are currently closed, but you can <a href="<?php trackback_url(display); ?> ">trackback</a> from your own site.
<?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
// Comments are open, Pings are not ?>
@@ -56,10 +56,10 @@
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div>
<?php get_footer(); ?>
<?php get_footer(); ?>

View File

@@ -2,7 +2,7 @@
if (empty($doing_rss)) {
$doing_rss = 1;
require(dirname(__FILE__) . '/wp-blog-header.php');
require('wp-blog-header.php');
}
// Remove the pad, if present.
@@ -13,23 +13,20 @@ if ($feed == '' || $feed == 'feed') {
}
if ( is_single() || ($withcomments == 1) ) {
require(ABSPATH . 'wp-commentsrss2.php');
require('wp-commentsrss2.php');
} else {
switch ($feed) {
case 'atom':
require(ABSPATH . 'wp-atom.php');
require('wp-atom.php');
break;
case 'rdf':
require(ABSPATH . 'wp-rdf.php');
require('wp-rdf.php');
break;
case 'rss':
require(ABSPATH . 'wp-rss.php');
require('wp-rss.php');
break;
case 'rss2':
require(ABSPATH . 'wp-rss2.php');
break;
case 'comments-rss2':
require(ABSPATH . 'wp-commentsrss2.php');
require('wp-rss2.php');
break;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -217,7 +217,7 @@ class WP_Query {
$this->query_vars[$query_var] = $value;
}
function &get_posts() {
function get_posts() {
global $wpdb, $pagenow, $request, $user_ID;
// Shorthand.
@@ -249,15 +249,8 @@ class WP_Query {
$q['nopaging'] = false;
}
}
if ( $this->is_feed ) {
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));
@@ -498,18 +491,17 @@ class WP_Query {
}
if ($this->is_page) {
$where .= ' AND (post_status = "static")';
} elseif ($this->is_single) {
$where .= ' AND (post_status != "static")';
$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 .= ')';
}
// Get private posts
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);
@@ -545,31 +537,18 @@ class WP_Query {
$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";
$request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1".$where." ORDER BY post_" . $q['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();
}
}
if ($q['preview']) {
$request = 'SELECT 1-1'; // dummy mysql query for the preview
// little funky fix for IEwin, rawk on that code
$is_winIE = ((preg_match('/MSIE/',$HTTP_USER_AGENT)) && (preg_match('/Win/',$HTTP_USER_AGENT)));
if (($is_winIE) && (!isset($IEWin_bookmarklet_fix))) {
$preview_content = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $preview_content);
}
}
$this->posts = $wpdb->get_results($request);
$this->posts = apply_filters('the_posts', $this->posts);
$this->post_count = count($this->posts);
if ($this->post_count > 0) {
@@ -612,7 +591,7 @@ class WP_Query {
}
}
function &query($query) {
function query($query) {
$this->parse_query($query);
return $this->get_posts();
}
@@ -626,9 +605,11 @@ class WP_Query {
$this->queried_object_id = 0;
if ($this->is_category) {
$category = &get_category($this->get('cat'));
$this->queried_object = &$category;
$this->queried_object_id = $this->get('cat');
global $cache_categories;
if (isset($cache_categories[$this->get('cat')])) {
$this->queried_object = $cache_categories[$this->get('cat')];
$this->queried_object_id = $this->get('cat');
}
} else if ($this->is_single) {
$this->queried_object = $this->post;
$this->queried_object_id = $this->post->ID;
@@ -877,32 +858,24 @@ class WP_Rewrite {
$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;
$this->date_structure = $this->front . $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;
}
if ( false !== strpos($this->permalink_structure, $this->front . '%post_id%') )
$front = $front . 'date/';
if (empty($this->date_structure)) {
$this->date_structure = $front . '%year%/%monthnum%/%day%';
}
$this->date_structure = $front . $date_endian;
return $this->date_structure;
}
@@ -1051,8 +1024,8 @@ class WP_Rewrite {
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 . '|';
foreach ($this->feeds as $feed) {
$feedregex2 .= $feed . '|';
}
$feedregex2 = '(' . trim($feedregex2, '|') . ')/?$';
$feedregex = $this->feed_base . '/' . $feedregex2;
@@ -1128,8 +1101,7 @@ class WP_Rewrite {
$post = 1;
$trackbackmatch = $match . $trackbackregex;
$trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
$match = rtrim($match, '/');
$match = $match . '(/[0-9]+)?/?$';
$match = $match . '?([0-9]+)?/?$';
$query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
} else {
$match .= '?$';

View File

@@ -20,10 +20,8 @@ function comments_template( $file = '/comments.php' ) {
get_currentuserinfo();
define('COMMENTS_TEMPLATE', true);
$include = apply_filters('comments_template', TEMPLATEPATH . $file );
if ( file_exists( $include ) )
require( $include );
if ( file_exists( TEMPLATEPATH . $file ) )
require( TEMPLATEPATH . $file );
else
require( ABSPATH . 'wp-content/themes/default/comments.php');
@@ -42,10 +40,11 @@ function clean_url( $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]);
if (!isset($comment_count_cache[$comment_id]))
$number = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_id' AND comment_approved = '1'");
else
$number = $comment_count_cache[$comment_id];
return apply_filters('get_comments_number', $number);
}
function comments_number( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $number = '' ) {
@@ -93,11 +92,11 @@ function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Com
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 ('' == $comment_count_cache["$id"]) {
$number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");
} else {
$number = $comment_count_cache["$id"];
}
if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) {
echo $none;
return;
@@ -288,13 +287,12 @@ function comment_date( $d = '' ) {
echo get_comment_date( $d );
}
function get_comment_time( $d = '', $gmt = false ) {
function get_comment_time( $d = '' ) {
global $comment;
$comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date;
if ( '' == $d )
$date = mysql2date(get_settings('time_format'), $comment_date);
$date = mysql2date(get_settings('time_format'), $comment->comment_date);
else
$date = mysql2date($d, $comment_date);
$date = mysql2date($d, $comment->comment_date);
return apply_filters('get_comment_time', $date);
}
@@ -355,20 +353,20 @@ function pings_open() {
// Non-template functions
function get_lastcommentmodified($timezone = 'server') {
global $cache_lastcommentmodified, $pagenow, $wpdb;
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 $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
$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 $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
$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 $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
$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;
@@ -467,11 +465,12 @@ function pingback($content, $post_ID) {
// when set to true, this outputs debug messages by itself
$client->debug = false;
$client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto));
if ( $client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto) ) )
add_ping( $post_ID, $pagelinkedto );
else
if ( !$client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto) ) )
debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n");
else
add_ping( $post_ID, $pagelinkedto );
}
}
@@ -480,7 +479,6 @@ function pingback($content, $post_ID) {
}
function discover_pingback_server_uri($url, $timeout_bytes = 2048) {
global $wp_version;
$byte_count = 0;
$contents = '';
@@ -616,6 +614,110 @@ function wp_get_comment_status($comment_id) {
}
}
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 = "New comment on your post #$comment->comment_post_ID \"".$post->post_title."\"\r\n\r\n";
$notify_message .= "Author : $comment->comment_author (IP: $comment->comment_author_IP , $comment_author_domain)\r\n";
$notify_message .= "E-mail : $comment->comment_author_email\r\n";
$notify_message .= "URI : $comment->comment_author_url\r\n";
$notify_message .= "Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=$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 = '[' . $blogname . '] Comment: "' .$post->post_title.'"';
} elseif ('trackback' == $comment_type) {
$notify_message = "New trackback on your post #$comment_post_ID \"".$post->post_title."\"\r\n\r\n";
$notify_message .= "Website: $comment->comment_author (IP: $comment->comment_author_IP , $comment_author_domain)\r\n";
$notify_message .= "URI : $comment->comment_author_url\r\n";
$notify_message .= "Excerpt: \n $comment->comment_content \r\n\r\n";
$notify_message .= "You can see all trackbacks on this post here: \r\n";
$subject = '[' . $blogname . '] Trackback: "' .$post->post_title.'"';
} elseif ('pingback' == $comment_type) {
$notify_message = "New pingback on your post #$comment_post_ID \"".$post->post_title."\"\r\n\r\n";
$notify_message .= "Website: $comment->comment_author\r\n";
$notify_message .= "URI : $comment->comment_author_url\r\n";
$notify_message .= "Excerpt: \n[...] $comment->comment_content [...]\r\n\r\n";
$notify_message .= "You can see all pingbacks on this post here: \r\n";
$subject = '[' . $blogname . '] Pingback: "' .$post->post_title.'"';
}
$notify_message .= get_permalink($comment->comment_post_ID) . '#comments';
$notify_message .= "\r\n\r\nTo delete this comment:\r\n" . get_settings('siteurl') . "/wp-admin/post.php?action=confirmdeletecomment&p=".$comment->comment_post_ID."&comment=$comment_id";
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;
}
}
/* 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");
$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' 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 = "A new comment on the post #$post->ID \"$post->post_title\" is waiting for your approval\r\n";
$notify_message .= get_permalink($comment->comment_post_ID);
$notify_message .= "\n\nAuthor : $comment->comment_author (IP: $comment->comment_author_IP , $comment_author_domain)\r\n";
$notify_message .= "E-mail : $comment->comment_author_email\r\n";
$notify_message .= "URL : $comment->comment_author_url\r\n";
$notify_message .= "Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=$comment->comment_author_IP\r\n";
$notify_message .= "Comment:\r\n".$comment->comment_content."\r\n\r\n";
$notify_message .= "To approve this comment, visit: " . get_settings('siteurl') . "/wp-admin/post.php?action=mailapprovecomment&p=".$comment->comment_post_ID."&comment=$comment_id\r\n";
$notify_message .= "To delete this comment, visit: " . get_settings('siteurl') . "/wp-admin/post.php?action=confirmdeletecomment&p=".$comment->comment_post_ID."&comment=$comment_id\r\n";
$notify_message .= "Currently $comments_waiting comments are waiting for approval. Please visit the moderation panel:\r\n";
$notify_message .= get_settings('siteurl') . "/wp-admin/moderation.php\r\n";
$subject = '[' . get_settings('blogname') . '] Please moderate: "' .$post->post_title.'"';
$admin_email = get_settings("admin_email");
$from = "From: $admin_email";
$message_headers = "MIME-Version: 1.0\n"
. "$from\n"
. "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n";
@wp_mail($admin_email, $subject, $notify_message, $message_headers);
return true;
}
}
function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
global $wpdb;
@@ -625,27 +727,27 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
return false; // Check # of external links
$mod_keys = trim( get_settings('moderation_keys') );
if ( !empty($mod_keys) ) {
$words = explode("\n", $mod_keys );
if ('' == $mod_keys )
return true; // If moderation keys are empty
$words = explode("\n", $mod_keys );
foreach ($words as $word) {
$word = trim($word);
foreach ($words as $word) {
$word = trim($word);
// Skip empty lines
if (empty($word)) { continue; }
// 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, '#');
// 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;
}
$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:
@@ -653,14 +755,10 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
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 )
if ( $wpdb->get_var("SELECT link_id FROM $wpdb->links WHERE link_url LIKE ('%$domain%') LIMIT 1") )
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");
$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' ");
if ( 1 == $ok_to_comment && false === strpos( $email, get_settings('moderation_keys')) )
return true;
else
@@ -673,4 +771,4 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
return true;
}
?>
?>

View File

@@ -48,17 +48,21 @@ add_filter('comment_text', 'make_clickable');
add_filter('comment_text', 'wpautop', 30);
add_filter('comment_text', 'convert_smilies', 20);
add_filter('comment_text_rss', 'htmlspecialchars');
add_filter('comment_excerpt', 'convert_chars');
add_filter('the_excerpt_rss', '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_title_rss', 'strip_tags');
add_filter('the_content', 'convert_smilies');
add_filter('the_content', 'convert_chars');
add_filter('the_content', 'wpautop');
@@ -66,23 +70,11 @@ 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');
?>

View File

@@ -1,12 +1,8 @@
<?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 bloginfo_rss($show='') {
$info = strip_tags(get_bloginfo($show));
echo convert_chars($info);
}
function the_title_rss() {
@@ -73,20 +69,20 @@ function comment_text_rss() {
echo $comment_text;
}
function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = '') {
function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = 'wp-commentsrss2.php') {
$url = comments_rss($commentsrssfilename);
echo "<a href='$url'>$link_text</a>";
}
function comments_rss($commentsrssfilename = '') {
function comments_rss($commentsrssfilename = 'wp-commentsrss2.php') {
global $id;
if ('' != get_settings('permalink_structure'))
$url = trailingslashit( get_permalink() ) . 'feed/';
else
$url = get_settings('home') . "/$commentsrssfilename?feed=rss2&amp;p=$id";
$url = get_settings('siteurl') . "/$commentsrssfilename?p=$id";
return apply_filters('post_comments_feed_link', $url);
return $url;
}
function get_author_rss_link($echo = false, $author_id, $author_nicename) {
@@ -94,30 +90,29 @@ function get_author_rss_link($echo = false, $author_id, $author_nicename) {
$permalink_structure = get_settings('permalink_structure');
if ('' == $permalink_structure) {
$link = get_settings('home') . '?feed=rss2&amp;author=' . $author_id;
$file = get_settings('siteurl') . '/wp-rss2.php';
$link = $file . '?author=' . $author_id;
} else {
$link = get_author_link(0, $author_id, $author_nicename);
$link = $link . "feed/";
$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) {
function get_category_rss_link($echo = false, $category_id, $category_nicename) {
$cat_ID = $category_id;
$permalink_structure = get_settings('permalink_structure');
if ('' == $permalink_structure) {
$link = get_settings('home') . '?feed=rss2&amp;cat=' . $cat_ID;
$file = get_settings('siteurl') . '/wp-rss2.php';
$link = $file . '?cat=' . $category_id;
} else {
$link = get_category_link($cat_ID);
$link = $link . "feed/";
$link = get_category_link($category_id);
$link = $link . "feed/";
}
$link = apply_filters('category_feed_link', $link);
if ($echo) echo $link;
return $link;
}
@@ -137,9 +132,7 @@ function the_category_rss($type = 'rss') {
}
function rss_enclosure() {
global $id, $post;
if (!empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password)) return;
global $id;
$custom_fields = get_post_custom();
if( is_array( $custom_fields ) ) {
while( list( $key, $val ) = each( $custom_fields ) ) {
@@ -147,7 +140,7 @@ function rss_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";
print "<enclosure url='".trim( $enclosure[ 0 ] )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
}
}
}

View File

@@ -10,15 +10,14 @@ function wptexturize($text) {
if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag
$curl = str_replace('---', '&#8212;', $curl);
$curl = str_replace(' -- ', ' &#8212; ', $curl);
$curl = preg_replace('/(\s)--(\s)/', '$1&#8212;$2', $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");
$cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round");
$cockneyreplace = array("&#8217;tain&#8217;t","&#8217;twere","&#8217;twas","&#8217;tis","&#8217;twill","&#8217;til","&#8217;bout","&#8217;nuff","&#8217;round");
$curl = str_replace($cockney, $cockneyreplace, $curl);
$curl = preg_replace("/'s/", '&#8217;s', $curl);
@@ -33,7 +32,7 @@ function wptexturize($text) {
$curl = preg_replace("/ \(tm\)/i", ' &#8482;', $curl);
$curl = str_replace("''", '&#8221;', $curl);
$curl = preg_replace('/(\d+)x(\d+)/', "$1&#215;$2", $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
@@ -58,20 +57,20 @@ 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 = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|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|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>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|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);
$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|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|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('!(</?(?:table|thead|tfoot|caption|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|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);
@@ -142,104 +141,42 @@ function utf8_uri_encode( $utf8_string ) {
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');
$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(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
// TODO: Finish me.
chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
chr(197).chr(189) => 'Z', chr(197).chr(190) => 'z',
// Euro Sign
chr(226).chr(130).chr(172) => 'E');
$string = strtr($string, $chars);
} else {
// Assume ISO-8859-1 if not UTF-8
@@ -682,7 +619,7 @@ function sanitize_email($email) {
function human_time_diff( $from, $to = '' ) {
if ( empty($to) )
$to = time();
$diff = (int) abs($to - $from);
$diff = (int) ($to - $from);
if ($diff <= 3600) {
$mins = round($diff / 60);
if ($mins <= 1)
@@ -705,289 +642,28 @@ function human_time_diff( $from, $to = '' ) {
return $since;
}
function wp_trim_excerpt($text) { // Fakes an excerpt if needed
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);
$text = strip_tags( $text );
$blah = explode(' ', $text);
$excerpt_length = 55;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
if (count($blah) > $excerpt_length) {
$k = $excerpt_length;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
}
$excerpt = '';
for ($i=0; $i<$k; $i++) {
$excerpt .= $blah[$i].' ';
}
$excerpt .= ($use_dotdotdot) ? '[...]' : '';
$text = $excerpt;
} // end if no excerpt
return $text;
}
function ent2ncr($text) {
$to_ncr = array(
'&quot;' => '&#34;',
'&amp;' => '&#38;',
'&frasl;' => '&#47;',
'&lt;' => '&#60;',
'&gt;' => '&#62;',
'&nbsp;' => '&#160;',
'&iexcl;' => '&#161;',
'&cent;' => '&#162;',
'&pound;' => '&#163;',
'&curren;' => '&#164;',
'&yen;' => '&#165;',
'|' => '&#166;',
'&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;
}
?>
?>

View File

@@ -6,17 +6,21 @@
* generic function for inserting data into the posts table.
*/
function wp_insert_post($postarr = array()) {
global $wpdb, $allowedtags;
global $wpdb, $post_default_category, $allowedtags;
// export array as variables
extract($postarr);
// Do some escapes for safety
$post_title = $wpdb->escape($post_title);
$post_name = sanitize_title($post_title);
$post_excerpt = $wpdb->escape($post_excerpt);
$post_content = $wpdb->escape($post_content);
$post_author = (int) $post_author;
// Make sure we set a valid category
if (0 == count($post_category) || !is_array($post_category)) {
$post_category = array(get_option('default_category'));
$post_category = array($post_default_category);
}
$post_cat = $post_category[0];
@@ -103,19 +107,19 @@ function wp_update_post($postarr = array()) {
global $wpdb;
// First get all of the original fields
$post = wp_get_single_post($postarr['ID'], ARRAY_A);
extract(wp_get_single_post($postarr['ID'], ARRAY_A));
// Escape data pulled from DB.
$post = add_magic_quotes($post);
extract($post);
// Now overwrite any changed values being passed in. These are
// already escaped.
// Now overwrite any changed values being passed in
extract($postarr);
// If no categories were passed along, use the current cats.
// Make sure we set a valid category
if ( 0 == count($post_category) || !is_array($post_category) )
$post_category = $post['post_category'];
$post_category = array($post_default_category);
// Do some escapes for safety
$post_title = $wpdb->escape($post_title);
$post_excerpt = $wpdb->escape($post_excerpt);
$post_content = $wpdb->escape($post_content);
$post_modified = current_time('mysql');
$post_modified_gmt = current_time('mysql', 1);
@@ -135,13 +139,12 @@ function wp_update_post($postarr = array()) {
WHERE ID = $ID";
$result = $wpdb->query($sql);
$rows_affected = $wpdb->rows_affected;
wp_set_post_cats('', $ID, $post_category);
do_action('edit_post', $ID);
return $rows_affected;
return $wpdb->rows_affected;
}
function wp_get_post_cats($blogid = '1', $post_ID = 0) {
@@ -154,17 +157,18 @@ function wp_get_post_cats($blogid = '1', $post_ID = 0) {
$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'));
if (!is_array($post_categories)) {
if (!$post_categories) {
$post_categories = 1;
}
$post_categories = array($post_categories);
}
$post_categories = array_unique($post_categories);
@@ -346,10 +350,10 @@ function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
/* 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);
$post_data = get_postdata($post_id);
$post_author_data = get_userdata($post_data['Author_ID']);
if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2))
if ( ($user_id == $post_author_data->ID)
|| ($author_data->user_level > $post_author_data->user_level)
|| ($author_data->user_level >= 10) ) {
return true;
@@ -475,18 +479,6 @@ function wp_new_comment( $commentdata, $spam = false ) {
$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);
@@ -497,17 +489,13 @@ function wp_new_comment( $commentdata, $spam = false ) {
}
}
if ( $userdata && ( $user_id == $post_author || $userdata->user_level >= 9 ) ) {
if ( check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) )
$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';
}
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
@@ -536,18 +524,14 @@ function do_trackbacks($post_id) {
$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) . '...';
$content = strip_tags($post->post_content);
$excerpt = strip_tags($post->post_excerpt);
$post_title = strip_tags($post->post_title);
$post_title = apply_filters('the_title', $post->post_title);
$post_title = strip_tags($post_title);
if ( $excerpt )
$excerpt = substr($excerpt, 0, 252) . '...';
else
$excerpt = substr($content, 0, 252) . '...';
if ($to_ping) : foreach ($to_ping as $tb_ping) :
$tb_ping = trim($tb_ping);
@@ -587,7 +571,7 @@ function get_to_ping($post_id) { // Get any URIs in the todo list
global $wpdb;
$to_ping = $wpdb->get_var("SELECT to_ping FROM $wpdb->posts WHERE ID = $post_id");
$to_ping = trim($to_ping);
$to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY);
$to_ping = preg_split('/\s/', $to_ping);
return $to_ping;
}

File diff suppressed because it is too large Load Diff

443
wp-includes/gettext.php Normal file → Executable file
View File

@@ -1,8 +1,7 @@
<?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
@@ -21,91 +20,44 @@
*/
/**
* 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)
*/
// For start, we only want to read the MO files
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
//public:
var $error = 0; // public variable that holds error code (0 if no error)
//private:
var $BYTEORDER = 0;
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 4 byte value from $FD and puts it in int
// $BYTEORDER specifies the byte order: 0 low endian, 1 big endian
for ($i=0; $i<4; $i++) {
$byte[$i]=ord($this->STREAM->read(1));
}
/**
* 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));
}
//print sprintf("pos: %d\n",$this->STREAM->currentpos());
if ($this->BYTEORDER == 0)
return (int)(($byte[0]) | ($byte[1]<<8) | ($byte[2]<<16) | ($byte[3]<<24));
else
return (int)(($byte[3]) | ($byte[2]<<8) | ($byte[1]<<16) | ($byte[0]<<24));
}
/**
* 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) {
// constructor that requires StreamReader object
function gettext_reader($Reader) {
// If there isn't a StreamReader, turn on short circuit mode.
if (! $Reader) {
$this->short_circuit = true;
return;
$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;
// $MAGIC1 = (int)0x950412de; //bug in PHP 5
$MAGIC1 = (int) - 1794895138;
// $MAGIC2 = (int)0xde120495; //bug
$MAGIC2 = (int) - 569244523;
$this->STREAM = $Reader;
$magic = $this->readint();
@@ -117,242 +69,169 @@ class gettext_reader {
$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);
}
$total = $this->readint();
$originals = $this->readint();
$translations = $this->readint();
$this->total = $total;
$this->originals = $originals;
$this->translations = $translations;
}
/**
* 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?
function load_tables($translations=false) {
// if tables are loaded do not load them again
if (!is_array($this->ORIGINALS)) {
$this->ORIGINALS = array();
$this->STREAM->seekto($this->originals);
for ($i=0; $i<$this->total; $i++) {
$len = $this->readint();
$ofs = $this->readint();
$this->ORIGINALS[] = array($len,$ofs);
}
}
// similar for translations
if ($translations and !is_array($this->TRANSLATIONS)) {
$this->TRANSLATIONS = array();
$this->STREAM->seekto($this->translations);
for ($i=0; $i<$this->total; $i++) {
$len = $this->readint();
$ofs = $this->readint();
$this->TRANSLATIONS[] = array($len,$ofs);
}
}
}
function get_string_number($num) {
// get a string with particular number
// TODO: Add simple hashing [check array, add if not already there]
$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;
$meta = $this->ORIGINALS[$num];
$length = $meta[0];
$offset = $meta[1];
if (! $length) {
return '';
}
$this->STREAM->seekto($offset);
$data = $this->STREAM->read($length);
return (string)$data;
}
function get_translation_number($num) {
// get a string with particular number
// TODO: Add simple hashing [check array, add if not already there]
$this->load_tables(true);
$meta = $this->TRANSLATIONS[$num];
$length = $meta[0];
$offset = $meta[1];
$this->STREAM->seekto($offset);
$data = $this->STREAM->read($length);
return (string)$data;
}
// binary search for string
function find_string($string, $start,$end) {
//print "start: $start, end: $end\n";
if (abs($start-$end)<=1) {
// we're done, if it's not it, bye bye
$txt = $this->get_string_number($start);
if ($string == $txt)
return $start;
else
return -1;
} elseif ($start>$end) {
return $this->find_string($string,$end,$start);
} else {
$half = (int)(($start+$end)/2);
$tst = $this->get_string_number($half);
$cmp = strcmp($string,$tst);
if ($cmp == 0)
return $half;
elseif ($cmp<0)
return $this->find_string($string,$start,$half);
else
return $this->find_string($string,$half,$end);
}
}
function translate($string) {
if ($this->short_circuit) {
return $string;
}
$num = $this->find_string($string, 0, $this->total);
if ($num == -1)
return $string;
else
return $this->get_translation_number($num);
}
function get_plural_forms() {
// lets assume message number 0 is header
// this is true, right?
// cache header field for plural forms
if (is_string($this->pluralheader))
return $this->pluralheader;
else {
$header = $this->get_translation_number(0);
if (eregi("plural-forms: (.*)\n",$header,$regs)) {
$expr = $regs[1];
} else {
$expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
}
$this->pluralheader = $expr;
return $expr;
}
}
/**
* 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;
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;
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];
}
$result = $this->find_string($single.chr(0).$plural,0,$this->total);
if ($result == -1) {
if ($number != 1) return $plural;
else return $single;
} 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];
}
$result = $this->get_translation_number($result);
// lets try to parse all the NUL staff
//$result = "proba0".chr(0)."proba1".chr(0)."proba2";
$list = explode (chr(0), $result);
return $list[$select];
}
}
}
?>
?>

View File

@@ -48,73 +48,43 @@ function bool_from_yn($yn) {
** Parameters:
** category (no default) - The category to use.
**/
function wp_get_linksbyname($category, $args = '') {
global $wpdb;
function wp_get_linksbyname($category) {
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);
}
$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) {
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));
}
} // 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;
function wp_get_links($category) {
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;
get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
}
$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));
}
} // end wp_get_links
/** function get_links()
@@ -198,27 +168,20 @@ function get_links($category = -1, $before = '', $after = '<br />',
if (!$results) {
return;
}
$output = "";
foreach ($results as $row) {
if (!isset($row->recently_updated)) $row->recently_updated = false;
$output .= ($before);
echo($before);
if ($show_updated && $row->recently_updated) {
$output .= get_settings('links_recently_updated_prepend');
echo get_settings('links_recently_updated_prepend');
}
$the_link = '#';
if ( !empty($row->link_url) )
$the_link = wp_specialchars($row->link_url);
if (($row->link_url != null) && ($row->link_url != '')) {
$the_link = $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);
@@ -240,37 +203,27 @@ function get_links($category = -1, $before = '', $after = '<br />',
if ('' != $target) {
$target = " target='$target'";
}
$output.= "<a href='$the_link'";
$output.= $rel . $title . $target;
$output.= '>';
echo("<a href='$the_link'");
echo($rel . $title . $target);
echo('>');
if (($row->link_image != null) && $show_images) {
if (strstr($row->link_image, 'http'))
$output.= "<img src='$row->link_image' $alt $title />";
echo "<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 />";
echo "<img src='" . get_settings('siteurl') . "$row->link_image' $alt $title />";
} else {
$output.= $name;
echo($name);
}
$output.= '</a>';
echo('</a>');
if ($show_updated && $row->recently_updated) {
$output.= get_settings('links_recently_updated_append');
echo get_settings('links_recently_updated_append');
}
if ($show_description && ($desc != '')) {
$output.= $between.$desc;
echo($between.$desc);
}
$output.= "$after\n";
echo("$after\n");
} // end while
if($echo) {
echo $output;
} else {
return $output;
}
}

View File

@@ -1,275 +0,0 @@
<?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_nickname, $user_email, $user_url, $user_pass_md5, $user_identity;
// *** retrieving user's data from cookies and db - no spoofing
if (isset($_COOKIE['wordpressuser_' . COOKIEHASH]))
$user_login = $_COOKIE['wordpressuser_' . COOKIEHASH];
$userdata = get_userdatabylogin($user_login);
$user_level = $userdata->user_level;
$user_ID = $userdata->ID;
$user_nickname = $userdata->user_nickname;
$user_email = $userdata->user_email;
$user_url = $userdata->user_url;
$user_pass_md5 = md5($userdata->user_pass);
$idmode = $userdata->user_idmode;
if ($idmode == 'nickname') $user_identity = $userdata->user_nickname;
if ($idmode == 'login') $user_identity = $userdata->user_login;
if ($idmode == 'firstname') $user_identity = $userdata->user_firstname;
if ($idmode == 'lastname') $user_identity = $userdata->user_lastname;
if ($idmode == 'namefl') $user_identity = $userdata->user_firstname.' '.$userdata->user_lastname;
if ($idmode == 'namelf') $user_identity = $userdata->user_lastname.' '.$userdata->user_firstname;
if (!$idmode) $user_identity = $userdata->user_nickname;
}
endif;
if ( !function_exists('get_userdata') ) :
function get_userdata($userid) {
global $wpdb, $cache_userdata;
$userid = (int) $userid;
if ( empty($cache_userdata[$userid]) && $userid != 0) {
$cache_userdata[$userid] = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = $userid");
$cache_userdata[$cache_userdata[$userid]->user_login] =& $cache_userdata[$userid];
}
return $cache_userdata[$userid];
}
endif;
if ( !function_exists('get_userdatabylogin') ) :
function get_userdatabylogin($user_login) {
global $cache_userdata, $wpdb;
if ( !empty($user_login) && empty($cache_userdata[$user_login]) ) {
$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'"); /* todo: get rid of this intermediate var */
$cache_userdata[$user->ID] = $user;
$cache_userdata[$user_login] =& $cache_userdata[$user->ID];
} else {
$user = $cache_userdata[$user_login];
}
return $user;
}
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])) ) {
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');
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>";
}
$notify_message = apply_filters('comment_notification_text', $notify_message);
$subject = apply_filters('comment_notification_subject', $subject);
$message_headers = apply_filters('comment_notification_headers', $message_headers);
$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");
$notify_message = apply_filters('comment_moderation_text', $notify_message);
$subject = apply_filters('comment_moderation_subject', $subject);
@wp_mail($admin_email, $subject, $notify_message);
return true;
}
endif;
?>

38
wp-includes/streams.php Normal file → Executable file
View File

@@ -1,6 +1,6 @@
<?php
/*
Copyright (c) 2003, 2005 Danilo Segan <danilo@kvota.net>.
Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
This file is part of PHP-gettext.
@@ -103,13 +103,11 @@ class FileReader {
}
function read($bytes) {
if ($bytes) {
fseek($this->_fd, $this->_pos);
$data = fread($this->_fd, $bytes);
$this->_pos = ftell($this->_fd);
return $data;
} else return '';
fseek($this->_fd, $this->_pos);
$data = fread($this->_fd, $bytes);
$this->_pos = ftell($this->_fd);
return $data;
}
function seekto($pos) {
@@ -132,28 +130,4 @@ class FileReader {
}
// 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;
}
}
}
?>

View File

@@ -156,7 +156,7 @@ function wp_list_authors($args = '') {
function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
global $wpdb;
$query = "SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY user_nickname";
$query = "SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_nickname <> 'admin' " : '') . "ORDER BY user_nickname";
$authors = $wpdb->get_results($query);
foreach($authors as $author) {

View File

@@ -1,36 +1,43 @@
<?php
function get_the_category($id = false) {
global $post, $category_cache;
global $post, $wpdb, $category_cache;
if ( !$id )
$id = $post->ID;
if (! $id) {
$id = $post->ID;
}
if ( ! isset($category_cache[$id]) )
update_post_category_cache($id);
if ($category_cache[$id]) {
$categories = $category_cache[$id];
} else {
$categories = $wpdb->get_results("
SELECT category_id, cat_name, category_nicename, category_description, category_parent
FROM $wpdb->categories, $wpdb->post2cat
WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$id'
");
}
$categories = $category_cache[$id];
if (!empty($categories))
sort($categories);
if (!empty($categories))
sort($categories);
else
$categories = array();
return $categories;
return $categories;
}
function get_category_link($category_id) {
global $wp_rewrite;
global $wpdb, $wp_rewrite, $querystring_start, $querystring_equal, $cache_categories;
$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 ($cache_categories[$category_id]->category_nicename)
$category_nicename = $cache_categories[$category_id]->category_nicename;
else
$category_nicename = $wpdb->get_var('SELECT category_nicename FROM ' . $wpdb->categories . ' WHERE cat_ID=' . $category_id);
if ($parent = $category->category_parent)
if ($parent = $cache_categories[$category_id]->category_parent)
$category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/';
$catlink = str_replace('%category%', $category_nicename, $catlink);
@@ -39,10 +46,11 @@ function get_category_link($category_id) {
return apply_filters('category_link', $catlink, $category_id);
}
function get_the_category_list($separator = '', $parents='') {
function the_category($separator = '', $parents='') {
$categories = get_the_category();
if (empty($categories)) {
return apply_filters('the_category', __('Uncategorized'), $separator, $parents);
_e('Uncategorized');
return;
}
$thelist = '';
@@ -56,10 +64,10 @@ function get_the_category_list($separator = '', $parents='') {
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>';
$thelist .= '<a href="' . get_category_link($category->category_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">';
$thelist .= '<a href="' . get_category_link($category->category_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);
}
@@ -67,7 +75,7 @@ function get_the_category_list($separator = '', $parents='') {
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 .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';
}
}
$thelist .= '</ul>';
@@ -79,36 +87,38 @@ function get_the_category_list($separator = '', $parents='') {
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>';
$thelist .= '<a href="' . get_category_link($category->category_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">';
$thelist .= '<a href="' . get_category_link($category->category_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>';
$thelist .= '<a href="' . get_category_link($category->category_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);
echo apply_filters('the_category', $thelist, $separator, $parents);
}
function get_the_category_by_ID($cat_ID) {
$cat_ID = (int) $cat_ID;
$category = &get_category($cat_ID);
return $category->cat_name;
global $cache_categories, $wpdb;
if ( !$cache_categories[$cat_ID] ) {
$cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
$cache_categories[$cat_ID]->cat_name = $cat_name;
} else {
$cat_name = $cache_categories[$cat_ID]->cat_name;
}
return($cat_name);
}
function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
global $cache_categories;
$chain = '';
$parent = &get_category($id);
$parent = $cache_categories[$id];
if ($nicename) {
$name = $parent->category_nicename;
} else {
@@ -124,27 +134,23 @@ function get_category_parents($id, $link = FALSE, $separator = '/', $nicename =
}
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;
global $cache_categories;
$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;
$cat = $categories[0]->category_id;
if ($echo) echo $cat;
@@ -166,10 +172,11 @@ function the_category_head($before='', $after='') {
}
function category_description($category = 0) {
global $cat;
global $cat, $wpdb, $cache_categories;
if (!$category) $category = $cat;
$category = & get_category($category);
return apply_filters('category_description', $category->category_description, $category->cat_ID);
$category_description = $cache_categories[$category]->category_description;
$category_description = apply_filters('category_description', $category_description, $category);
return $category_description;
}
// out of the WordPress loop
@@ -201,9 +208,9 @@ function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_
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";
echo "\t<option value='all'>$all</option>\n";
}
if (intval($optionnone) == 1) echo "\t<option value='-1'>".__('None')."</option>\n";
if (intval($optionnone) == 1) echo "\t<option value='0'>None</option>\n";
if ($categories) {
foreach ($categories as $category) {
$cat_name = apply_filters('list_cats', $category->cat_name, $category);
@@ -262,22 +269,27 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
}
}
$exclusions = apply_filters('list_cats_exclusions', $exclusions);
if ($hide_empty) {
$categories = array();
$extra_fields = 'cat_name, category_nicename, category_description,';
} else {
if (intval($categories)==0 && !$hide_empty){
$sort_column = 'cat_'.$sort_column;
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";
$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);
$categories = $wpdb->get_results($query);
}
$extra_fields = '';
}
if (!count($category_posts)) {
$now = current_time('mysql', 1);
$cat_counts = $wpdb->get_results(" SELECT cat_ID,
$cat_counts = $wpdb->get_results(" SELECT cat_ID, $extra_fields
COUNT($wpdb->post2cat.post_id) AS cat_count
FROM $wpdb->categories
INNER JOIN $wpdb->post2cat ON (cat_ID = category_id)
@@ -289,6 +301,9 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
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 ($hide_empty) {
$categories[] = $cat_count;
}
}
}
}
@@ -393,7 +408,7 @@ function in_category($category) { // Check if the current post is in the given c
global $post, $category_cache;
$cats = '';
foreach ($category_cache[$post->ID] as $cat) :
$cats[] = $cat->cat_ID;
$cats[] = $cat->category_id;
endforeach;
if ( in_array($category, $cats) )
@@ -401,4 +416,4 @@ function in_category($category) { // Check if the current post is in the given c
else
return false;
}
?>
?>

View File

@@ -25,10 +25,10 @@ function get_sidebar() {
function wp_loginout() {
global $user_ID;
global $user_level;
get_currentuserinfo();
if ('' == $user_ID) :
if (0 == $user_level) :
$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>';
@@ -38,13 +38,13 @@ function wp_loginout() {
}
function wp_register( $before = '<li>', $after = '</li>' ) {
global $user_ID;
global $user_level;
get_currentuserinfo();
if ('' == $user_ID && get_settings('users_can_register') ) :
if (0 == $user_level && 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') ) :
elseif (0 == $user_level && !get_settings('users_can_register') ) :
$link = '';
else :
$link = $before . '<a href="' . get_settings('siteurl') . '/wp-admin/">' . __('Site Admin') . '</a>' . $after;
@@ -193,8 +193,8 @@ function single_post_title($prefix = '', $display = true) {
if (!$p) {
$p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$name'");
}
$post = & get_post($p);
$title = $post->post_title;
$post_data = get_postdata($p);
$title = $post_data['Title'];
$title = apply_filters('single_post_title', $title);
if ($display) {
echo $prefix.strip_tags($title);
@@ -205,16 +205,16 @@ function single_post_title($prefix = '', $display = true) {
}
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);
}
}
$cat = 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 ) {
@@ -275,6 +275,11 @@ function get_archives($type='', $limit='', $format='html', $before = '', $after
// this is what will separate dates on weekly archive links
$archive_week_separator = '&#8211;';
// archive link url
$archive_link_m = get_settings('siteurl') . '/?m='; # monthly archive;
$archive_link_w = get_settings('siteurl') . '/?w='; # weekly archive;
$archive_link_p = get_settings('siteurl') . '/?p='; # post-by-post archive;
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
$archive_date_format_over_ride = 0;
@@ -342,11 +347,11 @@ function get_archives($type='', $limit='', $format='html', $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);
$arcresults = $wpdb->get_results("SELECT ID, post_date, post_title 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);
$url = get_permalink($arcresult->ID);
$arc_title = $arcresult->post_title;
if ($arc_title) {
$text = strip_tags($arc_title);

View File

@@ -22,7 +22,9 @@ function permalink_anchor($mode = 'id') {
}
}
function get_permalink($id = 0) {
function get_permalink($id = false) {
global $post, $wpdb;
$rewritecode = array(
'%year%',
'%monthnum%',
@@ -37,24 +39,29 @@ function get_permalink($id = 0) {
'%pagename%'
);
$post = & get_post($id);
if ($post->post_status == 'static') {
return get_page_link($post->ID);
if ($id) {
$idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status, post_author FROM $wpdb->posts WHERE ID = $id");
} else {
$idpost = $post;
}
if ($idpost->post_status == 'static') {
return get_page_link($idpost->ID);
}
$permalink = get_settings('permalink_structure');
if ('' != $permalink && 'draft' != $post->post_status) {
$unixtime = strtotime($post->post_date);
if ('' != $permalink) {
$unixtime = strtotime($idpost->post_date);
$category = '';
if (strstr($permalink, '%category%')) {
$cats = get_the_category($post->ID);
$cats = get_the_category($idpost->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);
$authordata = get_userdata($idpost->post_author);
$author = $authordata->user_nicename;
$rewritereplace =
array(
@@ -64,16 +71,16 @@ function get_permalink($id = 0) {
date('H', $unixtime),
date('i', $unixtime),
date('s', $unixtime),
$post->post_name,
$post->ID,
$idpost->post_name,
$idpost->ID,
$category,
$author,
$post->post_name,
$idpost->post_name,
);
return apply_filters('post_link', get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post);
return apply_filters('post_link', get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink), $idpost);
} else { // if they're not using the fancy permalink option
$permalink = get_settings('home') . '/?p=' . $post->ID;
return apply_filters('post_link', $permalink, $post);
$permalink = get_settings('home') . '/?p=' . $idpost->ID;
return apply_filters('post_link', $permalink, $idpost);
}
}
@@ -161,9 +168,9 @@ function get_feed_link($feed='rss2') {
$output = get_settings('home') . $permalink;
} else {
if ( false !== strpos($feed, 'comments_') )
$feed = str_replace('comments_', 'comments-', $feed);
$feed = str_replace('comments_', 'comments', $feed);
$output = get_settings('home') . "/?feed={$feed}";
$output = get_settings('siteurl') . "/wp-{$feed}.php";
}
return apply_filters('feed_link', $output, $feed);
@@ -198,69 +205,59 @@ function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
// Navigation links
function get_previous_post($in_same_cat = false, $excluded_categories = '') {
global $post, $wpdb;
global $post, $wpdb;
if(! is_single()) {
return null;
}
if(! is_single()) {
return null;
}
$current_post_date = $post->post_date;
$current_post_date = $post->post_date;
$current_category = $post->post_category;
$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 .= ')';
}
$sqlcat = '';
if ($in_same_cat) {
$sqlcat = " AND post_category = '$current_category' ";
}
$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";
}
}
$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");
return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts 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;
global $post, $wpdb;
if(! is_single()) {
return null;
}
if(! is_single()) {
return null;
}
$current_post_date = $post->post_date;
$current_post_date = $post->post_date;
$current_category = $post->post_category;
$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 .= ')';
}
$sqlcat = '';
if ($in_same_cat) {
$sqlcat = " AND post_category = '$current_category' ";
}
$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";
}
}
$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');
$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");
return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts 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 = '') {
@@ -303,113 +300,139 @@ function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat =
echo $format;
}
// Deprecated. Use previous_post_link().
function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
global $id, $post, $wpdb;
global $posts, $posts_per_page, $s;
if ( empty($in_same_cat) || 'no' == $in_same_cat )
$in_same_cat = false;
else
$in_same_cat = true;
if(($posts_per_page == 1) || is_single()) {
$post = get_previous_post($in_same_cat, $excluded_categories);
$current_post_date = $post->post_date;
$current_category = $post->post_category;
if(! $post) {
return;
}
$sqlcat = '';
if ($in_same_cat != 'no') {
$sqlcat = " AND post_category = '$current_category' ";
}
$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;
$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";
}
}
$limitprev--;
$lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1");
if ($lastpost) {
$string = '<a href="'.get_permalink($lastpost->ID).'">'.$previous;
if ($title == 'yes') {
$string .= wptexturize($lastpost->post_title);
}
$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;
global $posts_per_page, $post, $wpdb;
if(1 == $posts_per_page || is_single()) {
$post = get_next_post($in_same_cat, $excluded_categories);
$current_post_date = $post->post_date;
$current_category = $post->post_category;
if(! $post) {
return;
}
$sqlcat = '';
if ($in_same_cat != 'no') {
$sqlcat = " AND post_category='$current_category' ";
}
$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;
$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', 1);
$limitnext--;
$nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts WHERE post_date > '$current_post_date' AND post_date_gmt < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT $limitnext,1");
if ($nextpost) {
$string = '<a href="'.get_permalink($nextpost->ID).'">'.$next;
if ($title=='yes') {
$string .= wptexturize($nextpost->post_title);
}
$string .= '</a>';
$format = str_replace('%', $string, $format);
echo $format;
}
}
}
function get_pagenum_link($pagenum = 1) {
function get_pagenum_link($pagenum = 1){
global $wp_rewrite;
$qstr = $_SERVER['REQUEST_URI'];
$qstr = $_SERVER['REQUEST_URI'];
$page_querystring = "paged";
$page_modstring = "page/";
$page_modregex = "page/?";
$permalink = 0;
$page_querystring = "paged";
$page_modstring = "page/";
$page_modregex = "page/?";
$permalink = 0;
$index = 'index.php';
$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);
$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 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 deffinitely 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')) {
$permalink = 1;
// 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;
}
}
// 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 = 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 );
$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
@@ -425,16 +448,12 @@ function next_posts($max_page = 0) { // original by cfactor at cooltux.org
}
function next_posts_link($label='Next Page &raquo;', $max_page=0) {
global $paged, $result, $request, $posts_per_page, $wpdb, $max_num_pages;
global $paged, $result, $request, $posts_per_page, $wpdb;
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);
}
$max_page = ceil($numposts / $posts_per_page);
}
if (!$paged)
$paged = 1;
@@ -467,21 +486,19 @@ function previous_posts_link($label='&laquo; Previous Page') {
}
function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;') {
global $request, $posts_per_page, $wpdb, $max_num_pages;
global $request, $posts_per_page, $wpdb;
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);
}
preg_match('#FROM (.*) GROUP BY#', $request, $matches);
$fromwhere = $matches[1];
$numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere");
$max_page = ceil($numposts / $posts_per_page);
} else {
$max_num_pages = 999999;
$max_page = 999999;
}
if ($max_num_pages > 1) {
if ($max_page > 1) {
previous_posts_link($prelabel);
echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $sep);
next_posts_link($nxtlabel, $max_page);

View File

@@ -3,7 +3,7 @@
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>
<p><label>' . __("Password:") . ' <input name="post_password" type="text" size="20" /></label> <input type="submit" name="Submit" value="Submit" /></p>
</form>
';
return $output;
@@ -16,7 +16,7 @@ function the_ID() {
function the_title($before = '', $after = '', $echo = true) {
$title = get_the_title();
if ( strlen($title) > 0 ) {
if (!empty($title)) {
$title = apply_filters('the_title', $before . $title . $after, $before, $after);
if ($echo)
echo $title;
@@ -26,23 +26,34 @@ function the_title($before = '', $after = '', $echo = true) {
}
function get_the_title($id = 0) {
$post = &get_post($id);
$title = $post->post_title;
if (!empty($post->post_password))
$title = sprintf(__('Protected: %s'), $title);
global $post, $wpdb;
if ( 0 != $id ) {
$id_post = $wpdb->get_row("SELECT post_title, post_password FROM $wpdb->posts WHERE ID = $id");
$title = $id_post->post_title;
if (!empty($id_post->post_password))
$title = sprintf(__('Protected: %s'), $title);
}
else {
$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);
global $post, $wpdb;
$guid = $post->guid;
if ( 0 != $id )
$guid = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE ID = $id");
$guid = apply_filters('get_the_guid', $guid);
return $guid;
}
function the_guid( $id = 0 ) {
echo get_the_guid($id);
echo get_the_guid();
}
@@ -140,7 +151,7 @@ function link_pages($before='<br />', $after='<br />', $next_or_number='number',
if ('' == get_settings('permalink_structure')) {
echo '<a href="' . get_permalink() . '&amp;page=' . $i . '">';
} else {
echo '<a href="' . trailingslashit( get_permalink() ) . $i . '/">';
echo '<a href="' . get_permalink() . $i . '/">';
}
}
echo $j;
@@ -223,8 +234,6 @@ function get_post_custom_values($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];
}
@@ -250,78 +259,69 @@ function the_meta() {
// Pages
//
function &get_page_children($page_id, $pages) {
global $page_cache;
function get_pages($args = '') {
global $wpdb, $cache_pages;
if ( empty($pages) )
$pages = &$page_cache;
if (!isset($cache_pages) || empty($cache_pages)) {
$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);
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) . ' ';
}
}
}
$dates = ",UNIX_TIMESTAMP(post_modified) AS time_modified";
$dates .= ",UNIX_TIMESTAMP(post_date) AS time_created";
$post_parent = '';
if ($r['child_of']) {
$post_parent = ' AND post_parent=' . $r['child_of'] . ' ';
}
$pages = $wpdb->get_results("SELECT " .
"ID, post_title, post_name, post_parent " .
"$dates " .
"FROM $wpdb->posts " .
"WHERE post_status = 'static' " .
"$post_parent" .
"$exclusions " .
"ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);
$cache_pages = array();
if (count($pages)) {
foreach($pages as $page) {
$cache_pages[$page->ID] = $page;
}
}
}
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;
return $cache_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['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);
$pages = get_pages($args);
if ( $pages ) :
if ( $r['title_li'] )
$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
echo '<li id="pagenav">' . $r['title_li'] . '<ul>';
// Now loop over all pages that were selected
$page_tree = Array();
foreach($pages as $page) {
@@ -336,9 +336,9 @@ function wp_list_pages($args = '') {
// ts field.
if (! empty($r['show_date'])) {
if ('modified' == $r['show_date'])
$page_tree[$page->ID]['ts'] = $page->post_modified;
$page_tree[$page->ID]['ts'] = $page->time_modified;
else
$page_tree[$page->ID]['ts'] = $page->post_date;
$page_tree[$page->ID]['ts'] = $page->time_created;
}
// The tricky bit!!
@@ -346,31 +346,21 @@ function wp_list_pages($args = '') {
// 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;
$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);
_page_level_out($r['child_of'],$page_tree, $r);
if ( $r['title_li'] )
$output .= '</ul></li>';
echo '</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) {
function _page_level_out($parent, $page_tree, $args, $depth = 0) {
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"));
@@ -384,13 +374,13 @@ function _page_level_out($parent, $page_tree, $args, $depth = 0, $echo = true) {
$css_class .= ' current_page_item';
}
$output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>';
echo $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']);
echo " " . gmdate($format,$cur_page['ts']);
}
echo "\n";
@@ -398,17 +388,13 @@ function _page_level_out($parent, $page_tree, $args, $depth = 0, $echo = true) {
$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";
echo "$indent<ul>\n";
_page_level_out($page_id,$page_tree, $args, $new_depth);
echo "$indent</ul>\n";
}
}
$output .= "$indent</li>\n";
echo "$indent</li>\n";
}
if ( $echo )
echo $output;
else
return $output;
}
?>

View File

@@ -35,7 +35,6 @@ $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)) {

View File

@@ -1,7 +1,7 @@
<?php
// This just holds the version number, in a separate file so we can bump it without cluttering the SVN
// This just holds the version number, in a separate file so we can bump it without cluttering the CVS
$wp_version = '1.5.2';
$wp_version = '1.5';
?>
?>

View File

@@ -44,7 +44,7 @@ class wpdb {
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>
<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>.</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>
@@ -69,7 +69,7 @@ class wpdb {
<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>");
<p>If you continue to have connection problems you should contact your host. If all else fails you may find help at the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>");
}
}
@@ -301,7 +301,6 @@ class wpdb {
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">

View File

@@ -1,8 +1,8 @@
<?php
if ( defined('WPLANG') && '' != constant('WPLANG') ) {
include_once(ABSPATH . 'wp-includes/streams.php');
include_once(ABSPATH . 'wp-includes/gettext.php');
require_once(ABSPATH . 'wp-includes/streams.php');
require_once(ABSPATH . 'wp-includes/gettext.php');
}
function get_locale() {
@@ -54,10 +54,7 @@ function __ngettext($single, $plural, $number, $domain = 'default') {
if (isset($l10n[$domain])) {
return $l10n[$domain]->ngettext($single, $plural, $number);
} else {
if ($number != 1)
return $plural;
else
return $single;
return $text;
}
}
@@ -69,7 +66,7 @@ function load_textdomain($domain, $mofile) {
}
if ( is_readable($mofile)) {
$input = new CachedFileReader($mofile);
$input = new FileReader($mofile);
} else {
return;
}

View File

@@ -28,7 +28,7 @@ if ((empty($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
<body>
<?php $sql = "SELECT $wpdb->links.link_url, link_rss, $wpdb->links.link_name, $wpdb->links.link_category, $wpdb->linkcategories.cat_name, link_updated
FROM $wpdb->links
JOIN $wpdb->linkcategories on $wpdb->links.link_category = $wpdb->linkcategories.cat_id
LEFT JOIN $wpdb->linkcategories on $wpdb->links.link_category = $wpdb->linkcategories.cat_id
$sql_cat
ORDER BY $wpdb->linkcategories.cat_name, $wpdb->links.link_name \n";
//echo("<!-- $sql -->");

View File

@@ -8,7 +8,6 @@ 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');
header('Pragma: no-cache');
header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
if ( defined('RELOCATE') ) { // Move flag is set
if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
@@ -24,18 +23,18 @@ case 'logout':
wp_clearcookie();
do_action('wp_logout');
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
header('Expires: Mon, 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');
wp_redirect('wp-login.php');
header('Location: wp-login.php');
exit();
break;
case 'lostpassword':
do_action('lost_password');
?>
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@@ -67,9 +66,9 @@ if ($error)
<form name="lostpass" action="wp-login.php" method="post" id="lostpass">
<p>
<input type="hidden" name="action" value="retrievepassword" />
<label><?php _e('Username:') ?><br />
<label><?php _e('Login') ?>:<br />
<input type="text" name="user_login" id="user_login" value="" size="20" tabindex="1" /></label></p>
<p><label><?php _e('E-mail:') ?><br />
<p><label><?php _e('E-mail') ?>:<br />
<input type="text" name="email" id="email" value="" size="25" tabindex="2" /></label><br />
</p>
<p class="submit"><input type="submit" name="submit" id="submit" value="<?php _e('Retrieve Password'); ?> &raquo;" tabindex="3" /></p>
@@ -96,20 +95,18 @@ case 'retrievepassword':
if (!$user_email || $user_email != $_POST['email'])
die(sprintf(__('Sorry, that user does not seem to exist in our database. Perhaps you have the wrong username or e-mail address? <a href="%s">Try again</a>.'), 'wp-login.php?action=lostpassword'));
do_action('retreive_password', $user_login); // Misspelled and deprecated.
do_action('retrieve_password', $user_login);
// Generate something random for a password... md5'ing current time with a rand salt
$key = substr( md5( uniqid( microtime() ) ), 0, 50);
// now insert the new pass md5'd into the db
$wpdb->query("UPDATE $wpdb->users SET user_activation_key = '$key' WHERE user_login = '$user_login'");
$message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
$message .= get_option('siteurl') . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
$message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key=$key\r\n";
$message .= __("Someone has asked to reset a password for the login this site\n\n " . get_option('siteurl') ) . "\n\n";
$message .= __('Login') . ": $user_login\r\n\r\n";
$message .= __("To reset your password visit the following address, otherwise just ignore this email and nothing will happen.\n\n");
$message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key=$key";
$m = wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_settings('blogname')), $message);
$m = wp_mail($user_email, sprintf(__("[%s] Password Reset"), get_settings('blogname')), $message);
do_action('retreive_password', $user_login);
if ($m == false) {
echo '<p>' . __('The e-mail could not be sent.') . "<br />\n";
@@ -127,32 +124,29 @@ case 'resetpass' :
// Generate something random for a password... md5'ing current time with a rand salt
$key = $_GET['key'];
if ( empty($key) )
die( __('Sorry, that key does not appear to be valid.') );
$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_activation_key = '$key'");
if ( !$user )
die( __('Sorry, that key does not appear to be valid.') );
do_action('password_reset');
$new_pass = substr( md5( uniqid( microtime() ) ), 0, 7);
$wpdb->query("UPDATE $wpdb->users SET user_pass = MD5('$new_pass'), user_activation_key = '' WHERE user_login = '$user->user_login'");
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
$message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
$message .= get_settings('siteurl') . "/wp-login.php\r\n";
$message = __('Login') . ": $user->user_login\r\n";
$message .= __('Password') . ": $new_pass\r\n";
$message .= get_settings('siteurl') . '/wp-login.php';
$m = wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_settings('blogname')), $message);
$m = wp_mail($user->user_email, sprintf(__("[%s] Your new password"), get_settings('blogname')), $message);
do_action('password_reset');
if ($m == false) {
echo '<p>' . __('The e-mail could not be sent.') . "<br />\n";
echo __('Possible reason: your host may have disabled the mail() function...') . '</p>';
echo '<p>' . __('The e-mail could not be sent.') . "<br />\n";
echo __('Possible reason: your host may have disabled the mail() function...') . "</p>";
die();
} else {
echo '<p>' . sprintf(__('Your new password is in the mail.'), $user_login) . '<br />';
echo '<p>' . sprintf(__("Your new password is in the mail."), $user_login) . '<br />';
echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course') . "'>" . __('Click here to login!') . '</a></p>';
// send a copy of password change notification to the admin
$message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
wp_mail(get_settings('admin_email'), sprintf(__('[%s] Password Lost/Change'), get_settings('blogname')), $message);
wp_mail(get_settings('admin_email'), sprintf(__('[%s] Password Lost/Change'), get_settings('blogname')), sprintf(__('Password Lost and Changed for user: %s'), $user->user_login));
die();
}
break;
@@ -178,8 +172,6 @@ default:
}
}
do_action('wp_authenticate', array(&$user_login, &$user_pass));
if ($user_login && $user_pass) {
$user = get_userdatabylogin($user_login);
if ( 0 == $user->user_level )
@@ -190,7 +182,7 @@ default:
wp_setcookie($user_login, $user_pass);
}
do_action('wp_login', $user_login);
wp_redirect($redirect_to);
header("Location: $redirect_to");
exit();
} else {
if ($using_cookie)
@@ -228,8 +220,8 @@ if ( $error )
?>
<form name="loginform" id="loginform" action="wp-login.php" method="post">
<p><label><?php _e('Username:') ?><br /><input type="text" name="log" id="log" value="" size="20" tabindex="1" /></label></p>
<p><label><?php _e('Password:') ?><br /> <input type="password" name="pwd" id="pwd" value="" size="20" tabindex="2" /></label></p>
<p><label><?php _e('Login') ?>:<br /><input type="text" name="log" id="log" value="" size="20" tabindex="1" /></label></p>
<p><label><?php _e('Password') ?>:<br /> <input type="password" name="pwd" id="pwd" value="" size="20" tabindex="2" /></label></p>
<p class="submit">
<input type="submit" name="submit" id="submit" value="<?php _e('Login'); ?> &raquo;" tabindex="3" />
<input type="hidden" name="redirect_to" value="<?php echo $redirect_to; ?>" />
@@ -250,4 +242,4 @@ if ( $error )
break;
} // end action switch
?>
?>

View File

@@ -7,5 +7,6 @@ if ( get_magic_quotes_gpc() )
// 10 days
setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH);
wp_redirect($_SERVER['HTTP_REFERER']);
header('Location: ' . $_SERVER['HTTP_REFERER']);
?>

View File

@@ -25,7 +25,7 @@ $more = 1;
<title><?php bloginfo_rss('name') ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss('description') ?></description>
<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date>
<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></dc:date>
<admin:generatorAgent rdf:resource="http://wordpress.org/?v=<?php echo $wp_version ?>"/>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
@@ -42,7 +42,7 @@ $more = 1;
<item rdf:about="<?php permalink_single_rss() ?>">
<title><?php the_title_rss() ?></title>
<link><?php permalink_single_rss() ?></link>
<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_date_gmt, false); ?></dc:date>
<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_date_gmt); ?></dc:date>
<dc:creator><?php the_author() ?></dc:creator>
<?php the_category_rss('rdf') ?>
<?php if (get_settings('rss_use_excerpt')) : ?>

View File

@@ -17,10 +17,9 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
}
if ( !get_settings('users_can_register') )
if (!get_settings('users_can_register')) {
$action = 'disabled';
header( 'Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset') );
}
switch($action) {
@@ -29,9 +28,9 @@ case 'register':
$user_login = $_POST['user_login'];
$user_email = $_POST['user_email'];
/* checking that username has been typed */
/* checking login has been typed */
if ($user_login == '') {
die (__('<strong>ERROR</strong>: Please enter a username.'));
die (__('<strong>ERROR</strong>: Please enter a login.'));
}
/* checking e-mail address */
@@ -41,10 +40,10 @@ case 'register':
die (__('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
}
/* checking the username isn't already used by another user */
/* checking the login isn't already used by another user */
$result = $wpdb->get_results("SELECT user_login FROM $wpdb->users WHERE user_login = '$user_login'");
if (count($result) >= 1) {
die (__('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
die (__('<strong>ERROR</strong>: This login is already registered, please choose another one.'));
}
$user_ip = $_SERVER['REMOTE_ADDR'] ;
@@ -55,7 +54,7 @@ case 'register':
$user_nickname = $user_login;
$user_nicename = sanitize_title($user_nickname);
$now = gmdate('Y-m-d H:i:s');
$user_level = get_settings('new_users_can_blog');
if (get_settings('new_users_can_blog') >= 1) $user_level = 1;
$password = substr( md5( uniqid( microtime() ) ), 0, 7);
$result = $wpdb->query("INSERT INTO $wpdb->users
@@ -74,15 +73,13 @@ case 'register':
$stars .= '*';
}
$message = sprintf(__('Username: %s'), $user_login) . "\r\n";
$message .= sprintf(__('Password: %s'), $password) . "\r\n";
$message .= get_settings('siteurl') . "/wp-login.php\r\n";
$message = __('Login') . ": $user_login\r\n";
$message .= __('Password') . ": $password\r\n";
$message .= get_settings('siteurl') . '/wp-login.php';
wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
wp_mail($user_email, sprintf(__("[%s] Your login information"), get_settings('blogname')), $message);
$message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
$message = sprintf(__("New user registration on your blog %1\$s:\n\nLogin: %2\$s \n\nE-mail: %3\$s"), get_settings('blogname'), $user_login, $user_email);
@wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
@@ -103,9 +100,9 @@ case 'register':
<div id="login">
<h2><?php _e('Registration Complete') ?></h2>
<p><?php printf(__('Username: %s'), "<strong>$user_login</strong>") ?><br />
<?php printf(__('Password: %s'), '<strong>' . __('emailed to you') . '</strong>') ?> <br />
<?php printf(__('E-mail: %s'), "<strong>$user_email</strong>") ?></p>
<p><?php _e('Login:') ?> <strong><?php echo $user_login; ?></strong><br />
<?php _e('Password:') ?> <strong>emailed to you</strong><br />
<?php _e('E-mail:') ?> <strong><?php echo $user_email; ?></strong></p>
<p class="submit"><a href="wp-login.php"><?php _e('Login'); ?> &raquo;</a></p>
</div>
</body>
@@ -163,8 +160,8 @@ default:
<form method="post" action="wp-register.php" id="registerform">
<p><input type="hidden" name="action" value="register" />
<label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" /><br /></p>
<p><label for="user_email"><?php _e('E-mail:') ?></label><br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" /></p>
<label for="user_login"><?php _e('Login:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" /><br /></p>
<p><label for="user_email"><?php _e('E-mail') ?></label>:<br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" /></p>
<p>A password will be emailed to you.</p>
<p class="submit"><input type="submit" value="<?php _e('Register') ?> &raquo;" id="submit" name="submit" /></p>
</form>
@@ -181,4 +178,4 @@ default:
break;
}
?>
?>

View File

@@ -18,7 +18,7 @@ $more = 1;
<title><?php bloginfo_rss('name') ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss('description') ?></description>
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), 0); ?></lastBuildDate>
<docs>http://backend.userland.com/rss092</docs>
<language><?php echo get_option('rss_language'); ?></language>

View File

@@ -24,7 +24,7 @@ $more = 1;
<title><?php bloginfo_rss('name'); ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss("description") ?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), 0); ?></pubDate>
<generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
<language><?php echo get_option('rss_language'); ?></language>
@@ -33,7 +33,7 @@ $more = 1;
<title><?php the_title_rss() ?></title>
<link><?php permalink_single_rss() ?></link>
<comments><?php comments_link(); ?></comments>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_the_time('Y-m-d H:i:s')); ?></pubDate>
<dc:creator><?php the_author() ?></dc:creator>
<?php the_category_rss() ?>

View File

@@ -1,27 +1,7 @@
<?php
// Turn register globals off
function unregister_GLOBALS() {
if ( !ini_get('register_globals') )
return;
if ( isset($_REQUEST['GLOBALS']) )
die('GLOBALS overwrite attempt detected');
// Variables that shouldn't be unset
$noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
$input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
foreach ( $input as $k => $v )
if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) )
unset($GLOBALS[$k]);
}
unregister_GLOBALS();
$HTTP_HOST = getenv('HTTP_HOST'); /* domain name */
$REMOTE_ADDR = getenv('REMOTE_ADDR'); /* visitor's IP */
$HTTP_USER_AGENT = getenv('HTTP_USER_AGENT'); /* visitor's browser */
unset( $wp_filter, $cache_userdata, $cache_lastcommentmodified, $cache_lastpostdate, $cache_settings, $category_cache, $cache_categories );
// Fix for IIS, which doesn't set REQUEST_URI
if (! isset($_SERVER['REQUEST_URI'])) {
@@ -89,12 +69,12 @@ require (ABSPATH . WPINC . '/default-filters.php');
require_once (ABSPATH . WPINC . '/wp-l10n.php');
$wpdb->hide_errors();
if ( !update_user_cache() && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) {
if ( !update_user_cache() && !strstr($_SERVER['PHP_SELF'], 'install.php') ) {
if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
$link = 'install.php';
else
$link = 'wp-admin/install.php';
die(sprintf(__("It doesn't look like you've installed WP yet. Try running <a href='%s'>install.php</a>."), $link));
die("It doesn't look like you've installed WP yet. Try running <a href='$link'>install.php</a>.");
}
$wpdb->show_errors();
@@ -130,16 +110,12 @@ if (get_settings('hack_file')) {
if ( get_settings('active_plugins') ) {
$current_plugins = get_settings('active_plugins');
if ( is_array($current_plugins) ) {
foreach ($current_plugins as $plugin) {
if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
}
foreach ($current_plugins as $plugin) {
if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
}
}
require (ABSPATH . WPINC . '/pluggable-functions.php');
if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
wp_cache_postload();
@@ -167,4 +143,4 @@ register_shutdown_function('shutdown_action_hook');
// Everything is loaded.
do_action('init');
?>
?>

View File

@@ -27,9 +27,9 @@ function trackback_response($error = 0, $error_message = '') {
// trackback is done by a POST
$request_array = 'HTTP_POST_VARS';
if ( !$_GET['tb_id'] ) {
if (!$tb_id) {
$tb_id = explode('/', $_SERVER['REQUEST_URI']);
$tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
$tb_id = intval($tb_id[count($tb_id)-1]);
}
$tb_url = $_POST['url'];
@@ -41,7 +41,7 @@ $charset = $_POST['charset'];
if ($charset)
$charset = strtoupper( trim($charset) );
else
$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
$charset = 'auto';
if ( function_exists('mb_convert_encoding') ) { // For international trackbacks
$title = mb_convert_encoding($title, get_settings('blog_charset'), $charset);
@@ -52,7 +52,7 @@ if ( function_exists('mb_convert_encoding') ) { // For international trackbacks
if ( is_single() || is_page() )
$tb_id = $posts[0]->ID;
if ( !intval( $tb_id ) )
if ( !$tb_id )
trackback_response(1, 'I really need an ID for this to work.');
if (empty($title) && empty($tb_url) && empty($blog_name)) {
@@ -66,7 +66,7 @@ if ( !empty($tb_url) && !empty($title) && !empty($tb_url) ) {
$pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
if ( 'open' != $pingstatus )
if ('open' != $pingstatus)
trackback_response(1, 'Sorry, trackbacks are closed for this item.');
$title = wp_specialchars( strip_tags( $title ) );

View File

@@ -10,6 +10,7 @@ include_once(ABSPATH . WPINC . '/class-IXR.php');
// error_reporting(0);
$post_default_title = ""; // posts submitted via the xmlrpc interface get that title
$post_default_category = 1; // posts submitted via the xmlrpc interface go into that category
$xmlrpc_logging = 0;
@@ -126,19 +127,8 @@ class wp_xmlrpc_server extends IXR_Server {
return true;
}
function escape(&$array) {
global $wpdb;
foreach ($array as $k => $v) {
if (is_array($v)) {
$this->escape($array[$k]);
} else if (is_object($v)) {
//skip
} else {
$array[$k] = $wpdb->escape($v);
}
}
}
/* Blogger API functions
* specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
@@ -148,8 +138,6 @@ class wp_xmlrpc_server extends IXR_Server {
/* blogger.getUsersBlogs will make more sense once we support multiple blogs */
function blogger_getUsersBlogs($args) {
$this->escape($args);
$user_login = $args[1];
$user_pass = $args[2];
@@ -174,8 +162,6 @@ class wp_xmlrpc_server extends IXR_Server {
/* blogger.getUsersInfo gives your client some info about you, so you don't have to */
function blogger_getUserInfo($args) {
$this->escape($args);
$user_login = $args[1];
$user_pass = $args[2];
@@ -201,8 +187,6 @@ class wp_xmlrpc_server extends IXR_Server {
/* blogger.getPost ...gets a post */
function blogger_getPost($args) {
$this->escape($args);
$post_ID = $args[1];
$user_login = $args[2];
$user_pass = $args[3];
@@ -236,8 +220,6 @@ class wp_xmlrpc_server extends IXR_Server {
global $wpdb;
$this->escape($args);
$blog_ID = $args[1]; /* though we don't use it yet */
$user_login = $args[2];
$user_pass = $args[3];
@@ -284,8 +266,6 @@ class wp_xmlrpc_server extends IXR_Server {
/* blogger.getTemplate returns your blog_filename */
function blogger_getTemplate($args) {
$this->escape($args);
$blog_ID = $args[1];
$user_login = $args[2];
$user_pass = $args[3];
@@ -319,8 +299,6 @@ class wp_xmlrpc_server extends IXR_Server {
/* blogger.setTemplate updates the content of blog_filename */
function blogger_setTemplate($args) {
$this->escape($args);
$blog_ID = $args[1];
$user_login = $args[2];
$user_pass = $args[3];
@@ -357,8 +335,6 @@ class wp_xmlrpc_server extends IXR_Server {
global $wpdb;
$this->escape($args);
$blog_ID = $args[1]; /* though we don't use it yet */
$user_login = $args[2];
$user_pass = $args[3];
@@ -406,8 +382,6 @@ class wp_xmlrpc_server extends IXR_Server {
global $wpdb;
$this->escape($args);
$post_ID = $args[1];
$user_login = $args[2];
$user_pass = $args[3];
@@ -424,8 +398,6 @@ class wp_xmlrpc_server extends IXR_Server {
return new IXR_Error(404, 'Sorry, no such post.');
}
$this->escape($actual_post);
$post_author_data = get_userdata($actual_post['post_author']);
$user_data = get_userdatabylogin($user_login);
@@ -434,7 +406,6 @@ class wp_xmlrpc_server extends IXR_Server {
}
extract($actual_post);
$content = $newcontent;
$post_title = xmlrpc_getposttitle($content);
@@ -460,8 +431,6 @@ class wp_xmlrpc_server extends IXR_Server {
global $wpdb;
$this->escape($args);
$post_ID = $args[1];
$user_login = $args[2];
$user_pass = $args[3];
@@ -501,9 +470,7 @@ class wp_xmlrpc_server extends IXR_Server {
/* metaweblog.newPost creates a post */
function mw_newPost($args) {
global $wpdb, $post_default_category;
$this->escape($args);
global $wpdb;
$blog_ID = $args[0]; // we will support this in the near future
$user_login = $args[1];
@@ -540,9 +507,7 @@ class wp_xmlrpc_server extends IXR_Server {
if ($post_more) {
$post_content = $post_content . "\n<!--more-->\n" . $post_more;
}
$to_ping = $content_struct['mt_tb_ping_urls'];
// Do some timestamp voodoo
$dateCreatedd = $content_struct['dateCreated'];
if (!empty($dateCreatedd)) {
@@ -558,14 +523,16 @@ class wp_xmlrpc_server extends IXR_Server {
logIO('O', 'Post cats: ' . printr($catnames,true));
$post_category = array();
if (is_array($catnames)) {
if ($catnames) {
foreach ($catnames as $cat) {
$post_category[] = get_cat_ID($cat);
}
} else {
$post_category[] = 1;
}
// We've got all the data -- post it:
$postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping');
$postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status');
$post_ID = wp_insert_post($postdata);
@@ -576,14 +543,7 @@ class wp_xmlrpc_server extends IXR_Server {
logIO('O', "Posted ! ID: $post_ID");
// FIXME: do we pingback always? pingback($content, $post_ID);
// trackback_url_list($content_struct['mt_tb_ping_urls'],$post_ID);
if ('publish' == $post_status) {
if ($post_pingback) pingback($content, $post_ID);
do_enclose( $content, $post_ID );
do_trackbacks($post_ID);
do_action('publish_post', $post_ID);
}
trackback_url_list($content_struct['mt_tb_ping_urls'],$post_ID);
return strval($post_ID);
}
@@ -592,9 +552,7 @@ class wp_xmlrpc_server extends IXR_Server {
/* metaweblog.editPost ...edits a post */
function mw_editPost($args) {
global $wpdb, $post_default_category;
$this->escape($args);
global $wpdb;
$post_ID = $args[0];
$user_login = $args[1];
@@ -613,15 +571,12 @@ class wp_xmlrpc_server extends IXR_Server {
$postdata = wp_get_single_post($post_ID, ARRAY_A);
extract($postdata);
$this->escape($postdata);
$post_title = $content_struct['title'];
$post_content = apply_filters( 'content_save_pre', $content_struct['description'] );
$catnames = $content_struct['categories'];
$post_category = array();
if (is_array($catnames)) {
if ($catnames) {
foreach ($catnames as $cat) {
$post_category[] = get_cat_ID($cat);
}
@@ -635,8 +590,6 @@ class wp_xmlrpc_server extends IXR_Server {
$post_content = $post_content . "\n<!--more-->\n" . $post_more;
}
$to_ping = $content_struct['mt_tb_ping_urls'];
$comment_status = (empty($content_struct['mt_allow_comments'])) ?
get_settings('default_comment_status')
: $content_struct['mt_allow_comments'];
@@ -657,24 +610,17 @@ class wp_xmlrpc_server extends IXR_Server {
}
// We've got all the data -- post it:
$newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping');
$newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt');
$result = wp_update_post($newpost);
if (!$result) {
$post_ID = wp_update_post($newpost);
if (!$post_ID) {
return new IXR_Error(500, 'Sorry, your entry could not be edited. Something wrong happened.');
}
logIO('O',"(MW) Edited ! ID: $post_ID");
// FIXME: do we pingback always? pingback($content, $post_ID);
// trackback_url_list($content_struct['mt_tb_ping_urls'], $post_ID);
if ('publish' == $post_status) {
if ($post_pingback) pingback($content, $post_ID);
do_enclose( $content, $post_ID );
do_trackbacks($post_ID);
do_action('publish_post', $post_ID);
}
do_action('edit_post', $post_ID);
trackback_url_list($content_struct['mt_tb_ping_urls'], $post_ID);
return true;
}
@@ -685,8 +631,6 @@ class wp_xmlrpc_server extends IXR_Server {
global $wpdb;
$this->escape($args);
$post_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
@@ -740,8 +684,6 @@ class wp_xmlrpc_server extends IXR_Server {
/* metaweblog.getRecentPosts ...returns recent posts */
function mw_getRecentPosts($args) {
$this->escape($args);
$blog_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
@@ -806,8 +748,6 @@ class wp_xmlrpc_server extends IXR_Server {
global $wpdb;
$this->escape($args);
$blog_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
@@ -840,11 +780,9 @@ class wp_xmlrpc_server extends IXR_Server {
// adapted from a patch by Johann Richard
// http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/
global $wpdb;
$blog_ID = $wpdb->escape($args[0]);
$user_login = $wpdb->escape($args[1]);
$user_pass = $wpdb->escape($args[2]);
$blog_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
$data = $args[3];
$name = $data['name'];
@@ -921,8 +859,6 @@ class wp_xmlrpc_server extends IXR_Server {
/* mt.getRecentPostTitles ...returns recent posts' titles */
function mt_getRecentPostTitles($args) {
$this->escape($args);
$blog_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
@@ -966,8 +902,6 @@ class wp_xmlrpc_server extends IXR_Server {
global $wpdb;
$this->escape($args);
$blog_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
@@ -995,8 +929,6 @@ class wp_xmlrpc_server extends IXR_Server {
/* mt.getPostCategories ...returns a post's categories */
function mt_getPostCategories($args) {
$this->escape($args);
$post_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
@@ -1025,8 +957,6 @@ class wp_xmlrpc_server extends IXR_Server {
/* mt.setPostCategories ...sets a post's categories */
function mt_setPostCategories($args) {
$this->escape($args);
$post_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
@@ -1109,8 +1039,6 @@ class wp_xmlrpc_server extends IXR_Server {
/* mt.publishPost ...sets a post's publish status to 'publish' */
function mt_publishPost($args) {
$this->escape($args);
$post_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
@@ -1131,7 +1059,6 @@ class wp_xmlrpc_server extends IXR_Server {
// retain old cats
$cats = wp_get_post_cats('',$post_ID);
$postdata['post_category'] = $cats;
$this->escape($postdata);
$result = wp_update_post($postdata);
@@ -1146,10 +1073,10 @@ class wp_xmlrpc_server extends IXR_Server {
/* pingback.ping gets a pingback and registers it */
function pingback_ping($args) {
// original code by Mort (http://mort.mine.nu:8080 -- site seems dead)
// refactored to return error codes and avoid deep ifififif headaches
global $wpdb, $wp_version;
$this->escape($args);
$pagelinkedfrom = $args[0];
$pagelinkedto = $args[1];
@@ -1162,8 +1089,10 @@ class wp_xmlrpc_server extends IXR_Server {
// Check if the page linked to is in our site
$pos1 = strpos($pagelinkedto, str_replace('http://', '', str_replace('www.', '', get_settings('home'))));
if( !$pos1 )
return new IXR_Error(0, 'Is there no link to us?');
if(!$pos1) {
return new IXR_Error(0, '');
}
// let's find which post is linked to
// FIXME: does url_to_postid() cover all these cases already?
@@ -1193,7 +1122,7 @@ class wp_xmlrpc_server extends IXR_Server {
$way = 'from the fragment (post-###)';
} elseif (is_string($urltest['fragment'])) {
// ...or a string #title, a little more complicated
$title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']);
$title = preg_replace('/[^a-zA-Z0-9]/', '.', $urltest['fragment']);
$sql = "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE '$title'";
if (! ($post_ID = $wpdb->get_var($sql)) ) {
// returning unknown error '0' is better than die()ing
@@ -1205,74 +1134,86 @@ class wp_xmlrpc_server extends IXR_Server {
// TODO: Attempt to extract a post ID from the given URL
return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
}
$post_ID = (int) $post_ID;
logIO("O","(PB) URI='$pagelinkedto' ID='$post_ID' Found='$way'");
$post = get_post($post_ID);
$sql = 'SELECT post_author FROM '.$wpdb->posts.' WHERE ID = '.$post_ID;
$result = $wpdb->get_results($sql);
if ( !$post ) // Post_ID not found
if (!$wpdb->num_rows) {
// Post_ID not found
return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
}
// Check if pings are on
if ( 'closed' == $post->ping_status )
return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
// Let's check that the remote site didn't already pingback this entry
$result = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_ID' AND comment_author_url = '$pagelinkedfrom'");
if ( $wpdb->num_rows ) // We already have a Pingback from this URL
if ($wpdb->num_rows) {
// We already have a Pingback from this URL
return new IXR_Error(48, 'The pingback has already been registered.');
}
// very stupid, but gives time to the 'from' server to publish !
sleep(1);
// Let's check the remote site
$linea = wp_remote_fopen( $pagelinkedfrom );
if ( !$linea )
$fp = @fopen($pagelinkedfrom, 'r');
if (!$fp) {
// The source URI does not exist
return new IXR_Error(16, 'The source URI does not exist.');
// Work around bug in strip_tags():
$linea = str_replace('<!DOC', '<DOC', $linea);
$linea = preg_replace( '/[\s\r\n\t]+/', ' ', $linea ); // normalize spaces
$linea = preg_replace( "/ <(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/", "\n\n", $linea );
preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
$title = $matchtitle[1];
if ( empty( $title ) )
return new IXR_Error(32, 'We cannot find a title on that page.');
$linea = strip_tags( $linea, '<a>' ); // just keep the tag we need
$p = explode( "\n\n", $linea );
$sem_regexp_pb = "/(\\/|\\\|\*|\?|\+|\.|\^|\\$|\(|\)|\[|\]|\||\{|\})/";
$sem_regexp_fix = "\\\\$1";
$link = preg_replace( $sem_regexp_pb, $sem_regexp_fix, $pagelinkedfrom );
$finished = false;
foreach ( $p as $para ) {
if ( $finished )
continue;
if ( strstr( $para, $pagelinkedto ) ) {
$context = preg_replace( "/.*<a[^>]+".$link."[^>]*>([^>]+)<\/a>.*/", "$1", $para );
$excerpt = strip_tags( $para );
$excerpt = trim( $excerpt );
$use = preg_quote( $context );
$excerpt = preg_replace("|.*?\s(.{0,100}$use.{0,100})\s|s", "$1", $excerpt);
$finished = true;
}
}
if ( empty($context) ) // URL pattern not found
return new IXR_Error(17, 'The source URI does not contain a link to the target URI, and so cannot be used as a source.');
$puntero = 4096;
while($remote_read = fread($fp, $puntero)) {
$linea .= $remote_read;
}
// Work around bug in strip_tags():
$linea = str_replace('<!DOCTYPE','<DOCTYPE',$linea);
$linea = strip_tags($linea, '<title><a>');
$linea = strip_all_but_one_link($linea, $pagelinkedto);
// I don't think we need this? -- emc3
//$linea = preg_replace('#&([^amp\;])#is', '&amp;$1', $linea);
if (empty($matchtitle)) {
preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
}
$pos2 = strpos($linea, $pagelinkedto);
$pos3 = strpos($linea, str_replace('http://www.', 'http://', $pagelinkedto));
if (is_integer($pos2) || is_integer($pos3)) {
// The page really links to us :)
$pos4 = (is_integer($pos2)) ? $pos2 : $pos3;
$start = $pos4-100;
$context = substr($linea, $start, 250);
$context = str_replace("\n", ' ', $context);
$context = str_replace('&amp;', '&', $context);
}
fclose($fp);
if (empty($context)) {
// URL pattern not found
return new IXR_Error(17, 'The source URI does not contain a link to the target URI, and so cannot be used as a source.');
}
// Check if pings are on
$pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $post_ID");
if ('closed' == $pingstatus) {
return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
}
$pagelinkedfrom = preg_replace('#&([^amp\;])#is', '&amp;$1', $pagelinkedfrom);
$context = '[...] ' . wp_specialchars( $excerpt ) . ' [...]';
$title = (!strlen($matchtitle[1])) ? $pagelinkedfrom : $matchtitle[1];
$original_context = strip_tags($context);
$context = '[...] ';
$context .= wp_specialchars($original_context);
$context .= ' [...]';
$original_pagelinkedfrom = $pagelinkedfrom;
$pagelinkedfrom = addslashes( $pagelinkedfrom );
$pagelinkedfrom = addslashes($pagelinkedfrom);
$original_title = $title;
$comment_post_ID = $post_ID;
@@ -1281,6 +1222,11 @@ class wp_xmlrpc_server extends IXR_Server {
$comment_content = $context;
$comment_type = 'pingback';
$pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $post_ID");
if ('open' != $pingstatus)
die('Sorry, pingbacks are closed for this item.');
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_content', 'comment_type');
wp_new_comment($commentdata);
@@ -1297,8 +1243,6 @@ class wp_xmlrpc_server extends IXR_Server {
global $wpdb;
$this->escape($args);
$url = $args;
$post_ID = url_to_postid($url);
@@ -1333,4 +1277,4 @@ class wp_xmlrpc_server extends IXR_Server {
$wp_xmlrpc_server = new wp_xmlrpc_server();
?>
?>