Compare commits

..

1 Commits
2.0.2 ... 2.0

Author SHA1 Message Date
ryan
8f98a559c1 WordPress 2.0
git-svn-id: http://svn.automattic.com/wordpress/tags/2.0@3363 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2005-12-26 21:35:22 +00:00
77 changed files with 964 additions and 2277 deletions

View File

@@ -8,12 +8,5 @@
</div>
<?php do_action('admin_footer', ''); ?>
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
<?php
if ( (substr(php_sapi_name(), 0, 3) == 'cgi') && spawn_pinger() ) {
echo '<iframe id="pingcheck" src="' . get_settings('siteurl') .'/wp-admin/execute-pings.php?time=' . time() . '" style="border:none;width:1px;height:1px;"></iframe>';
}
?>
</body>
</html>
</html>

View File

@@ -43,12 +43,6 @@ function write_post() {
if ('static' == $_POST['post_status'] && !current_user_can('edit_pages'))
die(__('This user cannot edit pages.'));
if (!isset ($_POST['comment_status']))
$_POST['comment_status'] = 'closed';
if (!isset ($_POST['ping_status']))
$_POST['ping_status'] = 'closed';
if (!empty ($_POST['edit_date'])) {
$aa = $_POST['aa'];
$mm = $_POST['mm'];
@@ -90,12 +84,12 @@ function relocate_children($old_ID, $new_ID) {
function fix_attachment_links($post_ID) {
global $wp_rewrite;
$post = & get_post($post_ID, ARRAY_A);
$post = & get_post($post_ID);
$search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
// See if we have any rel="attachment" links
if ( 0 == preg_match_all($search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER) )
if ( 0 == preg_match_all($search, $post->post_content, $anchor_matches, PREG_PATTERN_ORDER) )
return;
$i = 0;
@@ -107,11 +101,9 @@ function fix_attachment_links($post_ID) {
$id = $id_matches[2];
// While we have the attachment ID, let's adopt any orphans.
$attachment = & get_post($id, ARRAY_A);
if ( ! empty($attachment) && ! is_object(get_post($attachment['post_parent'])) ) {
$attachment['post_parent'] = $post_ID;
// Escape data pulled from DB.
$attachment = add_magic_quotes($attachment);
$attachment = & get_post($id);
if ( ! is_object(get_post($attachment->post_parent)) ) {
$attachment->post_parent = $post_ID;
wp_update_post($attachment);
}
@@ -120,10 +112,7 @@ function fix_attachment_links($post_ID) {
++$i;
}
$post['post_content'] = str_replace($post_search, $post_replace, $post['post_content']);
// Escape data pulled from DB.
$post = add_magic_quotes($post);
$post->post_content = str_replace($post_search, $post_replace, $post->post_content);
return wp_update_post($post);
}
@@ -340,13 +329,13 @@ function add_user() {
}
function edit_user($user_id = 0) {
global $current_user, $wp_roles, $wpdb;
global $current_user, $wp_roles;
if ($user_id != 0) {
$update = true;
$user->ID = $user_id;
$userdata = get_userdata($user_id);
$user->user_login = $wpdb->escape($userdata->user_login);
$user->user_login = $userdata->user_login;
} else {
$update = false;
$user = '';
@@ -417,9 +406,6 @@ function edit_user($user_id = 0) {
if (!empty ($pass1))
$user->user_pass = $pass1;
if ( !validate_username($user->user_login) )
$errors['user_login'] = __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.');
if (!$update && username_exists($user->user_login))
$errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
@@ -593,6 +579,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
foreach ($categories as $category) {
if ($category->category_parent == $parent) {
$category->cat_name = wp_specialchars($category->cat_name);
$count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
$pad = str_repeat('&#8212; ', $level);
if ( current_user_can('manage_categories') ) {
$edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
@@ -609,7 +596,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
$class = ('alternate' == $class) ? '' : 'alternate';
echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td>
<td>$category->category_description</td>
<td>$category->category_count</td>
<td>$count</td>
<td>$edit</td>
</tr>";
cat_rows($category->cat_ID, $level +1, $categories);
@@ -976,6 +963,14 @@ function touch_time($edit = 1, $for_post = 1) {
}
function check_admin_referer() {
$adminurl = strtolower(get_settings('siteurl')).'/wp-admin';
$referer = strtolower($_SERVER['HTTP_REFERER']);
if (!strstr($referer, $adminurl))
die(__('Sorry, you need to <a href="http://codex.wordpress.org/Enable_Sending_Referrers">enable sending referrers</a> for this feature to work.'));
do_action('check_admin_referer');
}
// insert_with_markers: Owen Winkler, fixed by Eric Anderson
// Inserts an array of strings into a file (.htaccess), placing it between
// BEGIN and END markers. Replaces existing marked info. Retains surrounding
@@ -1254,9 +1249,7 @@ function get_admin_page_title() {
return $title;
}
$hook = get_plugin_page_hook($plugin_page, $pagenow);
$parent = $parent1 = get_admin_page_parent();
$parent = get_admin_page_parent();
if (empty ($parent)) {
foreach ($menu as $menu_array) {
if (isset ($menu_array[3])) {
@@ -1264,7 +1257,7 @@ function get_admin_page_title() {
$title = $menu_array[3];
return $menu_array[3];
} else
if (isset ($plugin_page) && ($plugin_page == $menu_array[2]) && ($hook == $menu_array[3])) {
if (isset ($plugin_page) && ($plugin_page == $menu_array[2])) {
$title = $menu_array[3];
return $menu_array[3];
}
@@ -1278,7 +1271,7 @@ function get_admin_page_title() {
$title = $submenu_array[3];
return $submenu_array[3];
} else
if (isset ($plugin_page) && ($plugin_page == $submenu_array[2]) && (($parent == $pagenow) || ($parent == $plugin_page) || ($plugin_page == $hook) || (($pagenow == 'admin.php') && ($parent1 != $submenu_array[2])))) {
if (isset ($plugin_page) && ($plugin_page == $submenu_array[2])) {
$title = $submenu_array[3];
return $submenu_array[3];
}
@@ -1621,7 +1614,6 @@ function get_importers() {
function current_theme_info() {
$themes = get_themes();
$current_theme = get_current_theme();
$ct->name = $current_theme;
$ct->title = $themes[$current_theme]['Title'];
$ct->version = $themes[$current_theme]['Version'];
$ct->parent_theme = $themes[$current_theme]['Parent Theme'];
@@ -1676,7 +1668,7 @@ function wp_handle_upload(&$file, $overrides = false) {
'avi' => 'video/avi',
'mov|qt' => 'video/quicktime',
'mpeg|mpg|mpe' => 'video/mpeg',
'txt|c|cc|h' => 'text/plain',
'txt|c|cc|h|php' => 'text/plain',
'rtx' => 'text/richtext',
'css' => 'text/css',
'htm|html' => 'text/html',
@@ -1727,7 +1719,7 @@ function wp_handle_upload(&$file, $overrides = false) {
return $upload_error_handler($file, __('File is empty. Please upload something more substantial.'));
// A properly uploaded file will pass this test. There should be no reason to override this one.
if (! @ is_uploaded_file($file['tmp_name']) )
if (! is_uploaded_file($file['tmp_name']) )
return $upload_error_handler($file, __('Specified file failed upload test.'));
// A correct MIME type will pass this test.
@@ -1755,28 +1747,19 @@ function wp_handle_upload(&$file, $overrides = false) {
$filename = $unique_filename_callback($uploads['path'], $file['name']);
} else {
$number = '';
$filename = str_replace('#', '_', $file['name']);
$filename = str_replace(array('\\', "'"), '', $filename);
if ( empty($ext) )
$ext = '';
else
$ext = ".$ext";
while ( file_exists($uploads['path'] . "/$filename") ) {
if ( '' == "$number$ext" )
$filename = $filename . ++$number . $ext;
else
$filename = str_replace("$number$ext", ++$number . $ext, $filename);
}
$filename = $file['name'];
while ( file_exists($uploads['path'] . "/$filename") )
$filename = str_replace("$number.$ext", ++$number . ".$ext", $filename);
}
// Move the file to the uploads dir
$new_file = $uploads['path'] . "/$filename";
if ( false === @ move_uploaded_file($file['tmp_name'], $new_file) )
if ( false === move_uploaded_file($file['tmp_name'], $new_file) )
die(printf(__('The uploaded file could not be moved to %s.'), $file['path']));
// Set correct file permissions
$stat = stat(dirname($new_file));
$perms = $stat['mode'] & 0000666;
$perms = $stat['mode'] & 0000777;
@ chmod($new_file, $perms);
// Compute the URL

View File

@@ -1,67 +1,324 @@
<?php
@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
if (!isset($_GET["page"])) require_once('admin.php');
if ( $editing ) {
$dbx_js = true;
if ( current_user_can('manage_categories') )
$cat_js = true;
}
if ( $list_js || $cat_js )
$sack_js = true;
?>
if (!isset($_GET["page"])) require_once('admin.php'); ?>
<?php get_admin_page_title(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
<link rel="stylesheet" href="<?php echo get_settings('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
<script type="text/javascript">
//<![CDATA[
function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
function addLoadEvent(func) {
if ( typeof wpOnload != 'function' ) {
wpOnload = func;
} else {
var oldonload = wpOnload;
wpOnload = function() {
oldonload();
func();
}
}
}
<?php if ( isset($xfn) ) : ?>
function GetElementsWithClassName(elementName, className) {
var allElements = document.getElementsByTagName(elementName);
var elemColl = new Array();
for (i = 0; i < allElements.length; i++) {
if (allElements[i].className == className) {
elemColl[elemColl.length] = allElements[i];
}
}
return elemColl;
}
function meChecked() {
var undefined;
var eMe = document.getElementById('me');
if (eMe == undefined) return false;
else return eMe.checked;
}
function upit() {
var isMe = meChecked(); //document.getElementById('me').checked;
var inputColl = GetElementsWithClassName('input', 'valinp');
var results = document.getElementById('link_rel');
var linkText, linkUrl, inputs = '';
for (i = 0; i < inputColl.length; i++) {
inputColl[i].disabled = isMe;
inputColl[i].parentNode.className = isMe ? 'disabled' : '';
if (!isMe && inputColl[i].checked && inputColl[i].value != '') {
inputs += inputColl[i].value + ' ';
}
}
inputs = inputs.substr(0,inputs.length - 1);
if (isMe) inputs='me';
results.value = inputs;
}
function blurry() {
if (!document.getElementById) return;
var aInputs = document.getElementsByTagName('input');
for (var i = 0; i < aInputs.length; i++) {
aInputs[i].onclick = aInputs[i].onkeyup = upit;
}
}
addLoadEvent(blurry);
<?php endif; ?>
//]]>
</script>
<script type="text/javascript" src="../wp-includes/js/fat.js"></script>
<?php if ( $xfn_js ) { ?>
<script type="text/javascript" src="xfn.js"></script>
<?php } ?>
<?php if ( $sack_js ) { ?>
<script type="text/javascript" src="../wp-includes/js/tw-sack.js"></script>
<?php } ?>
<?php if ( $list_js ) { ?>
<script type="text/javascript" src="list-manipulation.js"></script>
<?php } ?>
<?php if ( $dbx_js ) { ?>
<?php if ( isset( $editing ) ) : ?>
<?php if ( $editing && user_can_richedit() ) : ?>
<script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20051211"></script>
<?php endif; ?>
<script type="text/javascript" src="../wp-includes/js/dbx.js"></script>
<script type="text/javascript">
//<![CDATA[
addLoadEvent( function() {
addLoadEvent( function() {
<?php switch ( $pagenow ) : case 'post.php' : ?>
var manager = new dbxManager('postmeta');
var manager = new dbxManager('postmeta'); //session ID [/-_a-zA-Z0-9/]
<?php break; case 'page-new.php' : ?>
var manager = new dbxManager('pagemeta');
var manager = new dbxManager('pagemeta'); //session ID [/-_a-zA-Z0-9/]
<?php break; endswitch; ?>
});
});
//]]>
</script>
<script type="text/javascript" src="../wp-includes/js/dbx-key.js"></script>
<?php } ?>
<?php if ( $editing && user_can_richedit() ) { ?>
<script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20051211"></script>
<?php } ?>
<?php if ( $cat_js ) { ?>
<script type="text/javascript" src="cat-js.php"></script>
<?php } ?>
<?php if ( current_user_can('manage_categories') ) : ?>
<style type="text/css">
#newcat { width: 120px; margin-right: 5px; }
input#catadd { background: #a4a4a4;
border-bottom: 1px solid #898989;
border-left: 1px solid #bcbcbc;
border-right: 1px solid #898989;
border-top: 1px solid #bcbcbc;
color: #fff;
font-size: 10px;
padding: 0;
margin: 0;
font-weight: bold;
height: 20px;
margin-bottom: 2px;
text-align: center;
width: 37px; }
#howto {
font-size: 11px;
margin: 0 5px;
display: block;
}
#jaxcat {
margin: 0;
padding: 0;
}
</style>
<script type="text/javascript">
//<![CDATA[
var ajaxCat = new sack();
var newcat;
function newCatAddIn() {
if ( !document.getElementById('jaxcat') ) return false;
var ajaxcat = document.createElement('p');
ajaxcat.id = 'ajaxcat';
newcat = document.createElement('input');
newcat.type = 'text';
newcat.name = 'newcat';
newcat.id = 'newcat';
newcat.size = '16';
newcat.setAttribute('autocomplete', 'off');
newcat.onkeypress = ajaxNewCatKeyPress;
var newcatSub = document.createElement('input');
newcatSub.type = 'button';
newcatSub.name = 'Button';
newcatSub.id = 'catadd';
newcatSub.value = '<?php echo addslashes(__('Add')); ?>';
newcatSub.onclick = ajaxNewCat;
ajaxcat.appendChild(newcat);
ajaxcat.appendChild(newcatSub);
document.getElementById('jaxcat').appendChild(ajaxcat);
howto = document.createElement('span');
howto.innerHTML = '<?php echo addslashes(__('Separate multiple categories with commas.')); ?>';
howto.id = 'howto';
ajaxcat.appendChild(howto);
}
addLoadEvent(newCatAddIn);
function getResponseElement() {
var p = document.getElementById('ajaxcatresponse');
if (!p) {
p = document.createElement('span');
document.getElementById('jaxcat').appendChild(p);
p.id = 'ajaxcatresponse';
}
return p;
}
function newCatLoading() {
var p = getResponseElement();
p.innerHTML = '<?php echo addslashes(__('Sending Data...')); ?>';
}
function newCatLoaded() {
var p = getResponseElement();
p.innerHTML = '<?php echo addslashes(__('Data Sent...')); ?>';
}
function newCatInteractive() {
var p = getResponseElement();
p.innerHTML = '<?php echo addslashes(__('Processing Request...')); ?>';
}
function newCatCompletion() {
var p = getResponseElement();
var id = 0;
var ids = new Array();
var names = new Array();
ids = myPload( ajaxCat.response );
names = myPload( newcat.value );
for ( i = 0; i < ids.length; i++ ) {
id = ids[i].replace(/[\n\r\l]+/g, "");
if ( id == '-1' ) {
p.innerHTML = "<?php echo addslashes(__("You don't have permission to do that.")); ?>";
return;
}
if ( id == '0' ) {
p.innerHTML = "<?php echo addslashes(__('That category name is invalid. Try something else.')); ?>";
return;
}
var exists = document.getElementById('category-' + id);
if (exists) {
var moveIt = exists.parentNode;
var container = moveIt.parentNode;
container.removeChild(moveIt);
container.insertBefore(moveIt, container.firstChild);
moveIt.id = 'new-category-' + id;
exists.checked = 'checked';
var nowClass = moveIt.className;
moveIt.className = nowClass + ' fade';
Fat.fade_all();
moveIt.className = nowClass;
} else {
var catDiv = document.getElementById('categorychecklist');
var newLabel = document.createElement('label');
newLabel.setAttribute('for', 'category-' + id);
newLabel.id = 'new-category-' + id;
newLabel.className = 'selectit fade';
var newCheck = document.createElement('input');
newCheck.type = 'checkbox';
newCheck.value = id;
newCheck.name = 'post_category[]';
newCheck.id = 'category-' + id;
newLabel.appendChild(newCheck);
var newLabelText = document.createTextNode(' ' + names[i]);
newLabel.appendChild(newLabelText);
catDiv.insertBefore(newLabel, catDiv.firstChild);
newCheck.checked = 'checked';
Fat.fade_all();
newLabel.className = 'selectit';
}
newcat.value = '';
}
p.parentNode.removeChild(p);
// var id = parseInt(ajaxCat.response, 10);
}
function ajaxNewCatKeyPress(e) {
if (!e) {
if (window.event) {
e = window.event;
} else {
return;
}
}
if (e.keyCode == 13) {
ajaxNewCat();
e.returnValue = false;
e.cancelBubble = true;
return false;
}
}
function ajaxNewCat() {
var newcat = document.getElementById('newcat');
var split_cats = new Array(1);
var catString = '';
catString = 'ajaxnewcat=' + encodeURIComponent(newcat.value);
ajaxCat.requestFile = 'edit-form-ajax-cat.php';
ajaxCat.method = 'GET';
ajaxCat.onLoading = newCatLoading;
ajaxCat.onLoaded = newCatLoaded;
ajaxCat.onInteractive = newCatInteractive;
ajaxCat.onCompletion = newCatCompletion;
ajaxCat.runAJAX(catString);
}
function myPload( str ) {
var fixedExplode = new Array();
var comma = new String(',');
var count = 0;
var currentElement = '';
for( x=0; x < str.length; x++) {
andy = str.charAt(x);
if ( comma.indexOf(andy) != -1 ) {
currentElement = currentElement.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // trim
fixedExplode[count] = currentElement;
currentElement = "";
count++;
} else {
currentElement += andy;
}
}
if ( currentElement != "" )
fixedExplode[count] = currentElement;
return fixedExplode;
}
//]]>
</script>
<?php endif; ?>
<?php endif; ?>
<?php if ( ($parent_file != 'link-manager.php') && ($parent_file != 'options-general.php') ) : ?>
<style type="text/css">* html { overflow-x: hidden; }</style>
<?php endif; ?>
<?php do_action('admin_head'); ?>
</head>
<body>
<div id="wphead">
<h1><?php echo wptexturize(get_settings(('blogname'))); ?> <span>(<a href="<?php echo get_settings('home') . '/'; ?>"><?php _e('View site') ?> &raquo;</a>)</span></h1>
</div>
<div id="user_info"><p><?php printf(__('Howdy, <strong>%s</strong>.'), $user_identity) ?> [<a href="<?php echo get_settings('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php _e('Sign Out'); ?></a>, <a href="profile.php"><?php _e('My Account'); ?></a>] </p></div>
<div id="user_info"><p><?php printf(__('Howdy, <strong>%s</strong>.'), $user_identity) ?> [<a href="<?php echo get_settings('siteurl')
?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php _e('Sign Out'); ?></a>, <a href="profile.php"><?php _e('My Account'); ?></a>] </p></div>
<?php
require(ABSPATH . '/wp-admin/menu-header.php');

View File

@@ -40,8 +40,6 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
}
$xfn_js = $sack_js = $list_js = $cat_js = $dbx_js = $editing = false;
require(ABSPATH . '/wp-admin/menu.php');
// Handle plugin admin pages.
@@ -61,7 +59,7 @@ if (isset($_GET['page'])) {
}
if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page"))
die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
die(sprintf(__('Cannot load %s.'), $plugin_page));
if (! isset($_GET['noheader']))
require_once(ABSPATH . '/wp-admin/admin-header.php');

View File

@@ -1,178 +0,0 @@
<?php
require_once('admin.php');
header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);
?>
var ajaxCat = new sack();
var newcat;
function newCatAddIn() {
if ( !document.getElementById('jaxcat') ) return false;
var ajaxcat = document.createElement('span');
ajaxcat.id = 'ajaxcat';
newcat = document.createElement('input');
newcat.type = 'text';
newcat.name = 'newcat';
newcat.id = 'newcat';
newcat.size = '16';
newcat.setAttribute('autocomplete', 'off');
newcat.onkeypress = ajaxNewCatKeyPress;
var newcatSub = document.createElement('input');
newcatSub.type = 'button';
newcatSub.name = 'Button';
newcatSub.id = 'catadd';
newcatSub.value = '<?php echo addslashes(__('Add')); ?>';
newcatSub.onclick = ajaxNewCat;
ajaxcat.appendChild(newcat);
ajaxcat.appendChild(newcatSub);
document.getElementById('jaxcat').appendChild(ajaxcat);
howto = document.createElement('span');
howto.innerHTML = '<?php echo addslashes(__('Separate multiple categories with commas.')); ?>';
howto.id = 'howto';
ajaxcat.appendChild(howto);
}
addLoadEvent(newCatAddIn);
function getResponseElement() {
var p = document.getElementById('ajaxcatresponse');
if (!p) {
p = document.createElement('span');
document.getElementById('jaxcat').appendChild(p);
p.id = 'ajaxcatresponse';
}
return p;
}
function newCatLoading() {
var p = getResponseElement();
p.innerHTML = '<?php echo addslashes(__('Sending Data...')); ?>';
}
function newCatLoaded() {
var p = getResponseElement();
p.innerHTML = '<?php echo addslashes(__('Data Sent...')); ?>';
}
function newCatInteractive() {
var p = getResponseElement();
p.innerHTML = '<?php echo addslashes(__('Processing Request...')); ?>';
}
function newCatCompletion() {
var p = getResponseElement();
var id = 0;
var ids = new Array();
var names = new Array();
ids = myPload( ajaxCat.response );
names = myPload( newcat.value );
for ( i = 0; i < ids.length; i++ ) {
id = ids[i].replace(/[\n\r]+/g, "");
if ( id == '-1' ) {
p.innerHTML = "<?php echo addslashes(__("You don't have permission to do that.")); ?>";
return;
}
if ( id == '0' ) {
p.innerHTML = "<?php echo addslashes(__('That category name is invalid. Try something else.')); ?>";
return;
}
var exists = document.getElementById('category-' + id);
if (exists) {
var moveIt = exists.parentNode;
var container = moveIt.parentNode;
container.removeChild(moveIt);
container.insertBefore(moveIt, container.firstChild);
moveIt.id = 'new-category-' + id;
exists.checked = 'checked';
var nowClass = moveIt.className;
moveIt.className = nowClass + ' fade';
Fat.fade_all();
moveIt.className = nowClass;
} else {
var catDiv = document.getElementById('categorychecklist');
var newLabel = document.createElement('label');
newLabel.setAttribute('for', 'category-' + id);
newLabel.id = 'new-category-' + id;
newLabel.className = 'selectit fade';
var newCheck = document.createElement('input');
newCheck.type = 'checkbox';
newCheck.value = id;
newCheck.name = 'post_category[]';
newCheck.id = 'category-' + id;
newLabel.appendChild(newCheck);
var newLabelText = document.createTextNode(' ' + names[i]);
newLabel.appendChild(newLabelText);
catDiv.insertBefore(newLabel, catDiv.firstChild);
newCheck.checked = 'checked';
Fat.fade_all();
newLabel.className = 'selectit';
}
newcat.value = '';
}
p.parentNode.removeChild(p);
// var id = parseInt(ajaxCat.response, 10);
}
function ajaxNewCatKeyPress(e) {
if (!e) {
if (window.event) {
e = window.event;
} else {
return;
}
}
if (e.keyCode == 13) {
ajaxNewCat();
e.returnValue = false;
e.cancelBubble = true;
return false;
}
}
function ajaxNewCat() {
var newcat = document.getElementById('newcat');
var split_cats = new Array(1);
var catString = '';
catString = 'ajaxnewcat=' + encodeURIComponent(newcat.value);
ajaxCat.requestFile = 'edit-form-ajax-cat.php';
ajaxCat.method = 'GET';
ajaxCat.onLoading = newCatLoading;
ajaxCat.onLoaded = newCatLoaded;
ajaxCat.onInteractive = newCatInteractive;
ajaxCat.onCompletion = newCatCompletion;
ajaxCat.runAJAX(catString);
}
function myPload( str ) {
var fixedExplode = new Array();
var comma = new String(',');
var count = 0;
var currentElement = '';
for( x=0; x < str.length; x++) {
andy = str.charAt(x);
if ( comma.indexOf(andy) != -1 ) {
currentElement = currentElement.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // trim
fixedExplode[count] = currentElement;
currentElement = "";
count++;
} else {
currentElement += andy;
}
}
if ( currentElement != "" )
fixedExplode[count] = currentElement;
return fixedExplode;
}

View File

@@ -3,7 +3,6 @@ require_once('admin.php');
$title = __('Categories');
$parent_file = 'edit.php';
$list_js = true;
$wpvarstoreset = array('action','cat');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {

View File

@@ -3,7 +3,6 @@ require_once('admin.php');
$title = __('Edit Comments');
$parent_file = 'edit.php';
$list_js = true;
require_once('admin-header.php');
if (empty($_GET['mode'])) $mode = 'view';
@@ -45,7 +44,7 @@ if ( !empty( $_POST['delete_comments'] ) ) :
$post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
$authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
if ( current_user_can('edit_post', $post_id) ) :
wp_set_comment_status($comment, "delete");
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID = $comment");
++$i;
endif;
endforeach;

View File

@@ -129,8 +129,6 @@ endforeach;
</fieldset>
<?php endif; ?>
<?php do_action('dbx_post_sidebar'); ?>
</div>
</div>
@@ -218,13 +216,11 @@ else
<?php do_action('edit_form_advanced'); ?>
<?php
if (current_user_can('upload_files')) {
$uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
$uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
}
$uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
$uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
?>
<div id="advancedstuff" class="dbx-group" >
@@ -260,8 +256,6 @@ if($metadata = has_meta($post_ID)) {
</div>
</fieldset>
<?php do_action('dbx_post_advanced'); ?>
</div>
<?php if ('edit' == $action) : ?>

View File

@@ -108,8 +108,6 @@ endforeach;
<div class="dbx-content"><p><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" /></p></div>
</fieldset>
<?php do_action('dbx_page_sidebar'); ?>
</div>
</div>
@@ -181,16 +179,12 @@ else
<input name="referredby" type="hidden" id="referredby" value="<?php echo $sendto; ?>" />
</p>
<?php do_action('edit_page_form'); ?>
<?php
if (current_user_can('upload_files')) {
$uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
$uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
}
$uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
$uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
?>
<div id="advancedstuff" class="dbx-group">
@@ -211,13 +205,13 @@ if($metadata = has_meta($post_ID)) {
</div>
</fieldset>
<?php do_action('dbx_page_advanced'); ?>
</div>
<?php if ('edit' == $action) : ?>
<input name="deletepost" class="delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this page') ?>" <?php echo "onclick=\"return confirm('" . sprintf(__("You are about to delete this page \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), $wpdb->escape($post->post_title) ) . "')\""; ?> />
<?php endif; ?>
<?php do_action('edit_page_form', ''); ?>
</form>
</div>

View File

@@ -2,7 +2,6 @@
require_once('admin.php');
$title = __('Pages');
$parent_file = 'edit.php';
$list_js = true;
require_once('admin-header.php');
?>
@@ -43,7 +42,7 @@ if ($posts) {
if ( isset($_GET['s']) ) {
foreach ( $posts as $post ) :
$class = ('alternate' != $class) ? 'alternate' : ''; ?>
<tr id='page-<?php echo $post->ID; ?>' class='<?php echo $class; ?>'>
<tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
<th scope="row"><?php echo $post->ID; ?></th>
<td>
<?php echo $pad; ?><?php the_title() ?>
@@ -51,8 +50,8 @@ foreach ( $posts as $post ) :
<td><?php the_author() ?></td>
<td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>
<td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
<td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&amp;post=$post->ID' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&amp;post=$post->ID' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td>
<td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td>
</tr>
<?php
endforeach;

View File

@@ -3,7 +3,6 @@ require_once('admin.php');
$title = __('Posts');
$parent_file = 'edit.php';
$list_js = true;
require_once('admin-header.php');
$_GET['m'] = (int) $_GET['m'];

View File

@@ -1,25 +1,30 @@
<?php
require_once('../wp-config.php');
// Do pingbacks
while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';");
pingback($ping->post_content, $ping->ID);
}
register_shutdown_function('execute_all_pings');
//execute_all_pings();
// Do Enclosures
while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';");
do_enclose($enclosure->post_content, $enclosure->ID);
}
// Do Trackbacks
$trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status != 'draft'");
if ( is_array($trackbacks) ) {
foreach ( $trackbacks as $trackback ) {
function execute_all_pings() {
global $wpdb;
// Do pingbacks
while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';");
pingback($ping->post_content, $ping->ID);
echo "Pingback: $ping->post_title : $ping->ID<br/>";
}
// Do Enclosures
while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';");
do_enclose($enclosure->post_content, $enclosure->ID);
echo "Enclosure: $enclosure->post_title : $enclosure->ID<br/>";
}
// Do Trackbacks
while ($trackback = $wpdb->get_row("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' AND post_status != 'draft' LIMIT 1")) {
echo "Trackback : $trackback->ID<br/>";
do_trackbacks($trackback->ID);
}
}
_e('Done.');
?>

View File

@@ -587,7 +587,7 @@ class Blogger_Import {
if ( count($this->import['blogs']) > 1 )
echo '<li>'.__('In case you haven\'t done it already, you can import the posts from your other blogs:'). $this->show_blogs() . '</li>';
if ( $n = count($this->import['blogs'][$_GET['blog']]['newusers']) )
echo '<li>'.sprintf(__('Go to <a href="%s" target="%s">Authors &amp; Users</a>, where you can modify the new user(s) or delete them. If you want to make all of the imported posts yours, you will be given that option when you delete the new authors.'), 'users.php', '_parent').'</li>';
echo '<li>'.sptintf(__('Go to <a href="%s" target="%s">Authors &amp; Users</a>, where you can modify the new user(s) or delete them. If you want to make all of the imported posts yours, you will be given that option when you delete the new authors.'), 'users.php', '_parent').'</li>';
echo '<li>'.__('For security, click the link below to reset this importer. That will clear your Blogger credentials and options from the database.').'</li>';
echo '</ul>';
}
@@ -599,8 +599,6 @@ class Blogger_Import {
}
if ( isset($_GET['noheader']) ) {
header('Content-Type: text/html; charset=utf-8');
$this->import = get_settings('import-blogger');
if ( false === $this->import ) {

View File

@@ -1,741 +0,0 @@
<?php
/**
Add These Functions to make our lives easier
**/
if(!function_exists('get_catbynicename'))
{
function get_catbynicename($category_nicename)
{
global $wpdb;
$cat_id -= 0; // force numeric
$name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
return $name;
}
}
if(!function_exists('get_comment_count'))
{
function get_comment_count($post_ID)
{
global $wpdb;
return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID);
}
}
if(!function_exists('link_cat_exists'))
{
function link_cat_exists($catname)
{
global $wpdb;
return $wpdb->get_var('SELECT cat_id FROM '.$wpdb->linkcategories.' WHERE cat_name = "'.$wpdb->escape($catname).'"');
}
}
if(!function_exists('link_exists'))
{
function link_exists($linkname)
{
global $wpdb;
return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$linkname.'"');
}
}
/*
Identify UTF-8 text
Taken from http://www.php.net/manual/fr/function.mb-detect-encoding.php#50087
*/
//
// utf8 encoding validation developed based on Wikipedia entry at:
// http://en.wikipedia.org/wiki/UTF-8
//
// Implemented as a recursive descent parser based on a simple state machine
// copyright 2005 Maarten Meijer
//
// This cries out for a C-implementation to be included in PHP core
//
function valid_1byte($char) {
if(!is_int($char)) return false;
return ($char & 0x80) == 0x00;
}
function valid_2byte($char) {
if(!is_int($char)) return false;
return ($char & 0xE0) == 0xC0;
}
function valid_3byte($char) {
if(!is_int($char)) return false;
return ($char & 0xF0) == 0xE0;
}
function valid_4byte($char) {
if(!is_int($char)) return false;
return ($char & 0xF8) == 0xF0;
}
function valid_nextbyte($char) {
if(!is_int($char)) return false;
return ($char & 0xC0) == 0x80;
}
function valid_utf8($string) {
$len = strlen($string);
$i = 0;
while( $i < $len ) {
$char = ord(substr($string, $i++, 1));
if(valid_1byte($char)) { // continue
continue;
} else if(valid_2byte($char)) { // check 1 byte
if(!valid_nextbyte(ord(substr($string, $i++, 1))))
return false;
} else if(valid_3byte($char)) { // check 2 bytes
if(!valid_nextbyte(ord(substr($string, $i++, 1))))
return false;
if(!valid_nextbyte(ord(substr($string, $i++, 1))))
return false;
} else if(valid_4byte($char)) { // check 3 bytes
if(!valid_nextbyte(ord(substr($string, $i++, 1))))
return false;
if(!valid_nextbyte(ord(substr($string, $i++, 1))))
return false;
if(!valid_nextbyte(ord(substr($string, $i++, 1))))
return false;
} // goto next char
}
return true; // done
}
function csc ($s) {
if (valid_utf8 ($s)) {
return $s;
} else {
return iconv(get_option ("dccharset"),"UTF-8",$s);
}
}
function textconv ($s) {
return csc (preg_replace ('|(?<!<br />)\s*\n|', ' ', $s));
}
/**
The Main Importer Class
**/
class Dotclear_Import {
function header()
{
echo '<div class="wrap">';
echo '<h2>'.__('Import Dotclear').'</h2>';
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
}
function footer()
{
echo '</div>';
}
function greet()
{
echo '<p>'.__('Howdy! This importer allows you to extract posts from a Dotclear database into your blog. Mileage may vary.').'</p>';
echo '<p>'.__('Your Dotclear Configuration settings are as follows:').'</p>';
echo '<form action="admin.php?import=dotclear&amp;step=1" method="post">';
$this->db_form();
echo '<input type="submit" name="submit" value="'.__('Import Categories').'" />';
echo '</form>';
}
function get_dc_cats()
{
global $wpdb;
// General Housekeeping
$dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
set_magic_quotes_runtime(0);
$prefix = get_option('tpre');
// Get Categories
return $dcdb->get_results('SELECT * FROM dc_categorie', ARRAY_A);
}
function get_dc_users()
{
global $wpdb;
// General Housekeeping
$dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
set_magic_quotes_runtime(0);
$prefix = get_option('tpre');
// Get Users
return $dcdb->get_results('SELECT * FROM dc_user', ARRAY_A);
}
function get_dc_posts()
{
// General Housekeeping
$dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
set_magic_quotes_runtime(0);
$prefix = get_option('tpre');
// Get Posts
return $dcdb->get_results('SELECT dc_post.*, dc_categorie.cat_libelle_url AS post_cat_name
FROM dc_post INNER JOIN dc_categorie
ON dc_post.cat_id = dc_categorie.cat_id', ARRAY_A);
}
function get_dc_comments()
{
global $wpdb;
// General Housekeeping
$dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
set_magic_quotes_runtime(0);
$prefix = get_option('tpre');
// Get Comments
return $dcdb->get_results('SELECT * FROM dc_comment', ARRAY_A);
}
function get_dc_links()
{
//General Housekeeping
$dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
set_magic_quotes_runtime(0);
$prefix = get_option('tpre');
return $dcdb->get_results('SELECT * FROM dc_link ORDER BY position', ARRAY_A);
}
function cat2wp($categories='')
{
// General Housekeeping
global $wpdb;
$count = 0;
$dccat2wpcat = array();
// Do the Magic
if(is_array($categories))
{
echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
foreach ($categories as $category)
{
$count++;
extract($category);
// Make Nice Variables
$name = $wpdb->escape($cat_libelle_url);
$title = $wpdb->escape(csc ($cat_libelle));
$desc = $wpdb->escape(csc ($cat_desc));
if($cinfo = category_exists($name))
{
$ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
}
else
{
$ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
}
$dccat2wpcat[$id] = $ret_id;
}
// Store category translation for future use
add_option('dccat2wpcat',$dccat2wpcat);
echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
return true;
}
echo __('No Categories to Import!');
return false;
}
function users2wp($users='')
{
// General Housekeeping
global $wpdb;
$count = 0;
$dcid2wpid = array();
// Midnight Mojo
if(is_array($users))
{
echo '<p>'.__('Importing Users...').'<br /><br /></p>';
foreach($users as $user)
{
$count++;
extract($user);
// Make Nice Variables
$name = $wpdb->escape(csc ($name));
$RealName = $wpdb->escape(csc ($user_pseudo));
if($uinfo = get_userdatabylogin($name))
{
$ret_id = wp_insert_user(array(
'ID' => $uinfo->ID,
'user_login' => $user_id,
'user_nicename' => $Realname,
'user_email' => $user_email,
'user_url' => 'http://',
'display_name' => $Realname)
);
}
else
{
$ret_id = wp_insert_user(array(
'user_login' => $user_id,
'user_nicename' => csc ($user_pseudo),
'user_email' => $user_email,
'user_url' => 'http://',
'display_name' => $Realname)
);
}
$dcid2wpid[$user_id] = $ret_id;
// Set Dotclear-to-WordPress permissions translation
// Update Usermeta Data
$user = new WP_User($ret_id);
$wp_perms = $user_level + 1;
if(10 == $wp_perms) { $user->set_role('administrator'); }
else if(9 == $wp_perms) { $user->set_role('editor'); }
else if(5 <= $wp_perms) { $user->set_role('editor'); }
else if(4 <= $wp_perms) { $user->set_role('author'); }
else if(3 <= $wp_perms) { $user->set_role('contributor'); }
else if(2 <= $wp_perms) { $user->set_role('contributor'); }
else { $user->set_role('subscriber'); }
update_usermeta( $ret_id, 'wp_user_level', $wp_perms);
update_usermeta( $ret_id, 'rich_editing', 'false');
update_usermeta( $ret_id, 'first_name', csc ($user_prenom));
update_usermeta( $ret_id, 'last_name', csc ($user_nom));
}// End foreach($users as $user)
// Store id translation array for future use
add_option('dcid2wpid',$dcid2wpid);
echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
return true;
}// End if(is_array($users)
echo __('No Users to Import!');
return false;
}// End function user2wp()
function posts2wp($posts='')
{
// General Housekeeping
global $wpdb;
$count = 0;
$dcposts2wpposts = array();
$cats = array();
// Do the Magic
if(is_array($posts))
{
echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
foreach($posts as $post)
{
$count++;
extract($post);
// Set Dotclear-to-WordPress status translation
$stattrans = array(0 => 'draft', 1 => 'publish');
$comment_status_map = array (0 => 'closed', 1 => 'open');
//Can we do this more efficiently?
$uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1;
$authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ;
$Title = $wpdb->escape(csc ($post_titre));
$post_content = textconv ($post_content);
if ($post_chapo != "") {
$post_excerpt = textconv ($post_chapo);
$post_content = $post_excerpt ."\n<!--more-->\n".$post_content;
}
$post_excerpt = $wpdb->escape ($post_excerpt);
$post_content = $wpdb->escape ($post_content);
$post_status = $stattrans[$post_pub];
// Import Post data into WordPress
if($pinfo = post_exists($Title,$post_content))
{
$ret_id = wp_insert_post(array(
'ID' => $pinfo,
'post_author' => $authorid,
'post_date' => $post_dt,
'post_date_gmt' => $post_dt,
'post_modified' => $post_upddt,
'post_modified_gmt' => $post_upddt,
'post_title' => $Title,
'post_content' => $post_content,
'post_excerpt' => $post_excerpt,
'post_status' => $post_status,
'post_name' => $post_titre_url,
'comment_status' => $comment_status_map[$post_open_comment],
'ping_status' => $comment_status_map[$post_open_tb],
'comment_count' => $post_nb_comment + $post_nb_trackback)
);
}
else
{
$ret_id = wp_insert_post(array(
'post_author' => $authorid,
'post_date' => $post_dt,
'post_date_gmt' => $post_dt,
'post_modified' => $post_modified_gmt,
'post_modified_gmt' => $post_modified_gmt,
'post_title' => $Title,
'post_content' => $post_content,
'post_excerpt' => $post_excerpt,
'post_status' => $post_status,
'post_name' => $post_titre_url,
'comment_status' => $comment_status_map[$post_open_comment],
'ping_status' => $comment_status_map[$post_open_tb],
'comment_count' => $post_nb_comment + $post_nb_trackback)
);
}
$dcposts2wpposts[$post_id] = $ret_id;
// Make Post-to-Category associations
$cats = array();
if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; }
if(!empty($cats)) { wp_set_post_cats('', $ret_id, $cats); }
}
}
// Store ID translation for later use
add_option('dcposts2wpposts',$dcposts2wpposts);
echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
return true;
}
function comments2wp($comments='')
{
// General Housekeeping
global $wpdb;
$count = 0;
$dccm2wpcm = array();
$postarr = get_option('dcposts2wpposts');
// Magic Mojo
if(is_array($comments))
{
echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
foreach($comments as $comment)
{
$count++;
extract($comment);
// WordPressify Data
$comment_ID = ltrim($comment_id, '0');
$comment_post_ID = $postarr[$post_id];
$comment_approved = "$comment_pub";
$name = $wpdb->escape(csc ($comment_auteur));
$email = $wpdb->escape($comment_email);
$web = "http://".$wpdb->escape($comment_site);
$message = $wpdb->escape(textconv ($comment_content));
if($cinfo = comment_exists($name, $comment_dt))
{
// Update comments
$ret_id = wp_update_comment(array(
'comment_ID' => $cinfo,
'comment_post_ID' => $comment_post_ID,
'comment_author' => $name,
'comment_author_email' => $email,
'comment_author_url' => $web,
'comment_author_IP' => $comment_ip,
'comment_date' => $comment_dt,
'comment_date_gmt' => $comment_dt,
'comment_content' => $message,
'comment_approved' => $comment_approved)
);
}
else
{
// Insert comments
$ret_id = wp_insert_comment(array(
'comment_post_ID' => $comment_post_ID,
'comment_author' => $name,
'comment_author_email' => $email,
'comment_author_url' => $web,
'comment_author_IP' => $comment_ip,
'comment_date' => $comment_dt,
'comment_date_gmt' => $comment_dt,
'comment_content' => $message,
'comment_approved' => $comment_approved)
);
}
$dccm2wpcm[$comment_ID] = $ret_id;
}
// Store Comment ID translation for future use
add_option('dccm2wpcm', $dccm2wpcm);
// Associate newly formed categories with posts
get_comment_count($ret_id);
echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
return true;
}
echo __('No Comments to Import!');
return false;
}
function links2wp($links='')
{
// General Housekeeping
global $wpdb;
$count = 0;
// Deal with the links
if(is_array($links))
{
echo '<p>'.__('Importing Links...').'<br /><br /></p>';
foreach($links as $link)
{
$count++;
extract($link);
if ($title != "") {
if ($cinfo = link_cat_exists (csc ($title))) {
$category = $cinfo;
} else {
$wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('".
$wpdb->escape (csc ($title))."')");
$category = $wpdb->insert_id;
}
} else {
$linkname = $wpdb->escape(csc ($label));
$description = $wpdb->escape(csc ($title));
if($linfo = link_exists($linkname)) {
$ret_id = wp_insert_link(array(
'link_id' => $linfo,
'link_url' => $href,
'link_name' => $linkname,
'link_category' => $category,
'link_description' => $description)
);
} else {
$ret_id = wp_insert_link(array(
'link_url' => $url,
'link_name' => $linkname,
'link_category' => $category,
'link_description' => $description)
);
}
$dclinks2wplinks[$link_id] = $ret_id;
}
}
add_option('dclinks2wplinks',$dclinks2wplinks);
echo '<p>';
printf(__('Done! <strong>%s</strong> links or link categories imported'), $count);
echo '<br /><br /></p>';
return true;
}
echo __('No Links to Import!');
return false;
}
function import_categories()
{
// Category Import
$cats = $this->get_dc_cats();
$this->cat2wp($cats);
add_option('dc_cats', $cats);
echo '<form action="admin.php?import=dotclear&amp;step=2" method="post">';
printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
echo '</form>';
}
function import_users()
{
// User Import
$users = $this->get_dc_users();
$this->users2wp($users);
echo '<form action="admin.php?import=dotclear&amp;step=3" method="post">';
printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
echo '</form>';
}
function import_posts()
{
// Post Import
$posts = $this->get_dc_posts();
$this->posts2wp($posts);
echo '<form action="admin.php?import=dotclear&amp;step=4" method="post">';
printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
echo '</form>';
}
function import_comments()
{
// Comment Import
$comments = $this->get_dc_comments();
$this->comments2wp($comments);
echo '<form action="admin.php?import=dotclear&amp;step=5" method="post">';
printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
echo '</form>';
}
function import_links()
{
//Link Import
$links = $this->get_dc_links();
$this->links2wp($links);
add_option('dc_links', $links);
echo '<form action="admin.php?import=dotclear&amp;step=6" method="post">';
printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
echo '</form>';
}
function cleanup_dcimport()
{
delete_option('tpre');
delete_option('dc_cats');
delete_option('dcid2wpid');
delete_option('dccat2wpcat');
delete_option('dcposts2wpposts');
delete_option('dccm2wpcm');
delete_option('dclinks2wplinks');
delete_option('dcuser');
delete_option('dcpass');
delete_option('dcname');
delete_option('dchost');
delete_option('dccharset');
$this->tips();
}
function tips()
{
echo '<p>'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Dotclear, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.').'</p>';
echo '<h3>'.__('Users').'</h3>';
echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in Dotclear, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Dotclear uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>';
echo '<h3>'.__('Preserving Authors').'</h3>';
echo '<p>'.__('Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'</p>';
echo '<h3>'.__('Textile').'</h3>';
echo '<p>'.__('Also, since you\'re coming from Dotclear, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/2004/04/19/wordpress-plugin-textile-20/">Textile for WordPress</a>. Trust me... You\'ll want it.').'</p>';
echo '<h3>'.__('WordPress Resources').'</h3>';
echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>';
echo '<ul>';
echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>';
echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums').'</li>';
echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
echo '</ul>';
echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>';
}
function db_form()
{
echo '<ul>';
printf('<li><label for="dbuser">%s</label> <input type="text" name="dbuser" /></li>', __('Dotclear Database User:'));
printf('<li><label for="dbpass">%s</label> <input type="password" name="dbpass" /></li>', __('Dotclear Database Password:'));
printf('<li><label for="dbname">%s</label> <input type="text" name="dbname" /></li>', __('Dotclear Database Name:'));
printf('<li><label for="dbhost">%s</label> <input type="text" name="dbhost" value="localhost" /></li>', __('Dotclear Database Host:'));
/* printf('<li><label for="dbprefix">%s</label> <input type="text" name="dbprefix" /></li>', __('Dotclear Table prefix (if any):')); */
printf('<li><label for="dccharset">%s</label> <input type="text" name="dccharset" value="ISO-8859-15"/></li>', __('Originating character set:'));
echo '</ul>';
}
function dispatch()
{
if (empty ($_GET['step']))
$step = 0;
else
$step = (int) $_GET['step'];
$this->header();
if ( $step > 0 )
{
if($_POST['dbuser'])
{
if(get_option('dcuser'))
delete_option('dcuser');
add_option('dcuser',$_POST['dbuser']);
}
if($_POST['dbpass'])
{
if(get_option('dcpass'))
delete_option('dcpass');
add_option('dcpass',$_POST['dbpass']);
}
if($_POST['dbname'])
{
if(get_option('dcname'))
delete_option('dcname');
add_option('dcname',$_POST['dbname']);
}
if($_POST['dbhost'])
{
if(get_option('dchost'))
delete_option('dchost');
add_option('dchost',$_POST['dbhost']);
}
if($_POST['dccharset'])
{
if(get_option('dccharset'))
delete_option('dccharset');
add_option('dccharset',$_POST['dccharset']);
}
if($_POST['dbprefix'])
{
if(get_option('tpre'))
delete_option('tpre');
add_option('tpre',$_POST['dbprefix']);
}
}
switch ($step)
{
default:
case 0 :
$this->greet();
break;
case 1 :
$this->import_categories();
break;
case 2 :
$this->import_users();
break;
case 3 :
$this->import_posts();
break;
case 4 :
$this->import_comments();
break;
case 5 :
$this->import_links();
break;
case 6 :
$this->cleanup_dcimport();
break;
}
$this->footer();
}
function Dotclear_Import()
{
// Nothing.
}
}
$dc_import = new Dotclear_Import();
register_importer('dotclear', 'Dotclear', __('Import posts from a Dotclear Blog'), array ($dc_import, 'dispatch'));
?>

View File

@@ -1,171 +0,0 @@
<?php
class LJ_Import {
var $file;
function header() {
echo '<div class="wrap">';
echo '<h2>'.__('Import LiveJournal').'</h2>';
}
function footer() {
echo '</div>';
}
function unhtmlentities($string) { // From php.net for < 4.3 compat
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
function greet() {
echo '<p>'.__('Howdy! This importer allows you to extract posts from LiveJournal XML export file into your blog. Pick a LiveJournal file to upload and click Import.').'</p>';
wp_import_upload_form("admin.php?import=livejournal&amp;step=1");
}
function import_posts() {
global $wpdb, $current_user;
set_magic_quotes_runtime(0);
$importdata = file($this->file); // Read the file into an array
$importdata = implode('', $importdata); // squish it
$importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata);
preg_match_all('|<entry>(.*?)</entry>|is', $importdata, $posts);
$posts = $posts[1];
unset($importdata);
echo '<ol>';
foreach ($posts as $post) {
flush();
preg_match('|<subject>(.*?)</subject>|is', $post, $post_title);
$post_title = $wpdb->escape(trim($post_title[1]));
if ( empty($post_title) ) {
preg_match('|<itemid>(.*?)</itemid>|is', $post, $post_title);
$post_title = $wpdb->escape(trim($post_title[1]));
}
preg_match('|<eventtime>(.*?)</eventtime>|is', $post, $post_date);
$post_date = strtotime($post_date[1]);
$post_date = gmdate('Y-m-d H:i:s', $post_date);
preg_match('|<event>(.*?)</event>|is', $post, $post_content);
$post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
$post_content = $this->unhtmlentities($post_content);
// Clean up content
$post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
$post_content = $wpdb->escape($post_content);
$post_author = $current_user->ID;
$post_status = 'publish';
echo '<li>';
if ($post_id = post_exists($post_title, $post_content, $post_date)) {
printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
} else {
printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
$postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
$post_id = wp_insert_post($postdata);
if (!$post_id) {
_e("Couldn't get post ID");
echo '</li>';
break;
}
}
preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments);
$comments = $comments[1];
if ( $comments ) {
$comment_post_ID = $post_id;
$num_comments = 0;
foreach ($comments as $comment) {
preg_match('|<event>(.*?)</event>|is', $comment, $comment_content);
$comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
$comment_content = $this->unhtmlentities($comment_content);
// Clean up content
$comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
$comment_content = str_replace('<br>', '<br />', $comment_content);
$comment_content = str_replace('<hr>', '<hr />', $comment_content);
$comment_content = $wpdb->escape($comment_content);
preg_match('|<eventtime>(.*?)</eventtime>|is', $comment, $comment_date);
$comment_date = trim($comment_date[1]);
$comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
preg_match('|<name>(.*?)</name>|is', $comment, $comment_author);
$comment_author = $wpdb->escape(trim($comment_author[1]));
preg_match('|<email>(.*?)</email>|is', $comment, $comment_author_email);
$comment_author_email = $wpdb->escape(trim($comment_author_email[1]));
$comment_approved = 1;
// Check if it's already there
if (!comment_exists($comment_author, $comment_date)) {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_date', 'comment_content', 'comment_approved');
$commentdata = wp_filter_comment($commentdata);
wp_insert_comment($commentdata);
$num_comments++;
}
}
}
if ( $num_comments ) {
echo ' ';
printf(__('(%s comments)'), $num_comments);
}
echo '</li>';
flush();
ob_flush();
}
echo '</ol>';
}
function import() {
$file = wp_import_handle_upload();
if ( isset($file['error']) ) {
echo $file['error'];
return;
}
$this->file = $file['file'];
$this->import_posts();
wp_import_cleanup($file['id']);
echo '<h3>';
printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
echo '</h3>';
}
function dispatch() {
if (empty ($_GET['step']))
$step = 0;
else
$step = (int) $_GET['step'];
$this->header();
switch ($step) {
case 0 :
$this->greet();
break;
case 1 :
$this->import();
break;
}
$this->footer();
}
function LJ_Import() {
// Nothing.
}
}
$livejournal_import = new LJ_Import();
register_importer('livejournal', 'LiveJournal', __('Import posts from LiveJournal'), array ($livejournal_import, 'dispatch'));
?>

View File

@@ -54,7 +54,7 @@ class MT_Import {
if (!(in_array($author, $this->mtnames))) { //a new mt author name is found
++ $this->j;
$this->mtnames[$this->j] = $author; //add that new mt author name to an array
$user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user
$user_id = username_exists($this->newauthornames[$j]); //check if the new author name defined by the user is a pre-existing wp user
if (!$user_id) { //banging my head against the desk now.
if ($newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname
$user_id = wp_create_user($author, $pass);
@@ -243,11 +243,11 @@ class MT_Import {
$post_convert_breaks = $value;
break;
case 'ALLOW PINGS' :
$ping_status = trim($meta[2][0]);
if ($ping_status == 1) {
$ping_status = 'open';
$post_allow_pings = trim($meta[2][0]);
if ($post_allow_pings == 1) {
$post_allow_pings = 'open';
} else {
$ping_status = 'closed';
$post_allow_pings = 'closed';
}
break;
case 'PRIMARY CATEGORY' :
@@ -290,7 +290,6 @@ class MT_Import {
}
$comment_post_ID = $post_id;
$comment_approved = 1;
// Now for comments
$comments = explode("-----\nCOMMENT:", $comments[0]);
@@ -322,7 +321,7 @@ class MT_Import {
$comment_content = str_replace('-----', '', $comment_content);
// Check if it's already there
if (!comment_exists($comment_author, $comment_date)) {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_approved');
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content');
$commentdata = wp_filter_comment($commentdata);
wp_insert_comment($commentdata);
$num_comments++;
@@ -370,7 +369,7 @@ class MT_Import {
// Check if it's already there
if (!comment_exists($comment_author, $comment_date)) {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_type', 'comment_approved');
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_type');
$commentdata = wp_filter_comment($commentdata);
wp_insert_comment($commentdata);
$num_pings++;

View File

@@ -1,5 +1,9 @@
<?php
// Example:
// define('RSSFILE', '/home/example/public_html/rss.xml');
define('RSSFILE', 'rss.xml');
class RSS_Import {
var $posts = array ();

View File

@@ -56,11 +56,11 @@ class Textpattern_Import {
echo '<p>'.__('Your Textpattern Configuration settings are as follows:').'</p>';
echo '<form action="admin.php?import=textpattern&amp;step=1" method="post">';
$this->db_form();
echo '<input type="submit" name="submit" value="'.__('Import Categories').'" />';
echo '<input type="submit" name="submit" value="Import Categories" />';
echo '</form>';
}
function get_txp_cats()
function get_txp_cats()
{
global $wpdb;
// General Housekeeping

View File

@@ -19,7 +19,7 @@ $rss = @fetch_rss('http://feeds.technorati.com/cosmos/rss/?url='. trailingslashi
if ( isset($rss->items) && 0 != count($rss->items) ) {
?>
<div id="incominglinks">
<h3><?php _e('Incoming Links'); ?> <cite><a href="http://www.technorati.com/search/<?php echo trailingslashit(get_option('home')); ?>?partner=wordpress"><?php _e('More'); ?> &raquo;</a></cite></h3>
<h3><?php _e('Incoming Links'); ?> <cite><a href="http://www.technorati.com/cosmos/search.html?url=<?php echo trailingslashit(get_option('home')); ?>&amp;partner=wordpress"><?php _e('More'); ?> &raquo;</a></cite></h3>
<ul>
<?php
$rss->items = array_slice($rss->items, 0, 10);
@@ -33,7 +33,7 @@ foreach ($rss->items as $item ) {
<?php
$comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 5");
$numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
$numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_approved = '0'");
if ( $comments || $numcomments ) :
?>

View File

@@ -2,10 +2,8 @@
require_once('admin.php');
header('Content-Type: text/html; charset=' . get_option('blog_charset'));
if (!current_user_can('upload_files'))
die(__('You do not have permission to upload files.'));
if (!current_user_can('edit_posts'))
die(__('You do not have permission to edit posts.'));
$wpvarstoreset = array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'attachment');
@@ -34,7 +32,7 @@ break;
case 'delete':
if ( !current_user_can('edit_post', (int) $attachment) )
if ( !current_user_can('edit_post', (int) $attachment) )
die(__('You are not allowed to delete this attachment.').' <a href="'.basename(__FILE__)."?post=$post&amp;all=$all&amp;action=upload\">".__('Go back').'</a>');
wp_delete_attachment($attachment);
@@ -234,15 +232,14 @@ srcb[{$ID}] = '{$image['guid']}';
$xpadding = (128 - $image['uwidth']) / 2;
$ypadding = (96 - $image['uheight']) / 2;
$style .= "#target{$ID} img { padding: {$ypadding}px {$xpadding}px; }\n";
$title = htmlentities($image['post_title'], ENT_QUOTES);
$script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" class=\"imagelink\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
ab[{$ID}] = '<a class=\"imagelink\" href=\"{$image['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
imga[{$ID}] = '<img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />';
imgb[{$ID}] = '<img id=\"image{$ID}\" src=\"{$image['guid']}\" alt=\"{$title}\" $height_width />';
$script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" class=\"imagelink\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$image['post_title']}\">';
ab[{$ID}] = '<a class=\"imagelink\" href=\"{$image['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$image['post_title']}\">';
imga[{$ID}] = '<img id=\"image{$ID}\" src=\"$src\" alt=\"{$image['post_title']}\" $height_width />';
imgb[{$ID}] = '<img id=\"image{$ID}\" src=\"{$image['guid']}\" alt=\"{$image['post_title']}\" $height_width />';
";
$html .= "<div id='target{$ID}' class='attwrap left'>
<div id='div{$ID}' class='imagewrap' onclick=\"doPopup({$ID});\">
<img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />
<img id=\"image{$ID}\" src=\"$src\" alt=\"{$image['post_title']}\" $height_width />
</div>
{$noscript}
</div>
@@ -254,19 +251,19 @@ imgb[{$ID}] = '<img id=\"image{$ID}\" src=\"{$image['guid']}\" alt=\"{$title}\"
</div>
";
} else {
$title = htmlentities($attachment['post_title'], ENT_QUOTES);
$title = $attachment['post_title'];
$filename = basename($attachment['guid']);
$icon = get_attachment_icon($ID);
$toggle_icon = "<a id=\"I{$ID}\" onclick=\"toggleOtherIcon({$ID});return false;\" href=\"javascript:void()\">$__using_title</a>";
$script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
ab[{$ID}] = '<a id=\"p{$ID}\" href=\"{$filename}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
title[{$ID}] = '{$title}';
$script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">{$attachment['post_title']}</a>';
ab[{$ID}] = '<a id=\"p{$ID}\" href=\"{$filename}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">{$attachment['post_title']}</a>';
title[{$ID}] = '{$attachment['post_title']}';
filename[{$ID}] = '{$filename}';
icon[{$ID}] = '{$icon}';
";
$html .= "<div id='target{$ID}' class='attwrap left'>
<div id='div{$ID}' class='otherwrap usingtext' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\">
<a id=\"p{$ID}\" href=\"{$attachment['guid']}\" onmousedown=\"selectLink({$ID});\" onclick=\"return false;\">{$title}</a>
<a id=\"p{$ID}\" href=\"{$attachment['guid']}\" onmousedown=\"selectLink({$ID});\" onclick=\"return false;\">{$attachment['post_title']}</a>
</div>
{$noscript}
</div>
@@ -299,16 +296,7 @@ die(__('This script was not meant to be called directly.'));
<script type="text/javascript">
/* Define any variables we'll need, such as alternate URLs. */
<?php echo $script; ?>
function htmldecode(st) {
o = document.getElementById('htmldecode');
if (! o) {
o = document.createElement("A");
o.id = "htmldecode"
}
o.innerHTML = st;
r = o.innerHTML;
return r;
}
function cancelUpload() {
o = document.getElementById('uploadForm');
o.method = 'GET';
@@ -336,85 +324,70 @@ function selectLink(n) {
}
}
function toggleLink(n) {
ol=document.getElementById('L'+n);
if ( ol.innerHTML == htmldecode(notlinked) ) {
ol.innerHTML = linkedtoimage;
} else if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
ol.innerHTML = linkedtopage;
} else {
ol.innerHTML = notlinked;
}
updateImage(n);
}
function toggleOtherLink(n) {
ol=document.getElementById('L'+n);
if ( ol.innerHTML == htmldecode(linkedtofile) ) {
ol.innerHTML = linkedtopage;
} else {
ol.innerHTML = linkedtofile;
}
updateOtherIcon(n);
}
function toggleImage(n) {
oi = document.getElementById('I'+n);
if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
oi.innerHTML = usingoriginal;
} else {
oi.innerHTML = usingthumbnail;
}
updateImage(n);
}
function toggleOtherIcon(n) {
od = document.getElementById('div'+n);
oi = document.getElementById('I'+n);
if ( oi.innerHTML == htmldecode(usingtitle) ) {
oi.innerHTML = usingfilename;
od.className = 'otherwrap usingtext';
} else if ( oi.innerHTML == htmldecode(usingfilename) && icon[n] != '' ) {
oi.innerHTML = usingicon;
od.className = 'otherwrap usingicon';
} else {
oi.innerHTML = usingtitle;
od.className = 'otherwrap usingtext';
}
updateOtherIcon(n);
}
function updateImage(n) {
od=document.getElementById('div'+n);
ol=document.getElementById('L'+n);
oi=document.getElementById('I'+n);
if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
if ( oi.innerHTML == usingthumbnail ) {
img = imga[n];
} else {
img = imgb[n];
}
if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
if ( ol.innerHTML == notlinked ) {
od.innerHTML = ab[n]+img+'</a>';
} else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
ol.innerHTML = linkedtoimage;
} else if ( ol.innerHTML == linkedtoimage ) {
od.innerHTML = aa[n]+img+'</a>';
ol.innerHTML = linkedtopage;
} else {
od.innerHTML = img;
ol.innerHTML = notlinked;
}
}
function updateOtherIcon(n) {
function toggleOtherLink(n) {
od=document.getElementById('div'+n);
ol=document.getElementById('L'+n);
oi=document.getElementById('I'+n);
if ( oi.innerHTML == htmldecode(usingfilename) ) {
txt = filename[n];
} else if ( oi.innerHTML == htmldecode(usingicon) ) {
txt = icon[n];
oi=document.getElementById('p'+n);
ih=oi.innerHTML;
if ( ol.innerHTML == linkedtofile ) {
od.innerHTML = aa[n];
ol.innerHTML = linkedtopage;
} else {
txt = title[n];
od.innerHTML = ab[n];
ol.innerHTML = linkedtofile;
}
if ( ol.innerHTML == htmldecode(linkedtofile) ) {
od.innerHTML = ab[n]+txt+'</a>';
} else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
od.innerHTML = aa[n]+txt+'</a>';
oi=document.getElementById('p'+n);
oi.innerHTML = ih;
}
function toggleImage(n) {
o = document.getElementById('image'+n);
oi = document.getElementById('I'+n);
if ( oi.innerHTML == usingthumbnail ) {
o.src = srcb[n];
oi.innerHTML = usingoriginal;
} else {
od.innerHTML = txt;
o.src = srca[n];
oi.innerHTML = usingthumbnail;
}
}
function toggleOtherIcon(n) {
od = document.getElementById('div'+n);
o = document.getElementById('p'+n);
oi = document.getElementById('I'+n);
if ( oi.innerHTML == usingtitle ) {
o.innerHTML = filename[n];
oi.innerHTML = usingfilename;
} else if ( oi.innerHTML == usingfilename && icon[n] != '' ) {
o.innerHTML = icon[n];
oi.innerHTML = usingicon;
} else {
o.innerHTML = title[n];
oi.innerHTML = usingtitle;
}
if ( oi.innerHTML == usingicon )
od.className = 'otherwrap usingicon';
else
od.className = 'otherwrap usingtext';
}
var win = window.opener ? window.opener : window.dialogArguments;
if (!win) win = top;
@@ -424,7 +397,6 @@ function sendToEditor(n) {
o = document.getElementById('div'+n);
h = o.innerHTML.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // Trim
h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)', 'g'), ' $1="$2"$3'); // Enclose attribs in quotes
h = h.replace(new RegExp(' (width|height)=".*?"', 'g'), ''); // Drop size constraints
h = h.replace(new RegExp(' on(click|mousedown)="[^"]*"', 'g'), ''); // Drop menu events
h = h.replace(new RegExp('<(/?)A', 'g'), '<$1a'); // Lowercase tagnames
h = h.replace(new RegExp('<IMG', 'g'), '<img'); // Lowercase again
@@ -494,12 +466,16 @@ form {
text-align: center;
width: 128px;
}
.usingicon a {
}
.usingtext {
padding: 3px;
height: 90px;
text-align: left;
width: 122px;
}
.usingtext a {
}
.filetype {
font-size: 80%;
border-bottom: 3px double #89a
@@ -507,6 +483,7 @@ form {
.imagewrap, .imagewrap img, .imagewrap a, .imagewrap a img, .imagewrap a:hover img, .imagewrap a:visited img, .imagewrap a:active img {
text-decoration: none;
}
#upload-menu {
background: #fff;
margin: 0px;
@@ -516,10 +493,12 @@ form {
border-bottom: 1px solid #448abd;
width: 100%;
}
#upload-menu li {
float: left;
margin: 0 0 0 .75em;
}
#upload-menu a {
display: block;
padding: 5px;
@@ -527,14 +506,18 @@ form {
color: #000;
border-top: 3px solid #fff;
}
#upload-menu .current a {
background: #dfe8f1;
border-right: 2px solid #448abd;
}
#upload-menu a:hover {
background: #dfe8f1;
color: #000;
}
.tip {
color: rgb(68, 138, 189);
padding: 2px 1em;
@@ -615,6 +598,7 @@ th {
color: #333;
padding: 0.25em;
}
#submit input:active {
background: #f4f4f4;
border: 3px double #ccc;
@@ -630,6 +614,7 @@ th {
#links {
margin: 3px 8px;
line-height: 2em;
}
#links textarea {
width: 95%;

View File

@@ -171,7 +171,7 @@ $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comm
// First Page
$wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'static', '', '', '')");
$wp_rewrite->flush_rules();
generate_page_rewrite_rules();
// Set up admin user
$random_password = substr(md5(uniqid(microtime())), 0, 6);

View File

@@ -25,7 +25,7 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
}
$xfn_js = true;
$xfn = true;
require('admin-header.php');
?>

View File

@@ -5,7 +5,6 @@ require_once('admin.php');
$title = __('Link Categories');
$this_file='link-categories.php';
$parent_file = 'link-manager.php';
$list_js = true;
$wpvarstoreset = array('action', 'cat', 'auto_toggle');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {

View File

@@ -36,7 +36,7 @@ switch ($step) {
<div style="width: 48%; float: left;">
<h3><?php _e('Or choose from your local disk:'); ?></h3>
<input id="userfile" name="userfile" type="file" size="30" />
<input name="userfile" type="file" size="30" />
</div>
@@ -77,13 +77,13 @@ foreach ($categories as $category) {
}
$opml_url = $_POST['opml_url'];
if (isset($opml_url) && $opml_url != '' && $opml_url != 'http://') {
if (isset($opml_url) && $opml_url != '') {
$blogrolling = true;
}
else // try to get the upload file.
{
$overrides = array('test_form' => false, 'test_type' => false);
$file = wp_handle_upload($_FILES['userfile'], $overrides);
$file = wp_handle_upload($_FILES['import'], $overrides);
if ( isset($file['error']) )
die($file['error']);
@@ -126,7 +126,6 @@ foreach ($categories as $category) {
break;
} // end case 1
} // end switch
include('admin-footer.php');
?>
</body>
</html>

View File

@@ -6,7 +6,6 @@ require_once('admin.php');
$title = __('Manage Links');
$this_file = $parent_file = 'link-manager.php';
$list_js = true;
$wpvarstoreset = array('action','cat_id', 'linkurl', 'name', 'image',
'description', 'visible', 'target', 'category', 'link_id',
@@ -180,18 +179,18 @@ switch ($action) {
} // end Delete
case 'linkedit': {
$xfn_js = true;
include_once ('admin-header.php');
if ( !current_user_can('manage_links') )
die(__('You do not have sufficient permissions to edit the links for this blog.'));
$link_id = (int) $_GET['link_id'];
$xfn = true;
include_once ('admin-header.php');
if ( !current_user_can('manage_links') )
die(__('You do not have sufficient permissions to edit the links for this blog.'));
$link_id = (int) $_GET['link_id'];
if ( !$link = get_link_to_edit($link_id) )
die( __('Link not found.') );
include('edit-link-form.php');
break;
break;
} // end linkedit
case __("Show"):
{

View File

@@ -23,20 +23,19 @@ case 'delete-link' :
if ( !current_user_can('manage_links') )
die ('-1');
if ( wp_delete_link($id) )
if ( $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$id'") )
die('1');
else die('0');
break;
case 'delete-post' :
case 'delete-page' :
$id = (int) $_POST['id'];
if ( !current_user_can('edit_post', $id) ) {
if ( !current_user_can('edit_post', $post_id) )
die('-1');
}
if ( wp_delete_post($id) ) {
if ( wp_delete_post($id) )
die('1');
} else die('0');
else die('0');
break;
case 'delete-cat' :
if ( !current_user_can('manage_categories') )

View File

@@ -52,10 +52,4 @@ endforeach;
?>
</ul>
<?php
endif;
do_action('admin_notices');
?>
<?php endif; ?>

View File

@@ -3,7 +3,6 @@ require_once('admin.php');
$title = __('Moderate comments');
$parent_file = 'edit.php';
$list_js = true;
$wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {

View File

@@ -1,18 +1,20 @@
<?php
require_once('./admin.php');
require_once('admin.php');
$title = __('General Options');
$parent_file = 'options-general.php';
include('./admin-header.php');
include('admin-header.php');
?>
<div class="wrap">
<h2><?php _e('General Options') ?></h2>
<form method="post" action="options.php">
<table class="optiontable">
<div class="wrap">
<h2><?php _e('General Options') ?></h2>
<form name="form1" method="post" action="options.php">
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="blogname,blogdescription,siteurl,admin_email,users_can_register,gmt_offset,date_format,time_format,home,start_of_week,comment_registration,default_role" />
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th scope="row"><?php _e('Weblog title:') ?></th>
<th width="33%" scope="row"><?php _e('Weblog title:') ?></th>
<td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" size="40" /></td>
</tr>
<tr valign="top">
@@ -60,9 +62,9 @@ foreach($wp_roles->role_names as $role => $name) {
</table>
<fieldset class="options">
<legend><?php _e('Date and Time') ?></legend>
<table class="optiontable">
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr>
<th scope="row"><?php _e('<abbr title="Coordinated Universal Time">UTC</abbr> time is:') ?> </th>
<th scope="row" width="33%"><?php _e('<abbr title="Coordinated Universal Time">UTC</abbr> time is:') ?> </th>
<td><code><?php echo gmdate('Y-m-d g:i:s a'); ?></code></td>
</tr>
<tr>
@@ -96,15 +98,13 @@ endfor;
?>
</select></td>
</tr>
</table>
</fieldset>
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="blogname,blogdescription,siteurl,admin_email,users_can_register,gmt_offset,date_format,time_format,home,start_of_week,comment_registration,default_role" />
<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
</p>
</form>
</form>
</div>
<?php include('./admin-footer.php') ?>
<?php include("admin-footer.php") ?>

View File

@@ -10,40 +10,16 @@ include('admin-header.php');
<div class="wrap">
<h2><?php _e('Miscellaneous Options') ?></h2>
<form method="post" action="options.php">
<fieldset class="options">
<legend><?php _e('Uploading'); ?></legend>
<table class="editform optiontable">
<tr valign="top">
<th scope="row"><?php _e('Store uploads in this folder'); ?>:</th>
<td><input name="upload_path" type="text" id="upload_path" class="code" value="<?php echo str_replace(ABSPATH, '', get_settings('upload_path')); ?>" size="40" />
<br />
<?php _e('Default is <code>wp-content/uploads</code>'); ?>
</td>
</tr>
<tr>
<td></td>
<td>
<label for="uploads_use_yearmonth_folders">
<input name="uploads_use_yearmonth_folders" type="checkbox" id="uploads_use_yearmonth_folders" value="1" <?php checked('1', get_settings('uploads_use_yearmonth_folders')); ?> />
<?php _e('Organize my uploads into month- and year-based folders'); ?>
</label>
</td>
</tr>
</table>
</fieldset>
<form method="post" action="options.php">
<p><input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_settings('use_linksupdate')); ?> />
<label for="use_linksupdate"><?php _e('Track Links&#8217; Update Times') ?></label></p>
<p>
<label><input type="checkbox" name="hack_file" value="1" <?php checked('1', get_settings('hack_file')); ?> /> <?php _e('Use legacy <code>my-hacks.php</code> file support') ?></label>
</p>
<p class="submit">
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="hack_file,use_linksupdate,uploads_use_yearmonth_folders,upload_path" />
<input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
<input type="hidden" name="page_options" value="hack_file,use_linksupdate" />
<input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
</p>
</form>
</div>

View File

@@ -76,6 +76,8 @@ if ( isset($_POST) ) {
$permalink_structure = get_settings('permalink_structure');
$category_base = get_settings('category_base');
generate_page_rewrite_rules();
if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
$writable = true;
else
@@ -86,7 +88,7 @@ if ($wp_rewrite->using_index_permalinks())
else
$usingpi = false;
$wp_rewrite->flush_rules();
save_mod_rewrite_rules();
?>
<?php if (isset($_POST['submit'])) : ?>

View File

@@ -47,27 +47,26 @@ case 'update':
// Options that if not there have 0 value but need to be something like "closed"
$nonbools = array('default_ping_status', 'default_comment_status');
if ($options) {
foreach ($options as $option) {
$option = trim($option);
$value = trim(stripslashes($_POST[$option]));
if( in_array($option, $nonbools) && ( $value == '0' || $value == '') )
$value = 'closed';
if( $option == 'blogdescription' || $option == 'blogname' )
if (current_user_can('unfiltered_html') == false)
$value = wp_filter_post_kses( $value );
if (update_option($option, $value) ) {
$any_changed++;
}
}
}
foreach ($options as $option) {
$option = trim($option);
$value = trim(stripslashes($_POST[$option]));
if( in_array($option, $nonbools) && ( $value == '0' || $value == '') )
$value = 'closed';
if( $option == 'blogdescription' || $option == 'blogname' )
if (current_user_can('unfiltered_html') == false)
$value = wp_filter_post_kses( $value );
if ( update_option($option, $value) )
$any_changed++;
}
}
if ($any_changed) {
// If siteurl or home changed, reset cookies.
if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
// If home changed, write rewrite rules to new location.
$wp_rewrite->flush_rules();
save_mod_rewrite_rules();
// Get currently logged in user and password.
get_currentuserinfo();
// Clear cookies for old paths.
@@ -79,10 +78,10 @@ case 'update':
//$message = sprintf(__('%d setting(s) saved... '), $any_changed);
}
$referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']);
$goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']);
$goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
wp_redirect($goback);
$referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']);
$goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']);
$goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
wp_redirect($goback);
break;
default:

View File

@@ -21,7 +21,6 @@ if ( isset($_GET['action']) ) {
do_action('deactivate_' . trim( $_GET['plugin'] ));
header('Location: plugins.php?deactivate=true');
}
exit;
}
$title = __('Manage Plugins');
@@ -87,13 +86,6 @@ if (empty($plugins)) {
</tr>
<?php
$style = '';
function sort_plugins($plug1, $plug2) {
return strnatcasecmp($plug1['Name'], $plug2['Name']);
}
uksort($plugins, 'sort_plugins');
foreach($plugins as $plugin_file => $plugin_data) {
$style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';

View File

@@ -30,8 +30,7 @@ $editing = true;
switch($action) {
case 'post':
check_admin_referer();
$post_ID = write_post();
// Redirect.
@@ -75,20 +74,20 @@ case 'edit':
if ($post->post_status == 'static')
include('edit-page-form.php');
elseif ($post->post_status == 'attachment')
include('edit-attachment-form.php');
else
include('edit-form-advanced.php');
?>
<div id='preview' class='wrap'>
<h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?> <small class="quickjump"><a href="#write-post"><?php _e('edit &uarr;'); ?></a></small></h2>
<iframe src="<?php echo add_query_arg('preview', 'true', get_permalink($post->ID)); ?>" width="100%" height="600" ></iframe>
<iframe src="<?php the_permalink(); ?>" width="100%" height="600" ></iframe>
</div>
<?php
break;
case 'editattachment':
check_admin_referer();
$post_id = (int) $_POST['post_ID'];
// Don't let these be changed
@@ -105,8 +104,6 @@ case 'editattachment':
add_post_meta($post_id, '_wp_attachment_metadata', $newmeta);
case 'editpost':
check_admin_referer();
$post_ID = edit_post();
if ($_POST['save']) {
@@ -205,7 +202,7 @@ case 'confirmdeletecomment':
echo "<input type='hidden' name='noredir' value='1' />\n";
echo "<input type='submit' value='" . __('Yes') . "' />";
echo "&nbsp;&nbsp;";
echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit.php?p=$p&amp;c=1#comments';\" />\n";
echo "<input type='button' value='" . __('No') . "' onclick='self.location='". get_settings('siteurl') ."/wp-admin/edit.php?p=$p&amp;c=1#comments';' />\n";
echo "</form>\n";
echo "</div>\n";

View File

@@ -1,7 +1,7 @@
<?php
require_once('admin.php');
$title = __('Profile');
$title = 'Profile';
$parent_file = 'profile.php';
include_once('admin-header.php');

View File

@@ -86,9 +86,9 @@ default:
<?php if (isset($_GET['a'])) : ?>
<?php if ( 'err' == $_GET['a'] ) : ?>
<div id="message" class="error"><p><?php _e('Could not save file.') ?></p></div>
<?php else: ?>
<? else: ?>
<div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
<?php endif; ?>
<?endif; ?>
<?php endif; ?>
<div class="wrap">
<?php

View File

@@ -59,7 +59,7 @@ $theme_names = array_keys($themes);
natcasesort($theme_names);
foreach ($theme_names as $theme_name) {
if ( $theme_name == $ct->name )
if ( $theme_name == $current_theme )
continue;
$template = $themes[$theme_name]['Template'];
$stylesheet = $themes[$theme_name]['Stylesheet'];

View File

@@ -4,7 +4,7 @@ require_once(ABSPATH . '/wp-admin/admin-functions.php');
require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
// Functions to be called in install and upgrade scripts
function upgrade_all() {
global $wp_current_db_version, $wp_db_version, $wp_rewrite;
global $wp_current_db_version, $wp_db_version;
$wp_current_db_version = __get_option('db_version');
// We are up-to-date. Nothing to do.
@@ -33,7 +33,7 @@ function upgrade_all() {
if ( $wp_current_db_version < 3308 )
upgrade_160();
$wp_rewrite->flush_rules();
save_mod_rewrite_rules();
update_option('db_version', $wp_db_version);
}

View File

@@ -216,20 +216,11 @@ function populate_options() {
add_option('html_type', 'text/html');
// 1.5.1
add_option('use_trackback', 0);
// 2.0
// 1.6
add_option('default_role', 'subscriber');
add_option('rich_editing', 'true');
add_option('db_version', $wp_db_version);
// 2.0.1
if ( ini_get('safe_mode') ) {
// Safe mode screws up mkdir(), so we must use a flat structure.
add_option('uploads_use_yearmonth_folders', 0);
add_option('upload_path', 'wp-content');
} else {
add_option('uploads_use_yearmonth_folders', 1);
add_option('upload_path', 'wp-content/uploads');
}
// Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
foreach ($unusedoptions as $option) :
@@ -251,14 +242,14 @@ function populate_roles_160() {
global $wp_roles;
// Add roles
add_role('administrator', __('Administrator'));
add_role('editor', __('Editor'));
add_role('author', __('Author'));
add_role('contributor', __('Contributor'));
add_role('subscriber', __('Subscriber'));
$wp_roles->add_role('administrator', __('Administrator'));
$wp_roles->add_role('editor', __('Editor'));
$wp_roles->add_role('author', __('Author'));
$wp_roles->add_role('contributor', __('Contributor'));
$wp_roles->add_role('subscriber', __('Subscriber'));
// Add caps for Administrator role
$role = get_role('administrator');
$role = $wp_roles->get_role('administrator');
$role->add_cap('switch_themes');
$role->add_cap('edit_themes');
$role->add_cap('activate_plugins');
@@ -291,7 +282,7 @@ function populate_roles_160() {
$role->add_cap('level_0');
// Add caps for Editor role
$role = get_role('editor');
$role = $wp_roles->get_role('editor');
$role->add_cap('moderate_comments');
$role->add_cap('manage_categories');
$role->add_cap('manage_links');
@@ -313,7 +304,7 @@ function populate_roles_160() {
$role->add_cap('level_0');
// Add caps for Author role
$role = get_role('author');
$role = $wp_roles->get_role('author');
$role->add_cap('upload_files');
$role->add_cap('edit_posts');
$role->add_cap('edit_published_posts');
@@ -324,14 +315,14 @@ function populate_roles_160() {
$role->add_cap('level_0');
// Add caps for Contributor role
$role = get_role('contributor');
$role = $wp_roles->get_role('contributor');
$role->add_cap('edit_posts');
$role->add_cap('read');
$role->add_cap('level_1');
$role->add_cap('level_0');
// Add caps for Subscriber role
$role = get_role('subscriber');
$role = $wp_roles->get_role('subscriber');
$role->add_cap('read');
$role->add_cap('level_0');
}

View File

@@ -67,10 +67,9 @@ text-align: center; border-top: 1px solid #ccc; padding-top: 1em; font-style: it
switch($step) {
case 0:
$goback = wp_specialchars($_SERVER['HTTP_REFERER'], 1);
?>
<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&amp;backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress &raquo;'); ?></a></h2>
<h2 class="step"><a href="upgrade.php?step=1"><?php _e('Upgrade WordPress &raquo;'); ?></a></h2>
<?php
break;
@@ -79,14 +78,9 @@ switch($step) {
make_db_current_silent();
upgrade_all();
wp_cache_flush();
if ( empty( $_GET['backto'] ) )
$backto = __get_option('home');
else
$backto = wp_specialchars( $_GET['backto'] , 1 );
?>
<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>!"), $backto); ?></p>
<p><?php printf(__("There's actually only one step. So if you see this, you're done. <a href='%s'>Have fun</a>!"), __get_option('home') . '/'); ?></p>
<!--
<pre>

View File

@@ -32,8 +32,6 @@ break;
case 'update':
check_admin_referer();
$errors = array();
if (!current_user_can('edit_users'))

View File

@@ -149,7 +149,7 @@ default:
foreach($userids as $userid) {
$tmp_user = new WP_User($userid);
$roles = $tmp_user->roles;
$role = array_shift($roles);
$role = $roles[0];
$roleclasses[$role][$tmp_user->user_login] = $tmp_user;
}

View File

@@ -297,19 +297,6 @@ form#upload #post_content {
text-align: right;
}
.optiontable {
width: 100%;
}
.optiontable td, .optiontable th {
padding: .5em;
}
.optiontable th {
width: 33%;
text-align: right;
}
.unapproved {
color: #888;
}
@@ -745,10 +732,6 @@ table .vers, table .name {
display:block;
}
#grabit {
width: 188px;
}
* html #themeselect {
padding: 0px 3px;
height: 22px;
@@ -780,9 +763,6 @@ table .vers, table .name {
right: 5%;
width: 14.5em;
}
#moremeta select {
width: 96%;
}
#slugdiv input, #passworddiv input, #authordiv select, #thumbdiv input, #parentdiv input {
margin-top: .5em;
@@ -922,28 +902,3 @@ a.dbx-toggle, a.dbx-toggle:visited {
-khtml-opacity: 0.8;
filter: alpha(opacity=80);
}
#newcat { width: 120px; margin-right: 5px; }
input#catadd { background: #a4a4a4;
border-bottom: 1px solid #898989;
border-left: 1px solid #bcbcbc;
border-right: 1px solid #898989;
border-top: 1px solid #bcbcbc;
color: #fff;
font-size: 10px;
padding: 0;
margin: 0;
font-weight: bold;
height: 20px;
margin-bottom: 2px;
text-align: center;
width: 37px; }
#howto {
font-size: 11px;
margin: 0 5px;
display: block;
}
#jaxcat {
margin: 0;
padding: 0;
}

View File

@@ -1,46 +0,0 @@
function GetElementsWithClassName(elementName, className) {
var allElements = document.getElementsByTagName(elementName);
var elemColl = new Array();
for (i = 0; i < allElements.length; i++) {
if (allElements[i].className == className) {
elemColl[elemColl.length] = allElements[i];
}
}
return elemColl;
}
function meChecked() {
var undefined;
var eMe = document.getElementById('me');
if (eMe == undefined) return false;
else return eMe.checked;
}
function upit() {
var isMe = meChecked(); //document.getElementById('me').checked;
var inputColl = GetElementsWithClassName('input', 'valinp');
var results = document.getElementById('link_rel');
var linkText, linkUrl, inputs = '';
for (i = 0; i < inputColl.length; i++) {
inputColl[i].disabled = isMe;
inputColl[i].parentNode.className = isMe ? 'disabled' : '';
if (!isMe && inputColl[i].checked && inputColl[i].value != '') {
inputs += inputColl[i].value + ' ';
}
}
inputs = inputs.substr(0,inputs.length - 1);
if (isMe) inputs='me';
results.value = inputs;
}
function blurry() {
if (!document.getElementById) return;
var aInputs = document.getElementsByTagName('input');
for (var i = 0; i < aInputs.length; i++) {
aInputs[i].onclick = aInputs[i].onkeyup = upit;
}
}
addLoadEvent(blurry);

View File

@@ -48,17 +48,16 @@ if ( '' == $comment_content )
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID');
$comment_id = wp_new_comment( $commentdata );
wp_new_comment( $commentdata );
if ( !$user_ID ) :
$comment = get_comment($comment_id);
setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
setcookie('comment_author_url_' . COOKIEHASH, clean_url($comment->comment_author_url), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
setcookie('comment_author_' . COOKIEHASH, stripslashes($comment_author), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
setcookie('comment_author_email_' . COOKIEHASH, stripslashes($comment_author_email), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
setcookie('comment_author_url_' . COOKIEHASH, stripslashes($comment_author_url), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
endif;
$location = ( empty( $_POST['redirect_to'] ) ) ? get_permalink( $comment_post_ID ) : $_POST['redirect_to'];
wp_redirect( $location );
?>
?>

View File

@@ -645,7 +645,7 @@ class wpdbBackup {
// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$boundary}\n" .
"Content-Type: text/plain; charset=\"utf-8\"\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";

View File

@@ -25,18 +25,16 @@ function kubrick_header_image() {
}
function kubrick_upper_color() {
if ( strstr( $url = kubrick_header_image_url(), 'header-img.php?' ) ) {
parse_str(substr($url, strpos($url, '?') + 1), $q);
return $q['upper'];
} else
if ( strstr( kubrick_header_image_url(), 'header-img.php?' ) )
return substr( kubrick_header_image(), 21, 6 );
else
return '69aee7';
}
function kubrick_lower_color() {
if ( strstr( $url = kubrick_header_image_url(), 'header-img.php?' ) ) {
parse_str(substr($url, strpos($url, '?') + 1), $q);
return $q['lower'];
} else
if ( strstr( kubrick_header_image_url(), 'header-img.php?' ) )
return substr( kubrick_header_image(), 34, 6 );
else
return '4180b6';
}
@@ -128,7 +126,7 @@ function kubrick_add_theme_page() {
}
add_action('admin_head', 'kubrick_theme_page_head');
}
add_theme_page('Customize Header', 'Header Image and Color', 'edit_themes', basename(__FILE__), 'kubrick_theme_page');
add_theme_page("Kubrick Theme Options", "Current Theme Options", 'edit_themes', basename(__FILE__), 'kubrick_theme_page');
}
function kubrick_theme_page_head() {

View File

@@ -8,14 +8,11 @@ if ( ! function_exists('imagecreatefromjpeg') )
// Assign and validate the color values
$default = false;
$vars = array('upper'=>array('r1', 'g1', 'b1'), 'lower'=>array('r2', 'g2', 'b2'));
$vars = array('upper'=>array(0=>'r1', 2=>'g1', 4=>'b1'), 'lower'=>array(0=>'r2', 2=>'g2', 4=>'b2'));
foreach ( $vars as $var => $subvars ) {
if ( isset($_GET[$var]) ) {
foreach ( $subvars as $index => $subvar ) {
$length = strlen($_GET[$var]) / 3;
$v = substr($_GET[$var], $index * $length, $length);
if ( $length == 1 ) $v = '' . $v . $v;
$$subvar = hexdec( $v );
$$subvar = hexdec( substr($_GET[$var], $index, 2) );
if ( $$subvar < 0 || $$subvar > 255 )
$default = true;
}

View File

@@ -90,7 +90,7 @@ h1 {
text-align: center;
}
#headerimg .description {
.description {
font-size: 1.2em;
text-align: center;
}
@@ -112,7 +112,7 @@ h3 {
font-size: 1.3em;
}
h1, h1 a, h1 a:hover, h1 a:visited, #headerimg .description {
h1, h1 a, h1 a:hover, h1 a:visited, .description {
text-decoration: none;
color: white;
}
@@ -302,6 +302,10 @@ h1 {
margin: 0;
}
.description {
text-align: center;
}
h2 {
margin: 30px 0 0;
}

View File

@@ -53,9 +53,8 @@ define('CACHE_SERIAL_FOOTER', "\n?".">");
class WP_Object_Cache {
var $cache_dir;
var $cache_enabled = false;
var $expiration_time = 900;
var $expiration_time = 86400;
var $flock_filename = 'wp_object_cache.lock';
var $mutex;
var $cache = array ();
var $dirty_objects = array ();
var $non_existant_objects = array ();
@@ -65,15 +64,6 @@ class WP_Object_Cache {
var $warm_cache_hits = 0;
var $cache_misses = 0;
function acquire_lock() {
// Acquire a write lock.
$this->mutex = @fopen($this->cache_dir.$this->flock_filename, 'w');
if ( false == $this->mutex)
return false;
flock($this->mutex, LOCK_EX);
return true;
}
function add($id, $data, $group = 'default', $expire = '') {
if (empty ($group))
$group = 'default';
@@ -99,18 +89,12 @@ class WP_Object_Cache {
function flush() {
if ( !$this->cache_enabled )
return true;
if ( ! $this->acquire_lock() )
return false;
return;
$this->rm_cache_dir();
$this->rm($this->cache_dir.'*');
$this->cache = array ();
$this->dirty_objects = array ();
$this->non_existant_objects = array ();
$this->release_lock();
return true;
}
@@ -221,55 +205,32 @@ class WP_Object_Cache {
}
if (!file_exists($this->cache_dir.$make_dir."index.php")) {
$file_perms = $perms & 0000666;
@ touch($this->cache_dir.$make_dir."index.php");
@ chmod($this->cache_dir.$make_dir."index.php", $file_perms);
}
}
return $this->cache_dir."$group_dir/";
}
function rm_cache_dir() {
$dir = $this->cache_dir;
$dir = rtrim($dir, DIRECTORY_SEPARATOR);
$top_dir = $dir;
$stack = array($dir);
$index = 0;
while ($index < count($stack)) {
# Get indexed directory from stack
$dir = $stack[$index];
$dh = @ opendir($dir);
if (!$dh)
return false;
while (($file = @ readdir($dh)) !== false) {
if ($file == '.' or $file == '..')
continue;
if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file))
@ unlink($dir . DIRECTORY_SEPARATOR . $file);
function rm($fileglob) {
if (is_file($fileglob)) {
return @ unlink($fileglob);
} else
if (is_dir($fileglob)) {
$ok = WP_Object_Cache::rm("$fileglob/*");
if (!$ok)
return false;
return @ rmdir($fileglob);
} else {
$matching = glob($fileglob);
if ($matching === false)
return true;
$rcs = array_map(array ('WP_Object_Cache', 'rm'), $matching);
if (in_array(false, $rcs)) {
return false;
}
}
$index++;
}
$stack = array_reverse($stack); // Last added dirs are deepest
foreach($stack as $dir) {
if ( $dir != $top_dir)
@ rmdir($dir);
}
}
function release_lock() {
// Release write lock.
flock($this->mutex, LOCK_UN);
fclose($this->mutex);
return true;
}
function replace($id, $data, $group = 'default', $expire = '') {
@@ -300,33 +261,33 @@ class WP_Object_Cache {
//$this->stats();
if (!$this->cache_enabled)
return true;
return;
if (empty ($this->dirty_objects))
return true;
return;
// Give the new dirs the same perms as wp-content.
$stat = stat(ABSPATH.'wp-content');
$dir_perms = $stat['mode'] & 0007777; // Get the permission bits.
$file_perms = $dir_perms & 0000666; // Remove execute bits for files.
$dir_perms = $stat['mode'] & 0000777; // Get the permission bits.
// Make the base cache dir.
if (!file_exists($this->cache_dir)) {
if (! @ mkdir($this->cache_dir))
return false;
return;
@ chmod($this->cache_dir, $dir_perms);
}
if (!file_exists($this->cache_dir."index.php")) {
@ touch($this->cache_dir."index.php");
@ chmod($this->cache_dir."index.php", $file_perms);
}
if ( ! $this->acquire_lock() )
return false;
// Acquire a write lock.
$mutex = @fopen($this->cache_dir.$this->flock_filename, 'w');
if ( false == $mutex)
return;
flock($mutex, LOCK_EX);
// Loop over dirty objects and save them.
$errors = 0;
foreach ($this->dirty_objects as $group => $ids) {
$group_dir = $this->make_group_dir($group, $dir_perms);
@@ -337,37 +298,28 @@ class WP_Object_Cache {
// Remove the cache file if the key is not set.
if (!isset ($this->cache[$group][$id])) {
if (file_exists($cache_file))
@ unlink($cache_file);
unlink($cache_file);
continue;
}
$temp_file = tempnam($group_dir, 'tmp');
$serial = CACHE_SERIAL_HEADER.serialize($this->cache[$group][$id]).CACHE_SERIAL_FOOTER;
$fd = @fopen($temp_file, 'w');
if ( false === $fd ) {
$errors++;
if ( false === $fd )
continue;
}
fputs($fd, $serial);
fclose($fd);
if (!@ rename($temp_file, $cache_file)) {
if (@ copy($temp_file, $cache_file))
if (@ copy($temp_file, $cache_file)) {
@ unlink($temp_file);
else
$errors++;
}
}
@ chmod($cache_file, $file_perms);
}
}
$this->dirty_objects = array();
$this->release_lock();
if ( $errors )
return false;
return true;
// Release write lock.
flock($mutex, LOCK_UN);
fclose($mutex);
}
function stats() {
@@ -400,23 +352,17 @@ class WP_Object_Cache {
if (defined('DISABLE_CACHE'))
return;
// Disable the persistent cache if safe_mode is on.
if ( ini_get('safe_mode') && ! defined('ENABLE_CACHE') )
return;
if (defined('CACHE_PATH'))
$this->cache_dir = CACHE_PATH;
else
// Using the correct separator eliminates some cache flush errors on Windows
$this->cache_dir = ABSPATH.'wp-content'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;
$this->cache_dir = ABSPATH.'wp-content/cache/';
if (is_writable($this->cache_dir) && is_dir($this->cache_dir)) {
$this->cache_enabled = true;
} else {
} else
if (is_writable(ABSPATH.'wp-content')) {
$this->cache_enabled = true;
}
}
if (defined('CACHE_EXPIRATION_TIME'))
$this->expiration_time = CACHE_EXPIRATION_TIME;

View File

@@ -85,9 +85,6 @@ class WP_Role {
function add_cap($cap, $grant = true) {
global $wp_roles;
if ( ! isset($wp_roles) )
$wp_roles = new WP_Roles();
$this->capabilities[$cap] = $grant;
$wp_roles->add_cap($this->name, $cap, $grant);
}
@@ -95,9 +92,6 @@ class WP_Role {
function remove_cap($cap) {
global $wp_roles;
if ( ! isset($wp_roles) )
$wp_roles = new WP_Roles();
unset($this->capabilities[$cap]);
$wp_roles->remove_cap($this->name, $cap);
}
@@ -121,7 +115,7 @@ class WP_User {
var $allcaps = array();
function WP_User($id, $name = '') {
global $table_prefix;
global $wp_roles, $table_prefix;
if ( empty($id) && empty($name) )
return;
@@ -153,10 +147,6 @@ class WP_User {
function get_role_caps() {
global $wp_roles;
if ( ! isset($wp_roles) )
$wp_roles = new WP_Roles();
//Filter out caps that are not role names and assign to $this->roles
if(is_array($this->caps))
$this->roles = array_filter(array_keys($this->caps), array(&$wp_roles, 'is_role'));
@@ -224,6 +214,8 @@ class WP_User {
//has_cap(capability_or_role_name) or
//has_cap('edit_post', post_id)
function has_cap($cap) {
global $wp_roles;
if ( is_numeric($cap) )
$cap = $this->translate_level_to_cap($cap);
@@ -324,27 +316,18 @@ function current_user_can($capability) {
function get_role($role) {
global $wp_roles;
if ( ! isset($wp_roles) )
$wp_roles = new WP_Roles();
return $wp_roles->get_role($role);
}
function add_role($role, $display_name, $capabilities = '') {
global $wp_roles;
if ( ! isset($wp_roles) )
$wp_roles = new WP_Roles();
return $wp_roles->add_role($role, $display_name, $capabilities);
return $wp_roles->add_role($role, $display_name, $capabilities = '');
}
function remove_role($role) {
global $wp_roles;
if ( ! isset($wp_roles) )
$wp_roles = new WP_Roles();
return $wp_roles->remove_role($role);
}

View File

@@ -5,7 +5,6 @@ class WP_Query {
var $query_vars;
var $queried_object;
var $queried_object_id;
var $request;
var $posts;
var $post_count = 0;
@@ -226,11 +225,6 @@ class WP_Query {
if ('' != $qv['comments_popup']) {
$this->is_comments_popup = true;
}
//if we're previewing inside the write screen
if ('' != $qv['preview']) {
$this->is_preview = true;
}
if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) {
$this->is_admin = true;
@@ -263,7 +257,7 @@ class WP_Query {
}
function &get_posts() {
global $wpdb, $pagenow, $user_ID;
global $wpdb, $pagenow, $request, $user_ID;
do_action('pre_get_posts', array(&$this));
@@ -377,19 +371,17 @@ class WP_Query {
$all_page_ids = get_all_page_ids();
$reqpage = 0;
if (is_array($all_page_ids)) { foreach ( $all_page_ids as $page_id ) {
foreach ( $all_page_ids as $page_id ) {
$page = get_page($page_id);
if ( $page->fullpath == $page_path ) {
$reqpage = $page_id;
break;
}
} }
}
$where .= " AND (ID = '$reqpage')";
} elseif ('' != $q['attachment']) {
$q['attachment'] = str_replace('%2F', '/', urlencode(urldecode($q['attachment'])));
$attach_paths = '/' . trim($q['attachment'], '/');
$q['attachment'] = sanitize_title(basename($attach_paths));
$q['attachment'] = sanitize_title($q['attachment']);
$q['name'] = $q['attachment'];
$where .= " AND post_name = '" . $q['attachment'] . "'";
}
@@ -491,21 +483,14 @@ class WP_Query {
$cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
$all_cat_ids = get_all_category_ids();
$q['cat'] = 0; $partial_match = 0;
$q['cat'] = 0;
foreach ( $all_cat_ids as $cat_id ) {
$cat = get_category($cat_id);
if ( $cat->fullpath == $cat_path ) {
$q['cat'] = $cat_id;
break;
} elseif ( $cat->category_nicename == $q['category_name'] ) {
$partial_match = $cat_id;
}
}
//if we don't match the entire hierarchy fallback on just matching the nicename
if (!$q['cat'] && $partial_match) {
$q['cat'] = $partial_match;
}
$tables = ", $wpdb->post2cat, $wpdb->categories";
$join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
@@ -649,12 +634,12 @@ class WP_Query {
$orderby = "post_" . $q['orderby'];
$orderby = apply_filters('posts_orderby', $orderby);
$request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1" . $where . " GROUP BY " . $groupby . " ORDER BY " . $orderby . " $limits";
$this->request = apply_filters('posts_request', $request);
$request = apply_filters('posts_request', $request);
$this->posts = $wpdb->get_results($this->request);
$this->posts = $wpdb->get_results($request);
// Check post status to determine if post should be displayed.
if ( !empty($this->posts) && $this->is_single ) {
if ($this->is_single) {
$status = get_post_status($this->posts[0]);
if ( ('publish' != $status) && ('static' != $status) ) {
if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) {
@@ -667,7 +652,6 @@ class WP_Query {
$this->posts = array();
} else {
$this->is_preview = true;
$this->posts[0]->post_date = current_time('mysql');
}
} else {
if (! current_user_can('read_post', $this->posts[0]->ID))
@@ -969,22 +953,16 @@ class WP_Rewrite {
function page_rewrite_rules() {
$uris = get_settings('page_uris');
$attachment_uris = get_settings('page_attachment_uris');
$rewrite_rules = array();
$page_structure = $this->get_page_permastruct();
if( is_array( $attachment_uris ) ) {
foreach ($attachment_uris as $uri => $pagename) {
$this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
$rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure));
if( is_array( $uris ) )
{
foreach ($uris as $uri => $pagename) {
$this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
$rewrite_rules += $this->generate_rewrite_rules($page_structure);
}
}
}
if( is_array( $uris ) ) {
foreach ($uris as $uri => $pagename) {
$this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
$rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure));
}
}
return $rewrite_rules;
}
@@ -1175,7 +1153,7 @@ class WP_Rewrite {
}
}
function generate_rewrite_rules($permalink_structure, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true) {
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 . '|';
@@ -1243,18 +1221,15 @@ class WP_Rewrite {
$rewrite = array();
if ($feed)
$rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
if ($paged)
$rewrite = array_merge($rewrite, array($pagematch => $pagequery));
if ($page)
$rewrite = $rewrite + array($pagematch => $pagequery);
if ($num_toks) {
$post = false;
$page = false;
$post = 0;
if (strstr($struct, '%postname%') || strstr($struct, '%post_id%')
|| strstr($struct, '%pagename%')
|| (strstr($struct, '%year%') && strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) {
$post = true;
if ( strstr($struct, '%pagename%') )
$page = true;
$post = 1;
$trackbackmatch = $match . $trackbackregex;
$trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
$match = rtrim($match, '/');
@@ -1279,17 +1254,18 @@ class WP_Rewrite {
$query = $index . '?' . $query;
}
$rewrite = array_merge($rewrite, array($match => $query));
$rewrite = $rewrite + array($match => $query);
if ($post) {
$rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite);
if ( ! $page )
$rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery));
$rewrite = array_merge($rewrite, array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery));
$rewrite = array($trackbackmatch => $trackbackquery) + $rewrite +
array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery) +
array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery);
}
}
$post_rewrite = array_merge($rewrite, $post_rewrite);
$post_rewrite = $rewrite + $post_rewrite;
}
return $post_rewrite;
}
@@ -1321,7 +1297,7 @@ class WP_Rewrite {
$root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
// Comments
$comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, true, true, true, false);
$comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, true, true, true);
$comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
// Search
@@ -1342,7 +1318,7 @@ class WP_Rewrite {
$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
// Put them together.
$this->rules = array_merge($page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite);
$this->rules = $page_rewrite + $root_rewrite + $comments_rewrite + $search_rewrite + $category_rewrite + $author_rewrite + $date_rewrite + $post_rewrite;
do_action('generate_rewrite_rules', array(&$this));
$this->rules = apply_filters('rewrite_rules_array', $this->rules);
@@ -1351,14 +1327,8 @@ class WP_Rewrite {
}
function wp_rewrite_rules() {
$this->rules = get_option('rewrite_rules');
if ( empty($this->rules) ) {
$this->matches = 'matches';
$this->rewrite_rules();
update_option('rewrite_rules', $this->rules);
}
return $this->rules;
$this->matches = 'matches';
return $this->rewrite_rules();
}
function mod_rewrite_rules() {
@@ -1403,7 +1373,7 @@ class WP_Rewrite {
} else {
$rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
"RewriteCond %{REQUEST_FILENAME} !-d\n" .
"RewriteRule . {$home_root}{$this->index} [L]\n";
"RewriteRule . {$home_root}{$this->index}\n";
}
$rules .= "</IfModule>\n";
@@ -1414,14 +1384,6 @@ class WP_Rewrite {
return $rules;
}
function flush_rules() {
generate_page_rewrite_rules();
delete_option('rewrite_rules');
$this->wp_rewrite_rules();
if ( function_exists('save_mod_rewrite_rules') )
save_mod_rewrite_rules();
}
function init() {
$this->permalink_structure = get_settings('permalink_structure');
$this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));
@@ -1459,7 +1421,7 @@ class WP_Rewrite {
}
class WP {
var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview');
var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id');
var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'show_post_type');
@@ -1499,27 +1461,22 @@ class WP {
$self = $_SERVER['PHP_SELF'];
$home_path = parse_url(get_settings('home'));
$home_path = $home_path['path'];
$home_path = trim($home_path, '/');
// Trim path info from the end and the leading home path from the
// front. For path info requests, this leaves us with the requesting
// filename, if any. For 404 requests, this leaves us with the
// requested permalink.
$req_uri = str_replace($pathinfo, '', $req_uri);
$req_uri = str_replace($home_path, '', $req_uri);
$req_uri = trim($req_uri, '/');
$req_uri = preg_replace("|^$home_path|", '', $req_uri);
$req_uri = trim($req_uri, '/');
$pathinfo = str_replace($home_path, '', $pathinfo);
$pathinfo = trim($pathinfo, '/');
$pathinfo = preg_replace("|^$home_path|", '', $pathinfo);
$pathinfo = trim($pathinfo, '/');
$self = trim($self, '/');
$self = preg_replace("|^$home_path|", '', $self);
$self = str_replace($home_path, '', $self);
$self = trim($self, '/');
// The requested permalink is in $pathinfo for path info requests and
// $req_uri for other requests.
if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) {
if ( ! empty($pathinfo) && ($wp_rewrite->index != $pathinfo) ) {
$request = $pathinfo;
} else {
// If the request uri is the index, blank it out so that we don't try to match it against a rule.
@@ -1672,7 +1629,6 @@ class WP {
$GLOBALS['query_string'] = & $this->query_string;
$GLOBALS['posts'] = & $wp_query->posts;
$GLOBALS['post'] = & $wp_query->post;
$GLOBALS['request'] = & $wp_query->request;
if ( is_single() || is_page() ) {
$GLOBALS['more'] = 1;
@@ -1695,7 +1651,7 @@ class WP {
// issue a 404 if one was already issued, if the request was a search,
// or if the request was a regular query string request rather than a
// permalink request.
if ( (0 == count($wp_query->posts)) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
if ( (0 == count($wp_query->posts)) && !is_404() && !is_category() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
$wp_query->set_404();
status_header( 404 );
} elseif( is_404() != true ) {

View File

@@ -7,25 +7,9 @@ function comments_template( $file = '/comments.php' ) {
if ( is_single() || is_page() || $withcomments ) :
$req = get_settings('require_name_email');
$comment_author = '';
if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
$comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
$comment_author = stripslashes($comment_author);
$comment_author = wp_specialchars($comment_author, true);
}
$comment_author_email = '';
if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
$comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
$comment_author_email = stripslashes($comment_author_email);
$comment_author_email = wp_specialchars($comment_author_email, true);
}
$comment_author_url = '';
if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
$comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
$comment_author_url = stripslashes($comment_author_url);
$comment_author_url = wp_specialchars($comment_author_url, true);
}
$comment_author = isset($_COOKIE['comment_author_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_'.COOKIEHASH])) : '';
$comment_author_email = isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_email_'.COOKIEHASH])) : '';
$comment_author_url = isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_url_'.COOKIEHASH])) : '';
if ( empty($comment_author) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date");
} else {
@@ -92,8 +76,6 @@ function wp_insert_comment($commentdata) {
$comment_date_gmt = gmdate('Y-m-d H:i:s', strtotime($comment_date) );
if ( ! isset($comment_parent) )
$comment_parent = 0;
if ( ! isset($comment_approved) )
$comment_approved = 1;
$result = $wpdb->query("INSERT INTO $wpdb->comments
(comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id)
@@ -306,7 +288,7 @@ function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Com
} else {
if (!empty($post->post_password)) { // if there's a password
if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
echo(__('Enter your password to view comments'));
echo('Enter your password to view comments');
return;
}
}
@@ -559,20 +541,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;
@@ -650,11 +632,10 @@ function pingback($content, $post_ID) {
$post_links[] = $link_test;
elseif(($test['path'] != '/') && ($test['path'] != ''))
$post_links[] = $link_test;
do_action('pre_ping', array(&$post_links, &$pung));
endif;
endforeach;
do_action('pre_ping', array(&$post_links, &$pung));
foreach ($post_links as $pagelinkedto){
debug_fwrite($log, "Processing -- $pagelinkedto\n");
$pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);

View File

@@ -47,14 +47,6 @@ function printr($var, $do_not_echo = false) {
return $code;
}
/* compatibility with PHP versions older than 4.3 */
if ( !function_exists('file_get_contents') ) {
function file_get_contents( $file ) {
$file = file($file);
return !$file ? false : implode('', $file);
}
}
if (!defined('CASE_LOWER')) {
define('CASE_LOWER', 0);
}
@@ -97,4 +89,67 @@ if (!function_exists('array_change_key_case')) {
}
}
/* Added in PHP 4.3.0 */
if( !function_exists('glob') ):
function glob($pattern) {
// get pathname (everything up until the last / or \)
$path=$output=null;
// if(PHP_OS=='WIN32')
// $slash='\\';
// else
// $slash='/';
$slash = '/';
$lastpos=strrpos($pattern,$slash);
if(!($lastpos===false)) {
$path=substr($pattern,0,$lastpos); #negative length means take from the right
$pattern=substr($pattern,$lastpos+1);
} else {
//no dir info, use current dir
$path=getcwd();
}
$handle=@ opendir($path);
if($handle===false)
return false;
while($dir=readdir($handle)) {
if ( '.' == $dir || '..' == $dir )
continue;
if (pattern_match($pattern,$dir))
$output[]=$path . '/' . $dir;
}
closedir($handle);
if(is_array($output))
return $output;
return false;
}
function pattern_match($pattern,$string) {
// basically prepare a regular expression
$out=null;
$chunks=explode(';',$pattern);
foreach($chunks as $pattern) {
$escape=array('$','^','.','{','}','(',')','[',']','|');
while(strpos($pattern,'**')!==false)
$pattern=str_replace('**','*',$pattern);
foreach($escape as $probe)
$pattern=str_replace($probe,"\\$probe",$pattern);
$pattern=str_replace('?*','*',
str_replace('*?','*',
str_replace('*',".*",
str_replace('?','.{1,1}',$pattern))));
$out[]=$pattern;
}
if(count($out)==1)
return(eregi("^$out[0]$",$string));
else
foreach($out as $tester)
if(eregi("^$tester$",$string))
return true;
return false;
}
endif;
?>

View File

@@ -265,18 +265,8 @@ function remove_accents($string) {
return $string;
}
function sanitize_user( $username, $strict = false ) {
$raw_username = $username;
$username = strip_tags($username);
// Kill octets
$username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $username);
$username = preg_replace('/&.+?;/', '', $username); // Kill entities
// If strict, reduce to ASCII for max portability.
if ( $strict )
$username = preg_replace('|[^a-z0-9 _.-@]|i', '', $username);
return apply_filters('sanitize_user', $username, $raw_username, $strict);
function sanitize_user( $username ) {
return preg_replace('|a-z0-9 _.-|i', '', $username);
}
function sanitize_title($title, $fallback_title = '') {

View File

@@ -6,7 +6,7 @@
* generic function for inserting data into the posts table.
*/
function wp_insert_post($postarr = array()) {
global $wpdb, $wp_rewrite, $allowedtags, $user_ID;
global $wpdb, $allowedtags, $user_ID;
if ( is_object($postarr) )
$postarr = get_object_vars($postarr);
@@ -121,7 +121,7 @@ function wp_insert_post($postarr = array()) {
if ($update) {
$wpdb->query(
"UPDATE IGNORE $wpdb->posts SET
"UPDATE $wpdb->posts SET
post_author = '$post_author',
post_date = '$post_date',
post_date_gmt = '$post_date_gmt',
@@ -143,7 +143,7 @@ function wp_insert_post($postarr = array()) {
WHERE ID = $post_ID");
} else {
$wpdb->query(
"INSERT IGNORE INTO $wpdb->posts
"INSERT INTO $wpdb->posts
(post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
VALUES
('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type')");
@@ -196,8 +196,7 @@ function wp_insert_post($postarr = array()) {
spawn_pinger();
}
} else if ($post_status == 'static') {
wp_cache_delete('all_page_ids', 'pages');
$wp_rewrite->flush_rules();
generate_page_rewrite_rules();
if ( !empty($page_template) )
if ( ! update_post_meta($post_ID, '_wp_page_template', $page_template))
@@ -489,6 +488,10 @@ function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array(
$old_categories = array_unique($old_categories);
}
$oldies = printr($old_categories,1);
$newbies = printr($post_categories,1);
// Delete any?
$delete_cats = array_diff($old_categories,$post_categories);
@@ -523,7 +526,7 @@ function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array(
} // wp_set_post_cats()
function wp_delete_post($postid = 0) {
global $wpdb, $wp_rewrite;
global $wpdb;
$postid = (int) $postid;
if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") )
@@ -555,11 +558,9 @@ function wp_delete_post($postid = 0) {
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid");
if ( 'static' == $post->post_status ) {
wp_cache_delete('all_page_ids', 'pages');
$wp_rewrite->flush_rules();
}
if ( 'static' == $post->post_status )
generate_page_rewrite_rules();
return $post;
}
@@ -682,7 +683,7 @@ function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_age
function wp_proxy_check($ipnum) {
if ( get_option('open_proxy_check') && isset($ipnum) ) {
$rev_ip = implode( '.', array_reverse( explode( '.', $ipnum ) ) );
$lookup = $rev_ip . '.opm.blitzed.org.';
$lookup = $rev_ip . '.opm.blitzed.org';
if ( $lookup != gethostbyname( $lookup ) )
return true;
}
@@ -696,21 +697,15 @@ 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) ) {
$wpdb->query("UPDATE $wpdb->posts SET to_ping = '' WHERE ID = '$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);
if ( function_exists('mb_strcut') ) // For international trackbacks
$excerpt = mb_strcut($excerpt, 0, 252, get_settings('blog_charset')) . '...';
else
$excerpt = substr($excerpt, 0, 252) . '...';
$excerpt = substr($excerpt, 0, 252) . '...';
$post_title = apply_filters('the_title', $post->post_title);
$post_title = strip_tags($post_title);
@@ -797,29 +792,19 @@ function generate_page_rewrite_rules() {
$posts = array_reverse($posts, true);
$page_rewrite_rules = array();
$page_attachment_rewrite_rules = array();
if ($posts) {
foreach ($posts as $id => $post) {
// URI => page name
$uri = get_page_uri($id);
$attachments = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_status = 'attachment' AND post_parent = '$id'");
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
$attach_uri = get_page_uri($attachment->ID);
$page_attachment_rewrite_rules[$attach_uri] = $attachment->post_name;
}
}
$page_rewrite_rules[$uri] = $post;
}
update_option('page_uris', $page_rewrite_rules);
if ( $page_attachment_rewrite_rules )
update_option('page_attachment_uris', $page_attachment_rewrite_rules);
save_mod_rewrite_rules();
}
}
@@ -850,66 +835,48 @@ function get_attached_file($attachment_id) {
return get_post_meta($attachment_id, '_wp_attached_file', true);
}
function wp_mkdir_p($target) {
// from php.net/mkdir user contributed notes
if (file_exists($target)) {
if (! @ is_dir($target))
return false;
else
return true;
}
// Attempting to create the directory may clutter up our display.
if (@ mkdir($target)) {
$stat = @ stat(dirname($target));
$dir_perms = $stat['mode'] & 0007777; // Get the permission bits.
@ chmod($target, $dir_perms);
return true;
} else {
if ( is_dir(dirname($target)) )
return false;
}
// If the above failed, attempt to create the parent node, then try again.
if (wp_mkdir_p(dirname($target)))
return wp_mkdir_p($target);
return false;
}
// Returns an array containing the current upload directory's path and url, or an error message.
function wp_upload_dir() {
$siteurl = get_settings('siteurl');
//prepend ABSPATH to $dir and $siteurl to $url if they're not already there
$path = str_replace(ABSPATH, '', trim(get_settings('upload_path')));
$dir = ABSPATH . $path;
$url = trailingslashit($siteurl) . $path;
if ( defined('UPLOADS') )
$dir = UPLOADS;
else
$dir = 'wp-content/uploads';
if ( $dir == ABSPATH ) { //the option was empty
$dir = ABSPATH . 'wp-content/uploads';
$path = ABSPATH . $dir;
// Give the new dirs the same perms as wp-content.
$stat = stat(ABSPATH . 'wp-content');
$dir_perms = $stat['mode'] & 0000777; // Get the permission bits.
// Make sure we have an uploads dir
if ( ! file_exists( $path ) ) {
if ( ! @ mkdir( $path ) )
return array('error' => "Unable to create directory $path. Is its parent directory writable by the server?");
@ chmod( $path, $dir_perms );
}
if ( defined('UPLOADS') ) {
$dir = ABSPATH . UPLOADS;
$url = trailingslashit($siteurl) . UPLOADS;
// Generate the yearly and monthly dirs
$time = current_time( 'mysql' );
$y = substr( $time, 0, 4 );
$m = substr( $time, 5, 2 );
$pathy = "$path/$y";
$pathym = "$path/$y/$m";
// Make sure we have a yearly dir
if ( ! file_exists( $pathy ) ) {
if ( ! @ mkdir( $pathy ) )
return array('error' => "Unable to create directory $pathy. Is $path writable?");
@ chmod( $pathy, $dir_perms );
}
if ( get_settings('uploads_use_yearmonth_folders')) {
// Generate the yearly and monthly dirs
$time = current_time( 'mysql' );
$y = substr( $time, 0, 4 );
$m = substr( $time, 5, 2 );
$dir = $dir . "/$y/$m";
$url = $url . "/$y/$m";
// Make sure we have a monthly dir
if ( ! file_exists( $pathym ) ) {
if ( ! @ mkdir( $pathym ) )
return array('error' => "Unable to create directory $pathym. Is $pathy writable?");
@ chmod( $pathym, $dir_perms );
}
// Make sure we have an uploads dir
if ( ! wp_mkdir_p( $dir ) ) {
$message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), $dir);
return array('error' => $message);
}
$uploads = array('path' => $dir, 'url' => $url, 'error' => false);
$uploads = array('path' => $pathym, 'url' => get_option('siteurl') . "/$dir/$y/$m", 'error' => false);
return apply_filters('upload_dir', $uploads);
}
@@ -924,25 +891,10 @@ function wp_upload_bits($name, $type, $bits) {
$number = '';
$filename = $name;
$path_parts = pathinfo($filename);
$ext = $path_parts['extension'];
if ( empty($ext) )
$ext = '';
else
$ext = ".$ext";
while ( file_exists($upload['path'] . "/$filename") ) {
if ( '' == "$number$ext" )
$filename = $filename . ++$number . $ext;
else
$filename = str_replace("$number$ext", ++$number . $ext, $filename);
}
$new_file = $upload['path'] . "/$filename";
if ( ! wp_mkdir_p( dirname($new_file) ) ) {
$message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), dirname($new_file));
return array('error' => $message);
}
while ( file_exists($upload['path'] . "/$filename") )
$filename = str_replace("$number.$ext", ++$number . ".$ext", $filename);
$new_file = $uploads['path'] . "/$filename";
$ifp = @ fopen($new_file, 'wb');
if ( ! $ifp )
return array('error' => "Could not write file $new_file.");
@@ -951,14 +903,13 @@ function wp_upload_bits($name, $type, $bits) {
fclose($ifp);
// Set correct file permissions
$stat = @ stat(dirname($new_file));
$perms = $stat['mode'] & 0007777;
$perms = $perms & 0000666;
$perms = $stat['mode'] & 0000777;
@ chmod($new_file, $perms);
// Compute the URL
$url = $upload['url'] . "/$filename";
return array('file' => $new_file, 'url' => $url, 'error' => false);
return array('file' => $new_file, 'url' => $url);
}
?>

View File

@@ -71,10 +71,10 @@ function date_i18n($dateformatstring, $unixtimestamp) {
$dateweekday = $weekday[date('w', $i)];
$dateweekday_abbrev = $weekday_abbrev[$dateweekday];
$dateformatstring = ' '.$dateformatstring;
$dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\])F/", "\${1}".backslashit($datemonth), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
$dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
}
$j = @date($dateformatstring, $i);
@@ -355,13 +355,12 @@ function update_option($option_name, $newvalue) {
// If the new and old values are the same, no need to update.
$oldvalue = get_option($option_name);
if ( $newvalue == $oldvalue ) {
if ( $newvalue == $oldvalue )
return false;
}
if ( false === $oldvalue ) {
add_option($option_name, $newvalue);
return true;
if ( false === $oldvalue ) {
add_option($option_name, $newvalue);
return true;
}
if ( is_array($newvalue) || is_object($newvalue) )
@@ -372,11 +371,7 @@ function update_option($option_name, $newvalue) {
$newvalue = $wpdb->escape($newvalue);
$option_name = $wpdb->escape($option_name);
$wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'");
if ( $wpdb->rows_affected == 1 ) {
do_action("update_option_{$option_name}", $oldvalue, $newvalue);
return true;
}
return false;
return true;
}
function update_user_option( $user_id, $option_name, $newvalue, $global = false ) {
@@ -460,7 +455,7 @@ AND meta_key = '$key'");
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
AND meta_key = '$key' AND meta_value = '$value'");
$cache_key = $post_meta_cache['$post_id'][$key];
if ($cache_key) foreach ( $cache_key as $index => $data )
foreach ( $cache_key as $index => $data )
if ( $data == $value )
unset($post_meta_cache['$post_id'][$key][$index]);
}
@@ -477,7 +472,7 @@ function get_post_meta($post_id, $key, $single = false) {
if ( $single ) {
return maybe_unserialize( $post_meta_cache[$post_id][$key][0] );
} else {
return maybe_unserialize( $post_meta_cache[$post_id][$key] );
return maybe_unserialize( $post_meta_cache[$post_id][$key][0] );
}
}
@@ -593,9 +588,6 @@ function &get_post(&$post, $output = OBJECT) {
}
}
if ( defined(WP_IMPORTING) )
unset($post_cache);
if ( $output == OBJECT ) {
return $_post;
} elseif ( $output == ARRAY_A ) {
@@ -814,7 +806,7 @@ function get_all_category_ids() {
function get_all_page_ids() {
global $wpdb;
if ( ! $page_ids = wp_cache_get('all_page_ids', 'pages') ) {
if ( ! $page_ids = wp_cache_get('all_page_ids', 'posts') ) {
$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status='static'");
wp_cache_add('all_page_ids', $page_ids, 'pages');
}
@@ -929,7 +921,7 @@ function make_url_footnote($content) {
$link_url = $matches[2][$i];
$link_text = $matches[4][$i];
$content = str_replace($link_match, $link_text.' '.$link_number, $content);
$link_url = ((strtolower(substr($link_url,0,7)) != 'http://') && (strtolower(substr($link_url,0,8)) != 'https://')) ? get_settings('home') . $link_url : $link_url;
$link_url = ((strtolower(substr($link_url,0,7)) != 'http://')||(strtolower(substr($link_url,0,7)) != 'https://')) ? get_settings('home') . $link_url : $link_url;
$links_summary .= "\n".$link_number.' '.$link_url;
}
$content = strip_tags($content);
@@ -1001,9 +993,6 @@ function spawn_pinger() {
if ( $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_pingme' OR meta_key = '_encloseme' LIMIT 1") )
$doping = true;
if ( substr(php_sapi_name(), 0, 3) == 'cgi' )
return $doping;
if ( $doping ) {
$ping_url = get_settings('siteurl') .'/wp-admin/execute-pings.php';
$parts = parse_url($ping_url);
@@ -1688,11 +1677,6 @@ function get_stylesheet_uri() {
}
function get_template() {
$template = get_settings('template');
if (!file_exists(get_theme_root() . "/$template")) { //works for dirs too
update_option('template', 'default');
update_option('stylesheet', 'default');
}
return apply_filters('template', get_settings('template'));
}
@@ -1798,12 +1782,11 @@ function get_themes() {
$template = $theme_data['Template'];
$stylesheet = dirname($theme_file);
foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext) {
if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) {
$screenshot = "screenshot.$ext";
break;
}
}
$screenshot = glob("$theme_root/$stylesheet/screenshot.*");
if ( !empty( $screenshot ) )
$screenshot = basename( $screenshot[0] );
else
$screenshot = false;
if ( empty($name) ) {
$name = dirname($theme_file);
@@ -2050,10 +2033,7 @@ add_query_arg(associative_array, oldquery_or_uri)
function add_query_arg() {
$ret = '';
if ( is_array(func_get_arg(0)) ) {
if ( @func_num_args() < 2 )
$uri = $_SERVER['REQUEST_URI'];
else
$uri = @func_get_arg(1);
$uri = @func_get_arg(1);
} else {
if ( @func_num_args() < 3 )
$uri = $_SERVER['REQUEST_URI'];
@@ -2219,10 +2199,9 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
if ( is_array($meta_value) || is_object($meta_value) )
$meta_value = serialize($meta_value);
$meta_value = trim( $meta_value );
if (empty($meta_value)) {
delete_usermeta($user_id, $meta_key);
}
if ( '' == $meta_value )
return false;
$cur = $wpdb->get_row("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
if ( !$cur ) {

View File

@@ -1,30 +1,22 @@
// UK lang variables
if (navigator.userAgent.indexOf('Mac OS') != -1) {
// Mac OS browsers use Ctrl to hit accesskeys
var metaKey = 'Ctrl';
}
else {
var metaKey = 'Alt';
}
tinyMCELang['lang_bold_desc'] = 'Bold (' + metaKey + '+b)';
tinyMCELang['lang_italic_desc'] = 'Italic (' + metaKey + '+i)';
tinyMCELang['lang_bold_desc'] = 'Bold (Alt+b)';
tinyMCELang['lang_italic_desc'] = 'Italic (Alt+i)';
tinyMCELang['lang_underline_desc'] = 'Underline';
tinyMCELang['lang_striketrough_desc'] = 'Striketrough (' + metaKey + '-d)';
tinyMCELang['lang_justifyleft_desc'] = 'Align left (' + metaKey + '-f)';
tinyMCELang['lang_justifycenter_desc'] = 'Align center (' + metaKey + '-c)';
tinyMCELang['lang_justifyright_desc'] = 'Align right (' + metaKey + '-r)';
tinyMCELang['lang_striketrough_desc'] = 'Striketrough (Alt-d)';
tinyMCELang['lang_justifyleft_desc'] = 'Align left (Alt-f)';
tinyMCELang['lang_justifycenter_desc'] = 'Align center (Alt-c)';
tinyMCELang['lang_justifyright_desc'] = 'Align right (Alt-r)';
tinyMCELang['lang_justifyfull_desc'] = 'Align full';
tinyMCELang['lang_bullist_desc'] = 'Unordered list (' + metaKey + '-l)';
tinyMCELang['lang_numlist_desc'] = 'Ordered list (' + metaKey + '-o)';
tinyMCELang['lang_outdent_desc'] = 'Outdent (' + metaKey + '-w)';
tinyMCELang['lang_indent_desc'] = 'Indent/Blockquote (' + metaKey + '-q)';
tinyMCELang['lang_undo_desc'] = 'Undo (' + metaKey + '-u)';
tinyMCELang['lang_redo_desc'] = 'Redo (' + metaKey + '-y)';
tinyMCELang['lang_link_desc'] = 'Insert/edit link (' + metaKey + '-a)';
tinyMCELang['lang_unlink_desc'] = 'Unlink (' + metaKey + '-s)';
tinyMCELang['lang_image_desc'] = 'Insert/edit image (' + metaKey + '-m)';
tinyMCELang['lang_bullist_desc'] = 'Unordered list (Alt-l)';
tinyMCELang['lang_numlist_desc'] = 'Ordered list (Alt-o)';
tinyMCELang['lang_outdent_desc'] = 'Outdent (Alt-w)';
tinyMCELang['lang_indent_desc'] = 'Indent/Blockquote (Alt-q)';
tinyMCELang['lang_undo_desc'] = 'Undo (Alt-u)';
tinyMCELang['lang_redo_desc'] = 'Redo (Alt-y)';
tinyMCELang['lang_link_desc'] = 'Insert/edit link (Alt-a)';
tinyMCELang['lang_unlink_desc'] = 'Unlink (Alt-s)';
tinyMCELang['lang_image_desc'] = 'Insert/edit image (Alt-m)';
tinyMCELang['lang_cleanup_desc'] = 'Cleanup messy code';
tinyMCELang['lang_focus_alert'] = 'A editor instance must be focused before using this command.';
tinyMCELang['lang_edit_confirm'] = 'Do you want to use the WYSIWYG mode for this textarea?';

View File

@@ -1,15 +1,7 @@
// EN lang variables
if (navigator.userAgent.indexOf('Mac OS') != -1) {
// Mac OS browsers use Ctrl to hit accesskeys
var metaKey = 'Ctrl';
}
else {
var metaKey = 'Alt';
}
tinyMCE.addToLang('',{
wordpress_more_button : 'Split post with More tag (' + metaKey + '-t)',
wordpress_more_button : 'Split post with More tag (Alt-t)',
wordpress_page_button : 'Split post with Page tag',
wordpress_more_alt : 'More...',
wordpress_page_alt : '...page...'

View File

@@ -76,32 +76,15 @@
// Load theme, language pack and theme language packs
$theme = apply_filters('mce_theme', 'advanced');
echo wp_compact_tinymce_js(file_get_contents(realpath("themes/" . $theme . "/editor_template.js")));
// Get the WordPress locale
$locale = get_locale();
$themeLanguageFile = realpath("themes/" . $theme . "/langs/" . $locale . ".js");
if (!file_exists($themeLanguageFile))
$themeLanguageFile = realpath("themes/" . $theme . "/langs/en.js");
echo wp_translate_tinymce_lang(file_get_contents($themeLanguageFile));
$tinymceLanguageFile = realpath("langs/" . $locale . ".js");
if (!file_exists($tinymceLanguageFile))
$tinymceLanguageFile = realpath("langs/en.js");
echo wp_translate_tinymce_lang(file_get_contents($tinymceLanguageFile));
echo wp_translate_tinymce_lang(file_get_contents(realpath("themes/" . $theme . "/langs/en.js")));
echo wp_translate_tinymce_lang(file_get_contents(realpath("langs/en.js")));
// Load all plugins and their language packs
$plugins = apply_filters('mce_plugins', array('wordpress', 'autosave','wphelp'));
$plugins = apply_filters('mce_plugins', array('wordpress', 'autosave', 'wphelp'));
foreach ($plugins as $plugin) {
$pluginFile = realpath("plugins/" . $plugin . "/editor_plugin.js");
$languageFile = realpath("plugins/" . $plugin . "/langs/" . $locale . ".js");
if (!file_exists($languageFile))
$languageFile = realpath("plugins/" . $plugin . "/langs/en.js");
$languageFile = realpath("plugins/" . $plugin . "/langs/en.js");
if ($pluginFile)
echo file_get_contents($pluginFile);
@@ -122,7 +105,7 @@
. 'title[dir<ltr?rtl|lang],tr[abbr|align<center?char?justify?left?right|bgcolor|char|charoff|class|rowspan|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|valign<baseline?bottom?middle?top],tt[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],u[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],ul[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type],var[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title]';
else // Use a much smaller set
$valid_elements = '-a[id|href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align|dir],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote[dir],-table[border|cellspacing|cellpadding|width|height|class|align|dir],thead[class|rowspan|width|height|align|valign|dir],tr[class|rowspan|width|height|align|valign|dir],th[dir|class|colspan|rowspan|width|height|align|valign|scope],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],-code[class],-address,-h1[class|align|dir],-h2[class|align|dir],-h3[class|align|dir],-h4[class|align|dir],-h5[class|align|dir],-h6[class|align|dir],hr';
$valid_elements = apply_filters('mce_valid_elements', $valid_elements);
$valid_elements = apply_filters('mce_valid_elements', $valid_elements);
$plugins = implode($plugins, ',');
$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright' ,'separator', 'link', 'unlink', 'image', 'wordpress', 'separator', 'undo', 'redo', 'code', 'wphelp'));
$mce_buttons = implode($mce_buttons, ',');
@@ -157,7 +140,6 @@ initArray = {
convert_newlines_to_brs : false,
remove_linebreaks : true,
save_callback : "wp_save_callback",
document_base_url : "<?php echo trailingslashit(get_bloginfo('home')); ?>",
valid_elements : "<?php echo $valid_elements; ?>",
<?php do_action('mce_options'); ?>
plugins : "<?php echo $plugins; ?>"

View File

@@ -77,7 +77,10 @@ function wp_kses_split($string, $allowed_html, $allowed_protocols)
# matches stray ">" characters.
###############################################################################
{
return preg_replace('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%e',
return preg_replace('%(<'.# EITHER: <
'[^>]*'.# things that aren't >
'(>|$)'.# > or end of string
'|>)%e', # OR: just a >
"wp_kses_split2('\\1', \$allowed_html, ".'$allowed_protocols)', $string);
} # function wp_kses_split
@@ -95,16 +98,6 @@ function wp_kses_split2($string, $allowed_html, $allowed_protocols)
return '&gt;';
# It matched a ">" character
if (preg_match('%^<!--(.*?)(-->)?$%', $string, $matches)) {
$string = str_replace(array('<!--', '-->'), '', $matches[1]);
while ( $string != $newstring = wp_kses($string, $allowed_html, $allowed_protocols) )
$string = $newstring;
if ( $string == '' )
return '';
return "<!--{$string}-->";
}
# Allow HTML comments
if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches))
return '';
# It's seriously malformed
@@ -530,17 +523,9 @@ function kses_init_filters() {
function kses_init() {
global $current_user;
remove_filter('pre_comment_author', 'wp_filter_kses');
remove_filter('pre_comment_content', 'wp_filter_kses');
remove_filter('content_save_pre', 'wp_filter_post_kses');
remove_filter('title_save_pre', 'wp_filter_kses');
if (! defined('XMLRPC_REQUEST') )
get_currentuserinfo();
get_currentuserinfo(); // set $current_user
if (current_user_can('unfiltered_html') == false)
kses_init_filters();
}
add_action('init', 'kses_init');
add_action('set_current_user', 'kses_init');
?>

View File

@@ -3,38 +3,11 @@
/* These functions can be replaced via plugins. They are loaded after
plugins are loaded. */
if ( !function_exists('set_current_user') ) :
function set_current_user($id, $name = '') {
global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
$current_user = '';
$current_user = new WP_User($id, $name);
$userdata = get_userdatabylogin($user_login);
$user_login = $userdata->user_login;
$user_level = $userdata->user_level;
$user_ID = $userdata->ID;
$user_email = $userdata->user_email;
$user_url = $userdata->user_url;
$user_pass_md5 = md5($userdata->user_pass);
$user_identity = $userdata->display_name;
do_action('set_current_user');
return $current_user;
}
endif;
if ( !function_exists('get_currentuserinfo') ) :
function get_currentuserinfo() {
global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
return false;
if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) {
$current_user = new WP_User(0);
@@ -86,14 +59,6 @@ function get_userdata( $user_id ) {
} // end foreach
} //end if
// For backwards compat.
if ( isset($user->first_name) )
$user->user_firstname = $user->first_name;
if ( isset($user->last_name) )
$user->user_lastname = $user->last_name;
if ( isset($user->description) )
$user->user_description = $user->description;
wp_cache_add($user_id, $user, 'users');
wp_cache_add($user->user_login, $user, 'userlogins');
@@ -139,14 +104,6 @@ function get_userdatabylogin($user_login) {
}
}
// For backwards compat.
if ( isset($user->first_name) )
$user->user_firstname = $user->first_name;
if ( isset($user->last_name) )
$user->user_lastname = $user->last_name;
if ( isset($user->description) )
$user->user_description = $user->description;
wp_cache_add($user->ID, $user, 'users');
wp_cache_add($user->user_login, $user, 'userlogins');
@@ -223,16 +180,6 @@ function auth_redirect() {
}
endif;
if ( !function_exists('check_admin_referer') ) :
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');
}
endif;
// Cookie safe redirect. Works around IIS Set-Cookie bug.
// http://support.microsoft.com/kb/q176113/
if ( !function_exists('wp_redirect') ) :
@@ -352,9 +299,9 @@ function wp_notify_postauthor($comment_id, $comment_type='') {
if ( isset($reply_to) )
$message_headers .= $reply_to . "\n";
$notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
$subject = apply_filters('comment_notification_subject', $subject, $comment_id);
$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
$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);
@wp_mail($user->user_email, $subject, $notify_message, $message_headers);
@@ -395,8 +342,8 @@ function wp_notify_moderator($comment_id) {
$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, $comment_id);
$subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
$notify_message = apply_filters('comment_moderation_text', $notify_message);
$subject = apply_filters('comment_moderation_subject', $subject);
@wp_mail($admin_email, $subject, $notify_message);

View File

@@ -10,16 +10,6 @@ function username_exists( $username ) {
return null;
}
function validate_username( $username ) {
$name = sanitize_user($username, true);
$valid = true;
if ( $name != $username )
$valid = false;
return apply_filters('validate_username', $valid, $username);
}
function wp_insert_user($userdata) {
global $wpdb;
@@ -34,8 +24,6 @@ function wp_insert_user($userdata) {
$user_pass = md5($user_pass);
}
$user_login = sanitize_user($user_login, true);
if ( empty($user_nicename) )
$user_nicename = sanitize_title( $user_login );

View File

@@ -482,8 +482,7 @@ function get_calendar($daylength = 1) {
if ( $previous ) {
echo "\n\t\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' .
get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($previous->month, 2)],
date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $month_abbrev[$month[zeroise($previous->month, 2)]] . '</a></td>';
get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($previous->month, 2)], date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $month_abbrev[$month[zeroise($previous->month, 2)]] . '</a></td>';
} else {
echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
}
@@ -492,8 +491,8 @@ function get_calendar($daylength = 1) {
if ( $next ) {
echo "\n\t\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .
get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($next->month, 2)],
date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $month_abbrev[$month[zeroise($next->month, 2)]] . ' &raquo;</a></td>';
get_month_link($next->year, $next->month) . '" title="View posts for ' . $month[zeroise($next->month, 2)] . ' ' .
date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . $month_abbrev[$month[zeroise($next->month, 2)]] . ' &raquo;</a></td>';
} else {
echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
}
@@ -701,7 +700,7 @@ function the_weekday_date($before='',$after='') {
}
function rsd_link() {
echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('url') . "/xmlrpc.php?rsd\" />\n";
}
?>

View File

@@ -205,10 +205,13 @@ function get_feed_link($feed='rss2') {
}
function edit_post_link($link = 'Edit This', $before = '', $after = '') {
global $post;
global $user_ID, $post;
if ( ! current_user_can('edit_post', $post->ID) )
get_currentuserinfo();
if ( !user_can_edit_post($user_ID, $post->ID) ) {
return;
}
if ( is_attachment() )
return;
@@ -220,9 +223,11 @@ function edit_post_link($link = 'Edit This', $before = '', $after = '') {
}
function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
global $post, $comment;
global $user_ID, $post, $comment;
if ( ! current_user_can('edit_post', $post->ID) )
get_currentuserinfo();
if ( !user_can_edit_post_comments($user_ID, $post->ID) )
return;
$location = get_settings('siteurl') . "/wp-admin/post.php?action=editcomment&amp;comment=$comment->comment_ID";
@@ -377,7 +382,7 @@ function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat=
function get_pagenum_link($pagenum = 1) {
global $wp_rewrite;
$qstr = wp_specialchars($_SERVER['REQUEST_URI']);
$qstr = $_SERVER['REQUEST_URI'];
$page_querystring = "paged";
$page_modstring = "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="password" size="20" /></label> <input type="submit" name="Submit" value="Submit" /></p>
</form>
';
return $output;
@@ -193,61 +193,58 @@ Post-meta: Custom per-post fields.
function get_post_custom( $post_id = 0 ) {
global $id, $post_meta_cache, $wpdb;
if ( $post_id )
$id = $post_id;
if ( isset($post_meta_cache[$id]) ) {
return $post_meta_cache[$id];
} else {
if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = '$id' ORDER BY post_id, meta_key", ARRAY_A) ) {
// Change from flat structure to hierarchical:
$post_meta_cache = array();
foreach ( $meta_list as $metarow ) {
$mpid = $metarow['post_id'];
$mkey = $metarow['meta_key'];
$mval = $metarow['meta_value'];
if ( ! $post_id )
$post_id = $id;
// Force subkeys to be array type:
if ( !isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]) )
$post_meta_cache[$mpid] = array();
if ( !isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]) )
$post_meta_cache[$mpid]["$mkey"] = array();
if ( isset($post_meta_cache[$post_id]) )
return $post_meta_cache[$post_id];
if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = '$post_id' ORDER BY post_id, meta_key", ARRAY_A) ) {
// Change from flat structure to hierarchical:
$post_meta_cache = array();
foreach ( $meta_list as $metarow ) {
$mpid = $metarow['post_id'];
$mkey = $metarow['meta_key'];
$mval = $metarow['meta_value'];
// Force subkeys to be array type:
if ( !isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]) )
$post_meta_cache[$mpid] = array();
if ( !isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]) )
$post_meta_cache[$mpid]["$mkey"] = array();
// Add a value to the current pid/key:
$post_meta_cache[$mpid][$mkey][] = $mval;
}
// Add a value to the current pid/key:
$post_meta_cache[$mpid][$mkey][] = $mval;
}
return $post_meta_cache[$mpid];
}
}
}
function get_post_custom_keys() {
$custom = get_post_custom();
global $id, $post_meta_cache;
if ( ! is_array($custom) )
if ( !is_array($post_meta_cache[$id]) )
return;
if ( $keys = array_keys($custom) )
if ( $keys = array_keys($post_meta_cache[$id]) )
return $keys;
}
function get_post_custom_values( $key = '' ) {
$custom = get_post_custom();
function get_post_custom_values($key='') {
global $id, $post_meta_cache;
return $custom[$key];
return $post_meta_cache[$id][$key];
}
function post_custom( $key = '' ) {
$custom = get_post_custom();
global $id, $post_meta_cache;
if ( 1 == count($custom[$key]) )
return $custom[$key][0];
if ( 1 == count($post_meta_cache[$id][$key]) )
return $post_meta_cache[$id][$key][0];
else
return $custom[$key];
return $post_meta_cache[$id][$key];
}
@@ -258,7 +255,7 @@ function the_meta() {
if ( $keys = get_post_custom_keys() ) {
echo "<ul class='post-meta'>\n";
foreach ( $keys as $key ) {
$values = array_map('trim', get_post_custom_values($key));
$values = array_map('trim',$post_meta_cache[$id][$key]);
$value = implode($values,', ');
echo "<li><span class='post-meta-key'>$key:</span> $value</li>\n";
}

View File

@@ -7,45 +7,45 @@ if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
} else if ( is_trackback() ) {
include(ABSPATH . '/wp-trackback.php');
exit;
} else if ( is_404() && $template = get_404_template() ) {
include($template);
} else if ( is_404() && get_404_template() ) {
include(get_404_template());
exit;
} else if ( is_search() && $template = get_search_template() ) {
include($template);
} else if ( is_search() && get_search_template() ) {
include(get_search_template());
exit;
} else if ( is_home() && $template = get_home_template() ) {
include($template);
} else if ( is_home() && get_home_template() ) {
include(get_home_template());
exit;
} else if ( is_attachment() && $template = get_attachment_template() ) {
include($template);
} else if ( is_attachment() && get_attachment_template() ) {
include(get_attachment_template());
exit;
} else if ( is_single() && $template = get_single_template() ) {
} else if ( is_single() && get_single_template() ) {
if ( is_attachment() )
add_filter('the_content', 'prepend_attachment');
include($template);
include(get_single_template());
exit;
} else if ( is_page() && $template = get_page_template() ) {
} else if ( is_page() && get_page_template() ) {
if ( is_attachment() )
add_filter('the_content', 'prepend_attachment');
include($template);
include(get_page_template());
exit;
} else if ( is_category() && $template = get_category_template()) {
include($template);
} else if ( is_category() && get_category_template()) {
include(get_category_template());
exit;
} else if ( is_author() && $template = get_author_template() ) {
include($template);
} else if ( is_author() && get_author_template() ) {
include(get_author_template());
exit;
} else if ( is_date() && $template = get_date_template() ) {
include($template);
} else if ( is_date() && get_date_template() ) {
include(get_date_template());
exit;
} else if ( is_archive() && $template = get_archive_template() ) {
include($template);
} else if ( is_archive() && get_archive_template() ) {
include(get_archive_template());
exit;
} else if ( is_comments_popup() && $template = get_comments_popup_template() ) {
include($template);
} else if ( is_comments_popup() && get_comments_popup_template() ) {
include(get_comments_popup_template());
exit;
} else if ( is_paged() && $template = get_paged_template() ) {
include($template);
} else if ( is_paged() && get_paged_template() ) {
include(get_paged_template());
exit;
} else if ( file_exists(TEMPLATEPATH . "/index.php") ) {
if ( is_attachment() )
@@ -64,4 +64,4 @@ if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
}
}
?>
?>

View File

@@ -1,6 +1,10 @@
<?php
// On which page are we ?
$PHP_SELF = $_SERVER['PHP_SELF'];
if ( empty($PHP_SELF) )
$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
if (preg_match('#([^/]+.php)#', $PHP_SELF, $self_matches)) {
$pagenow = $self_matches[1];
} else if (strstr($PHP_SELF, '?')) {

View File

@@ -2,7 +2,7 @@
// This just holds the version number, in a separate file so we can bump it without cluttering the SVN
$wp_version = '2.0.2';
$wp_db_version = 3437;
$wp_version = '2.0';
$wp_db_version = 3308;
?>

View File

@@ -12,11 +12,13 @@ function get_locale() {
return $locale;
// WPLANG is defined in wp-config.
if (defined('WPLANG'))
$locale = WPLANG;
if (defined('WPLANG')) {
$locale = WPLANG;
}
if (empty($locale))
$locale = 'en_US';
if (empty($locale)) {
$locale = 'en_US';
}
$locale = apply_filters('locale', $locale);
@@ -27,20 +29,22 @@ function get_locale() {
function __($text, $domain = 'default') {
global $l10n;
if (isset($l10n[$domain]))
return apply_filters('gettext', $l10n[$domain]->translate($text), $text);
else
if (isset($l10n[$domain])) {
return $l10n[$domain]->translate($text);
} else {
return $text;
}
}
// Echo a translated string.
function _e($text, $domain = 'default') {
global $l10n;
if (isset($l10n[$domain]))
echo apply_filters('gettext', $l10n[$domain]->translate($text), $text);
else
if (isset($l10n[$domain])) {
echo $l10n[$domain]->translate($text);
} else {
echo $text;
}
}
// Return the plural form.
@@ -60,13 +64,15 @@ function __ngettext($single, $plural, $number, $domain = 'default') {
function load_textdomain($domain, $mofile) {
global $l10n;
if (isset($l10n[$domain]))
if (isset($l10n[$domain])) {
return;
}
if ( is_readable($mofile))
$input = new CachedFileReader($mofile);
else
if ( is_readable($mofile)) {
$input = new CachedFileReader($mofile);
} else {
return;
}
$l10n[$domain] = new gettext_reader($input);
}

View File

@@ -29,7 +29,6 @@ if ((empty($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
<?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
AND $wpdb->links.link_visible = 'Y'
$sql_cat
ORDER BY $wpdb->linkcategories.cat_name, $wpdb->links.link_name \n";
//echo("<!-- $sql -->");
@@ -52,10 +51,8 @@ FROM $wpdb->links
<outline text="<?php echo wp_specialchars($result->link_name); ?>" type="link" xmlUrl="<?php echo wp_specialchars($result->link_rss); ?>" htmlUrl="<?php echo wp_specialchars($result->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $result->link_updated) echo $result->link_updated; ?>" />
<?php
} // end foreach
?>
</outline>
<?php
} // end if
?>
</body>
</outline>
</body>
</opml>

View File

@@ -188,7 +188,7 @@ default:
do_action('wp_authenticate', array(&$user_login, &$user_pass));
if ( $user_login && $user_pass ) {
if ( $_POST ) {
$user = new WP_User(0, $user_login);
// If the user can't edit posts, send them to their profile.

View File

@@ -61,10 +61,8 @@ for ($i=1; $i <= $count; $i++) :
if (preg_match('/From: /', $line) | preg_match('Reply-To: /', $line)) {
$author=trim($line);
if ( ereg("([a-zA-Z0-9\_\-\.]+@[\a-zA-z0-9\_\-\.]+)", $author , $regs) ) {
$author = $regs[1];
echo "Author = {$author} <p>";
$author = $wpdb->escape($author);
$result = $wpdb->get_row("SELECT ID FROM $wpdb->users WHERE user_email='$author' LIMIT 1");
echo "Author = {$regs[1]} <p>";
$result = $wpdb->get_row("SELECT ID FROM $tableusers WHERE user_email='$regs[1]' ORDER BY ID DESC LIMIT 1");
if (!$result)
$post_author = 1;
else

View File

@@ -25,15 +25,9 @@ case 'register':
$errors['user_email'] = __('<strong>ERROR</strong>: Please type your e-mail address.');
} else if (!is_email($user_email)) {
$errors['user_email'] = __('<strong>ERROR</strong>: The email address isn&#8217;t correct.');
$user_email = '';
}
if ( ! validate_username($user_login) ) {
$errors['user_login'] = __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.');
$user_login = '';
}
if ( username_exists( $user_login ) )
if ( username_exists( $user_login ) )
$errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
/* checking the email isn't already used by another user */
@@ -70,9 +64,9 @@ case 'register':
<div id="login">
<h2><?php _e('Registration Complete') ?></h2>
<p><?php printf(__('Username: %s'), "<strong>" . wp_specialchars($user_login) . "</strong>") ?><br />
<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>" . wp_specialchars($user_email) . "</strong>") ?></p>
<?php printf(__('E-mail: %s'), "<strong>$user_email</strong>") ?></p>
<p class="submit"><a href="wp-login.php"><?php _e('Login'); ?> &raquo;</a></p>
</div>
</body>
@@ -113,8 +107,8 @@ default:
<?php endif; ?>
<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" value="<?php echo wp_specialchars($user_login); ?>" /><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" value="<?php echo wp_specialchars($user_email); ?>" /></p>
<label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" value="<?php echo $user_login; ?>" /><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" value="<?php echo $user_email; ?>" /></p>
<p><?php _e('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>

View File

@@ -35,17 +35,13 @@ if ( empty( $_SERVER['REQUEST_URI'] ) ) {
}
// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
if ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 )
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
// Fix for Dreamhost and other PHP as CGI hosts
if ( strstr( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) )
unset($_SERVER['PATH_INFO']);
// Fix empty PHP_SELF
$PHP_SELF = $_SERVER['PHP_SELF'];
if ( empty($PHP_SELF) )
$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
if ( !(phpversion() >= '4.1') )
die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' );
@@ -108,11 +104,14 @@ if ( file_exists(ABSPATH . 'wp-content/object-cache.php') )
else
require (ABSPATH . WPINC . '/cache.php');
// To disable persistant caching, add the below line to your wp-config.php file, uncommented of course.
// define('DISABLE_CACHE', true);
// For now, disable persistent caching by default. To enable, comment out
// the following line.
//define('DISABLE_CACHE', true);
wp_cache_init();
$wp_filters = array();
require (ABSPATH . WPINC . '/functions.php');
require (ABSPATH . WPINC . '/default-filters.php');
require_once (ABSPATH . WPINC . '/wp-l10n.php');
@@ -162,6 +161,8 @@ if ( !defined('COOKIE_DOMAIN') )
require (ABSPATH . WPINC . '/vars.php');
do_action('core_files_loaded');
// Check for hacks file if the option is enabled
if (get_settings('hack_file')) {
if (file_exists(ABSPATH . '/my-hacks.php'))
@@ -190,6 +191,7 @@ if ( get_magic_quotes_gpc() ) {
$_GET = stripslashes_deep($_GET );
$_POST = stripslashes_deep($_POST );
$_COOKIE = stripslashes_deep($_COOKIE);
$_SERVER = stripslashes_deep($_SERVER);
}
// Escape with wpdb.
@@ -201,6 +203,7 @@ $_SERVER = add_magic_quotes($_SERVER);
$wp_query = new WP_Query();
$wp_rewrite = new WP_Rewrite();
$wp = new WP();
$wp_roles = new WP_Roles();
define('TEMPLATEPATH', get_template_directory());
@@ -215,8 +218,8 @@ if ( file_exists(TEMPLATEPATH . "/functions.php") )
include(TEMPLATEPATH . "/functions.php");
function shutdown_action_hook() {
do_action('shutdown');
wp_cache_close();
do_action('shutdown');
}
register_shutdown_function('shutdown_action_hook');

View File

@@ -69,9 +69,9 @@ if ( !empty($tb_url) && !empty($title) && !empty($tb_url) ) {
$title = wp_specialchars( strip_tags( $title ) );
$excerpt = strip_tags($excerpt);
if ( function_exists('mb_strcut') ) { // For international trackbacks
$excerpt = mb_strcut($excerpt, 0, 252, get_settings('blog_charset')) . '...';
$title = mb_strcut($title, 0, 250, get_settings('blog_charset')) . '...';
if ( function_exists('mb_substr') ) { // For international trackbacks
$excerpt = mb_substr($excerpt, 0, 252, get_settings('blog_charset')) . '...';
$title = mb_substr($title, 0, 250, get_settings('blog_charset')) . '...';
} else {
$excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt;
$title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;

View File

@@ -1,13 +1,7 @@
<?php
define('XMLRPC_REQUEST', true);
// Some browser-embedded clients send cookies. We don't want them.
$_COOKIE = array();
# fix for mozBlog and other cases where '<?xml' isn't on the very first line
if ( isset($HTTP_RAW_POST_DATA) )
$HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
$HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
include('./wp-config.php');
@@ -185,8 +179,8 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
}
set_current_user(0, $user_login);
$is_admin = current_user_can('level_8');
$user = new WP_User(0, $user_login);
$is_admin = $user->has_cap('level_8');
$struct = array(
'isAdmin' => $is_admin,
@@ -323,8 +317,8 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
}
set_current_user(0, $user_login);
if ( !current_user_can('edit_themes') ) {
$user = new WP_User(0, $user_login);
if ( !$user->has_cap('edit_themes') ) {
return new IXR_Error(401, 'Sorry, this user can not edit the template.');
}
@@ -358,8 +352,8 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
}
set_current_user(0, $user_login);
if ( !current_user_can('edit_themes') ) {
$user = new WP_User(0, $user_login);
if ( !$user->has_cap('edit_themes') ) {
return new IXR_Error(401, 'Sorry, this user can not edit the template.');
}
@@ -396,8 +390,9 @@ class wp_xmlrpc_server extends IXR_Server {
}
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
$user = set_current_user(0, $user_login);
if ( !current_user_can($cap) )
$user = new WP_User(0, $user_login);
if ( !$user->has_cap($cap) )
return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
$post_status = ($publish) ? 'publish' : 'draft';
@@ -450,8 +445,8 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($actual_post);
set_current_user(0, $user_login);
if ( !current_user_can('edit_post', $post_ID) )
$user = new WP_User(0, $user_login);
if ( !$user->has_cap('edit_post', $post_ID) )
return new IXR_Error(401, 'Sorry, you do not have the right to edit this post.');
extract($actual_post);
@@ -494,8 +489,8 @@ class wp_xmlrpc_server extends IXR_Server {
return new IXR_Error(404, 'Sorry, no such post.');
}
set_current_user(0, $user_login);
if ( !current_user_can('edit_post', $post_ID) )
$user = new WP_User(0, $user_login);
if ( !$user->has_cap('edit_post', $post_ID) )
return new IXR_Error(401, 'Sorry, you do not have the right to delete this post.');
$result = wp_delete_post($post_ID);
@@ -530,8 +525,8 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
}
$user = set_current_user(0, $user_login);
if ( !current_user_can('publish_posts') )
$user = new WP_User(0, $user_login);
if ( !$user->has_cap('publish_posts') )
return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
$post_author = $user->ID;
@@ -610,8 +605,8 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
}
set_current_user(0, $user_login);
if ( !current_user_can('edit_post', $post_ID) )
$user = new WP_User(0, $user_login);
if ( !$user->has_cap('edit_post', $post_ID) )
return new IXR_Error(401, 'Sorry, you can not edit this post.');
$postdata = wp_get_single_post($post_ID, ARRAY_A);
@@ -849,15 +844,16 @@ class wp_xmlrpc_server extends IXR_Server {
if ( !$this->login_pass_ok($user_login, $user_pass) )
return $this->error;
set_current_user(0, $user_login);
if ( !current_user_can('upload_files') ) {
$user = new WP_User(0, $user_login);
if ( !$user->has_cap('upload_files') ) {
logIO('O', '(MW) User does not have upload_files capability');
$this->error = new IXR_Error(401, 'You are not allowed to upload files to this site.');
return $this->error;
}
$upload = wp_upload_bits($name, $type, $bits);
if ( ! empty($upload['error']) ) {
if ( $upload['error'] !== false ) {
logIO('O', '(MW) Could not write file '.$name);
return new IXR_Error(500, 'Could not write file '.$name);
}
@@ -988,8 +984,8 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
}
set_current_user(0, $user_login);
if ( !current_user_can('edit_post', $post_ID) )
$user = new WP_User(0, $user_login);
if ( !$user->has_cap('edit_post', $post_ID) )
return new IXR_Error(401, 'Sorry, you can not edit this post.');
foreach($categories as $cat) {
@@ -1070,8 +1066,8 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
}
set_current_user(0, $user_login);
if ( !current_user_can('edit_post', $post_ID) )
$user = new WP_User(0, $user_login);
if ( !$user->has_cap('edit_post', $post_ID) )
return new IXR_Error(401, 'Sorry, you can not edit this post.');
$postdata = wp_get_single_post($post_ID,ARRAY_A);
@@ -1286,4 +1282,4 @@ class wp_xmlrpc_server extends IXR_Server {
$wp_xmlrpc_server = new wp_xmlrpc_server();
?>
?>